Skip to content

Commit

Permalink
Registering super properties
Browse files Browse the repository at this point in the history
Fixes #94
  • Loading branch information
tombeckenham committed Nov 17, 2024
1 parent 49edb71 commit 61ba4c3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/background/service/mixpanel.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import mixpanel from 'mixpanel-browser';

import { version } from '../../../package.json';

type BaseProperties = {
wallet_address?: string;
network?: string;
timestamp?: number;
};

// Super properties that will be sent with every event
type SuperProperties = {
app_version: string;
platform: 'extension';
environment: 'development' | 'production';
wallet_type: 'flow';
};

type TrackingEvents = {
// Platform Events
app_launched: BaseProperties;
Expand Down Expand Up @@ -79,6 +89,17 @@ class MixpanelService {
return MixpanelService.instance;
}

private registerSuperProperties() {
const superProperties: SuperProperties = {
app_version: version,
platform: 'extension',
environment: process.env.NODE_ENV === 'production' ? 'production' : 'development',
wallet_type: 'flow',
};

mixpanel.register(superProperties);
}

init() {
if (this.initialized) return;

Expand All @@ -92,8 +113,12 @@ class MixpanelService {
debug: process.env.NODE_ENV !== 'production',
track_pageview: true,
persistence: 'localStorage',
batch_requests: true,
batch_size: 10,
batch_flush_interval_ms: 2000,
});

this.registerSuperProperties();
this.initialized = true;
}

Expand Down

0 comments on commit 61ba4c3

Please sign in to comment.