@ada-support/embed2 1.0.78 → 1.0.81

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.
@@ -14,6 +14,7 @@ export interface StartOptions {
14
14
  sensitiveMetaFields?: Record<string, unknown>;
15
15
  parentElement?: string | HTMLElement;
16
16
  privateMode?: boolean;
17
+ chatFrameTimeoutCallback?(): void;
17
18
  adaReadyCallback?(params: {
18
19
  isRolledOut: boolean;
19
20
  }): void;
@@ -8788,7 +8788,7 @@ var client = new error_tracker_BrowserClient({
8788
8788
  return event;
8789
8789
  },
8790
8790
  environment: "production",
8791
- release: "1.0.78-033c4a1",
8791
+ release: "1.0.81-52718e8",
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
@@ -9490,7 +9490,7 @@ function getEmbedURL(_ref) {
9490
9490
  polyfillVersionString = "legacy";
9491
9491
  }
9492
9492
 
9493
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "033c4a1", "/index.html");
9493
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "52718e8", "/index.html");
9494
9494
  }
9495
9495
  /**
9496
9496
  * Generate the Chat / API URL
@@ -11618,6 +11618,8 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11618
11618
 
11619
11619
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "channel", void 0);
11620
11620
 
11621
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "chatRenderTimeout", void 0);
11622
+
11621
11623
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "state", {
11622
11624
  isMounted: false,
11623
11625
  closeTransitionTime: 200
@@ -11942,7 +11944,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11942
11944
  case 0:
11943
11945
  _this$props9 = this.props, adaSettings = _this$props9.adaSettings, setState = _this$props9.setState, setConnectionState = _this$props9.setConnectionState;
11944
11946
  _context22.t0 = type;
11945
- _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 === ZD_MESSAGING_HANDOFF ? 41 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 50 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 58 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 67 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 70 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 88 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 90 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 94 : _context22.t0 === END_CONVERSATION_EVENT ? 96 : 99;
11947
+ _context22.next = _context22.t0 === GET_WINDOW_ORIGIN ? 4 : _context22.t0 === CHAT_STARTED ? 8 : _context22.t0 === CHAT_WEBSOCKET_CONNECTED ? 14 : _context22.t0 === PUBLISH_EVENT ? 16 : _context22.t0 === ANALYTICS_EVENT ? 19 : _context22.t0 === CHATTER_EVENT ? 23 : _context22.t0 === "ZD_SESSION" ? 33 : _context22.t0 === ZD_MESSAGING_HANDOFF ? 42 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 51 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 59 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 68 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 71 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 89 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 91 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 95 : _context22.t0 === END_CONVERSATION_EVENT ? 97 : 100;
11946
11948
  break;
11947
11949
 
11948
11950
  case 4:
@@ -11955,7 +11957,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11955
11957
 
11956
11958
  case 6:
11957
11959
  this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11958
- return _context22.abrupt("break", 100);
11960
+ return _context22.abrupt("break", 101);
11959
11961
 
11960
11962
  case 8:
11961
11963
  if (this.channel) {
@@ -11966,24 +11968,25 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11966
11968
  throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11967
11969
 
11968
11970
  case 10:
11971
+ clearTimeout(this.chatRenderTimeout);
11969
11972
  this.channel.isConnected = true;
11970
11973
  setConnectionState({
11971
11974
  "chat": ConnectionState.Done
11972
11975
  });
11973
- return _context22.abrupt("break", 100);
11976
+ return _context22.abrupt("break", 101);
11974
11977
 
11975
- case 13:
11978
+ case 14:
11976
11979
  setState({
11977
11980
  isChatWebsocketConnected: true
11978
11981
  });
11979
- return _context22.abrupt("break", 100);
11982
+ return _context22.abrupt("break", 101);
11980
11983
 
11981
- case 15:
11984
+ case 16:
11982
11985
  _ref = payload, eventKey = _ref.eventKey, data = _ref.data;
11983
11986
  publishEvent(eventKey, data);
11984
- return _context22.abrupt("break", 100);
11987
+ return _context22.abrupt("break", 101);
11985
11988
 
11986
- case 18:
11989
+ case 19:
11987
11990
  _ref2 = payload, analytics = _ref2.analytics;
11988
11991
  analyticsCallback = adaSettings.analyticsCallback;
11989
11992
 
@@ -11991,28 +11994,28 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11991
11994
  analyticsCallback(analytics);
11992
11995
  }
11993
11996
 
11994
- return _context22.abrupt("break", 100);
11997
+ return _context22.abrupt("break", 101);
11995
11998
 
11996
- case 22:
11999
+ case 23:
11997
12000
  client = this.props.client;
11998
12001
  _ref3 = payload, chatter = _ref3.chatter, created = _ref3.created;
11999
12002
  chatterTokenCallback = adaSettings.chatterTokenCallback;
12000
12003
 
12001
12004
  if (client) {
12002
- _context22.next = 27;
12005
+ _context22.next = 28;
12003
12006
  break;
12004
12007
  }
12005
12008
 
12006
12009
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
12007
12010
 
12008
- case 27:
12009
- _context22.next = 29;
12011
+ case 28:
12012
+ _context22.next = 30;
12010
12013
  return setState({
12011
12014
  chatterToken: chatter,
12012
12015
  chatterCreated: created
12013
12016
  });
12014
12017
 
12015
- case 29:
12018
+ case 30:
12016
12019
  /**
12017
12020
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
12018
12021
  * come from chat. This is important for campaign and business event triggers.
@@ -12029,26 +12032,26 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12029
12032
  chatterTokenCallback(chatter);
12030
12033
  }
12031
12034
 
12032
- return _context22.abrupt("break", 100);
12035
+ return _context22.abrupt("break", 101);
12033
12036
 
12034
- case 32:
12037
+ case 33:
12035
12038
  _client = this.props.client;
12036
12039
  _ref4 = payload, zdSessionId = _ref4.zdSessionId, zdPreviousTags = _ref4.zdPreviousTags;
12037
12040
 
12038
12041
  if (_client) {
12039
- _context22.next = 36;
12042
+ _context22.next = 37;
12040
12043
  break;
12041
12044
  }
12042
12045
 
12043
12046
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
12044
12047
 
12045
- case 36:
12046
- _context22.next = 38;
12048
+ case 37:
12049
+ _context22.next = 39;
12047
12050
  return setState({
12048
12051
  zdSessionId: zdSessionId
12049
12052
  });
12050
12053
 
12051
- case 38:
12054
+ case 39:
12052
12055
  storage = function () {
12053
12056
  if (_client.persistence === PERSISTENCE_NORMAL) {
12054
12057
  return safeLocalStorage;
@@ -12075,27 +12078,27 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12075
12078
  }
12076
12079
  }
12077
12080
 
12078
- return _context22.abrupt("break", 100);
12081
+ return _context22.abrupt("break", 101);
12079
12082
 
12080
- case 41:
12083
+ case 42:
12081
12084
  _client2 = this.props.client;
12082
12085
  _ref5 = payload, zdMessagingExternalUserId = _ref5.zdMessagingExternalUserId, zdMessagingChatterCreated = _ref5.zdMessagingChatterCreated;
12083
12086
 
12084
12087
  if (_client2) {
12085
- _context22.next = 45;
12088
+ _context22.next = 46;
12086
12089
  break;
12087
12090
  }
12088
12091
 
12089
12092
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
12090
12093
 
12091
- case 45:
12092
- _context22.next = 47;
12094
+ case 46:
12095
+ _context22.next = 48;
12093
12096
  return setState({
12094
12097
  zdMessagingExternalUserId: zdMessagingExternalUserId,
12095
12098
  zdMessagingChatterCreated: zdMessagingChatterCreated
12096
12099
  });
12097
12100
 
12098
- case 47:
12101
+ case 48:
12099
12102
  if (zdMessagingExternalUserId === null) {
12100
12103
  safeLocalStorage.removeItem(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY);
12101
12104
  } else {
@@ -12108,25 +12111,25 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12108
12111
  safeLocalStorage.setItem(ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY, zdMessagingChatterCreated);
12109
12112
  }
12110
12113
 
12111
- return _context22.abrupt("break", 100);
12114
+ return _context22.abrupt("break", 101);
12112
12115
 
12113
- case 50:
12116
+ case 51:
12114
12117
  _client3 = this.props.client;
12115
12118
  _ref6 = payload, inLiveChat = _ref6.inLiveChat;
12116
- _context22.next = 54;
12119
+ _context22.next = 55;
12117
12120
  return setState({
12118
12121
  chatterInLiveChat: inLiveChat
12119
12122
  });
12120
12123
 
12121
- case 54:
12124
+ case 55:
12122
12125
  if (_client3) {
12123
- _context22.next = 56;
12126
+ _context22.next = 57;
12124
12127
  break;
12125
12128
  }
12126
12129
 
12127
12130
  throw new errors/* AdaEmbedError */.S("`client` is not defined");
