@blotoutio/providers-google-analytics-4-sdk 0.60.1 → 0.61.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 (4) hide show
  1. package/index.cjs.js +25 -14
  2. package/index.js +25 -14
  3. package/index.mjs +25 -14
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -303,28 +303,39 @@ const handleTag = ({ data = {}, eventName, eventId, manifestVariables, }) => {
303
303
  };
304
304
 
305
305
  const getCookieValue = (key) => {
306
+ var _a;
306
307
  try {
307
308
  if (!document || !document.cookie) {
308
309
  return '';
309
310
  }
310
- const name = `${key}=`;
311
- const decodedCookie = decodeURIComponent(document.cookie);
312
- const ca = decodedCookie.split(';');
313
- for (let i = 0; i < ca.length; i++) {
314
- let c = ca[i];
315
- while (c.charAt(0) === ' ') {
316
- c = c.substring(1);
317
- }
318
- if (c.indexOf(name) === 0) {
319
- return c.substring(name.length, c.length);
320
- }
321
- }
322
- return '';
311
+ const cookies = parseCookies(document.cookie);
312
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
323
313
  }
324
314
  catch {
325
315
  return '';
326
316
  }
327
317
  };
318
+ const parseCookies = (cookie) => {
319
+ return Object.fromEntries(cookie
320
+ .split(/;\s+/)
321
+ .map((r) => r.split('=').map((str) => str.trim()))
322
+ .map(([cookieKey, cookieValue]) => {
323
+ if (!cookieKey) {
324
+ return [];
325
+ }
326
+ let decodedValue = '';
327
+ if (cookieValue) {
328
+ try {
329
+ decodedValue = decodeURIComponent(cookieValue);
330
+ }
331
+ catch (e) {
332
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
333
+ decodedValue = cookieValue;
334
+ }
335
+ }
336
+ return [cookieKey, decodedValue];
337
+ }));
338
+ };
328
339
 
329
340
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
330
341
  let isLoaded;
@@ -342,7 +353,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
342
353
  }
343
354
  return {
344
355
  loaded: isLoaded,
345
- sdkVersion: "0.60.1" ,
356
+ sdkVersion: "0.61.0" ,
346
357
  };
347
358
  };
348
359
 
package/index.js CHANGED
@@ -304,28 +304,39 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
304
304
  };
305
305
 
306
306
  const getCookieValue = (key) => {
307
+ var _a;
307
308
  try {
308
309
  if (!document || !document.cookie) {
309
310
  return '';
310
311
  }
311
- const name = `${key}=`;
312
- const decodedCookie = decodeURIComponent(document.cookie);
313
- const ca = decodedCookie.split(';');
314
- for (let i = 0; i < ca.length; i++) {
315
- let c = ca[i];
316
- while (c.charAt(0) === ' ') {
317
- c = c.substring(1);
318
- }
319
- if (c.indexOf(name) === 0) {
320
- return c.substring(name.length, c.length);
321
- }
322
- }
323
- return '';
312
+ const cookies = parseCookies(document.cookie);
313
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
324
314
  }
325
315
  catch {
326
316
  return '';
327
317
  }
328
318
  };
319
+ const parseCookies = (cookie) => {
320
+ return Object.fromEntries(cookie
321
+ .split(/;\s+/)
322
+ .map((r) => r.split('=').map((str) => str.trim()))
323
+ .map(([cookieKey, cookieValue]) => {
324
+ if (!cookieKey) {
325
+ return [];
326
+ }
327
+ let decodedValue = '';
328
+ if (cookieValue) {
329
+ try {
330
+ decodedValue = decodeURIComponent(cookieValue);
331
+ }
332
+ catch (e) {
333
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
334
+ decodedValue = cookieValue;
335
+ }
336
+ }
337
+ return [cookieKey, decodedValue];
338
+ }));
339
+ };
329
340
 
330
341
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
331
342
  let isLoaded;
@@ -343,7 +354,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
343
354
  }
344
355
  return {
345
356
  loaded: isLoaded,
346
- sdkVersion: "0.60.1" ,
357
+ sdkVersion: "0.61.0" ,
347
358
  };
348
359
  };
349
360
 
package/index.mjs CHANGED
@@ -301,28 +301,39 @@ const handleTag = ({ data = {}, eventName, eventId, manifestVariables, }) => {
301
301
  };
302
302
 
303
303
  const getCookieValue = (key) => {
304
+ var _a;
304
305
  try {
305
306
  if (!document || !document.cookie) {
306
307
  return '';
307
308
  }
308
- const name = `${key}=`;
309
- const decodedCookie = decodeURIComponent(document.cookie);
310
- const ca = decodedCookie.split(';');
311
- for (let i = 0; i < ca.length; i++) {
312
- let c = ca[i];
313
- while (c.charAt(0) === ' ') {
314
- c = c.substring(1);
315
- }
316
- if (c.indexOf(name) === 0) {
317
- return c.substring(name.length, c.length);
318
- }
319
- }
320
- return '';
309
+ const cookies = parseCookies(document.cookie);
310
+ return (_a = cookies[key]) !== null && _a !== void 0 ? _a : '';
321
311
  }
322
312
  catch {
323
313
  return '';
324
314
  }
325
315
  };
316
+ const parseCookies = (cookie) => {
317
+ return Object.fromEntries(cookie
318
+ .split(/;\s+/)
319
+ .map((r) => r.split('=').map((str) => str.trim()))
320
+ .map(([cookieKey, cookieValue]) => {
321
+ if (!cookieKey) {
322
+ return [];
323
+ }
324
+ let decodedValue = '';
325
+ if (cookieValue) {
326
+ try {
327
+ decodedValue = decodeURIComponent(cookieValue);
328
+ }
329
+ catch (e) {
330
+ console.log(`Unable to decode cookie ${cookieKey}: ${e}`);
331
+ decodedValue = cookieValue;
332
+ }
333
+ }
334
+ return [cookieKey, decodedValue];
335
+ }));
336
+ };
326
337
 
327
338
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
328
339
  let isLoaded;
@@ -340,7 +351,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
340
351
  }
341
352
  return {
342
353
  loaded: isLoaded,
343
- sdkVersion: "0.60.1" ,
354
+ sdkVersion: "0.61.0" ,
344
355
  };
345
356
  };
346
357
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-google-analytics-4-sdk",
3
- "version": "0.60.1",
3
+ "version": "0.61.0",
4
4
  "description": "Google Analytics 4 Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",