@maxzima/wa-communicator 1.0.21 → 1.0.23

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.
@@ -1,15 +1,6 @@
1
- declare const enum GA4EventActionEnum {
2
- VERIFY_CONTACT = "verify_contact"
3
- }
4
- declare const enum GA4EventContactEnum {
5
- PHONE = "phone",
6
- EMAIL = "email"
7
- }
8
1
  declare const enum LintrkActionTypeEnum {
9
2
  TRACK = "track"
10
3
  }
11
4
  declare const enum LintrkEventIdEnum {
12
- PHONE = 8612332,
13
- EMAIL = 8612340,
14
5
  REGISTRATION = 8612308
15
6
  }
@@ -1,9 +1,6 @@
1
1
  export declare class AccountTracker {
2
2
  private props;
3
3
  constructor(props: TAccountTrackerProps);
4
- sendPhoneVerifyEvent(): void;
5
- sendEmailVerifyEvent(): void;
6
4
  sendRegistrationSuccessEvent(): void;
7
- private sendGA4Event;
8
5
  private sendLinkedInEvent;
9
6
  }
@@ -1,16 +1,5 @@
1
1
  export class AccountTracker {
2
2
  constructor(props) {
3
- this.sendGA4Event = (action, contact) => {
4
- if (typeof this.props.gtag === 'undefined' || !this.props.ga4Id) {
5
- return;
6
- }
7
- const params = {
8
- contact: contact,
9
- origin: this.props.origin || null,
10
- send_to: this.props.ga4Id,
11
- };
12
- this.props.gtag('event', action, params);
13
- };
14
3
  this.sendLinkedInEvent = (id) => {
15
4
  if (typeof this.props.lintrk === 'undefined') {
16
5
  return;
@@ -21,14 +10,6 @@ export class AccountTracker {
21
10
  };
22
11
  this.props = props;
23
12
  }
24
- sendPhoneVerifyEvent() {
25
- this.sendGA4Event("verify_contact", "phone");
26
- this.sendLinkedInEvent(8612332);
27
- }
28
- sendEmailVerifyEvent() {
29
- this.sendGA4Event("verify_contact", "email");
30
- this.sendLinkedInEvent(8612340);
31
- }
32
13
  sendRegistrationSuccessEvent() {
33
14
  this.sendLinkedInEvent(8612308);
34
15
  }
@@ -1,15 +1,6 @@
1
- /// <reference types="gtag.js" />
2
1
  declare type TLintrkOptions = {
3
2
  conversation_id: LintrkEventIdEnum;
4
3
  };
5
- declare type TGA4Event = {
6
- contact: GA4EventContactEnum;
7
- send_to: TAccountTrackerProps['ga4Id'];
8
- origin?: TAccountTrackerProps['origin'];
9
- };
10
4
  declare type TAccountTrackerProps = {
11
- origin?: string;
12
- gtag?: Gtag.Gtag;
13
5
  lintrk?: (action: LintrkActionTypeEnum, options: TLintrkOptions) => void;
14
- ga4Id?: string;
15
6
  };
@@ -141,6 +141,11 @@ export class Communicator {
141
141
  device_type: data.deviceType,
142
142
  ga_id: data.gaId,
143
143
  origin: data.origin,
144
+ gc_id: data.gcId,
145
+ utm_source: data.utmSource,
146
+ utm_medium: data.utmMedium,
147
+ utm_campaign: data.utmCampaign,
148
+ utm_term: data.utmTerm,
144
149
  } }));
