Skip to content

Commit

Permalink
fix(console): console crash when running offline (#3602)
Browse files Browse the repository at this point in the history
our analytics crashed and caused the console server to crash as well.

resolves: #3598

## Checklist

- [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [ ] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
ainvoner authored Jul 25, 2023
1 parent b538fe6 commit fab1aa7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions apps/wing-console/console/app/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ export const createAnalytics = (options: CreateAnalyticsOptions): Analytics => {
const sessionId = Date.now();
return {
track(event: string, properties?: Record<string, any>) {
segment.track({
anonymousId: options.anonymousId,
event: event.toLowerCase().replaceAll(/\s/g, ""),
properties,
integrations: {
"Actions Amplitude": {
session_id: sessionId,
try {
segment.track({
anonymousId: options.anonymousId,
event: event.toLowerCase().replaceAll(/\s/g, ""),
properties,
integrations: {
"Actions Amplitude": {
session_id: sessionId,
},
},
},
});
});
} catch (error) {
console.debug("failed to send analytics", error);
}
},
};
};

0 comments on commit fab1aa7

Please sign in to comment.