@mhubcloud/tms_core 3.5.0 → 3.5.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.
package/dist/index.js CHANGED
@@ -100,9 +100,14 @@ function logMessage(level, message, properties) {
100
100
  properties
101
101
  });
102
102
  }
103
- function logEvent(publisher2, event, region, id, status, payload) {
104
- const message = status >= 200 && status < 300 ? "Event dispatched to platform" : "Event dispatch failed";
105
- const properties = {
103
+ function logEvent(publisher2, event, region, status, payload, id) {
104
+ let message = "";
105
+ if (status || status === 0) {
106
+ message = status >= 200 && status < 300 ? "Event dispatched to platform" : "Event dispatch failed";
107
+ } else {
108
+ message = "Event dispatched to platform";
109
+ }
110
+ let properties = {
106
111
  publisher: publisher2,
107
112
  event,
108
113
  region,
@@ -110,6 +115,7 @@ function logEvent(publisher2, event, region, id, status, payload) {
110
115
  status,
111
116
  payload
112
117
  };
118
+ properties = removeUndefined(properties);
113
119
  logMessage(1, message, properties);
114
120
  }
115
121
  function logException(exception) {
@@ -236,9 +242,9 @@ async function handlePlatformRequest({
236
242
  source,
237
243
  event.event,
238
244
  event.region,
239
- event.id,
240
245
  0,
241
- requestOptions.body ? JSON.stringify(requestOptions.body) : void 0
246
+ requestOptions.body ? JSON.stringify(requestOptions.body) : void 0,
247
+ event.id
242
248
  );
243
249
  throw e;
244
250
  }
@@ -255,9 +261,9 @@ async function handlePlatformRequest({
255
261
  source,
256
262
  event.event,
257
263
  event.region,
258
- event.id,
259
264
  rawPlatformResponse.status,
260
- requestOptions.body ? JSON.stringify(requestOptions.body) : void 0
265
+ requestOptions.body ? JSON.stringify(requestOptions.body) : void 0,
266
+ event.id
261
267
  );
262
268
  if (!rawPlatformResponse.ok) {
263
269
  throw new Error(
@@ -704,9 +710,9 @@ var googleAds = {
704
710
  this.source,
705
711
  event.event,
706
712
  event.region,
707
- event.id,
708
713
  status,
709
- requestOptions.body
714
+ requestOptions.body,
715
+ event.id
710
716
  );
711
717
  if (error) {
712
718
  throw new Error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhubcloud/tms_core",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Core function for mHub Cloud TMS publishers",
5
5
  "homepage": "https://mhubcloud.com/",
6
6
  "license": "Apache 2.0",
@@ -137,9 +137,9 @@ export const googleAds: GoogleAdsPlatformPublisher = {
137
137
  this.source,
138
138
  event.event,
139
139
  event.region,
140
- event.id,
141
140
  status,
142
141
  requestOptions.body,
142
+ event.id,
143
143
  );
144
144
 
145
145
  if (error) {
@@ -73,15 +73,22 @@ export function logEvent(
73
73
  publisher: string,
74
74
  event: string,
75
75
  region: string,
76
- id: string,
77
76
  status: number,
78
- payload?: string,
77
+ payload: string | undefined,
78
+ id: string,
79
79
  ): void {
80
- const message =
81
- status >= 200 && status < 300
82
- ? 'Event dispatched to platform'
83
- : 'Event dispatch failed';
84
- const properties: Telemetry['properties'] = {
80
+ let message = '';
81
+
82
+ if (status || status === 0) {
83
+ message =
84
+ status >= 200 && status < 300
85
+ ? 'Event dispatched to platform'
86
+ : 'Event dispatch failed';
87
+ } else {
88
+ message = 'Event dispatched to platform';
89
+ }
90
+
91
+ let properties: Telemetry['properties'] = {
85
92
  publisher,
86
93
  event,
87
94
  region,
@@ -89,6 +96,9 @@ export function logEvent(
89
96
  status,
90
97
  payload,
91
98
  };
99
+
100
+ properties = removeUndefined(properties);
101
+
92
102
  logMessage(1, message, properties);
93
103
  }
94
104
 
@@ -339,9 +349,9 @@ export async function handlePlatformRequest({
339
349
  source,
340
350
  event.event,
341
351
  event.region,
342
- event.id,
343
352
  0,
344
353
  requestOptions.body ? JSON.stringify(requestOptions.body) : undefined,
354
+ event.id,
345
355
  );
346
356
  throw e;
347
357
  }
@@ -360,9 +370,9 @@ export async function handlePlatformRequest({
360
370
  source,
361
371
  event.event,
362
372
  event.region,
363
- event.id,
364
373
  rawPlatformResponse.status,
365
374
  requestOptions.body ? JSON.stringify(requestOptions.body) : undefined,
375
+ event.id,
366
376
  );
367
377
 
368
378
  if (!rawPlatformResponse.ok) {