@ada-support/embed2 1.0.62 → 1.0.63

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.
@@ -1,5 +1,5 @@
1
- import { TrackEventParams } from "common/types";
2
- import { StartOptions } from "common/types/store-state";
3
- import { BusinessEvent } from "./types";
1
+ import type { TrackEventParams } from "common/types";
2
+ import type { StartOptions } from "common/types/store-state";
3
+ import type { BusinessEvent } from "./types";
4
4
  export declare function trackEventImpl(adaSettings: StartOptions, chatterToken: string, params: TrackEventParams): void;
5
5
  export declare const getEventsToTrigger: (businessEvents: BusinessEvent[]) => BusinessEvent[];
@@ -1,17 +1,8 @@
1
- export interface URLMatchTriggerCondition {
2
- type: "url-match";
3
- conditions_any: [
4
- {
5
- type: "ends-with" | "contains" | "equals" | "regex";
6
- value: string;
7
- }
8
- ];
9
- }
10
- export declare type TriggerCondition = URLMatchTriggerCondition;
1
+ import type { URLMatchTriggerCondition } from "common/types/helpers";
11
2
  export interface BusinessEvent {
12
3
  event_key: string;
13
4
  value: number;
14
- trigger_conditions: TriggerCondition[];
5
+ trigger_conditions: URLMatchTriggerCondition[];
15
6
  }
16
7
  export interface BusinessEventsResponse {
17
8
  business_events: BusinessEvent[];
@@ -1,22 +1,5 @@
1
- export declare type TriggerCondition = URLMatchTriggerCondition | DateTimeTriggerCondition;
1
+ import type { TriggerCondition } from "common/types/helpers";
2
2
  export declare type GoalEvent = unknown;
3
- export interface URLMatchTriggerCondition {
4
- type: "url-match";
5
- conditions_any: [
6
- {
7
- type: "ends-with" | "contains" | "equals" | "regex";
8
- value: string;
9
- }
10
- ];
11
- }
12
- export interface DateTimeTriggerCondition {
13
- type: "datetime";
14
- timezone: string;
15
- condition: {
16
- operator: "before-exclusive" | "after-inclusive";
17
- datetime: string;
18
- };
19
- }
20
3
  export declare type CampaignFrequency = "every-time" | "once-per-session" | "once-per-user";
21
4
  export interface MarketingCampaign {
22
5
  _id: string;
@@ -1,4 +1,4 @@
1
- import { DateTimeTriggerCondition, TriggerCondition, URLMatchTriggerCondition } from "./types";
1
+ import type { DateTimeTriggerCondition, TriggerCondition, URLMatchTriggerCondition } from "common/types/helpers";
2
2
  export declare const evalUrlMatchTriggerCondition: (triggerCondition: URLMatchTriggerCondition, url: string) => boolean;
3
3
  export declare const evalDatetimeTriggerCondition: (triggerCondition: DateTimeTriggerCondition, currentDateTime: Date) => boolean;
4
4
  export declare const evalTriggerCondition: (triggerCondition: TriggerCondition) => boolean;
@@ -1,3 +1,21 @@
1
1
  export declare type PartialRecord<K extends keyof any, T> = {
2
2
  [P in K]?: T;
3
3
  };
4
+ export declare type TriggerCondition = URLMatchTriggerCondition | DateTimeTriggerCondition;
5
+ export interface URLMatchTriggerCondition {
6
+ type: "url-match";
7
+ conditions_any: [
8
+ {
9
+ type: "ends-with" | "contains" | "equals" | "regex";
10
+ value: string;
11
+ }
12
+ ];
13
+ }
14
+ export interface DateTimeTriggerCondition {
15
+ type: "datetime";
16
+ timezone: string;
17
+ condition: {
18
+ operator: "before-exclusive" | "after-inclusive";
19
+ datetime: string;
20
+ };
21
+ }
@@ -570,7 +570,7 @@ var browserPerformanceTimeOrigin = (function () {
570
570
 
571
571
  /***/ }),
572
572
 
573
- /***/ 9262:
573
+ /***/ 5265:
574
574
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
575
575
 
576
576
  "use strict";
@@ -8788,7 +8788,7 @@ var client = new error_tracker_BrowserClient({
8788
8788
  return event;
8789
8789
  },
8790
8790
  environment: "production",
8791
- release: "1.0.62-e5d1f99",
8791
+ release: "1.0.63-1d1b0f6",
8792
8792
  sampleRate: 0.25,
8793
8793
  autoSessionTracking: false,
8794
8794
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -9488,7 +9488,7 @@ function getEmbedURL(_ref) {
9488
9488
  polyfillVersionString = "legacy";
9489
9489
  }
9490
9490
 
9491
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "e5d1f99", "/index.html");
9491
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "1d1b0f6", "/index.html");
9492
9492
  }
