From 99ebbab100ade14e925e8c5e07b759ef5bbf1499 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Mon, 14 Mar 2022 09:06:29 +0100 Subject: [PATCH] Custom scripts --- src/constants/TelemetryEvent.ts | 14 +++++++++++--- src/helpers/CustomScript.ts | 7 ++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/constants/TelemetryEvent.ts b/src/constants/TelemetryEvent.ts index 1c1dae4b..a2627123 100644 --- a/src/constants/TelemetryEvent.ts +++ b/src/constants/TelemetryEvent.ts @@ -1,18 +1,22 @@ export const TelemetryEvent = { activate: 'activate', initialization: 'initialization', + registerFolder: 'registerFolder', + unregisterFolder: 'unregisterFolder', + promoteSettings: 'promoteSettings', + + // Commands openContentDashboard: 'openContentDashboard', openMediaDashboard: 'openMediaDashboard', openDataDashboard: 'openDataDashboard', openSnippetsDashboard: 'openSnippetsDashboard', closeDashboard: 'closeDashboard', + + // Other actions generateSlug: 'generateSlug', createContentFromTemplate: 'createContentFromTemplate', createContentFromContentType: 'createContentFromContentType', - registerFolder: 'registerFolder', - unregisterFolder: 'unregisterFolder', addMediaFolder: 'addMediaFolder', - promoteSettings: 'promoteSettings', openPreview: 'openPreview', uploadMedia: 'uploadMedia', refreshMedia: 'refreshMedia', @@ -21,6 +25,10 @@ export const TelemetryEvent = { updateMediaMetadata: 'updateMediaMetadata', openExplorerView: 'openExplorerView', + // Custom scripts + runCustomScript: 'runCustomScript', + runMediaScript: 'runMediaScript', + // Webviews webviewWelcomeScreen: 'webviewWelcomeScreen', webviewMediaView: 'webviewMediaView', diff --git a/src/helpers/CustomScript.ts b/src/helpers/CustomScript.ts index 5ac4b9ea..719b3915 100644 --- a/src/helpers/CustomScript.ts +++ b/src/helpers/CustomScript.ts @@ -1,6 +1,6 @@ import { CustomScript as ICustomScript, ScriptType } from '../models/PanelSettings'; import { window, env as vscodeEnv, ProgressLocation } from 'vscode'; -import { ArticleHelper } from '.'; +import { ArticleHelper, Telemetry } from '.'; import { Folders } from '../commands/Folders'; import { exec } from 'child_process'; import * as os from 'os'; @@ -10,6 +10,7 @@ import ContentProvider from '../providers/ContentProvider'; import { Dashboard } from '../commands/Dashboard'; import { DashboardCommand } from '../dashboardWebView/DashboardCommand'; import { ParsedFrontMatter } from '../parsers'; +import { TelemetryEvent } from '../constants/TelemetryEvent'; export class CustomScript { @@ -20,8 +21,12 @@ export class CustomScript { const wsPath = wsFolder.fsPath; if (script.type === ScriptType.MediaFile || script.type === ScriptType.MediaFolder) { + Telemetry.send(TelemetryEvent.runMediaScript); + CustomScript.runMediaScript(wsPath, path, script); } else { + Telemetry.send(TelemetryEvent.runCustomScript); + if (script.bulk) { // Run script on all files CustomScript.bulkRun(wsPath, script);