@maxzima/wa-communicator 1.0.21 → 1.0.22
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/dist/engine/AccountTracker/Enums/AccountTrackerEnum.d.ts +0 -9
- package/dist/engine/AccountTracker/Public/AccountTracker.d.ts +0 -3
- package/dist/engine/AccountTracker/Public/AccountTracker.js +0 -19
- package/dist/engine/AccountTracker/Types/TAccountTracker.d.ts +0 -9
- package/package.json +1 -1
- package/src/engine/AccountTracker/Enums/AccountTrackerEnum.ts +0 -11
- package/src/engine/AccountTracker/Public/AccountTracker.ts +0 -24
- package/src/engine/AccountTracker/Types/TAccountTracker.ts +0 -9
- package/test/accountTracker.spec.ts +3 -31
- package/test/testunits/accountTracker/events.ts +0 -38
- package/test/testunits/accountTracker/general.ts +0 -8
|
@@ -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,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
|
};
|
package/package.json
CHANGED
|
@@ -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
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {AccountTracker} from "../src";
|
|
2
|
-
import {
|
|
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
|
};
|