9493
9493
  /**
9494
9494
  * Generate the Chat / API URL
@@ -10201,7 +10201,38 @@ var ends_with_default = /*#__PURE__*/__webpack_require__.n(ends_with);
10201
10201
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/slice.js
10202
10202
  var slice = __webpack_require__(3649);
10203
10203
  var slice_default = /*#__PURE__*/__webpack_require__.n(slice);
10204
- ;// CONCATENATED MODULE: ./src/businessEvents/TriggerConditionEvaluator.ts
10204
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/trim.js
10205
+ var trim = __webpack_require__(5843);
10206
+ var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
10207
+ ;// CONCATENATED MODULE: ./src/common/helpers/get-intro-for-url.ts
10208
+
10209
+
10210
+ function getProcessedPath(path) {
10211
+ var regex = /^http(s)?:\/\/(www.)?/;
10212
+ return trim_default()(path).call(path).replace(regex, "");
10213
+ }
10214
+ function getPathSearchRegex(path) {
10215
+ var params = path.split("?");
10216
+
10217
+ if (params.length > 1) {
10218
+ var _context;
10219
+
10220
+ var escapedParams = encodeURI(params[1]);
10221
+ return new RegExp(concat_default()(_context = "^".concat(params[0], "\\?")).call(_context, escapedParams, "$"));
10222
+ }
10223
+
10224
+ var newPath = path.replace("*", ".*");
10225
+ return new RegExp("^".concat(newPath, "$"));
10226
+ }
10227
+ function doesUrlMatchPath(url, path) {
10228
+ var processedUrl = getProcessedPath(url);
10229
+ var processedPath = getProcessedPath(path);
10230
+ var pathRegex = getPathSearchRegex(processedPath);
10231
+ var matches = pathRegex.exec(processedUrl);
10232
+ return matches !== null;
10233
+ }
10234
+ ;// CONCATENATED MODULE: ./src/common/helpers/TriggerConditionEvaluator.ts
10235
+
10205
10236
 
10206
10237
 
10207
10238
 
@@ -10233,7 +10264,9 @@ var evalUrlMatchTriggerCondition = function evalUrlMatchTriggerCondition(trigger
10233
10264
  return includes_default()(url).call(url, condition.value);
10234
10265
 
10235
10266
  case "equals":
10236
- return urlWithoutQueryParams === condition.value;
10267
+ {
10268
+ return doesUrlMatchPath(urlWithoutQueryParams, condition.value);
10269
+ }
10237
10270
 
10238
10271
  case "regex":
10239
10272
  {
@@ -10247,11 +10280,29 @@ var evalUrlMatchTriggerCondition = function evalUrlMatchTriggerCondition(trigger
10247
10280
  }
10248
10281
  });
10249
10282
  };
