From 00bbb3879f7a7e8b4f764331fb180633e1510996 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 18 Jul 2024 17:08:16 +0200 Subject: [PATCH] Telemetry removal --- README.beta.md | 13 +--- README.md | 13 +--- package.json | 5 -- src/commands/Article.ts | 4 - src/commands/Chatbot.ts | 5 +- src/commands/Dashboard.ts | 12 +-- src/commands/Folders.ts | 9 +-- src/commands/Preview.ts | 4 - src/commands/Project.ts | 6 +- src/commands/Template.ts | 6 +- src/constants/TelemetryEvent.ts | 56 ------------- src/constants/index.ts | 2 +- src/constants/settings.ts | 2 - src/dashboardWebView/DashboardMessage.ts | 1 - .../components/Contents/Contents.tsx | 6 +- .../components/DataView/DataView.tsx | 6 +- .../components/Media/Media.tsx | 11 +-- .../components/SettingsView/SettingsView.tsx | 6 +- .../components/SnippetsView/Snippets.tsx | 5 -- .../components/TaxonomyView/TaxonomyView.tsx | 6 +- .../components/UnknownView/UnknownView.tsx | 5 -- .../components/WelcomeView/WelcomeScreen.tsx | 5 +- src/extension.ts | 5 +- src/helpers/ContentType.ts | 11 +-- src/helpers/CustomScript.ts | 7 +- src/helpers/SettingsHelper.ts | 4 - src/helpers/Telemetry.ts | 78 +------------------ src/listeners/dashboard/MediaListener.ts | 9 +-- src/listeners/dashboard/SnippetListener.ts | 5 +- src/listeners/dashboard/TelemetryListener.ts | 20 ----- src/listeners/dashboard/index.ts | 1 - src/listeners/general/GitListener.ts | 8 +- src/panelWebView/PanelProvider.ts | 4 +- 33 files changed, 23 insertions(+), 317 deletions(-) delete mode 100644 src/constants/TelemetryEvent.ts delete mode 100644 src/listeners/dashboard/TelemetryListener.ts diff --git a/README.beta.md b/README.beta.md index c9a30b19..6e51946a 100644 --- a/README.beta.md +++ b/README.beta.md @@ -203,18 +203,7 @@ You can open showcase issues for the following things: ## 📊 Telemetry -The Front Matter CMS extension collects telemetry data to help us build a better understand which features from the CMS are used. The extension respects the `telemetry.enableTelemetry` setting which you can learn more about in the [Visual Studio Code FAQ](https://aka.ms/vscode-remote/telemetry), or you can only disable it for the extension by configuring the `frontMatter.telemetry.disable` setting. - -We only collect the following data: - -- Type of event -- Extension title (main or beta) -- Extension version - -No user-specific data is collected, you can check the telemetry implementation in the following files: - -- [Telemetry class](https://github.com/estruyf/vscode-front-matter/blob/59528a3db01be8d34dc40638e6cf827090e31986/src/helpers/Telemetry.ts) -- [Metrics API](https://github.com/FrontMatter/web-documentation-nextjs/blob/main/pages/api/metrics.ts) +The Front Matter CMS extension only uses telemetry on application crashes. The extension respects the `telemetry.enableTelemetry` setting which you can learn more about in the [Visual Studio Code FAQ](https://aka.ms/vscode-remote/telemetry). For crash reports in the webviews, we make use of Sentry to help us understand what went wrong. This data is only used to fix issues and improve the extension. You can find more information about the Sentry implementation in the following files: diff --git a/README.md b/README.md index 1b90cd3d..f795b9f1 100644 --- a/README.md +++ b/README.md @@ -209,18 +209,7 @@ You can open showcase issues for the following things: ## 📊 Telemetry -The Front Matter CMS extension collects telemetry data to help us build a better understand which features from the CMS are used. The extension respects the `telemetry.enableTelemetry` setting which you can learn more about in the [Visual Studio Code FAQ](https://aka.ms/vscode-remote/telemetry), or you can only disable it for the extension by configuring the `frontMatter.telemetry.disable` setting. - -We only collect the following data: - -- Type of event -- Extension title (main or beta) -- Extension version - -No user-specific data is collected, you can check the telemetry implementation in the following files: - -- [Telemetry class](https://github.com/estruyf/vscode-front-matter/blob/59528a3db01be8d34dc40638e6cf827090e31986/src/helpers/Telemetry.ts) -- [Metrics API](https://github.com/FrontMatter/web-documentation-nextjs/blob/main/pages/api/metrics.ts) +The Front Matter CMS extension only uses telemetry on application crashes. The extension respects the `telemetry.enableTelemetry` setting which you can learn more about in the [Visual Studio Code FAQ](https://aka.ms/vscode-remote/telemetry). For crash reports in the webviews, we make use of Sentry to help us understand what went wrong. This data is only used to fix issues and improve the extension. You can find more information about the Sentry implementation in the following files: diff --git a/package.json b/package.json index fe21bdd6..176b759b 100644 --- a/package.json +++ b/package.json @@ -1985,11 +1985,6 @@ }, "scope": "Taxonomy" }, - "frontMatter.telemetry.disable": { - "type": "boolean", - "default": false, - "markdownDescription": "%setting.frontMatter.telemetry.disable.markdownDescription%" - }, "frontMatter.templates.enabled": { "type": "boolean", "default": false, diff --git a/src/commands/Article.ts b/src/commands/Article.ts index 583aece4..53ce77ac 100644 --- a/src/commands/Article.ts +++ b/src/commands/Article.ts @@ -20,7 +20,6 @@ import { SETTING_SLUG_PREFIX, SETTING_SLUG_SUFFIX, SETTING_CONTENT_PLACEHOLDERS, - TelemetryEvent, SETTING_SLUG_TEMPLATE } from './../constants'; import { CustomPlaceholder, Field } from '../models'; @@ -39,7 +38,6 @@ import { COMMAND_NAME, DefaultFields } from '../constants'; import { DashboardData, SnippetInfo, SnippetRange } from '../models/DashboardData'; import { DateHelper } from '../helpers/DateHelper'; import { parseWinPath } from '../helpers/parseWinPath'; -import { Telemetry } from '../helpers/Telemetry'; import { ParsedFrontMatter } from '../parsers'; import { MediaListener } from '../listeners/panel'; import { NavigationType } from '../dashboardWebView/models'; @@ -192,8 +190,6 @@ export class Article { * Generate the slug based on the article title */ public static async updateSlug() { - Telemetry.send(TelemetryEvent.generateSlug); - const updateFileName = Settings.get(SETTING_SLUG_UPDATE_FILE_NAME) as string; const editor = window.activeTextEditor; diff --git a/src/commands/Chatbot.ts b/src/commands/Chatbot.ts index 856e3424..7210dd75 100644 --- a/src/commands/Chatbot.ts +++ b/src/commands/Chatbot.ts @@ -1,5 +1,4 @@ -import { Telemetry } from './../helpers/Telemetry'; -import { TelemetryEvent, PreviewCommands, GeneralCommands } from './../constants'; +import { PreviewCommands, GeneralCommands } from './../constants'; import { join } from 'path'; import { commands, Uri, ViewColumn, window } from 'vscode'; import { Extension } from '../helpers'; @@ -116,7 +115,5 @@ export class Chatbot { `; - - Telemetry.send(TelemetryEvent.openChatbot); } } diff --git a/src/commands/Dashboard.ts b/src/commands/Dashboard.ts index 5e6053ce..42860f14 100644 --- a/src/commands/Dashboard.ts +++ b/src/commands/Dashboard.ts @@ -3,8 +3,7 @@ import { CONTEXT, ExtensionState, SETTING_EXPERIMENTAL, - COMMAND_NAME, - TelemetryEvent + COMMAND_NAME } from '../constants'; import { join } from 'path'; import { commands, Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode'; @@ -17,7 +16,6 @@ import { DashboardListener, MediaListener, SettingsListener, - TelemetryListener, DataListener, PagesListener, ExtensionListener, @@ -28,7 +26,6 @@ import { } from '../listeners/dashboard'; import { MediaListener as PanelMediaListener } from '../listeners/panel'; import { GitListener, ModeListener } from '../listeners/general'; -import { Folders } from './Folders'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; import { DashboardMessage } from '../dashboardWebView/DashboardMessage'; @@ -66,7 +63,6 @@ export class Dashboard { subscriptions.push( commands.registerCommand(COMMAND_NAME.dashboard, (data?: DashboardData) => { - Telemetry.send(TelemetryEvent.openContentDashboard); if (!data) { Dashboard.open({ type: NavigationType.Contents }); } else { @@ -77,35 +73,30 @@ export class Dashboard { subscriptions.push( commands.registerCommand(COMMAND_NAME.dashboardMedia, () => { - Telemetry.send(TelemetryEvent.openMediaDashboard); Dashboard.open({ type: NavigationType.Media }); }) ); subscriptions.push( commands.registerCommand(COMMAND_NAME.dashboardSnippets, () => { - Telemetry.send(TelemetryEvent.openSnippetsDashboard); Dashboard.open({ type: NavigationType.Snippets }); }) ); subscriptions.push( commands.registerCommand(COMMAND_NAME.dashboardData, () => { - Telemetry.send(TelemetryEvent.openDataDashboard); Dashboard.open({ type: NavigationType.Data }); }) ); subscriptions.push( commands.registerCommand(COMMAND_NAME.dashboardTaxonomy, () => { - Telemetry.send(TelemetryEvent.openTaxonomyDashboard); Dashboard.open({ type: NavigationType.Taxonomy }); }) ); subscriptions.push( commands.registerCommand(COMMAND_NAME.dashboardClose, () => { - Telemetry.send(TelemetryEvent.closeDashboard); Dashboard.close(); }) ); @@ -240,7 +231,6 @@ export class Dashboard { PagesListener.process(msg); SettingsListener.process(msg); DataListener.process(msg); - TelemetryListener.process(msg); SnippetListener.process(msg); ModeListener.process(msg); GitListener.process(msg); diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index 670b7c24..bae0ee06 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -6,8 +6,7 @@ import { SETTING_CONTENT_PAGE_FOLDERS, SETTING_CONTENT_STATIC_FOLDER, SETTING_CONTENT_SUPPORTED_FILETYPES, - SETTING_DATE_FORMAT, - TelemetryEvent + SETTING_DATE_FORMAT } from './../constants'; import { commands, Uri, workspace, window } from 'vscode'; import { basename, dirname, join, relative, sep } from 'path'; @@ -107,8 +106,6 @@ export class Folders { MediaHelpers.resetMedia(); MediaListener.sendMediaFiles(0, folderPath); } - - Telemetry.send(TelemetryEvent.addMediaFolder); } /** @@ -183,8 +180,6 @@ export class Folders { Notifications.info(l10n.t(LocalizationKey.commandsFoldersCreateSuccess)); - Telemetry.send(TelemetryEvent.registerFolder); - SettingsListener.getSettings(true); } } @@ -198,8 +193,6 @@ export class Folders { let folders = await Folders.get(); folders = folders.filter((f) => f.path !== folder.fsPath); await Folders.update(folders); - - Telemetry.send(TelemetryEvent.unregisterFolder); } } diff --git a/src/commands/Preview.ts b/src/commands/Preview.ts index 1a2cb6e7..29480771 100644 --- a/src/commands/Preview.ts +++ b/src/commands/Preview.ts @@ -2,7 +2,6 @@ import { SETTING_PREVIEW_HOST, SETTING_PREVIEW_PATHNAME, CONTEXT, - TelemetryEvent, PreviewCommands, SETTING_EXPERIMENTAL, SETTING_DATE_FORMAT, @@ -20,7 +19,6 @@ import { processFmPlaceholders, processPathPlaceholders, Settings, - Telemetry, processDateTimePlaceholders } from '../helpers'; import { ContentFolder, ContentType, PreviewSettings } from '../models'; @@ -199,8 +197,6 @@ export class Preview { `; - - Telemetry.send(TelemetryEvent.openPreview); } /** diff --git a/src/commands/Project.ts b/src/commands/Project.ts index d275b4d0..19a8bbb9 100644 --- a/src/commands/Project.ts +++ b/src/commands/Project.ts @@ -1,5 +1,4 @@ import { DEFAULT_CONTENT_TYPE } from './../constants/ContentType'; -import { Telemetry } from './../helpers/Telemetry'; import { workspace, Uri, commands, window } from 'vscode'; import { join } from 'path'; import { Notifications } from '../helpers/Notifications'; @@ -16,8 +15,7 @@ import { import { COMMAND_NAME, SETTING_CONTENT_DEFAULT_FILETYPE, - SETTING_TAXONOMY_CONTENT_TYPES, - TelemetryEvent + SETTING_TAXONOMY_CONTENT_TYPES } from '../constants'; import { SettingsListener } from '../listeners/dashboard'; import { existsAsync, writeFileAsync } from '../utils'; @@ -96,8 +94,6 @@ categories: [] // Initialize the taxonomy database TaxonomyHelper.initDb(); - Telemetry.send(TelemetryEvent.initialization); - // Check if you can find the framework const wsFolder = Folders.getWorkspaceFolder(); const framework = await FrameworkDetector.get(wsFolder?.fsPath || ''); diff --git a/src/commands/Template.ts b/src/commands/Template.ts index de19ea5a..4a289aac 100644 --- a/src/commands/Template.ts +++ b/src/commands/Template.ts @@ -5,8 +5,7 @@ import { COMMAND_NAME, DefaultFields, SETTING_CONTENT_DEFAULT_FILETYPE, - SETTING_TEMPLATES_FOLDER, - TelemetryEvent + SETTING_TEMPLATES_FOLDER } from '../constants'; import { ArticleHelper, Extension, Settings } from '../helpers'; import { Article, Folders } from '.'; @@ -16,7 +15,6 @@ import { ContentType } from '../helpers/ContentType'; import { ContentType as IContentType } from '../models'; import { PagesListener } from '../listeners/dashboard'; import { extname } from 'path'; -import { Telemetry } from '../helpers/Telemetry'; import { writeFileAsync, copyFileAsync } from '../utils'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; @@ -224,8 +222,6 @@ export class Template { Notifications.info(l10n.t(LocalizationKey.commandsTemplateCreateSuccess)); - Telemetry.send(TelemetryEvent.createContentFromTemplate); - // Trigger a refresh for the dashboard PagesListener.refresh(); } diff --git a/src/constants/TelemetryEvent.ts b/src/constants/TelemetryEvent.ts deleted file mode 100644 index 6047f5f8..00000000 --- a/src/constants/TelemetryEvent.ts +++ /dev/null @@ -1,56 +0,0 @@ -export const TelemetryEvent = { - activate: 'activate', - initialization: 'initialization', - registerFolder: 'registerFolder', - unregisterFolder: 'unregisterFolder', - promoteSettings: 'promoteSettings', - - // Commands - openContentDashboard: 'openContentDashboard', - openMediaDashboard: 'openMediaDashboard', - openDataDashboard: 'openDataDashboard', - openSnippetsDashboard: 'openSnippetsDashboard', - openTaxonomyDashboard: 'openTaxonomyDashboard', - closeDashboard: 'closeDashboard', - - // Other actions - generateSlug: 'generateSlug', - createContentFromTemplate: 'createContentFromTemplate', - createContentFromContentType: 'createContentFromContentType', - addMediaFolder: 'addMediaFolder', - openPreview: 'openPreview', - uploadMedia: 'uploadMedia', - refreshMedia: 'refreshMedia', - deleteMedia: 'deleteMedia', - insertContentSnippet: 'insertContentSnippet', - insertMediaToContent: 'insertMediaToContent', - insertFileToContent: 'insertFileToContent', - updateMediaMetadata: 'updateMediaMetadata', - openPanelWebview: 'openPanelWebview', - - // Chatbot - openChatbot: 'openChatbot', - - // Content types - generateContentType: 'generateContentType', - addMissingFields: 'addMissingFields', - setContentType: 'setContentType', - - // Custom scripts - runCustomScript: 'runCustomScript', - runMediaScript: 'runMediaScript', - - // Webviews - webviewWelcomeScreen: 'webviewWelcomeScreen', - webviewMediaView: 'webviewMediaView', - webviewDataView: 'webviewDataView', - webviewContentsView: 'webviewContentsView', - webviewSnippetsView: 'webviewSnippetsView', - webviewTaxonomyDashboard: 'webviewTaxonomyDashboard', - webviewSettings: 'webviewSettings', - webviewUnknown: 'webviewUnknown', - - // Git - gitSync: 'gitSync', - gitFetch: 'gitFetch' -}; diff --git a/src/constants/index.ts b/src/constants/index.ts index ee247c3b..52794c2b 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -1,4 +1,5 @@ export * from './ContentType'; +export * from './DefaultFeatureFlags'; export * from './DefaultFieldValues'; export * from './DefaultFields'; export * from './DefaultFileTypes'; @@ -17,7 +18,6 @@ export * from './SentryIgnore'; export * from './Snippet'; export * from './SsgScripts'; export * from './StaticFolderPlaceholder'; -export * from './TelemetryEvent'; export * from './Templates'; export * from './charCode'; export * from './charMap'; diff --git a/src/constants/settings.ts b/src/constants/settings.ts index 9b2a1e83..483da63d 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -45,8 +45,6 @@ export const SETTING_TEMPLATES_FOLDER = 'templates.folder'; export const SETTING_TEMPLATES_PREFIX = 'templates.prefix'; export const SETTING_TEMPLATES_ENABLED = 'templates.enabled'; -export const SETTING_TELEMETRY_DISABLE = 'telemetry.disable'; - export const SETTING_PANEL_FREEFORM = 'panel.freeform'; export const SETTING_PANEL_ACTIONS_DISABLED = 'panel.actions.disabled'; diff --git a/src/dashboardWebView/DashboardMessage.ts b/src/dashboardWebView/DashboardMessage.ts index 84b38185..66f35ca2 100644 --- a/src/dashboardWebView/DashboardMessage.ts +++ b/src/dashboardWebView/DashboardMessage.ts @@ -74,7 +74,6 @@ export enum DashboardMessage { setState = 'setState', getState = 'getState', runCustomScript = 'runCustomScript', - sendTelemetry = 'sendTelemetry', showNotification = 'showNotification', setTitle = 'setTitle', diff --git a/src/dashboardWebView/components/Contents/Contents.tsx b/src/dashboardWebView/components/Contents/Contents.tsx index 23e30bd9..10c8bf65 100644 --- a/src/dashboardWebView/components/Contents/Contents.tsx +++ b/src/dashboardWebView/components/Contents/Contents.tsx @@ -10,7 +10,7 @@ import usePages from '../../hooks/usePages'; import { useCallback, useEffect, useState } from 'react'; import { Messenger, messageHandler } from '@estruyf/vscode/dist/client'; import { DashboardMessage } from '../../DashboardMessage'; -import { GeneralCommands, TelemetryEvent } from '../../../constants'; +import { GeneralCommands } from '../../../constants'; import { PageLayout } from '../Layout/PageLayout'; import { FilesProvider } from '../../providers/FilesProvider'; import { Alert } from '../Modals/Alert'; @@ -67,10 +67,6 @@ export const Contents: React.FunctionComponent = ({ }, [JSON.stringify(pageItems)]); useEffect(() => { - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewContentsView - }); - Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsContents)); }, []); diff --git a/src/dashboardWebView/components/DataView/DataView.tsx b/src/dashboardWebView/components/DataView/DataView.tsx index 8d95bd72..d9dd185c 100644 --- a/src/dashboardWebView/components/DataView/DataView.tsx +++ b/src/dashboardWebView/components/DataView/DataView.tsx @@ -17,7 +17,7 @@ import { Container } from './SortableContainer'; import { SortableItem } from './SortableItem'; import { ChevronRightIcon, CircleStackIcon } from '@heroicons/react/24/outline'; import { DataType } from '../../../models/DataType'; -import { GeneralCommands, TelemetryEvent, WEBSITE_LINKS } from '../../../constants'; +import { GeneralCommands, WEBSITE_LINKS } from '../../../constants'; import { NavigationItem } from '../Layout'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../../../localization'; @@ -130,10 +130,6 @@ export const DataView: React.FunctionComponent = ( Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsData)); - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewDataView - }); - Messenger.send(GeneralCommands.toVSCode.logging.info, { message: 'Data view loaded', location: 'DASHBOARD' diff --git a/src/dashboardWebView/components/Media/Media.tsx b/src/dashboardWebView/components/Media/Media.tsx index 68ee270f..b070053d 100644 --- a/src/dashboardWebView/components/Media/Media.tsx +++ b/src/dashboardWebView/components/Media/Media.tsx @@ -21,7 +21,7 @@ import { DashboardMessage } from '../../DashboardMessage'; import { FrontMatterIcon } from '../../../panelWebView/components/Icons/FrontMatterIcon'; import { FolderItem } from './FolderItem'; import useMedia from '../../hooks/useMedia'; -import { GeneralCommands, STATIC_FOLDER_PLACEHOLDER, TelemetryEvent } from '../../../constants'; +import { STATIC_FOLDER_PLACEHOLDER, } from '../../../constants'; import { PageLayout } from '../Layout/PageLayout'; import { parseWinPath } from '../../../helpers/parseWinPath'; import { basename, extname, join } from 'path'; @@ -154,15 +154,6 @@ export const Media: React.FunctionComponent = ( useEffect(() => { Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsMedia)); - - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewMediaView - }); - - Messenger.send(GeneralCommands.toVSCode.logging.info, { - message: `Media view loaded`, - location: 'DASHBOARD' - }); }, []); const { getRootProps, isDragActive } = useDropzone({ diff --git a/src/dashboardWebView/components/SettingsView/SettingsView.tsx b/src/dashboardWebView/components/SettingsView/SettingsView.tsx index e04d91d6..a3e2f354 100644 --- a/src/dashboardWebView/components/SettingsView/SettingsView.tsx +++ b/src/dashboardWebView/components/SettingsView/SettingsView.tsx @@ -8,7 +8,7 @@ import { AstroContentTypes } from '../Configuration/Astro/AstroContentTypes'; import { ContentFolders } from '../Configuration/Common/ContentFolders'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../../../localization'; -import { COMMAND_NAME, TelemetryEvent } from '../../../constants'; +import { COMMAND_NAME } from '../../../constants'; import { ArrowPathIcon } from '@heroicons/react/24/outline'; import { VSCodePanelTab, VSCodePanelView, VSCodePanels } from '@vscode/webview-ui-toolkit/react'; import { CommonSettings } from './CommonSettings'; @@ -25,10 +25,6 @@ export const SettingsView: React.FunctionComponent = (_: Rea useEffect(() => { Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.commonSettings)); - - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewSettings - }); }, []); return ( diff --git a/src/dashboardWebView/components/SnippetsView/Snippets.tsx b/src/dashboardWebView/components/SnippetsView/Snippets.tsx index 2a7da3f3..c3c7b6d9 100644 --- a/src/dashboardWebView/components/SnippetsView/Snippets.tsx +++ b/src/dashboardWebView/components/SnippetsView/Snippets.tsx @@ -5,7 +5,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useRecoilValue } from 'recoil'; import { FeatureFlag } from '../../../components/features/FeatureFlag'; import { FEATURE_FLAG, GeneralCommands, WEBSITE_LINKS } from '../../../constants'; -import { TelemetryEvent } from '../../../constants/TelemetryEvent'; import { SnippetParser } from '../../../helpers/SnippetParser'; import { DashboardMessage } from '../../DashboardMessage'; import { ModeAtom, SettingsSelector, ViewDataSelector } from '../../state'; @@ -84,10 +83,6 @@ export const Snippets: React.FunctionComponent = ( useEffect(() => { Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsSnippets)); - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewSnippetsView - }); - Messenger.send(GeneralCommands.toVSCode.logging.info, { message: `Snippets view loaded`, location: 'DASHBOARD' diff --git a/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx b/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx index 81ddca32..3973c63e 100644 --- a/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx +++ b/src/dashboardWebView/components/TaxonomyView/TaxonomyView.tsx @@ -3,7 +3,7 @@ import { ChevronRightIcon, ArrowDownTrayIcon } from '@heroicons/react/24/outline import * as React from 'react'; import { useEffect, useState } from 'react'; import { useRecoilValue } from 'recoil'; -import { GeneralCommands, TelemetryEvent } from '../../../constants'; +import { GeneralCommands } from '../../../constants'; import { TaxonomyData } from '../../../models'; import { DashboardMessage } from '../../DashboardMessage'; import { Page, PageMappings } from '../../models'; @@ -55,10 +55,6 @@ export const TaxonomyView: React.FunctionComponent = ({ useEffect(() => { Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsTaxonomies)); - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewTaxonomyDashboard - }); - Messenger.send(GeneralCommands.toVSCode.logging.info, { message: 'Taxonomy view loaded', location: 'DASHBOARD' diff --git a/src/dashboardWebView/components/UnknownView/UnknownView.tsx b/src/dashboardWebView/components/UnknownView/UnknownView.tsx index c9d72126..1d3f51ea 100644 --- a/src/dashboardWebView/components/UnknownView/UnknownView.tsx +++ b/src/dashboardWebView/components/UnknownView/UnknownView.tsx @@ -5,7 +5,6 @@ import { LocalizationKey } from '../../../localization'; import { useEffect } from 'react'; import { Messenger } from '@estruyf/vscode/dist/client'; import { DashboardMessage } from '../../DashboardMessage'; -import { TelemetryEvent } from '../../../constants'; export interface IUnknownViewProps { } @@ -14,10 +13,6 @@ export const UnknownView: React.FunctionComponent = ( ) => { useEffect(() => { Messenger.send(DashboardMessage.setTitle, "Unknown View"); - - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewUnknown - }); }, []); return ( diff --git a/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx b/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx index 65a5f0c6..917aaece 100644 --- a/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx +++ b/src/dashboardWebView/components/WelcomeView/WelcomeScreen.tsx @@ -1,6 +1,6 @@ import { BookOpenIcon, HeartIcon, StarIcon } from '@heroicons/react/24/outline'; import * as React from 'react'; -import { DOCUMENTATION_LINK, GITHUB_LINK, GeneralCommands, REVIEW_LINK, SPONSOR_LINK, TelemetryEvent } from '../../../constants'; +import { DOCUMENTATION_LINK, GITHUB_LINK, GeneralCommands, REVIEW_LINK, SPONSOR_LINK } from '../../../constants'; import { Messenger } from '@estruyf/vscode/dist/client'; import { FrontMatterIcon } from '../../../panelWebView/components/Icons/FrontMatterIcon'; import { GitHubIcon } from '../../../panelWebView/components/Icons/GitHubIcon'; @@ -25,9 +25,6 @@ export const WelcomeScreen: React.FunctionComponent = ({ React.useEffect(() => { setView(NavigationType.Welcome); - Messenger.send(DashboardMessage.sendTelemetry, { - event: TelemetryEvent.webviewWelcomeScreen - }); Messenger.send(GeneralCommands.toVSCode.logging.info, { message: 'Welcome screen loaded', diff --git a/src/extension.ts b/src/extension.ts index c122324b..ed371d64 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,6 @@ import { GitListener } from './listeners/general/GitListener'; import * as vscode from 'vscode'; -import { COMMAND_NAME, CONTEXT, EXTENSION_NAME, TelemetryEvent } from './constants'; +import { COMMAND_NAME, CONTEXT, EXTENSION_NAME } from './constants'; import { MarkdownFoldingProvider } from './providers/MarkdownFoldingProvider'; import { PanelProvider } from './panelWebView/PanelProvider'; import { @@ -81,9 +81,6 @@ export async function activate(context: vscode.ExtensionContext) { SettingsHelper.checkToPromote(); - // Sends the activation event - Telemetry.send(TelemetryEvent.activate); - // Start listening to the folders for content changes. // This will make sure the dashboard is up to date PagesListener.startWatchers(); diff --git a/src/helpers/ContentType.ts b/src/helpers/ContentType.ts index 7ac64c8e..98af8c4b 100644 --- a/src/helpers/ContentType.ts +++ b/src/helpers/ContentType.ts @@ -19,8 +19,7 @@ import { SETTING_DATE_FORMAT, SETTING_FRAMEWORK_ID, SETTING_TAXONOMY_CONTENT_TYPES, - SETTING_TAXONOMY_FIELD_GROUPS, - TelemetryEvent + SETTING_TAXONOMY_FIELD_GROUPS } from '../constants'; import { ContentType as IContentType, @@ -204,8 +203,6 @@ export class ContentType { return; } - Telemetry.send(TelemetryEvent.generateContentType); - const content = ArticleHelper.getCurrent(); const editor = window.activeTextEditor; @@ -333,8 +330,6 @@ export class ContentType { return; } - Telemetry.send(TelemetryEvent.addMissingFields); - const article = ArticleHelper.getCurrent(); if (!article || !article.data) { @@ -378,8 +373,6 @@ export class ContentType { return; } - Telemetry.send(TelemetryEvent.setContentType); - const content = ArticleHelper.getCurrent(); const contentTypes = ContentType.getAll() || []; @@ -1034,8 +1027,6 @@ export class ContentType { Notifications.info(l10n.t(LocalizationKey.helpersContentTypeCreateSuccess)); - Telemetry.send(TelemetryEvent.createContentFromContentType); - // Trigger a refresh for the dashboard PagesListener.refresh(); } diff --git a/src/helpers/CustomScript.ts b/src/helpers/CustomScript.ts index 8c822bb0..ea92b6b5 100644 --- a/src/helpers/CustomScript.ts +++ b/src/helpers/CustomScript.ts @@ -2,7 +2,7 @@ import { Settings } from './SettingsHelper'; import { CommandType, EnvironmentType } from './../models/PanelSettings'; import { CustomScript as ICustomScript, ScriptType } from '../models/PanelSettings'; import { window, env as vscodeEnv, ProgressLocation, Uri, commands } from 'vscode'; -import { ArticleHelper, Logger, MediaHelpers, Telemetry } from '.'; +import { ArticleHelper, Logger, MediaHelpers } from '.'; import { Folders, WORKSPACE_PLACEHOLDER } from '../commands/Folders'; import { exec, execSync } from 'child_process'; import * as os from 'os'; @@ -12,7 +12,6 @@ import ContentProvider from '../providers/ContentProvider'; import { Dashboard } from '../commands/Dashboard'; import { DashboardCommand } from '../dashboardWebView/DashboardCommand'; import { ParsedFrontMatter } from '../parsers'; -import { TelemetryEvent } from '../constants/TelemetryEvent'; import { SETTING_CUSTOM_SCRIPTS } from '../constants'; import { existsAsync } from '../utils'; import * as l10n from '@vscode/l10n'; @@ -40,12 +39,8 @@ export class CustomScript { const wsPath = wsFolder.fsPath; if (script.type === ScriptType.MediaFile || script.type === ScriptType.MediaFolder) { - Telemetry.send(TelemetryEvent.runMediaScript); - await CustomScript.runMediaScript(wsPath, path, script); } else { - Telemetry.send(TelemetryEvent.runCustomScript); - if (script.bulk) { // Run script on all files await CustomScript.bulkRun(wsPath, script); diff --git a/src/helpers/SettingsHelper.ts b/src/helpers/SettingsHelper.ts index 20d5f786..92d6014a 100644 --- a/src/helpers/SettingsHelper.ts +++ b/src/helpers/SettingsHelper.ts @@ -1,5 +1,4 @@ import { parseWinPath } from './parseWinPath'; -import { Telemetry } from './Telemetry'; import { Notifications } from './Notifications'; import { commands, @@ -18,7 +17,6 @@ import { CONTEXT, ExtensionState, SETTING_TAXONOMY_CUSTOM, - TelemetryEvent, COMMAND_NAME, SETTING_TAXONOMY_CONTENT_TYPES, SETTING_CONTENT_PAGE_FOLDERS, @@ -602,8 +600,6 @@ ${JSON.stringify(value, null, 2)}`, } Notifications.info(l10n.t(LocalizationKey.helpersSettingsHelperPromoteSuccess)); - - Telemetry.send(TelemetryEvent.promoteSettings); } /** diff --git a/src/helpers/Telemetry.ts b/src/helpers/Telemetry.ts index f40dfd24..3b95596d 100644 --- a/src/helpers/Telemetry.ts +++ b/src/helpers/Telemetry.ts @@ -1,32 +1,6 @@ import { workspace } from 'vscode'; -import { Extension, Settings } from '.'; -import { - EXTENSION_BETA_ID, - EXTENSION_ID, - SETTING_TELEMETRY_DISABLE, - WEBSITE_LINKS -} from '../constants'; export class Telemetry { - private static instance: Telemetry; - private extTitle: string; - private extVersion: string; - private events: any[] = []; - private timeout: NodeJS.Timeout | undefined; - - private constructor() { - const extension = Extension.getInstance(); - this.extTitle = extension.isBetaVersion() ? EXTENSION_BETA_ID : EXTENSION_ID; - this.extVersion = extension.version; - } - - public static getInstance(): Telemetry { - if (!Telemetry.instance) { - Telemetry.instance = new Telemetry(); - } - return Telemetry.instance; - } - public static isVscodeEnabled(): boolean { const config = workspace.getConfiguration('telemetry'); const isVscodeEnable = config.get<'off' | undefined>('enableTelemetry'); @@ -39,56 +13,6 @@ export class Telemetry { */ public static isEnabled(): boolean { const isVscodeEnable = Telemetry.isVscodeEnabled(); - - const isDisabled = Settings.get(SETTING_TELEMETRY_DISABLE); - - return isDisabled || isVscodeEnable ? false : true; - } - - /** - * Send metrics to our own database - * @param eventName - * @param properties - * @returns - */ - public static send(eventName: string, properties?: any) { - if (!Telemetry.isEnabled()) { - return; - } - - const instance = Telemetry.getInstance(); - instance.events.push({ - name: eventName, - extName: instance.extTitle, - version: instance.extVersion, - properties - }); - - instance.debounceMetrics(); - } - - /** - * Debounce the metrics by 1 second - */ - private async debounceMetrics() { - const instance = Telemetry.getInstance(); - - // Check if timeout was defined - if (instance.timeout) { - clearTimeout(instance.timeout); - } - - // Set a new timeout - instance.timeout = setTimeout(async () => { - await fetch(WEBSITE_LINKS.api.metrics, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(this.events) - }); - // Reset the events - this.events = []; - }, 1000) as any as NodeJS.Timeout; + return isVscodeEnable ? false : true; } } diff --git a/src/listeners/dashboard/MediaListener.ts b/src/listeners/dashboard/MediaListener.ts index 85893602..da61f1df 100644 --- a/src/listeners/dashboard/MediaListener.ts +++ b/src/listeners/dashboard/MediaListener.ts @@ -1,11 +1,10 @@ -import { Telemetry } from '../../helpers/Telemetry'; import { MediaHelpers } from '../../helpers/MediaHelpers'; import { DashboardMessage } from '../../dashboardWebView/DashboardMessage'; import { BaseListener } from './BaseListener'; import { DashboardCommand } from '../../dashboardWebView/DashboardCommand'; import { SortingOption } from '../../dashboardWebView/models'; import { commands, env, Uri } from 'vscode'; -import { COMMAND_NAME, TelemetryEvent } from '../../constants'; +import { COMMAND_NAME } from '../../constants'; import * as os from 'os'; import { Folders } from '../../commands'; import { PostMessageData, UnmappedMedia } from '../../models'; @@ -24,31 +23,25 @@ export class MediaListener extends BaseListener { this.sendMediaFiles(page, folder, sorting); break; case DashboardMessage.refreshMedia: - Telemetry.send(TelemetryEvent.refreshMedia); MediaHelpers.resetMedia(); this.sendMediaFiles(0, msg?.payload?.folder); break; case DashboardMessage.uploadMedia: - Telemetry.send(TelemetryEvent.uploadMedia); this.store(msg?.payload); break; case DashboardMessage.deleteMedia: - Telemetry.send(TelemetryEvent.deleteMedia); this.delete(msg?.payload); break; case DashboardMessage.revealMedia: this.openFileInFinder(msg?.payload?.file); break; case DashboardMessage.insertMedia: - Telemetry.send(TelemetryEvent.insertMediaToContent); MediaHelpers.insertMediaToMarkdown(msg?.payload); break; case DashboardMessage.insertFile: - Telemetry.send(TelemetryEvent.insertFileToContent); MediaHelpers.insertMediaToMarkdown(msg?.payload); break; case DashboardMessage.updateMediaMetadata: - Telemetry.send(TelemetryEvent.updateMediaMetadata); this.update(msg.payload); break; case DashboardMessage.getUnmappedMedia: diff --git a/src/listeners/dashboard/SnippetListener.ts b/src/listeners/dashboard/SnippetListener.ts index 49904567..9a3bf770 100644 --- a/src/listeners/dashboard/SnippetListener.ts +++ b/src/listeners/dashboard/SnippetListener.ts @@ -1,13 +1,11 @@ import { EditorHelper } from '@estruyf/vscode'; import { window, Range, Position } from 'vscode'; import { Dashboard } from '../../commands/Dashboard'; -import { SETTING_CONTENT_SNIPPETS, SETTING_DATE_FORMAT, TelemetryEvent } from '../../constants'; +import { SETTING_CONTENT_SNIPPETS, SETTING_DATE_FORMAT } from '../../constants'; import { DashboardMessage } from '../../dashboardWebView/DashboardMessage'; import { - ArticleHelper, Notifications, Settings, - Telemetry, processArticlePlaceholdersFromPath, processTimePlaceholders } from '../../helpers'; @@ -29,7 +27,6 @@ export class SnippetListener extends BaseListener { this.updateSnippet(msg.payload); break; case DashboardMessage.insertSnippet: - Telemetry.send(TelemetryEvent.insertContentSnippet); this.insertSnippet(msg.payload); break; case DashboardMessage.updateSnippetPlaceholders: diff --git a/src/listeners/dashboard/TelemetryListener.ts b/src/listeners/dashboard/TelemetryListener.ts deleted file mode 100644 index 30c637fe..00000000 --- a/src/listeners/dashboard/TelemetryListener.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { DashboardMessage } from '../../dashboardWebView/DashboardMessage'; -import { Telemetry } from '../../helpers/Telemetry'; -import { PostMessageData } from '../../models'; -import { BaseListener } from './BaseListener'; - -export class TelemetryListener extends BaseListener { - /** - * Process the messages for the dashboard views - * @param msg - */ - public static process(msg: PostMessageData) { - super.process(msg); - - switch (msg.command) { - case DashboardMessage.sendTelemetry: - Telemetry.send(msg.payload.event, msg.payload.properties); - break; - } - } -} diff --git a/src/listeners/dashboard/index.ts b/src/listeners/dashboard/index.ts index 26727ef8..8c75249c 100644 --- a/src/listeners/dashboard/index.ts +++ b/src/listeners/dashboard/index.ts @@ -6,7 +6,6 @@ export * from './MediaListener'; export * from './PagesListener'; export * from './SettingsListener'; export * from './SnippetListener'; -export * from './TelemetryListener'; export * from './TaxonomyListener'; export * from './LocalizationListener'; export * from './SsgListener'; diff --git a/src/listeners/general/GitListener.ts b/src/listeners/general/GitListener.ts index b3a84e19..99133b33 100644 --- a/src/listeners/general/GitListener.ts +++ b/src/listeners/general/GitListener.ts @@ -10,8 +10,7 @@ import { SETTING_GIT_SUBMODULE_BRANCH, SETTING_GIT_SUBMODULE_FOLDER, SETTING_GIT_SUBMODULE_PULL, - SETTING_GIT_SUBMODULE_PUSH, - TelemetryEvent + SETTING_GIT_SUBMODULE_PUSH } from './../../constants'; import { Settings } from './../../helpers/SettingsHelper'; import { Dashboard } from '../../commands/Dashboard'; @@ -22,8 +21,7 @@ import { Logger, Notifications, parseWinPath, - processTimePlaceholders, - Telemetry + processTimePlaceholders } from '../../helpers'; import { GeneralCommands } from './../../constants/GeneralCommands'; import simpleGit, { SimpleGit } from 'simple-git'; @@ -158,8 +156,6 @@ export class GitListener { try { this.sendMsg(GeneralCommands.toWebview.git.syncingStart, isSync ? 'syncing' : 'fetching'); - Telemetry.send(isSync ? TelemetryEvent.gitSync : TelemetryEvent.gitFetch); - await this.pull(); if (isSync) { diff --git a/src/panelWebView/PanelProvider.ts b/src/panelWebView/PanelProvider.ts index 5787d2d7..90453d5e 100644 --- a/src/panelWebView/PanelProvider.ts +++ b/src/panelWebView/PanelProvider.ts @@ -9,7 +9,7 @@ import { FieldsListener, LocalizationListener } from './../listeners/panel'; -import { SETTING_EXPERIMENTAL, TelemetryEvent } from '../constants'; +import { SETTING_EXPERIMENTAL } from '../constants'; import { CancellationToken, Disposable, @@ -27,7 +27,6 @@ import { WebviewHelper } from '@estruyf/vscode'; import { Extension } from '../helpers/Extension'; import { Telemetry } from '../helpers/Telemetry'; import { GitListener, ModeListener } from '../listeners/general'; -import { Folders } from '../commands'; import { basename } from 'path'; import { getExtensibilityScripts, ignoreMsgCommand } from '../utils'; @@ -120,7 +119,6 @@ export class PanelProvider implements WebviewViewProvider, Disposable { webviewView.onDidChangeVisibility(() => { if (this.visible) { - Telemetry.send(TelemetryEvent.openPanelWebview); DataListener.getFileData(); } });