@ada-support/embed2 1.0.49 → 1.0.53

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.
@@ -12,5 +12,5 @@ interface TriggerCampaignImplParams {
12
12
  messageService: MessageService;
13
13
  }
14
14
  export declare function triggerCampaignImpl({ adaSettings, chatterToken, campaign, ignoreStatus, ignoreFrequency, clearCampaignToTrigger, messageService, }: TriggerCampaignImplParams): void;
15
- export declare const getCampaignToTrigger: (adaSettings: StartOptions, marketingCampaigns: MarketingCampaign[] | undefined, options: EvaluateCampaignParams, onlyBasic: boolean) => MarketingCampaign;
15
+ export declare const getCampaignToTrigger: (adaSettings: StartOptions, marketingCampaigns: MarketingCampaign[] | undefined, options: EvaluateCampaignParams, onlyBasic: boolean) => MarketingCampaign | undefined;
16
16
  export {};
@@ -22,14 +22,14 @@ export interface MarketingCampaign {
22
22
  _id: string;
23
23
  version: "2021-01-12";
24
24
  client_id: string;
25
- created_at: string;
26
- updated_at: string;
25
+ created: string;
26
+ updated: string;
27
27
  updated_by: string;
28
28
  name: string;
29
29
  description: string;
30
30
  campaign_key: string;
31
31
  status: "draft" | "active" | "off";
32
- trigger_conditions: TriggerCondition[];
32
+ trigger_conditions?: TriggerCondition[];
33
33
  goals: GoalEvent[];
34
34
  message_frequency: CampaignFrequency;
35
35
  message_delay: number;
@@ -11,7 +11,7 @@ export interface CSInterface {
11
11
  domain?: string;
12
12
  route?: string;
13
13
  qp?: {
14
- [key: string]: string | boolean | number;
14
+ [key: string]: string | boolean | number | null | undefined;
15
15
  };
16
16
  isEmbedFramed?: boolean;
17
17
  }
@@ -22,7 +22,7 @@ export interface StartOptions {
22
22
  onAdaEmbedLoaded?(): void;
23
23
  toggleCallback?(isDrawerOpen: boolean): void;
24
24
  eventCallbacks?: {
25
- [eventName: string]: (customJavascriptEvent: object) => void;
25
+ [eventName: string]: ((customJavascriptEvent: object) => void) | undefined;
26
26
  };
27
27
  zdChatterAuthCallback?(callback: (token: string) => void): void;
28
28
  embedStyles?: string;
@@ -736,7 +736,7 @@ var browserPerformanceTimeOrigin = (function () {
736
736
 
737
737
  /***/ }),
738
738
 
739
- /***/ 9136:
739
+ /***/ 356:
740
740
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
741
741
 
742
742
  "use strict";
@@ -8514,7 +8514,7 @@ var client = new error_tracker_BrowserClient({
8514
8514
  return event;
8515
8515
  },
8516
8516
  environment: "production",
8517
- release: "1.0.49-4562505",
8517
+ release: "1.0.53-036d569",
8518
8518
  sampleRate: 0.25,
8519
8519
  autoSessionTracking: false,
8520
8520
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -9213,7 +9213,7 @@ function getEmbedURL(_ref) {
9213
9213
  polyfillVersionString = "legacy";
9214
9214
  }
9215
9215
 
9216
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "4562505", "/index.html");
9216
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "036d569", "/index.html");
9217
9217
  }
9218
9218
  /**
9219
9219
  * Generate the Chat / API URL
@@ -9230,12 +9230,18 @@ function getURL(_ref2) {
9230
9230
  _ref2$qp = _ref2.qp,
9231
9231
  qp = _ref2$qp === void 0 ? {} : _ref2$qp;
9232
9232
 
9233
- var queryString = map_default()(_context8 = filter_default()(_context9 = keys_default()(qp)).call(_context9, function (key) {
9234
- return qp[key] !== undefined && qp[key] !== null;
9235
- })).call(_context8, function (key) {
9233
+ var queryString = filter_default()(_context8 = map_default()(_context9 = keys_default()(qp)).call(_context9, function (key) {
9236
9234
  var _context10;
9237
9235
 
9238
- return concat_default()(_context10 = "".concat(key, "=")).call(_context10, window.encodeURIComponent(qp[key]));
9236
+ var value = qp[key];
9237
+
9238
+ if (value === undefined || value === null) {
9239
+ return null;
9240
+ }
9241
+
9242
+ return concat_default()(_context10 = "".concat(key, "=")).call(_context10, window.encodeURIComponent(value));
9243
+ })).call(_context8, function (v) {
9244
+ return v !== null;
9239
9245
  }).join("&");
9240
9246
 
9241
9247
  var questionSym = queryString.length ? "?" : "";
@@ -10049,6 +10055,9 @@ var get_browser_language_getBrowserLanguage = function getBrowserLanguage() {
10049
10055
  };
10050
10056
 
10051
10057
  /* harmony default export */ var get_browser_language = (get_browser_language_getBrowserLanguage);
