@ada-support/embed2 1.5.4 → 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.
@@ -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.4-8867424",
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("8867424", "/index.html");
16439
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("b0afd4b", "/index.html");
16440
16440
  }
16441
16441
 
16442
16442
  function constructQueryString(query) {
@@ -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.4",
18195
+ version: "1.6.4",
18190
18196
  isNpm: true,
18191
- commitHash: "8867424"
18197
+ commitHash: "b0afd4b"
18192
18198
  }))
18193
18199
  });
18194
18200
  }
@@ -18758,7 +18764,7 @@ class ChatFrame extends d {
18758
18764
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18759
18765
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18760
18766
  const queryParams = {
18761
- embedVersion: "8867424".slice(0, 7),
18767
+ embedVersion: "b0afd4b".slice(0, 7),
18762
18768
  greeting,
18763
18769
  language,
18764
18770
  skipGreeting,
@@ -20500,6 +20506,7 @@ class Container extends d {
20500
20506
  try {
20501
20507
  await setState(Container_objectSpread(Container_objectSpread({
20502
20508
  client: newClient,
20509
+ enabledLanguages: newClient.features.translations ? ["en"].concat(newClient.translated_languages) : ["en"],
20503
20510
  initialURL: window.location.href,
20504
20511
  isIntroShown: false
20505
20512
  }, adaSettingsWithoutFunctions), {}, {
@@ -20973,7 +20980,7 @@ class Embed {
20973
20980
 
20974
20981
  }
20975
20982
 
20976
- _defineProperty(Embed, "embed2Version", "8867424");
20983
+ _defineProperty(Embed, "embed2Version", "b0afd4b");
20977
20984
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20978
20985
 
20979
20986
 
@@ -21132,26 +21139,35 @@ function createEmbedObject() {
21132
21139
  await waitForEmbedInit();
21133
21140
  return (_embed13 = embed) === null || _embed13 === void 0 ? void 0 : _embed13.setDeviceToken(token);
21134
21141
  },
21135
- handleNotification: async () => {
21142
+ setLanguage: async language => {
21136
21143
  var _embed14;
21137
21144
 
21138
21145
  await waitForEmbedInit();
21139
- 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());
21140
21156
 
21141
21157
  if (!windowInfo) {
21142
21158
  return;
21143
21159
  }
21144
21160
 
21145
21161
  if (!windowInfo.isChatOpen) {
21146
- var _embed15;
21162
+ var _embed16;
21147
21163
 
21148
- (_embed15 = embed) === null || _embed15 === void 0 ? void 0 : _embed15.toggle();
21164
+ (_embed16 = embed) === null || _embed16 === void 0 ? void 0 : _embed16.toggle();
21149
21165
  }
21150
21166
  },
21151
21167
  triggerAnswer: answerId => {
21152
- var _embed16;
21168
+ var _embed17;
21153
21169
 
21154
- 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");
21155
21171
  channel === null || channel === void 0 ? void 0 : channel.postMessage("TRIGGER_ANSWER", {
21156
21172
  answerId
21157
21173
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.5.4",
3
+ "version": "1.6.4",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",