@mparticle/web-google-analytics-4-server-kit 1.0.2 → 1.0.3
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
|
@@ -22,11 +22,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
22
22
|
// This kit does not have a `processEvent` method because no events should be sent client side.
|
|
23
23
|
|
|
24
24
|
var name = 'GoogleAnalytics4',
|
|
25
|
-
GA4MODULENUMBER = 160
|
|
25
|
+
GA4MODULENUMBER = 160,
|
|
26
|
+
suffix = 'Server';
|
|
26
27
|
|
|
27
28
|
var constructor = function() {
|
|
28
29
|
var self = this;
|
|
29
30
|
self.name = name;
|
|
31
|
+
self.suffix = suffix;
|
|
30
32
|
|
|
31
33
|
function initForwarder(forwarderSettings, service, testMode) {
|
|
32
34
|
mParticle._setIntegrationDelay(GA4MODULENUMBER, true);
|
|
@@ -38,6 +40,12 @@ var constructor = function() {
|
|
|
38
40
|
window.dataLayer.push(arguments);
|
|
39
41
|
};
|
|
40
42
|
|
|
43
|
+
gtag('js', new Date());
|
|
44
|
+
|
|
45
|
+
gtag('get', measurementId, 'client_id', function(clientId) {
|
|
46
|
+
setClientId(clientId, GA4MODULENUMBER);
|
|
47
|
+
});
|
|
48
|
+
|
|
41
49
|
if (!testMode) {
|
|
42
50
|
var clientScript = document.createElement('script');
|
|
43
51
|
clientScript.type = 'text/javascript';
|
|
@@ -48,21 +56,12 @@ var constructor = function() {
|
|
|
48
56
|
document.getElementsByTagName('head')[0] ||
|
|
49
57
|
document.getElementsByTagName('body')[0]
|
|
50
58
|
).appendChild(clientScript);
|
|
51
|
-
|
|
52
|
-
clientScript.onload = function() {
|
|
53
|
-
gtag('js', new Date());
|
|
54
|
-
|
|
55
|
-
gtag('get', measurementId, 'client_id', function(clientId) {
|
|
56
|
-
setClientId(clientId, GA4MODULENUMBER);
|
|
57
|
-
});
|
|
58
|
-
return;
|
|
59
|
-
};
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
this.init = initForwarder;
|
|
64
63
|
};
|
|
65
|
-
|
|
64
|
+
|
|
66
65
|
function setClientId(clientId, GA4MODULENUMBER) {
|
|
67
66
|
var GA4CLIENTID = 'client_id';
|
|
68
67
|
var ga4IntegrationAttributes = {};
|
|
@@ -83,13 +82,18 @@ if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
|
83
82
|
name: name,
|
|
84
83
|
constructor: constructor,
|
|
85
84
|
getId: getId,
|
|
85
|
+
// A suffix is added if there are multiple different versions of
|
|
86
|
+
// a client kit. This matches the suffix in the DB.
|
|
87
|
+
suffix: suffix,
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
function register(config) {
|
|
92
|
+
var forwarderNameWithSuffix = [name, suffix].join('-');
|
|
90
93
|
if (!config) {
|
|
91
94
|
window.console.log(
|
|
92
|
-
'You must pass a config object to register the kit ' +
|
|
95
|
+
'You must pass a config object to register the kit ' +
|
|
96
|
+
forwarderNameWithSuffix
|
|
93
97
|
);
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
@@ -102,17 +106,19 @@ function register(config) {
|
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
if (isObject(config.kits)) {
|
|
105
|
-
config.kits[
|
|
109
|
+
config.kits[forwarderNameWithSuffix] = {
|
|
106
110
|
constructor: constructor,
|
|
107
111
|
};
|
|
108
112
|
} else {
|
|
109
113
|
config.kits = {};
|
|
110
|
-
config.kits[
|
|
114
|
+
config.kits[forwarderNameWithSuffix] = {
|
|
111
115
|
constructor: constructor,
|
|
112
116
|
};
|
|
113
117
|
}
|
|
114
118
|
window.console.log(
|
|
115
|
-
'Successfully registered ' +
|
|
119
|
+
'Successfully registered ' +
|
|
120
|
+
forwarderNameWithSuffix +
|
|
121
|
+
' to your mParticle configuration'
|
|
116
122
|
);
|
|
117
123
|
}
|
|
118
124
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-google-analytics-4-server-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "mParticle integration sdk for Google Analytics (server side)",
|
|
5
5
|
"main": "dist/GoogleAnalytics4EventForwarderServerSide-Kit.common.js",
|
|
6
6
|
"browser": "dist/GoogleAnalytics4EventForwarderServerSide-Kit.common.js",
|
|
7
7
|
"files": ["dist/GoogleAnalytics4EventForwarderServerSide-Kit.common.js"],
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "rollup --config rollup.config.js",
|
|
10
|
-
"
|
|
10
|
+
"build:test": "ENVIRONMENT=production rollup --config rollup.test.config.js",
|
|
11
|
+
"watch": "rollup --config rollup.config.js -w",
|
|
12
|
+
"test": "npm run build && npm run build:test && DEBUG=false karma start test/karma.config.js",
|
|
13
|
+
"test:debug": "npm run build && npm run build:test && DEBUG=true karma start test/karma.config.js"
|
|
14
|
+
|
|
11
15
|
},
|
|
12
16
|
"author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
|
|
13
17
|
"license": "Apache-2.0",
|
|
@@ -16,6 +20,14 @@
|
|
|
16
20
|
},
|
|
17
21
|
"repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-google-analytics-4/tree/master/packages/GA4Server",
|
|
18
22
|
"devDependencies": {
|
|
19
|
-
"
|
|
23
|
+
"mocha": "^5.2.0",
|
|
24
|
+
"rollup": "^1.15.6",
|
|
25
|
+
"rollup-plugin-commonjs": "^10.0.0",
|
|
26
|
+
"rollup-plugin-node-resolve": "^5.0.3",
|
|
27
|
+
"should": "13.2.3",
|
|
28
|
+
"sinon": "^15.1.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@mparticle/web-sdk": "^2.23.0"
|
|
20
32
|
}
|
|
21
33
|
}
|