@ada-support/embed2 1.4.1 → 1.4.2

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,3 +1,4 @@
1
+ import type { LanguageKey } from "common/types/languages";
1
2
  /**
2
3
  * Gets a language code from the browser. Stolen from `chat` repo
3
4
  *
@@ -11,5 +12,6 @@
11
12
  *
12
13
  * I'M SO SORRY.
13
14
  */
14
- declare const getBrowserLanguage: () => string;
15
+ export declare function isSupportedLanguageCode(languageCode: string): boolean;
16
+ declare const getBrowserLanguage: () => LanguageKey;
15
17
  export default getBrowserLanguage;
@@ -1,4 +1,51 @@
1
- export declare type LanguageKey = "en" | "da" | "de" | "es" | "fi" | "fr" | "hi" | "ht" | "id" | "it" | "ja" | "km" | "ko" | "ms" | "my" | "no" | "nl" | "pa" | "pt" | "ru" | "sv" | "ta" | "th" | "tl" | "tr" | "vi" | "zh" | "zh-tw" | "bg" | "ro" | "el" | "hu" | "pl" | "cs" | "et" | "hr" | "lt" | "lv" | "sl" | "sk" | "is" | "ar" | "he";
1
+ export declare const Languages: {
2
+ readonly en: "en";
3
+ readonly be: "be";
4
+ readonly da: "da";
5
+ readonly de: "de";
6
+ readonly es: "es";
7
+ readonly fi: "fi";
8
+ readonly fr: "fr";
9
+ readonly hi: "hi";
10
+ readonly ht: "ht";
11
+ readonly id: "id";
12
+ readonly it: "it";
13
+ readonly ja: "ja";
14
+ readonly km: "km";
15
+ readonly ko: "ko";
16
+ readonly ms: "ms";
17
+ readonly my: "my";
18
+ readonly no: "no";
19
+ readonly nl: "nl";
20
+ readonly pa: "pa";
21
+ readonly pt: "pt";
22
+ readonly ru: "ru";
23
+ readonly sv: "sv";
24
+ readonly ta: "ta";
25
+ readonly th: "th";
26
+ readonly tl: "tl";
27
+ readonly tr: "tr";
28
+ readonly uk: "uk";
29
+ readonly vi: "vi";
30
+ readonly zh: "zh";
31
+ readonly "zh-tw": "zh-tw";
32
+ readonly bg: "bg";
33
+ readonly ro: "ro";
34
+ readonly el: "el";
35
+ readonly hu: "hu";
36
+ readonly pl: "pl";
37
+ readonly cs: "cs";
38
+ readonly et: "et";
39
+ readonly hr: "hr";
40
+ readonly lt: "lt";
41
+ readonly lv: "lv";
42
+ readonly sl: "sl";
43
+ readonly sk: "sk";
44
+ readonly is: "is";
45
+ readonly ar: "ar";
46
+ readonly he: "he";
47
+ };
48
+ export declare type LanguageKey = keyof typeof Languages;
2
49
  export declare type LanguageMap = {
3
50
  [K in LanguageKey]?: string;
4
51
  };
@@ -15811,7 +15811,7 @@ const client = new error_tracker_BrowserClient({
15811
15811
  },
15812
15812
 
15813
15813
  environment: "production",
15814
- release: "1.4.1-ef0b30f",
15814
+ release: "1.4.2-7dfe147",
15815
15815
  sampleRate: 0.25,
15816
15816
  autoSessionTracking: false,
15817
15817
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -16432,7 +16432,7 @@ function getEmbedURL(_ref) {
16432
16432
  host = "http://".concat(window.location.hostname, ":9001");
16433
16433
  }
16434
16434
 
16435
- return "".concat(host, "/embed/").concat(frameName, "/").concat("ef0b30f", "/index.html");
16435
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("7dfe147", "/index.html");
16436
16436
  }
16437
16437
 