145
150
  return yield this.send({
146
151
  method: 'POST',
@@ -103,6 +103,11 @@ declare type TRegistrationRequestBodySource = {
103
103
  device_type: TRegistrationRequestBodySourceDeviceType;
104
104
  ga_id: string;
105
105
  origin: string;
106
+ gc_id: string;
107
+ utm_source: string;
108
+ utm_medium: string;
109
+ utm_campaign: string;
110
+ utm_term: string;
106
111
  };
107
112
  declare type TRegistrationRequestBody = {
108
113
  name: string;
@@ -120,6 +125,11 @@ declare type TRegistrationRequestData = {
120
125
  hash: TRegistrationRequestBodySource['hash'];
121
126
  gaId: TRegistrationRequestBodySource['ga_id'];
122
127
  origin: TRegistrationRequestBodySource['origin'];
128
+ gcId: TRegistrationRequestBodySource['gc_id'];
129
+ utmSource: TRegistrationRequestBodySource['utm_source'];
130
+ utmMedium: TRegistrationRequestBodySource['utm_medium'];
131
+ utmCampaign: TRegistrationRequestBodySource['utm_campaign'];
132
+ utmTerm: TRegistrationRequestBodySource['utm_term'];
123
133
  };
124
134
  declare type TStorageRequestData = {
125
135
  accessToken: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.21",
2
+ "version": "1.0.23",
3
3
  "name": "@maxzima/wa-communicator",
4
4
  "description": "",
5
5
  "author": "Noname",
@@ -1,18 +1,7 @@
1
- const enum GA4EventActionEnum {
2
- VERIFY_CONTACT = 'verify_contact',
3
- }
4
-
5
- const enum GA4EventContactEnum {
6
- PHONE = 'phone',
7
- EMAIL = 'email',
8
- }
9
-
10
1
  const enum LintrkActionTypeEnum {
11
2
  TRACK= 'track',
12
3
  }
13
4
 
14
5
  const enum LintrkEventIdEnum {
15
- PHONE = 8612332,
16
- EMAIL = 8612340,
17
6
  REGISTRATION = 8612308,
18
7
  }
@@ -5,34 +5,10 @@ export class AccountTracker {
5
5
  this.props = props;
6
6
  }
7
7
 
8
- public sendPhoneVerifyEvent () {
9
- this.sendGA4Event(GA4EventActionEnum.VERIFY_CONTACT, GA4EventContactEnum.PHONE);
10
- this.sendLinkedInEvent(LintrkEventIdEnum.PHONE);
11
- }
12
-
13
- public sendEmailVerifyEvent () {
14
- this.sendGA4Event(GA4EventActionEnum.VERIFY_CONTACT, GA4EventContactEnum.EMAIL);
15
- this.sendLinkedInEvent(LintrkEventIdEnum.EMAIL);
16
- }
17
-
18
8
  public sendRegistrationSuccessEvent () {
19
9
  this.sendLinkedInEvent(LintrkEventIdEnum.REGISTRATION);
20
10
  }
21
11
 
22
- private sendGA4Event = (action: GA4EventActionEnum, contact: GA4EventContactEnum) => {
23
- if (typeof this.props.gtag === 'undefined' || !this.props.ga4Id) {
24
- return;
25
- }
26
-
27
- const params: TGA4Event = {
28
- contact: contact,
29
- origin: this.props.origin || null,
30
- send_to: this.props.ga4Id,
31
- };
32
-
33
- this.props.gtag('event', action, params);
34
- };
35
-
36
12
  private sendLinkedInEvent = (id: LintrkEventIdEnum) => {
37
13
  if (typeof this.props.lintrk === 'undefined') {
38
14
  return;
@@ -2,15 +2,6 @@ type TLintrkOptions = {
2
2
  conversation_id: LintrkEventIdEnum;
3
3
  }
4
4
 
5
- type TGA4Event = {
6
- contact: GA4EventContactEnum;
7
- send_to: TAccountTrackerProps['ga4Id'];
8
- origin?: TAccountTrackerProps['origin'];
9
- }
10
-
11
5
  type TAccountTrackerProps = {
12
- origin?: string;
13
- gtag?: Gtag.Gtag;
14
6
  lintrk?: (action: LintrkActionTypeEnum, options: TLintrkOptions) => void;
15
- ga4Id?: string;
16
7
  }
@@ -137,6 +137,11 @@ export class Communicator {
137
137
  device_type: data.deviceType,
138
138
  ga_id: data.gaId,
139
139
  origin: data.origin,
140
+ gc_id: data.gcId,
141
+ utm_source: data.utmSource,
142
+ utm_medium: data.utmMedium,
143
+ utm_campaign: data.utmCampaign,
144
+ utm_term: data.utmTerm,
140
145
  }
141
146
  });
142
147
 
@@ -147,6 +147,11 @@ type TRegistrationRequestBodySource = {
147
147
  device_type: TRegistrationRequestBodySourceDeviceType,
148
148
  ga_id: string,
149
149
  origin: string,
150
+ gc_id: string,
151
+ utm_source: string,
152
+ utm_medium: string,
153
+ utm_campaign: string,
154
+ utm_term: string,
150
155
  }
151
156
 
152
157
  type TRegistrationRequestBody = {
@@ -167,6 +172,11 @@ type TRegistrationRequestData = {
167
172
  hash: TRegistrationRequestBodySource['hash'],
168
173
  gaId: TRegistrationRequestBodySource['ga_id'],
169
174
  origin: TRegistrationRequestBodySource['origin'],
175
+ gcId: TRegistrationRequestBodySource['gc_id'],
176
+ utmSource: TRegistrationRequestBodySource['utm_source'],
177
+ utmMedium: TRegistrationRequestBodySource['utm_medium'],
178
+ utmCampaign: TRegistrationRequestBodySource['utm_campaign'],
179
+ utmTerm: TRegistrationRequestBodySource['utm_term'],
170
180
  }
171
181
  /* endregion registration */
172
182
 
@@ -84,7 +84,7 @@ Object {
84
84
 
85
85
  exports[`Communicator requests registration 1`] = `
86
86
  Object {
87
- "body": "{\\"name\\":\\"_companyName_\\",\\"country_code\\":\\"CAN\\",\\"source\\":{\\"hash\\":\\"_hash_\\",\\"device_type\\":\\"mobile\\",\\"ga_id\\":\\"_gaId_\\",\\"origin\\":\\"_origin_\\"}}",
87
+ "body": "{\\"name\\":\\"_companyName_\\",\\"country_code\\":\\"CAN\\",\\"source\\":{\\"hash\\":\\"_hash_\\",\\"device_type\\":\\"mobile\\",\\"ga_id\\":\\"_gaId_\\",\\"origin\\":\\"_origin_\\",\\"gc_id\\":\\"_gcId_\\",\\"utm_source\\":\\"_utmSource_\\",\\"utm_medium\\":\\"_utmMedium_\\",\\"utm_campaign\\":\\"_utmCampaign_\\",\\"utm_term\\":\\"_utmTerm_\\"}}",
88
88
  "headers": Object {
89
89
  "Accept": "application/json, text/plain, */*",
90
90
  "Authorization": "Bearer _accessToken_",
@@ -1,14 +1,12 @@
1
1
  import {AccountTracker} from "../src";
2
- import {accountTrackerInitPropsNormal} from "./testunits/accountTracker/general";
3
- import {emailVerifyEvents, phoneVerifyEvents, registrationSuccessEvents} from "./testunits/accountTracker/events";
2
+ import {registrationSuccessEvents} from "./testunits/accountTracker/events";
4
3
 
5
- const mockGtag = jest.fn().mockImplementation();
6
4
  const mockLintrk = jest.fn().mockImplementation();
5
+
7
6
  const accountTrackerInitProps = {
8
- ...accountTrackerInitPropsNormal,
9
- gtag: mockGtag,
10
7
  lintrk: mockLintrk,
11
8
  };
9
+
12
10
  const accountTracker = new AccountTracker(accountTrackerInitProps);
13
11
 
14
12
  describe('AccountTracker', () => {
@@ -16,35 +14,9 @@ describe('AccountTracker', () => {
16
14
  jest.clearAllMocks();
17
15
  });
18
16
 
19
- test('sendPhoneVerifyEvent', () => {
20
- accountTracker.sendPhoneVerifyEvent();
21
-
22
- expect(mockGtag.mock.calls[0][1]).toBe(phoneVerifyEvents.ga4.action);
23
- expect(mockGtag.mock.calls[0][2]).toEqual(phoneVerifyEvents.ga4.event);
24
- expect(mockGtag).toHaveBeenCalled();
25
-
26
- expect(mockLintrk.mock.calls[0][0]).toBe(phoneVerifyEvents.linkedIn.action);
27
- expect(mockLintrk.mock.calls[0][1]).toEqual(phoneVerifyEvents.linkedIn.event);
28
- expect(mockLintrk).toHaveBeenCalled();
29
- });
30
-
31
- test('sendEmailVerifyEvent', () => {
32
- accountTracker.sendEmailVerifyEvent();
33
-
34
- expect(mockGtag.mock.calls[0][1]).toBe(emailVerifyEvents.ga4.action);
35
- expect(mockGtag.mock.calls[0][2]).toEqual(emailVerifyEvents.ga4.event);
36
- expect(mockGtag).toHaveBeenCalled();
37
-
38
- expect(mockLintrk.mock.calls[0][0]).toBe(emailVerifyEvents.linkedIn.action);
39
- expect(mockLintrk.mock.calls[0][1]).toEqual(emailVerifyEvents.linkedIn.event);
40
- expect(mockLintrk).toHaveBeenCalled();
41
- });
42
-
43
17
  test('sendRegistrationSuccessEvent', () => {
44
18
  accountTracker.sendRegistrationSuccessEvent();
45
19
 
46
- expect(mockGtag).not.toHaveBeenCalled();
47
-
48
20
  expect(mockLintrk.mock.calls[0][0]).toBe(registrationSuccessEvents.linkedIn.action);
49
21
  expect(mockLintrk.mock.calls[0][1]).toEqual(registrationSuccessEvents.linkedIn.event);
50
22
  expect(mockLintrk).toHaveBeenCalled();
@@ -1,39 +1,3 @@
1
- import {accountTrackerInitPropsNormal} from "./general";
2
-
3
- const phoneVerifyEvents = {
4
- ga4: {
5
- action: 'verify_contact',
6
- event: {
7
- contact: 'phone',
8
- origin: accountTrackerInitPropsNormal.origin,
9
- send_to: accountTrackerInitPropsNormal.ga4Id,
10
- },
11
- },
12
- linkedIn: {
13
- action: 'track',
14
- event: {
15
- conversation_id: 8612332,
16
- },
17
- },
18
- };
19
-
20
- const emailVerifyEvents = {
21
- ga4: {
22
- action: 'verify_contact',
23
- event: {
24
- contact: 'email',
25
- origin: accountTrackerInitPropsNormal.origin,
26
- send_to: accountTrackerInitPropsNormal.ga4Id,
27
- },
28
- },
29
- linkedIn: {
30
- action: 'track',
31
- event: {
32
- conversation_id: 8612340,
33
- },
34
- },
35
- };
36
-
37
1
  const registrationSuccessEvents = {
38
2
  linkedIn: {
39
3
  action: 'track',
@@ -44,7 +8,5 @@ const registrationSuccessEvents = {
44
8
  };
45
9
 
46
10
  export {
47
- phoneVerifyEvents,
48
- emailVerifyEvents,
49
11
  registrationSuccessEvents,
50
12
  };
@@ -26,6 +26,11 @@ const communicatorTestData = {
26
26
  hash: '_hash_',
27
27
  gaId: '_gaId_',
28
28
  origin: '_origin_',
29
+ gcId: '_gcId_',
30
+ utmSource: '_utmSource_',
31
+ utmMedium: '_utmMedium_',
32
+ utmCampaign: '_utmCampaign_',
33
+ utmTerm: '_utmTerm_',
29
34
  };
30
35
 
31
36
  export {
@@ -57,6 +57,11 @@ const registrationData: TRegistrationRequestData = {
57
57
  hash: communicatorTestData.hash,
58
58
  gaId: communicatorTestData.gaId,
59
59
  origin: communicatorTestData.origin,
60
+ gcId: communicatorTestData.gcId,
61
+ utmSource: communicatorTestData.utmSource,
62
+ utmMedium: communicatorTestData.utmMedium,
63
+ utmCampaign: communicatorTestData.utmCampaign,
64
+ utmTerm: communicatorTestData.utmTerm,
60
65
  };
61
66
 
62
67
  const setStorageValuesData: TStorageRequestData = {
@@ -1,8 +0,0 @@
1
- const accountTrackerInitPropsNormal = {
2
- origin: '_origin_',
3
- ga4Id: '_ga4Id_',
4
- };
5
-
6
- export {
7
- accountTrackerInitPropsNormal,
8
- };