10283
+ var evalDatetimeTriggerCondition = function evalDatetimeTriggerCondition(triggerCondition, currentDateTime) {
10284
+ var conditionDatetime = new Date(triggerCondition.condition.datetime);
10285
+
10286
+ switch (triggerCondition.condition.operator) {
10287
+ case "before-exclusive":
10288
+ return currentDateTime < conditionDatetime;
10289
+
10290
+ case "after-inclusive":
10291
+ return currentDateTime >= conditionDatetime;
10292
+ // If an unknown comparator is found, ignore the trigger condition - do not block campaign
10293
+
10294
+ default:
10295
+ return true;
10296
+ }
10297
+ };
10250
10298
  var evalTriggerCondition = function evalTriggerCondition(triggerCondition) {
10251
10299
  switch (triggerCondition.type) {
10252
10300
  case "url-match":
10253
10301
  return evalUrlMatchTriggerCondition(triggerCondition, window.location.href);
10254
- // If an unknown trigger type is found, ignore the trigger condition - do not block event
10302
+
10303
+ case "datetime":
10304
+ return evalDatetimeTriggerCondition(triggerCondition, new Date());
10305
+ // If an unknown trigger type is found, ignore the trigger condition - do not block campaign
10255
10306
 
10256
10307
  default:
10257
10308
  return true;
@@ -10346,113 +10397,6 @@ var get_browser_language_getBrowserLanguage = function getBrowserLanguage() {
10346
10397
  ;// CONCATENATED MODULE: ./src/services/helpers.ts
10347
10398
  var NO_OP_FUNCTION = function NO_OP_FUNCTION() {// Do nothing
10348
10399
  };
10349
- // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/trim.js
10350
- var trim = __webpack_require__(5843);
10351
- var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
10352
- ;// CONCATENATED MODULE: ./src/common/helpers/get-intro-for-url.ts
10353
-
10354
-
10355
- function getProcessedPath(path) {
10356
- var regex = /^http(s)?:\/\/(www.)?/;
10357
- return trim_default()(path).call(path).replace(regex, "");
10358
- }
10359
- function getPathSearchRegex(path) {
10360
- var params = path.split("?");
10361
-
10362
- if (params.length > 1) {
10363
- var _context;
10364
-
10365
- var escapedParams = encodeURI(params[1]);
10366
- return new RegExp(concat_default()(_context = "^".concat(params[0], "\\?")).call(_context, escapedParams, "$"));
10367
- }
10368
-
10369
- var newPath = path.replace("*", ".*");
10370
- return new RegExp("^".concat(newPath, "$"));
10371
- }
10372
- function doesUrlMatchPath(url, path) {
10373
- var processedUrl = getProcessedPath(url);
10374
- var processedPath = getProcessedPath(path);
10375
- var pathRegex = getPathSearchRegex(processedPath);
10376
- var matches = pathRegex.exec(processedUrl);
10377
- return matches !== null;
10378
- }
10379
- ;// CONCATENATED MODULE: ./src/campaigns/TriggerConditionEvaluator.ts
10380
-
10381
-
10382
-
10383
-
10384
-
10385
- var TriggerConditionEvaluator_stripTrailingSlash = function stripTrailingSlash(url) {
10386
- return ends_with_default()(url).call(url, "/") ? slice_default()(url).call(url, 0, -1) : url;
10387
- };
10388
-
10389
- var TriggerConditionEvaluator_evalUrlMatchTriggerCondition = function evalUrlMatchTriggerCondition(triggerCondition, url) {
10390
- /**
10391
- * Behaviour
10392
- * regex Regex match (as per javascript string .match) over the whole string including
10393
- * query params
10394
- * ends-with Match only the URL without query params. Match including trailing slashes
10395
- * contains Match substring including query params
10396
- * equals Matches the exact URL, without query params
10397
- */
10398
- var urlWithoutQueryParams = url.split("?")[0];
10399
- return triggerCondition.conditions_any.some(function (condition) {
10400
- switch (condition.type) {
10401
- case "ends-with":
10402
- {
10403
- var _context;
10404
-
10405
- return ends_with_default()(urlWithoutQueryParams).call(urlWithoutQueryParams, condition.value) || ends_with_default()(_context = TriggerConditionEvaluator_stripTrailingSlash(urlWithoutQueryParams)).call(_context, condition.value);
10406
- }
10407
-
10408
- case "contains":
10409
- return includes_default()(url).call(url, condition.value);
10410
-
10411
- case "equals":
10412
- {
10413
- return doesUrlMatchPath(urlWithoutQueryParams, condition.value);
10414
- }
10415
-
10416
- case "regex":
10417
- {
10418
- var rx = new RegExp(condition.value);
10419
- return Boolean(rx.exec(url));
10420
- }
10421
- // If an unknown URL match type is found, ignore it - one of the others will have to match
10422
-
10423
- default:
10424
- return false;
10425
- }
10426
- });
10427
- };
10428
- var evalDatetimeTriggerCondition = function evalDatetimeTriggerCondition(triggerCondition, currentDateTime) {
10429
- var conditionDatetime = new Date(triggerCondition.condition.datetime);
10430
-
10431
- switch (triggerCondition.condition.operator) {
10432
- case "before-exclusive":
10433
- return currentDateTime < conditionDatetime;
10434
-
10435
- case "after-inclusive":
10436
- return currentDateTime >= conditionDatetime;
10437
- // If an unknown comparator is found, ignore the trigger condition - do not block campaign
10438
-
10439
- default:
10440
- return true;
10441
- }
10442
- };
10443
- var TriggerConditionEvaluator_evalTriggerCondition = function evalTriggerCondition(triggerCondition) {
10444
- switch (triggerCondition.type) {
10445
- case "url-match":
10446
- return TriggerConditionEvaluator_evalUrlMatchTriggerCondition(triggerCondition, window.location.href);
10447
-
10448
- case "datetime":
10449
- return evalDatetimeTriggerCondition(triggerCondition, new Date());
10450
- // If an unknown trigger type is found, ignore the trigger condition - do not block campaign
10451
-
10452
- default:
10453
- return true;
10454
- }
10455
- };
10456
10400
  ;// CONCATENATED MODULE: ./src/campaigns/campaign.ts
10457
10401
 
10458
10402
 
@@ -10627,7 +10571,7 @@ var getCampaignToTrigger = function getCampaignToTrigger(adaSettings, marketingC
10627
10571
  }
10628
10572
 
10629
10573
  var conditionsMet = campaign.trigger_conditions.every(function (tc) {
10630
- return TriggerConditionEvaluator_evalTriggerCondition(tc);
10574
+ return evalTriggerCondition(tc);
10631
10575
  });
10632
10576
  var doesPassFrequencyCheck = ignoreFrequency || !campaignShownWithinFrequency(campaign, handle);
10633
10577
  return conditionsMet && doesPassFrequencyCheck;
@@ -14368,7 +14312,7 @@ window.__AdaEmbedConstructor = Embed;
14368
14312
  /* harmony export */ });
14369
14313
  var isModern = new RegExp("((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(15|(1[6-9]|[2-9]\\d|\\d{3,}))[_.]\\d+(?:[_.]\\d+)?)|((Chromium|Chrome)\\/(97|(9[8-9]|\\d{3,}))\\.\\d+(?:\\.\\d+)?)|(Version\\/(15|(1[6-9]|[2-9]\\d|\\d{3,}))\\.\\d+(?:\\.\\d+)? Safari\\/)|(Firefox\\/(96|(9[7-9]|\\d{3,}))\\.\\d+\\.\\d+)|(Firefox\\/(96|(9[7-9]|\\d{3,}))\\.\\d+(pre|[ab]\\d+[a-z]*)?)").test(navigator.userAgent);
14370
14314
  var isProduction = "production" === "production";
14371
- var embed2Version = "e5d1f99";
14315
+ var embed2Version = "1d1b0f6";
14372
14316
 
14373
14317
  /***/ }),
