Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

Commit 4f486f3

Browse files
committed
Adding fallback/debug telemetry reporter
1 parent 6508429 commit 4f486f3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/extension.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ let telemetryReporter: TelemetryReporter;
1717
export function activate(context: vscode.ExtensionContext) {
1818

1919
const packageInfo = getPackageInfo(context);
20-
telemetryReporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
20+
if (packageInfo && vscode.env.sessionId !== 'someValue.machineId') {
21+
// Use the real telemetry reporter
22+
telemetryReporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
23+
} else {
24+
// Fallback to a fake telemetry reporter
25+
telemetryReporter = new DebugTelemetryReporter('', '', '');
26+
}
2127
context.subscriptions.push(telemetryReporter);
2228

2329
context.subscriptions.push(vscode.commands.registerCommand('devtools-for-chrome.launch', async () => {
@@ -346,4 +352,18 @@ class DevToolsPanel {
346352
</html>
347353
`;
348354
}
355+
}
356+
357+
class DebugTelemetryReporter extends TelemetryReporter {
358+
constructor(extensionId: string, extensionVersion: string, key: string) {
359+
super(extensionId, extensionVersion, key);
360+
}
361+
362+
public sendTelemetryEvent(name: string, properties?: any, measurements?: any) {
363+
console.log(`${name}: ${JSON.stringify(properties)}, ${JSON.stringify(properties)}`);
364+
}
365+
366+
public dispose(): Promise<any> {
367+
return Promise.resolve();
368+
}
349369
}

0 commit comments

Comments
 (0)