Skip to content

Commit

Permalink
Record user and session data properly for telemetry (#748)
Browse files Browse the repository at this point in the history
This PR fixes the issue with telemetry module that wasn't collecting
user-id and session-id properly resulting in all the telemetry events
being squashed under a single user and session.

The main fix for user-id reporting has already landed in the new version
of telemetry package
microsoft/vscode-extension-telemetry#210
We also submitted a PR that has been merged to address the session ID
issue: microsoft/vscode-extension-telemetry#215

Because there's been no release since that update, we're installing a
fork of telemetry module with our changes included from
https://github.com/software-mansion-labs/vscode-extension-telemetry
Since the package requires a build-step, we've uploaded bundled JS files
into the fork repository and install the dependency using github link.

The new version of telementy module now requires a so-called "connection
string" instead of just the instrumentation key as the first argument.
Because of that we're also updating the public key value.

### How Has This Been Tested: 
1. Change panelOpen event to panelOpen-test20
2. Open extension
3. Check in Application Insights that the new event arrived and it has
distinct user id and session set.
  • Loading branch information
Apple0717 committed Nov 20, 2024
1 parent 4745bd5 commit 5670b98
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 58 deletions.
1 change: 1 addition & 0 deletions packages/vscode-extension/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@software-mansion-labs:registry=https://npm.pkg.github.com
110 changes: 55 additions & 55 deletions packages/vscode-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
"@vscode/codicons": "^0.0.35",
"@vscode/debugadapter": "^1.51.0",
"@vscode/debugprotocol": "^1.51.0",
"@vscode/extension-telemetry": "^0.9.6",
"@vscode/extension-telemetry": "github:software-mansion-labs/vscode-extension-telemetry",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"@vscode/vsce": "^2.22.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/vscode-extension/src/utilities/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import TelemetryReporter from "@vscode/extension-telemetry";
import { extensionContext } from "./extensionContext";

const PUBLIC_INSIGHTS_KEY = "6709dbd6-92e7-40f6-be09-618db8a85ce9";
const PUBLIC_APP_INSIGHTS_CONNECTION_STRING =
"InstrumentationKey=6709dbd6-92e7-40f6-be09-618db8a85ce9";

let reporter: TelemetryReporter | undefined;

export function getTelemetryReporter(): TelemetryReporter {
if (!reporter) {
reporter = new TelemetryReporter(PUBLIC_INSIGHTS_KEY);
reporter = new TelemetryReporter(PUBLIC_APP_INSIGHTS_CONNECTION_STRING);
extensionContext.subscriptions.push(reporter);
}
return reporter;
Expand Down

0 comments on commit 5670b98

Please sign in to comment.