16438
16438
  function constructQueryString(query) {
@@ -17266,8 +17266,104 @@ const getEventsToTrigger = businessEvents => {
17266
17266
  const eventsToTrigger = businessEvents.filter(businessEvent => businessEvent.trigger_conditions.some(triggerCondition => evalTriggerCondition(triggerCondition)));
17267
17267
  return eventsToTrigger;
17268
17268
  };
17269
+ ;// CONCATENATED MODULE: ./src/common/types/languages.ts
17270
+ const Languages = {
17271
+ en: "en",
17272
+ // English
17273
+ be: "be",
17274
+ // Belarusian
17275
+ da: "da",
17276
+ // Danish
17277
+ de: "de",
17278
+ // German
17279
+ es: "es",
17280
+ // Spanish
17281
+ fi: "fi",
17282
+ // Finnish
17283
+ fr: "fr",
17284
+ // French
17285
+ hi: "hi",
17286
+ // Hindi
17287
+ ht: "ht",
17288
+ // Haitian Creole
17289
+ id: "id",
17290
+ // Indonesian
17291
+ it: "it",
17292
+ // Italian
17293
+ ja: "ja",
17294
+ // Japanese
17295
+ km: "km",
17296
+ // Khmer
17297
+ ko: "ko",
17298
+ // Korean
17299
+ ms: "ms",
17300
+ // Malay
17301
+ my: "my",
17302
+ // Burmese
17303
+ no: "no",
17304
+ // Norwegian
17305
+ nl: "nl",
17306
+ // Dutch
17307
+ pa: "pa",
17308
+ // Punjabi
17309
+ pt: "pt",
17310
+ // Portuguese
17311
+ ru: "ru",
17312
+ // Russian
17313
+ sv: "sv",
17314
+ // Swedish
17315
+ ta: "ta",
17316
+ // Tamil
17317
+ th: "th",
17318
+ // Thai
17319
+ tl: "tl",
17320
+ // Tagalog
17321
+ tr: "tr",
17322
+ // Turkish
17323
+ uk: "uk",
17324
+ // Ukrainian
17325
+ vi: "vi",
17326
+ // Vietnamese
17327
+ zh: "zh",
17328
+ // Chinese simplified
17329
+ "zh-tw": "zh-tw",
17330
+ // Chinese traditional
17331
+ bg: "bg",
17332
+ // Bulgarian
17333
+ ro: "ro",
17334
+ // Romanian
17335
+ el: "el",
17336
+ // Greek
17337
+ hu: "hu",
17338
+ // Hungarian
17339
+ pl: "pl",
17340
+ // Polish
17341
+ cs: "cs",
17342
+ // Czech
17343
+ et: "et",
17344
+ // Estonian
17345
+ hr: "hr",
17346
+ // Croatian
17347
+ lt: "lt",
17348
+ // Lithuanian
17349
+ lv: "lv",
17350
+ // Latvian
17351
+ sl: "sl",
17352
+ // Slovenian
17353
+ sk: "sk",
17354
+ // Slovak
17355
+ is: "is",
17356
+ // Icelandic
17357
+ ar: "ar",
17358
+ // Arabic
17359
+ he: "he" // Hebrew
17360
+
17361
+ };
17269
17362
  ;// CONCATENATED MODULE: ./src/common/helpers/get-browser-language.ts
17363
+
17364
+
17270
17365
  const DEFAULT_LANGUAGE_CODE = "en";
17366
+ const SUPPORTED_LANGUAGES = [...Object.values(Languages)];
17271
17367
  /**
17272
17368
  * Gets a language code from the browser. Stolen from `chat` repo
17273
17369
  *
@@ -17282,7 +17378,29 @@ const DEFAULT_LANGUAGE_CODE = "en";
17282
17378
  * I'M SO SORRY.
17283
17379
  */
17284
17380
 
17285
- const get_browser_language_getBrowserLanguage = () => (navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage || DEFAULT_LANGUAGE_CODE).split("-")[0];
17381
+ function isSupportedLanguageCode(languageCode) {
17382
+ return includes_default()(SUPPORTED_LANGUAGES).call(SUPPORTED_LANGUAGES, languageCode);
17383
+ }
17384
+
17385
+ const get_browser_language_getBrowserLanguage = () => {
17386
+ const browserLanguageString = (navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage || DEFAULT_LANGUAGE_CODE).toLowerCase();
17387
+
17388
+ if (isSupportedLanguageCode(browserLanguageString)) {
17389
+ return browserLanguageString;
17390
+ }
17391
+
17392
+ if (includes_default()(browserLanguageString).call(browserLanguageString, "-")) {
17393
+ // an unsupported, hyphenated language code was received so return the main locale
17394
+ // if it is supported
17395
+ const mainLocale = browserLanguageString.split("-")[0];
17396
+
17397
+ if (isSupportedLanguageCode(mainLocale)) {
17398
+ return mainLocale;
17399
+ }
17400
+ }
17401
+
17402
+ return browserLanguageString;
17403
+ };
17286
17404
 
17287
17405
  /* harmony default export */ var get_browser_language = (get_browser_language_getBrowserLanguage);
17288
17406
  ;// CONCATENATED MODULE: ./src/services/helpers.ts
@@ -18181,9 +18299,9 @@ async function log(message, extra, options) {
18181
18299
  service: "embed",
18182
18300
  env: "production",
18183
18301
  embedVersion: 2,
18184
- version: "1.4.1",
18302
+ version: "1.4.2",
18185
18303
  isNpm: true,
18186
- commitHash: "ef0b30f"
18304
+ commitHash: "7dfe147"
18187
18305
  }))
18188
18306
  });
18189
18307
  }
@@ -18625,7 +18743,7 @@ class ChatFrame extends d {
18625
18743
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18626
18744
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18627
18745
  const queryParams = {
18628
- embedVersion: "ef0b30f".slice(0, 7),
18746
+ embedVersion: "7dfe147".slice(0, 7),
18629
18747
  greeting,
18630
18748
  language,
18631
18749
  skipGreeting,
@@ -20806,7 +20924,7 @@ class Embed {
20806
20924
 
20807
20925
  }
20808
20926
 
20809
- _defineProperty(Embed, "embed2Version", "ef0b30f");
20927
+ _defineProperty(Embed, "embed2Version", "7dfe147");
20810
20928
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20811
20929
 
20812
20930
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",