@mhubcloud/tms_core 3.6.0-beta.0 → 3.6.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.
Files changed (2) hide show
  1. package/dist/index.js +32 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -54,6 +54,8 @@ __export(utils_exports, {
54
54
  EventPublisherBase: () => EventPublisherBase,
55
55
  encodeEmail: () => encodeEmail,
56
56
  extractAdCode: () => extractAdCode,
57
+ extractClickId: () => extractClickId,
58
+ extractPlatformClicks: () => extractPlatformClicks,
57
59
  extractPlatformCodes: () => extractPlatformCodes,
58
60
  flatten: () => flatten,
59
61
  formatError: () => formatError,
@@ -180,6 +182,23 @@ function extractAdCode(data, adPlatform, adCode, format = null) {
180
182
  }
181
183
  return null;
182
184
  }
185
+ function extractClickId(ads, platform, clickId, format = null) {
186
+ const ad = ads.filter((x) => {
187
+ return x.adPlatforms.includes(platform);
188
+ }).sort((a, b) => b.visitAt - a.visitAt)[0];
189
+ if (!ad) {
190
+ return null;
191
+ }
192
+ const clickIdValue = ad.adCodes ? ad.adCodes[clickId] : null;
193
+ if (clickIdValue) {
194
+ const ret = { code: clickIdValue, visitAt: ad.visitAt };
195
+ if (format) {
196
+ return format(ret, ad);
197
+ }
198
+ return ret;
199
+ }
200
+ return null;
201
+ }
183
202
  function extractPlatformCodes(data, adPlatform) {
184
203
  const platformCodes = data.ads.filter((x) => {
185
204
  return x.adPlatform === adPlatform;
@@ -193,6 +212,19 @@ function extractPlatformCodes(data, adPlatform) {
193
212
  };
194
213
  }
195
214
  }
215
+ function extractPlatformClicks(ads, platform) {
216
+ const platformCodes = ads.filter((x) => {
217
+ return x.adPlatforms.includes(platform);
218
+ }).sort((a, b) => b.visitAt - a.visitAt)[0];
219
+ if (!platformCodes) {
220
+ return null;
221
+ } else {
222
+ return {
223
+ adCodes: platformCodes.adCodes,
224
+ visitAt: platformCodes.visitAt
225
+ };
226
+ }
227
+ }
196
228
  function flatten(event, separator = "_") {
197
229
  return Object.assign(
198
230
  {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhubcloud/tms_core",
3
- "version": "3.6.0-beta.0",
3
+ "version": "3.6.0",
4
4
  "description": "Core function for mHub Cloud TMS publishers",
5
5
  "homepage": "https://mhubcloud.com/",
6
6
  "license": "Apache 2.0",