@vrplatform/log 2.0.0 → 2.0.2

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.
Files changed (61) hide show
  1. package/build/main/log/index.spec.d.ts +0 -0
  2. package/build/main/log/index.spec.js +2 -0
  3. package/build/main/log/index.spec.js.map +1 -0
  4. package/build/main/log/type.d.ts +3 -1
  5. package/build/main/tracking/_intercom.d.ts +109 -0
  6. package/build/main/tracking/_intercom.js +139 -0
  7. package/build/main/tracking/_intercom.js.map +1 -0
  8. package/build/main/tracking/eventTypes.d.ts +16 -0
  9. package/build/main/tracking/eventTypes.js +3 -0
  10. package/build/main/tracking/eventTypes.js.map +1 -0
  11. package/build/main/tracking/index.d.ts +96 -33
  12. package/build/main/tracking/index.js +105 -68
  13. package/build/main/tracking/index.js.map +1 -1
  14. package/build/main/tracking/types.d.ts +508 -15
  15. package/build/main/utils/convertKeysToSnakeCase.d.ts +1 -0
  16. package/build/main/utils/convertKeysToSnakeCase.js +23 -0
  17. package/build/main/utils/convertKeysToSnakeCase.js.map +1 -0
  18. package/build/main/utils/convertValuesToString.d.ts +5 -0
  19. package/build/main/utils/convertValuesToString.js +11 -0
  20. package/build/main/utils/convertValuesToString.js.map +1 -0
  21. package/build/main/utils/index.d.ts +3 -0
  22. package/build/main/utils/index.js +20 -0
  23. package/build/main/utils/index.js.map +1 -0
  24. package/build/main/utils/isTest.d.ts +1 -0
  25. package/build/main/utils/isTest.js +18 -0
  26. package/build/main/utils/isTest.js.map +1 -0
  27. package/build/module/log/index.spec.d.ts +0 -0
  28. package/build/module/log/index.spec.js +2 -0
  29. package/build/module/log/index.spec.js.map +1 -0
  30. package/build/module/log/type.d.ts +3 -1
  31. package/build/module/tracking/_intercom.d.ts +109 -0
  32. package/build/module/tracking/_intercom.js +136 -0
  33. package/build/module/tracking/_intercom.js.map +1 -0
  34. package/build/module/tracking/eventTypes.d.ts +16 -0
  35. package/build/module/tracking/eventTypes.js +2 -0
  36. package/build/module/tracking/eventTypes.js.map +1 -0
  37. package/build/module/tracking/index.d.ts +96 -33
  38. package/build/module/tracking/index.js +96 -57
  39. package/build/module/tracking/index.js.map +1 -1
  40. package/build/module/tracking/types.d.ts +508 -15
  41. package/build/module/utils/convertKeysToSnakeCase.d.ts +1 -0
  42. package/build/module/utils/convertKeysToSnakeCase.js +19 -0
  43. package/build/module/utils/convertKeysToSnakeCase.js.map +1 -0
  44. package/build/module/utils/convertValuesToString.d.ts +5 -0
  45. package/build/module/utils/convertValuesToString.js +8 -0
  46. package/build/module/utils/convertValuesToString.js.map +1 -0
  47. package/build/module/utils/index.d.ts +3 -0
  48. package/build/module/utils/index.js +4 -0
  49. package/build/module/utils/index.js.map +1 -0
  50. package/build/module/utils/isTest.d.ts +1 -0
  51. package/build/module/utils/isTest.js +14 -0
  52. package/build/module/utils/isTest.js.map +1 -0
  53. package/package.json +24 -26
  54. package/src/log/type.ts +5 -1
  55. package/src/tracking/index.ts +230 -97
  56. package/src/tracking/types.ts +622 -97
  57. package/src/utils/convertKeysToSnakeCase.ts +21 -0
  58. package/src/utils/convertValuesToString.ts +10 -0
  59. package/src/utils/index.ts +3 -0
  60. package/src/utils/isTest.ts +16 -0
  61. package/src/tracking/intercom.ts +0 -258