12128
12131
 
12129
- case 56:
12132
+ case 57:
12130
12133
  /**
12131
12134
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
12132
12135
  * come from chat. This is important for campaign and business event triggers.
@@ -12137,19 +12140,19 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12137
12140
  safeSessionStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
12138
12141
  }
12139
12142
 
12140
- return _context22.abrupt("break", 100);
12143
+ return _context22.abrupt("break", 101);
12141
12144
 
12142
- case 58:
12145
+ case 59:
12143
12146
  eventCallbacks = adaSettings.eventCallbacks;
12144
12147
 
12145
12148
  if (eventCallbacks) {
12146
- _context22.next = 61;
12149
+ _context22.next = 62;
12147
12150
  break;
12148
12151
  }
12149
12152
 
12150
- return _context22.abrupt("break", 100);
12153
+ return _context22.abrupt("break", 101);
12151
12154
 
12152
- case 61:
12155
+ case 62:
12153
12156
  customJavascriptEvent = payload.event_data;
12154
12157
  specificCallback = eventCallbacks[customJavascriptEvent.event_name];
12155
12158
  genericCallback = eventCallbacks["*"];
@@ -12162,22 +12165,22 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12162
12165
  genericCallback(customJavascriptEvent);
12163
12166
  }
12164
12167
 
12165
- return _context22.abrupt("break", 100);
12168
+ return _context22.abrupt("break", 101);
12166
12169
 
12167
- case 67:
12170
+ case 68:
12168
12171
  resetChat = this.props.resetChat;
12169
12172
  resetChat();
12170
- return _context22.abrupt("break", 100);
12173
+ return _context22.abrupt("break", 101);
12171
12174
 
12172
- case 70:
12175
+ case 71:
12173
12176
  zdChatterAuthCallback = adaSettings.zdChatterAuthCallback;
12174
12177
 
12175
12178
  if (!zdChatterAuthCallback) {
12176
- _context22.next = 84;
12179
+ _context22.next = 85;
12177
12180
  break;
12178
12181
  }
12179
12182
 
12180
- _context22.prev = 72;
12183
+ _context22.prev = 73;
12181
12184
  zdChatterAuthCallback(function (token) {
12182
12185
  if (!_this4.channel) {
12183
12186
  throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
@@ -12187,82 +12190,82 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12187
12190
  token: token
12188
12191
  }, id);
12189
12192
  });
12190
- _context22.next = 82;
12193
+ _context22.next = 83;
12191
12194
  break;
12192
12195
 
12193
- case 76:
12194
- _context22.prev = 76;
12195
- _context22.t1 = _context22["catch"](72);
12196
+ case 77:
12197
+ _context22.prev = 77;
12198
+ _context22.t1 = _context22["catch"](73);
12196
12199
  console.warn("Function for zdChatterAuthCallback produced an error - please ensure the callback is functioning normally");
12197
12200
 
12198
12201
  if (this.channel) {
12199
- _context22.next = 81;
12202
+ _context22.next = 82;
12200
12203
  break;
12201
12204
  }
12202
12205
 
12203
12206
  throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
12204
12207
 
12205
- case 81:
12208
+ case 82:
12206
12209
  this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
12207
12210
 
12208
- case 82:
12209
- _context22.next = 87;
12211
+ case 83:
12212
+ _context22.next = 88;
12210
12213
  break;
12211
12214
 
12212
- case 84:
12215
+ case 85:
12213
12216
  if (this.channel) {
12214
- _context22.next = 86;
12217
+ _context22.next = 87;
12215
12218
  break;
12216
12219
  }
12217
12220
 
12218
12221
  throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
12219
12222
 
12220
- case 86:
12221
- this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
12222
-
12223
12223
  case 87:
12224
- return _context22.abrupt("break", 100);
12224
+ this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
12225
12225
 
12226
12226
  case 88:
12227
+ return _context22.abrupt("break", 101);
12228
+
12229
+ case 89:
12227
12230
  this.handleNotifications(payload);
12228
- return _context22.abrupt("break", 100);
12231
+ return _context22.abrupt("break", 101);
12229
12232
 
12230
- case 90:
12233
+ case 91:
12231
12234
  if (this.channel) {
12232
- _context22.next = 92;
12235
+ _context22.next = 93;
12233
12236
  break;
12234
12237
  }
12235
12238
 
12236
12239
  throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
12237
12240
 
12238
- case 92:
12241
+ case 93:
12239
12242
  this.channel.postMessage(BROWSER_HAS_NOTIFICATIONS_RESPONSE_EVENT, {
12240
12243
  browserHasNotificationSupport: browserHasNotificationSupport
12241
12244
  });
12242
- return _context22.abrupt("break", 100);
12245
+ return _context22.abrupt("break", 101);
12243
12246
 
12244
- case 94:
12247
+ case 95:
12245
12248
  requestNotificationPermission();
12246
- return _context22.abrupt("break", 100);
12249
+ return _context22.abrupt("break", 101);
12247
12250
 
12248
- case 96:
12251
+ case 97:
12249
12252
  conversationEndCallback = adaSettings.conversationEndCallback;
12250
12253
 
12251
12254
  if (conversationEndCallback) {
12252
12255
  conversationEndCallback(payload);
12253
12256
  }
12254
12257
 
12255
- return _context22.abrupt("break", 100);
12256
-
12257
- case 99:
12258
- return _context22.abrupt("break", 100);
12258
+ return _context22.abrupt("break", 101);
12259
12259
 
12260
12260
  case 100:
12261
+ return _context22.abrupt("break", 101);
12262
+
12263
+ case 101:
12261
12264
  case "end":
12262
12265
  return _context22.stop();
12263
12266
  }
12264
12267
  }
12265
- }, _callee, this, [[72, 76]]);
12268
+ }, _callee, this, [[73, 77]]);
12266
12269
  }));
12267
12270
 
12268
12271
  function handleChatEvent(_x, _x2, _x3) {
@@ -12289,12 +12292,34 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12289
12292
  _this5.handleChatEvent(type, payload, id);
12290
12293
  });
12291
12294
  }
12295
+ }, {
12296
+ key: "frameLoaded",
12297
+ value: function frameLoaded() {
12298
+ var _this6 = this;
12299
+
12300
+ var _this$props11 = this.props,
12301
+ handle = _this$props11.handle,
12302
+ adaSettings = _this$props11.adaSettings;
12303
+ var chatFrameTimeoutCallback = adaSettings.chatFrameTimeoutCallback;
12304
+ this.chatRenderTimeout = window.setTimeout(function () {
12305
+ var _this6$channel;
12306
+
12307
+ (0,services_logger/* log */.cM)("Chat frame took over 5 seconds to respond", {
12308
+ handle: handle,
12309
+ embedSettings: adaSettings
12310
+ });
12311
+
12312
+ if (chatFrameTimeoutCallback && !((_this6$channel = _this6.channel) !== null && _this6$channel !== void 0 && _this6$channel.isConnected)) {
12313
+ chatFrameTimeoutCallback();
12314
+ }
12315
+ }, 5000);
12316
+ }
12292
12317
  }, {
12293
12318
  key: "render",
12294
12319
  value: function render() {
12295
- var _this$props11 = this.props,
12296
- name = _this$props11.name,
12297
- isDrawerOpen = _this$props11.isDrawerOpen;
12320
+ var _this$props12 = this.props,
12321
+ name = _this$props12.name,
12322
+ isDrawerOpen = _this$props12.isDrawerOpen;
12298
12323
  var iFrameName = "ada-".concat(name, "-frame");
12299
12324
  return v("iframe", {
12300
12325
  src: this.url,
@@ -12308,7 +12333,8 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
12308
12333
  className: iFrameName,
12309
12334
  "aria-expanded": isDrawerOpen,
12310
12335
  allowTransparency: true,
12311
- allowFullScreen: true
12336
+ allowFullScreen: true,
12337
+ onLoad: this.frameLoaded.bind(this)
12312
12338
  });
12313
12339
  }
12314
12340
  }], [{
@@ -14348,7 +14374,7 @@ window.__AdaEmbedConstructor = Embed;
14348
14374
  /* harmony export */ });
