@blotoutio/providers-google-analytics-4-sdk 1.12.1 → 1.13.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/index.cjs.js +39 -3
- package/index.js +39 -3
- package/index.mjs +39 -3
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -44,6 +44,30 @@ const upsert = (map, key, update, createDefault) => {
|
|
|
44
44
|
return map.set(key, update(currentValue));
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
const flattenObject = (obj, prefix, keyFormatter, delimiter) => {
|
|
48
|
+
if (!obj) {
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
const updatedPrefix = prefix !== null && prefix !== void 0 ? prefix : '';
|
|
52
|
+
const updatedDelimiter = delimiter !== null && delimiter !== void 0 ? delimiter : '_';
|
|
53
|
+
const flattened = {};
|
|
54
|
+
Object.keys(obj).forEach((key) => {
|
|
55
|
+
const keyValue = keyFormatter ? keyFormatter(key) : key;
|
|
56
|
+
const value = obj[keyValue];
|
|
57
|
+
if (typeof value === 'object' && value !== null) {
|
|
58
|
+
const prefixValue = updatedPrefix
|
|
59
|
+
? updatedPrefix + keyValue + updatedDelimiter
|
|
60
|
+
: keyValue + updatedDelimiter;
|
|
61
|
+
Object.assign(flattened, flattenObject(value, prefixValue, keyFormatter, delimiter));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const objKey = updatedPrefix ? updatedPrefix + keyValue : keyValue;
|
|
65
|
+
flattened[objKey] = value;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return flattened;
|
|
69
|
+
};
|
|
70
|
+
|
|
47
71
|
const expand = (str) => str.split(',').flatMap((entry) => {
|
|
48
72
|
if (!entry.includes('-')) {
|
|
49
73
|
return entry;
|
|
@@ -483,6 +507,7 @@ const init = ({ manifest, userId, executionContext, consentData, }) => {
|
|
|
483
507
|
}
|
|
484
508
|
};
|
|
485
509
|
|
|
510
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
486
511
|
const getItems = (contents = []) => {
|
|
487
512
|
return contents.map((content) => {
|
|
488
513
|
const data = {
|
|
@@ -662,7 +687,7 @@ const getEvent = (eventName, data, eventId) => {
|
|
|
662
687
|
default: {
|
|
663
688
|
return {
|
|
664
689
|
event: eventName,
|
|
665
|
-
eventData:
|
|
690
|
+
eventData: {},
|
|
666
691
|
};
|
|
667
692
|
}
|
|
668
693
|
}
|
|
@@ -679,7 +704,18 @@ const handleTag = ({ data = {}, eventName, eventId, manifestVariables, }) => {
|
|
|
679
704
|
if (manifestVariables['debug'] === '1') {
|
|
680
705
|
eventData['debug_mode'] = true;
|
|
681
706
|
}
|
|
682
|
-
|
|
707
|
+
const rawData = structuredClone(data);
|
|
708
|
+
if ('items' in eventData) {
|
|
709
|
+
delete rawData['contents'];
|
|
710
|
+
}
|
|
711
|
+
const flattenedRawData = flattenObject(rawData);
|
|
712
|
+
const ga4Data = { ...flattenedRawData, ...eventData };
|
|
713
|
+
for (const key in ga4Data) {
|
|
714
|
+
if (ga4Data[key] === undefined) {
|
|
715
|
+
delete ga4Data[key];
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
window.gtag('event', event, { ...ga4Data, app: 'blotout' });
|
|
683
719
|
};
|
|
684
720
|
|
|
685
721
|
const getCookieValue = (key) => {
|
|
@@ -734,7 +770,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
734
770
|
}
|
|
735
771
|
return {
|
|
736
772
|
loaded: isLoaded,
|
|
737
|
-
sdkVersion: "1.
|
|
773
|
+
sdkVersion: "1.13.0" ,
|
|
738
774
|
};
|
|
739
775
|
};
|
|
740
776
|
|
package/index.js
CHANGED
|
@@ -45,6 +45,30 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
|
|
|
45
45
|
return map.set(key, update(currentValue));
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
const flattenObject = (obj, prefix, keyFormatter, delimiter) => {
|
|
49
|
+
if (!obj) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
const updatedPrefix = prefix !== null && prefix !== void 0 ? prefix : '';
|
|
53
|
+
const updatedDelimiter = delimiter !== null && delimiter !== void 0 ? delimiter : '_';
|
|
54
|
+
const flattened = {};
|
|
55
|
+
Object.keys(obj).forEach((key) => {
|
|
56
|
+
const keyValue = keyFormatter ? keyFormatter(key) : key;
|
|
57
|
+
const value = obj[keyValue];
|
|
58
|
+
if (typeof value === 'object' && value !== null) {
|
|
59
|
+
const prefixValue = updatedPrefix
|
|
60
|
+
? updatedPrefix + keyValue + updatedDelimiter
|
|
61
|
+
: keyValue + updatedDelimiter;
|
|
62
|
+
Object.assign(flattened, flattenObject(value, prefixValue, keyFormatter, delimiter));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const objKey = updatedPrefix ? updatedPrefix + keyValue : keyValue;
|
|
66
|
+
flattened[objKey] = value;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return flattened;
|
|
70
|
+
};
|
|
71
|
+
|
|
48
72
|
const expand = (str) => str.split(',').flatMap((entry) => {
|
|
49
73
|
if (!entry.includes('-')) {
|
|
50
74
|
return entry;
|
|
@@ -484,6 +508,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
|
|
|
484
508
|
}
|
|
485
509
|
};
|
|
486
510
|
|
|
511
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
487
512
|
const getItems = (contents = []) => {
|
|
488
513
|
return contents.map((content) => {
|
|
489
514
|
const data = {
|
|
@@ -663,7 +688,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
|
|
|
663
688
|
default: {
|
|
664
689
|
return {
|
|
665
690
|
event: eventName,
|
|
666
|
-
eventData:
|
|
691
|
+
eventData: {},
|
|
667
692
|
};
|
|
668
693
|
}
|
|
669
694
|
}
|
|
@@ -680,7 +705,18 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
|
|
|
680
705
|
if (manifestVariables['debug'] === '1') {
|
|
681
706
|
eventData['debug_mode'] = true;
|
|
682
707
|
}
|
|
683
|
-
|
|
708
|
+
const rawData = structuredClone(data);
|
|
709
|
+
if ('items' in eventData) {
|
|
710
|
+
delete rawData['contents'];
|
|
711
|
+
}
|
|
712
|
+
const flattenedRawData = flattenObject(rawData);
|
|
713
|
+
const ga4Data = { ...flattenedRawData, ...eventData };
|
|
714
|
+
for (const key in ga4Data) {
|
|
715
|
+
if (ga4Data[key] === undefined) {
|
|
716
|
+
delete ga4Data[key];
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
window.gtag('event', event, { ...ga4Data, app: 'blotout' });
|
|
684
720
|
};
|
|
685
721
|
|
|
686
722
|
const getCookieValue = (key) => {
|
|
@@ -735,7 +771,7 @@ var ProvidersGoogleAnalytics4Sdk = (function () {
|
|
|
735
771
|
}
|
|
736
772
|
return {
|
|
737
773
|
loaded: isLoaded,
|
|
738
|
-
sdkVersion: "1.
|
|
774
|
+
sdkVersion: "1.13.0" ,
|
|
739
775
|
};
|
|
740
776
|
};
|
|
741
777
|
|
package/index.mjs
CHANGED
|
@@ -42,6 +42,30 @@ const upsert = (map, key, update, createDefault) => {
|
|
|
42
42
|
return map.set(key, update(currentValue));
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
+
const flattenObject = (obj, prefix, keyFormatter, delimiter) => {
|
|
46
|
+
if (!obj) {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
const updatedPrefix = prefix !== null && prefix !== void 0 ? prefix : '';
|
|
50
|
+
const updatedDelimiter = delimiter !== null && delimiter !== void 0 ? delimiter : '_';
|
|
51
|
+
const flattened = {};
|
|
52
|
+
Object.keys(obj).forEach((key) => {
|
|
53
|
+
const keyValue = keyFormatter ? keyFormatter(key) : key;
|
|
54
|
+
const value = obj[keyValue];
|
|
55
|
+
if (typeof value === 'object' && value !== null) {
|
|
56
|
+
const prefixValue = updatedPrefix
|
|
57
|
+
? updatedPrefix + keyValue + updatedDelimiter
|
|
58
|
+
: keyValue + updatedDelimiter;
|
|
59
|
+
Object.assign(flattened, flattenObject(value, prefixValue, keyFormatter, delimiter));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const objKey = updatedPrefix ? updatedPrefix + keyValue : keyValue;
|
|
63
|
+
flattened[objKey] = value;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return flattened;
|
|
67
|
+
};
|
|
68
|
+
|
|
45
69
|
const expand = (str) => str.split(',').flatMap((entry) => {
|
|
46
70
|
if (!entry.includes('-')) {
|
|
47
71
|
return entry;
|
|
@@ -481,6 +505,7 @@ const init = ({ manifest, userId, executionContext, consentData, }) => {
|
|
|
481
505
|
}
|
|
482
506
|
};
|
|
483
507
|
|
|
508
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
484
509
|
const getItems = (contents = []) => {
|
|
485
510
|
return contents.map((content) => {
|
|
486
511
|
const data = {
|
|
@@ -660,7 +685,7 @@ const getEvent = (eventName, data, eventId) => {
|
|
|
660
685
|
default: {
|
|
661
686
|
return {
|
|
662
687
|
event: eventName,
|
|
663
|
-
eventData:
|
|
688
|
+
eventData: {},
|
|
664
689
|
};
|
|
665
690
|
}
|
|
666
691
|
}
|
|
@@ -677,7 +702,18 @@ const handleTag = ({ data = {}, eventName, eventId, manifestVariables, }) => {
|
|
|
677
702
|
if (manifestVariables['debug'] === '1') {
|
|
678
703
|
eventData['debug_mode'] = true;
|
|
679
704
|
}
|
|
680
|
-
|
|
705
|
+
const rawData = structuredClone(data);
|
|
706
|
+
if ('items' in eventData) {
|
|
707
|
+
delete rawData['contents'];
|
|
708
|
+
}
|
|
709
|
+
const flattenedRawData = flattenObject(rawData);
|
|
710
|
+
const ga4Data = { ...flattenedRawData, ...eventData };
|
|
711
|
+
for (const key in ga4Data) {
|
|
712
|
+
if (ga4Data[key] === undefined) {
|
|
713
|
+
delete ga4Data[key];
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
window.gtag('event', event, { ...ga4Data, app: 'blotout' });
|
|
681
717
|
};
|
|
682
718
|
|
|
683
719
|
const getCookieValue = (key) => {
|
|
@@ -732,7 +768,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
732
768
|
}
|
|
733
769
|
return {
|
|
734
770
|
loaded: isLoaded,
|
|
735
|
-
sdkVersion: "1.
|
|
771
|
+
sdkVersion: "1.13.0" ,
|
|
736
772
|
};
|
|
737
773
|
};
|
|
738
774
|
|