@vrplatform/log 2.0.0-alpha.14 → 2.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main/tracking/index.d.ts +14 -23
- package/build/main/tracking/index.js +31 -24
- package/build/main/tracking/index.js.map +1 -1
- package/build/module/tracking/index.d.ts +14 -23
- package/build/module/tracking/index.js +31 -24
- package/build/module/tracking/index.js.map +1 -1
- package/package.json +1 -1
- package/src/tracking/index.ts +65 -26
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Analytics } from '@june-so/analytics-node';
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
|
+
import { type WorkerLog } from '../log';
|
|
4
|
+
import { useIntercom } from './intercom';
|
|
3
5
|
export declare const isTest: (userId: string, groupId?: string, userEmail?: string) => boolean | "" | undefined;
|
|
4
6
|
export declare const convertKeysToSnakeCase: (obj?: Record<string, any>) => Record<string, any>;
|
|
5
7
|
type AuthEvent = 'account_signin_completed' | 'account_signup_code_requested' | 'account_signup_code_completed' | 'account_signup_code_failed' | 'account_signup_completed' | 'account_password_reset_requested' | 'account_password_reset_failed' | 'account_password_reset_completed' | 'account_invitation_accepted' | 'account_signed_out';
|
|
@@ -50,37 +52,26 @@ type OptionalUser<T> = T & ({
|
|
|
50
52
|
anonymousId: string;
|
|
51
53
|
});
|
|
52
54
|
export declare const useTracking: ({ dataset, env, name, debugging }: TrackingProps, isDev?: boolean) => {
|
|
53
|
-
track: (props: TrackProps) => void
|
|
54
|
-
identify: (props: IdentifyProps) => void
|
|
55
|
-
group: (props: GroupProps) => void
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
intercom: {};
|
|
59
|
-
posthog: {};
|
|
60
|
-
shutdown?: undefined;
|
|
61
|
-
alias?: undefined;
|
|
62
|
-
isFeatureEnabled?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
track: ({ userId, groupId, event, properties }: TrackProps) => Promise<void>;
|
|
65
|
-
identify: ({ traits, userId, disableGeoip, timestamp }: IdentifyProps) => void;
|
|
66
|
-
group: ({ traits, groupId, userId, anonymousId, timestamp, }: GroupProps) => void;
|
|
67
|
-
shutdown: () => Promise<[void | undefined, void | undefined, void]>;
|
|
68
|
-
alias: ((data: {
|
|
55
|
+
track: (props: TrackProps) => Promise<void>;
|
|
56
|
+
identify: (props: IdentifyProps) => Promise<void>;
|
|
57
|
+
group: (props: GroupProps) => Promise<void>;
|
|
58
|
+
shutdown: () => Promise<any>;
|
|
59
|
+
alias?: (data: {
|
|
69
60
|
distinctId: string;
|
|
70
61
|
alias: string;
|
|
71
62
|
disableGeoip?: boolean;
|
|
72
|
-
}) => void
|
|
73
|
-
isFeatureEnabled
|
|
63
|
+
}) => void;
|
|
64
|
+
isFeatureEnabled?: (key: string, distinctId: string, options?: {
|
|
74
65
|
groups?: Record<string, string>;
|
|
75
66
|
personProperties?: Record<string, string>;
|
|
76
67
|
groupProperties?: Record<string, Record<string, string>>;
|
|
77
68
|
onlyEvaluateLocally?: boolean;
|
|
78
69
|
sendFeatureFlagEvents?: boolean;
|
|
79
70
|
disableGeoip?: boolean;
|
|
80
|
-
}) => Promise<boolean | undefined
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
}) => Promise<boolean | undefined>;
|
|
72
|
+
log: WorkerLog;
|
|
73
|
+
june?: Analytics;
|
|
74
|
+
intercom?: ReturnType<typeof useIntercom>;
|
|
75
|
+
posthog?: PostHog;
|
|
85
76
|
};
|
|
86
77
|
export {};
|
|
@@ -41,21 +41,32 @@ const convertKeysToSnakeCase = (obj) => {
|
|
|
41
41
|
};
|
|
42
42
|
exports.convertKeysToSnakeCase = convertKeysToSnakeCase;
|
|
43
43
|
const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
44
|
-
if (debugging)
|
|
44
|
+
if (debugging) {
|
|
45
|
+
const log = {
|
|
46
|
+
...console,
|
|
47
|
+
child: () => log,
|
|
48
|
+
addContext: (data) => console.log(data),
|
|
49
|
+
flush: () => Promise.resolve(),
|
|
50
|
+
respond: () => Promise.resolve(new Response()),
|
|
51
|
+
};
|
|
45
52
|
return {
|
|
46
|
-
track: (props) => console.log(props),
|
|
47
|
-
identify: (props) => console.log(props),
|
|
48
|
-
group: (props) => console.log(props),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
track: async (props) => console.log(props),
|
|
54
|
+
identify: async (props) => console.log(props),
|
|
55
|
+
group: async (props) => console.log(props),
|
|
56
|
+
shutdown: () => Promise.resolve(),
|
|
57
|
+
log,
|
|
58
|
+
june: new analytics_node_1.Analytics(''),
|
|
59
|
+
intercom: (0, intercom_1.useIntercom)('', log),
|
|
60
|
+
posthog: new posthog_node_1.PostHog('', {
|
|
61
|
+
host: 'https://app.posthog.com',
|
|
62
|
+
}),
|
|
53
63
|
};
|
|
54
|
-
|
|
64
|
+
}
|
|
65
|
+
const log = (0, log_1.useLog)({ name, dataset, env });
|
|
55
66
|
const intercom = env.INTERCOM_TOKEN
|
|
56
|
-
? (0, intercom_1.useIntercom)(env.INTERCOM_TOKEN,
|
|
67
|
+
? (0, intercom_1.useIntercom)(env.INTERCOM_TOKEN, log)
|
|
57
68
|
: undefined;
|
|
58
|
-
const
|
|
69
|
+
const june = env.JUNESO_TOKEN ? new analytics_node_1.Analytics(env.JUNESO_TOKEN) : undefined;
|
|
59
70
|
const posthog = env.POSTHOG_TOKEN
|
|
60
71
|
? new posthog_node_1.PostHog(env.POSTHOG_TOKEN, {
|
|
61
72
|
host: 'https://app.posthog.com',
|
|
@@ -74,7 +85,7 @@ const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
74
85
|
},
|
|
75
86
|
properties: (0, exports.convertKeysToSnakeCase)(properties),
|
|
76
87
|
});
|
|
77
|
-
|
|
88
|
+
june?.track({
|
|
78
89
|
userId,
|
|
79
90
|
event,
|
|
80
91
|
properties,
|
|
@@ -94,7 +105,7 @@ const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
94
105
|
console.error(error);
|
|
95
106
|
}
|
|
96
107
|
},
|
|
97
|
-
identify: ({ traits, userId, disableGeoip, timestamp }) => {
|
|
108
|
+
identify: async ({ traits, userId, disableGeoip, timestamp, }) => {
|
|
98
109
|
if (isDev || (0, exports.isTest)(userId))
|
|
99
110
|
return;
|
|
100
111
|
posthog?.identify({
|
|
@@ -102,7 +113,7 @@ const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
102
113
|
properties: (0, exports.convertKeysToSnakeCase)(traits),
|
|
103
114
|
disableGeoip,
|
|
104
115
|
});
|
|
105
|
-
|
|
116
|
+
june?.identify({
|
|
106
117
|
userId,
|
|
107
118
|
traits,
|
|
108
119
|
timestamp,
|
|
@@ -111,7 +122,7 @@ const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
111
122
|
console.error(err);
|
|
112
123
|
});
|
|
113
124
|
},
|
|
114
|
-
group: ({ traits, groupId, userId, anonymousId, timestamp, }) => {
|
|
125
|
+
group: async ({ traits, groupId, userId, anonymousId, timestamp, }) => {
|
|
115
126
|
if (isDev || (0, exports.isTest)(userId || anonymousId || '', groupId))
|
|
116
127
|
return;
|
|
117
128
|
posthog?.groupIdentify({
|
|
@@ -121,29 +132,25 @@ const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
121
132
|
distinctId: userId,
|
|
122
133
|
});
|
|
123
134
|
if (anonymousId)
|
|
124
|
-
|
|
135
|
+
june?.group({ anonymousId, groupId, traits, timestamp }, (err) => {
|
|
125
136
|
if (err)
|
|
126
137
|
console.error(err);
|
|
127
138
|
});
|
|
128
139
|
else if (userId)
|
|
129
|
-
|
|
140
|
+
june?.group({ userId, groupId, traits, timestamp }, (err) => {
|
|
130
141
|
if (err)
|
|
131
142
|
console.error(err);
|
|
132
143
|
});
|
|
133
144
|
},
|
|
134
|
-
shutdown: async () => Promise.all([
|
|
135
|
-
posthog?.shutdown(),
|
|
136
|
-
juneso?.closeAndFlush(),
|
|
137
|
-
axiom?.flush(),
|
|
138
|
-
]),
|
|
145
|
+
shutdown: async () => Promise.all([posthog?.shutdown(), june?.closeAndFlush(), log?.flush()]),
|
|
139
146
|
// Posthog specific
|
|
140
147
|
alias: posthog?.alias,
|
|
141
148
|
isFeatureEnabled: posthog?.isFeatureEnabled,
|
|
142
149
|
// export intercom and axiom
|
|
143
150
|
intercom,
|
|
144
151
|
posthog,
|
|
145
|
-
june
|
|
146
|
-
log
|
|
152
|
+
june,
|
|
153
|
+
log,
|
|
147
154
|
};
|
|
148
155
|
};
|
|
149
156
|
exports.useTracking = useTracking;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":";;;AAAA,4DAAoD;AACpD,+CAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":";;;AAAA,4DAAoD;AACpD,+CAAuC;AACvC,gCAAgD;AAChD,yCAAyC;AAEzC,MAAM,cAAc,GAAG;IACrB,gCAAgC,EAAE,sCAAsC;IACxE,+BAA+B,EAAE,sCAAsC;IACvE,0BAA0B,EAAE,sCAAsC;IAClE,2BAA2B,EAAE,sCAAsC;CACpE,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,uBAAuB,EAAE,sCAAsC;IAC/D,iBAAiB,EAAE,sCAAsC;CAC1D,CAAC;AAEK,MAAM,MAAM,GAAG,CAAC,MAAc,EAAE,OAAgB,EAAE,SAAkB,EAAE,EAAE,CAC7E,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9C,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CA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,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QACzE,mBAAmB;QACnB,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,4BAA4B;QAC5B,QAAQ;QACR,OAAO;QACP,IAAI;QACJ,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC;AA9JW,QAAA,WAAW,eA8JtB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Analytics } from '@june-so/analytics-node';
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
|
+
import { type WorkerLog } from '../log';
|
|
4
|
+
import { useIntercom } from './intercom';
|
|
3
5
|
export declare const isTest: (userId: string, groupId?: string, userEmail?: string) => boolean | "" | undefined;
|
|
4
6
|
export declare const convertKeysToSnakeCase: (obj?: Record<string, any>) => Record<string, any>;
|
|
5
7
|
type AuthEvent = 'account_signin_completed' | 'account_signup_code_requested' | 'account_signup_code_completed' | 'account_signup_code_failed' | 'account_signup_completed' | 'account_password_reset_requested' | 'account_password_reset_failed' | 'account_password_reset_completed' | 'account_invitation_accepted' | 'account_signed_out';
|
|
@@ -50,37 +52,26 @@ type OptionalUser<T> = T & ({
|
|
|
50
52
|
anonymousId: string;
|
|
51
53
|
});
|
|
52
54
|
export declare const useTracking: ({ dataset, env, name, debugging }: TrackingProps, isDev?: boolean) => {
|
|
53
|
-
track: (props: TrackProps) => void
|
|
54
|
-
identify: (props: IdentifyProps) => void
|
|
55
|
-
group: (props: GroupProps) => void
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
intercom: {};
|
|
59
|
-
posthog: {};
|
|
60
|
-
shutdown?: undefined;
|
|
61
|
-
alias?: undefined;
|
|
62
|
-
isFeatureEnabled?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
track: ({ userId, groupId, event, properties }: TrackProps) => Promise<void>;
|
|
65
|
-
identify: ({ traits, userId, disableGeoip, timestamp }: IdentifyProps) => void;
|
|
66
|
-
group: ({ traits, groupId, userId, anonymousId, timestamp, }: GroupProps) => void;
|
|
67
|
-
shutdown: () => Promise<[void | undefined, void | undefined, void]>;
|
|
68
|
-
alias: ((data: {
|
|
55
|
+
track: (props: TrackProps) => Promise<void>;
|
|
56
|
+
identify: (props: IdentifyProps) => Promise<void>;
|
|
57
|
+
group: (props: GroupProps) => Promise<void>;
|
|
58
|
+
shutdown: () => Promise<any>;
|
|
59
|
+
alias?: (data: {
|
|
69
60
|
distinctId: string;
|
|
70
61
|
alias: string;
|
|
71
62
|
disableGeoip?: boolean;
|
|
72
|
-
}) => void
|
|
73
|
-
isFeatureEnabled
|
|
63
|
+
}) => void;
|
|
64
|
+
isFeatureEnabled?: (key: string, distinctId: string, options?: {
|
|
74
65
|
groups?: Record<string, string>;
|
|
75
66
|
personProperties?: Record<string, string>;
|
|
76
67
|
groupProperties?: Record<string, Record<string, string>>;
|
|
77
68
|
onlyEvaluateLocally?: boolean;
|
|
78
69
|
sendFeatureFlagEvents?: boolean;
|
|
79
70
|
disableGeoip?: boolean;
|
|
80
|
-
}) => Promise<boolean | undefined
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
}) => Promise<boolean | undefined>;
|
|
72
|
+
log: WorkerLog;
|
|
73
|
+
june?: Analytics;
|
|
74
|
+
intercom?: ReturnType<typeof useIntercom>;
|
|
75
|
+
posthog?: PostHog;
|
|
85
76
|
};
|
|
86
77
|
export {};
|
|
@@ -36,21 +36,32 @@ export const convertKeysToSnakeCase = (obj) => {
|
|
|
36
36
|
return result;
|
|
37
37
|
};
|
|
38
38
|
export const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
39
|
-
if (debugging)
|
|
39
|
+
if (debugging) {
|
|
40
|
+
const log = {
|
|
41
|
+
...console,
|
|
42
|
+
child: () => log,
|
|
43
|
+
addContext: (data) => console.log(data),
|
|
44
|
+
flush: () => Promise.resolve(),
|
|
45
|
+
respond: () => Promise.resolve(new Response()),
|
|
46
|
+
};
|
|
40
47
|
return {
|
|
41
|
-
track: (props) => console.log(props),
|
|
42
|
-
identify: (props) => console.log(props),
|
|
43
|
-
group: (props) => console.log(props),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
track: async (props) => console.log(props),
|
|
49
|
+
identify: async (props) => console.log(props),
|
|
50
|
+
group: async (props) => console.log(props),
|
|
51
|
+
shutdown: () => Promise.resolve(),
|
|
52
|
+
log,
|
|
53
|
+
june: new Analytics(''),
|
|
54
|
+
intercom: useIntercom('', log),
|
|
55
|
+
posthog: new PostHog('', {
|
|
56
|
+
host: 'https://app.posthog.com',
|
|
57
|
+
}),
|
|
48
58
|
};
|
|
49
|
-
|
|
59
|
+
}
|
|
60
|
+
const log = useLog({ name, dataset, env });
|
|
50
61
|
const intercom = env.INTERCOM_TOKEN
|
|
51
|
-
? useIntercom(env.INTERCOM_TOKEN,
|
|
62
|
+
? useIntercom(env.INTERCOM_TOKEN, log)
|
|
52
63
|
: undefined;
|
|
53
|
-
const
|
|
64
|
+
const june = env.JUNESO_TOKEN ? new Analytics(env.JUNESO_TOKEN) : undefined;
|
|
54
65
|
const posthog = env.POSTHOG_TOKEN
|
|
55
66
|
? new PostHog(env.POSTHOG_TOKEN, {
|
|
56
67
|
host: 'https://app.posthog.com',
|
|
@@ -69,7 +80,7 @@ export const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
69
80
|
},
|
|
70
81
|
properties: convertKeysToSnakeCase(properties),
|
|
71
82
|
});
|
|
72
|
-
|
|
83
|
+
june?.track({
|
|
73
84
|
userId,
|
|
74
85
|
event,
|
|
75
86
|
properties,
|
|
@@ -89,7 +100,7 @@ export const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
89
100
|
console.error(error);
|
|
90
101
|
}
|
|
91
102
|
},
|
|
92
|
-
identify: ({ traits, userId, disableGeoip, timestamp }) => {
|
|
103
|
+
identify: async ({ traits, userId, disableGeoip, timestamp, }) => {
|
|
93
104
|
if (isDev || isTest(userId))
|
|
94
105
|
return;
|
|
95
106
|
posthog?.identify({
|
|
@@ -97,7 +108,7 @@ export const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
97
108
|
properties: convertKeysToSnakeCase(traits),
|
|
98
109
|
disableGeoip,
|
|
99
110
|
});
|
|
100
|
-
|
|
111
|
+
june?.identify({
|
|
101
112
|
userId,
|
|
102
113
|
traits,
|
|
103
114
|
timestamp,
|
|
@@ -106,7 +117,7 @@ export const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
106
117
|
console.error(err);
|
|
107
118
|
});
|
|
108
119
|
},
|
|
109
|
-
group: ({ traits, groupId, userId, anonymousId, timestamp, }) => {
|
|
120
|
+
group: async ({ traits, groupId, userId, anonymousId, timestamp, }) => {
|
|
110
121
|
if (isDev || isTest(userId || anonymousId || '', groupId))
|
|
111
122
|
return;
|
|
112
123
|
posthog?.groupIdentify({
|
|
@@ -116,29 +127,25 @@ export const useTracking = ({ dataset, env, name, debugging }, isDev) => {
|
|
|
116
127
|
distinctId: userId,
|
|
117
128
|
});
|
|
118
129
|
if (anonymousId)
|
|
119
|
-
|
|
130
|
+
june?.group({ anonymousId, groupId, traits, timestamp }, (err) => {
|
|
120
131
|
if (err)
|
|
121
132
|
console.error(err);
|
|
122
133
|
});
|
|
123
134
|
else if (userId)
|
|
124
|
-
|
|
135
|
+
june?.group({ userId, groupId, traits, timestamp }, (err) => {
|
|
125
136
|
if (err)
|
|
126
137
|
console.error(err);
|
|
127
138
|
});
|
|
128
139
|
},
|
|
129
|
-
shutdown: async () => Promise.all([
|
|
130
|
-
posthog?.shutdown(),
|
|
131
|
-
juneso?.closeAndFlush(),
|
|
132
|
-
axiom?.flush(),
|
|
133
|
-
]),
|
|
140
|
+
shutdown: async () => Promise.all([posthog?.shutdown(), june?.closeAndFlush(), log?.flush()]),
|
|
134
141
|
// Posthog specific
|
|
135
142
|
alias: posthog?.alias,
|
|
136
143
|
isFeatureEnabled: posthog?.isFeatureEnabled,
|
|
137
144
|
// export intercom and axiom
|
|
138
145
|
intercom,
|
|
139
146
|
posthog,
|
|
140
|
-
june
|
|
141
|
-
log
|
|
147
|
+
june,
|
|
148
|
+
log,
|
|
142
149
|
};
|
|
143
150
|
};
|
|
144
151
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAkB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,cAAc,GAAG;IACrB,gCAAgC,EAAE,sCAAsC;IACxE,+BAA+B,EAAE,sCAAsC;IACvE,0BAA0B,EAAE,sCAAsC;IAClE,2BAA2B,EAAE,sCAAsC;CACpE,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,uBAAuB,EAAE,sCAAsC;IAC/D,iBAAiB,EAAE,sCAAsC;CAC1D,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAc,EAAE,OAAgB,EAAE,SAAkB,EAAE,EAAE,CAC7E,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9C,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC,SAAS,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G,EAAE,KAAK,EAAE,CAAC,CAAC;QACzE,mBAAmB;QACnB,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,4BAA4B;QAC5B,QAAQ;QACR,OAAO;QACP,IAAI;QACJ,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/tracking/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Analytics } from '@june-so/analytics-node';
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
|
-
import { useLog } from '../log';
|
|
3
|
+
import { type WorkerLog, useLog } from '../log';
|
|
4
4
|
import { useIntercom } from './intercom';
|
|
5
5
|
|
|
6
6
|
const E2E_TEST_USERS = {
|
|
@@ -176,23 +176,61 @@ type OptionalUser<T> = T &
|
|
|
176
176
|
export const useTracking = (
|
|
177
177
|
{ dataset, env, name, debugging }: TrackingProps,
|
|
178
178
|
isDev?: boolean
|
|
179
|
-
)
|
|
180
|
-
|
|
179
|
+
): {
|
|
180
|
+
track: (props: TrackProps) => Promise<void>;
|
|
181
|
+
identify: (props: IdentifyProps) => Promise<void>;
|
|
182
|
+
group: (props: GroupProps) => Promise<void>;
|
|
183
|
+
shutdown: () => Promise<any>;
|
|
184
|
+
alias?: (data: {
|
|
185
|
+
distinctId: string;
|
|
186
|
+
alias: string;
|
|
187
|
+
disableGeoip?: boolean;
|
|
188
|
+
}) => void;
|
|
189
|
+
isFeatureEnabled?: (
|
|
190
|
+
key: string,
|
|
191
|
+
distinctId: string,
|
|
192
|
+
options?: {
|
|
193
|
+
groups?: Record<string, string>;
|
|
194
|
+
personProperties?: Record<string, string>;
|
|
195
|
+
groupProperties?: Record<string, Record<string, string>>;
|
|
196
|
+
onlyEvaluateLocally?: boolean;
|
|
197
|
+
sendFeatureFlagEvents?: boolean;
|
|
198
|
+
disableGeoip?: boolean;
|
|
199
|
+
}
|
|
200
|
+
) => Promise<boolean | undefined>;
|
|
201
|
+
log: WorkerLog;
|
|
202
|
+
june?: Analytics;
|
|
203
|
+
intercom?: ReturnType<typeof useIntercom>;
|
|
204
|
+
posthog?: PostHog;
|
|
205
|
+
} => {
|
|
206
|
+
if (debugging) {
|
|
207
|
+
const log: WorkerLog = {
|
|
208
|
+
...console,
|
|
209
|
+
child: () => log,
|
|
210
|
+
addContext: (data: Record<string, any>) => console.log(data),
|
|
211
|
+
flush: () => Promise.resolve(),
|
|
212
|
+
respond: () => Promise.resolve(new Response()),
|
|
213
|
+
};
|
|
214
|
+
|
|
181
215
|
return {
|
|
182
|
-
track: (props: TrackProps) => console.log(props),
|
|
183
|
-
identify: (props: IdentifyProps) => console.log(props),
|
|
184
|
-
group: (props: GroupProps) => console.log(props),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
216
|
+
track: async (props: TrackProps) => console.log(props),
|
|
217
|
+
identify: async (props: IdentifyProps) => console.log(props),
|
|
218
|
+
group: async (props: GroupProps) => console.log(props),
|
|
219
|
+
shutdown: () => Promise.resolve(),
|
|
220
|
+
log,
|
|
221
|
+
june: new Analytics(''),
|
|
222
|
+
intercom: useIntercom('', log),
|
|
223
|
+
posthog: new PostHog('', {
|
|
224
|
+
host: 'https://app.posthog.com',
|
|
225
|
+
}),
|
|
189
226
|
};
|
|
227
|
+
}
|
|
190
228
|
|
|
191
|
-
const
|
|
229
|
+
const log = useLog({ name, dataset, env });
|
|
192
230
|
const intercom = env.INTERCOM_TOKEN
|
|
193
|
-
? useIntercom(env.INTERCOM_TOKEN,
|
|
231
|
+
? useIntercom(env.INTERCOM_TOKEN, log)
|
|
194
232
|
: undefined;
|
|
195
|
-
const
|
|
233
|
+
const june = env.JUNESO_TOKEN ? new Analytics(env.JUNESO_TOKEN) : undefined;
|
|
196
234
|
const posthog = env.POSTHOG_TOKEN
|
|
197
235
|
? new PostHog(env.POSTHOG_TOKEN, {
|
|
198
236
|
host: 'https://app.posthog.com',
|
|
@@ -212,7 +250,7 @@ export const useTracking = (
|
|
|
212
250
|
},
|
|
213
251
|
properties: convertKeysToSnakeCase(properties),
|
|
214
252
|
});
|
|
215
|
-
|
|
253
|
+
june?.track(
|
|
216
254
|
{
|
|
217
255
|
userId,
|
|
218
256
|
event,
|
|
@@ -234,7 +272,12 @@ export const useTracking = (
|
|
|
234
272
|
console.error(error);
|
|
235
273
|
}
|
|
236
274
|
},
|
|
237
|
-
identify: ({
|
|
275
|
+
identify: async ({
|
|
276
|
+
traits,
|
|
277
|
+
userId,
|
|
278
|
+
disableGeoip,
|
|
279
|
+
timestamp,
|
|
280
|
+
}: IdentifyProps) => {
|
|
238
281
|
if (isDev || isTest(userId)) return;
|
|
239
282
|
|
|
240
283
|
posthog?.identify({
|
|
@@ -242,7 +285,7 @@ export const useTracking = (
|
|
|
242
285
|
properties: convertKeysToSnakeCase(traits),
|
|
243
286
|
disableGeoip,
|
|
244
287
|
});
|
|
245
|
-
|
|
288
|
+
june?.identify(
|
|
246
289
|
{
|
|
247
290
|
userId,
|
|
248
291
|
traits,
|
|
@@ -253,7 +296,7 @@ export const useTracking = (
|
|
|
253
296
|
}
|
|
254
297
|
);
|
|
255
298
|
},
|
|
256
|
-
group: ({
|
|
299
|
+
group: async ({
|
|
257
300
|
traits,
|
|
258
301
|
groupId,
|
|
259
302
|
userId,
|
|
@@ -269,27 +312,23 @@ export const useTracking = (
|
|
|
269
312
|
distinctId: userId,
|
|
270
313
|
});
|
|
271
314
|
if (anonymousId)
|
|
272
|
-
|
|
315
|
+
june?.group({ anonymousId, groupId, traits, timestamp }, (err) => {
|
|
273
316
|
if (err) console.error(err);
|
|
274
317
|
});
|
|
275
318
|
else if (userId)
|
|
276
|
-
|
|
319
|
+
june?.group({ userId, groupId, traits, timestamp }, (err) => {
|
|
277
320
|
if (err) console.error(err);
|
|
278
321
|
});
|
|
279
322
|
},
|
|
280
323
|
shutdown: async () =>
|
|
281
|
-
Promise.all([
|
|
282
|
-
posthog?.shutdown(),
|
|
283
|
-
juneso?.closeAndFlush(),
|
|
284
|
-
axiom?.flush(),
|
|
285
|
-
]),
|
|
324
|
+
Promise.all([posthog?.shutdown(), june?.closeAndFlush(), log?.flush()]),
|
|
286
325
|
// Posthog specific
|
|
287
326
|
alias: posthog?.alias,
|
|
288
327
|
isFeatureEnabled: posthog?.isFeatureEnabled,
|
|
289
328
|
// export intercom and axiom
|
|
290
329
|
intercom,
|
|
291
330
|
posthog,
|
|
292
|
-
june
|
|
293
|
-
log
|
|
331
|
+
june,
|
|
332
|
+
log,
|
|
294
333
|
};
|
|
295
334
|
};
|