10058
+ ;// CONCATENATED MODULE: ./src/services/helpers.ts
10059
+ var NO_OP_FUNCTION = function NO_OP_FUNCTION() {// Do nothing
10060
+ };
10052
10061
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/trim.js
10053
10062
  var trim = __webpack_require__(5843);
10054
10063
  var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
@@ -10217,6 +10226,7 @@ var TriggerConditionEvaluator_evalTriggerCondition = function evalTriggerConditi
10217
10226
 
10218
10227
 
10219
10228
 
10229
+
10220
10230
  /**
10221
10231
  * To enforce frequency restrictions, when a campaign is shown we add its id to a list of shown
10222
10232
  * campaigns, and any campaigns in this list will not be shown again until removed from the list.
@@ -10353,7 +10363,7 @@ function triggerCampaignImpl(_ref) {
10353
10363
  },
10354
10364
  ignore_status: ignoreStatus
10355
10365
  })
10356
- });
10366
+ }).catch(NO_OP_FUNCTION); // we don't want to log errors here, it may fail because of rate limiting
10357
10367
  }
10358
10368
  }
10359
10369
  var getCampaignToTrigger = function getCampaignToTrigger(adaSettings, marketingCampaigns, options, onlyBasic) {
@@ -10372,7 +10382,7 @@ var getCampaignToTrigger = function getCampaignToTrigger(adaSettings, marketingC
10372
10382
  } // Campaigns with no trigger conditions can only be triggered manually
10373
10383
 
10374
10384
 
10375
- if (campaign.trigger_conditions.length === 0) {
10385
+ if (!campaign.trigger_conditions || campaign.trigger_conditions.length === 0) {
10376
10386
  return false;
10377
10387
  }
10378
10388
 
@@ -11385,6 +11395,8 @@ function ChatFrame_isNativeReflectConstruct() { if (typeof Reflect === "undefine
11385
11395
 
11386
11396
 
11387
11397
 
11398
+ var documentBodyStyle = window.document.body.style;
11399
+
11388
11400
  var ChatFrame = /*#__PURE__*/function (_Component) {
11389
11401
  (0,inherits/* default */.Z)(ChatFrame, _Component);
11390
11402
 
@@ -11405,21 +11417,19 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11405
11417
 
11406
11418
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "iframeRef", y());
11407
11419
 
11408
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "pageYOffset", void 0);
11409
-
11410
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyOverflow", void 0);
11420
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "pageYOffset", window.pageYOffset);
11411
11421
 
11412
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyPosition", void 0);
11422
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyOverflow", documentBodyStyle.overflow);
11413
11423
 
11414
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyTop", void 0);
11424
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyPosition", documentBodyStyle.position);
11415
11425
 
11416
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyBottom", void 0);
11426
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyTop", documentBodyStyle.top);
11417
11427
 
11418
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyLeft", void 0);
11428
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyBottom", documentBodyStyle.bottom);
11419
11429
 
11420
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyRight", void 0);
11430
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyLeft", documentBodyStyle.left);
11421
11431
 
11422
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "frameConnected", void 0);
11432
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyRight", documentBodyStyle.right);
11423
11433
 
11424
11434
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "url", _this.getURL);
11425
11435
 
@@ -11439,6 +11449,8 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11439
11449
  var _this2 = this;
11440
11450
 
11441
11451
  var _this$props = this.props,
11452
+ adaSettings = _this$props.adaSettings,
11453
+ handle = _this$props.handle,
11442
11454
  name = _this$props.name,
