@shware/analytics 8.15.1 → 9.0.0
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/README.md +28 -4
- package/dist/attribution/classify.cjs +17 -5
- package/dist/attribution/classify.cjs.map +1 -1
- package/dist/attribution/classify.d.cts +2 -1
- package/dist/attribution/classify.d.cts.map +1 -1
- package/dist/attribution/classify.d.mts +2 -1
- package/dist/attribution/classify.d.mts.map +1 -1
- package/dist/attribution/classify.mjs +17 -5
- package/dist/attribution/classify.mjs.map +1 -1
- package/dist/attribution/vocabulary.cjs +99 -19
- package/dist/attribution/vocabulary.cjs.map +1 -1
- package/dist/attribution/vocabulary.d.cts +15 -4
- package/dist/attribution/vocabulary.d.cts.map +1 -1
- package/dist/attribution/vocabulary.d.mts +15 -4
- package/dist/attribution/vocabulary.d.mts.map +1 -1
- package/dist/attribution/vocabulary.mjs +99 -19
- package/dist/attribution/vocabulary.mjs.map +1 -1
- package/dist/click-id/index.cjs +24 -6
- package/dist/click-id/index.cjs.map +1 -1
- package/dist/click-id/index.d.cts +14 -3
- package/dist/click-id/index.d.cts.map +1 -1
- package/dist/click-id/index.d.mts +14 -3
- package/dist/click-id/index.d.mts.map +1 -1
- package/dist/click-id/index.mjs +23 -7
- package/dist/click-id/index.mjs.map +1 -1
- package/dist/schema/index.cjs +27 -9
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +126 -54
- package/dist/schema/index.d.cts.map +1 -1
- package/dist/schema/index.d.mts +126 -54
- package/dist/schema/index.d.mts.map +1 -1
- package/dist/schema/index.mjs +27 -9
- package/dist/schema/index.mjs.map +1 -1
- package/dist/server/click-ids.cjs +93 -0
- package/dist/server/click-ids.cjs.map +1 -0
- package/dist/server/click-ids.d.cts +40 -0
- package/dist/server/click-ids.d.cts.map +1 -0
- package/dist/server/click-ids.d.mts +40 -0
- package/dist/server/click-ids.d.mts.map +1 -0
- package/dist/server/click-ids.mjs +85 -0
- package/dist/server/click-ids.mjs.map +1 -0
- package/dist/server/google-data-manager.cjs +2 -1
- package/dist/server/google-data-manager.cjs.map +1 -1
- package/dist/server/google-data-manager.d.cts.map +1 -1
- package/dist/server/google-data-manager.d.mts.map +1 -1
- package/dist/server/google-data-manager.mjs +2 -1
- package/dist/server/google-data-manager.mjs.map +1 -1
- package/dist/server/linkedin-conversions-api.cjs +9 -4
- package/dist/server/linkedin-conversions-api.cjs.map +1 -1
- package/dist/server/linkedin-conversions-api.d.cts.map +1 -1
- package/dist/server/linkedin-conversions-api.d.mts.map +1 -1
- package/dist/server/linkedin-conversions-api.mjs +9 -4
- package/dist/server/linkedin-conversions-api.mjs.map +1 -1
- package/dist/server/meta-capi.cjs +5 -4
- package/dist/server/meta-capi.cjs.map +1 -1
- package/dist/server/meta-capi.mjs +5 -4
- package/dist/server/meta-capi.mjs.map +1 -1
- package/dist/server/meta-conversions-api.cjs +5 -4
- package/dist/server/meta-conversions-api.cjs.map +1 -1
- package/dist/server/meta-conversions-api.d.cts.map +1 -1
- package/dist/server/meta-conversions-api.d.mts.map +1 -1
- package/dist/server/meta-conversions-api.mjs +5 -4
- package/dist/server/meta-conversions-api.mjs.map +1 -1
- package/dist/server/microsoft-conversions-api.cjs +3 -1
- package/dist/server/microsoft-conversions-api.cjs.map +1 -1
- package/dist/server/microsoft-conversions-api.d.cts.map +1 -1
- package/dist/server/microsoft-conversions-api.d.mts.map +1 -1
- package/dist/server/microsoft-conversions-api.mjs +3 -1
- package/dist/server/microsoft-conversions-api.mjs.map +1 -1
- package/dist/server/openai-conversions-api.cjs +33 -10
- package/dist/server/openai-conversions-api.cjs.map +1 -1
- package/dist/server/openai-conversions-api.d.cts +19 -8
- package/dist/server/openai-conversions-api.d.cts.map +1 -1
- package/dist/server/openai-conversions-api.d.mts +19 -8
- package/dist/server/openai-conversions-api.d.mts.map +1 -1
- package/dist/server/openai-conversions-api.mjs +33 -10
- package/dist/server/openai-conversions-api.mjs.map +1 -1
- package/dist/server/reddit-conversions-api.cjs +3 -2
- package/dist/server/reddit-conversions-api.cjs.map +1 -1
- package/dist/server/reddit-conversions-api.d.cts.map +1 -1
- package/dist/server/reddit-conversions-api.d.mts.map +1 -1
- package/dist/server/reddit-conversions-api.mjs +3 -2
- package/dist/server/reddit-conversions-api.mjs.map +1 -1
- package/dist/track/types.d.cts +50 -16
- package/dist/track/types.d.cts.map +1 -1
- package/dist/track/types.d.mts +50 -16
- package/dist/track/types.d.mts.map +1 -1
- package/dist/web/index.cjs +19 -11
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts.map +1 -1
- package/dist/web/index.d.mts.map +1 -1
- package/dist/web/index.mjs +19 -11
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/page-key.cjs +4 -2
- package/dist/web/page-key.cjs.map +1 -1
- package/dist/web/page-key.d.cts.map +1 -1
- package/dist/web/page-key.d.mts.map +1 -1
- package/dist/web/page-key.mjs +4 -2
- package/dist/web/page-key.mjs.map +1 -1
- package/package.json +1 -1
package/dist/schema/index.d.mts
CHANGED
|
@@ -28,8 +28,6 @@ export declare const tagsSchema: z.ZodMiniObject<{
|
|
|
28
28
|
source_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
29
29
|
advertising_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
30
30
|
install_referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
31
|
-
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
32
|
-
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
33
31
|
fbclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
34
32
|
ad_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
35
33
|
ad_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -38,22 +36,36 @@ export declare const tagsSchema: z.ZodMiniObject<{
|
|
|
38
36
|
campaign_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
39
37
|
campaign_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
40
38
|
placement: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
39
|
+
_fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
40
|
+
_fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
41
|
+
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
42
|
+
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
|
+
rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
41
44
|
gclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
42
45
|
gclsrc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
43
46
|
gad_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
44
47
|
gad_campaignid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
49
|
+
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
47
50
|
dclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
_gcl_aw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
52
|
+
_gcl_gb: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
50
53
|
msclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
51
|
-
|
|
54
|
+
_uetmsclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
55
|
+
rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
56
|
+
_rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
57
|
+
_rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
58
|
+
li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
59
|
+
_li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
60
|
+
oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
61
|
+
__oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
62
|
+
__obref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
63
|
+
ko_click_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
64
|
+
ScCid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
52
65
|
ttclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
53
66
|
twclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
54
|
-
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
55
|
-
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
56
67
|
yclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
68
|
+
epik: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
57
69
|
utm_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
58
70
|
utm_medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
59
71
|
utm_campaign: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -109,8 +121,6 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
|
|
|
109
121
|
source_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
110
122
|
advertising_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
111
123
|
install_referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
112
|
-
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
113
|
-
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
114
124
|
fbclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
115
125
|
ad_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
116
126
|
ad_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -119,22 +129,36 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
|
|
|
119
129
|
campaign_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
120
130
|
campaign_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
121
131
|
placement: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
132
|
+
_fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
133
|
+
_fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
134
|
+
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
135
|
+
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
136
|
+
rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
122
137
|
gclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
123
138
|
gclsrc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
124
139
|
gad_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
125
140
|
gad_campaignid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
142
|
+
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
128
143
|
dclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
129
|
-
|
|
130
|
-
|
|
144
|
+
_gcl_aw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
145
|
+
_gcl_gb: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
131
146
|
msclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
132
|
-
|
|
147
|
+
_uetmsclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
148
|
+
rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
149
|
+
_rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
150
|
+
_rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
151
|
+
li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
152
|
+
_li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
153
|
+
oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
154
|
+
__oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
155
|
+
__obref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
156
|
+
ko_click_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
157
|
+
ScCid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
133
158
|
ttclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
134
159
|
twclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
135
|
-
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
136
|
-
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
137
160
|
yclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
161
|
+
epik: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
138
162
|
utm_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
139
163
|
utm_medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
140
164
|
utm_campaign: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -179,8 +203,6 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
|
|
|
179
203
|
source_url?: string | undefined;
|
|
180
204
|
advertising_id?: string | undefined;
|
|
181
205
|
install_referrer?: string | undefined;
|
|
182
|
-
fbc?: string | undefined;
|
|
183
|
-
fbp?: string | undefined;
|
|
184
206
|
fbclid?: string | undefined;
|
|
185
207
|
ad_id?: string | undefined;
|
|
186
208
|
ad_name?: string | undefined;
|
|
@@ -189,22 +211,36 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
|
|
|
189
211
|
campaign_id?: string | undefined;
|
|
190
212
|
campaign_name?: string | undefined;
|
|
191
213
|
placement?: string | undefined;
|
|
214
|
+
_fbc?: string | undefined;
|
|
215
|
+
_fbp?: string | undefined;
|
|
216
|
+
fbc?: string | undefined;
|
|
217
|
+
fbp?: string | undefined;
|
|
218
|
+
rdt_uuid?: string | undefined;
|
|
192
219
|
gclid?: string | undefined;
|
|
193
220
|
gclsrc?: string | undefined;
|
|
194
221
|
gad_source?: string | undefined;
|
|
195
222
|
gad_campaignid?: string | undefined;
|
|
196
|
-
|
|
197
|
-
|
|
223
|
+
wbraid?: string | undefined;
|
|
224
|
+
gbraid?: string | undefined;
|
|
198
225
|
dclid?: string | undefined;
|
|
199
|
-
|
|
200
|
-
|
|
226
|
+
_gcl_aw?: string | undefined;
|
|
227
|
+
_gcl_gb?: string | undefined;
|
|
201
228
|
msclkid?: string | undefined;
|
|
202
|
-
|
|
229
|
+
_uetmsclkid?: string | undefined;
|
|
230
|
+
rdt_cid?: string | undefined;
|
|
231
|
+
_rdt_cid?: string | undefined;
|
|
232
|
+
_rdt_uuid?: string | undefined;
|
|
233
|
+
li_fat_id?: string | undefined;
|
|
234
|
+
_li_fat_id?: string | undefined;
|
|
235
|
+
oppref?: string | undefined;
|
|
236
|
+
__oppref?: string | undefined;
|
|
237
|
+
__obref?: string | undefined;
|
|
238
|
+
ko_click_id?: string | undefined;
|
|
239
|
+
ScCid?: string | undefined;
|
|
203
240
|
ttclid?: string | undefined;
|
|
204
241
|
twclid?: string | undefined;
|
|
205
|
-
wbraid?: string | undefined;
|
|
206
|
-
gbraid?: string | undefined;
|
|
207
242
|
yclid?: string | undefined;
|
|
243
|
+
epik?: string | undefined;
|
|
208
244
|
utm_source?: string | undefined;
|
|
209
245
|
utm_medium?: string | undefined;
|
|
210
246
|
utm_campaign?: string | undefined;
|
|
@@ -249,8 +285,6 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
|
|
|
249
285
|
source_url?: string | undefined;
|
|
250
286
|
advertising_id?: string | undefined;
|
|
251
287
|
install_referrer?: string | undefined;
|
|
252
|
-
fbc?: string | undefined;
|
|
253
|
-
fbp?: string | undefined;
|
|
254
288
|
fbclid?: string | undefined;
|
|
255
289
|
ad_id?: string | undefined;
|
|
256
290
|
ad_name?: string | undefined;
|
|
@@ -259,22 +293,36 @@ export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodM
|
|
|
259
293
|
campaign_id?: string | undefined;
|
|
260
294
|
campaign_name?: string | undefined;
|
|
261
295
|
placement?: string | undefined;
|
|
296
|
+
_fbc?: string | undefined;
|
|
297
|
+
_fbp?: string | undefined;
|
|
298
|
+
fbc?: string | undefined;
|
|
299
|
+
fbp?: string | undefined;
|
|
300
|
+
rdt_uuid?: string | undefined;
|
|
262
301
|
gclid?: string | undefined;
|
|
263
302
|
gclsrc?: string | undefined;
|
|
264
303
|
gad_source?: string | undefined;
|
|
265
304
|
gad_campaignid?: string | undefined;
|
|
266
|
-
|
|
267
|
-
|
|
305
|
+
wbraid?: string | undefined;
|
|
306
|
+
gbraid?: string | undefined;
|
|
268
307
|
dclid?: string | undefined;
|
|
269
|
-
|
|
270
|
-
|
|
308
|
+
_gcl_aw?: string | undefined;
|
|
309
|
+
_gcl_gb?: string | undefined;
|
|
271
310
|
msclkid?: string | undefined;
|
|
272
|
-
|
|
311
|
+
_uetmsclkid?: string | undefined;
|
|
312
|
+
rdt_cid?: string | undefined;
|
|
313
|
+
_rdt_cid?: string | undefined;
|
|
314
|
+
_rdt_uuid?: string | undefined;
|
|
315
|
+
li_fat_id?: string | undefined;
|
|
316
|
+
_li_fat_id?: string | undefined;
|
|
317
|
+
oppref?: string | undefined;
|
|
318
|
+
__oppref?: string | undefined;
|
|
319
|
+
__obref?: string | undefined;
|
|
320
|
+
ko_click_id?: string | undefined;
|
|
321
|
+
ScCid?: string | undefined;
|
|
273
322
|
ttclid?: string | undefined;
|
|
274
323
|
twclid?: string | undefined;
|
|
275
|
-
wbraid?: string | undefined;
|
|
276
|
-
gbraid?: string | undefined;
|
|
277
324
|
yclid?: string | undefined;
|
|
325
|
+
epik?: string | undefined;
|
|
278
326
|
utm_source?: string | undefined;
|
|
279
327
|
utm_medium?: string | undefined;
|
|
280
328
|
utm_campaign?: string | undefined;
|
|
@@ -328,8 +376,6 @@ export declare const createVisitorSchema: z.ZodMiniObject<{
|
|
|
328
376
|
source_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
329
377
|
advertising_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
330
378
|
install_referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
331
|
-
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
332
|
-
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
333
379
|
fbclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
334
380
|
ad_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
335
381
|
ad_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -338,22 +384,36 @@ export declare const createVisitorSchema: z.ZodMiniObject<{
|
|
|
338
384
|
campaign_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
339
385
|
campaign_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
340
386
|
placement: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
387
|
+
_fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
388
|
+
_fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
389
|
+
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
390
|
+
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
391
|
+
rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
341
392
|
gclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
342
393
|
gclsrc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
343
394
|
gad_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
344
395
|
gad_campaignid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
345
|
-
|
|
346
|
-
|
|
396
|
+
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
397
|
+
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
347
398
|
dclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
348
|
-
|
|
349
|
-
|
|
399
|
+
_gcl_aw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
400
|
+
_gcl_gb: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
350
401
|
msclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
351
|
-
|
|
402
|
+
_uetmsclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
403
|
+
rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
404
|
+
_rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
405
|
+
_rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
406
|
+
li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
407
|
+
_li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
408
|
+
oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
409
|
+
__oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
410
|
+
__obref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
411
|
+
ko_click_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
412
|
+
ScCid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
352
413
|
ttclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
353
414
|
twclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
354
|
-
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
355
|
-
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
356
415
|
yclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
416
|
+
epik: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
357
417
|
utm_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
358
418
|
utm_medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
359
419
|
utm_campaign: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -446,8 +506,6 @@ export declare const updateVisitorSchema: z.ZodMiniObject<{
|
|
|
446
506
|
source_url: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
447
507
|
advertising_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
448
508
|
install_referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
449
|
-
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
450
|
-
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
451
509
|
fbclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
452
510
|
ad_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
453
511
|
ad_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -456,22 +514,36 @@ export declare const updateVisitorSchema: z.ZodMiniObject<{
|
|
|
456
514
|
campaign_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
457
515
|
campaign_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
458
516
|
placement: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
517
|
+
_fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
518
|
+
_fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
519
|
+
fbc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
520
|
+
fbp: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
521
|
+
rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
459
522
|
gclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
460
523
|
gclsrc: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
461
524
|
gad_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
462
525
|
gad_campaignid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
463
|
-
|
|
464
|
-
|
|
526
|
+
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
527
|
+
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
465
528
|
dclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
466
|
-
|
|
467
|
-
|
|
529
|
+
_gcl_aw: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
530
|
+
_gcl_gb: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
468
531
|
msclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
469
|
-
|
|
532
|
+
_uetmsclkid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
533
|
+
rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
534
|
+
_rdt_cid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
535
|
+
_rdt_uuid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
536
|
+
li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
537
|
+
_li_fat_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
538
|
+
oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
539
|
+
__oppref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
540
|
+
__obref: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
541
|
+
ko_click_id: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
542
|
+
ScCid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
470
543
|
ttclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
471
544
|
twclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
472
|
-
wbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
473
|
-
gbraid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
474
545
|
yclid: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
546
|
+
epik: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
475
547
|
utm_source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
476
548
|
utm_medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
477
549
|
utm_campaign: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAmFa;qBAUA;qBAEA,YAAU,EAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAmFa;qBAUA;qBAEA,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGrB,EAAA,KAAA;qBAEW,kBAAgB,EAAA,gBAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,aAAA,EAAA,YAAA,EAAA,aAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,gBAAA,EAAA,iBAAA,kDAAA,qDAAA,EAAA,iBAAA,oDAAA,yDAAA,EAAA,iBAAA,2CAAA,4DAAA,2CAAA;qBA4ChB,wBAAsB,EAAA,YAAA,EAAA,aAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgBtB,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM9B,EAAA,KAAA;;;;;;;;;;;qBA6BW,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;GAIjC,EAAA,KAAA;qBAEW,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK9B,EAAA,KAAA;qBAEW,sBAAoB,EAAA;;;;GAI/B,EAAA,KAAA;;;;;qBAWW,kBAAgB,EAAA;;;;;;;;;;;GA+C3B,EAAA,KAAA;YAEU,sBAAsB,EAAE,cAAc;YACtC,oBAAoB,EAAE,cAAc;YACpC,gBAAgB,EAAE,cAAc;YAChC,mBAAmB,EAAE,cAAc;YACnC,sBAAsB,EAAE,cAAc;YACtC,mBAAmB,EAAE,cAAc"}
|
package/dist/schema/index.mjs
CHANGED
|
@@ -86,8 +86,6 @@ const tagsSchema = object({
|
|
|
86
86
|
source_url: optional(string()),
|
|
87
87
|
advertising_id: optional(string()),
|
|
88
88
|
install_referrer: optional(string()),
|
|
89
|
-
fbc: optional(string()),
|
|
90
|
-
fbp: optional(string()),
|
|
91
89
|
fbclid: optional(string()),
|
|
92
90
|
ad_id: optional(string()),
|
|
93
91
|
ad_name: optional(string()),
|
|
@@ -96,22 +94,42 @@ const tagsSchema = object({
|
|
|
96
94
|
campaign_id: optional(string()),
|
|
97
95
|
campaign_name: optional(string()),
|
|
98
96
|
placement: optional(string()),
|
|
97
|
+
_fbc: optional(string()),
|
|
98
|
+
_fbp: optional(string()),
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.
|
|
101
|
+
* Accepted so that conversions from clients still on an older SDK keep their match keys; the
|
|
102
|
+
* senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are
|
|
103
|
+
* gone.
|
|
104
|
+
*/
|
|
105
|
+
fbc: optional(string()),
|
|
106
|
+
fbp: optional(string()),
|
|
107
|
+
rdt_uuid: optional(string()),
|
|
99
108
|
gclid: optional(string()),
|
|
100
109
|
gclsrc: optional(string()),
|
|
101
110
|
gad_source: optional(string()),
|
|
102
111
|
gad_campaignid: optional(string()),
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
wbraid: optional(string()),
|
|
113
|
+
gbraid: optional(string()),
|
|
105
114
|
dclid: optional(string()),
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
_gcl_aw: optional(string()),
|
|
116
|
+
_gcl_gb: optional(string()),
|
|
108
117
|
msclkid: optional(string()),
|
|
109
|
-
|
|
118
|
+
_uetmsclkid: optional(string()),
|
|
119
|
+
rdt_cid: optional(string()),
|
|
120
|
+
_rdt_cid: optional(string()),
|
|
121
|
+
_rdt_uuid: optional(string()),
|
|
122
|
+
li_fat_id: optional(string()),
|
|
123
|
+
_li_fat_id: optional(string()),
|
|
124
|
+
oppref: optional(string()),
|
|
125
|
+
__oppref: optional(string()),
|
|
126
|
+
__obref: optional(string()),
|
|
127
|
+
ko_click_id: optional(string()),
|
|
128
|
+
ScCid: optional(string()),
|
|
110
129
|
ttclid: optional(string()),
|
|
111
130
|
twclid: optional(string()),
|
|
112
|
-
wbraid: optional(string()),
|
|
113
|
-
gbraid: optional(string()),
|
|
114
131
|
yclid: optional(string()),
|
|
132
|
+
epik: optional(string()),
|
|
115
133
|
utm_source: optional(string()),
|
|
116
134
|
utm_medium: optional(string()),
|
|
117
135
|
utm_campaign: optional(string()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n webdriver: optional(boolean()),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n page_location: optional(string()),\n page_referrer: optional(string()),\n page_title: optional(string()),\n page_load_id: optional(string()),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n source_url: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Meta Ads\n fbc: optional(string()),\n fbp: optional(string()),\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n // Reddit ads\n rdt_cid: optional(string()),\n rdt_uuid: optional(string()),\n // click ids\n dclid: optional(string()),\n ko_click_id: optional(string()),\n li_fat_id: optional(string()),\n msclkid: optional(string()),\n sccid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n wbraid: optional(string()),\n gbraid: optional(string()),\n yclid: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n);\n\n/**\n * How far an event's time may be from the server's before the client clock it was stamped with is\n * taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a\n * session_start held back after a failed batch — by hours, not days; a phone set to another year\n * writes its sessions into that year.\n */\nconst MAX_CLOCK_SKEW = 24 * 60 * 60 * 1000;\n\n/**\n * Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only\n * the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch\n * along: they move together by their own latest one — the wrong clock at sending — keeping their\n * order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock\n * at all and takes the server's time. Corrected rather than rejected, for the same reason values\n * are truncated: a wrong clock should cost the event its time, not the batch its events.\n */\nfunction alignClock<T extends { timestamp: string }>(events: T[], now = Date.now()): T[] {\n const within = (time: number) => Math.abs(now - time) <= MAX_CLOCK_SKEW;\n const times = events.map((event) => Date.parse(event.timestamp));\n const wrong = times.filter((time) => !within(time));\n if (wrong.length === 0) return events;\n const offset = now - Math.max(...wrong);\n return events.map((event, i) => {\n if (within(times[i])) return event;\n const shifted = times[i] + offset;\n return { ...event, timestamp: new Date(within(shifted) ? shifted : now).toISOString() };\n });\n}\n\nexport const createTrackEventSchema = pipe(\n array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n ).check(minLength(1), maxLength(100)),\n transform((events) => alignClock(events))\n);\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA4BA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;;;;;;AAQvB,MAAM,eAAe,KACnB,OAAO,GACP,WAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;;;AAYA,SAAS,eAAkB,MAA4C;CACrE,MAAM,SAA4B,CAAC;CACnC,IAAI,QAAQ;CACZ,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,IAAI,GAAG;EAClD,IAAI,SAAS,gBAAgB;EAC7B,MAAM,MAAM,OAAO,KAAK;EACxB,IAAI,CAAC,OAAO,IAAI,SAAS,gBAAgB;EACzC,OAAO,OAAO;EACd;CACF;CACA,OAAO;AACT;;;;;;AAOA,MAAM,YAAY;AAElB,MAAM,QAAQ,KACZ,MACE,KACE,OAAO,OAAO,GAAG,MAAM;CAAC;CAAc,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CAAC,GACpE,UAAU,cAAc,CAC1B,CACF,GACA,WAAW,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC,CAC9C;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,mBAAmB,CAAC,eAAe,YAAY;AAE5D,MAAa,aAAa,OAAO;CAC/B,IAAI,SAAS,OAAO,CAAC;CACrB,SAAS,SAAS,OAAO,CAAC;CAC1B,YAAY,SAAS,OAAO,CAAC;CAC7B,SAAS,SAAS,OAAO,CAAC;CAC1B,cAAc,SAAS,OAAO,CAAC;CAC/B,iBAAiB,SAAS,OAAO,CAAC;CAClC,QAAQ,SAAS,OAAO,CAAC;CACzB,WAAW,SAAS,OAAO,CAAC,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC;CACvE,aAAa,SAA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AAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n webdriver: optional(boolean()),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n page_location: optional(string()),\n page_referrer: optional(string()),\n page_title: optional(string()),\n page_load_id: optional(string()),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n source_url: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Ad click ids (URL parameters) and ad platform cookies (underscore names); see AdvertisingInfo.\n // Meta Ads\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n _fbc: optional(string()),\n _fbp: optional(string()),\n /**\n * @deprecated `fbc` / `fbp` / `rdt_uuid` were renamed to `_fbc` / `_fbp` / `_rdt_uuid` in 9.0.0.\n * Accepted so that conversions from clients still on an older SDK keep their match keys; the\n * senders read them only as a fallback (`server/click-ids.ts`). Remove once those clients are\n * gone.\n */\n fbc: optional(string()),\n fbp: optional(string()),\n rdt_uuid: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n wbraid: optional(string()),\n gbraid: optional(string()),\n dclid: optional(string()),\n _gcl_aw: optional(string()),\n _gcl_gb: optional(string()),\n // Microsoft Ads\n msclkid: optional(string()),\n _uetmsclkid: optional(string()),\n // Reddit Ads\n rdt_cid: optional(string()),\n _rdt_cid: optional(string()),\n _rdt_uuid: optional(string()),\n // LinkedIn Ads\n li_fat_id: optional(string()),\n _li_fat_id: optional(string()),\n // OpenAI Ads\n oppref: optional(string()),\n __oppref: optional(string()),\n __obref: optional(string()),\n // other click ids\n ko_click_id: optional(string()),\n ScCid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n yclid: optional(string()),\n epik: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n);\n\n/**\n * How far an event's time may be from the server's before the client clock it was stamped with is\n * taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a\n * session_start held back after a failed batch — by hours, not days; a phone set to another year\n * writes its sessions into that year.\n */\nconst MAX_CLOCK_SKEW = 24 * 60 * 60 * 1000;\n\n/**\n * Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only\n * the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch\n * along: they move together by their own latest one — the wrong clock at sending — keeping their\n * order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock\n * at all and takes the server's time. Corrected rather than rejected, for the same reason values\n * are truncated: a wrong clock should cost the event its time, not the batch its events.\n */\nfunction alignClock<T extends { timestamp: string }>(events: T[], now = Date.now()): T[] {\n const within = (time: number) => Math.abs(now - time) <= MAX_CLOCK_SKEW;\n const times = events.map((event) => Date.parse(event.timestamp));\n const wrong = times.filter((time) => !within(time));\n if (wrong.length === 0) return events;\n const offset = now - Math.max(...wrong);\n return events.map((event, i) => {\n if (within(times[i])) return event;\n const shifted = times[i] + offset;\n return { ...event, timestamp: new Date(within(shifted) ? shifted : now).toISOString() };\n });\n}\n\nexport const createTrackEventSchema = pipe(\n array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n ).check(minLength(1), maxLength(100)),\n transform((events) => alignClock(events))\n);\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA4BA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;;;;;;AAQvB,MAAM,eAAe,KACnB,OAAO,GACP,WAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;;;AAYA,SAAS,eAAkB,MAA4C;CACrE,MAAM,SAA4B,CAAC;CAC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mB,OAAO;;CAErC,KAAK,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_click_id_index = require("../click-id/index.cjs");
|
|
3
|
+
//#region src/server/click-ids.ts
|
|
4
|
+
/**
|
|
5
|
+
* The click id each conversion sender passes on, resolved from an event's tags.
|
|
6
|
+
*
|
|
7
|
+
* The tags keep a URL parameter and the cookie that persists it apart (`gclid` / `_gcl_aw`, see
|
|
8
|
+
* `AdvertisingInfo`). The URL parameter wins: the two only coexist on the landing page, where the
|
|
9
|
+
* parameter is this very click while the cookie may still hold an earlier one — the pixel that
|
|
10
|
+
* rewrites it can run after this SDK read it. On every later page and visit the URL carries
|
|
11
|
+
* nothing and the cookie is what remains of the click.
|
|
12
|
+
*
|
|
13
|
+
* Clients older than 9.0.0 send `fbc` / `fbp` / `rdt_uuid` for the cookies (and may have filled
|
|
14
|
+
* `gclid`, `wbraid`, `msclkid`, `rdt_cid` and `li_fat_id` from them), so those are still read
|
|
15
|
+
* as a fallback. Transitional: drop them here and in `tagsSchema` and `AdvertisingInfo` once no
|
|
16
|
+
* client sends them.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Meta's `fbc`: built from this page's `fbclid`, else the `_fbc` cookie. One exception on the
|
|
20
|
+
* landing page: a cookie opened by that same `fbclid` is sent as it is, for its creationTime —
|
|
21
|
+
* `resolveClickIdCookies` sets it on the landing document, before any event of the page.
|
|
22
|
+
*/
|
|
23
|
+
function metaFbc(tags, eventTimeMs) {
|
|
24
|
+
const cookie = tags._fbc ?? tags.fbc;
|
|
25
|
+
if (tags.fbclid) {
|
|
26
|
+
if (require_click_id_index.parseFbc(cookie)?.fbclid === tags.fbclid) return cookie;
|
|
27
|
+
return require_click_id_index.formatFbc(tags.fbclid, eventTimeMs);
|
|
28
|
+
}
|
|
29
|
+
return cookie;
|
|
30
|
+
}
|
|
31
|
+
/** Meta's `fbp`: the pixel's browser id, a cookie only. */
|
|
32
|
+
function metaFbp(tags) {
|
|
33
|
+
return tags._fbp ?? tags.fbp;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Google Ads' click ids, from the URL when it carries any of them, else from gtag's cookies.
|
|
37
|
+
* All or nothing rather than one by one: the sender picks gclid over gbraid / wbraid, so a
|
|
38
|
+
* landing URL with a fresh gbraid next to the `_gcl_aw` of an earlier click would otherwise send
|
|
39
|
+
* the earlier click. gbraid is an app-to-web id and never kept in a cookie. A gclid that
|
|
40
|
+
* `gclsrc` says is Search Ads 360's is not a Google Ads click and is left out, as gtag leaves it
|
|
41
|
+
* out of `_gcl_aw`.
|
|
42
|
+
*/
|
|
43
|
+
function googleClickIds(tags) {
|
|
44
|
+
const gclid = require_click_id_index.isGoogleAdsGclid(tags.gclsrc) ? tags.gclid : void 0;
|
|
45
|
+
const { gbraid, wbraid } = tags;
|
|
46
|
+
if (gclid || gbraid || wbraid) return {
|
|
47
|
+
gclid,
|
|
48
|
+
gbraid,
|
|
49
|
+
wbraid
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
gclid: require_click_id_index.parseGcl(tags._gcl_aw)?.clickId,
|
|
53
|
+
gbraid: void 0,
|
|
54
|
+
wbraid: require_click_id_index.parseGcl(tags._gcl_gb)?.clickId
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Microsoft Ads' click id, in the 32-hex form of the URL and the cookie. A URL value in any other
|
|
59
|
+
* shape is not one (the API drops it), so it does not hide the cookie's.
|
|
60
|
+
*/
|
|
61
|
+
function microsoftMsclkid(tags) {
|
|
62
|
+
const url = tags.msclkid?.trim();
|
|
63
|
+
return require_click_id_index.isMsclkid(url) ? url : require_click_id_index.parseUetMsclkid(tags._uetmsclkid);
|
|
64
|
+
}
|
|
65
|
+
function redditClickId(tags) {
|
|
66
|
+
return tags.rdt_cid ?? tags._rdt_cid;
|
|
67
|
+
}
|
|
68
|
+
/** The Reddit pixel's browser id, a cookie only. */
|
|
69
|
+
function redditUuid(tags) {
|
|
70
|
+
return tags._rdt_uuid ?? tags.rdt_uuid;
|
|
71
|
+
}
|
|
72
|
+
function linkedinFatId(tags) {
|
|
73
|
+
return tags.li_fat_id ?? tags._li_fat_id;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* OpenAI's `oppref`: the pixel captures it from the landing URL and keeps it in `__oppref` for
|
|
77
|
+
* the later pages, and "the API does not capture `oppref` for you".
|
|
78
|
+
* ref: https://developers.openai.com/ads/measurement-pixel#cookie-expiry
|
|
79
|
+
*/
|
|
80
|
+
function openaiOppref(tags) {
|
|
81
|
+
return tags.oppref ?? tags.__oppref;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.googleClickIds = googleClickIds;
|
|
85
|
+
exports.linkedinFatId = linkedinFatId;
|
|
86
|
+
exports.metaFbc = metaFbc;
|
|
87
|
+
exports.metaFbp = metaFbp;
|
|
88
|
+
exports.microsoftMsclkid = microsoftMsclkid;
|
|
89
|
+
exports.openaiOppref = openaiOppref;
|
|
90
|
+
exports.redditClickId = redditClickId;
|
|
91
|
+
exports.redditUuid = redditUuid;
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=click-ids.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click-ids.cjs","names":["parseFbc","formatFbc","isGoogleAdsGclid","parseGcl","isMsclkid","parseUetMsclkid"],"sources":["../../src/server/click-ids.ts"],"sourcesContent":["/**\n * The click id each conversion sender passes on, resolved from an event's tags.\n *\n * The tags keep a URL parameter and the cookie that persists it apart (`gclid` / `_gcl_aw`, see\n * `AdvertisingInfo`). The URL parameter wins: the two only coexist on the landing page, where the\n * parameter is this very click while the cookie may still hold an earlier one — the pixel that\n * rewrites it can run after this SDK read it. On every later page and visit the URL carries\n * nothing and the cookie is what remains of the click.\n *\n * Clients older than 9.0.0 send `fbc` / `fbp` / `rdt_uuid` for the cookies (and may have filled\n * `gclid`, `wbraid`, `msclkid`, `rdt_cid` and `li_fat_id` from them), so those are still read\n * as a fallback. Transitional: drop them here and in `tagsSchema` and `AdvertisingInfo` once no\n * client sends them.\n */\nimport {\n formatFbc,\n isGoogleAdsGclid,\n isMsclkid,\n parseFbc,\n parseGcl,\n parseUetMsclkid,\n} from '../click-id/index';\nimport type { TrackTags } from '../track/types';\n\n/**\n * Meta's `fbc`: built from this page's `fbclid`, else the `_fbc` cookie. One exception on the\n * landing page: a cookie opened by that same `fbclid` is sent as it is, for its creationTime —\n * `resolveClickIdCookies` sets it on the landing document, before any event of the page.\n */\nexport function metaFbc(tags: TrackTags, eventTimeMs: number): string | undefined {\n const cookie = tags._fbc ?? tags.fbc;\n if (tags.fbclid) {\n if (parseFbc(cookie)?.fbclid === tags.fbclid) return cookie;\n // ref: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#2--format-clickid\n // Without the cookie, creationTime is \"the timestamp when you first observed or received\n // this fbclid value\" — the event's own time is the closest thing the server has to that,\n // and it does not move when a queued or retried batch finally goes out.\n return formatFbc(tags.fbclid, eventTimeMs);\n }\n return cookie;\n}\n\n/** Meta's `fbp`: the pixel's browser id, a cookie only. */\nexport function metaFbp(tags: TrackTags): string | undefined {\n return tags._fbp ?? tags.fbp;\n}\n\n/**\n * Google Ads' click ids, from the URL when it carries any of them, else from gtag's cookies.\n * All or nothing rather than one by one: the sender picks gclid over gbraid / wbraid, so a\n * landing URL with a fresh gbraid next to the `_gcl_aw` of an earlier click would otherwise send\n * the earlier click. gbraid is an app-to-web id and never kept in a cookie. A gclid that\n * `gclsrc` says is Search Ads 360's is not a Google Ads click and is left out, as gtag leaves it\n * out of `_gcl_aw`.\n */\nexport function googleClickIds(tags: TrackTags) {\n const gclid = isGoogleAdsGclid(tags.gclsrc) ? tags.gclid : undefined;\n const { gbraid, wbraid } = tags;\n if (gclid || gbraid || wbraid) return { gclid, gbraid, wbraid };\n return {\n gclid: parseGcl(tags._gcl_aw)?.clickId,\n gbraid: undefined,\n wbraid: parseGcl(tags._gcl_gb)?.clickId,\n };\n}\n\n/**\n * Microsoft Ads' click id, in the 32-hex form of the URL and the cookie. A URL value in any other\n * shape is not one (the API drops it), so it does not hide the cookie's.\n */\nexport function microsoftMsclkid(tags: TrackTags): string | undefined {\n const url = tags.msclkid?.trim();\n return isMsclkid(url) ? url : parseUetMsclkid(tags._uetmsclkid);\n}\n\nexport function redditClickId(tags: TrackTags): string | undefined {\n return tags.rdt_cid ?? tags._rdt_cid;\n}\n\n/** The Reddit pixel's browser id, a cookie only. */\nexport function redditUuid(tags: TrackTags): string | undefined {\n return tags._rdt_uuid ?? tags.rdt_uuid;\n}\n\nexport function linkedinFatId(tags: TrackTags): string | undefined {\n return tags.li_fat_id ?? tags._li_fat_id;\n}\n\n/**\n * OpenAI's `oppref`: the pixel captures it from the landing URL and keeps it in `__oppref` for\n * the later pages, and \"the API does not capture `oppref` for you\".\n * ref: https://developers.openai.com/ads/measurement-pixel#cookie-expiry\n */\nexport function openaiOppref(tags: TrackTags): string | undefined {\n return tags.oppref ?? tags.__oppref;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,QAAQ,MAAiB,aAAyC;CAChF,MAAM,SAAS,KAAK,QAAQ,KAAK;CACjC,IAAI,KAAK,QAAQ;EACf,IAAIA,uBAAAA,SAAS,MAAM,CAAC,EAAE,WAAW,KAAK,QAAQ,OAAO;EAKrD,OAAOC,uBAAAA,UAAU,KAAK,QAAQ,WAAW;CAC3C;CACA,OAAO;AACT;;AAGA,SAAgB,QAAQ,MAAqC;CAC3D,OAAO,KAAK,QAAQ,KAAK;AAC3B;;;;;;;;;AAUA,SAAgB,eAAe,MAAiB;CAC9C,MAAM,QAAQC,uBAAAA,iBAAiB,KAAK,MAAM,IAAI,KAAK,QAAQ,KAAA;CAC3D,MAAM,EAAE,QAAQ,WAAW;CAC3B,IAAI,SAAS,UAAU,QAAQ,OAAO;EAAE;EAAO;EAAQ;CAAO;CAC9D,OAAO;EACL,OAAOC,uBAAAA,SAAS,KAAK,OAAO,CAAC,EAAE;EAC/B,QAAQ,KAAA;EACR,QAAQA,uBAAAA,SAAS,KAAK,OAAO,CAAC,EAAE;CAClC;AACF;;;;;AAMA,SAAgB,iBAAiB,MAAqC;CACpE,MAAM,MAAM,KAAK,SAAS,KAAK;CAC/B,OAAOC,uBAAAA,UAAU,GAAG,IAAI,MAAMC,uBAAAA,gBAAgB,KAAK,WAAW;AAChE;AAEA,SAAgB,cAAc,MAAqC;CACjE,OAAO,KAAK,WAAW,KAAK;AAC9B;;AAGA,SAAgB,WAAW,MAAqC;CAC9D,OAAO,KAAK,aAAa,KAAK;AAChC;AAEA,SAAgB,cAAc,MAAqC;CACjE,OAAO,KAAK,aAAa,KAAK;AAChC;;;;;;AAOA,SAAgB,aAAa,MAAqC;CAChE,OAAO,KAAK,UAAU,KAAK;AAC7B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TrackTags } from "../track/types.cjs";
|
|
2
|
+
//#region src/server/click-ids.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Meta's `fbc`: built from this page's `fbclid`, else the `_fbc` cookie. One exception on the
|
|
5
|
+
* landing page: a cookie opened by that same `fbclid` is sent as it is, for its creationTime —
|
|
6
|
+
* `resolveClickIdCookies` sets it on the landing document, before any event of the page.
|
|
7
|
+
*/
|
|
8
|
+
export declare function metaFbc(tags: TrackTags, eventTimeMs: number): string | undefined;
|
|
9
|
+
/** Meta's `fbp`: the pixel's browser id, a cookie only. */
|
|
10
|
+
export declare function metaFbp(tags: TrackTags): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Google Ads' click ids, from the URL when it carries any of them, else from gtag's cookies.
|
|
13
|
+
* All or nothing rather than one by one: the sender picks gclid over gbraid / wbraid, so a
|
|
14
|
+
* landing URL with a fresh gbraid next to the `_gcl_aw` of an earlier click would otherwise send
|
|
15
|
+
* the earlier click. gbraid is an app-to-web id and never kept in a cookie. A gclid that
|
|
16
|
+
* `gclsrc` says is Search Ads 360's is not a Google Ads click and is left out, as gtag leaves it
|
|
17
|
+
* out of `_gcl_aw`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function googleClickIds(tags: TrackTags): {
|
|
20
|
+
gclid: string | undefined;
|
|
21
|
+
gbraid: string | undefined;
|
|
22
|
+
wbraid: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Microsoft Ads' click id, in the 32-hex form of the URL and the cookie. A URL value in any other
|
|
26
|
+
* shape is not one (the API drops it), so it does not hide the cookie's.
|
|
27
|
+
*/
|
|
28
|
+
export declare function microsoftMsclkid(tags: TrackTags): string | undefined;
|
|
29
|
+
export declare function redditClickId(tags: TrackTags): string | undefined;
|
|
30
|
+
/** The Reddit pixel's browser id, a cookie only. */
|
|
31
|
+
export declare function redditUuid(tags: TrackTags): string | undefined;
|
|
32
|
+
export declare function linkedinFatId(tags: TrackTags): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* OpenAI's `oppref`: the pixel captures it from the landing URL and keeps it in `__oppref` for
|
|
35
|
+
* the later pages, and "the API does not capture `oppref` for you".
|
|
36
|
+
* ref: https://developers.openai.com/ads/measurement-pixel#cookie-expiry
|
|
37
|
+
*/
|
|
38
|
+
export declare function openaiOppref(tags: TrackTags): string | undefined;
|
|
39
|
+
//#endregion
|
|
40
|
+
//# sourceMappingURL=click-ids.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click-ids.d.cts","names":[],"sources":["../../src/server/click-ids.ts"],"mappings":";;;;;;;wBA6BgB,QAAQ,MAAM,WAAW;;wBAczB,QAAQ,MAAM;;;;;;;;;wBAYd,eAAe,MAAM;;;;;;;;;wBAerB,iBAAiB,MAAM;wBAKvB,cAAc,MAAM;;wBAKpB,WAAW,MAAM;wBAIjB,cAAc,MAAM;;;;;;wBASpB,aAAa,MAAM"}
|