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