@@ -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":"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;IAED,UAAU;IACV,KAAK,CAAC,oBAAoB,CAAC,QAAgB;QACzC,OAAO,MAAM,IAAI,CAAC,KAAK,CAoCpB,yBAAyB,QAAQ,EAAE,EAAE;YACtC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,EAClB,IAAI,EACJ,QAAQ,GAQT;QACC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,GAAG,IAAI;gBACP,UAAU,EAAE,QAAQ;aACrB;SACF,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,EAClB,IAAI,EACJ,SAAS,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"}
@@ -0,0 +1,16 @@
1
+ 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';
2
+ type TeamEvent = 'team_added' | 'team_info_updated' | 'team_deleted' | 'team_member_removed';
3
+ type ConnectionEvent = 'connection_created' | 'connection_reconnected' | 'connection_deleted' | 'connection_requested';
4
+ type OwnershipEvent = 'ownership_created' | 'ownership_updated' | 'ownership_deleted';
5
+ type OwnerEvent = 'owner_created' | 'owner_updated' | 'owner_deleted' | 'owner_tax_info_modal_opened' | 'owner_tax_info_modal_submitted';
6
+ type SetupEvent = 'setup_classes_set' | 'setup_accounting_version_completed' | 'setup_accounting_config_completed' | 'setup_owner_imported' | 'setup_listing_imported';
7
+ type AutomationEvent = 'automation_created' | 'automation_updated' | 'automation_deleted';
8
+ type TaxStatementEvent = 'tax_statement_preview_opened' | 'tax_statement_downloaded';
9
+ type GLOwnerStatementEvent = 'gl_owner_statement_preview_opened' | 'gl_owner_statement_downloaded';
10
+ type HyperlineEvent = 'hyperline_invoice_ready' | 'hyperline_invoice_settled' | 'hyperline_trial_started' | 'hyperline_trial_ended' | 'hyperline_subscription_activated' | 'hyperline_subscription_cancelled' | 'hyperline_subscription_created' | 'hyperline_subscription_errored' | 'hyperline_subscription_paused' | 'hyperline_subscription_voided' | 'hyperline_subscription_charged' | 'hyperline_customer_created' | 'hyperline_customer_updated' | 'hyperline_payment_method_created' | 'hyperline_payment_method_errored' | 'hyperline_payment_method_deleted';
11
+ type ListingEvent = 'listing_activated' | 'listing_deactivated';
12
+ type ReportEvent = 'listings_reported';
13
+ type UserEvent = 'update_refresh_accepted' | 'owner_statement_opened';
14
+ type TestEvent = 'test_event' | 'test_error';
15
+ export type TrackingEvent = AuthEvent | TeamEvent | ConnectionEvent | OwnershipEvent | OwnerEvent | SetupEvent | AutomationEvent | TaxStatementEvent | GLOwnerStatementEvent | HyperlineEvent | UserEvent | ListingEvent | ReportEvent | TestEvent;
16
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=eventTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventTypes.js","sourceRoot":"src/","sources":["tracking/eventTypes.ts"],"names":[],"mappings":""}
@@ -1,12 +1,100 @@
1
+ declare module 'intercom-client' {
2
+ namespace Intercom {
3
+ interface CreateContactRequestWithExternalId {
4
+ /** A unique identifier for the contact which is given to Intercom */
5
+ external_id: string;
6
+ /** The contacts phone */
7
+ phone?: string;
8
+ /** The contacts name */
9
+ name?: string;
10
+ /** An image URL containing the avatar of a contact */
11
+ avatar?: string;
12
+ /** The time specified for when a contact signed up */
13
+ signed_up_at?: number;
14
+ /** The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) */
15
+ last_seen_at?: number;
16
+ /** The id of an admin that has been assigned account ownership of the contact */
17
+ owner_id?: number;
18
+ /** Whether the contact is unsubscribed from emails */
19
+ unsubscribed_from_emails?: boolean;
20
+ /** The custom attributes which are set for the contact */
21
+ custom_attributes?: ContactCustomAttributes;
22
+ }
23
+ interface UpdateContactRequest {
24
+ /** The role of the contact. */
25
+ role?: 'user' | 'lead';
26
+ /** A unique identifier for the contact which is given to Intercom */
27
+ external_id?: string;
28
+ /** The contacts email */
29
+ email?: string;
30
+ /** The contacts phone */
31
+ phone?: string;
32
+ /** The contacts name */
33
+ name?: string;
34
+ /** An image URL containing the avatar of a contact */
35
+ avatar?: string;
36
+ /** The time specified for when a contact signed up */
37
+ signed_up_at?: number;
38
+ /** The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) */
39
+ last_seen_at?: number;
40
+ /** The id of an admin that has been assigned account ownership of the contact */
41
+ owner_id?: number;
42
+ /** Whether the contact is unsubscribed from emails */
43
+ unsubscribed_from_emails?: boolean;
44
+ /** The custom attributes which are set for the contact */
45
+ custom_attributes?: ContactCustomAttributes;
46
+ }
47
+ interface ContactCustomAttributes {
48
+ Onboarding_Support?: string;
49
+ userType?: string;
50
+ }
51
+ interface CreateOrUpdateCompanyRequest {
52
+ /** The name of the Company */
53
+ name?: string;
54
+ /** The company id you have defined for the company. Can't be updated */
55
+ company_id?: string;
56
+ /** The name of the plan you have associated with the company. */
57
+ plan?: string;
58
+ /** The number of employees in this company. */
59
+ size?: number;
60
+ /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */
61
+ website?: string;
62
+ /** The industry that this company operates in. */
63
+ industry?: string;
64
+ /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */
65
+ custom_attributes?: CompanyCustomAttributes;
66
+ /** The time the company was created by you. */
67
+ remote_created_at?: number;
68
+ /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2\*\*31-1 or 2147483647.. */
69
+ monthly_spend?: number;
70
+ }
71
+ interface CompanyCustomAttributes {
72
+ teamId?: string;
73
+ team?: string;
74
+ type?: string;
75
+ status?: string;
76
+ pms?: string;
77
+ accountingSoftware?: string;
78
+ creation_source?: string;
79
+ activeListings?: number;
80
+ paymentMethodType?: string;
81
+ partnerName?: string;
82
+ billingPortalUrl?: string;
83
+ billingStatus?: string;
84
+ billingPartner?: string;
85
+ }
86
+ }
87
+ }
1
88
  import { Analytics } from '@june-so/analytics-node';
