@ada-support/embed2 1.0.54 → 1.0.55

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,3 @@
1
- import type { CurrentIntro, Intro } from "common/types/http";
2
1
  export declare function getProcessedPath(path: string): string;
3
2
  export declare function getPathSearchRegex(path: string): RegExp;
4
3
  export declare function doesUrlMatchPath(url: string, path: string): boolean;
5
- export declare function getIntroForCurrentUrl(intros: Intro[], language: string): CurrentIntro | undefined;
@@ -29,5 +29,4 @@ export declare class Client {
29
29
  [key: string]: unknown;
30
30
  constructor(clientResponse: ClientResponse["client"]);
31
31
  }
32
- export declare function hasCampaignsEnabled(client?: Client): boolean;
33
32
  export declare function getButtonText(client?: Client): string;
@@ -6,20 +6,6 @@ export interface ChatButton {
6
6
  icon_path: string;
7
7
  icon_type: string;
8
8
  }
9
- interface MessageBody {
10
- message_text: {
11
- [language: string]: string;
12
- };
13
- emoji_link: string;
14
- }
15
- export interface Intro {
16
- style: "Text" | "Emoji";
17
- response_id: string;
18
- duration: number;
19
- paths: string[];
20
- delay: number;
21
- body: MessageBody;
22
- }
23
9
  export interface CurrentIntro {
24
10
  response_id: string;
25
11
  body: string;
@@ -34,7 +20,6 @@ export interface Features {
34
20
  developer_proactive?: boolean;
35
21
  afm_business_events?: boolean;
36
22
  afm_proactive_messaging?: boolean;
37
- afm_proactive_messaging_free_tier?: boolean;
38
23
  embed_test_bot?: boolean;
39
24
  rtl_language_support?: boolean;
40
25
  translations?: boolean;
@@ -62,7 +47,6 @@ export interface CachedClientObject {
62
47
  privacy: boolean;
63
48
  tint: string;
64
49
  chat_button: ChatButton | null;
65
- intros?: Intro[];
66
50
  features: Features;
67
51
  business_events?: BusinessEvent[];
68
52
  marketing_campaigns_order?: string[];
@@ -75,4 +59,3 @@ export interface NotificationStatusResponse {
75
59
  is_live_state: boolean;
76
60
  unread_amount: number;
77
61
  }
78
- export {};
@@ -8788,7 +8788,7 @@ var client = new error_tracker_BrowserClient({
8788
8788
  return event;
8789
8789
  },
8790
8790
  environment: "production",
8791
- release: "1.0.54-ff2e454",
8791
+ release: "1.0.55-68d18b3",
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
@@ -9487,7 +9487,7 @@ function getEmbedURL(_ref) {
9487
9487
  polyfillVersionString = "legacy";
9488
9488
  }
9489
9489
 
9490
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "ff2e454", "/index.html");
9490
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "68d18b3", "/index.html");
9491
9491
  }
9492
9492
  /**
9493
9493
  * Generate the Chat / API URL
@@ -10345,7 +10345,6 @@ var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
10345
10345
  ;// CONCATENATED MODULE: ./src/common/helpers/get-intro-for-url.ts
10346
10346
 
10347
10347
 
10348
-
10349
10348
  function getProcessedPath(path) {
10350
10349
  var regex = new RegExp("^http(s)?://(www.)?");
10351
10350
  return trim_default()(path).call(path).replace(regex, "");
@@ -10370,53 +10369,6 @@ function doesUrlMatchPath(url, path) {
10370
10369
  var matches = pathRegex.exec(processedUrl);
10371
10370
  return matches !== null;
10372
10371
  }
10373
-
10374
- function findMatchingIntro(intros) {
10375
- var currentUrl = window.location.href;
10376
-
10377
- var matchingIntros = filter_default()(intros).call(intros, function (intro) {
10378
- var _context2;
10379
-
10380
- var matchingPaths = filter_default()(_context2 = intro.paths).call(_context2, function (path) {
10381
- return doesUrlMatchPath(currentUrl, path);
10382
- });
10383
-
10384
- return matchingPaths.length > 0;
10385
- });
10386
-
10387
- if (matchingIntros.length === 0) {
10388
- return null;
10389
- }
10390
-
10391
- return matchingIntros[0];
10392
- }
10393
-
10394
- function getIntroForCurrentUrl(intros, language) {
10395
- var matchingIntro = findMatchingIntro(intros);
10396
-
10397
- if (!matchingIntro) {
10398
- return undefined;
10399
- }
10400
-
10401
- if (matchingIntro.style === "Emoji") {
10402
- return {
10403
- response_id: matchingIntro.response_id,
10404
- body: matchingIntro.body.emoji_link,
10405
- style: matchingIntro.style,
10406
- delay: matchingIntro.delay,
10407
- duration: matchingIntro.duration
10408
- };
10409
- } // Default - "Text" style
10410
-
10411
-
10412
- return {
10413
- response_id: matchingIntro.response_id,
10414
- body: matchingIntro.body.message_text[language],
10415
- style: matchingIntro.style,
10416
- delay: matchingIntro.delay,
10417
- duration: matchingIntro.duration
10418
- };
10419
- }
10420
10372
  ;// CONCATENATED MODULE: ./src/campaigns/TriggerConditionEvaluator.ts
10421
10373
 
10422
10374
 
@@ -10976,20 +10928,6 @@ function bindActionCreators(action, dispatch) {
10976
10928
 
10977
10929
 
10978
10930
 
10979
-
10980
-
10981
-
10982
-
10983
-
10984
- function fetch_client_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); enumerableOnly && (symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10985
-
10986
- function fetch_client_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? fetch_client_ownKeys(Object(source), !0).forEach(function (key) { (0,defineProperty/* default */.Z)(target, key, source[key]); }) : (get_own_property_descriptors_default()) ? define_properties_default()(target, get_own_property_descriptors_default()(source)) : fetch_client_ownKeys(Object(source)).forEach(function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } return target; }
10987
-
10988
-
10989
-
10990
-
10991
-
10992
-
10993
10931
  function isClientObject(client) {
10994
10932
  // We require the following properties defined
10995
10933
  return ["handle", "rollout", "chat", "features"].every(function (key) {
@@ -11027,9 +10965,7 @@ function _fetchClient() {
11027
10965
  }
11028
10966
 
11029
10967
  return _context.abrupt("return", {
11030
- client: fetch_client_objectSpread({
11031
- intro: getIntroForCurrentUrl(cachedClient.intros || [], language || cachedClient.language)
11032
- }, cachedClient)
10968
+ client: cachedClient
11033
10969
  });
11034
10970
 
11035
10971
  case 6:
@@ -11225,9 +11161,6 @@ var Client = /*#__PURE__*/(0,createClass/* default */.Z)(function Client(clientR
11225
11161
 
11226
11162
  object_assign_default()(this, rest);
11227
11163
  });
11228
- function hasCampaignsEnabled(client) {
11229
- return (client === null || client === void 0 ? void 0 : client.features.afm_proactive_messaging) || (client === null || client === void 0 ? void 0 : client.features.afm_proactive_messaging_free_tier);
11230
- }
11231
11164
  function getButtonText(client) {
11232
11165
  var _client$ui_settings, _client$ui_settings$e;
11233
11166
 
@@ -12893,7 +12826,7 @@ var Container = /*#__PURE__*/function (_Component) {
12893
12826
  // (message_text) campaigns
12894
12827
  campaignToTrigger.message_text || chatterToken) && (campaignToTrigger.message_text || isChatWebsocketConnected) && ( // We need to wait for bindEmbedActionEventHandlerOnce to be called, but only for free tier
12895
12828
  // campaigns, we don't need this for engage (response_id) campaigns
12896
- campaignToTrigger.response_id || appConnectionState === ConnectionState.Done) && !isDrawerOpen && !chatterInLiveChat && hasCampaignsEnabled(client)) {
12829
+ campaignToTrigger.response_id || appConnectionState === ConnectionState.Done) && !isDrawerOpen && !chatterInLiveChat) {
12897
12830
  triggerCampaignImpl({
12898
12831
  adaSettings: adaSettings,
12899
12832
  chatterToken: chatterToken,
@@ -12928,7 +12861,7 @@ var Container = /*#__PURE__*/function (_Component) {
12928
12861
  } // Wait for client to be available, then set campaign to trigger
12929
12862
 
12930
12863
 
12931
- if (client && !prevProps.client && hasCampaignsEnabled(client)) {
12864
+ if (client && !prevProps.client) {
12932
12865
  this.evaluateCampaignConditions({}, true);
12933
12866
  }
12934
12867
  /**
@@ -13101,11 +13034,6 @@ var Container = /*#__PURE__*/function (_Component) {
13101
13034
  var _this$props8 = this.props,
13102
13035
  adaSettings = _this$props8.adaSettings,
13103
13036
  client = _this$props8.client;
13104
-
13105
- if (!hasCampaignsEnabled(client)) {
13106
- return;
13107
- }
13108
-
13109
13037
  var campaignToTrigger = getCampaignToTrigger(adaSettings, client.marketing_campaigns, params, !client.features.afm_proactive_messaging);
13110
13038
 
13111
13039
  if (campaignToTrigger) {
@@ -13128,7 +13056,7 @@ var Container = /*#__PURE__*/function (_Component) {
13128
13056
  var _handleEmbedAction = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee2(type, payload, id) {
13129
13057
  var _this5 = this;
13130
13058
 
13131
- var _this$props9, client, messageService, adaSettings, parentElement, localChannel, xStorageChannel, toggleChat, _this$props10, isDrawerOpen, drawerHasBeenOpened, chatterToken, contentToReturn, _this$props11, metaFields, setState, metaData, newMetaFields, _this$props12, sensitiveMetaFields, _setState, _ref, greeting, language, _newMetaFields, _sensitiveMetaFields, _ref$resetChatHistory, resetChatHistory, _setState2, chatHasBeenRendered, newState, _setState3, _ref2, body, duration, EXTRA_PROACTIVE_DELAY, canCreateProactive;
13059
+ var _this$props9, client, messageService, adaSettings, parentElement, localChannel, xStorageChannel, toggleChat, _this$props10, isDrawerOpen, drawerHasBeenOpened, chatterToken, contentToReturn, _this$props11, metaFields, setState, metaData, newMetaFields, _this$props12, sensitiveMetaFields, _setState, _ref, greeting, language, _newMetaFields, _sensitiveMetaFields, _ref$resetChatHistory, resetChatHistory, _setState2, chatHasBeenRendered, newState, _setState3, _ref2, body, duration, EXTRA_PROACTIVE_DELAY;
13132
13060
 
13133
13061
  return regenerator_default().wrap(function _callee2$(_context3) {
13134
13062
  while (1) {
@@ -13148,7 +13076,7 @@ var Container = /*#__PURE__*/function (_Component) {
13148
13076
 
13149
13077
  case 6:
13150
13078
  _context3.t0 = type;
13151
- _context3.next = _context3.t0 === TRACK_EVENT ? 9 : _context3.t0 === TRIGGER_CAMPAIGN ? 14 : _context3.t0 === EVAL_CAMPAIGN_CONDITIONS ? 19 : _context3.t0 === TOGGLE ? 24 : _context3.t0 === GET_INFO ? 29 : _context3.t0 === SET_META_FIELDS ? 33 : _context3.t0 === "SET_SENSITIVE_META_FIELDS" ? 40 : _context3.t0 === STOP ? 45 : _context3.t0 === RESET ? 48 : _context3.t0 === DELETE_HISTORY ? 66 : _context3.t0 === CREATE_PROACTIVE ? 78 : 91;
13079
+ _context3.next = _context3.t0 === TRACK_EVENT ? 9 : _context3.t0 === TRIGGER_CAMPAIGN ? 14 : _context3.t0 === EVAL_CAMPAIGN_CONDITIONS ? 19 : _context3.t0 === TOGGLE ? 24 : _context3.t0 === GET_INFO ? 29 : _context3.t0 === SET_META_FIELDS ? 33 : _context3.t0 === "SET_SENSITIVE_META_FIELDS" ? 40 : _context3.t0 === STOP ? 45 : _context3.t0 === RESET ? 48 : _context3.t0 === DELETE_HISTORY ? 66 : _context3.t0 === CREATE_PROACTIVE ? 78 : 87;
13152
13080
  break;
13153
13081
 
13154
13082
  case 9:
@@ -13162,7 +13090,7 @@ var Container = /*#__PURE__*/function (_Component) {
13162
13090
 
13163
13091
  case 12:
13164
13092
  this.trackEvent(payload);
13165
- return _context3.abrupt("break", 91);
13093
+ return _context3.abrupt("break", 87);
13166
13094
 
13167
13095
  case 14:
13168
13096
  if (client.features.afm_proactive_messaging) {
@@ -13175,7 +13103,7 @@ var Container = /*#__PURE__*/function (_Component) {
13175
13103
 
13176
13104
  case 17:
13177
13105
  this.triggerCampaign(payload);
13178
- return _context3.abrupt("break", 91);
13106
+ return _context3.abrupt("break", 87);
13179
13107
 
13180
13108
  case 19:
13181
13109
  if (client.features.afm_proactive_messaging) {
@@ -13188,7 +13116,7 @@ var Container = /*#__PURE__*/function (_Component) {
13188
13116
 
13189
13117
  case 22:
13190
13118
  this.evaluateCampaignConditions(payload);
13191
- return _context3.abrupt("break", 91);
13119
+ return _context3.abrupt("break", 87);
13192
13120
 
13193
13121
  case 24:
13194
13122
  toggleChat = this.props.toggleChat;
@@ -13197,7 +13125,7 @@ var Container = /*#__PURE__*/function (_Component) {
13197
13125
 
13198
13126
  case 27:
13199
13127
  localChannel.postMessage(TOGGLE_RESPONSE, null, id);
13200
- return _context3.abrupt("break", 91);
13128
+ return _context3.abrupt("break", 87);
13201
13129
 
13202
13130
  case 29:
13203
13131
  _this$props10 = this.props, isDrawerOpen = _this$props10.isDrawerOpen, drawerHasBeenOpened = _this$props10.drawerHasBeenOpened, chatterToken = _this$props10.chatterToken;
@@ -13208,7 +13136,7 @@ var Container = /*#__PURE__*/function (_Component) {
13208
13136
  hasClosedChat: drawerHasBeenOpened && !isDrawerOpen
13209
13137
  };
13210
13138
  localChannel.postMessage(GET_INFO_RESPONSE, contentToReturn, id);
13211
- return _context3.abrupt("break", 91);
13139
+ return _context3.abrupt("break", 87);
13212
13140
 
13213
13141
  case 33:
13214
13142
  _this$props11 = this.props, metaFields = _this$props11.metaFields, setState = _this$props11.setState;
@@ -13221,7 +13149,7 @@ var Container = /*#__PURE__*/function (_Component) {
13221
13149
 
13222
13150
  case 38:
13223
13151
  localChannel.postMessage(SET_META_FIELDS_RESPONSE, null, id);
13224
- return _context3.abrupt("break", 91);
13152
+ return _context3.abrupt("break", 87);
13225
13153
 
13226
13154
  case 40:
13227
13155
  _this$props12 = this.props, sensitiveMetaFields = _this$props12.sensitiveMetaFields, _setState = _this$props12.setState;
@@ -13232,12 +13160,12 @@ var Container = /*#__PURE__*/function (_Component) {
13232
13160
 
13233
13161
  case 43:
13234
13162
  localChannel.postMessage("SET_SENSITIVE_META_FIELDS_RESPONSE", null, id);
13235
- return _context3.abrupt("break", 91);
13163
+ return _context3.abrupt("break", 87);
13236
13164
 
13237
13165
  case 45:
13238
13166
  localChannel.postMessage(STOP_RESPONSE, null, id);
13239
13167
  this.unmount();
13240
- return _context3.abrupt("break", 91);
13168
+ return _context3.abrupt("break", 87);
13241
13169
 
13242
13170
  case 48:
13243
13171
  _ref = payload, greeting = _ref.greeting, language = _ref.language, _newMetaFields = _ref.metaFields, _sensitiveMetaFields = _ref.sensitiveMetaFields, _ref$resetChatHistory = _ref.resetChatHistory, resetChatHistory = _ref$resetChatHistory === void 0 ? true : _ref$resetChatHistory;
@@ -13291,7 +13219,7 @@ var Container = /*#__PURE__*/function (_Component) {
13291
13219
  }
13292
13220
 
13293
13221
  localChannel.postMessage(RESET_RESPONSE, null, id);
13294
- return _context3.abrupt("break", 91);
13222
+ return _context3.abrupt("break", 87);
13295
13223
 
13296
13224
  case 66:
13297
13225
  _setState3 = this.props.setState;
@@ -13319,7 +13247,7 @@ var Container = /*#__PURE__*/function (_Component) {
13319
13247
  case 75:
13320
13248
  xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
13321
13249
  localChannel.postMessage(DELETE_HISTORY_RESPONSE, null, id);
13322
- return _context3.abrupt("break", 91);
13250
+ return _context3.abrupt("break", 87);
13323
13251
 
13324
13252
  case 78:
13325
13253
  _ref2 = payload, body = _ref2.body, duration = _ref2.duration;
@@ -13333,18 +13261,8 @@ var Container = /*#__PURE__*/function (_Component) {
13333
13261
  throw new errors/* AdaEmbedError */.S("`client` is not defined");
13334
13262
 
13335
13263
  case 82:
13336
- // Free tier campaigns re-use the createProactive infrastructure
13337
- canCreateProactive = client.features.developer_proactive || client.features.afm_proactive_messaging_free_tier;
13338
-
13339
- if (canCreateProactive) {
13340
- _context3.next = 86;
13341
- break;
13342
- }
13343
-
13344
- localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, "Ada Embed - Proactive intros are not available in your feature set.", id, FetchEventStatus.Failure);
13345
- return _context3.abrupt("return");
13346
-
13347
- case 86:
13264
+ // Do not feature flag gate this behind the developer_proactive flag
13265
+ // It's also used for free-tier campaigns, which are available to all clients
13348
13266
  this.setState({
13349
13267
  hideIntroOverride: true
13350
13268
  }, /*#__PURE__*/(0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee() {
@@ -13382,14 +13300,14 @@ var Container = /*#__PURE__*/function (_Component) {
13382
13300
  }
13383
13301
  }, _callee);
13384
13302
  })));
13385
- _context3.next = 89;
13303
+ _context3.next = 85;
13386
13304
  return wait(duration * 1000 + EXTRA_PROACTIVE_DELAY);
13387
13305
 
13388
- case 89:
13306
+ case 85:
13389
13307
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, null, id);
13390
- return _context3.abrupt("break", 91);
13308
+ return _context3.abrupt("break", 87);
13391
13309
 
13392
- case 91:
13310
+ case 87:
13393
13311
  case "end":
13394
13312
  return _context3.stop();
13395
13313
  }
@@ -13522,7 +13440,7 @@ var Container = /*#__PURE__*/function (_Component) {
13522
13440
  (0,errors/* warn */.Z)("Failed to fetch events from API.");
13523
13441
 
13524
13442
  case 25:
13525
- if (!(hasCampaignsEnabled(newClient) && !newClient.marketing_campaigns)) {
13443
+ if (newClient.marketing_campaigns) {
13526
13444
  _context8.next = 38;
13527
13445
  break;
13528
13446
  }
@@ -13548,7 +13466,7 @@ var Container = /*#__PURE__*/function (_Component) {
13548
13466
 
13549
13467
  case 38:
13550
13468
  // Sort the campaigns by marketing_campaigns_order
13551
- if (hasCampaignsEnabled(newClient) && newClient.marketing_campaigns_order) {
13469
+ if (newClient.marketing_campaigns_order) {
13552
13470
  newClient.marketing_campaigns = filter_default()(_context5 = map_default()(_context6 = newClient.marketing_campaigns_order).call(_context6, function (campaignId) {
13553
13471
  var _context7;
13554
13472
 
@@ -14384,7 +14302,7 @@ window.__AdaEmbedConstructor = Embed;
14384
14302
  /* harmony export */ });
14385
14303
  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);
14386
14304
  var isProduction = "production" === "production";
14387
- var embed2Version = "ff2e454";
14305
+ var embed2Version = "68d18b3";
14388
14306
 
14389
14307
  /***/ }),
14390
14308
 
@@ -14726,9 +14644,9 @@ function _log() {
14726
14644
  service: "embed",
14727
14645
  env: "production",
14728
14646
  embedVersion: 2,
14729
- version: "1.0.54",
14647
+ version: "1.0.55",
14730
14648
  isNpm: true,
14731
- commitHash: "ff2e454"
14649
+ commitHash: "68d18b3"
14732
14650
  }))
14733
14651
  });
14734
14652
 
@@ -24275,7 +24193,7 @@ function _loadEmbed() {
24275
24193
  polyfillVersionString = "legacy";
24276
24194
  }
24277
24195
 
24278
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "ff2e454", "/index.js");
24196
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "68d18b3", "/index.js");
24279
24197
  }
24280
24198
 
24281
24199
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",