@blotoutio/providers-google-analytics-4-sdk 0.7.3 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +562 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -22,7 +22,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
22
22
  if (!manifest.variables || !window) {
23
23
  return;
24
24
  }
25
- if (!window.gtag && manifest.variables['enableBrowser'] === '1') {
25
+ if (!window.gtag) {
26
26
  initGA4(manifest.variables['measurementId']);
27
27
  }
28
28
  if (window.gtag) {
@@ -32,9 +32,570 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
32
32
  }
33
33
  };
34
34
 
35
+ const getItems = (contents = [], currency) => {
36
+ return contents.map((content) => {
37
+ const data = {
38
+ item_id: content.id,
39
+ item_name: content.title,
40
+ quantity: content.quantity || 1,
41
+ };
42
+ if (currency) {
43
+ data['currency'] = currency.toUpperCase();
44
+ }
45
+ if (content.category) {
46
+ data['item_category'] = content.category;
47
+ }
48
+ if (content.item_price) {
49
+ data['price'] = content.item_price;
50
+ }
51
+ return data;
52
+ });
53
+ };
54
+ const getEvent = (eventName, data, eventId) => {
55
+ let event = eventName;
56
+ let eventData = data || {};
57
+ switch (eventName) {
58
+ case 'PageView': {
59
+ event = 'page_view';
60
+ break;
61
+ }
62
+ case 'ViewContent': {
63
+ event = 'view_item';
64
+ eventData = {
65
+ currency: data['currency'],
66
+ value: data['value'],
67
+ items: getItems(data['contents'], data['currency']),
68
+ };
69
+ break;
70
+ }
71
+ case 'AddToCart': {
72
+ event = 'add_to_cart';
73
+ eventData = {
74
+ currency: data['currency'],
75
+ value: data['value'],
76
+ items: getItems(data['contents'], data['currency']),
77
+ };
78
+ break;
79
+ }
80
+ case 'InitiateCheckout': {
81
+ event = 'begin_checkout';
82
+ eventData = {
83
+ currency: data['currency'],
84
+ value: data['value'],
85
+ items: getItems(data['contents'], data['currency']),
86
+ };
87
+ break;
88
+ }
89
+ case 'Purchase': {
90
+ event = 'purchase';
91
+ eventData = {
92
+ currency: data['currency'],
93
+ transaction_id: data['orderId'] || eventId,
94
+ value: data['value'],
95
+ items: getItems(data['contents'], data['currency']),
96
+ };
97
+ break;
98
+ }
99
+ case 'Search': {
100
+ event = 'search';
101
+ eventData = {
102
+ search_term: data['search'],
103
+ };
104
+ break;
105
+ }
106
+ case 'Lead': {
107
+ event = 'generate_lead';
108
+ eventData = {
109
+ currency: data['currency'],
110
+ value: data['value'],
111
+ };
112
+ break;
113
+ }
114
+ }
115
+ return {
116
+ event,
117
+ eventData,
118
+ };
119
+ };
120
+ const handleTag = ({ data = {}, eventName, eventId, }) => {
121
+ if (!eventName || !window.gtag) {
122
+ return;
123
+ }
124
+ const { event, eventData } = getEvent(eventName, data, eventId);
125
+ window.gtag('event', event, eventData);
126
+ };
127
+
128
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
129
+
130
+ function validate(uuid) {
131
+ return typeof uuid === 'string' && REGEX.test(uuid);
132
+ }
133
+
134
+ /**
135
+ * Convert array of 16 byte values to UUID string format of the form:
136
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
137
+ */
138
+
139
+ const byteToHex = [];
140
+
141
+ for (let i = 0; i < 256; ++i) {
142
+ byteToHex.push((i + 0x100).toString(16).slice(1));
143
+ }
144
+
145
+ function unsafeStringify(arr, offset = 0) {
146
+ // Note: Be careful editing this code! It's been tuned for performance
147
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
148
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
149
+ }
150
+
151
+ function parse(uuid) {
152
+ if (!validate(uuid)) {
153
+ throw TypeError('Invalid UUID');
154
+ }
155
+
156
+ let v;
157
+ const arr = new Uint8Array(16); // Parse ########-....-....-....-............
158
+
159
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
160
+ arr[1] = v >>> 16 & 0xff;
161
+ arr[2] = v >>> 8 & 0xff;
162
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
163
+
164
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
165
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
166
+
167
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
168
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
169
+
170
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
171
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
172
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
173
+
174
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
175
+ arr[11] = v / 0x100000000 & 0xff;
176
+ arr[12] = v >>> 24 & 0xff;
177
+ arr[13] = v >>> 16 & 0xff;
178
+ arr[14] = v >>> 8 & 0xff;
179
+ arr[15] = v & 0xff;
180
+ return arr;
181
+ }
182
+
183
+ function stringToBytes(str) {
184
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
185
+
186
+ const bytes = [];
187
+
188
+ for (let i = 0; i < str.length; ++i) {
189
+ bytes.push(str.charCodeAt(i));
190
+ }
191
+
192
+ return bytes;
193
+ }
194
+
195
+ const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
196
+ const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
197
+ function v35(name, version, hashfunc) {
198
+ function generateUUID(value, namespace, buf, offset) {
199
+ var _namespace;
200
+
201
+ if (typeof value === 'string') {
202
+ value = stringToBytes(value);
203
+ }
204
+
205
+ if (typeof namespace === 'string') {
206
+ namespace = parse(namespace);
207
+ }
208
+
209
+ if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
210
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
211
+ } // Compute hash of namespace and value, Per 4.3
212
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
213
+ // hashfunc([...namespace, ... value])`
214
+
215
+
216
+ let bytes = new Uint8Array(16 + value.length);
217
+ bytes.set(namespace);
218
+ bytes.set(value, namespace.length);
219
+ bytes = hashfunc(bytes);
220
+ bytes[6] = bytes[6] & 0x0f | version;
221
+ bytes[8] = bytes[8] & 0x3f | 0x80;
222
+
223
+ if (buf) {
224
+ offset = offset || 0;
225
+
226
+ for (let i = 0; i < 16; ++i) {
227
+ buf[offset + i] = bytes[i];
228
+ }
229
+
230
+ return buf;
231
+ }
232
+
233
+ return unsafeStringify(bytes);
234
+ } // Function#name is not settable on some platforms (#270)
235
+
236
+
237
+ try {
238
+ generateUUID.name = name; // eslint-disable-next-line no-empty
239
+ } catch (err) {} // For CommonJS default export support
240
+
241
+
242
+ generateUUID.DNS = DNS;
243
+ generateUUID.URL = URL;
244
+ return generateUUID;
245
+ }
246
+
247
+ /*
248
+ * Browser-compatible JavaScript MD5
249
+ *
250
+ * Modification of JavaScript MD5
251
+ * https://github.com/blueimp/JavaScript-MD5
252
+ *
253
+ * Copyright 2011, Sebastian Tschan
254
+ * https://blueimp.net
255
+ *
256
+ * Licensed under the MIT license:
257
+ * https://opensource.org/licenses/MIT
258
+ *
259
+ * Based on
260
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
261
+ * Digest Algorithm, as defined in RFC 1321.
262
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
263
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
264
+ * Distributed under the BSD License
265
+ * See http://pajhome.org.uk/crypt/md5 for more info.
266
+ */
267
+ function md5(bytes) {
268
+ if (typeof bytes === 'string') {
269
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
270
+
271
+ bytes = new Uint8Array(msg.length);
272
+
273
+ for (let i = 0; i < msg.length; ++i) {
274
+ bytes[i] = msg.charCodeAt(i);
275
+ }
276
+ }
277
+
278
+ return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
279
+ }
280
+ /*
281
+ * Convert an array of little-endian words to an array of bytes
282
+ */
283
+
284
+
285
+ function md5ToHexEncodedArray(input) {
286
+ const output = [];
287
+ const length32 = input.length * 32;
288
+ const hexTab = '0123456789abcdef';
289
+
290
+ for (let i = 0; i < length32; i += 8) {
291
+ const x = input[i >> 5] >>> i % 32 & 0xff;
292
+ const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
293
+ output.push(hex);
294
+ }
295
+
296
+ return output;
297
+ }
298
+ /**
299
+ * Calculate output length with padding and bit length
300
+ */
301
+
302
+
303
+ function getOutputLength(inputLength8) {
304
+ return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
305
+ }
306
+ /*
307
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
308
+ */
309
+
310
+
311
+ function wordsToMd5(x, len) {
312
+ /* append padding */
313
+ x[len >> 5] |= 0x80 << len % 32;
314
+ x[getOutputLength(len) - 1] = len;
315
+ let a = 1732584193;
316
+ let b = -271733879;
317
+ let c = -1732584194;
318
+ let d = 271733878;
319
+
320
+ for (let i = 0; i < x.length; i += 16) {
321
+ const olda = a;
322
+ const oldb = b;
323
+ const oldc = c;
324
+ const oldd = d;
325
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
326
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
327
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
328
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
329
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
330
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
331
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
332
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
333
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
334
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
335
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
336
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
337
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
338
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
339
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
340
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
341
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
342
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
343
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
344
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
345
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
346
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
347
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
348
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
349
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
350
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
351
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
352
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
353
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
354
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
355
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
356
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
357
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
358
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
359
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
360
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
361
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
362
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
363
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
364
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
365
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
366
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
367
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
368
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
369
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
370
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
371
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
372
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
373
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
374
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
375
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
376
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
377
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
378
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
379
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
380
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
381
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
382
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
383
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
384
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
385
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
386
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
387
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
388
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
389
+ a = safeAdd(a, olda);
390
+ b = safeAdd(b, oldb);
391
+ c = safeAdd(c, oldc);
392
+ d = safeAdd(d, oldd);
393
+ }
394
+
395
+ return [a, b, c, d];
396
+ }
397
+ /*
398
+ * Convert an array bytes to an array of little-endian words
399
+ * Characters >255 have their high-byte silently ignored.
400
+ */
401
+
402
+
403
+ function bytesToWords(input) {
404
+ if (input.length === 0) {
405
+ return [];
406
+ }
407
+
408
+ const length8 = input.length * 8;
409
+ const output = new Uint32Array(getOutputLength(length8));
410
+
411
+ for (let i = 0; i < length8; i += 8) {
412
+ output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
413
+ }
414
+
415
+ return output;
416
+ }
417
+ /*
418
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
419
+ * to work around bugs in some JS interpreters.
420
+ */
421
+
422
+
423
+ function safeAdd(x, y) {
424
+ const lsw = (x & 0xffff) + (y & 0xffff);
425
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
426
+ return msw << 16 | lsw & 0xffff;
427
+ }
428
+ /*
429
+ * Bitwise rotate a 32-bit number to the left.
430
+ */
431
+
432
+
433
+ function bitRotateLeft(num, cnt) {
434
+ return num << cnt | num >>> 32 - cnt;
435
+ }
436
+ /*
437
+ * These functions implement the four basic operations the algorithm uses.
438
+ */
439
+
440
+
441
+ function md5cmn(q, a, b, x, s, t) {
442
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
443
+ }
444
+
445
+ function md5ff(a, b, c, d, x, s, t) {
446
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
447
+ }
448
+
449
+ function md5gg(a, b, c, d, x, s, t) {
450
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
451
+ }
452
+
453
+ function md5hh(a, b, c, d, x, s, t) {
454
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
455
+ }
456
+
457
+ function md5ii(a, b, c, d, x, s, t) {
458
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
459
+ }
460
+
461
+ v35('v3', 0x30, md5);
462
+
463
+ typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
464
+
465
+ // Adapted from Chris Veness' SHA1 code at
466
+ // http://www.movable-type.co.uk/scripts/sha1.html
467
+ function f(s, x, y, z) {
468
+ switch (s) {
469
+ case 0:
470
+ return x & y ^ ~x & z;
471
+
472
+ case 1:
473
+ return x ^ y ^ z;
474
+
475
+ case 2:
476
+ return x & y ^ x & z ^ y & z;
477
+
478
+ case 3:
479
+ return x ^ y ^ z;
480
+ }
481
+ }
482
+
483
+ function ROTL(x, n) {
484
+ return x << n | x >>> 32 - n;
485
+ }
486
+
487
+ function sha1(bytes) {
488
+ const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
489
+ const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
490
+
491
+ if (typeof bytes === 'string') {
492
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
493
+
494
+ bytes = [];
495
+
496
+ for (let i = 0; i < msg.length; ++i) {
497
+ bytes.push(msg.charCodeAt(i));
498
+ }
499
+ } else if (!Array.isArray(bytes)) {
500
+ // Convert Array-like to Array
501
+ bytes = Array.prototype.slice.call(bytes);
502
+ }
503
+
504
+ bytes.push(0x80);
505
+ const l = bytes.length / 4 + 2;
506
+ const N = Math.ceil(l / 16);
507
+ const M = new Array(N);
508
+
509
+ for (let i = 0; i < N; ++i) {
510
+ const arr = new Uint32Array(16);
511
+
512
+ for (let j = 0; j < 16; ++j) {
513
+ arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
514
+ }
515
+
516
+ M[i] = arr;
517
+ }
518
+
519
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
520
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
521
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
522
+
523
+ for (let i = 0; i < N; ++i) {
524
+ const W = new Uint32Array(80);
525
+
526
+ for (let t = 0; t < 16; ++t) {
527
+ W[t] = M[i][t];
528
+ }
529
+
530
+ for (let t = 16; t < 80; ++t) {
531
+ W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
532
+ }
533
+
534
+ let a = H[0];
535
+ let b = H[1];
536
+ let c = H[2];
537
+ let d = H[3];
538
+ let e = H[4];
539
+
540
+ for (let t = 0; t < 80; ++t) {
541
+ const s = Math.floor(t / 20);
542
+ const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
543
+ e = d;
544
+ d = c;
545
+ c = ROTL(b, 30) >>> 0;
546
+ b = a;
547
+ a = T;
548
+ }
549
+
550
+ H[0] = H[0] + a >>> 0;
551
+ H[1] = H[1] + b >>> 0;
552
+ H[2] = H[2] + c >>> 0;
553
+ H[3] = H[3] + d >>> 0;
554
+ H[4] = H[4] + e >>> 0;
555
+ }
556
+
557
+ return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
558
+ }
559
+
560
+ v35('v5', 0x50, sha1);
561
+
562
+ const getCookieValue = (key) => {
563
+ try {
564
+ if (!document || !document.cookie) {
565
+ return '';
566
+ }
567
+ const name = `${key}=`;
568
+ const decodedCookie = decodeURIComponent(document.cookie);
569
+ const ca = decodedCookie.split(';');
570
+ for (let i = 0; i < ca.length; i++) {
571
+ let c = ca[i];
572
+ while (c.charAt(0) === ' ') {
573
+ c = c.substring(1);
574
+ }
575
+ if (c.indexOf(name) === 0) {
576
+ return c.substring(name.length, c.length);
577
+ }
578
+ }
579
+ return '';
580
+ }
581
+ catch (_a) {
582
+ return '';
583
+ }
584
+ };
585
+
586
+ const tag = ({ data, eventName, manifestVariables }) => {
587
+ if (manifestVariables['type'] === 'FULL') {
588
+ handleTag({ data, eventName });
589
+ }
590
+ return {
591
+ loaded: !!getCookieValue('_ga'),
592
+ };
593
+ };
594
+
35
595
  const data = {
36
596
  name: 'googleAnalytics4',
37
597
  init,
598
+ tag,
38
599
  };
39
600
  try {
40
601
  if (window) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-analytics-4-sdk",
3
- "version": "0.7.3",
3
+ "version": "0.8.1",
4
4
  "description": "Google Analytics 4 Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",