Skip to content

Commit

Permalink
Fix issue with anonymous telemetry (#362)
Browse files Browse the repository at this point in the history
* Fix issue with anonymous telemetry

* build

---------

Co-authored-by: Nicolas Vuillamy <nicolas.vuillamy@cloudity.com>
  • Loading branch information
nvuillam and nvuillam authored Mar 13, 2024
1 parent b2a7d51 commit 7059db4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## UNRELEASED

## [14.2.4] 2024-03-13

- Fix issue with anonymous telemetry

## [14.2.3] 2024-02-26

- Fix [#351](https://github.com/nvuillam/npm-groovy-lint/issues/351): temp directories aren't cleaned up
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## UNRELEASED

## [14.2.4] 2024-03-13

- Fix issue with anonymous telemetry

## [14.2.3] 2024-02-26

- Fix [#351](https://github.com/nvuillam/npm-groovy-lint/issues/351): temp directories aren't cleaned up
Expand Down
27 changes: 16 additions & 11 deletions lib/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@ async function recordAnonymousEvent(eventType, data) {
const linterEvent = buildLinterEvent(eventType, data);
events.push(linterEvent);
events.push(...(await buildFileStatsEvents(linterEvent, data)));
return (async resolve => {
// Failing to send analytics isn't fatal.
try {
await amplitudeClient.track(events);
debug(`Analytics sent type: ${eventType} ${JSON.stringify(events)}`);
} catch (err) {
debug(`Analytics send failed type: ${eventType} ${JSON.stringify(events)} ${err}`);
} finally {
resolve();
}
})();
try {
return (async resolve => {
// Failing to send analytics isn't fatal.
try {
await amplitudeClient.track(events);
debug(`Analytics sent type: ${eventType} ${JSON.stringify(events)}`);
} catch (err) {
debug(`Analytics send failed type: ${eventType} ${JSON.stringify(events)} ${err}`);
} finally {
resolve();
}
})();
} catch (e) {
debug(`Analytics send failed type: ${eventType} ${JSON.stringify(events)} ${e}`);
return Promise.resolve();
}
}

// Build payload for main linter event
Expand Down

0 comments on commit 7059db4

Please sign in to comment.