@mhubcloud/tms_core 3.5.1 → 3.6.0-beta.1

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.
@@ -1,107 +0,0 @@
1
- const localSettings = require('../local.settings.json').Values;
2
- process.env = { ...process.env, ...localSettings };
3
- const publisher = require('../dist/index.js').publisher.UniversalAnalytics;
4
- const defaultPublisher = require('../dist/index.js').DefaultPublisher;
5
- const utils = require('../dist/index.js').utils;
6
- const testUtils = require('../dist/index.js').testUtils;
7
-
8
- describe('test UniversalAnalytics publisher', function () {
9
- it('pageview', async function () {
10
- var serviceBusMessage = {
11
- currencyCode: 'CZK',
12
- event: {
13
- region: 'MAIN',
14
- id: '115169112-4870.1657003407533',
15
- code: 'pageview',
16
- },
17
- session: {
18
- userAgent:
19
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
20
- ip: '89.177.126.237',
21
- referrer: 'https://crossmasters.com/',
22
- },
23
- referrer: 'https://crossmasters.com/',
24
- permissions: [],
25
- identity: {
26
- piano: {
27
- id: '1657003393413.319297501',
28
- },
29
- },
30
- publisher: {
31
- code: 'mhubcloud.com',
32
- tm: 'GTM-N7K9L4X',
33
- tmv: '494',
34
- },
35
- $schema: 'mhub/pageview',
36
- enqueuedAt: 1657003409370,
37
- ads: [],
38
- };
39
- await test(serviceBusMessage);
40
- });
41
- });
42
-
43
- /**
44
- * Test function
45
- * @param [object] object obsahující nastavení testovací parametry
46
- */
47
- async function test(serviceBusMessage) {
48
- await defaultPublisher(
49
- testUtils.context,
50
- serviceBusMessage,
51
- 'UniversalAnalytics',
52
- publisher,
53
- trigger,
54
- );
55
- }
56
-
57
- // eslint-disable-next-line @typescript-eslint/require-await
58
- async function trigger(data) {
59
- const publishers = [];
60
- const config = { trackingId: 'UA-xxxxxxx-yy' };
61
-
62
- if (data.event?.code === 'pageview') {
63
- const publisher = GAPageviewPublisher;
64
- publisher.register(publishers, config);
65
- }
66
-
67
- return publishers;
68
- }
69
-
70
- class GAPageviewPublisher extends utils.EventPublisherBase {
71
- /**
72
- * Maps `pageview` event data to GA payload
73
- */
74
- map(data) {
75
- /** @type {AdCodeInfo} */
76
- let gclid = utils.extractAdCode(data, 'googleads', 'gclid');
77
- /** @type {AdCodeInfo} */
78
- let referrer = utils.extractAdCode(data, 'referrerPlatform', 'referrer');
79
- /** @type {Ad} */
80
- let utm = utils.extractAdCode(
81
- data,
82
- 'googleAnalytics',
83
- 'utm_source',
84
- (_, data) => (data.adCodes ? data : null),
85
- ); // Only supports new format
86
-
87
- // https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#event
88
- // https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#dr
89
- return {
90
- // mandatory for all events
91
- t: 'pageview',
92
- cid: '456', // TODO
93
-
94
- // mandatory for pageview
95
- dp: '/',
96
-
97
- // Traffic Sources - optional
98
- // TODO not tested
99
- cn: utm?.adCodes?.utm_campaign,
100
- cs: utm?.adCodes?.utm_source,
101
- cm: utm?.adCodes?.utm_medium,
102
- cc: utm?.adCodes?.utm_content,
103
- gclid: gclid?.code,
104
- dr: referrer?.code,
105
- };
106
- }
107
- }
@@ -1,43 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "Default",
4
- "extends": "@tsconfig/recommended/tsconfig.json",
5
- "compilerOptions": {
6
- "allowJs": true,
7
- "allowSyntheticDefaultImports": true,
8
- "checkJs": false,
9
- "composite": false,
10
- "declaration": true,
11
- "declarationDir": "./types",
12
- "declarationMap": true,
13
- "inlineSources": false,
14
- "isolatedModules": true,
15
- "moduleResolution": "node",
16
- "noEmit": true,
17
- "noFallthroughCasesInSwitch": true,
18
- "noImplicitOverride": true,
19
- "noImplicitReturns": true,
20
- "noUncheckedIndexedAccess": true,
21
- "noUnusedLocals": true,
22
- "noUnusedParameters": true,
23
- "preserveWatchOutput": true,
24
- "removeComments": true,
25
- "resolveJsonModule": true,
26
- "sourceMap": true,
27
- "strictNullChecks": true,
28
- "useDefineForClassFields": true,
29
- "useUnknownInCatchVariables": true,
30
- "strict": true,
31
- "outDir": "dist"
32
- },
33
- "include": [
34
- ".eslintrc.cjs",
35
- "**/*"
36
- // "build_scripts/post-build.mjs"
37
- ],
38
- "exclude": [
39
- "node_modules",
40
- "build",
41
- "dist"
42
- ]
43
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "extends": "./tsconfig.eslint.json",
3
- "compilerOptions": {
4
- "lib": [
5
- "es2021", "es2022.error"
6
- ],
7
- "module": "commonjs",
8
- "target": "es2021",
9
- "moduleResolution": "node",
10
- "experimentalDecorators": true,
11
- "types": [
12
- "node"
13
- ]
14
- },
15
- "include": [
16
- "**/*.ts",
17
- "tsconfig.eslint.json"
18
- ],
19
- "exclude": [
20
- "node_modules",
21
- "build",
22
- "dist",
23
- "tests",
24
- "js"
25
- ]
26
- }