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