@ada-support/embed2 1.5.3 → 1.6.4

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,6 +1,6 @@
1
1
  export declare const CHATTER_TOKEN_STORAGE_KEY = "chatter";
2
2
  export declare const CHATTER_CREATED_STORAGE_KEY = "ada-embed_chatter-created";
3
- export declare const SESSION_AUTH_TOKEN_STORAGE_KEY = "session_token";
3
+ export declare const SESSION_AUTH_TOKEN_STORAGE_KEY = "ada-embed_session-token";
4
4
  export declare const IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
5
5
  export declare const ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
6
6
  export declare const ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
@@ -31,6 +31,9 @@ export interface EmbedRequestPayloadByEvent {
31
31
  TRIGGER_ANSWER: {
32
32
  answerId: string;
33
33
  };
34
+ SET_LANGUAGE: {
35
+ language: string;
36
+ };
34
37
  }
35
38
  export declare type EmbedRequestEvent = keyof EmbedRequestPayloadByEvent;
36
39
  export interface EmbedResponsePayloadByEvent {
@@ -26,6 +26,7 @@ export declare class Client {
26
26
  button_text: LanguageMap;
27
27
  };
28
28
  };
29
+ translated_languages: string[];
29
30
  [key: string]: unknown;
30
31
  constructor(clientResponse: ClientResponse["client"]);
31
32
  }
@@ -36,6 +36,7 @@ export interface ClientObject {
36
36
  intro?: CurrentIntro;
37
37
  features: Features;
38
38
  marketing_campaigns_order?: string[];
39
+ translated_languages: string[];
39
40
  [key: string]: unknown;
40
41
  }