14374
14318
 
@@ -14714,9 +14658,9 @@ function _log() {
14714
14658
  service: "embed",
14715
14659
  env: "production",
14716
14660
  embedVersion: 2,
14717
- version: "1.0.62",
14661
+ version: "1.0.63",
14718
14662
  isNpm: true,
14719
- commitHash: "e5d1f99"
14663
+ commitHash: "1d1b0f6"
14720
14664
  }))
14721
14665
  });
14722
14666
 
@@ -25657,7 +25601,7 @@ function _loadEmbed() {
25657
25601
  polyfillVersionString = "legacy";
25658
25602
  }
25659
25603
 
25660
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "e5d1f99", "/index.js");
25604
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "1d1b0f6", "/index.js");
25661
25605
  }
25662
25606
 
25663
25607
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -26195,7 +26139,7 @@ function createEmbedObject() {
26195
26139
  }
26196
26140
  ;// CONCATENATED MODULE: ./src/index-npm.ts
26197
26141
 
26198
- Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 9262));
26142
+ Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 5265));
26199
26143
  /* harmony default export */ var index_npm = (createEmbedObject());
26200
26144
  }();
26201
26145
  module.exports = __webpack_exports__;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",
@@ -1,3 +0,0 @@
1
- import { TriggerCondition, URLMatchTriggerCondition } from "./types";
2
- export declare const evalUrlMatchTriggerCondition: (triggerCondition: URLMatchTriggerCondition, url: string) => boolean;
3
- export declare const evalTriggerCondition: (triggerCondition: TriggerCondition) => boolean;