Skip to content

Commit

Permalink
fix: Fixed Google Analytics user properties
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Aug 26, 2022
1 parent 1a47158 commit 73ab7cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gtag/Tracker.ts
Expand Up @@ -201,5 +201,6 @@ export class Tracker {

public setUserProperty(key: string, value: any) {
this.userProperties[key] = value;
this.trackEvent('user_engagement');
}
}
16 changes: 16 additions & 0 deletions src/gtag/index.ts
Expand Up @@ -66,6 +66,22 @@ internalEv.on('webpack.injected', () => {

otherTracker.trackEvent('page_view', { authenticated, method });
}

internalEv.on('config.update', (evt) => {
if (evt.path[0] === 'poweredBy') {
mainTracker.setUserProperty('powered_by', evt.value || '-');
if (otherTracker) {
otherTracker.setUserProperty('powered_by', evt.value || '-');
}
} else if (evt.path[0] === 'googleAnalyticsUserProperty' && otherTracker) {
if (typeof config.googleAnalyticsUserProperty === 'object') {
for (const key in config.googleAnalyticsUserProperty) {
const value = config.googleAnalyticsUserProperty[key];
otherTracker.setUserProperty(key, value);
}
}
}
});
});

if (!config.disableGoogleAnalytics) {
Expand Down

0 comments on commit 73ab7cd

Please sign in to comment.