@mhubcloud/tms_core 2.0.0-beta.4 → 2.1.0-beta.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/dist/index.js +13 -15
- package/index.js +1 -0
- package/package.json +4 -3
- package/publishers/TableStorage.js +46 -0
- package/src/defaultPublisher.ts +17 -19
- package/src/types/EventPublisher.ts +5 -2
- package/src/types/{EventHubMessage.ts → ServiceBusMessage.ts} +1 -1
- package/tests/AffiliatePort.js +59 -62
- package/tests/CJ.js +87 -88
- package/tests/Facebook.js +38 -40
- package/tests/GoogleAnalytics4.js +38 -40
- package/tests/Piano.js +38 -40
- package/tests/UniversalAnalytics.js +29 -31
package/dist/index.js
CHANGED
|
@@ -237,18 +237,16 @@ async function handleTestRequest(params) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// src/defaultPublisher.ts
|
|
240
|
-
async function defaultPublisher(azureFunctionContext,
|
|
240
|
+
async function defaultPublisher(azureFunctionContext, serviceBusMessage, source, platformPublisher, trigger) {
|
|
241
241
|
const processMessagePromises = [];
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
);
|
|
251
|
-
}
|
|
242
|
+
processMessagePromises.push(
|
|
243
|
+
processMessage(
|
|
244
|
+
serviceBusMessage,
|
|
245
|
+
azureFunctionContext.log,
|
|
246
|
+
platformPublisher,
|
|
247
|
+
trigger
|
|
248
|
+
)
|
|
249
|
+
);
|
|
252
250
|
const results = await Promise.allSettled(processMessagePromises);
|
|
253
251
|
for (const result of results) {
|
|
254
252
|
if (result.status === "rejected") {
|
|
@@ -263,9 +261,9 @@ async function defaultPublisher(azureFunctionContext, eventHubMessages, source,
|
|
|
263
261
|
}
|
|
264
262
|
}
|
|
265
263
|
}
|
|
266
|
-
async function processMessage(message, log3,
|
|
264
|
+
async function processMessage(message, log3, platformPublisher, trigger) {
|
|
267
265
|
const logProperties = {
|
|
268
|
-
source:
|
|
266
|
+
source: platformPublisher.source,
|
|
269
267
|
data: JSON.stringify(message)
|
|
270
268
|
};
|
|
271
269
|
const publishers = trigger(message, log3);
|
|
@@ -286,7 +284,7 @@ async function processMessage(message, log3, platfromPublisher, trigger) {
|
|
|
286
284
|
log3,
|
|
287
285
|
mapped,
|
|
288
286
|
eventPublisher.config,
|
|
289
|
-
|
|
287
|
+
platformPublisher,
|
|
290
288
|
message.event.code + (message.event.name ? "/" + message.event.name : "")
|
|
291
289
|
);
|
|
292
290
|
if (res) {
|
|
@@ -295,7 +293,7 @@ async function processMessage(message, log3, platfromPublisher, trigger) {
|
|
|
295
293
|
logException(
|
|
296
294
|
log3,
|
|
297
295
|
new Error(
|
|
298
|
-
`The message has not been published. Source: ${
|
|
296
|
+
`The message has not been published. Source: ${platformPublisher.source}`
|
|
299
297
|
)
|
|
300
298
|
);
|
|
301
299
|
failedToPublishAll = true;
|
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ module.exports = {
|
|
|
10
10
|
GoogleAnalytics4 : require('./publishers/GoogleAnalytics4'),
|
|
11
11
|
CJ : require('./publishers/CJ'),
|
|
12
12
|
UniversalAnalytics : require('./publishers/UniversalAnalytics'),
|
|
13
|
+
TableStorage : require('./publishers/TableStorage'),
|
|
13
14
|
HttpPublisher : require('./publishers/HttpPublisher'),
|
|
14
15
|
AffiliatePort : require('./publishers/AffiliatePort')
|
|
15
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mhubcloud/tms_core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0-beta.0",
|
|
4
4
|
"description": "Core function for mHub Cloud TMS publishers",
|
|
5
5
|
"homepage": "https://mhubcloud.com/",
|
|
6
6
|
"license": "Apache 2.0",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"conversion API"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@azure/data-tables": "^13.2.2",
|
|
19
20
|
"ajv": "^8.12.0",
|
|
20
21
|
"applicationinsights": "^2.6.0",
|
|
21
22
|
"node-fetch": "^2.6.11"
|
|
@@ -39,8 +40,8 @@
|
|
|
39
40
|
"typescript": "^4.9.5"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
43
|
+
"test": "mocha ./tests/*.js --local-settings=./local.settings.json --timeout 100000",
|
|
42
44
|
"dev": "ts-node index.ts",
|
|
43
|
-
"build": "tsup ./src/index.ts --format cjs --target node18"
|
|
44
|
-
"test": "mocha ./tests/*.js --timeout 10000 "
|
|
45
|
+
"build": "tsup ./src/index.ts --format cjs --target node18"
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { TableClient } = require("@azure/data-tables");
|
|
2
|
+
const utils = require("../lib/utils");
|
|
3
|
+
const SOURCE = "f_TableStorage";
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
/**
|
|
7
|
+
* Processed data comming from EventHub to data for further processing
|
|
8
|
+
* @param {Object} data The data comming from EventHub
|
|
9
|
+
* @returns {Object} Data for further processing
|
|
10
|
+
*/
|
|
11
|
+
parse: function parse(data, context) {
|
|
12
|
+
//ConsumerBase.cs:ConsumeOneEventAsync
|
|
13
|
+
data.enqueuedAt = context.test ? 1600000000000 : Date.now();
|
|
14
|
+
return data;
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Publishes data to TableStorage
|
|
19
|
+
* https://www.npmjs.com/package/@azure/data-tables
|
|
20
|
+
* @param {{id: string, access_token: string}} config Publisher configuration
|
|
21
|
+
* @param {Object} data Data in publisher-friendly format to be published
|
|
22
|
+
* @param {string} event for which is it triggered
|
|
23
|
+
*/
|
|
24
|
+
publish: async function publish(config, data, event) {
|
|
25
|
+
data = utils.removeUndefined(data);
|
|
26
|
+
|
|
27
|
+
const client = new TableClient(config.connectionString, config.tableName);
|
|
28
|
+
|
|
29
|
+
await client.createEntity(data);
|
|
30
|
+
|
|
31
|
+
console.log(`TableStorage - ${event} - sent`);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validates an object against given schema
|
|
36
|
+
* @param {Object} data An object to validate.
|
|
37
|
+
* @param {string} schema Name of the schema. That's name of a file with `.schema.json` extension in `customizable/schemas` subfolder of current publisher folder
|
|
38
|
+
* @returns {boolean} Validation result, true if successful, false if unsuccessfull (in which case more info is written to console)
|
|
39
|
+
*/
|
|
40
|
+
validate: function validate(data, schema) {
|
|
41
|
+
if (!schema) throw new Error("Schema parameters not provided");
|
|
42
|
+
if (schema.indexOf("/") >= 0) throw new Error("Schema must be provided as schema name, not schema path");
|
|
43
|
+
//More validation done by utils.validate
|
|
44
|
+
return utils.validate(data, SOURCE, schema);
|
|
45
|
+
}
|
|
46
|
+
};
|
package/src/defaultPublisher.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Logger } from '@azure/functions';
|
|
2
2
|
import { Telemetry } from 'applicationinsights/out/Declarations/Contracts';
|
|
3
|
-
import { EventHubMessage } from './types/EventHubMessage';
|
|
4
3
|
import { EventPublisher } from './types/EventPublisher';
|
|
5
4
|
import { PlatformPublisher } from './types/PlatformPublisher';
|
|
5
|
+
import { ServiceBusMessage } from './types/ServiceBusMessage';
|
|
6
6
|
import { TypeSafeObject } from './types/UtilTypes';
|
|
7
7
|
import * as utils from './utils/utils';
|
|
8
8
|
|
|
@@ -10,29 +10,27 @@ import * as utils from './utils/utils';
|
|
|
10
10
|
* Implements the Azure Function, called for set of events received via Event Hub
|
|
11
11
|
* @deprecated Udelat novou metodu, ktera bude spravne a bude inicializovat classu
|
|
12
12
|
* @param azureFunctionContext Azure Function Context
|
|
13
|
-
* @param
|
|
13
|
+
* @param serviceBusMessage Array of messages received from Event Hub
|
|
14
14
|
* @param source Name of the publisher (it's folder name in which it's implemented)
|
|
15
15
|
* @param platformPublisher Publisher implementation instance (from <publisher>/publisher.js)
|
|
16
16
|
* @param trigger
|
|
17
17
|
*/
|
|
18
18
|
export async function defaultPublisher(
|
|
19
19
|
azureFunctionContext: Context,
|
|
20
|
-
|
|
20
|
+
serviceBusMessage: ServiceBusMessage,
|
|
21
21
|
source: string,
|
|
22
22
|
platformPublisher: PlatformPublisher,
|
|
23
23
|
trigger: (a: unknown) => EventPublisher[],
|
|
24
24
|
) {
|
|
25
25
|
const processMessagePromises = [];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
}
|
|
26
|
+
processMessagePromises.push(
|
|
27
|
+
processMessage(
|
|
28
|
+
serviceBusMessage,
|
|
29
|
+
azureFunctionContext.log,
|
|
30
|
+
platformPublisher,
|
|
31
|
+
trigger,
|
|
32
|
+
),
|
|
33
|
+
);
|
|
36
34
|
const results = await Promise.allSettled(processMessagePromises);
|
|
37
35
|
// ? musi nahoru probublat, ze aspon neco selhalo a to je to, co bude triggerovat nasledujici error. Error pro konkretniho publishera musi byt primo v processMessage v loopu. Hodnotu pro typ publishera vezmeme z platformBublisher.SOURCE
|
|
38
36
|
for (const result of results) {
|
|
@@ -54,19 +52,19 @@ export async function defaultPublisher(
|
|
|
54
52
|
* @param message A message received from EventHub
|
|
55
53
|
* @param log Azure Function context.log
|
|
56
54
|
* @param source Name of the publisher (it's folder name in which it's implemented)
|
|
57
|
-
* @param
|
|
55
|
+
* @param platformPublisher Publisher implementation instance (from <publisher>/publisher.js)
|
|
58
56
|
* @param trigger Publisher-specific trigger function (from <publisher>/customizable/trigger.js)
|
|
59
57
|
* @returns Returns false if at least one publisher failed or in case of other failed requirements
|
|
60
58
|
*/
|
|
61
59
|
async function processMessage(
|
|
62
|
-
message:
|
|
60
|
+
message: ServiceBusMessage,
|
|
63
61
|
log: Logger,
|
|
64
|
-
|
|
62
|
+
platformPublisher: PlatformPublisher,
|
|
65
63
|
trigger: (a: object, log: Logger) => EventPublisher[],
|
|
66
64
|
) {
|
|
67
65
|
// TODO Je potreba otestovat, ze se to nerozbije, kdyz jsme prestali prepisovat enqueuedAt na Date.now()
|
|
68
66
|
const logProperties: Telemetry['properties'] = {
|
|
69
|
-
source:
|
|
67
|
+
source: platformPublisher.source,
|
|
70
68
|
data: JSON.stringify(message),
|
|
71
69
|
};
|
|
72
70
|
const publishers = trigger(message, log);
|
|
@@ -88,7 +86,7 @@ async function processMessage(
|
|
|
88
86
|
log,
|
|
89
87
|
mapped,
|
|
90
88
|
eventPublisher.config,
|
|
91
|
-
|
|
89
|
+
platformPublisher,
|
|
92
90
|
message.event.code + (message.event.name ? '/' + message.event.name : ''),
|
|
93
91
|
);
|
|
94
92
|
if (res) {
|
|
@@ -97,7 +95,7 @@ async function processMessage(
|
|
|
97
95
|
utils.logException(
|
|
98
96
|
log,
|
|
99
97
|
new Error(
|
|
100
|
-
`The message has not been published. Source: ${
|
|
98
|
+
`The message has not been published. Source: ${platformPublisher.source}`,
|
|
101
99
|
),
|
|
102
100
|
);
|
|
103
101
|
failedToPublishAll = true;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Logger } from '@azure/functions';
|
|
2
|
-
import {
|
|
2
|
+
import { ServiceBusMessage } from './ServiceBusMessage';
|
|
3
3
|
|
|
4
4
|
export interface EventPublisherBaseClass {
|
|
5
5
|
config: Record<string, unknown>;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface EventPublisher extends EventPublisherBaseClass {
|
|
9
|
-
map: (
|
|
9
|
+
map: (
|
|
10
|
+
data: ServiceBusMessage,
|
|
11
|
+
log: Logger,
|
|
12
|
+
) => Promise<Record<string, unknown>>;
|
|
10
13
|
}
|
package/tests/AffiliatePort.js
CHANGED
|
@@ -6,69 +6,66 @@ const testUtils = require('../dist/index.js').testUtils;
|
|
|
6
6
|
|
|
7
7
|
describe('test AffiliatePort publisher', function () {
|
|
8
8
|
it('purchase', async function () {
|
|
9
|
-
var
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
var serviceBusMessage = {
|
|
10
|
+
event: {
|
|
11
|
+
region: 'smarty.cz',
|
|
12
|
+
id: '825333270-1011.1659006863812',
|
|
13
|
+
code: 'purchase',
|
|
14
|
+
},
|
|
15
|
+
user: {
|
|
16
|
+
ts: 'customer.HL',
|
|
17
|
+
email: 'jan.brzobohaty@crossmasters.com',
|
|
18
|
+
id: 'a2992fb8-40ac-4b88-9cf5-7fba02f1f611',
|
|
19
|
+
},
|
|
20
|
+
session: {
|
|
21
|
+
userAgent:
|
|
22
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15',
|
|
23
|
+
ip: '217.195.174.253',
|
|
24
|
+
},
|
|
25
|
+
permissions: [],
|
|
26
|
+
currencyCode: 'CZK',
|
|
27
|
+
publisher: {
|
|
28
|
+
code: 'www.smarty.cz',
|
|
29
|
+
tm: 'GTM-NVNTFG',
|
|
30
|
+
tmv: '193',
|
|
31
|
+
},
|
|
32
|
+
$schema: 'https://schema.measurementhub.net/mhub/2021-12-27/purchase',
|
|
33
|
+
id: '3511111111',
|
|
34
|
+
revenue: 10,
|
|
35
|
+
products: [
|
|
36
|
+
{
|
|
37
|
+
id: '67137',
|
|
38
|
+
price: 10,
|
|
39
|
+
quantity: 1,
|
|
40
|
+
category: 'Playstation',
|
|
41
|
+
masterType: 'Konzole',
|
|
25
42
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
{
|
|
44
|
+
id: '67137',
|
|
45
|
+
price: 20,
|
|
46
|
+
quantity: 1,
|
|
47
|
+
category: 'Monitor',
|
|
48
|
+
masterType: 'Video',
|
|
32
49
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
],
|
|
51
|
+
location: 'https://www.smarty.cz/checkoutSuccess',
|
|
52
|
+
referrer:
|
|
53
|
+
'https://www.smarty.cz/Order/AddReservation?productId=57873&shopAddressId=24798',
|
|
54
|
+
enqueuedAt: 1659006864038,
|
|
55
|
+
ads: [
|
|
56
|
+
{
|
|
57
|
+
adPlatform: 'affiliateport',
|
|
58
|
+
adCodes: {
|
|
59
|
+
transaction_id: '816f5670dbf52c3dc27a7e849903c327d705ef643993fbab3',
|
|
43
60
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
location: 'https://www.smarty.cz/checkoutSuccess',
|
|
53
|
-
referrer:
|
|
54
|
-
'https://www.smarty.cz/Order/AddReservation?productId=57873&shopAddressId=24798',
|
|
55
|
-
enqueuedAt: 1659006864038,
|
|
56
|
-
ads: [
|
|
57
|
-
{
|
|
58
|
-
adPlatform: 'affiliateport',
|
|
59
|
-
adCodes: {
|
|
60
|
-
transaction_id:
|
|
61
|
-
'816f5670dbf52c3dc27a7e849903c327d705ef643993fbab3',
|
|
62
|
-
},
|
|
63
|
-
visitAt: 1658392668000,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
EventProcessedUtcTime: '2022-07-28T11:54:50.2528883Z',
|
|
67
|
-
PartitionId: 0,
|
|
68
|
-
EventEnqueuedUtcTime: '2022-07-28T11:14:24.1170000Z',
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
await test(eventHubMessages);
|
|
61
|
+
visitAt: 1658392668000,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
EventProcessedUtcTime: '2022-07-28T11:54:50.2528883Z',
|
|
65
|
+
PartitionId: 0,
|
|
66
|
+
EventEnqueuedUtcTime: '2022-07-28T11:14:24.1170000Z',
|
|
67
|
+
};
|
|
68
|
+
await test(serviceBusMessage);
|
|
72
69
|
});
|
|
73
70
|
});
|
|
74
71
|
|
|
@@ -76,11 +73,11 @@ describe('test AffiliatePort publisher', function () {
|
|
|
76
73
|
* Test function
|
|
77
74
|
* @param [object] object obsahující nastavení testovací parametry
|
|
78
75
|
*/
|
|
79
|
-
async function test(
|
|
76
|
+
async function test(serviceBusMessage) {
|
|
80
77
|
try {
|
|
81
78
|
await defaultPublisher(
|
|
82
79
|
testUtils.context,
|
|
83
|
-
|
|
80
|
+
serviceBusMessage,
|
|
84
81
|
'AffiliatePort',
|
|
85
82
|
publisher,
|
|
86
83
|
trigger,
|
package/tests/CJ.js
CHANGED
|
@@ -6,101 +6,100 @@ const testUtils = require('../dist/index.js').testUtils;
|
|
|
6
6
|
|
|
7
7
|
describe('test CJ publisher', function () {
|
|
8
8
|
it('purchase', async function () {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ip: '89.177.126.237',
|
|
21
|
-
referrer: 'https://crossmasters.com/',
|
|
22
|
-
},
|
|
9
|
+
var serviceBusMessage = {
|
|
10
|
+
currencyCode: 'CZK',
|
|
11
|
+
event: {
|
|
12
|
+
region: 'MAIN',
|
|
13
|
+
id: '115169112-4870.1657003407533',
|
|
14
|
+
code: 'purchase',
|
|
15
|
+
},
|
|
16
|
+
session: {
|
|
17
|
+
userAgent:
|
|
18
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
|
|
19
|
+
ip: '89.177.126.237',
|
|
23
20
|
referrer: 'https://crossmasters.com/',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
publisher: {
|
|
31
|
-
code: 'mhubcloud.com',
|
|
32
|
-
tm: 'GTM-N7K9L4X',
|
|
33
|
-
tmv: '494',
|
|
21
|
+
},
|
|
22
|
+
referrer: 'https://crossmasters.com/',
|
|
23
|
+
permissions: [],
|
|
24
|
+
identity: {
|
|
25
|
+
piano: {
|
|
26
|
+
id: '1657003393413.319297501',
|
|
34
27
|
},
|
|
35
|
-
$schema: '/mhub/purchase',
|
|
36
|
-
id: '20162351',
|
|
37
|
-
revenue: 440,
|
|
38
|
-
products: [
|
|
39
|
-
{
|
|
40
|
-
id: 'Car',
|
|
41
|
-
price: 440,
|
|
42
|
-
quantity: 1,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
enqueuedAt: 1657003409370,
|
|
46
|
-
ads: [
|
|
47
|
-
{
|
|
48
|
-
adPlatform: 'cjaffiliate',
|
|
49
|
-
adCodes: {
|
|
50
|
-
cjevent: '816f5670dbf52c3dc27a7e849903c327d705ef643993fbab3',
|
|
51
|
-
},
|
|
52
|
-
visitAt: 1658392668000,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
28
|
},
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
29
|
+
publisher: {
|
|
30
|
+
code: 'mhubcloud.com',
|
|
31
|
+
tm: 'GTM-N7K9L4X',
|
|
32
|
+
tmv: '494',
|
|
33
|
+
},
|
|
34
|
+
$schema: '/mhub/purchase',
|
|
35
|
+
id: '20162351',
|
|
36
|
+
revenue: 440,
|
|
37
|
+
products: [
|
|
38
|
+
{
|
|
39
|
+
id: 'Car',
|
|
40
|
+
price: 440,
|
|
41
|
+
quantity: 1,
|
|
62
42
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
],
|
|
44
|
+
enqueuedAt: 1657003409370,
|
|
45
|
+
ads: [
|
|
46
|
+
{
|
|
47
|
+
adPlatform: 'cjaffiliate',
|
|
48
|
+
adCodes: {
|
|
49
|
+
cjevent: '816f5670dbf52c3dc27a7e849903c327d705ef643993fbab3',
|
|
50
|
+
},
|
|
51
|
+
visitAt: 1658392668000,
|
|
68
52
|
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
var serviceBusMessage2 = {
|
|
56
|
+
currencyCode: 'CZK',
|
|
57
|
+
event: {
|
|
58
|
+
region: 'MAIN',
|
|
59
|
+
id: '115169112-4870.1657003407533',
|
|
60
|
+
code: 'purchase',
|
|
61
|
+
},
|
|
62
|
+
session: {
|
|
63
|
+
userAgent:
|
|
64
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
|
|
65
|
+
ip: '89.177.126.237',
|
|
69
66
|
referrer: 'https://crossmasters.com/',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
},
|
|
68
|
+
referrer: 'https://crossmasters.com/',
|
|
69
|
+
permissions: [],
|
|
70
|
+
identity: {
|
|
71
|
+
piano: {
|
|
72
|
+
id: '1657003393413.319297501',
|
|
75
73
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
},
|
|
75
|
+
publisher: {
|
|
76
|
+
code: 'mhubcloud.com',
|
|
77
|
+
tm: 'GTM-N7K9L4X',
|
|
78
|
+
tmv: '494',
|
|
79
|
+
},
|
|
80
|
+
$schema: '/mhub/purchase',
|
|
81
|
+
id: '20162351',
|
|
82
|
+
revenue: 440,
|
|
83
|
+
products: [
|
|
84
|
+
{
|
|
85
|
+
id: 'Car',
|
|
86
|
+
price: 440,
|
|
87
|
+
quantity: 1,
|
|
80
88
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
quantity: 1,
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
enqueuedAt: 1657003409370,
|
|
92
|
-
ads: [
|
|
93
|
-
{
|
|
94
|
-
adPlatform: 'cjaffiliate',
|
|
95
|
-
adCodes: {
|
|
96
|
-
cjevent: '816f5670dbf52c3dc27a7e849903c327d705ef643993fbab3',
|
|
97
|
-
},
|
|
98
|
-
visitAt: 1658392668000,
|
|
89
|
+
],
|
|
90
|
+
enqueuedAt: 1657003409370,
|
|
91
|
+
ads: [
|
|
92
|
+
{
|
|
93
|
+
adPlatform: 'cjaffiliate',
|
|
94
|
+
adCodes: {
|
|
95
|
+
cjevent: '816f5670dbf52c3dc27a7e849903c327d705ef643993fbab3',
|
|
99
96
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
visitAt: 1658392668000,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
await test(serviceBusMessage);
|
|
102
|
+
await test(serviceBusMessage2);
|
|
104
103
|
});
|
|
105
104
|
});
|
|
106
105
|
|
|
@@ -108,10 +107,10 @@ describe('test CJ publisher', function () {
|
|
|
108
107
|
* Test function
|
|
109
108
|
* @param [object] object obsahující nastavení testovací parametry
|
|
110
109
|
*/
|
|
111
|
-
async function test(
|
|
110
|
+
async function test(serviceBusMessage) {
|
|
112
111
|
await defaultPublisher(
|
|
113
112
|
testUtils.context,
|
|
114
|
-
|
|
113
|
+
serviceBusMessage,
|
|
115
114
|
'CJ',
|
|
116
115
|
publisher,
|
|
117
116
|
trigger,
|
package/tests/Facebook.js
CHANGED
|
@@ -6,47 +6,45 @@ const testUtils = require('../dist/index.js').testUtils;
|
|
|
6
6
|
|
|
7
7
|
describe('test Facebook publisher', function () {
|
|
8
8
|
it('purchase', async function () {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ip: '89.177.126.237',
|
|
21
|
-
referrer: 'https://crossmasters.com/',
|
|
22
|
-
},
|
|
9
|
+
var serviceBusMessage = {
|
|
10
|
+
currencyCode: 'CZK',
|
|
11
|
+
event: {
|
|
12
|
+
region: 'MAIN',
|
|
13
|
+
id: '115169112-4870.1657003407533',
|
|
14
|
+
code: 'purchase',
|
|
15
|
+
},
|
|
16
|
+
session: {
|
|
17
|
+
userAgent:
|
|
18
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
|
|
19
|
+
ip: '89.177.126.237',
|
|
23
20
|
referrer: 'https://crossmasters.com/',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
publisher: {
|
|
31
|
-
code: 'mhubcloud.com',
|
|
32
|
-
tm: 'GTM-N7K9L4X',
|
|
33
|
-
tmv: '494',
|
|
21
|
+
},
|
|
22
|
+
referrer: 'https://crossmasters.com/',
|
|
23
|
+
permissions: [],
|
|
24
|
+
identity: {
|
|
25
|
+
piano: {
|
|
26
|
+
id: '1657003393413.319297501',
|
|
34
27
|
},
|
|
35
|
-
$schema: '/mhub/purchase',
|
|
36
|
-
id: '20162351',
|
|
37
|
-
revenue: 440,
|
|
38
|
-
products: [
|
|
39
|
-
{
|
|
40
|
-
id: 'Car',
|
|
41
|
-
price: 440,
|
|
42
|
-
quantity: 1,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
enqueuedAt: 1657003409370,
|
|
46
|
-
ads: [],
|
|
47
28
|
},
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
publisher: {
|
|
30
|
+
code: 'mhubcloud.com',
|
|
31
|
+
tm: 'GTM-N7K9L4X',
|
|
32
|
+
tmv: '494',
|
|
33
|
+
},
|
|
34
|
+
$schema: '/mhub/purchase',
|
|
35
|
+
id: '20162351',
|
|
36
|
+
revenue: 440,
|
|
37
|
+
products: [
|
|
38
|
+
{
|
|
39
|
+
id: 'Car',
|
|
40
|
+
price: 440,
|
|
41
|
+
quantity: 1,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
enqueuedAt: 1657003409370,
|
|
45
|
+
ads: [],
|
|
46
|
+
};
|
|
47
|
+
await test(serviceBusMessage);
|
|
50
48
|
});
|
|
51
49
|
});
|
|
52
50
|
|
|
@@ -54,11 +52,11 @@ describe('test Facebook publisher', function () {
|
|
|
54
52
|
* Test function
|
|
55
53
|
* @param [object] object obsahující nastavení testovací parametry
|
|
56
54
|
*/
|
|
57
|
-
async function test(
|
|
55
|
+
async function test(serviceBusMessage) {
|
|
58
56
|
try {
|
|
59
57
|
await defaultPublisher(
|
|
60
58
|
testUtils.context,
|
|
61
|
-
|
|
59
|
+
serviceBusMessage,
|
|
62
60
|
'Facebook',
|
|
63
61
|
publisher,
|
|
64
62
|
trigger,
|
|
@@ -6,47 +6,45 @@ const testUtils = require('../dist/index.js').testUtils;
|
|
|
6
6
|
|
|
7
7
|
describe('test GoogleAnalytics4 publisher', function () {
|
|
8
8
|
it('purchase', async function () {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ip: '89.177.126.237',
|
|
21
|
-
referrer: 'https://crossmasters.com/',
|
|
22
|
-
},
|
|
9
|
+
var serviceBusMessage = {
|
|
10
|
+
currencyCode: 'CZK',
|
|
11
|
+
event: {
|
|
12
|
+
region: 'MAIN',
|
|
13
|
+
id: '115169112-4870.1657003407533',
|
|
14
|
+
code: 'pageview',
|
|
15
|
+
},
|
|
16
|
+
session: {
|
|
17
|
+
userAgent:
|
|
18
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
|
|
19
|
+
ip: '89.177.126.237',
|
|
23
20
|
referrer: 'https://crossmasters.com/',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
publisher: {
|
|
31
|
-
code: 'mhubcloud.com',
|
|
32
|
-
tm: 'GTM-N7K9L4X',
|
|
33
|
-
tmv: '494',
|
|
21
|
+
},
|
|
22
|
+
referrer: 'https://crossmasters.com/',
|
|
23
|
+
permissions: [],
|
|
24
|
+
identity: {
|
|
25
|
+
piano: {
|
|
26
|
+
id: '1657003393413.319297501',
|
|
34
27
|
},
|
|
35
|
-
$schema: '/mhub/purchase',
|
|
36
|
-
id: '20162351',
|
|
37
|
-
revenue: 440,
|
|
38
|
-
products: [
|
|
39
|
-
{
|
|
40
|
-
id: 'Car',
|
|
41
|
-
price: 440,
|
|
42
|
-
quantity: 1,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
enqueuedAt: 1657003409370,
|
|
46
|
-
ads: [],
|
|
47
28
|
},
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
publisher: {
|
|
30
|
+
code: 'mhubcloud.com',
|
|
31
|
+
tm: 'GTM-N7K9L4X',
|
|
32
|
+
tmv: '494',
|
|
33
|
+
},
|
|
34
|
+
$schema: '/mhub/purchase',
|
|
35
|
+
id: '20162351',
|
|
36
|
+
revenue: 440,
|
|
37
|
+
products: [
|
|
38
|
+
{
|
|
39
|
+
id: 'Car',
|
|
40
|
+
price: 440,
|
|
41
|
+
quantity: 1,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
enqueuedAt: 1657003409370,
|
|
45
|
+
ads: [],
|
|
46
|
+
};
|
|
47
|
+
await test(serviceBusMessage);
|
|
50
48
|
});
|
|
51
49
|
});
|
|
52
50
|
|
|
@@ -54,10 +52,10 @@ describe('test GoogleAnalytics4 publisher', function () {
|
|
|
54
52
|
* Test function
|
|
55
53
|
* @param [object] object obsahující nastavení testovací parametry
|
|
56
54
|
*/
|
|
57
|
-
async function test(
|
|
55
|
+
async function test(serviceBusMessage) {
|
|
58
56
|
await defaultPublisher(
|
|
59
57
|
testUtils.context,
|
|
60
|
-
|
|
58
|
+
serviceBusMessage,
|
|
61
59
|
'GoogleAnalytics4',
|
|
62
60
|
publisher,
|
|
63
61
|
trigger,
|
package/tests/Piano.js
CHANGED
|
@@ -6,47 +6,45 @@ var assert = require('assert');
|
|
|
6
6
|
|
|
7
7
|
describe('test Piano publisher', function () {
|
|
8
8
|
it('purchase', async function () {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ip: '89.177.126.237',
|
|
21
|
-
referrer: 'https://crossmasters.com/',
|
|
22
|
-
},
|
|
9
|
+
var serviceBusMessage = {
|
|
10
|
+
currencyCode: 'CZK',
|
|
11
|
+
event: {
|
|
12
|
+
region: 'MAIN',
|
|
13
|
+
id: '115169112-4870.1657003407533',
|
|
14
|
+
code: 'purchase',
|
|
15
|
+
},
|
|
16
|
+
session: {
|
|
17
|
+
userAgent:
|
|
18
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
|
|
19
|
+
ip: '89.177.126.237',
|
|
23
20
|
referrer: 'https://crossmasters.com/',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
publisher: {
|
|
31
|
-
code: 'mhubcloud.com',
|
|
32
|
-
tm: 'GTM-N7K9L4X',
|
|
33
|
-
tmv: '494',
|
|
21
|
+
},
|
|
22
|
+
referrer: 'https://crossmasters.com/',
|
|
23
|
+
permissions: [],
|
|
24
|
+
identity: {
|
|
25
|
+
piano: {
|
|
26
|
+
id: '1657003393413.319297501',
|
|
34
27
|
},
|
|
35
|
-
$schema: '/mhub/purchase',
|
|
36
|
-
id: '20162351',
|
|
37
|
-
revenue: 440,
|
|
38
|
-
products: [
|
|
39
|
-
{
|
|
40
|
-
id: 'Car',
|
|
41
|
-
price: 440,
|
|
42
|
-
quantity: 1,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
enqueuedAt: 1657003409370,
|
|
46
|
-
ads: [],
|
|
47
28
|
},
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
publisher: {
|
|
30
|
+
code: 'mhubcloud.com',
|
|
31
|
+
tm: 'GTM-N7K9L4X',
|
|
32
|
+
tmv: '494',
|
|
33
|
+
},
|
|
34
|
+
$schema: '/mhub/purchase',
|
|
35
|
+
id: '20162351',
|
|
36
|
+
revenue: 440,
|
|
37
|
+
products: [
|
|
38
|
+
{
|
|
39
|
+
id: 'Car',
|
|
40
|
+
price: 440,
|
|
41
|
+
quantity: 1,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
enqueuedAt: 1657003409370,
|
|
45
|
+
ads: [],
|
|
46
|
+
};
|
|
47
|
+
await test(serviceBusMessage);
|
|
50
48
|
});
|
|
51
49
|
});
|
|
52
50
|
|
|
@@ -54,11 +52,11 @@ describe('test Piano publisher', function () {
|
|
|
54
52
|
* Test function
|
|
55
53
|
* @param [object] object obsahující nastavení testovací parametry
|
|
56
54
|
*/
|
|
57
|
-
async function test(
|
|
55
|
+
async function test(serviceBusMessage) {
|
|
58
56
|
try {
|
|
59
57
|
await defaultPublisher(
|
|
60
58
|
testUtils.context,
|
|
61
|
-
|
|
59
|
+
serviceBusMessage,
|
|
62
60
|
'Piano',
|
|
63
61
|
publisher,
|
|
64
62
|
trigger,
|
|
@@ -6,38 +6,36 @@ const testUtils = require('../dist/index.js').testUtils;
|
|
|
6
6
|
|
|
7
7
|
describe('test UniversalAnalytics publisher', function () {
|
|
8
8
|
it('pageview', async function () {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
ip: '89.177.126.237',
|
|
21
|
-
referrer: 'https://crossmasters.com/',
|
|
22
|
-
},
|
|
9
|
+
var serviceBusMessage = {
|
|
10
|
+
currencyCode: 'CZK',
|
|
11
|
+
event: {
|
|
12
|
+
region: 'MAIN',
|
|
13
|
+
id: '115169112-4870.1657003407533',
|
|
14
|
+
code: 'pageview',
|
|
15
|
+
},
|
|
16
|
+
session: {
|
|
17
|
+
userAgent:
|
|
18
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
|
|
19
|
+
ip: '89.177.126.237',
|
|
23
20
|
referrer: 'https://crossmasters.com/',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
publisher: {
|
|
31
|
-
code: 'mhubcloud.com',
|
|
32
|
-
tm: 'GTM-N7K9L4X',
|
|
33
|
-
tmv: '494',
|
|
21
|
+
},
|
|
22
|
+
referrer: 'https://crossmasters.com/',
|
|
23
|
+
permissions: [],
|
|
24
|
+
identity: {
|
|
25
|
+
piano: {
|
|
26
|
+
id: '1657003393413.319297501',
|
|
34
27
|
},
|
|
35
|
-
$schema: '/mhub/pageview',
|
|
36
|
-
enqueuedAt: 1657003409370,
|
|
37
|
-
ads: [],
|
|
38
28
|
},
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
publisher: {
|
|
30
|
+
code: 'mhubcloud.com',
|
|
31
|
+
tm: 'GTM-N7K9L4X',
|
|
32
|
+
tmv: '494',
|
|
33
|
+
},
|
|
34
|
+
$schema: '/mhub/pageview',
|
|
35
|
+
enqueuedAt: 1657003409370,
|
|
36
|
+
ads: [],
|
|
37
|
+
};
|
|
38
|
+
await test(serviceBusMessage);
|
|
41
39
|
});
|
|
42
40
|
});
|
|
43
41
|
|
|
@@ -45,10 +43,10 @@ describe('test UniversalAnalytics publisher', function () {
|
|
|
45
43
|
* Test function
|
|
46
44
|
* @param [object] object obsahující nastavení testovací parametry
|
|
47
45
|
*/
|
|
48
|
-
async function test(
|
|
46
|
+
async function test(serviceBusMessage) {
|
|
49
47
|
await defaultPublisher(
|
|
50
48
|
testUtils.context,
|
|
51
|
-
|
|
49
|
+
serviceBusMessage,
|
|
52
50
|
'UniversalAnalytics',
|
|
53
51
|
publisher,
|
|
54
52
|
trigger,
|