Skip to content

Commit 922ca03

Browse files
committed
Make PostHog init method idempotent
Adds a check in the PostHog analytics class's init method to return early if the instance has already been initialized. Ensures that calling init() multiple times does not reinitialize and prevents possible side effects from multiple initializations.
1 parent 1351537 commit 922ca03

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

apps/desktop/src/lib/analytics/posthog.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class PostHogWrapper {
3737
}
3838

3939
async init() {
40+
if (this._instance) return;
4041
const appInfo = await this.backend.getAppInfo();
4142
this._instance = posthog.init(PUBLIC_POSTHOG_API_KEY, {
4243
api_host: 'https://eu.posthog.com',

0 commit comments

Comments
 (0)