Skip to content

Commit

Permalink
Merge pull request #883 from NordicSemiconductor/fix/insights-send-br…
Browse files Browse the repository at this point in the history
…owser-data-on-opt-out

Fix: sending browser info after opting out
  • Loading branch information
kylebonnici authored Feb 5, 2024
2 parents 4d87c8d + c15fb86 commit 4a3fe22
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ This project does _not_ adhere to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
every new version is a new major version.

## 155.0 - 2024-02-05

### Fix

- Disable Azure Insights when opting out to avoid leaking off browser
information.

## 154.0.0 - 2024-02-05

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nordicsemiconductor/pc-nrfconnect-shared",
"version": "154.0.0",
"version": "155.0.0",
"description": "Shared commodities for developing pc-nrfconnect-* packages",
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions src/telemetry/TelemetrySender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export default abstract class TelemetrySender {

sendDisagreementEvent() {
this.sendMinimalEvent('Telemetry Opt-Out');
this.flush();
this.stop();
}

async setUsersAgreedToTelemetry(hasAgreed: boolean) {
Expand Down Expand Up @@ -77,4 +79,5 @@ export default abstract class TelemetrySender {
abstract sendTrace(message: string): MaybePromise<void>;
abstract sendErrorReport(error: Error): MaybePromise<void>;
abstract flush(): MaybePromise<void>;
abstract stop(): void;
}
7 changes: 7 additions & 0 deletions src/telemetry/TelemetrySenderInMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ export default class TelemetrySenderInMain extends TelemetrySender {
};

flush = () => this.getClient().flush();

stop(): void {
if (this.client) {
this.client.config.disableAppInsights = true;
}
this.client = undefined;
}
}
8 changes: 8 additions & 0 deletions src/telemetry/TelemetrySenderInRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,12 @@ export default class TelemetrySenderInRenderer extends TelemetrySender {
};

flush = async () => (await this.getClient()).flush();

stop(): void {
if (this.client) {
this.client.config.disableTelemetry = true;
this.client?.unload();
}
this.client = undefined;
}
}

0 comments on commit 4a3fe22

Please sign in to comment.