@mhubcloud/tms_core 3.4.0 → 3.4.2
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 +33 -11
- package/package.json +1 -1
- package/src/publishers/googleAds.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -302,7 +302,7 @@ var cosmosContainerName = process.env.CosmosDbEventsContainerName;
|
|
|
302
302
|
var serviceBusClient;
|
|
303
303
|
var cosmosClient;
|
|
304
304
|
var senders = {};
|
|
305
|
-
function resolveEvent(
|
|
305
|
+
function resolveEvent(event, publisherConfig) {
|
|
306
306
|
if (!publisherConfig) {
|
|
307
307
|
const envConfig = process.env.Broker_PublisherConfig;
|
|
308
308
|
publisherConfig = envConfig ? JSON.parse(envConfig) : {};
|
|
@@ -314,14 +314,11 @@ function resolveEvent(eventCode, publisherConfig) {
|
|
|
314
314
|
if (publisherEvents[0] === "*") {
|
|
315
315
|
let matchesExcluded = false;
|
|
316
316
|
if (Array.isArray(publisherEvents[1]) && publisherEvents[1].length > 0) {
|
|
317
|
-
for (const
|
|
317
|
+
for (const publisherEvent of publisherEvents[1]) {
|
|
318
318
|
if (matchesExcluded) {
|
|
319
319
|
break;
|
|
320
320
|
}
|
|
321
|
-
|
|
322
|
-
const regex = new RegExp(event);
|
|
323
|
-
matchesExcluded = regex.test(eventCode);
|
|
324
|
-
}
|
|
321
|
+
matchesExcluded = matchEvent(event, publisherEvent);
|
|
325
322
|
}
|
|
326
323
|
}
|
|
327
324
|
if (!matchesExcluded) {
|
|
@@ -329,11 +326,11 @@ function resolveEvent(eventCode, publisherConfig) {
|
|
|
329
326
|
}
|
|
330
327
|
} else {
|
|
331
328
|
let match = false;
|
|
332
|
-
for (const
|
|
333
|
-
if (
|
|
334
|
-
|
|
335
|
-
match = regex.test(eventCode);
|
|
329
|
+
for (const publisherEvent of publisherEvents) {
|
|
330
|
+
if (Array.isArray(publisherEvent)) {
|
|
331
|
+
continue;
|
|
336
332
|
}
|
|
333
|
+
match = matchEvent(event, publisherEvent);
|
|
337
334
|
if (match) {
|
|
338
335
|
publishers.push(publisher2);
|
|
339
336
|
}
|
|
@@ -346,6 +343,31 @@ function resolveEvent(eventCode, publisherConfig) {
|
|
|
346
343
|
}
|
|
347
344
|
return publishers;
|
|
348
345
|
}
|
|
346
|
+
function matchEvent(event, publisherEvent) {
|
|
347
|
+
if (typeof publisherEvent === "string") {
|
|
348
|
+
const regex = new RegExp(publisherEvent);
|
|
349
|
+
const match = regex.test(event.code);
|
|
350
|
+
return match;
|
|
351
|
+
} else if (typeof publisherEvent === "object") {
|
|
352
|
+
let paramMatch = true;
|
|
353
|
+
for (const key of Object.keys(publisherEvent)) {
|
|
354
|
+
const publisherEventParam = publisherEvent[key];
|
|
355
|
+
const eventParam = event[key];
|
|
356
|
+
if (typeof publisherEventParam === "string" && typeof eventParam === "string") {
|
|
357
|
+
const regex = new RegExp(publisherEventParam);
|
|
358
|
+
paramMatch = regex.test(eventParam);
|
|
359
|
+
if (!paramMatch) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
throw new Error("Unexpected formatting in publisher configuration");
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return true;
|
|
367
|
+
} else {
|
|
368
|
+
throw new Error("Unexpected formatting in publisher configuration");
|
|
369
|
+
}
|
|
370
|
+
}
|
|
349
371
|
async function dispatchEvent(message, queues) {
|
|
350
372
|
if (!serviceBusClient) {
|
|
351
373
|
if (!serviceBusConnectionString) {
|
|
@@ -643,7 +665,7 @@ var googleAds = {
|
|
|
643
665
|
},
|
|
644
666
|
body: JSON.stringify(body)
|
|
645
667
|
};
|
|
646
|
-
const baseUrl = `https://googleads.googleapis.com/
|
|
668
|
+
const baseUrl = `https://googleads.googleapis.com/v20/customers/${config.customerId}:uploadClickConversions`;
|
|
647
669
|
const response = await fetch(baseUrl, requestOptions);
|
|
648
670
|
const responseJson = await response.json();
|
|
649
671
|
const knownErrors = [
|
package/package.json
CHANGED
|
@@ -101,7 +101,7 @@ export const googleAds: GoogleAdsPlatformPublisher = {
|
|
|
101
101
|
body: JSON.stringify(body),
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
const baseUrl = `https://googleads.googleapis.com/
|
|
104
|
+
const baseUrl = `https://googleads.googleapis.com/v20/customers/${config.customerId}:uploadClickConversions`;
|
|
105
105
|
|
|
106
106
|
const response = await fetch(baseUrl, requestOptions);
|
|
107
107
|
const responseJson: GoogleAdsResponse = await response.json();
|