@vrplatform/log 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +12 -5
- package/build/main/tracking/index.js +20 -3
- package/build/main/tracking/index.js.map +1 -1
- package/build/module/tracking/index.d.ts +12 -5
- package/build/module/tracking/index.js +20 -3
- package/build/module/tracking/index.js.map +1 -1
- package/package.json +1 -1
- package/src/tracking/index.ts +24 -6
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type IntercomAPI, useIntercom } from './intercom';
|
|
2
1
|
export type TrackingProps = {
|
|
3
2
|
name: string;
|
|
4
3
|
dataset: string;
|
|
@@ -9,7 +8,6 @@ export type TrackingProps = {
|
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
10
|
export type Tracking = ReturnType<typeof useTracking>;
|
|
12
|
-
export type Intercom = ReturnType<typeof useIntercom>;
|
|
13
11
|
type OptionalUser<T> = T & ({
|
|
14
12
|
userId: string;
|
|
15
13
|
anonymousId?: string;
|
|
@@ -33,12 +31,21 @@ export declare const useTracking: ({ dataset, env, name }: TrackingProps, isDev?
|
|
|
33
31
|
groupId: string;
|
|
34
32
|
traits?: Record<string, any>;
|
|
35
33
|
}>) => void;
|
|
36
|
-
|
|
34
|
+
shutdown: () => Promise<[void, void, void]>;
|
|
35
|
+
alias: (data: {
|
|
37
36
|
distinctId: string;
|
|
38
37
|
alias: string;
|
|
38
|
+
disableGeoip?: boolean;
|
|
39
39
|
}) => void;
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
isFeatureEnabled: (key: string, distinctId: string, options?: {
|
|
41
|
+
groups?: Record<string, string>;
|
|
42
|
+
personProperties?: Record<string, string>;
|
|
43
|
+
groupProperties?: Record<string, Record<string, string>>;
|
|
44
|
+
onlyEvaluateLocally?: boolean;
|
|
45
|
+
sendFeatureFlagEvents?: boolean;
|
|
46
|
+
disableGeoip?: boolean;
|
|
47
|
+
}) => Promise<boolean | undefined>;
|
|
48
|
+
intercom: import("./intercom").IntercomAPI;
|
|
42
49
|
log: import("../log").WorkerLog;
|
|
43
50
|
};
|
|
44
51
|
export {};
|
|
@@ -5,6 +5,18 @@ const analytics_node_1 = require("@june-so/analytics-node");
|
|
|
5
5
|
const posthog_node_1 = require("posthog-node");
|
|
6
6
|
const log_1 = require("../log");
|
|
7
7
|
const intercom_1 = require("./intercom");
|
|
8
|
+
const E2E_TEST_USERS = [
|
|
9
|
+
'9e7dfc88-503c-4222-9905-9116169d2203', // lars+checkly@finalytic.co
|
|
10
|
+
'113d73d8-ee21-46b7-a12a-a74f632401ca', // e2e-invite-member@finalytic.io
|
|
11
|
+
'917b7c4e-cb03-491c-9e94-d33a5bdeca05', // e2e-invite-owner@finalytic.io
|
|
12
|
+
'ec8e5572-74d0-4ae6-af73-bca8db9a27e9', // e2e-sign-up@finalytic.io
|
|
13
|
+
];
|
|
14
|
+
const E2E_TEST_TEAMS = [
|
|
15
|
+
'c4fd21b4-8447-43a2-bdcb-f06a85a935ad', // VRP Automated Testing
|
|
16
|
+
'8f21060e-afe6-410a-b2f4-00a3caa20786', // test_company_xxxx
|
|
17
|
+
];
|
|
18
|
+
const isTest = (userId, groupId) => E2E_TEST_USERS.includes(userId) ||
|
|
19
|
+
(groupId && E2E_TEST_TEAMS.includes(groupId));
|
|
8
20
|
const useTracking = ({ dataset, env, name }, isDev) => {
|
|
9
21
|
const axiom = (0, log_1.useLog)({ name, dataset, env });
|
|
10
22
|
const intercom = (0, intercom_1.useIntercom)(env.INTERCOM_TOKEN, axiom);
|
|
@@ -15,7 +27,7 @@ const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
15
27
|
return {
|
|
16
28
|
// General
|
|
17
29
|
track: async ({ userId, groupId, event, properties, }) => {
|
|
18
|
-
if (isDev)
|
|
30
|
+
if (isDev || isTest(userId, groupId))
|
|
19
31
|
return;
|
|
20
32
|
posthog.capture({
|
|
21
33
|
distinctId: userId,
|
|
@@ -43,6 +55,8 @@ const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
43
55
|
}
|
|
44
56
|
},
|
|
45
57
|
identify: ({ traits, userId, disableGeoip, }) => {
|
|
58
|
+
if (isDev || isTest(userId))
|
|
59
|
+
return;
|
|
46
60
|
posthog.identify({
|
|
47
61
|
distinctId: userId,
|
|
48
62
|
properties: traits,
|
|
@@ -54,6 +68,8 @@ const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
54
68
|
});
|
|
55
69
|
},
|
|
56
70
|
group: ({ traits, groupId, userId, anonymousId, }) => {
|
|
71
|
+
if (isDev || isTest(userId || anonymousId || '', groupId))
|
|
72
|
+
return;
|
|
57
73
|
posthog.groupIdentify({
|
|
58
74
|
groupKey: groupId,
|
|
59
75
|
groupType: 'tenant',
|
|
@@ -65,9 +81,10 @@ const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
65
81
|
else if (userId)
|
|
66
82
|
juneso.group({ userId, groupId, traits });
|
|
67
83
|
},
|
|
68
|
-
// Posthog specific
|
|
69
|
-
alias: ({ distinctId, alias }) => posthog.alias({ distinctId, alias }),
|
|
70
84
|
shutdown: async () => Promise.all([posthog.shutdown(), juneso.closeAndFlush(), axiom.flush()]),
|
|
85
|
+
// Posthog specific
|
|
86
|
+
alias: posthog.alias,
|
|
87
|
+
isFeatureEnabled: posthog.isFeatureEnabled,
|
|
71
88
|
// export intercom and axiom
|
|
72
89
|
intercom,
|
|
73
90
|
log: axiom,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":";;;AAAA,4DAAoD;AACpD,+CAAuC;AACvC,gCAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":";;;AAAA,4DAAoD;AACpD,+CAAuC;AACvC,gCAAgC;AAChC,yCAAyC;AAEzC,MAAM,cAAc,GAAG;IACrB,sC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ACD,QAAQ,EAAE,KAAK,IAAI,EAAE,CACnB,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1E,mBAAmB;QACnB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,4BAA4B;QAC5B,QAAQ;QACR,GAAG,EAAE,KAAK;KACX,CAAC;AACJ,CAAC,CAAC;AArGW,QAAA,WAAW,eAqGtB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type IntercomAPI, useIntercom } from './intercom';
|
|
2
1
|
export type TrackingProps = {
|
|
3
2
|
name: string;
|
|
4
3
|
dataset: string;
|
|
@@ -9,7 +8,6 @@ export type TrackingProps = {
|
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
10
|
export type Tracking = ReturnType<typeof useTracking>;
|
|
12
|
-
export type Intercom = ReturnType<typeof useIntercom>;
|
|
13
11
|
type OptionalUser<T> = T & ({
|
|
14
12
|
userId: string;
|
|
15
13
|
anonymousId?: string;
|
|
@@ -33,12 +31,21 @@ export declare const useTracking: ({ dataset, env, name }: TrackingProps, isDev?
|
|
|
33
31
|
groupId: string;
|
|
34
32
|
traits?: Record<string, any>;
|
|
35
33
|
}>) => void;
|
|
36
|
-
|
|
34
|
+
shutdown: () => Promise<[void, void, void]>;
|
|
35
|
+
alias: (data: {
|
|
37
36
|
distinctId: string;
|
|
38
37
|
alias: string;
|
|
38
|
+
disableGeoip?: boolean;
|
|
39
39
|
}) => void;
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
isFeatureEnabled: (key: string, distinctId: string, options?: {
|
|
41
|
+
groups?: Record<string, string>;
|
|
42
|
+
personProperties?: Record<string, string>;
|
|
43
|
+
groupProperties?: Record<string, Record<string, string>>;
|
|
44
|
+
onlyEvaluateLocally?: boolean;
|
|
45
|
+
sendFeatureFlagEvents?: boolean;
|
|
46
|
+
disableGeoip?: boolean;
|
|
47
|
+
}) => Promise<boolean | undefined>;
|
|
48
|
+
intercom: import("./intercom").IntercomAPI;
|
|
42
49
|
log: import("../log").WorkerLog;
|
|
43
50
|
};
|
|
44
51
|
export {};
|
|
@@ -2,6 +2,18 @@ import { Analytics } from '@june-so/analytics-node';
|
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
3
|
import { useLog } from '../log';
|
|
4
4
|
import { useIntercom } from './intercom';
|
|
5
|
+
const E2E_TEST_USERS = [
|
|
6
|
+
'9e7dfc88-503c-4222-9905-9116169d2203', // lars+checkly@finalytic.co
|
|
7
|
+
'113d73d8-ee21-46b7-a12a-a74f632401ca', // e2e-invite-member@finalytic.io
|
|
8
|
+
'917b7c4e-cb03-491c-9e94-d33a5bdeca05', // e2e-invite-owner@finalytic.io
|
|
9
|
+
'ec8e5572-74d0-4ae6-af73-bca8db9a27e9', // e2e-sign-up@finalytic.io
|
|
10
|
+
];
|
|
11
|
+
const E2E_TEST_TEAMS = [
|
|
12
|
+
'c4fd21b4-8447-43a2-bdcb-f06a85a935ad', // VRP Automated Testing
|
|
13
|
+
'8f21060e-afe6-410a-b2f4-00a3caa20786', // test_company_xxxx
|
|
14
|
+
];
|
|
15
|
+
const isTest = (userId, groupId) => E2E_TEST_USERS.includes(userId) ||
|
|
16
|
+
(groupId && E2E_TEST_TEAMS.includes(groupId));
|
|
5
17
|
export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
6
18
|
const axiom = useLog({ name, dataset, env });
|
|
7
19
|
const intercom = useIntercom(env.INTERCOM_TOKEN, axiom);
|
|
@@ -12,7 +24,7 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
12
24
|
return {
|
|
13
25
|
// General
|
|
14
26
|
track: async ({ userId, groupId, event, properties, }) => {
|
|
15
|
-
if (isDev)
|
|
27
|
+
if (isDev || isTest(userId, groupId))
|
|
16
28
|
return;
|
|
17
29
|
posthog.capture({
|
|
18
30
|
distinctId: userId,
|
|
@@ -40,6 +52,8 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
40
52
|
}
|
|
41
53
|
},
|
|
42
54
|
identify: ({ traits, userId, disableGeoip, }) => {
|
|
55
|
+
if (isDev || isTest(userId))
|
|
56
|
+
return;
|
|
43
57
|
posthog.identify({
|
|
44
58
|
distinctId: userId,
|
|
45
59
|
properties: traits,
|
|
@@ -51,6 +65,8 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
51
65
|
});
|
|
52
66
|
},
|
|
53
67
|
group: ({ traits, groupId, userId, anonymousId, }) => {
|
|
68
|
+
if (isDev || isTest(userId || anonymousId || '', groupId))
|
|
69
|
+
return;
|
|
54
70
|
posthog.groupIdentify({
|
|
55
71
|
groupKey: groupId,
|
|
56
72
|
groupType: 'tenant',
|
|
@@ -62,9 +78,10 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
62
78
|
else if (userId)
|
|
63
79
|
juneso.group({ userId, groupId, traits });
|
|
64
80
|
},
|
|
65
|
-
// Posthog specific
|
|
66
|
-
alias: ({ distinctId, alias }) => posthog.alias({ distinctId, alias }),
|
|
67
81
|
shutdown: async () => Promise.all([posthog.shutdown(), juneso.closeAndFlush(), axiom.flush()]),
|
|
82
|
+
// Posthog specific
|
|
83
|
+
alias: posthog.alias,
|
|
84
|
+
isFeatureEnabled: posthog.isFeatureEnabled,
|
|
68
85
|
// export intercom and axiom
|
|
69
86
|
intercom,
|
|
70
87
|
log: axiom,
|
|
@@ -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,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"index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,MAAM;gBAClB,UAAU,EAAE,MAAM;aACnB,CAAC,CAAC;YACH,IAAI,WAAW;gBAAE,MAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;iBAC3D,IAAI,MAAM;gBAAE,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7D,CAAC;QACD,QAAQ,EAAE,KAAK,IAAI,EAAE,CACnB,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1E,mBAAmB;QACnB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,4BAA4B;QAC5B,QAAQ;QACR,GAAG,EAAE,KAAK;KACX,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/tracking/index.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import { Analytics } from '@june-so/analytics-node';
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
3
|
import { useLog } from '../log';
|
|
4
|
-
import {
|
|
4
|
+
import { useIntercom } from './intercom';
|
|
5
|
+
|
|
6
|
+
const E2E_TEST_USERS = [
|
|
7
|
+
'9e7dfc88-503c-4222-9905-9116169d2203', // lars+checkly@finalytic.co
|
|
8
|
+
'113d73d8-ee21-46b7-a12a-a74f632401ca', // e2e-invite-member@finalytic.io
|
|
9
|
+
'917b7c4e-cb03-491c-9e94-d33a5bdeca05', // e2e-invite-owner@finalytic.io
|
|
10
|
+
'ec8e5572-74d0-4ae6-af73-bca8db9a27e9', // e2e-sign-up@finalytic.io
|
|
11
|
+
];
|
|
12
|
+
const E2E_TEST_TEAMS = [
|
|
13
|
+
'c4fd21b4-8447-43a2-bdcb-f06a85a935ad', // VRP Automated Testing
|
|
14
|
+
'8f21060e-afe6-410a-b2f4-00a3caa20786', // test_company_xxxx
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const isTest = (userId: string, groupId?: string) =>
|
|
18
|
+
E2E_TEST_USERS.includes(userId) ||
|
|
19
|
+
(groupId && E2E_TEST_TEAMS.includes(groupId));
|
|
5
20
|
|
|
6
21
|
export type TrackingProps = {
|
|
7
22
|
name: string;
|
|
@@ -13,7 +28,6 @@ export type TrackingProps = {
|
|
|
13
28
|
};
|
|
14
29
|
};
|
|
15
30
|
export type Tracking = ReturnType<typeof useTracking>;
|
|
16
|
-
export type Intercom = ReturnType<typeof useIntercom>;
|
|
17
31
|
|
|
18
32
|
type OptionalUser<T> = T &
|
|
19
33
|
(
|
|
@@ -48,7 +62,7 @@ export const useTracking = (
|
|
|
48
62
|
event: string;
|
|
49
63
|
properties: Record<string, any>;
|
|
50
64
|
}) => {
|
|
51
|
-
if (isDev) return;
|
|
65
|
+
if (isDev || isTest(userId, groupId)) return;
|
|
52
66
|
|
|
53
67
|
posthog.capture({
|
|
54
68
|
distinctId: userId,
|
|
@@ -84,6 +98,8 @@ export const useTracking = (
|
|
|
84
98
|
traits: Record<string, any>;
|
|
85
99
|
disableGeoip?: boolean;
|
|
86
100
|
}) => {
|
|
101
|
+
if (isDev || isTest(userId)) return;
|
|
102
|
+
|
|
87
103
|
posthog.identify({
|
|
88
104
|
distinctId: userId,
|
|
89
105
|
properties: traits,
|
|
@@ -103,6 +119,8 @@ export const useTracking = (
|
|
|
103
119
|
groupId: string;
|
|
104
120
|
traits?: Record<string, any>;
|
|
105
121
|
}>) => {
|
|
122
|
+
if (isDev || isTest(userId || anonymousId || '', groupId)) return;
|
|
123
|
+
|
|
106
124
|
posthog.groupIdentify({
|
|
107
125
|
groupKey: groupId,
|
|
108
126
|
groupType: 'tenant',
|
|
@@ -112,11 +130,11 @@ export const useTracking = (
|
|
|
112
130
|
if (anonymousId) juneso.group({ anonymousId, groupId, traits });
|
|
113
131
|
else if (userId) juneso.group({ userId, groupId, traits });
|
|
114
132
|
},
|
|
115
|
-
// Posthog specific
|
|
116
|
-
alias: ({ distinctId, alias }: { distinctId: string; alias: string }) =>
|
|
117
|
-
posthog.alias({ distinctId, alias }),
|
|
118
133
|
shutdown: async () =>
|
|
119
134
|
Promise.all([posthog.shutdown(), juneso.closeAndFlush(), axiom.flush()]),
|
|
135
|
+
// Posthog specific
|
|
136
|
+
alias: posthog.alias,
|
|
137
|
+
isFeatureEnabled: posthog.isFeatureEnabled,
|
|
120
138
|
// export intercom and axiom
|
|
121
139
|
intercom,
|
|
122
140
|
log: axiom,
|