89
+ import { IntercomClient } from 'intercom-client';
2
90
  import { PostHog } from 'posthog-node';
3
91
  import { type LogBindings, type WorkerLog } from '../log';
4
- import { useIntercom } from './intercom';
5
- import type { TrackingEvent } from './types';
92
+ import type { GroupProps, IdentifyProps, TrackProps, TrackingEvent } from './types';
6
93
  export * from './types';
7
- export declare const isTest: (userId: string, groupId?: string, userEmail?: string) => boolean | "" | undefined;
8
- export declare const convertKeysToSnakeCase: (obj?: Record<string, any>) => Record<string, any>;
9
- export type TrackingProps = {
94
+ export * from 'intercom-client';
95
+ export * from '../utils';
96
+ export type Tracking = ReturnType<typeof useTracking>;
97
+ export type UseTracking = {
10
98
  name: string;
11
99
  dataset: string;
12
100
  env: {
@@ -16,38 +104,13 @@ export type TrackingProps = {
16
104
  } & LogBindings;
17
105
  debugging?: boolean;
18
106
  };
19
- export type Tracking = ReturnType<typeof useTracking>;
20
- export type TrackProps = OptionalUser<{
21
- groupId: string;
22
- event: TrackingEvent;
23
- properties: Record<string, string | number | boolean | null | undefined>;
24
- timestamp?: Date;
25
- }>;
26
- export type IdentifyProps = {
27
- userId: string;
28
- traits: Record<string, string | number | boolean | null | undefined>;
29
- disableGeoip?: boolean;
30
- timestamp?: Date;
31
- };
32
- export type GroupProps = OptionalUser<{
33
- groupId: string;
34
- traits?: Record<string, string | number | boolean | null | undefined>;
35
- timestamp?: Date;
36
- }>;
37
- type OptionalUser<T> = T & ({
38
- userId: string;
39
- anonymousId?: string;
40
- } | {
41
- userId?: string;
42
- anonymousId: string;
43
- });
44
- export declare const useTracking: ({ dataset, env, name }: TrackingProps, isDev?: boolean) => {
45
- track: (props: TrackProps) => Promise<void>;
107
+ export declare const useTracking: ({ dataset, env, name }: UseTracking, isDev?: boolean) => {
108
+ track: <T extends TrackingEvent>(props: TrackProps<T>) => Promise<void>;
46
109
  identify: (props: IdentifyProps) => Promise<void>;
47
110
  group: (props: GroupProps) => Promise<void>;
48
111
  shutdown: () => Promise<any>;
49
112
  log: WorkerLog;
50
113
  june?: Analytics;
51
- _intercom?: ReturnType<typeof useIntercom>;
114
+ intercom?: IntercomClient;
52
115
  posthog?: PostHog;
53
116
  };
@@ -1,45 +1,23 @@
1
1
  import { Analytics } from '@june-so/analytics-node';
2
+ import { Intercom, IntercomClient } from 'intercom-client';
3
+ import { fetcher } from 'intercom-client/core/fetcher/Fetcher';
2
4
  import { PostHog } from 'posthog-node';
3
5
  import { useLog } from '../log';
4
- import { useIntercom } from './intercom';
6
+ import { convertKeysToSnakeCase, isTest } from '../utils';
7
+ import { convertValuesToString } from '../utils/convertValuesToString';
5
8
  export * from './types';
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
- const E2E_TEST_TEAMS = {
13
- 'VRP Automated Testing': 'c4fd21b4-8447-43a2-bdcb-f06a85a935ad',
14
- test_company_xxxx: '8f21060e-afe6-410a-b2f4-00a3caa20786',
15
- };
16
- export const isTest = (userId, groupId, userEmail) => Object.values(E2E_TEST_USERS).includes(userId) ||
17
- (groupId && Object.values(E2E_TEST_TEAMS).includes(groupId)) ||
18
- (userEmail && Object.keys(E2E_TEST_USERS).includes(userEmail));
19
- const camelToSnakeCase = (str) => str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
20
- // todo: move to utils
21
- export const convertKeysToSnakeCase = (obj) => {
22
- const result = {};
23
- const hasOwnProperty = Object.prototype.hasOwnProperty;
24
- for (const key in obj) {
25
- if (hasOwnProperty.call(obj, key)) {
26
- const snakeKey = camelToSnakeCase(key);
27
- if (typeof obj[key] === 'object' &&
28
- !Array.isArray(obj[key]) &&
29
- obj[key] !== null) {
30
- result[snakeKey] = convertKeysToSnakeCase(obj[key]);
31
- }
32
- else {
33
- result[snakeKey] = obj[key];
34
- }
35
- }
36
- }
37
- return result;
38
- };
9
+ export * from 'intercom-client';
10
+ export * from '../utils';
39
11
  export const useTracking = ({ dataset, env, name }, isDev) => {
40
12
  const log = useLog({ name, dataset, env });
41
- const _intercom = env.INTERCOM_TOKEN
42
- ? useIntercom(env.INTERCOM_TOKEN, log)
13
+ const intercom = env.INTERCOM_TOKEN
14
+ ? new IntercomClient({
15
+ token: env.INTERCOM_TOKEN,
16
+ fetcher: (args) => fetcher({
17
+ ...args,
18
+ headers: { ...args.headers, accept: 'application/json' },
19
+ }),
20
+ })
43
21
  : undefined;
44
22
  const june = env.JUNESO_TOKEN ? new Analytics(env.JUNESO_TOKEN) : undefined;
45
23
  const posthog = env.POSTHOG_TOKEN
@@ -94,16 +72,20 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
94
72
  if (err)
95
73
  console.error(err);
96
74
  });
97
- try {
98
- await _intercom?.trackEvent({
99
- user_id: userId,
75
+ const intercomUserId = (await intercom?.contacts.search({
76
+ query: {
77
+ field: 'external_id',
78
+ operator: Intercom.SingleFilterSearchRequestOperator.Equals,
79
+ value: userId,
80
+ },
81
+ }))?.data.at(0)?.id;
82
+ if (intercomUserId)
83
+ await intercom?.events.create({
84
+ user_id: intercomUserId,
100
85
  event_name: event,
101
- metadata: properties,
86
+ metadata: convertValuesToString(properties),
87
+ created_at: timestamp ? timestamp.getTime() : Date.now(),
102
88
  });
103
- }
104
- catch (error) {
105
- console.error(error);
106
- }
107
89
  }
108
90
  },
109
91
  identify: async ({ traits, userId, disableGeoip, timestamp, }) => {
@@ -118,14 +100,65 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
118
100
  userId,
119
101
  traits,
120
102
  timestamp,
121
- }, (err) => {
122
- if (err)
123
- console.error(err);
124
- });
103
+ }, (err) => (err ? console.error(err) : {}));
104
+ // upsert intercom user
105
+ const data = {
106
+ external_id: userId,
107
+ email: traits?.email,
108
+ name: traits?.name ||
109
+ (traits?.firstName
110
+ ? `${traits.firstName} ${traits.lastName}`
111
+ : traits?.lastName),
112
+ avatar: traits?.avatar,
113
+ signed_up_at: traits?.createdAt
114
+ ? new Date(traits.createdAt).getTime() / 1000
115
+ : undefined,
116
+ last_seen_at: new Date().getTime() / 1000,
117
+ custom_attributes: { userType: traits?.role },
118
+ };
119
+ const intercomUser = (await intercom?.contacts.search({
120
+ query: {
121
+ field: 'external_id',
122
+ operator: Intercom.SingleFilterSearchRequestOperator.Equals,
123
+ value: userId,
124
+ },
125
+ }))?.data.at(0);
126
+ if (intercomUser?.id)
127
+ await intercom?.contacts.update(intercomUser?.id, data);
128
+ else
129
+ await intercom?.contacts.create(data);
125
130
  },
