@ninetailed/experience.js-plugin-google-tagmanager 2.0.0-beta.42 → 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.
package/package.json
CHANGED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { AnalyticsPlugin } from 'analytics';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const TrackExperienceProperties: z.ZodObject<{
|
|
4
|
+
experience: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
audience: z.ZodDefault<z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
id: string;
|
|
10
|
+
}, {
|
|
11
|
+
id: string;
|
|
12
|
+
}>>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
id: string;
|
|
15
|
+
audience: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
}, {
|
|
19
|
+
audience?: {
|
|
20
|
+
id: string;
|
|
21
|
+
} | undefined;
|
|
22
|
+
id: string;
|
|
23
|
+
}>;
|
|
24
|
+
variant: z.ZodNumber;
|
|
25
|
+
component: z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
id: string;
|
|
29
|
+
}, {
|
|
30
|
+
id: string;
|
|
31
|
+
}>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
experience: {
|
|
34
|
+
id: string;
|
|
35
|
+
audience: {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
variant: number;
|
|
40
|
+
component: {
|
|
41
|
+
id: string;
|
|
42
|
+
};
|
|
43
|
+
}, {
|
|
44
|
+
experience: {
|
|
45
|
+
audience?: {
|
|
46
|
+
id: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
variant: number;
|
|
51
|
+
component: {
|
|
52
|
+
id: string;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
export declare type TrackExperienceProperties = z.infer<typeof TrackExperienceProperties>;
|
|
56
|
+
declare const TrackComponentProperties: z.ZodObject<{
|
|
57
|
+
variant: z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
id: string;
|
|
61
|
+
}, {
|
|
62
|
+
id: string;
|
|
63
|
+
}>;
|
|
64
|
+
audience: z.ZodObject<{
|
|
65
|
+
id: z.ZodString;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
id: string;
|
|
68
|
+
}, {
|
|
69
|
+
id: string;
|
|
70
|
+
}>;
|
|
71
|
+
isPersonalized: z.ZodBoolean;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
audience: {
|
|
74
|
+
id: string;
|
|
75
|
+
};
|
|
76
|
+
variant: {
|
|
77
|
+
id: string;
|
|
78
|
+
};
|
|
79
|
+
isPersonalized: boolean;
|
|
80
|
+
}, {
|
|
81
|
+
audience: {
|
|
82
|
+
id: string;
|
|
83
|
+
};
|
|
84
|
+
variant: {
|
|
85
|
+
id: string;
|
|
86
|
+
};
|
|
87
|
+
isPersonalized: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
export declare type TrackComponentProperties = z.infer<typeof TrackComponentProperties>;
|
|
90
|
+
declare const TrackPayload: z.ZodDiscriminatedUnion<"event", z.Primitive, z.ZodObject<{
|
|
91
|
+
event: z.ZodLiteral<"nt_experience">;
|
|
92
|
+
properties: z.ZodObject<{
|
|
93
|
+
experience: z.ZodObject<{
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
audience: z.ZodDefault<z.ZodObject<{
|
|
96
|
+
id: z.ZodString;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
id: string;
|
|
99
|
+
}, {
|
|
100
|
+
id: string;
|
|
101
|
+
}>>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
id: string;
|
|
104
|
+
audience: {
|
|
105
|
+
id: string;
|
|
106
|
+
};
|
|
107
|
+
}, {
|
|
108
|
+
audience?: {
|
|
109
|
+
id: string;
|
|
110
|
+
} | undefined;
|
|
111
|
+
id: string;
|
|
112
|
+
}>;
|
|
113
|
+
variant: z.ZodNumber;
|
|
114
|
+
component: z.ZodObject<{
|
|
115
|
+
id: z.ZodString;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
id: string;
|
|
118
|
+
}, {
|
|
119
|
+
id: string;
|
|
120
|
+
}>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
experience: {
|
|
123
|
+
id: string;
|
|
124
|
+
audience: {
|
|
125
|
+
id: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
variant: number;
|
|
129
|
+
component: {
|
|
130
|
+
id: string;
|
|
131
|
+
};
|
|
132
|
+
}, {
|
|
133
|
+
experience: {
|
|
134
|
+
audience?: {
|
|
135
|
+
id: string;
|
|
136
|
+
} | undefined;
|
|
137
|
+
id: string;
|
|
138
|
+
};
|
|
139
|
+
variant: number;
|
|
140
|
+
component: {
|
|
141
|
+
id: string;
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
event: "nt_experience";
|
|
146
|
+
properties: {
|
|
147
|
+
experience: {
|
|
148
|
+
id: string;
|
|
149
|
+
audience: {
|
|
150
|
+
id: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
variant: number;
|
|
154
|
+
component: {
|
|
155
|
+
id: string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
}, {
|
|
159
|
+
event: "nt_experience";
|
|
160
|
+
properties: {
|
|
161
|
+
experience: {
|
|
162
|
+
audience?: {
|
|
163
|
+
id: string;
|
|
164
|
+
} | undefined;
|
|
165
|
+
id: string;
|
|
166
|
+
};
|
|
167
|
+
variant: number;
|
|
168
|
+
component: {
|
|
169
|
+
id: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
}> | z.ZodObject<{
|
|
173
|
+
event: z.ZodLiteral<"hasSeenComponent">;
|
|
174
|
+
properties: z.ZodObject<{
|
|
175
|
+
variant: z.ZodObject<{
|
|
176
|
+
id: z.ZodString;
|
|
177
|
+
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
id: string;
|
|
179
|
+
}, {
|
|
180
|
+
id: string;
|
|
181
|
+
}>;
|
|
182
|
+
audience: z.ZodObject<{
|
|
183
|
+
id: z.ZodString;
|
|
184
|
+
}, "strip", z.ZodTypeAny, {
|
|
185
|
+
id: string;
|
|
186
|
+
}, {
|
|
187
|
+
id: string;
|
|
188
|
+
}>;
|
|
189
|
+
isPersonalized: z.ZodBoolean;
|
|
190
|
+
}, "strip", z.ZodTypeAny, {
|
|
191
|
+
audience: {
|
|
192
|
+
id: string;
|
|
193
|
+
};
|
|
194
|
+
variant: {
|
|
195
|
+
id: string;
|
|
196
|
+
};
|
|
197
|
+
isPersonalized: boolean;
|
|
198
|
+
}, {
|
|
199
|
+
audience: {
|
|
200
|
+
id: string;
|
|
201
|
+
};
|
|
202
|
+
variant: {
|
|
203
|
+
id: string;
|
|
204
|
+
};
|
|
205
|
+
isPersonalized: boolean;
|
|
206
|
+
}>;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
event: "hasSeenComponent";
|
|
209
|
+
properties: {
|
|
210
|
+
audience: {
|
|
211
|
+
id: string;
|
|
212
|
+
};
|
|
213
|
+
variant: {
|
|
214
|
+
id: string;
|
|
215
|
+
};
|
|
216
|
+
isPersonalized: boolean;
|
|
217
|
+
};
|
|
218
|
+
}, {
|
|
219
|
+
event: "hasSeenComponent";
|
|
220
|
+
properties: {
|
|
221
|
+
audience: {
|
|
222
|
+
id: string;
|
|
223
|
+
};
|
|
224
|
+
variant: {
|
|
225
|
+
id: string;
|
|
226
|
+
};
|
|
227
|
+
isPersonalized: boolean;
|
|
228
|
+
};
|
|
229
|
+
}>>;
|
|
230
|
+
declare type TrackPayload = z.infer<typeof TrackPayload>;
|
|
231
|
+
declare type TrackArgs = {
|
|
232
|
+
payload: TrackPayload;
|
|
233
|
+
};
|
|
234
|
+
export declare abstract class NinetailedAnalyticsPlugin implements AnalyticsPlugin {
|
|
235
|
+
[x: string]: unknown;
|
|
236
|
+
abstract readonly name: string;
|
|
237
|
+
protected abstract onTrackExperience(properties: TrackExperienceProperties): Promise<void>;
|
|
238
|
+
protected abstract onTrackComponent(properties: TrackComponentProperties): Promise<void>;
|
|
239
|
+
track(data: TrackArgs): void;
|
|
240
|
+
}
|
|
241
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NinetailedAnalyticsPlugin = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const TrackExperienceProperties = zod_1.z.object({
|
|
6
|
+
experience: zod_1.z.object({
|
|
7
|
+
id: zod_1.z.string(),
|
|
8
|
+
audience: zod_1.z.object({ id: zod_1.z.string() }).default({ id: 'ALL_VISITORS' }),
|
|
9
|
+
}),
|
|
10
|
+
variant: zod_1.z.number(),
|
|
11
|
+
component: zod_1.z.object({ id: zod_1.z.string() }),
|
|
12
|
+
});
|
|
13
|
+
const TrackComponentProperties = zod_1.z.object({
|
|
14
|
+
variant: zod_1.z.object({ id: zod_1.z.string() }),
|
|
15
|
+
audience: zod_1.z.object({
|
|
16
|
+
id: zod_1.z.string(),
|
|
17
|
+
}),
|
|
18
|
+
isPersonalized: zod_1.z.boolean(),
|
|
19
|
+
});
|
|
20
|
+
const TrackPayload = zod_1.z.discriminatedUnion('event', [
|
|
21
|
+
zod_1.z.object({
|
|
22
|
+
event: zod_1.z.literal('nt_experience'),
|
|
23
|
+
properties: TrackExperienceProperties,
|
|
24
|
+
}),
|
|
25
|
+
zod_1.z.object({
|
|
26
|
+
event: zod_1.z.literal('hasSeenComponent'),
|
|
27
|
+
properties: TrackComponentProperties,
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
30
|
+
class NinetailedAnalyticsPlugin {
|
|
31
|
+
track(data) {
|
|
32
|
+
const payload = TrackPayload.parse(data.payload);
|
|
33
|
+
if (payload.event === 'nt_experience') {
|
|
34
|
+
this.onTrackExperience(payload.properties);
|
|
35
|
+
}
|
|
36
|
+
if (payload.event === 'hasSeenComponent') {
|
|
37
|
+
this.onTrackComponent(payload.properties);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.NinetailedAnalyticsPlugin = NinetailedAnalyticsPlugin;
|
|
42
|
+
//# sourceMappingURL=NinetailedAnalyticsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NinetailedAnalyticsPlugin.js","sourceRoot":"","sources":["../../../../packages/google-tagmanager/src/NinetailedAnalyticsPlugin.ts"],"names":[],"mappings":";;;AACA,6BAAwB;AAExB,MAAM,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;QACnB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;QACd,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,EAAC,EAAE,EAAE,cAAc,EAAC,CAAC;KACrE,CAAC;IACF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,SAAS,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;CACxC,CAAC,CAAC;AAGH,MAAM,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IACrC,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC;QACjB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;KACf,CAAC;IACF,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE;CAC5B,CAAC,CAAC;AAGH,MAAM,YAAY,GAAG,OAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE;IACjD,OAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,OAAC,CAAC,OAAO,CAAC,eAAe,CAAC;QACjC,UAAU,EAAE,yBAAyB;KACtC,CAAC;IACF,OAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,OAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACpC,UAAU,EAAE,wBAAwB;KACrC,CAAC;CACH,CAAC,CAAC;AAOH,MAAsB,yBAAyB;IAQtC,KAAK,CAAC,IAAe;QAC1B,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEjD,IAAI,OAAO,CAAC,KAAK,KAAK,eAAe,EAAE;YACnC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC9C;QAED,IAAI,OAAO,CAAC,KAAK,KAAK,kBAAkB,EAAE;YACtC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC7C;IACH,CAAC;CACF;AAnBD,8DAmBC"}
|
package/src/plugin.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// import template from 'lodash/template';
|
|
3
|
+
// import {
|
|
4
|
+
// NinetailedAnalyticsPlugin,
|
|
5
|
+
// TrackExperienceProperties,
|
|
6
|
+
// } from './NinetailedAnalyticsPlugin';
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.NinetailedGoogleTagmanagerPlugin = void 0;
|
|
4
9
|
const tslib_1 = require("tslib");
|
package/src/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../packages/google-tagmanager/src/plugin.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../packages/google-tagmanager/src/plugin.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,WAAW;AACX,+BAA+B;AAC/B,+BAA+B;AAC/B,wCAAwC;;;;AAwExC,4EAAuC;AAIvC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AA0B9C,MAAM,gBAAgB,GAAG;IACvB,WAAW,EAAE,iBAAiB;CAC/B,CAAC;AAEK,MAAM,gCAAgC,GAAG,CAC9C,UAAmD,EAAE,EACpC,EAAE;IACnB,MAAM,sBAAsB,GAAG,CAAC,OAAgC,EAAE,EAAE;;QAClE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QAEtD,MAAM,cAAc,GAAG,IAAA,kBAAQ,EAC7B,OAAO,CAAC,cAAc,IAAI,qBAAqB,EAC/C,gBAAgB,CACjB,CAAC;QACF,MAAM,aAAa,GAAG,IAAA,kBAAQ,EAC5B,OAAO,CAAC,aAAa,IAAI,4CAA4C,EACrE,gBAAgB,CACjB,CAAC;QAEF,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChE,MAAM,KAAK,GAAG,aAAa,CAAC;YAC1B,SAAS,EAAE,OAAO;YAClB,QAAQ;YACR,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;SAC3D,CAAC,CAAC;QAEH,MAAA,MAAM,CAAC,SAAS,0CAAE,IAAI,CAAC;YACrB,KAAK,EAAE,MAAM;YACb,UAAU,EAAE;gBACV,QAAQ,EAAE,YAAY;gBACtB,KAAK;gB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