Skip to content

Commit

Permalink
Removed mixpanel tracking from the web-app
Browse files Browse the repository at this point in the history
  • Loading branch information
crisnicandrei committed Mar 14, 2024
1 parent f059c31 commit fae91a0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 50 deletions.
13 changes: 0 additions & 13 deletions src/app/core/components/upload-button/upload-button.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* @format */
import { MixpanelService } from '@shared/services/mixpanel/mixpanel.service';
import {
Component,
OnInit,
Expand Down Expand Up @@ -106,18 +105,6 @@ export class UploadButtonComponent
async onFileChange(event) {
this.files = Array.from(event.target.files);
if (this.currentFolder) {
const account = this.account.getAccount();
const workspace = this.currentFolder.type.includes('private')
? 'Private'
: 'Public';

// await this.api.mixpanel.sendData({
// entity:'record',
// action:'submit',
// version:1,
// entityId:account.accountId.toString(),
// })
// this.mixpanel.track('Finalize Upload', { workspace });
if (this.currentFolder.type.includes('public')) {
try {
await this.prompt.confirm(
Expand Down
36 changes: 1 addition & 35 deletions src/app/shared/services/mixpanel/mixpanel.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* @format*/
import { DeviceService } from '@shared/services/device/device.service';
import { Injectable } from '@angular/core';
import mixpanel from 'mixpanel-browser';
import { environment } from '@root/environments/environment';
import { AccountVO } from '@models/account-vo';
import { SecretsService } from '../secrets/secrets.service';

@Injectable({
providedIn: 'root',
Expand All @@ -15,50 +12,19 @@ export class MixpanelService {
protected token: string;
private mixpanelIdentifier: string;

constructor(secrets: SecretsService, private deviceService: DeviceService) {
if (secrets.get('MIXPANEL_TOKEN') && MixpanelService.enableMixpanel) {
this.token = secrets.get('MIXPANEL_TOKEN');
this.enabled = true;
mixpanel.init(this.token, {
debug: environment.analyticsDebug,
persistence: 'localStorage',
track_pageview: true,
});
}
}
constructor() {}

public setMixpanelIdentifier(account: AccountVO): void {
if (this.enabled) {
if (account.accountId) {
this.mixpanelIdentifier = environment.analyticsDebug
? `${environment.environment}:${account.accountId}`
: `${account.accountId}`;
// mixpanel.identify(mixpanelIdentifier);
// mixpanel.people.set({
// $email: account.primaryEmail,
// accountId: `${account.accountId}`,
// environment: environment.environment,
// });
}
}
}

public getMixpanelIdentifier(): string {
return this.mixpanelIdentifier;
}

public track(eventName: string, data: Object): void {
if (this.enabled) {
mixpanel.track(eventName, data);
}
}

public isEnabled(): boolean {
return this.enabled;
}

public trackPageView(page: string): void {
const trackMessage = this.deviceService.getViewMessageForEventTracking();
this.track(trackMessage, { page });
}
}
2 changes: 0 additions & 2 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
NgbTimepickerModule,
NgbTooltipModule,
} from '@ng-bootstrap/ng-bootstrap';
import { MixpanelService } from '@shared/services/mixpanel/mixpanel.service';

window['Stripe'] = () => {
return {
Expand All @@ -42,7 +41,6 @@ window['Stripe'] = () => {
window['doNotLoadGoogleMapsAPI'] = true;

// Disable loading of MixPanel
MixpanelService.enableMixpanel = false;

// Always Replace RouterModule with RouterTestingModule to avoid errors.
Shallow.alwaysReplaceModule(RouterModule, RouterTestingModule);
Expand Down

0 comments on commit fae91a0

Please sign in to comment.