14349
14375
  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)\\/(99|([1-9]\\d\\d|\\d{4,}))\\.\\d+(?:\\.\\d+)?)|(Version\\/(15|(1[6-9]|[2-9]\\d|\\d{3,}))\\.\\d+(?:\\.\\d+)? Safari\\/)|(Firefox\\/(98|(99|\\d{3,}))\\.\\d+\\.\\d+)|(Firefox\\/(98|(99|\\d{3,}))\\.\\d+(pre|[ab]\\d+[a-z]*)?)").test(navigator.userAgent);
14350
14376
  var isProduction = "production" === "production";
14351
- var embed2Version = "033c4a1";
14377
+ var embed2Version = "52718e8";
14352
14378
 
14353
14379
  /***/ }),
14354
14380
 
@@ -14694,9 +14720,9 @@ function _log() {
14694
14720
  service: "embed",
14695
14721
  env: "production",
14696
14722
  embedVersion: 2,
14697
- version: "1.0.78",
14723
+ version: "1.0.81",
14698
14724
  isNpm: true,
14699
- commitHash: "033c4a1"
14725
+ commitHash: "52718e8"
14700
14726
  }))
14701
14727
  });
14702
14728
 
@@ -25637,7 +25663,7 @@ function _loadEmbed() {
25637
25663
  polyfillVersionString = "legacy";
25638
25664
  }
25639
25665
 
25640
- embedScriptSource = concat_default()(_context17 = concat_default()(_context18 = "".concat(host, "/embed/")).call(_context18, polyfillVersionString, "/client/")).call(_context17, "033c4a1", "/index.js");
25666
+ embedScriptSource = concat_default()(_context17 = concat_default()(_context18 = "".concat(host, "/embed/")).call(_context18, polyfillVersionString, "/client/")).call(_context17, "52718e8", "/index.js");
25641
25667
  }
25642
25668
 
25643
25669
  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.78",
3
+ "version": "1.0.81",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",