@vrplatform/log 2.0.36 → 2.0.38
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/_intercom.d.ts +109 -0
- package/build/main/tracking/_intercom.js +139 -0
- package/build/main/tracking/_intercom.js.map +1 -0
- package/build/main/tracking/eventTypes.d.ts +16 -0
- package/build/main/{type.js → tracking/eventTypes.js} +1 -1
- package/build/main/tracking/eventTypes.js.map +1 -0
- package/build/main/tracking/index.d.ts +0 -6
- package/build/main/tracking/index.js +5 -82
- package/build/main/tracking/index.js.map +1 -1
- package/build/main/tracking/intercom.d.ts +109 -0
- package/build/main/tracking/intercom.js +139 -0
- package/build/main/tracking/intercom.js.map +1 -0
- package/build/main/tracking/types.d.ts +16 -3
- package/build/module/tracking/_intercom.d.ts +109 -0
- package/build/module/tracking/_intercom.js +136 -0
- package/build/module/tracking/_intercom.js.map +1 -0
- package/build/module/tracking/eventTypes.d.ts +16 -0
- package/build/module/tracking/eventTypes.js +2 -0
- package/build/module/tracking/eventTypes.js.map +1 -0
- package/build/module/tracking/index.d.ts +0 -6
- package/build/module/tracking/index.js +6 -83
- package/build/module/tracking/index.js.map +1 -1
- package/build/module/tracking/intercom.d.ts +109 -0
- package/build/module/tracking/intercom.js +136 -0
- package/build/module/tracking/intercom.js.map +1 -0
- package/build/module/tracking/types.d.ts +16 -3
- package/package.json +1 -3
- package/src/tracking/index.ts +5 -110
- package/src/tracking/types.ts +18 -3
- package/build/main/baselog.d.ts +0 -19
- package/build/main/baselog.js +0 -137
- package/build/main/baselog.js.map +0 -1
- package/build/main/color.d.ts +0 -54
- package/build/main/color.js +0 -371
- package/build/main/color.js.map +0 -1
- package/build/main/common.d.ts +0 -29
- package/build/main/common.js +0 -86
- package/build/main/common.js.map +0 -1
- package/build/main/index.spec.d.ts +0 -0
- package/build/main/index.spec.js +0 -2
- package/build/main/index.spec.js.map +0 -1
- package/build/main/type.d.ts +0 -39
- package/build/main/type.js.map +0 -1
- package/build/module/baselog.d.ts +0 -19
- package/build/module/baselog.js +0 -120
- package/build/module/baselog.js.map +0 -1
- package/build/module/color.d.ts +0 -54
- package/build/module/color.js +0 -375
- package/build/module/color.js.map +0 -1
- package/build/module/common.d.ts +0 -29
- package/build/module/common.js +0 -80
- package/build/module/common.js.map +0 -1
- package/build/module/index.spec.d.ts +0 -0
- package/build/module/index.spec.js +0 -2
- package/build/module/index.spec.js.map +0 -1
- package/build/module/type.d.ts +0 -39
- package/build/module/type.js +0 -2
- package/build/module/type.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":"AAoGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":"AAoGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAoC,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAQvE,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AAczB,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAe,EACnC,KAAe,EAQf,EAAE;IACF,MAAM,MAAM,GAAG,GAAG,CAAC,2BAA2B;QAC5C,CAAC,CAAC,eAAe,CAAC;YACd,MAAM,EAAE,GAAG,CAAC,mBAAmB,IAAI,GAAG,CAAC,2BAA2B;SACnE,CAAC;QACJ,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,IAAI,E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,EAAE,GAAG,IAAI,CAAC;wBACzD,CAAC,CAAC,SAAS;oBACb,aAAa,EAAE,MAAM,EAAE,GAAG;oBAC1B,iBAAiB;iBAClB,EACD,EAAE,CACH,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;YAED,IAAI,MAAM,EAAE,CAAC;gBACX,2CAA2C;gBAC3C,IAAI,CAAC;oBACH,MAAM,YAAY,GAAG,CACnB,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;wBAC9B,KAAK,EAAE;4BACL,KAAK,EAAE,aAAa;4BACpB,QAAQ,EAAE,GAAG;4BACb,KAAK,EAAE,MAAM;yBACd;qBACF,CAAC,CACH,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;oBACf,IAAI,YAAY,EAAE,EAAE,IAAI,eAAe,EAAE,EAAE;wBACzC,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,EAAE;4BACpD,UAAU,EAAE,eAAe,EAAE,EAAE;yBAChC,CAAC,CAAC;gBACP,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;QACD,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE;QAClC,sBAAsB;QACtB,QAAQ;QACR,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { Log } from '../log';
|
|
2
|
+
export declare class IntercomAPI {
|
|
3
|
+
constructor(token: string, log?: Log);
|
|
4
|
+
private headers;
|
|
5
|
+
private log?;
|
|
6
|
+
private fetch;
|
|
7
|
+
getUserByUserId(userId: string): Promise<{
|
|
8
|
+
type: "list";
|
|
9
|
+
data: {
|
|
10
|
+
id: string;
|
|
11
|
+
}[] | undefined;
|
|
12
|
+
total_count: 0;
|
|
13
|
+
pages: {
|
|
14
|
+
type: "pages";
|
|
15
|
+
page: 1;
|
|
16
|
+
per_page: 10;
|
|
17
|
+
total_pages: 0;
|
|
18
|
+
};
|
|
19
|
+
} | undefined>;
|
|
20
|
+
createUser({ data, userId, }: {
|
|
21
|
+
userId: string;
|
|
22
|
+
data: {
|
|
23
|
+
email: string;
|
|
24
|
+
name: string;
|
|
25
|
+
custom_attributes: Record<string, any>;
|
|
26
|
+
};
|
|
27
|
+
}): Promise<unknown>;
|
|
28
|
+
updateUser({ data, contactId, }: {
|
|
29
|
+
contactId: string;
|
|
30
|
+
data: {
|
|
31
|
+
email?: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
custom_attributes: Record<string, any>;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
};
|
|
36
|
+
}): Promise<unknown>;
|
|
37
|
+
deleteUser(intercom_contact_id: string): Promise<{
|
|
38
|
+
id: "6657adf56abd0167d9419d1c";
|
|
39
|
+
external_id: "70";
|
|
40
|
+
type: "contact";
|
|
41
|
+
deleted: true;
|
|
42
|
+
} | undefined>;
|
|
43
|
+
createCompanyUser(data: {
|
|
44
|
+
intercom_contact_id: string;
|
|
45
|
+
intercom_company_id: string;
|
|
46
|
+
}): Promise<unknown>;
|
|
47
|
+
deleteCompanyUser({ intercom_company_id, intercom_contact_id, }: {
|
|
48
|
+
intercom_contact_id: string;
|
|
49
|
+
intercom_company_id: string;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
id: "6657adc96abd0167d9419ca7";
|
|
52
|
+
} | undefined>;
|
|
53
|
+
trackEvent(data: {
|
|
54
|
+
user_id: string;
|
|
55
|
+
event_name: string;
|
|
56
|
+
metadata: Record<string, any>;
|
|
57
|
+
}): Promise<unknown>;
|
|
58
|
+
getCompanyByTenantId(tenantId: string): Promise<{
|
|
59
|
+
type: "list";
|
|
60
|
+
data: [{
|
|
61
|
+
type: "company";
|
|
62
|
+
company_id: "remote_companies_scroll_2";
|
|
63
|
+
id: "664df5436abd01f7945e1a78";
|
|
64
|
+
app_id: "this_is_an_id111_that_should_be_at_least_";
|
|
65
|
+
name: "IntercomQATest1";
|
|
66
|
+
remote_created_at: 1716385091;
|
|
67
|
+
created_at: 1716385091;
|
|
68
|
+
updated_at: 1716385091;
|
|
69
|
+
monthly_spend: 0;
|
|
70
|
+
session_count: 0;
|
|
71
|
+
user_count: 4;
|
|
72
|
+
tags: {
|
|
73
|
+
type: "tag.list";
|
|
74
|
+
tags: [];
|
|
75
|
+
};
|
|
76
|
+
segments: {
|
|
77
|
+
type: "segment.list";
|
|
78
|
+
segments: [];
|
|
79
|
+
};
|
|
80
|
+
custom_attributes: Record<string, string>;
|
|
81
|
+
}] | undefined;
|
|
82
|
+
pages: {
|
|
83
|
+
type: "pages";
|
|
84
|
+
next: null;
|
|
85
|
+
page: 1;
|
|
86
|
+
per_page: 15;
|
|
87
|
+
total_pages: 1;
|
|
88
|
+
};
|
|
89
|
+
total_count: 1;
|
|
90
|
+
} | undefined>;
|
|
91
|
+
createCompany({ data, tenantId, }: {
|
|
92
|
+
tenantId: string;
|
|
93
|
+
data: {
|
|
94
|
+
name: string;
|
|
95
|
+
remote_created_at: number;
|
|
96
|
+
custom_attributes: Record<string, any>;
|
|
97
|
+
};
|
|
98
|
+
}): Promise<unknown>;
|
|
99
|
+
updateCompany({ data, companyId, }: {
|
|
100
|
+
companyId: string;
|
|
101
|
+
data: Record<string, any>;
|
|
102
|
+
}): Promise<unknown>;
|
|
103
|
+
deleteCompany(intercom_company_id: string): Promise<{
|
|
104
|
+
id: "6657adc96abd0167d9419ca7";
|
|
105
|
+
object: "company";
|
|
106
|
+
deleted: true;
|
|
107
|
+
} | undefined>;
|
|
108
|
+
}
|
|
109
|
+
export declare function useIntercom(token: string, log?: Log): IntercomAPI;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export class IntercomAPI {
|
|
2
|
+
constructor(token, log) {
|
|
3
|
+
this.headers = {
|
|
4
|
+
'Content-Type': 'application/json',
|
|
5
|
+
Accept: 'application/json',
|
|
6
|
+
'Intercom-Version': '2.11',
|
|
7
|
+
Authorization: `Bearer ${token}`,
|
|
8
|
+
};
|
|
9
|
+
this.log = log;
|
|
10
|
+
}
|
|
11
|
+
headers;
|
|
12
|
+
log;
|
|
13
|
+
async fetch(path, options) {
|
|
14
|
+
if (options?.data) {
|
|
15
|
+
options.body = JSON.stringify(options.data);
|
|
16
|
+
options.data = undefined;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const result = await fetch(`https://api.intercom.io${path}`, {
|
|
20
|
+
method: 'GET',
|
|
21
|
+
headers: this.headers,
|
|
22
|
+
...options,
|
|
23
|
+
});
|
|
24
|
+
if (!result.ok) {
|
|
25
|
+
this.log?.info('Failed to fetch from Intercom', {
|
|
26
|
+
result: {
|
|
27
|
+
status: result.status,
|
|
28
|
+
statusText: result.statusText,
|
|
29
|
+
body: await result.text(),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
if (result.status === 404)
|
|
33
|
+
return undefined;
|
|
34
|
+
if (result.status === 429) {
|
|
35
|
+
console.log('Intercom rate limit exceeded, waiting for 1 minute');
|
|
36
|
+
// X-RateLimit-Reset: 1487332520 => timestamp from header response when resetting
|
|
37
|
+
const reset = Number(result.headers.get('X-RateLimit-Reset'));
|
|
38
|
+
if (reset) {
|
|
39
|
+
const now = Math.floor(Date.now() / 1000);
|
|
40
|
+
const wait = reset - now + 1;
|
|
41
|
+
console.log(`Waiting for ${wait} seconds`);
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
|
|
43
|
+
return await this.fetch(path, options);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result.status === 202 ? {} : (await result.json());
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
this.log?.error(error);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// User
|
|
55
|
+
async getUserByUserId(userId) {
|
|
56
|
+
return await this.fetch('/contacts/search', {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
data: {
|
|
59
|
+
query: {
|
|
60
|
+
field: 'external_id',
|
|
61
|
+
operator: '=',
|
|
62
|
+
value: userId,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async createUser({ data, userId, }) {
|
|
68
|
+
return await this.fetch('/contacts', {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
data: { ...data, external_id: userId },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async updateUser({ data, contactId, }) {
|
|
74
|
+
return await this.fetch(`/contacts/${contactId}`, {
|
|
75
|
+
method: 'PUT',
|
|
76
|
+
data,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async deleteUser(intercom_contact_id) {
|
|
80
|
+
return await this.fetch(`/contacts/${intercom_contact_id}`, {
|
|
81
|
+
method: 'DELETE',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async createCompanyUser(data) {
|
|
85
|
+
return await this.fetch(`/contacts/${data.intercom_contact_id}/companies`, {
|
|
86
|
+
method: 'POST',
|
|
87
|
+
data: {
|
|
88
|
+
id: data.intercom_company_id,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async deleteCompanyUser({ intercom_company_id, intercom_contact_id, }) {
|
|
93
|
+
return await this.fetch(`/contacts/${intercom_contact_id}/companies/${intercom_company_id}`, {
|
|
94
|
+
method: 'DELETE',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async trackEvent(data) {
|
|
98
|
+
return await this.fetch('/events', {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
data: {
|
|
101
|
+
created_at: Math.floor(new Date().getTime() / 1000), // to seconds
|
|
102
|
+
...data,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// Company
|
|
107
|
+
async getCompanyByTenantId(tenantId) {
|
|
108
|
+
return await this.fetch(`/companies?company_id=${tenantId}`, {
|
|
109
|
+
method: 'GET',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async createCompany({ data, tenantId, }) {
|
|
113
|
+
return await this.fetch('/companies', {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
data: {
|
|
116
|
+
...data,
|
|
117
|
+
company_id: tenantId,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
async updateCompany({ data, companyId, }) {
|
|
122
|
+
return await this.fetch(`/companies/${companyId}`, {
|
|
123
|
+
method: 'PUT',
|
|
124
|
+
data,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async deleteCompany(intercom_company_id) {
|
|
128
|
+
return await this.fetch(`/companies/${intercom_company_id}`, {
|
|
129
|
+
method: 'DELETE',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export function useIntercom(token, log) {
|
|
134
|
+
return new IntercomAPI(token, log);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=intercom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intercom.js","sourceRoot":"src/","sources":["tracking/intercom.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAW;IACtB,YAAY,KAAa,EAAE,GAAS;QAClC,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,kBAAkB;YAC1B,kBAAkB,EAAE,MAAM;YAC1B,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC,CAAC;QAEF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEO,OAAO,CAAyB;IAChC,GAAG,CAAO;IAEV,KAAK,CAAC,KAAK,CACjB,IAAY,EACZ,OAAsC;QAEtC,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;YAClB,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,GAIV;QACC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,SAAS,EAAE,EAAE;YACjD,MAAM,EAAE,KAAK;YACb,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,mBAA2B;QAC7C,OAAO,MAAM,IAAI,CAAC,KAAK,CAIpB,cAAc,mBAAmB,EAAE,EAAE;YACtC,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,GAAS;IAClD,OAAO,IAAI,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -24,8 +24,6 @@ export type IdentifyProps = {
|
|
|
24
24
|
role?: UserRole;
|
|
25
25
|
[key: string]: string | number | boolean | null | undefined;
|
|
26
26
|
};
|
|
27
|
-
disableGeoip?: boolean;
|
|
28
|
-
timestamp?: Date;
|
|
29
27
|
};
|
|
30
28
|
export type GroupProps = OptionalUser<{
|
|
31
29
|
groupId: string;
|
|
@@ -52,7 +50,6 @@ export type GroupProps = OptionalUser<{
|
|
|
52
50
|
trialUntil?: string;
|
|
53
51
|
[key: string]: string | number | boolean | null | undefined;
|
|
54
52
|
};
|
|
55
|
-
timestamp?: Date;
|
|
56
53
|
}>;
|
|
57
54
|
export type TrackingEventProps = {
|
|
58
55
|
account_invitation_accepted: AccountInvitationAcceptedProps;
|
|
@@ -91,9 +88,11 @@ export type TrackingEventProps = {
|
|
|
91
88
|
tax_statement_preview_opened: TaxStatementPreviewOpenedProps;
|
|
92
89
|
tax_statement_downloaded: TaxStatementDownloadedProps;
|
|
93
90
|
team_added: TeamAddedProps;
|
|
91
|
+
team_canceled: TeamCanceledProps;
|
|
94
92
|
team_deleted: TeamDeletedProps;
|
|
95
93
|
team_info_updated: TeamInfoUpdatedProps;
|
|
96
94
|
team_member_removed: TeamMemberRemovedProps;
|
|
95
|
+
team_reinstated: TeamReinstatedProps;
|
|
97
96
|
gl_owner_statement_preview_opened: GlOwnerStatementPreviewOpenedProps;
|
|
98
97
|
gl_owner_statement_downloaded: GlOwnerStatementDownloadedProps;
|
|
99
98
|
hyperline_invoice_ready: HyperlineInvoiceReadyProps;
|
|
@@ -497,6 +496,13 @@ type TeamAddedProps = Partial<{
|
|
|
497
496
|
userId: string;
|
|
498
497
|
userEmail: string;
|
|
499
498
|
}>;
|
|
499
|
+
type TeamCanceledProps = Partial<{
|
|
500
|
+
tenantId: string;
|
|
501
|
+
customerId: string;
|
|
502
|
+
subscriptionId: string;
|
|
503
|
+
feedback: string;
|
|
504
|
+
reason: string;
|
|
505
|
+
}>;
|
|
500
506
|
type TeamDeletedProps = Partial<{
|
|
501
507
|
tenantId: string;
|
|
502
508
|
userId: string;
|
|
@@ -513,6 +519,13 @@ type TeamMemberRemovedProps = Partial<{
|
|
|
513
519
|
tenantId: string;
|
|
514
520
|
userEmail: string;
|
|
515
521
|
}>;
|
|
522
|
+
type TeamReinstatedProps = Partial<{
|
|
523
|
+
tenantId: string;
|
|
524
|
+
customerId: string;
|
|
525
|
+
subscriptionId: string;
|
|
526
|
+
feedback: string;
|
|
527
|
+
reason: string;
|
|
528
|
+
}>;
|
|
516
529
|
type TestErrorProps = Partial<{
|
|
517
530
|
userId: string;
|
|
518
531
|
tenantId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vrplatform/log",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.38",
|
|
4
4
|
"main": "build/main/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@axiomhq/js": "1.0.0-rc.3",
|
|
21
21
|
"@finalytic/graphql": "1.12.133",
|
|
22
|
-
"@june-so/analytics-node": "8.0.0",
|
|
23
22
|
"intercom-client": "6.0.0-beta.3",
|
|
24
|
-
"posthog-node": "4.0.1",
|
|
25
23
|
"serialize-error": "11.0.3"
|
|
26
24
|
},
|
|
27
25
|
"devDependencies": {
|
package/src/tracking/index.ts
CHANGED
|
@@ -101,9 +101,8 @@ declare module 'intercom-client' {
|
|
|
101
101
|
import { useHasuraClient } from '@finalytic/graphql';
|
|
102
102
|
import { Analytics } from '@june-so/analytics-node';
|
|
103
103
|
import { Intercom } from 'intercom-client';
|
|
104
|
-
import { PostHog } from 'posthog-node';
|
|
105
104
|
import { type LogBindings, type WorkerLog, useLog } from '../log';
|
|
106
|
-
import {
|
|
105
|
+
import { isTest } from '../utils';
|
|
107
106
|
import { convertValuesToString } from '../utils/convertValuesToString';
|
|
108
107
|
import type {
|
|
109
108
|
GroupProps,
|
|
@@ -122,8 +121,6 @@ export type UseTracking = {
|
|
|
122
121
|
dataset: string;
|
|
123
122
|
env: {
|
|
124
123
|
INTERCOM_TOKEN?: string;
|
|
125
|
-
JUNESO_TOKEN?: string;
|
|
126
|
-
POSTHOG_TOKEN?: string;
|
|
127
124
|
HASURA_GRAPHQL_ADMIN_SECRET?: string;
|
|
128
125
|
HASURA_ADMIN_SECRET?: string;
|
|
129
126
|
} & LogBindings;
|
|
@@ -139,9 +136,7 @@ export const useTracking = (
|
|
|
139
136
|
group: (props: GroupProps) => Promise<void>;
|
|
140
137
|
shutdown: () => Promise<any>;
|
|
141
138
|
log: WorkerLog;
|
|
142
|
-
june?: Analytics;
|
|
143
139
|
intercom?: Intercom;
|
|
144
|
-
posthog?: PostHog;
|
|
145
140
|
} => {
|
|
146
141
|
const client = env.HASURA_GRAPHQL_ADMIN_SECRET
|
|
147
142
|
? useHasuraClient({
|
|
@@ -159,12 +154,6 @@ export const useTracking = (
|
|
|
159
154
|
// }),
|
|
160
155
|
})
|
|
161
156
|
: undefined;
|
|
162
|
-
const june = env.JUNESO_TOKEN ? new Analytics(env.JUNESO_TOKEN) : undefined;
|
|
163
|
-
const posthog = env.POSTHOG_TOKEN
|
|
164
|
-
? new PostHog(env.POSTHOG_TOKEN, {
|
|
165
|
-
host: 'https://app.posthog.com',
|
|
166
|
-
})
|
|
167
|
-
: undefined;
|
|
168
157
|
|
|
169
158
|
return {
|
|
170
159
|
// General
|
|
@@ -193,55 +182,7 @@ export const useTracking = (
|
|
|
193
182
|
}).id
|
|
194
183
|
);
|
|
195
184
|
|
|
196
|
-
if (
|
|
197
|
-
posthog?.capture({
|
|
198
|
-
distinctId: anonymousId,
|
|
199
|
-
event,
|
|
200
|
-
groups: {
|
|
201
|
-
tenant: groupId,
|
|
202
|
-
},
|
|
203
|
-
timestamp,
|
|
204
|
-
properties: convertKeysToSnakeCase(properties),
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
june?.track(
|
|
208
|
-
{
|
|
209
|
-
anonymousId,
|
|
210
|
-
event,
|
|
211
|
-
properties,
|
|
212
|
-
timestamp,
|
|
213
|
-
context: { groupId },
|
|
214
|
-
},
|
|
215
|
-
(err) => {
|
|
216
|
-
if (err) console.error(err);
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
// no intercom for anonymous
|
|
221
|
-
} else if (userId) {
|
|
222
|
-
posthog?.capture({
|
|
223
|
-
distinctId: userId,
|
|
224
|
-
event,
|
|
225
|
-
groups: {
|
|
226
|
-
tenant: groupId,
|
|
227
|
-
},
|
|
228
|
-
timestamp,
|
|
229
|
-
properties: convertKeysToSnakeCase(properties),
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
june?.track(
|
|
233
|
-
{
|
|
234
|
-
userId,
|
|
235
|
-
event,
|
|
236
|
-
properties,
|
|
237
|
-
timestamp,
|
|
238
|
-
context: { groupId },
|
|
239
|
-
},
|
|
240
|
-
(err) => {
|
|
241
|
-
if (err) console.error(err);
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
|
|
185
|
+
if (userId) {
|
|
245
186
|
try {
|
|
246
187
|
await intercom?.dataEvents.create({
|
|
247
188
|
body: {
|
|
@@ -256,29 +197,9 @@ export const useTracking = (
|
|
|
256
197
|
}
|
|
257
198
|
}
|
|
258
199
|
},
|
|
259
|
-
identify: async ({
|
|
260
|
-
traits,
|
|
261
|
-
userId,
|
|
262
|
-
disableGeoip,
|
|
263
|
-
timestamp = new Date(),
|
|
264
|
-
}: IdentifyProps) => {
|
|
200
|
+
identify: async ({ traits, userId }: IdentifyProps) => {
|
|
265
201
|
if (isDev || isTest(userId)) return;
|
|
266
202
|
|
|
267
|
-
posthog?.identify({
|
|
268
|
-
distinctId: userId,
|
|
269
|
-
properties: convertKeysToSnakeCase(traits),
|
|
270
|
-
disableGeoip,
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
june?.identify(
|
|
274
|
-
{
|
|
275
|
-
userId,
|
|
276
|
-
traits,
|
|
277
|
-
timestamp,
|
|
278
|
-
},
|
|
279
|
-
(err) => (err ? console.error(err) : {})
|
|
280
|
-
);
|
|
281
|
-
|
|
282
203
|
// upsert intercom user
|
|
283
204
|
try {
|
|
284
205
|
const data = {
|
|
@@ -322,7 +243,6 @@ export const useTracking = (
|
|
|
322
243
|
groupId,
|
|
323
244
|
userId,
|
|
324
245
|
anonymousId,
|
|
325
|
-
timestamp = new Date(),
|
|
326
246
|
}: GroupProps) => {
|
|
327
247
|
if (isDev || isTest(userId || anonymousId || '', groupId)) return;
|
|
328
248
|
|
|
@@ -374,29 +294,7 @@ export const useTracking = (
|
|
|
374
294
|
console.error(e);
|
|
375
295
|
}
|
|
376
296
|
|
|
377
|
-
if (
|
|
378
|
-
posthog?.groupIdentify({
|
|
379
|
-
groupKey: groupId,
|
|
380
|
-
groupType: 'tenant',
|
|
381
|
-
properties: convertKeysToSnakeCase(traits),
|
|
382
|
-
distinctId: anonymousId,
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
june?.group({ anonymousId, groupId, traits, timestamp }, (err) =>
|
|
386
|
-
err ? console.error(err) : {}
|
|
387
|
-
);
|
|
388
|
-
} else if (userId) {
|
|
389
|
-
posthog?.groupIdentify({
|
|
390
|
-
groupKey: groupId,
|
|
391
|
-
groupType: 'tenant',
|
|
392
|
-
properties: convertKeysToSnakeCase(traits),
|
|
393
|
-
distinctId: userId,
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
june?.group({ userId, groupId, traits, timestamp }, (err) =>
|
|
397
|
-
err ? console.error(err) : {}
|
|
398
|
-
);
|
|
399
|
-
|
|
297
|
+
if (userId) {
|
|
400
298
|
// attach intercom user to intercom company
|
|
401
299
|
try {
|
|
402
300
|
const intercomUser = (
|
|
@@ -417,12 +315,9 @@ export const useTracking = (
|
|
|
417
315
|
}
|
|
418
316
|
}
|
|
419
317
|
},
|
|
420
|
-
shutdown: async () =>
|
|
421
|
-
Promise.all([posthog?.shutdown(), june?.closeAndFlush(), log?.flush()]),
|
|
318
|
+
shutdown: async () => log?.flush(),
|
|
422
319
|
// export dependencies
|
|
423
320
|
intercom,
|
|
424
|
-
posthog,
|
|
425
|
-
june,
|
|
426
321
|
log,
|
|
427
322
|
};
|
|
428
323
|
};
|
package/src/tracking/types.ts
CHANGED
|
@@ -36,8 +36,6 @@ export type IdentifyProps = {
|
|
|
36
36
|
role?: UserRole;
|
|
37
37
|
[key: string]: string | number | boolean | null | undefined;
|
|
38
38
|
};
|
|
39
|
-
disableGeoip?: boolean;
|
|
40
|
-
timestamp?: Date;
|
|
41
39
|
};
|
|
42
40
|
|
|
43
41
|
export type GroupProps = OptionalUser<{
|
|
@@ -65,7 +63,6 @@ export type GroupProps = OptionalUser<{
|
|
|
65
63
|
trialUntil?: string;
|
|
66
64
|
[key: string]: string | number | boolean | null | undefined;
|
|
67
65
|
};
|
|
68
|
-
timestamp?: Date;
|
|
69
66
|
}>;
|
|
70
67
|
|
|
71
68
|
export type TrackingEventProps = {
|
|
@@ -105,9 +102,11 @@ export type TrackingEventProps = {
|
|
|
105
102
|
tax_statement_preview_opened: TaxStatementPreviewOpenedProps;
|
|
106
103
|
tax_statement_downloaded: TaxStatementDownloadedProps;
|
|
107
104
|
team_added: TeamAddedProps;
|
|
105
|
+
team_canceled: TeamCanceledProps;
|
|
108
106
|
team_deleted: TeamDeletedProps;
|
|
109
107
|
team_info_updated: TeamInfoUpdatedProps;
|
|
110
108
|
team_member_removed: TeamMemberRemovedProps;
|
|
109
|
+
team_reinstated: TeamReinstatedProps;
|
|
111
110
|
gl_owner_statement_preview_opened: GlOwnerStatementPreviewOpenedProps;
|
|
112
111
|
gl_owner_statement_downloaded: GlOwnerStatementDownloadedProps;
|
|
113
112
|
hyperline_invoice_ready: HyperlineInvoiceReadyProps;
|
|
@@ -610,6 +609,14 @@ type TeamAddedProps = Partial<{
|
|
|
610
609
|
userEmail: string;
|
|
611
610
|
}>;
|
|
612
611
|
|
|
612
|
+
type TeamCanceledProps = Partial<{
|
|
613
|
+
tenantId: string;
|
|
614
|
+
customerId: string;
|
|
615
|
+
subscriptionId: string;
|
|
616
|
+
feedback: string;
|
|
617
|
+
reason: string;
|
|
618
|
+
}>;
|
|
619
|
+
|
|
613
620
|
type TeamDeletedProps = Partial<{
|
|
614
621
|
tenantId: string;
|
|
615
622
|
userId: string;
|
|
@@ -629,6 +636,14 @@ type TeamMemberRemovedProps = Partial<{
|
|
|
629
636
|
userEmail: string;
|
|
630
637
|
}>;
|
|
631
638
|
|
|
639
|
+
type TeamReinstatedProps = Partial<{
|
|
640
|
+
tenantId: string;
|
|
641
|
+
customerId: string;
|
|
642
|
+
subscriptionId: string;
|
|
643
|
+
feedback: string;
|
|
644
|
+
reason: string;
|
|
645
|
+
}>;
|
|
646
|
+
|
|
632
647
|
type TestErrorProps = Partial<{
|
|
633
648
|
userId: string;
|
|
634
649
|
tenantId: string;
|
package/build/main/baselog.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BaseLog } from './type';
|
|
2
|
-
export * from './type';
|
|
3
|
-
export declare function createBaseLog({ token, orgId, dataset, consoleLog, }: {
|
|
4
|
-
token?: string;
|
|
5
|
-
orgId?: string;
|
|
6
|
-
dataset?: string;
|
|
7
|
-
consoleLog?: boolean | 'color';
|
|
8
|
-
}, { environment, workerId, app, version, context, type, correlationId, executionContext, }: {
|
|
9
|
-
correlationId?: string;
|
|
10
|
-
environment?: 'development' | 'production';
|
|
11
|
-
type?: 'worker' | 'durableObject';
|
|
12
|
-
workerId?: string;
|
|
13
|
-
app?: string;
|
|
14
|
-
version?: string;
|
|
15
|
-
context?: Record<string, any>;
|
|
16
|
-
executionContext?: {
|
|
17
|
-
waitUntil(promise: Promise<any>): void;
|
|
18
|
-
};
|
|
19
|
-
}): BaseLog;
|