@mparticle/web-google-analytics-4-client-kit 1.0.5 → 1.0.6
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
CHANGED
|
@@ -18,6 +18,10 @@ function truncateString(string, limit) {
|
|
|
18
18
|
: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function isEmpty(value) {
|
|
22
|
+
return value == null || !(Object.keys(value) || value).length;
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
function Common() {}
|
|
22
26
|
|
|
23
27
|
Common.prototype.forwarderSettings = null;
|
|
@@ -41,11 +45,13 @@ Common.prototype.truncateAttributes = function (
|
|
|
41
45
|
) {
|
|
42
46
|
var truncatedAttributes = {};
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if (!isEmpty(attributes)) {
|
|
49
|
+
Object.keys(attributes).forEach(function (attribute) {
|
|
50
|
+
var key = truncateString(attribute, keyLimit);
|
|
51
|
+
var val = truncateString(attributes[attribute], valueLimit);
|
|
52
|
+
truncatedAttributes[key] = val;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
49
55
|
|
|
50
56
|
return truncatedAttributes;
|
|
51
57
|
};
|
|
@@ -779,6 +785,21 @@ var initialization = {
|
|
|
779
785
|
window.gtag = function () {
|
|
780
786
|
window.dataLayer.push(arguments);
|
|
781
787
|
};
|
|
788
|
+
gtag('js', new Date());
|
|
789
|
+
|
|
790
|
+
// Check to see if mParticle SDK is V2 because V1 does not have the
|
|
791
|
+
// Identity API
|
|
792
|
+
if (window.mParticle.getVersion().split('.')[0] === '2') {
|
|
793
|
+
var userId = common.getUserId(
|
|
794
|
+
mParticle.Identity.getCurrentUser(),
|
|
795
|
+
userIdType,
|
|
796
|
+
hashUserId
|
|
797
|
+
);
|
|
798
|
+
if (userId) {
|
|
799
|
+
configSettings.user_id = userId;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
gtag('config', measurementId, configSettings);
|
|
782
803
|
|
|
783
804
|
if (!testMode) {
|
|
784
805
|
var clientScript = document.createElement('script');
|
|
@@ -792,19 +813,6 @@ var initialization = {
|
|
|
792
813
|
).appendChild(clientScript);
|
|
793
814
|
|
|
794
815
|
clientScript.onload = function () {
|
|
795
|
-
gtag('js', new Date());
|
|
796
|
-
|
|
797
|
-
if (window.mParticle.getVersion().split('.')[0] === '2') {
|
|
798
|
-
var userId = common.getUserId(
|
|
799
|
-
mParticle.Identity.getCurrentUser(),
|
|
800
|
-
userIdType,
|
|
801
|
-
hashUserId
|
|
802
|
-
);
|
|
803
|
-
if (userId) {
|
|
804
|
-
configSettings.user_id = userId;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
gtag('config', measurementId, configSettings);
|
|
808
816
|
isInitialized = true;
|
|
809
817
|
|
|
810
818
|
if (window.dataLayer && gtag && eventQueue.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-google-analytics-4-client-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
|
|
5
5
|
"description": "mParticle integration sdk for Google Analytics",
|
|
6
6
|
"main": "dist/GoogleAnalytics4EventForwarderClientSide-Kit.common.js",
|