41
42
  export interface CachedClientObject {
@@ -7,6 +7,7 @@ export interface StoreState extends StartOptionsNoFunction {
7
7
  chatterToken?: string | null;
8
8
  sessionToken?: string | null;
9
9
  client?: Client;
10
+ enabledLanguages: string[];
10
11
  isDrawerOpen: boolean;
11
12
  zdSessionId?: string | null;
12
13
  zdPreviousTags?: string | null;
@@ -15806,7 +15806,7 @@ const client = new error_tracker_BrowserClient({
15806
15806
  },
15807
15807
 
15808
15808
  environment: "production",
15809
- release: "1.5.3-2ed66a8",
15809
+ release: "1.6.4-b0afd4b",
15810
15810
  sampleRate: 0.25,
15811
15811
  autoSessionTracking: false,
15812
15812
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -16436,7 +16436,7 @@ function getEmbedURL(_ref) {
16436
16436
  host = "http://".concat(window.location.hostname, ":9001");
16437
16437
  }
16438
16438
 
16439
- return "".concat(host, "/embed/").concat(frameName, "/").concat("2ed66a8", "/index.html");
16439
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("b0afd4b", "/index.html");
16440
16440
  }
16441
16441
 
16442
16442
  function constructQueryString(query) {
@@ -16635,7 +16635,7 @@ const actions = {
16635
16635
  ;// CONCATENATED MODULE: ./src/common/constants/storage-keys.ts
16636
16636
  const CHATTER_TOKEN_STORAGE_KEY = "chatter";
16637
16637
  const CHATTER_CREATED_STORAGE_KEY = "ada-embed_chatter-created";
16638
- const SESSION_AUTH_TOKEN_STORAGE_KEY = "session_token";
16638
+ const SESSION_AUTH_TOKEN_STORAGE_KEY = "ada-embed_session-token";
16639
16639
  const IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
16640
16640
  const ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
16641
16641
  const ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
@@ -16644,7 +16644,7 @@ const ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY = "ada-embed_zd-messaging-extern
16644
16644
  const ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY = "ada-embed_zd-messaging-chatter-created";
16645
16645
  /** @deprecated - Use CHATTER_TOKEN_STORAGE_KEY */
16646
16646
 
16647
- const CHATTER_STORAGE_KEY = CHATTER_TOKEN_STORAGE_KEY;
16647
+ const CHATTER_STORAGE_KEY = (/* unused pure expression or super */ null && (CHATTER_TOKEN_STORAGE_KEY));
16648
16648
  ;// CONCATENATED MODULE: ./src/frames/lib/safe-storage/index.ts
16649
16649
 
16650
16650
 
@@ -17088,6 +17088,7 @@ const getInitialState = adaSettings => ({
17088
17088
  parentElement: undefined,
17089
17089
  isDrawerOpen: false,
17090
17090
  drawerHasBeenOpened: false,
17091
+ enabledLanguages: ["en"],
17091
17092
  client: undefined,
17092
17093
  isIntroShown: false,
17093
17094
  wasIntroShown: false,
@@ -18005,7 +18006,7 @@ function _objectWithoutProperties(source, excluded) {
18005
18006
  ;// CONCATENATED MODULE: ./src/common/models/client/index.ts
18006
18007
 
18007
18008
 
18008
- const _excluded = ["chat", "chat_button", "features", "handle", "language", "persistence", "privacy", "rollout", "tint"];
18009
+ const _excluded = ["chat", "chat_button", "features", "handle", "language", "persistence", "privacy", "rollout", "tint", "translated_languages"];
18009
18010
 
18010
18011
  class Client {
18011
18012
  constructor(clientResponse) {
@@ -18037,6 +18038,8 @@ class Client {
18037
18038
 
18038
18039
  _defineProperty(this, "ui_settings", void 0);
18039
18040
 
18041
+ _defineProperty(this, "translated_languages", void 0);
18042
+
18040
18043
  const {
18041
18044
  chat,
18042
18045
  chat_button: chatButton,
@@ -18046,7 +18049,9 @@ class Client {
18046
18049
  persistence,
18047
18050
  privacy,
18048
18051
  rollout,
18049
- tint
18052
+ tint,
18053
+ // eslint-disable-next-line @typescript-eslint/naming-convention
18054
+ translated_languages
18050
18055
  } = clientResponse,
18051
18056
  rest = _objectWithoutProperties(clientResponse, _excluded);
18052
18057
 
@@ -18059,6 +18064,7 @@ class Client {
18059
18064
  this.privacy = privacy;
18060
18065
  this.rollout = rollout;
18061
18066
  this.tint = tint;
18067
+ this.translated_languages = translated_languages;
18062
18068
  /**
18063
18069
  * Even if some properties are not used by Embed2, they may be used by Chat.
18064
18070
  * Chat can "pull" the client object from Embed2 in order to reduce an API
@@ -18186,9 +18192,9 @@ async function log(message, extra, options) {
18186
18192
  service: "embed",
18187
18193
  env: "production",
18188
18194
  embedVersion: 2,
18189
- version: "1.5.3",
18195
+ version: "1.6.4",
18190
18196
  isNpm: true,
18191
- commitHash: "2ed66a8"
18197
+ commitHash: "b0afd4b"
18192
18198
  }))
18193
18199
  });
18194
18200
  }
@@ -18620,20 +18626,17 @@ const isMobile = /(iPhone)|(iPod)|(android)|(webOS)/i.exec(navigator.userAgent)
18620
18626
 
18621
18627
  function storeChatterEventDataInBrowser(client, payload) {
18622
18628
  const {
18623
- persistence,
18624
- features
18625
- } = client; // TODO: CHATX-1618 please remove the line below - the ff won't be needed anymore
18626
-
18627
- const isChatSessionAuthEnabled = features.chat_session_auth;
18629
+ persistence
18630
+ } = client;
18628
18631
  const {
18629
18632
  chatter,
18630
18633
  created,
18631
18634
  sessionToken
18632
18635
  } = payload;
18633
- setBrowserStorageItem(CHATTER_STORAGE_KEY, chatter, persistence);
18634
- setBrowserStorageItem(CHATTER_CREATED_STORAGE_KEY, created, persistence); // TODO: CHATX-1618 please remove the check for isChatSessionAuthEnabled - the Boolean(sessionToken) is still needed so we don't store falsy values
18636
+ setBrowserStorageItem(CHATTER_TOKEN_STORAGE_KEY, chatter, persistence);
18637
+ setBrowserStorageItem(CHATTER_CREATED_STORAGE_KEY, created, persistence);
18635
18638
 
18636
- if (isChatSessionAuthEnabled && Boolean(sessionToken)) {
18639
+ if (sessionToken) {
18637
18640
  setBrowserStorageItem(SESSION_AUTH_TOKEN_STORAGE_KEY, sessionToken, persistence);
18638
18641
  }
18639
18642
  }
@@ -18761,7 +18764,7 @@ class ChatFrame extends d {
18761
18764
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18762
18765
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18763
18766
  const queryParams = {
18764
- embedVersion: "2ed66a8".slice(0, 7),
18767
+ embedVersion: "b0afd4b".slice(0, 7),
18765
18768
  greeting,
18766
18769
  language,
18767
18770
  skipGreeting,
@@ -20503,6 +20506,7 @@ class Container extends d {
20503
20506
  try {
20504
20507
  await setState(Container_objectSpread(Container_objectSpread({
20505
20508
  client: newClient,
20509
+ enabledLanguages: newClient.features.translations ? ["en"].concat(newClient.translated_languages) : ["en"],
20506
20510
  initialURL: window.location.href,
20507
20511
  isIntroShown: false
20508
20512
  }, adaSettingsWithoutFunctions), {}, {
@@ -20976,7 +20980,7 @@ class Embed {
20976
20980
 
20977
20981
  }
20978
20982
 
20979
- _defineProperty(Embed, "embed2Version", "2ed66a8");
20983
+ _defineProperty(Embed, "embed2Version", "b0afd4b");
20980
20984
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20981
20985
 
20982
20986
 
@@ -21135,26 +21139,35 @@ function createEmbedObject() {
21135
21139
  await waitForEmbedInit();
21136
21140
  return (_embed13 = embed) === null || _embed13 === void 0 ? void 0 : _embed13.setDeviceToken(token);
21137
21141
  },
21138
- handleNotification: async () => {
21142
+ setLanguage: async language => {
21139
21143
  var _embed14;
21140
21144
 
21141
21145
  await waitForEmbedInit();
21142
- const windowInfo = await ((_embed14 = embed) === null || _embed14 === void 0 ? void 0 : _embed14.getInfo());
21146
+ const channel = (_embed14 = embed) === null || _embed14 === void 0 ? void 0 : _embed14.messageService.getChannel("chat");
21147
+ channel === null || channel === void 0 ? void 0 : channel.postMessage("SET_LANGUAGE", {
21148
+ language
21149
+ });
21150
+ },
21151
+ handleNotification: async () => {
21152
+ var _embed15;
21153
+
21154
+ await waitForEmbedInit();
21155
+ const windowInfo = await ((_embed15 = embed) === null || _embed15 === void 0 ? void 0 : _embed15.getInfo());
21143
21156
 
21144
21157
  if (!windowInfo) {
21145
21158
  return;
21146
21159
  }
21147
21160
 
21148
21161
  if (!windowInfo.isChatOpen) {
21149
- var _embed15;
21162
+ var _embed16;
21150
21163
 
21151
- (_embed15 = embed) === null || _embed15 === void 0 ? void 0 : _embed15.toggle();
21164
+ (_embed16 = embed) === null || _embed16 === void 0 ? void 0 : _embed16.toggle();
21152
21165
  }
21153
21166
  },
21154
21167
  triggerAnswer: answerId => {
21155
- var _embed16;
21168
+ var _embed17;
21156
21169
 
21157
- const channel = (_embed16 = embed) === null || _embed16 === void 0 ? void 0 : _embed16.messageService.getChannel("chat");
21170
+ const channel = (_embed17 = embed) === null || _embed17 === void 0 ? void 0 : _embed17.messageService.getChannel("chat");
21158
21171
  channel === null || channel === void 0 ? void 0 : channel.postMessage("TRIGGER_ANSWER", {
21159
21172
  answerId
21160
21173
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.5.3",
3
+ "version": "1.6.4",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",