File tree Expand file tree Collapse file tree 4 files changed +68
-28
lines changed
@types/analytics__segment Expand file tree Collapse file tree 4 files changed +68
-28
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import Analytics from 'analytics' ;
21import googleTagManager from '@analytics/google-tag-manager' ;
3- import segmentPlugin from '@analytics/segment' ;
2+ import Analytics from 'analytics' ;
3+ import userpilot from './common/analytics-plugins/userpilot' ;
44import { isDev } from './common/isDevEnvironment' ;
55
66const analytics = Analytics ( {
@@ -13,10 +13,8 @@ const analytics = Analytics({
1313 preview : 'env-4' ,
1414 } ) ,
1515 } ) ,
16- segmentPlugin ( {
17- writeKey : isDev ( )
18- ? 'AxHbacd31w50NwjDM8tadsP82hSwTz4Z'
19- : 'oxd3W7coKxDdzq99F88doV5VvQrESbJh' ,
16+ userpilot ( {
17+ token : isDev ( ) ? 'STG-NX-54e88e10' : 'NX-54e88e10' ,
2018 } ) ,
2119 ] ,
2220} ) ;
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ export const Track = ({
5353 name : userData . name ,
5454 email : userData . email ,
5555 company : activeWorkspace . company ,
56+ workspace : activeWorkspace ,
5657 } ) ;
5758
5859 track (
@@ -68,8 +69,8 @@ export const Track = ({
6869 } ,
6970 {
7071 plugins : {
71- // disable track event for segment
72- segment : false ,
72+ // disable userpilot for this event
73+ userpilot : false ,
7374 } ,
7475 }
7576 ) ;
Original file line number Diff line number Diff line change 1+ import { User } from 'src/features/api' ;
2+ import { Userpilot } from 'userpilot' ;
3+
4+ declare global {
5+ interface Window {
6+ userpilot ?: {
7+ initialized : number ;
8+ } ;
9+ }
10+ }
11+
12+ interface UserpilotConfig {
13+ token : string ;
14+ name ?: string ;
15+ }
16+
17+ interface IPayload {
18+ type : string ;
19+ userId : string ;
20+ }
21+
22+ interface IIdentifyPayload extends IPayload {
23+ traits : User & { workspace : { id : number ; company : string } } ;
24+ }
25+
26+ export default function userpilotPlugin ( pluginSettings : UserpilotConfig ) {
27+ return {
28+ name : 'userpilot' ,
29+ config : { ...pluginSettings } ,
30+ initialize : ( { config } : { config : UserpilotConfig } ) => {
31+ Userpilot . initialize ( config . token ) ;
32+ } ,
33+ identify : ( { payload } : { payload : IIdentifyPayload } ) => {
34+ const { userId, traits } = payload ;
35+ const { workspace, ...basicTraits } = traits ;
36+
37+ Userpilot . identify ( userId , {
38+ ...basicTraits ,
39+ company : {
40+ id : workspace . id ,
41+ name : workspace . company ,
42+ } ,
43+ } ) ;
44+ } ,
45+
46+ page : ( ) => {
47+ Userpilot . reload ( ) ;
48+ } ,
49+
50+ track : ( {
51+ payload,
52+ } : {
53+ payload : IPayload & { event : string ; properties : Record < string , any > } ;
54+ } ) => {
55+ const { event, properties, userId } = payload ;
56+ Userpilot . track ( event , { ...properties , userId } ) ;
57+ } ,
58+
59+ loaded : ( ) => ! ! window . userpilot ,
60+ } ;
61+ }
You can’t perform that action at this time.
0 commit comments