Skip to content

Commit

Permalink
update posthog
Browse files Browse the repository at this point in the history
  • Loading branch information
Palabola committed Nov 12, 2024
1 parent 0e14b4a commit f391feb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
39 changes: 28 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"ng2-charts": "^6.0.1",
"ngx-lightbox": "^3.0.0",
"ngx-markdown": "^17.2.1",
"posthog-js": "^1.132.2",
"posthog-js": "1.178.0",
"process": "^0.11.10",
"rxjs": "~7.8.0",
"serverless-http": "^3.2.0",
Expand Down
9 changes: 3 additions & 6 deletions src/app/services/analytics.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isPlatformBrowser } from '@angular/common';
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import * as Sentry from "@sentry/angular";
import posthog from 'posthog-js';

const POSTHOG_KEY = import.meta?.env?.NG_APP_POSTHOG_KEY;
const POSTHOG_HOST = import.meta?.env?.NG_APP_POSTHOG_HOST;
Expand All @@ -22,26 +23,22 @@ export class AnalyticsService {
}

if (!this.trackingInitialized && POSTHOG_KEY && POSTHOG_HOST && typeof window !== 'undefined' && typeof document !== 'undefined') {
/*
posthog.init(POSTHOG_KEY, {
api_host: POSTHOG_HOST,
persistence: 'sessionStorage',
});
this.trackingInitialized = true;
*/
}
}

public trackEvent(eventName: string, properties: { [key: string]: any }): void {
if (this.trackingInitialized) {
//posthog.capture(eventName, properties)
console.log('Event tracked:', eventName, properties);
posthog.capture(eventName, properties)
}
}

public getId() {
//return posthog.get_distinct_id();
return '';
return posthog.get_distinct_id();
}

public SentryException(exception: any, hint?: any) {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
Expand Down

0 comments on commit f391feb

Please sign in to comment.