diff --git a/run.sh b/run.sh index c7c0563..dd73c0a 100644 --- a/run.sh +++ b/run.sh @@ -15,6 +15,7 @@ do sed -i $SED_EXTRA_ARGS "s?{{SENTRY_ENV}}?${SENTRY_ENV}?g" $f; sed -i $SED_EXTRA_ARGS "s?{{CLARITY_PROJECT_ID}}?${CLARITY_PROJECT_ID}?g" $f; sed -i $SED_EXTRA_ARGS "s?{{SEGMENT_ID}}?${SEGMENT_ID}?g" $f; + sed -i $SED_EXTRA_ARGS "s?{{MIXPANEL_PROJECT_TOKEN}}?${MIXPANEL_PROJECT_TOKEN}?g" $f; done nginx -g "daemon off;" diff --git a/src/app/core/services/integration/tracking.service.spec.ts b/src/app/core/services/integration/tracking.service.spec.ts index 74a9357..d565a71 100644 --- a/src/app/core/services/integration/tracking.service.spec.ts +++ b/src/app/core/services/integration/tracking.service.spec.ts @@ -8,9 +8,12 @@ describe('TrackingService', () => { beforeEach(() => { TestBed.configureTestingModule({}); service = TestBed.inject(TrackingService); - (window as any).analytics = { + (window as any).mixpanel = { track: () => undefined, - identify: () => undefined + identify: () => undefined, + people: { + set: () => undefined + } }; }); diff --git a/src/app/core/services/integration/tracking.service.ts b/src/app/core/services/integration/tracking.service.ts index 04a2ffc..087b681 100644 --- a/src/app/core/services/integration/tracking.service.ts +++ b/src/app/core/services/integration/tracking.service.ts @@ -36,7 +36,7 @@ export class TrackingService { } get tracking() { - return (window as any).analytics; + return (window as any).mixpanel; } eventTrack(action: string, properties: any = {}): void { @@ -45,31 +45,45 @@ export class TrackingService { ...flattenedObject, Asset: 'Partner Dashboard Web' }; - if (this.tracking) { - this.tracking.track(action, properties); + try { + if (this.tracking) { + this.tracking.track(action, properties); + } + } catch (e) { + console.error('Tracking error:', e); } } onSignIn(email: string | undefined, partnerOrgId: number, partnerOrgName: string, orgId: string): void { - if (this.tracking) { - this.tracking.identify(email, { - partnerOrgId, - partnerOrgName, - orgId - }); - this.identityEmail = email; + try { + if (this.tracking) { + this.tracking.identify(email); + this.tracking.people.set({ + partnerOrgId, + partnerOrgName, + orgId + }); + this.identityEmail = email; + } + } catch (e) { + console.error('Tracking error:', e); } this.eventTrack('Sign In'); } onSignUp(email: string | undefined, partnerOrgId: number, partnerOrgName: string, orgId: string): void { - if (this.tracking) { - this.tracking.identify(email, { - partnerOrgId, - partnerOrgName, - orgId - }); - this.identityEmail = email; + try { + if (this.tracking) { + this.tracking.identify(email); + this.tracking.people.set({ + partnerOrgId, + partnerOrgName, + orgId + }); + this.identityEmail = email; + } + } catch (e) { + console.error('Tracking error:', e); } this.eventTrack('Sign Up'); } diff --git a/src/index.html b/src/index.html index 7ba837a..af93cc1 100644 --- a/src/index.html +++ b/src/index.html @@ -18,15 +18,22 @@ } - +