-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@W-14219242@: Fixing behavioral issues with telemetry. #27
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ import { CORE_EXTENSION_ID, MINIMUM_REQUIRED_VERSION_CORE_EXTENSION } from './co | |
*/ | ||
export class CoreExtensionService { | ||
private static initialized = false; | ||
private static telemetryService: TelemetryService; | ||
private static telemetryService: CoreTelemetryService; | ||
|
||
public static async loadDependencies(context: vscode.ExtensionContext): Promise<void> { | ||
if (!CoreExtensionService.initialized) { | ||
|
@@ -61,11 +61,11 @@ export class CoreExtensionService { | |
} | ||
|
||
/** | ||
* Initializes a {@link TelemetryService} instance of the provided class, or a {@link NoOpTelemetryService} if none was provided | ||
* Initializes a {@link CoreTelemetryService} instance of the provided class, or uses null if none was provided. | ||
* @param telemetryService | ||
* @param context | ||
*/ | ||
private static async initializeTelemetryService(telemetryService: TelemetryService | undefined, context: vscode.ExtensionContext): Promise<void> { | ||
private static async initializeTelemetryService(telemetryService: CoreTelemetryService | undefined, context: vscode.ExtensionContext): Promise<void> { | ||
if (!telemetryService) { | ||
console.log(`Telemetry service not present in core dependency API. Using null instead.`); | ||
CoreExtensionService.telemetryService = null; | ||
|
@@ -79,14 +79,34 @@ export class CoreExtensionService { | |
* | ||
* @returns The {@link TelemetryService} object exported by the Core Extension if available, else null. | ||
*/ | ||
public static getTelemetryService(): TelemetryService|null { | ||
public static _getTelemetryService(): CoreTelemetryService|null { | ||
if (CoreExtensionService.initialized) { | ||
return CoreExtensionService.telemetryService; | ||
} | ||
throw new Error(messages.error.coreExtensionServiceUninitialized); | ||
} | ||
} | ||
|
||
export class TelemetryService { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving |
||
|
||
public static sendExtensionActivationEvent(hrStart: [number, number]): void { | ||
CoreExtensionService._getTelemetryService()?.sendExtensionActivationEvent(hrStart); | ||
} | ||
|
||
public static sendCommandEvent(key: string, data: Properties): void { | ||
CoreExtensionService._getTelemetryService()?.sendCommandEvent(key, undefined, data); | ||
} | ||
|
||
public static sendException(name: string, message: string, data?: Record<string, string>): void { | ||
const fullMessage = data ? message + JSON.stringify(data) : message; | ||
CoreExtensionService._getTelemetryService()?.sendException(name, fullMessage); | ||
} | ||
|
||
public static dispose(): void { | ||
CoreExtensionService._getTelemetryService()?.dispose(); | ||
} | ||
} | ||
|
||
|
||
interface Measurements { | ||
[key: string]: number; | ||
|
@@ -99,10 +119,10 @@ export interface Properties { | |
/** | ||
* This interface is a subset of the TelemetryService interface from the salesforcedx-utils-vscode package. | ||
*/ | ||
interface TelemetryService { | ||
interface CoreTelemetryService { | ||
extensionName: string; | ||
isTelemetryEnabled(): boolean; | ||
getInstance(): TelemetryService; | ||
getInstance(): CoreTelemetryService; | ||
initializeService(extensionContext: vscode.ExtensionContext): Promise<void>; | ||
sendExtensionActivationEvent(hrstart: [number, number]): void; | ||
sendExtensionDeactivationEvent(): void; | ||
|
@@ -118,6 +138,6 @@ interface TelemetryService { | |
|
||
interface CoreExtensionApi { | ||
services: { | ||
TelemetryService: TelemetryService; | ||
TelemetryService: CoreTelemetryService; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The leading underscore is a JS social convention indicating that the method should be treated by developers as private even though it's technically public.