Skip to content

Commit

Permalink
Merge pull request #856 from NordicSemiconductor/fix/multiple-duplica…
Browse files Browse the repository at this point in the history
…te-insights

Fix/multiple duplicate insights
  • Loading branch information
kylebonnici authored Jan 5, 2024
2 parents 6c10e36 + bf50f41 commit e4c37bc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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.

## 145.0.0 - 2023-01-05

### Fix

- Azure insights sends the same event multiple times
- Shared compatibility with launcher

## 144.0.0 - 2023-12-19

### Added
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": "144.0.0",
"version": "145.0.0",
"description": "Shared commodities for developing pc-nrfconnect-* packages",
"repository": {
"type": "git",
Expand Down
11 changes: 8 additions & 3 deletions src/utils/usageDataRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ const getInsights = async (forceSend?: boolean) => {

// We experienced that apps sometimes freeze when closing the window
// until the telemetry events are sent.
window.addEventListener('beforeunload', async () => {
(await getInsights())?.flush();
});
const isRenderer = process && process.type === 'renderer';
if (isRenderer) {
window.addEventListener('beforeunload', async () => {
(await getInsights())?.flush();
});
}

const init = async () => {
const applicationName = packageJson().name;
Expand All @@ -48,6 +51,8 @@ const init = async () => {
config: {
instrumentationKey: INSTRUMENTATION_KEY,
accountId, // to hide with removeAllMetadata
isStorageUseDisabled: true, // fix issue with duplicate events being sent https://github.com/microsoft/ApplicationInsights-JS/issues/796
namePrefix: applicationName, // fix issue with duplicate events being sent https://github.com/microsoft/ApplicationInsights-JS/issues/796
},
});

Expand Down

0 comments on commit e4c37bc

Please sign in to comment.