From 85ee56c000fa598baece5d716c0c4eb5709ad941 Mon Sep 17 00:00:00 2001 From: mingxuanzhang Date: Fri, 10 Nov 2023 13:39:56 -0800 Subject: [PATCH] chore: compatible with old e4d telemetryService usage --- packages/salesforcedx-utils-vscode/src/constants.ts | 1 + packages/salesforcedx-utils-vscode/src/index.ts | 1 + .../salesforcedx-utils-vscode/src/telemetry/telemetry.ts | 7 ++++++- packages/salesforcedx-vscode-core/src/index.ts | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/salesforcedx-utils-vscode/src/constants.ts b/packages/salesforcedx-utils-vscode/src/constants.ts index abe5d55fd0..021f84eebb 100644 --- a/packages/salesforcedx-utils-vscode/src/constants.ts +++ b/packages/salesforcedx-utils-vscode/src/constants.ts @@ -5,3 +5,4 @@ export const TARGET_DEV_HUB_KEY = 'target-dev-hub'; export const TARGET_ORG_KEY = 'target-org'; export const SF_CONFIG_DISABLE_TELEMETRY = 'disable-telemetry'; export const DEFAULT_AIKEY = 'ec3632a4-df47-47a4-98dc-8134cacbaf7e'; +export const SFDX_E4D_EXTENSION_NAME = 'salesforcedx-einstein-gpt'; diff --git a/packages/salesforcedx-utils-vscode/src/index.ts b/packages/salesforcedx-utils-vscode/src/index.ts index 76507bed1c..69f9e8d31f 100644 --- a/packages/salesforcedx-utils-vscode/src/index.ts +++ b/packages/salesforcedx-utils-vscode/src/index.ts @@ -32,6 +32,7 @@ export { } from './context/workspaceContextUtil'; export { TelemetryProvider, + TelemetryService, TelemetryBuilder, TelemetryData, Properties, diff --git a/packages/salesforcedx-utils-vscode/src/telemetry/telemetry.ts b/packages/salesforcedx-utils-vscode/src/telemetry/telemetry.ts index 18c074afda..f11f0e0ca5 100644 --- a/packages/salesforcedx-utils-vscode/src/telemetry/telemetry.ts +++ b/packages/salesforcedx-utils-vscode/src/telemetry/telemetry.ts @@ -10,7 +10,8 @@ import { env, ExtensionContext, ExtensionMode, workspace } from 'vscode'; import { DEFAULT_AIKEY, SFDX_CORE_CONFIGURATION_NAME, - SFDX_CORE_EXTENSION_NAME + SFDX_CORE_EXTENSION_NAME, + SFDX_E4D_EXTENSION_NAME } from '../constants'; import { disableCLITelemetry, isCLITelemetryAllowed } from './cliConfiguration'; import { TelemetryReporter } from './telemetryReporter'; @@ -87,6 +88,10 @@ export class TelemetryService { private reporter: TelemetryReporter | undefined; private aiKey = DEFAULT_AIKEY; private version: string = ''; + // Temporary usage for earlier version of e4d + public static getInstance() { + return TelemetryProvider.getInstance(SFDX_E4D_EXTENSION_NAME); + } /** * Cached promise to check if CLI telemetry config is enabled */ diff --git a/packages/salesforcedx-vscode-core/src/index.ts b/packages/salesforcedx-vscode-core/src/index.ts index 6f10410d64..bbb4762248 100644 --- a/packages/salesforcedx-vscode-core/src/index.ts +++ b/packages/salesforcedx-vscode-core/src/index.ts @@ -9,7 +9,8 @@ import { ChannelService, getRootWorkspacePath, SFDX_CORE_CONFIGURATION_NAME, - TelemetryProvider + TelemetryProvider, + TelemetryService } from '@salesforce/salesforcedx-utils-vscode'; import * as vscode from 'vscode'; import { channelService } from './channels'; @@ -617,6 +618,7 @@ export async function activate(extensionContext: vscode.ExtensionContext) { services: { ChannelService, TelemetryProvider, + TelemetryService, WorkspaceContext } };