11443
11455
  setChatHasBeenRendered = _this$props.setChatHasBeenRendered,
11444
11456
  messageService = _this$props.messageService,
@@ -11447,7 +11459,12 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11447
11459
  this.channel = messageService.registerFrameChannel(name, this.iframeRef.current.contentWindow, this.iframeRef.current.src);
11448
11460
  store.addChannelListener(name);
11449
11461
  this.bindChatEventHandlers();
11450
- this.handleScrollLock(); // Delay to allow inline css animation to work.
11462
+ this.handleScrollLock(); // We use this log to track number of chat impressions (times when users see chat iFrame render first time).
11463
+
11464
+ (0,services_logger/* log */.c)("Chat frame mount", {
11465
+ handle: handle,
11466
+ embedSettings: adaSettings
11467
+ }); // Delay to allow inline css animation to work.
11451
11468
 
11452
11469
  setTimeout(function () {
11453
11470
  _this2.setState({
@@ -11484,7 +11501,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11484
11501
  }
11485
11502
 
11486
11503
  var theme = client.ui_settings.chat.theme;
11487
- var systemDarkMode = Boolean(window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches);
11504
+ var systemDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
11488
11505
  return theme === "dark" || theme === "auto" && systemDarkMode;
11489
11506
  }
11490
11507
  /**
@@ -11506,6 +11523,11 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11506
11523
  privateMode = _this$props3.privateMode,
11507
11524
  testMode = _this$props3.testMode,
11508
11525
  adaSettings = _this$props3.adaSettings;
11526
+
11527
+ if (!handle) {
11528
+ throw new errors/* AdaEmbedError */.S("`handle` is not defined");
11529
+ }
11530
+
11509
11531
  return getURL({
11510
11532
  name: name,
11511
11533
  handle: handle,
@@ -11526,7 +11548,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11526
11548
  }, {
11527
11549
  key: "styles",
11528
11550
  get: function get() {
11529
- var _client$ui_settings2, _context10, _context11, _context12, _context13, _context14;
11551
+ var _client$ui_settings2, _client$ui_settings2$, _context10, _context11, _context12, _context13, _context14;
11530
11552
 
11531
11553
  var _this$props4 = this.props,
11532
11554
  isDrawerOpen = _this$props4.isDrawerOpen,
@@ -11543,7 +11565,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11543
11565
  closeTransitionTime = _this$state.closeTransitionTime;
11544
11566
  var isShown = isDrawerOpen && isMounted;
11545
11567
  var backgroundColor = this.darkMode ? "#121212" : "#fff";
11546
- var borderRadius = ((_client$ui_settings2 = client.ui_settings) === null || _client$ui_settings2 === void 0 ? void 0 : _client$ui_settings2.chat.style) === "rectangular" ? "8px" : "16px";
11568
+ var borderRadius = ((_client$ui_settings2 = client.ui_settings) === null || _client$ui_settings2 === void 0 ? void 0 : (_client$ui_settings2$ = _client$ui_settings2.chat) === null || _client$ui_settings2$ === void 0 ? void 0 : _client$ui_settings2$.style) === "rectangular" ? "8px" : "16px";
11547
11569
  var WINDOW_HEIGHT = 725;
11548
11570
  var TEST_BOT_NAV_HEIGHT = 48;
11549
11571
  var isTestBot = client.features.embed_test_bot && testMode;
@@ -11572,12 +11594,17 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11572
11594
  var _this$props5 = this.props,
11573
11595
  chatDimensions = _this$props5.chatDimensions,
11574
11596
  client = _this$props5.client,
11575
- adaSettings = _this$props5.adaSettings; // delta is used to determine how much of the button's height should be ignored
11597
+ adaSettings = _this$props5.adaSettings;
11598
+
11599
+ if (!(client !== null && client !== void 0 && client.chat_button)) {
11600
+ return "";
11601
+ } // delta is used to determine how much of the button's height should be ignored
11576
11602
  // when spacing the proactive message
11577
11603
 
11604
+
11578
11605
  var delta = 3;
11579
11606
  var TEXT_BUTTON_HEIGHT = 44;
11580
- var bottomOffset = (client === null || client === void 0 ? void 0 : (_client$ui_settings3 = client.ui_settings) === null || _client$ui_settings3 === void 0 ? void 0 : (_client$ui_settings3$ = _client$ui_settings3.embed) === null || _client$ui_settings3$ === void 0 ? void 0 : _client$ui_settings3$.style) === "text" ? TEXT_BUTTON_HEIGHT - delta : (client === null || client === void 0 ? void 0 : client.chat_button.size) - delta;
11607
+ var bottomOffset = ((_client$ui_settings3 = client.ui_settings) === null || _client$ui_settings3 === void 0 ? void 0 : (_client$ui_settings3$ = _client$ui_settings3.embed) === null || _client$ui_settings3$ === void 0 ? void 0 : _client$ui_settings3$.style) === "text" ? TEXT_BUTTON_HEIGHT - delta : client.chat_button.size - delta;
11581
11608
  return concat_default()(_context15 = concat_default()(_context16 = concat_default()(_context17 = "\n box-shadow: none;\n background: none;\n height: ".concat(chatDimensions === null || chatDimensions === void 0 ? void 0 : chatDimensions.height, "px !important;\n width: ")).call(_context17, chatDimensions === null || chatDimensions === void 0 ? void 0 : chatDimensions.width, "px !important;\n ")).call(_context16, getAlignment(adaSettings), ": 0;\n bottom: ")).call(_context15, bottomOffset, "px;\n z-index: 9999;\n ");
11582
11609
  }
11583
11610
  }, {
@@ -11593,6 +11620,10 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11593
11620
  return ChatFrame.parentElementStyles;
11594
11621
  }
11595
11622
 
11623
+ if (!client) {
11624
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
11625
+ }
11626
+
11596
11627
  if (client.features.afm_proactive_messaging && !isDrawerOpen) {
11597
11628
  var _context21;
11598
11629
 
@@ -11612,11 +11643,18 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11612
11643
  value: function handleScrollLock() {
11613
11644
  var _this3 = this;
11614
11645
 
11615
- var isDrawerOpen = this.props.isDrawerOpen;
11616
- var closeTransitionTime = this.state.closeTransitionTime;
11646
+ var _this$props7 = this.props,
11647
+ isDrawerOpen = _this$props7.isDrawerOpen,
11648
+ parentElement = _this$props7.parentElement;
11649
+ var closeTransitionTime = this.state.closeTransitionTime; // Lock scroll only on mobile
11617
11650
 
11618
11651
  if (!isMobile) {
11619
11652
  return;
11653
+ } // And if parentElement is not used
11654
+
11655
+
11656
+ if (parentElement) {
11657
+ return;
11620
11658
  }
11621
11659
 
11622
11660
  if (isDrawerOpen) {
@@ -11649,7 +11687,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11649
11687
  }, {
11650
11688
  key: "lockDocumentBodyFromScrolling",
11651
11689
  value: function lockDocumentBodyFromScrolling() {
11652
- // save current page position so we can scroll back there
11690
+ // Save current page position so we can scroll back there
11653
11691
  this.pageYOffset = window.pageYOffset;
11654
11692
  this.documentBodyOverflow = window.document.body.style.overflow;
11655
11693
  this.documentBodyPosition = window.document.body.style.position;
@@ -11697,9 +11735,9 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11697
11735
  var title = payload.title,
11698
11736
  body = payload.body,
11699
11737
  icon = payload.icon;
11700
- var _this$props7 = this.props,
11701
- isDrawerOpen = _this$props7.isDrawerOpen,
11702
- parentElement = _this$props7.parentElement;
11738
+ var _this$props8 = this.props,
11739
+ isDrawerOpen = _this$props8.isDrawerOpen,
11740
+ parentElement = _this$props8.parentElement;
11703
11741
  var isChatOpen = isDrawerOpen || Boolean(parentElement);
11704
11742
  var onClickHandler = this.notificationOnClickHandler.bind(this, isChatOpen);
11705
11743
  createNotification(title, isChatOpen, onClickHandler, {
@@ -11713,40 +11751,56 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11713
11751
  var _handleChatEvent = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(type, payload, id) {
11714
11752
  var _this4 = this;
11715
11753
 
11716
- var _this$props8, adaSettings, setState, setConnectionState, _ref, eventKey, data, _ref2, analytics, analyticsCallback, client, _ref3, chatter, created, chatterTokenCallback, _client, _ref4, zdSessionId, zdPreviousTags, storage, _client2, _ref5, inLiveChat, eventCallbacks, customJavascriptEvent, specificCallback, genericCallback, resetChat, zdChatterAuthCallback, conversationEndCallback;
11754
+ var _this$props9, adaSettings, setState, setConnectionState, _ref, eventKey, data, _ref2, analytics, analyticsCallback, client, _ref3, chatter, created, chatterTokenCallback, _client, _ref4, zdSessionId, zdPreviousTags, storage, _client2, _ref5, inLiveChat, eventCallbacks, customJavascriptEvent, specificCallback, genericCallback, resetChat, zdChatterAuthCallback, conversationEndCallback;
11717
11755
 
11718
11756
  return regenerator_default().wrap(function _callee$(_context22) {
11719
11757
  while (1) {
11720
11758
  switch (_context22.prev = _context22.next) {
11721
11759
  case 0:
11722
- _this$props8 = this.props, adaSettings = _this$props8.adaSettings, setState = _this$props8.setState, setConnectionState = _this$props8.setConnectionState;
11760
+ _this$props9 = this.props, adaSettings = _this$props9.adaSettings, setState = _this$props9.setState, setConnectionState = _this$props9.setConnectionState;
11723
11761
  _context22.t0 = type;
11724
- _context22.next = _context22.t0 === GET_WINDOW_ORIGIN ? 4 : _context22.t0 === CHAT_STARTED ? 6 : _context22.t0 === CHAT_WEBSOCKET_CONNECTED ? 9 : _context22.t0 === PUBLISH_EVENT ? 11 : _context22.t0 === ANALYTICS_EVENT ? 14 : _context22.t0 === CHATTER_EVENT ? 18 : _context22.t0 === "ZD_SESSION" ? 28 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 37 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 43 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 52 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 55 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 58 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 60 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 62 : _context22.t0 === END_CONVERSATION_EVENT ? 64 : 67;
11762
+ _context22.next = _context22.t0 === GET_WINDOW_ORIGIN ? 4 : _context22.t0 === CHAT_STARTED ? 8 : _context22.t0 === CHAT_WEBSOCKET_CONNECTED ? 13 : _context22.t0 === PUBLISH_EVENT ? 15 : _context22.t0 === ANALYTICS_EVENT ? 18 : _context22.t0 === CHATTER_EVENT ? 22 : _context22.t0 === "ZD_SESSION" ? 32 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 41 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 49 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 58 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 61 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 79 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 81 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 85 : _context22.t0 === END_CONVERSATION_EVENT ? 87 : 90;
11725
11763
  break;
11726
11764
 
11727
11765
  case 4:
11728
- this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11729
- return _context22.abrupt("break", 68);
11766
+ if (this.channel) {
11767
+ _context22.next = 6;
11768
+ break;
11769
+ }
11770
+
11771
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11730
11772
 
11731
11773
  case 6:
11774
+ this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11775
+ return _context22.abrupt("break", 91);
11776
+
11777
+ case 8:
11778
+ if (this.channel) {
11779
+ _context22.next = 10;
11780
+ break;
11781
+ }
11782
+
11783
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11784
+
11785
+ case 10:
11732
11786
  this.channel.isConnected = true;
11733
11787
  setConnectionState({
11734
11788
  "chat": ConnectionState.Done
11735
11789
  });
11736
- return _context22.abrupt("break", 68);
11790
+ return _context22.abrupt("break", 91);
11737
11791
 
11738
- case 9:
11792
+ case 13:
11739
11793
  setState({
11740
11794
  isChatWebsocketConnected: true
11741
11795
  });
11742
- return _context22.abrupt("break", 68);
11796
+ return _context22.abrupt("break", 91);
11743
11797
 
11744
- case 11:
11798
+ case 15:
11745
11799
  _ref = payload, eventKey = _ref.eventKey, data = _ref.data;
11746
11800
  publishEvent(eventKey, data);
11747
- return _context22.abrupt("break", 68);
11801
+ return _context22.abrupt("break", 91);
11748
11802
 
11749
- case 14:
11803
+ case 18:
11750
11804
  _ref2 = payload, analytics = _ref2.analytics;
11751
11805
  analyticsCallback = adaSettings.analyticsCallback;
11752
11806
 
@@ -11754,28 +11808,28 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11754
11808
  analyticsCallback(analytics);
11755
11809
  }
11756
11810
 
11757
- return _context22.abrupt("break", 68);
11811
+ return _context22.abrupt("break", 91);
11758
11812
 
11759
- case 18:
11813
+ case 22:
11760
11814
  client = this.props.client;
11761
11815
  _ref3 = payload, chatter = _ref3.chatter, created = _ref3.created;
11762
11816
  chatterTokenCallback = adaSettings.chatterTokenCallback;
11763
11817
 
11764
11818
  if (client) {
11765
- _context22.next = 23;
11819
+ _context22.next = 27;
11766
11820
  break;
11767
11821
  }
11768
11822
 
11769
11823
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
11770
11824
 
11771
- case 23:
11772
- _context22.next = 25;
11825
+ case 27:
11826
+ _context22.next = 29;
11773
11827
  return setState({
11774
11828
  chatterToken: chatter,
11775
11829
  chatterCreated: created
11776
11830
  });
11777
11831
 
11778
- case 25:
11832
+ case 29:
11779
11833
  /**
11780
11834
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11781
11835
  * come from chat. This is important for campaign and business event triggers.
@@ -11792,26 +11846,26 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11792
11846
  chatterTokenCallback(chatter);
11793
11847
  }
11794
11848
 
11795
- return _context22.abrupt("break", 68);
11849
+ return _context22.abrupt("break", 91);
11796
11850
 
11797
- case 28:
11851
+ case 32:
11798
11852
  _client = this.props.client;
11799
11853
  _ref4 = payload, zdSessionId = _ref4.zdSessionId, zdPreviousTags = _ref4.zdPreviousTags;
11800
11854
 
11801
11855
  if (_client) {
11802
- _context22.next = 32;
11856
+ _context22.next = 36;
11803
11857
  break;
11804
11858
  }
11805
11859
 
11806
11860
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
11807
11861
 
11808
- case 32:
11809
- _context22.next = 34;
11862
+ case 36:
11863
+ _context22.next = 38;
11810
11864
  return setState({
11811
11865
  zdSessionId: zdSessionId
11812
11866
  });
11813
11867
 
11814
- case 34:
11868
+ case 38:
11815
11869
  storage = function () {
11816
11870
  if (_client.persistence === PERSISTENCE_NORMAL) {
11817
11871
  return safeLocalStorage;
@@ -11838,17 +11892,25 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11838
11892
  }
11839
11893
  }
11840
11894
 
11841
- return _context22.abrupt("break", 68);
11895
+ return _context22.abrupt("break", 91);
11842
11896
 
11843
- case 37:
11897
+ case 41:
11844
11898
  _client2 = this.props.client;
11845
11899
  _ref5 = payload, inLiveChat = _ref5.inLiveChat;
11846
- _context22.next = 41;
11900
+ _context22.next = 45;
11847
11901
  return setState({
11848
11902
  chatterInLiveChat: inLiveChat
11849
11903
  });
11850
11904
 
11851
- case 41:
11905
+ case 45:
11906
+ if (_client2) {
11907
+ _context22.next = 47;
11908
+ break;
11909
+ }
11910
+
11911
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
11912
+
11913
+ case 47:
11852
11914
  /**
11853
11915
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11854
11916
  * come from chat. This is important for campaign and business event triggers.
@@ -11859,19 +11921,19 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11859
11921
  safeSessionStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
11860
11922
  }
11861
11923
 
11862
- return _context22.abrupt("break", 68);
11924
+ return _context22.abrupt("break", 91);
11863
11925
 
11864
- case 43:
11926
+ case 49:
11865
11927
  eventCallbacks = adaSettings.eventCallbacks;
11866
11928
 
11867
11929
  if (eventCallbacks) {
11868
- _context22.next = 46;
11930
+ _context22.next = 52;
11869
11931
  break;
11870
11932
  }
11871
11933
 
11872
- return _context22.abrupt("break", 68);
11934
+ return _context22.abrupt("break", 91);
11873
11935
 
11874
- case 46:
11936
+ case 52:
11875
11937
  customJavascriptEvent = payload.event_data;
11876
11938
  specificCallback = eventCallbacks[customJavascriptEvent.event_name];
11877
11939
  genericCallback = eventCallbacks["*"];
@@ -11884,65 +11946,107 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11884
11946
  genericCallback(customJavascriptEvent);
11885
11947
  }
11886
11948
 
11887
- return _context22.abrupt("break", 68);
11949
+ return _context22.abrupt("break", 91);
11888
11950
 
11889
- case 52:
11951
+ case 58:
11890
11952
  resetChat = this.props.resetChat;
11891
11953
  resetChat();
11892
- return _context22.abrupt("break", 68);
11954
+ return _context22.abrupt("break", 91);
11893
11955
 
11894
- case 55:
11956
+ case 61:
11895
11957
  zdChatterAuthCallback = adaSettings.zdChatterAuthCallback;
11896
11958
 
11897
- if (zdChatterAuthCallback) {
11898
- try {
11899
- zdChatterAuthCallback(function (token) {
11900
- _this4.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {
11901
- token: token
11902
- }, id);
11903
- });
11904
- } catch (e) {
11905
- console.warn("Function for zdChatterAuthCallback produced an error - please ensure the callback is functioning normally");
11906
- this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11959
+ if (!zdChatterAuthCallback) {
11960
+ _context22.next = 75;
11961
+ break;
11962
+ }
11963
+
11964
+ _context22.prev = 63;
11965
+ zdChatterAuthCallback(function (token) {
11966
+ if (!_this4.channel) {
11967
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11907
11968
  }
11908
- } else {
11909
- this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11969
+
11970
+ _this4.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {
11971
+ token: token
11972
+ }, id);
11973
+ });
11974
+ _context22.next = 73;
11975
+ break;
11976
+
11977
+ case 67:
11978
+ _context22.prev = 67;
11979
+ _context22.t1 = _context22["catch"](63);
11980
+ console.warn("Function for zdChatterAuthCallback produced an error - please ensure the callback is functioning normally");
11981
+
11982
+ if (this.channel) {
11983
+ _context22.next = 72;
11984
+ break;
11910
11985
  }
11911
11986
 
11912
- return _context22.abrupt("break", 68);
11987
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11913
11988
 
11914
- case 58:
11989
+ case 72:
11990
+ this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11991
+
11992
+ case 73:
11993
+ _context22.next = 78;
11994
+ break;
11995
+
11996
+ case 75:
11997
+ if (this.channel) {
11998
+ _context22.next = 77;
11999
+ break;
12000
+ }
12001
+
12002
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
12003
+
12004
+ case 77:
12005
+ this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
12006
+
12007
+ case 78:
12008
+ return _context22.abrupt("break", 91);
12009
+
12010
+ case 79:
11915
12011
  this.handleNotifications(payload);
11916
- return _context22.abrupt("break", 68);
12012
+ return _context22.abrupt("break", 91);
11917
12013
 
11918
- case 60:
12014
+ case 81:
12015
+ if (this.channel) {
12016
+ _context22.next = 83;
12017
+ break;
12018
+ }
12019
+
12020
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
12021
+
12022
+ case 83:
11919
12023
  this.channel.postMessage(BROWSER_HAS_NOTIFICATIONS_RESPONSE_EVENT, {
11920
12024
  browserHasNotificationSupport: browserHasNotificationSupport
11921
12025
  });
11922
- return _context22.abrupt("break", 68);
12026
+ return _context22.abrupt("break", 91);
11923
12027
 
11924
- case 62:
12028
+ case 85:
11925
12029
  requestNotificationPermission();
11926
- return _context22.abrupt("break", 68);
12030
+ return _context22.abrupt("break", 91);
11927
12031
 
11928
- case 64:
12032
+ case 87:
11929
12033
  conversationEndCallback = adaSettings.conversationEndCallback;
11930
12034
 
11931
12035
  if (conversationEndCallback) {
11932
12036
  conversationEndCallback(payload);
11933
12037
  }
11934
12038
 
11935
- return _context22.abrupt("break", 68);
12039
+ return _context22.abrupt("break", 91);
11936
12040
 
11937
- case 67:
11938
- return _context22.abrupt("break", 68);
12041
+ case 90:
12042
+ return _context22.abrupt("break", 91);
11939
12043
 
11940
- case 68:
12044
+ case 91:
11941
12045
  case "end":
11942
12046
  return _context22.stop();
11943
12047
  }
11944
12048
  }
11945
- }, _callee, this);
12049
+ }, _callee, this, [[63, 67]]);
11946
12050
  }));
11947
12051
 
11948
12052
  function handleChatEvent(_x, _x2, _x3) {
@@ -11956,19 +12060,25 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11956
12060
  value: function bindChatEventHandlers() {
11957
12061
  var _this5 = this;
11958
12062
 
11959
- var _this$props9 = this.props,
11960
- name = _this$props9.name,
11961
- messageService = _this$props9.messageService;
11962
- messageService.getChannel(name).addEventListener(function (type, payload, id) {
12063
+ var _this$props10 = this.props,
12064
+ name = _this$props10.name,
12065
+ messageService = _this$props10.messageService;
12066
+ var channel = messageService.getChannel(name);
12067
+
12068
+ if (!channel) {
12069
+ throw new errors/* AdaEmbedError */.S("`channel` is not defined");
12070
+ }
12071
+
12072
+ channel.addEventListener(function (type, payload, id) {
11963
12073
  _this5.handleChatEvent(type, payload, id);
11964
12074
  });
11965
12075
  }
11966
12076
  }, {
11967
12077
  key: "render",
11968
12078
  value: function render() {
11969
- var _this$props10 = this.props,
11970
- name = _this$props10.name,
11971
- isDrawerOpen = _this$props10.isDrawerOpen;
12079
+ var _this$props11 = this.props,
12080
+ name = _this$props11.name,
12081
+ isDrawerOpen = _this$props11.isDrawerOpen;
11972
12082
  var iFrameName = "ada-".concat(name, "-frame");
11973
12083
  return v("iframe", {
11974
12084
  src: this.url,
@@ -13980,7 +14090,7 @@ window.__AdaEmbedConstructor = Embed;
13980
14090
  /* harmony export */ });
13981
14091
  var isModern = new RegExp("((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(14|(1[5-9]|[2-9]\\d|\\d{3,}))[_.]\\d+(?:[_.]\\d+)?)|((Chromium|Chrome)\\/(92|(9[3-9]|\\d{3,}))\\.\\d+(?:\\.\\d+)?)|(Version\\/(14|(1[5-9]|[2-9]\\d|\\d{3,}))\\.\\d+(?:\\.\\d+)? Safari\\/)|(Firefox\\/(91|(9[2-9]|\\d{3,}))\\.\\d+\\.\\d+)|(Firefox\\/(91|(9[2-9]|\\d{3,}))\\.\\d+(pre|[ab]\\d+[a-z]*)?)").test(navigator.userAgent);
13982
14092
  var isProduction = "production" === "production";
13983
- var embed2Version = "4562505";
14093
+ var embed2Version = "036d569";
13984
14094
 
13985
14095
  /***/ }),
13986
14096
 
@@ -14313,9 +14423,9 @@ function _log() {
14313
14423
  service: "embed",
14314
14424
  env: "production",
14315
14425
  embedVersion: 2,
14316
- version: "1.0.49",
14426
+ version: "1.0.53",
14317
14427
  isNpm: true,
14318
- commitHash: "4562505"
14428
+ commitHash: "036d569"
14319
14429
  }))
14320
14430
  });
14321
14431
 
@@ -23790,7 +23900,7 @@ function _loadEmbed() {
23790
23900
  polyfillVersionString = "legacy";
23791
23901
  }
23792
23902
 
23793
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "4562505", "/index.js");
23903
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "036d569", "/index.js");
23794
23904
  }
23795
23905
 
23796
23906
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -24328,7 +24438,7 @@ function createEmbedObject() {
24328
24438
  }
24329
24439
  ;// CONCATENATED MODULE: ./src/index-npm.ts
24330
24440
 
24331
- Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 9136));
24441
+ Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 356));
24332
24442
  /* harmony default export */ var index_npm = (createEmbedObject());
24333
24443
  }();
24334
24444
  module.exports = __webpack_exports__;
@@ -0,0 +1 @@
1
+ export declare const NO_OP_FUNCTION: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.49",
3
+ "version": "1.0.53",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",