@mhubcloud/tms_core 3.4.3 → 3.4.4
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/package.json +1 -1
- package/src/broker.ts +2 -0
- package/src/defaultPublisher.ts +10 -2
- package/src/index.ts +3 -3
- package/src/publishers/googleAds.ts +1 -1
- package/publishers/TableStorage.js +0 -46
package/package.json
CHANGED
package/src/broker.ts
CHANGED
|
@@ -104,6 +104,8 @@ function matchEvent(event: EventInfo, publisherEvent: string | PublisherEvent) {
|
|
|
104
104
|
if (!paramMatch) {
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
|
+
} else if (publisherEventParam && !eventParam) {
|
|
108
|
+
return false;
|
|
107
109
|
} else {
|
|
108
110
|
throw new Error('Unexpected formatting in publisher configuration');
|
|
109
111
|
}
|
package/src/defaultPublisher.ts
CHANGED
|
@@ -41,7 +41,10 @@ export async function defaultPublisher(
|
|
|
41
41
|
if (result.status === 'rejected') {
|
|
42
42
|
if (result.reason instanceof Error) {
|
|
43
43
|
const formattedError = utils.formatError(result.reason);
|
|
44
|
-
utils.logException(
|
|
44
|
+
utils.logException(
|
|
45
|
+
azureFunctionContext.log,
|
|
46
|
+
new Error(formattedError.message),
|
|
47
|
+
);
|
|
45
48
|
throw formattedError;
|
|
46
49
|
} else {
|
|
47
50
|
const formattedError = utils.formatError(
|
|
@@ -49,7 +52,10 @@ export async function defaultPublisher(
|
|
|
49
52
|
? JSON.stringify(result.reason)
|
|
50
53
|
: (result.reason as Error['message']),
|
|
51
54
|
);
|
|
52
|
-
utils.logException(
|
|
55
|
+
utils.logException(
|
|
56
|
+
azureFunctionContext.log,
|
|
57
|
+
new Error(formattedError.message),
|
|
58
|
+
);
|
|
53
59
|
throw formattedError;
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -106,6 +112,7 @@ async function processMessage(
|
|
|
106
112
|
publishedAny = true;
|
|
107
113
|
} else {
|
|
108
114
|
utils.logException(
|
|
115
|
+
log,
|
|
109
116
|
new Error(
|
|
110
117
|
`The message has not been published. Source: ${platformPublisher.source}`,
|
|
111
118
|
),
|
|
@@ -114,6 +121,7 @@ async function processMessage(
|
|
|
114
121
|
}
|
|
115
122
|
if (!publishedAny) {
|
|
116
123
|
utils.logException(
|
|
124
|
+
log,
|
|
117
125
|
new Error(
|
|
118
126
|
'The message has not been published to any publisher configuration',
|
|
119
127
|
),
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { defaultPublisher } from './defaultPublisher';
|
|
|
3
3
|
import { affiliatePort } from './publishers/affiliatePort';
|
|
4
4
|
import { cj } from './publishers/cj';
|
|
5
5
|
import { facebook } from './publishers/facebook';
|
|
6
|
-
import { googleAds
|
|
6
|
+
import { googleAds } from './publishers/googleAds';
|
|
7
7
|
import { googleAnalytics4 } from './publishers/googleAnalytics4';
|
|
8
8
|
import { piano } from './publishers/piano';
|
|
9
9
|
import { universalAnalytics } from './publishers/universalAnalytics';
|
|
@@ -15,8 +15,8 @@ export const publisher = {
|
|
|
15
15
|
Facebook: facebook,
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
17
17
|
CJ: cj,
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
|
-
GoogleAds: googleAds
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
|
+
GoogleAds: googleAds,
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
21
21
|
GoogleAnalytics4: googleAnalytics4,
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -3,7 +3,7 @@ import * as utils from './../utils/utils';
|
|
|
3
3
|
import { EventToLog } from '../types/EventToLog';
|
|
4
4
|
import { TypeSafeObject } from '../types/UtilTypes';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface GoogleAdsPlatformPublisher {
|
|
7
7
|
source: string;
|
|
8
8
|
publish: (
|
|
9
9
|
log: Logger,
|
|
@@ -1,46 +0,0 @@
|
|
|
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 coming from EventHub to data for further processing
|
|
8
|
-
* @param {Object} data The data coming 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
|
-
};
|