@vrplatform/log 2.0.0-alpha.11 → 2.0.0-alpha.13
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 +6 -2
- package/build/main/tracking/index.js +50 -23
- package/build/main/tracking/index.js.map +1 -1
- package/build/module/tracking/index.d.ts +6 -2
- package/build/module/tracking/index.js +44 -19
- package/build/module/tracking/index.js.map +1 -1
- package/package.json +1 -1
- package/src/tracking/index.ts +84 -53
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Analytics } from '@june-so/analytics-node';
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
|
+
export declare const isTest: (userId: string, groupId?: string, userEmail?: string) => boolean | "" | undefined;
|
|
4
|
+
export declare const convertKeysToSnakeCase: (obj?: Record<string, any>) => Record<string, any>;
|
|
3
5
|
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';
|
|
4
6
|
type TeamEvent = 'team_added' | 'team_info_updated' | 'team_deleted' | 'team_member_removed';
|
|
5
7
|
type ConnectionEvent = 'connection_created' | 'connection_reconnected' | 'connection_deleted' | 'connection_requested';
|
|
@@ -36,14 +38,16 @@ export declare const useTracking: ({ dataset, env, name }: TrackingProps, isDev?
|
|
|
36
38
|
event: TrackingEvent;
|
|
37
39
|
properties: Record<string, string | number | boolean | null | undefined>;
|
|
38
40
|
}) => Promise<void>;
|
|
39
|
-
identify: ({ traits, userId, disableGeoip, }: {
|
|
41
|
+
identify: ({ traits, userId, disableGeoip, timestamp, }: {
|
|
40
42
|
userId: string;
|
|
41
43
|
traits: Record<string, any>;
|
|
42
44
|
disableGeoip?: boolean;
|
|
45
|
+
timestamp?: Date;
|
|
43
46
|
}) => void;
|
|
44
|
-
group: ({ traits, groupId, userId, anonymousId, }: OptionalUser<{
|
|
47
|
+
group: ({ traits, groupId, userId, anonymousId, timestamp, }: OptionalUser<{
|
|
45
48
|
groupId: string;
|
|
46
49
|
traits?: Record<string, any>;
|
|
50
|
+
timestamp?: Date;
|
|
47
51
|
}>) => void;
|
|
48
52
|
shutdown: () => Promise<[void | undefined, void | undefined, void]>;
|
|
49
53
|
alias: ((data: {
|
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useTracking = void 0;
|
|
3
|
+
exports.useTracking = exports.convertKeysToSnakeCase = exports.isTest = void 0;
|
|
4
4
|
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
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
|
|
14
|
-
const E2E_TEST_TEAMS =
|
|
15
|
-
'c4fd21b4-8447-43a2-bdcb-f06a85a935ad',
|
|
16
|
-
'8f21060e-afe6-410a-b2f4-00a3caa20786',
|
|
17
|
-
|
|
18
|
-
const isTest = (userId, groupId) => E2E_TEST_USERS.includes(userId) ||
|
|
19
|
-
(groupId && E2E_TEST_TEAMS.includes(groupId))
|
|
8
|
+
const E2E_TEST_USERS = {
|
|
9
|
+
'e2e-invite-member@finalytic.io': '113d73d8-ee21-46b7-a12a-a74f632401ca',
|
|
10
|
+
'e2e-invite-owner@finalytic.io': '917b7c4e-cb03-491c-9e94-d33a5bdeca05',
|
|
11
|
+
'e2e-sign-up@finalytic.io': 'ec8e5572-74d0-4ae6-af73-bca8db9a27e9',
|
|
12
|
+
'lars+checkly@finalytic.co': '9e7dfc88-503c-4222-9905-9116169d2203',
|
|
13
|
+
};
|
|
14
|
+
const E2E_TEST_TEAMS = {
|
|
15
|
+
'VRP Automated Testing': 'c4fd21b4-8447-43a2-bdcb-f06a85a935ad',
|
|
16
|
+
test_company_xxxx: '8f21060e-afe6-410a-b2f4-00a3caa20786',
|
|
17
|
+
};
|
|
18
|
+
const isTest = (userId, groupId, userEmail) => Object.values(E2E_TEST_USERS).includes(userId) ||
|
|
19
|
+
(groupId && Object.values(E2E_TEST_TEAMS).includes(groupId)) ||
|
|
20
|
+
(userEmail && Object.keys(E2E_TEST_USERS).includes(userEmail));
|
|
21
|
+
exports.isTest = isTest;
|
|
22
|
+
const camelToSnakeCase = (str) => str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
|
23
|
+
// todo: move to utils
|
|
24
|
+
const convertKeysToSnakeCase = (obj) => {
|
|
25
|
+
const result = {};
|
|
26
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
27
|
+
for (const key in obj) {
|
|
28
|
+
if (hasOwnProperty.call(obj, key)) {
|
|
29
|
+
const snakeKey = camelToSnakeCase(key);
|
|
30
|
+
if (typeof obj[key] === 'object' &&
|
|
31
|
+
!Array.isArray(obj[key]) &&
|
|
32
|
+
obj[key] !== null) {
|
|
33
|
+
result[snakeKey] = (0, exports.convertKeysToSnakeCase)(obj[key]);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result[snakeKey] = obj[key];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
exports.convertKeysToSnakeCase = convertKeysToSnakeCase;
|
|
20
43
|
const useTracking = ({ dataset, env, name }, isDev) => {
|
|
21
44
|
const axiom = (0, log_1.useLog)({ name, dataset, env });
|
|
22
45
|
const intercom = env.INTERCOM_TOKEN
|
|
@@ -31,7 +54,7 @@ const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
31
54
|
return {
|
|
32
55
|
// General
|
|
33
56
|
track: async ({ userId, groupId, event, properties, }) => {
|
|
34
|
-
if (isDev || isTest(userId, groupId))
|
|
57
|
+
if (isDev || (0, exports.isTest)(userId, groupId))
|
|
35
58
|
return;
|
|
36
59
|
posthog?.capture({
|
|
37
60
|
distinctId: userId,
|
|
@@ -39,7 +62,7 @@ const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
39
62
|
groups: {
|
|
40
63
|
tenant: groupId,
|
|
41
64
|
},
|
|
42
|
-
properties,
|
|
65
|
+
properties: (0, exports.convertKeysToSnakeCase)(properties),
|
|
43
66
|
});
|
|
44
67
|
juneso?.track({
|
|
45
68
|
userId,
|
|
@@ -61,35 +84,39 @@ const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
61
84
|
console.error(error);
|
|
62
85
|
}
|
|
63
86
|
},
|
|
64
|
-
identify: ({ traits, userId, disableGeoip, }) => {
|
|
65
|
-
if (isDev || isTest(userId))
|
|
87
|
+
identify: ({ traits, userId, disableGeoip, timestamp, }) => {
|
|
88
|
+
if (isDev || (0, exports.isTest)(userId))
|
|
66
89
|
return;
|
|
67
90
|
posthog?.identify({
|
|
68
91
|
distinctId: userId,
|
|
69
|
-
properties: traits,
|
|
92
|
+
properties: (0, exports.convertKeysToSnakeCase)(traits),
|
|
70
93
|
disableGeoip,
|
|
71
94
|
});
|
|
72
95
|
juneso?.identify({
|
|
73
96
|
userId,
|
|
74
97
|
traits,
|
|
98
|
+
timestamp,
|
|
75
99
|
}, (err) => {
|
|
76
100
|
if (err)
|
|
77
101
|
console.error(err);
|
|
78
102
|
});
|
|
79
103
|
},
|
|
80
|
-
group: ({ traits, groupId, userId, anonymousId, }) => {
|
|
81
|
-
if (isDev || isTest(userId || anonymousId || '', groupId))
|
|
104
|
+
group: ({ traits, groupId, userId, anonymousId, timestamp, }) => {
|
|
105
|
+
if (isDev || (0, exports.isTest)(userId || anonymousId || '', groupId))
|
|
82
106
|
return;
|
|
83
107
|
posthog?.groupIdentify({
|
|
84
108
|
groupKey: groupId,
|
|
85
109
|
groupType: 'tenant',
|
|
86
|
-
properties: traits,
|
|
110
|
+
properties: (0, exports.convertKeysToSnakeCase)(traits),
|
|
87
111
|
distinctId: userId,
|
|
88
112
|
});
|
|
89
113
|
if (anonymousId)
|
|
90
|
-
juneso?.group({ anonymousId, groupId, traits }, (err) =>
|
|
114
|
+
juneso?.group({ anonymousId, groupId, traits, timestamp }, (err) => {
|
|
115
|
+
if (err)
|
|
116
|
+
console.error(err);
|
|
117
|
+
});
|
|
91
118
|
else if (userId)
|
|
92
|
-
juneso?.group({ userId, groupId, traits }, (err) => {
|
|
119
|
+
juneso?.group({ userId, groupId, traits, timestamp }, (err) => {
|
|
93
120
|
if (err)
|
|
94
121
|
console.error(err);
|
|
95
122
|
});
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,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,S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;gBACb,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;oBAC5D,IAAI,GAAG;wBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;QACP,CAAC;QACD,QAAQ,EAAE,KAAK,IAAI,EAAE,CACnB,OAAO,CAAC,GAAG,CAAC;YACV,OAAO,EAAE,QAAQ,EAAE;YACnB,MAAM,EAAE,aAAa,EAAE;YACvB,KAAK,EAAE,KAAK,EAAE;SACf,CAAC;QACJ,mBAAmB;QACnB,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,4BAA4B;QAC5B,QAAQ;QACR,OAAO;QACP,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;KACX,CAAC;AACJ,CAAC,CAAC;AApIW,QAAA,WAAW,eAoItB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Analytics } from '@june-so/analytics-node';
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
|
+
export declare const isTest: (userId: string, groupId?: string, userEmail?: string) => boolean | "" | undefined;
|
|
4
|
+
export declare const convertKeysToSnakeCase: (obj?: Record<string, any>) => Record<string, any>;
|
|
3
5
|
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';
|
|
4
6
|
type TeamEvent = 'team_added' | 'team_info_updated' | 'team_deleted' | 'team_member_removed';
|
|
5
7
|
type ConnectionEvent = 'connection_created' | 'connection_reconnected' | 'connection_deleted' | 'connection_requested';
|
|
@@ -36,14 +38,16 @@ export declare const useTracking: ({ dataset, env, name }: TrackingProps, isDev?
|
|
|
36
38
|
event: TrackingEvent;
|
|
37
39
|
properties: Record<string, string | number | boolean | null | undefined>;
|
|
38
40
|
}) => Promise<void>;
|
|
39
|
-
identify: ({ traits, userId, disableGeoip, }: {
|
|
41
|
+
identify: ({ traits, userId, disableGeoip, timestamp, }: {
|
|
40
42
|
userId: string;
|
|
41
43
|
traits: Record<string, any>;
|
|
42
44
|
disableGeoip?: boolean;
|
|
45
|
+
timestamp?: Date;
|
|
43
46
|
}) => void;
|
|
44
|
-
group: ({ traits, groupId, userId, anonymousId, }: OptionalUser<{
|
|
47
|
+
group: ({ traits, groupId, userId, anonymousId, timestamp, }: OptionalUser<{
|
|
45
48
|
groupId: string;
|
|
46
49
|
traits?: Record<string, any>;
|
|
50
|
+
timestamp?: Date;
|
|
47
51
|
}>) => void;
|
|
48
52
|
shutdown: () => Promise<[void | undefined, void | undefined, void]>;
|
|
49
53
|
alias: ((data: {
|
|
@@ -2,18 +2,39 @@ 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
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
|
|
11
|
-
const E2E_TEST_TEAMS =
|
|
12
|
-
'c4fd21b4-8447-43a2-bdcb-f06a85a935ad',
|
|
13
|
-
'8f21060e-afe6-410a-b2f4-00a3caa20786',
|
|
14
|
-
|
|
15
|
-
const isTest = (userId, groupId) => E2E_TEST_USERS.includes(userId) ||
|
|
16
|
-
(groupId && E2E_TEST_TEAMS.includes(groupId))
|
|
5
|
+
const E2E_TEST_USERS = {
|
|
6
|
+
'e2e-invite-member@finalytic.io': '113d73d8-ee21-46b7-a12a-a74f632401ca',
|
|
7
|
+
'e2e-invite-owner@finalytic.io': '917b7c4e-cb03-491c-9e94-d33a5bdeca05',
|
|
8
|
+
'e2e-sign-up@finalytic.io': 'ec8e5572-74d0-4ae6-af73-bca8db9a27e9',
|
|
9
|
+
'lars+checkly@finalytic.co': '9e7dfc88-503c-4222-9905-9116169d2203',
|
|
10
|
+
};
|
|
11
|
+
const E2E_TEST_TEAMS = {
|
|
12
|
+
'VRP Automated Testing': 'c4fd21b4-8447-43a2-bdcb-f06a85a935ad',
|
|
13
|
+
test_company_xxxx: '8f21060e-afe6-410a-b2f4-00a3caa20786',
|
|
14
|
+
};
|
|
15
|
+
export const isTest = (userId, groupId, userEmail) => Object.values(E2E_TEST_USERS).includes(userId) ||
|
|
16
|
+
(groupId && Object.values(E2E_TEST_TEAMS).includes(groupId)) ||
|
|
17
|
+
(userEmail && Object.keys(E2E_TEST_USERS).includes(userEmail));
|
|
18
|
+
const camelToSnakeCase = (str) => str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
|
19
|
+
// todo: move to utils
|
|
20
|
+
export const convertKeysToSnakeCase = (obj) => {
|
|
21
|
+
const result = {};
|
|
22
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
23
|
+
for (const key in obj) {
|
|
24
|
+
if (hasOwnProperty.call(obj, key)) {
|
|
25
|
+
const snakeKey = camelToSnakeCase(key);
|
|
26
|
+
if (typeof obj[key] === 'object' &&
|
|
27
|
+
!Array.isArray(obj[key]) &&
|
|
28
|
+
obj[key] !== null) {
|
|
29
|
+
result[snakeKey] = convertKeysToSnakeCase(obj[key]);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
result[snakeKey] = obj[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
17
38
|
export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
18
39
|
const axiom = useLog({ name, dataset, env });
|
|
19
40
|
const intercom = env.INTERCOM_TOKEN
|
|
@@ -36,7 +57,7 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
36
57
|
groups: {
|
|
37
58
|
tenant: groupId,
|
|
38
59
|
},
|
|
39
|
-
properties,
|
|
60
|
+
properties: convertKeysToSnakeCase(properties),
|
|
40
61
|
});
|
|
41
62
|
juneso?.track({
|
|
42
63
|
userId,
|
|
@@ -58,35 +79,39 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
58
79
|
console.error(error);
|
|
59
80
|
}
|
|
60
81
|
},
|
|
61
|
-
identify: ({ traits, userId, disableGeoip, }) => {
|
|
82
|
+
identify: ({ traits, userId, disableGeoip, timestamp, }) => {
|
|
62
83
|
if (isDev || isTest(userId))
|
|
63
84
|
return;
|
|
64
85
|
posthog?.identify({
|
|
65
86
|
distinctId: userId,
|
|
66
|
-
properties: traits,
|
|
87
|
+
properties: convertKeysToSnakeCase(traits),
|
|
67
88
|
disableGeoip,
|
|
68
89
|
});
|
|
69
90
|
juneso?.identify({
|
|
70
91
|
userId,
|
|
71
92
|
traits,
|
|
93
|
+
timestamp,
|
|
72
94
|
}, (err) => {
|
|
73
95
|
if (err)
|
|
74
96
|
console.error(err);
|
|
75
97
|
});
|
|
76
98
|
},
|
|
77
|
-
group: ({ traits, groupId, userId, anonymousId, }) => {
|
|
99
|
+
group: ({ traits, groupId, userId, anonymousId, timestamp, }) => {
|
|
78
100
|
if (isDev || isTest(userId || anonymousId || '', groupId))
|
|
79
101
|
return;
|
|
80
102
|
posthog?.groupIdentify({
|
|
81
103
|
groupKey: groupId,
|
|
82
104
|
groupType: 'tenant',
|
|
83
|
-
properties: traits,
|
|
105
|
+
properties: convertKeysToSnakeCase(traits),
|
|
84
106
|
distinctId: userId,
|
|
85
107
|
});
|
|
86
108
|
if (anonymousId)
|
|
87
|
-
juneso?.group({ anonymousId, groupId, traits }, (err) =>
|
|
109
|
+
juneso?.group({ anonymousId, groupId, traits, timestamp }, (err) => {
|
|
110
|
+
if (err)
|
|
111
|
+
console.error(err);
|
|
112
|
+
});
|
|
88
113
|
else if (userId)
|
|
89
|
-
juneso?.group({ userId, groupId, traits }, (err) => {
|
|
114
|
+
juneso?.group({ userId, groupId, traits, timestamp }, (err) => {
|
|
90
115
|
if (err)
|
|
91
116
|
console.error(err);
|
|
92
117
|
});
|
|
@@ -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,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,cAAc,GAAG;IACrB,
|
|
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,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,IAAI,MAAM,CAAC,IAAI,CAAC,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IAAI,GAAG;wBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;QACP,CAAC;QACD,QAAQ,EAAE,KAAK,IAAI,EAAE,CACnB,OAAO,CAAC,GAAG,CAAC;YACV,OAAO,EAAE,QAAQ,EAAE;YACnB,MAAM,EAAE,aAAa,EAAE;YACvB,KAAK,EAAE,KAAK,EAAE;SACf,CAAC;QACJ,mBAAmB;QACnB,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,4BAA4B;QAC5B,QAAQ;QACR,OAAO;QACP,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;KACX,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/tracking/index.ts
CHANGED
|
@@ -3,38 +3,66 @@ import { PostHog } from 'posthog-node';
|
|
|
3
3
|
import { useLog } from '../log';
|
|
4
4
|
import { useIntercom } from './intercom';
|
|
5
5
|
|
|
6
|
-
const E2E_TEST_USERS =
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'
|
|
15
|
-
|
|
6
|
+
const E2E_TEST_USERS = {
|
|
7
|
+
'e2e-invite-member@finalytic.io': '113d73d8-ee21-46b7-a12a-a74f632401ca',
|
|
8
|
+
'e2e-invite-owner@finalytic.io': '917b7c4e-cb03-491c-9e94-d33a5bdeca05',
|
|
9
|
+
'e2e-sign-up@finalytic.io': 'ec8e5572-74d0-4ae6-af73-bca8db9a27e9',
|
|
10
|
+
'lars+checkly@finalytic.co': '9e7dfc88-503c-4222-9905-9116169d2203',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const E2E_TEST_TEAMS = {
|
|
14
|
+
'VRP Automated Testing': 'c4fd21b4-8447-43a2-bdcb-f06a85a935ad',
|
|
15
|
+
test_company_xxxx: '8f21060e-afe6-410a-b2f4-00a3caa20786',
|
|
16
|
+
};
|
|
16
17
|
|
|
17
|
-
const isTest = (userId: string, groupId?: string) =>
|
|
18
|
-
E2E_TEST_USERS.includes(userId) ||
|
|
19
|
-
(groupId && E2E_TEST_TEAMS.includes(groupId))
|
|
18
|
+
export const isTest = (userId: string, groupId?: string, userEmail?: string) =>
|
|
19
|
+
Object.values(E2E_TEST_USERS).includes(userId) ||
|
|
20
|
+
(groupId && Object.values(E2E_TEST_TEAMS).includes(groupId)) ||
|
|
21
|
+
(userEmail && Object.keys(E2E_TEST_USERS).includes(userEmail));
|
|
22
|
+
|
|
23
|
+
const camelToSnakeCase = (str: string) =>
|
|
24
|
+
str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
|
25
|
+
|
|
26
|
+
// todo: move to utils
|
|
27
|
+
export const convertKeysToSnakeCase = (obj?: Record<string, any>) => {
|
|
28
|
+
const result: Record<string, any> = {};
|
|
29
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
30
|
+
|
|
31
|
+
for (const key in obj) {
|
|
32
|
+
if (hasOwnProperty.call(obj, key)) {
|
|
33
|
+
const snakeKey = camelToSnakeCase(key);
|
|
34
|
+
if (
|
|
35
|
+
typeof obj[key] === 'object' &&
|
|
36
|
+
!Array.isArray(obj[key]) &&
|
|
37
|
+
obj[key] !== null
|
|
38
|
+
) {
|
|
39
|
+
result[snakeKey] = convertKeysToSnakeCase(obj[key]);
|
|
40
|
+
} else {
|
|
41
|
+
result[snakeKey] = obj[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
20
48
|
|
|
21
49
|
type AuthEvent =
|
|
22
50
|
| 'account_signin_completed'
|
|
23
51
|
| 'account_signup_code_requested'
|
|
24
52
|
| 'account_signup_code_completed'
|
|
25
53
|
| 'account_signup_code_failed'
|
|
26
|
-
| 'account_signup_completed'
|
|
54
|
+
| 'account_signup_completed'
|
|
27
55
|
| 'account_password_reset_requested'
|
|
28
56
|
| 'account_password_reset_failed'
|
|
29
57
|
| 'account_password_reset_completed'
|
|
30
|
-
| 'account_invitation_accepted'
|
|
31
|
-
| 'account_signed_out';
|
|
58
|
+
| 'account_invitation_accepted'
|
|
59
|
+
| 'account_signed_out';
|
|
32
60
|
|
|
33
61
|
type TeamEvent =
|
|
34
62
|
| 'team_added'
|
|
35
63
|
| 'team_info_updated'
|
|
36
64
|
| 'team_deleted'
|
|
37
|
-
| 'team_member_removed';
|
|
65
|
+
| 'team_member_removed';
|
|
38
66
|
|
|
39
67
|
type ConnectionEvent =
|
|
40
68
|
| 'connection_created'
|
|
@@ -51,19 +79,19 @@ type OwnerEvent =
|
|
|
51
79
|
| 'owner_created'
|
|
52
80
|
| 'owner_updated'
|
|
53
81
|
| 'owner_deleted'
|
|
54
|
-
| 'owner_tax_info_modal_opened'
|
|
55
|
-
| 'owner_tax_info_modal_submitted';
|
|
82
|
+
| 'owner_tax_info_modal_opened'
|
|
83
|
+
| 'owner_tax_info_modal_submitted';
|
|
56
84
|
|
|
57
85
|
type SetupEvent =
|
|
58
|
-
| 'setup_classes_set'
|
|
59
|
-
| 'setup_accounting_version_completed'
|
|
60
|
-
| 'setup_accounting_config_completed'
|
|
61
|
-
| 'setup_owner_imported'
|
|
62
|
-
| 'setup_listing_imported';
|
|
86
|
+
| 'setup_classes_set'
|
|
87
|
+
| 'setup_accounting_version_completed'
|
|
88
|
+
| 'setup_accounting_config_completed'
|
|
89
|
+
| 'setup_owner_imported'
|
|
90
|
+
| 'setup_listing_imported';
|
|
63
91
|
|
|
64
92
|
type AutomationEvent =
|
|
65
93
|
| 'automation_created'
|
|
66
|
-
| 'automation_updated'
|
|
94
|
+
| 'automation_updated'
|
|
67
95
|
| 'automation_deleted';
|
|
68
96
|
|
|
69
97
|
type TaxStatementEvent =
|
|
@@ -71,30 +99,28 @@ type TaxStatementEvent =
|
|
|
71
99
|
| 'tax_statement_downloaded';
|
|
72
100
|
|
|
73
101
|
type GLOwnerStatementEvent =
|
|
74
|
-
| 'gl_owner_statement_preview_opened'
|
|
75
|
-
| 'gl_owner_statement_downloaded';
|
|
102
|
+
| 'gl_owner_statement_preview_opened'
|
|
103
|
+
| 'gl_owner_statement_downloaded';
|
|
76
104
|
|
|
77
105
|
type HyperlineEvent =
|
|
78
|
-
| 'hyperline_invoice_ready'
|
|
79
|
-
| 'hyperline_invoice_settled'
|
|
80
|
-
| 'hyperline_trial_started'
|
|
81
|
-
| 'hyperline_trial_ended'
|
|
82
|
-
| 'hyperline_subscription_activated'
|
|
83
|
-
| 'hyperline_subscription_cancelled'
|
|
84
|
-
| 'hyperline_subscription_created'
|
|
85
|
-
| 'hyperline_subscription_errored'
|
|
86
|
-
| 'hyperline_subscription_paused'
|
|
87
|
-
| 'hyperline_subscription_voided'
|
|
88
|
-
| 'hyperline_subscription_charged'
|
|
89
|
-
| 'hyperline_customer_created'
|
|
90
|
-
| 'hyperline_customer_updated'
|
|
91
|
-
| 'hyperline_payment_method_created'
|
|
92
|
-
| 'hyperline_payment_method_errored'
|
|
93
|
-
| 'hyperline_payment_method_deleted';
|
|
106
|
+
| 'hyperline_invoice_ready'
|
|
107
|
+
| 'hyperline_invoice_settled'
|
|
108
|
+
| 'hyperline_trial_started'
|
|
109
|
+
| 'hyperline_trial_ended'
|
|
110
|
+
| 'hyperline_subscription_activated'
|
|
111
|
+
| 'hyperline_subscription_cancelled'
|
|
112
|
+
| 'hyperline_subscription_created'
|
|
113
|
+
| 'hyperline_subscription_errored'
|
|
114
|
+
| 'hyperline_subscription_paused'
|
|
115
|
+
| 'hyperline_subscription_voided'
|
|
116
|
+
| 'hyperline_subscription_charged'
|
|
117
|
+
| 'hyperline_customer_created'
|
|
118
|
+
| 'hyperline_customer_updated'
|
|
119
|
+
| 'hyperline_payment_method_created'
|
|
120
|
+
| 'hyperline_payment_method_errored'
|
|
121
|
+
| 'hyperline_payment_method_deleted';
|
|
94
122
|
|
|
95
|
-
type TestEvent =
|
|
96
|
-
| 'test_event' // missing in list
|
|
97
|
-
| 'test_error'; // missing in list
|
|
123
|
+
type TestEvent = 'test_event' | 'test_error';
|
|
98
124
|
|
|
99
125
|
export type TrackingEvent =
|
|
100
126
|
| AuthEvent
|
|
@@ -165,7 +191,7 @@ export const useTracking = (
|
|
|
165
191
|
groups: {
|
|
166
192
|
tenant: groupId,
|
|
167
193
|
},
|
|
168
|
-
properties,
|
|
194
|
+
properties: convertKeysToSnakeCase(properties),
|
|
169
195
|
});
|
|
170
196
|
juneso?.track(
|
|
171
197
|
{
|
|
@@ -193,22 +219,25 @@ export const useTracking = (
|
|
|
193
219
|
traits,
|
|
194
220
|
userId,
|
|
195
221
|
disableGeoip,
|
|
222
|
+
timestamp,
|
|
196
223
|
}: {
|
|
197
224
|
userId: string;
|
|
198
225
|
traits: Record<string, any>;
|
|
199
226
|
disableGeoip?: boolean;
|
|
227
|
+
timestamp?: Date;
|
|
200
228
|
}) => {
|
|
201
229
|
if (isDev || isTest(userId)) return;
|
|
202
230
|
|
|
203
231
|
posthog?.identify({
|
|
204
232
|
distinctId: userId,
|
|
205
|
-
properties: traits,
|
|
233
|
+
properties: convertKeysToSnakeCase(traits),
|
|
206
234
|
disableGeoip,
|
|
207
235
|
});
|
|
208
236
|
juneso?.identify(
|
|
209
237
|
{
|
|
210
238
|
userId,
|
|
211
239
|
traits,
|
|
240
|
+
timestamp,
|
|
212
241
|
},
|
|
213
242
|
(err) => {
|
|
214
243
|
if (err) console.error(err);
|
|
@@ -220,24 +249,26 @@ export const useTracking = (
|
|
|
220
249
|
groupId,
|
|
221
250
|
userId,
|
|
222
251
|
anonymousId,
|
|
252
|
+
timestamp,
|
|
223
253
|
}: OptionalUser<{
|
|
224
254
|
groupId: string;
|
|
225
255
|
traits?: Record<string, any>;
|
|
256
|
+
timestamp?: Date;
|
|
226
257
|
}>) => {
|
|
227
258
|
if (isDev || isTest(userId || anonymousId || '', groupId)) return;
|
|
228
259
|
|
|
229
260
|
posthog?.groupIdentify({
|
|
230
261
|
groupKey: groupId,
|
|
231
262
|
groupType: 'tenant',
|
|
232
|
-
properties: traits,
|
|
263
|
+
properties: convertKeysToSnakeCase(traits),
|
|
233
264
|
distinctId: userId,
|
|
234
265
|
});
|
|
235
266
|
if (anonymousId)
|
|
236
|
-
juneso?.group({ anonymousId, groupId, traits }, (err) =>
|
|
237
|
-
console.error(err)
|
|
238
|
-
);
|
|
267
|
+
juneso?.group({ anonymousId, groupId, traits, timestamp }, (err) => {
|
|
268
|
+
if (err) console.error(err);
|
|
269
|
+
});
|
|
239
270
|
else if (userId)
|
|
240
|
-
juneso?.group({ userId, groupId, traits }, (err) => {
|
|
271
|
+
juneso?.group({ userId, groupId, traits, timestamp }, (err) => {
|
|
241
272
|
if (err) console.error(err);
|
|
242
273
|
});
|
|
243
274
|
},
|