126
131
  group: async ({ traits, groupId, userId, anonymousId, timestamp, }) => {
127
132
  if (isDev || isTest(userId || anonymousId || '', groupId))
128
133
  return;
134
+ const cid = traits?.billingCustomerId || traits?.hyperlineCustomerId;
135
+ const intercomCompany = await intercom?.companies.create({
136
+ name: traits?.name,
137
+ company_id: groupId,
138
+ plan: traits?.plan,
139
+ remote_created_at: traits?.createdAt
140
+ ? new Date(traits.createdAt).getTime() / 1000
141
+ : undefined,
142
+ monthly_spend: traits?.mrr,
143
+ custom_attributes: {
144
+ teamId: groupId,
145
+ team: traits?.name,
146
+ type: traits?.type,
147
+ status: traits?.status,
148
+ pms: traits?.pms,
149
+ accountingSoftware: traits?.accountingSoftware,
150
+ activeListings: traits?.activeListings,
151
+ paymentMethodType: traits?.paymentMethodType,
152
+ partnerName: traits?.partner || traits?.accountingPartner,
153
+ billingPortalUrl: cid
154
+ ? `https://billing.vrplatform.app/portal/${cid}`
155
+ : undefined,
156
+ billingStatus: traits?.billingSubscriptionStatus,
157
+ billingPartner: traits?.billingPartner ||
158
+ traits?.partner ||
159
+ traits?.accountingPartner,
160
+ },
161
+ });
129
162
  if (anonymousId) {
130
163
  posthog?.groupIdentify({
131
164
  groupKey: groupId,
@@ -133,10 +166,7 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
133
166
  properties: convertKeysToSnakeCase(traits),
134
167
  distinctId: anonymousId,
135
168
  });
136
- june?.group({ anonymousId, groupId, traits, timestamp }, (err) => {
137
- if (err)
138
- console.error(err);
139
- });
169
+ june?.group({ anonymousId, groupId, traits, timestamp }, (err) => err ? console.error(err) : {});
140
170
  }
141
171
  else if (userId) {
142
172
  posthog?.groupIdentify({
@@ -145,15 +175,24 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
145
175
  properties: convertKeysToSnakeCase(traits),
146
176
  distinctId: userId,
147
177
  });
148
- june?.group({ userId, groupId, traits, timestamp }, (err) => {
149
- if (err)
150
- console.error(err);
151
- });
178
+ june?.group({ userId, groupId, traits, timestamp }, (err) => err ? console.error(err) : {});
179
+ // attach intercom user to intercom company
180
+ const intercomUser = (await intercom?.contacts.search({
181
+ query: {
182
+ field: 'external_id',
183
+ operator: Intercom.SingleFilterSearchRequestOperator.Equals,
184
+ value: userId,
185
+ },
186
+ }))?.data.at(0);
187
+ if (intercomUser?.id && intercomCompany?.id)
188
+ intercom?.companies.attachContact(intercomUser?.id, {
189
+ id: intercomCompany?.id,
190
+ });
152
191
  }
153
192
  },
154
193
  shutdown: async () => Promise.all([posthog?.shutdown(), june?.closeAndFlush(), log?.flush()]),
155
194
  // export dependencies
156
- _intercom,
195
+ intercom,
157
196
  posthog,
158
197
  june,
159
198
  log,
@@ -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,EAAoC,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,cAAc,SAAS,CAAC;AAExB,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,cAAc,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAEjE,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE,CACvC,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AAExD,sBAAsB;AACtB,MAAM,CAAC,MAAM,sBAAsB,GA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