@ada-support/embed2 1.3.2 → 1.4.1

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.
@@ -0,0 +1,3 @@
1
+ import type { Client } from "common/models/client";
2
+ import type { MessagePayload } from "common/types/events";
3
+ export declare function storeChatterEventDataInBrowser(client: Client, payload: MessagePayload): void;
@@ -0,0 +1 @@
1
+ export * from "./chatterEvent";
@@ -1,5 +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
4
  export declare const IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
4
5
  export declare const ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
5
6
  export declare const ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
@@ -22,6 +22,7 @@ export interface Features {
22
22
  afm_proactive_messaging?: boolean;
23
23
  embed_test_bot?: boolean;
24
24
  translations?: boolean;
25
+ chat_session_auth?: boolean;
25
26
  }
26
27
  export interface ClientObject {
27
28
  handle: string;
@@ -4,6 +4,7 @@ import type { Client } from "common/models/client";
4
4
  export interface StoreState extends StartOptionsNoFunction {
5
5
  chatterCreated?: string | null;
6
6
  chatterToken?: string | null;
7
+ sessionToken?: string | null;
7
8
  client?: Client;
8
9
  isDrawerOpen: boolean;
9
10
  zdSessionId?: string | null;
@@ -7,3 +7,4 @@ export declare const PERSISTENCE_SESSION = "session";
7
7
  * persistence setting. If privateMode is set, it returns null.
8
8
  */
9
9
  export declare function retrieveStorage<T extends StorageKey>(key: T, client: Client, privateMode?: boolean): StorageValueByKey[T] | null;
10
+ export declare function setBrowserStorageItem<T extends StorageKey>(key: T, value: StorageValueByKey[T], persistenceSetting: Client["persistence"]): void;
@@ -1,4 +1,4 @@
1
- import type { CHATTER_CREATED_STORAGE_KEY, CHATTER_TOKEN_STORAGE_KEY, IN_LIVE_CHAT_STORAGE_KEY, ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY, ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY, ZD_PREVIOUS_TAGS_STORAGE_KEY, ZD_SESSION_STORAGE_KEY } from "common/constants/storage-keys";
1
+ import type { CHATTER_CREATED_STORAGE_KEY, CHATTER_TOKEN_STORAGE_KEY, IN_LIVE_CHAT_STORAGE_KEY, SESSION_AUTH_TOKEN_STORAGE_KEY, ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY, ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY, ZD_PREVIOUS_TAGS_STORAGE_KEY, ZD_SESSION_STORAGE_KEY } from "common/constants/storage-keys";
2
2
  export declare enum StorageTypes {
3
3
  Local = "local",
4
4
  Session = "session"
@@ -8,6 +8,7 @@ export declare type StorageValueType = string | number | boolean | unknown[];
8
8
  export interface StorageValueByKey {
9
9
  [CHATTER_CREATED_STORAGE_KEY]: string;
10
10
  [CHATTER_TOKEN_STORAGE_KEY]: string;
11
+ [SESSION_AUTH_TOKEN_STORAGE_KEY]: string;
11
12
  [IN_LIVE_CHAT_STORAGE_KEY]: boolean;
12
13
  [ZD_SESSION_STORAGE_KEY]: string;
13
14
  [ZD_PREVIOUS_TAGS_STORAGE_KEY]: string;
@@ -15811,7 +15811,7 @@ const client = new error_tracker_BrowserClient({
15811
15811
  },
15812
15812
 
15813
15813
  environment: "production",
15814
- release: "1.3.2-6bc9054",
15814
+ release: "1.4.1-ef0b30f",
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("6bc9054", "/index.html");
16435
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("ef0b30f", "/index.html");
16436
16436
  }
16437
16437
 
16438
16438
  function constructQueryString(query) {
@@ -16631,6 +16631,7 @@ const actions = {
16631
16631
  ;// CONCATENATED MODULE: ./src/common/constants/storage-keys.ts
16632
16632
  const CHATTER_TOKEN_STORAGE_KEY = "chatter";
16633
16633
  const CHATTER_CREATED_STORAGE_KEY = "ada-embed_chatter-created";
16634
+ const SESSION_AUTH_TOKEN_STORAGE_KEY = "session_token";
16634
16635
  const IN_LIVE_CHAT_STORAGE_KEY = "inLiveChat";
16635
16636
  const ZD_SESSION_STORAGE_KEY = "ada-embed_zd-session-id";
16636
16637
  const ZD_PREVIOUS_TAGS_STORAGE_KEY = "ada-embed_zd-previous-tags";
@@ -17094,6 +17095,7 @@ const getInitialState = adaSettings => ({
17094
17095
  rolloutOverride: undefined,
17095
17096
  chatterToken: getValueFromStorage(CHATTER_TOKEN_STORAGE_KEY) || undefined,
17096
17097
  chatterCreated: getValueFromStorage(CHATTER_CREATED_STORAGE_KEY) || undefined,
17098
+ sessionToken: getValueFromStorage(SESSION_AUTH_TOKEN_STORAGE_KEY || undefined),
17097
17099
  zdSessionId: getValueFromStorage(ZD_SESSION_STORAGE_KEY) || undefined,
17098
17100
  zdPreviousTags: getValueFromStorage(ZD_PREVIOUS_TAGS_STORAGE_KEY) || undefined,
17099
17101
  zdMessagingExternalUserId: getValueFromStorage(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY) || null,
@@ -17998,6 +18000,15 @@ function retrieveStorage(key, client, privateMode) {
17998
18000
 
17999
18001
  return null;
18000
18002
  }
18003
+ function setBrowserStorageItem(key, value, persistenceSetting) {
18004
+ if (persistenceSetting === PERSISTENCE_NORMAL) {
18005
+ safeLocalStorage.setItem(key, value);
18006
+ }
18007
+
18008
+ if (persistenceSetting === PERSISTENCE_SESSION) {
18009
+ safeSessionStorage.setItem(key, value);
18010
+ }
18011
+ }
18001
18012
  ;// CONCATENATED MODULE: ./src/services/persistence/index.ts
18002
18013
  const persistence = {
18003
18014
  get: item => {
@@ -18170,9 +18181,9 @@ async function log(message, extra, options) {
18170
18181
  service: "embed",
18171
18182
  env: "production",
18172
18183
  embedVersion: 2,
18173
- version: "1.3.2",
18184
+ version: "1.4.1",
18174
18185
  isNpm: true,
18175
- commitHash: "6bc9054"
18186
+ commitHash: "ef0b30f"
18176
18187
  }))
18177
18188
  });
18178
18189
  }
@@ -18468,6 +18479,30 @@ function ButtonFrame_mapStateToProps(storeState) {
18468
18479
  const ANIMATION_DELAY = 50;
18469
18480
  ;// CONCATENATED MODULE: ./src/common/helpers/is-mobile.ts
18470
18481
  const isMobile = /(iPhone)|(iPod)|(android)|(webOS)/i.exec(navigator.userAgent) !== null;
18482
+ ;// CONCATENATED MODULE: ./src/client/components/ChatFrame/chatFrameEvents/chatterEvent/index.ts
18483
+
18484
+
18485
+ function storeChatterEventDataInBrowser(client, payload) {
18486
+ const {
18487
+ persistence,
18488
+ features
18489
+ } = client; // TODO: CHATX-1618 please remove the line below - the ff won't be needed anymore
18490
+
18491
+ const isChatSessionAuthEnabled = features.chat_session_auth;
18492
+ const {
18493
+ chatter,
18494
+ created,
18495
+ sessionToken
18496
+ } = payload;
18497
+ setBrowserStorageItem(CHATTER_STORAGE_KEY, chatter, persistence);
18498
+ 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
18499
+
18500
+ if (isChatSessionAuthEnabled && Boolean(sessionToken)) {
18501
+ setBrowserStorageItem(SESSION_AUTH_TOKEN_STORAGE_KEY, sessionToken, persistence);
18502
+ }
18503
+ }
18504
+ ;// CONCATENATED MODULE: ./src/client/components/ChatFrame/chatFrameEvents/index.ts
18505
+
18471
18506
  ;// CONCATENATED MODULE: ./src/client/components/ChatFrame/index.tsx
18472
18507
 
18473
18508
 
@@ -18486,6 +18521,7 @@ const isMobile = /(iPhone)|(iPod)|(android)|(webOS)/i.exec(navigator.userAgent)
18486
18521
 
18487
18522
 
18488
18523
 
18524
+
18489
18525
  class ChatFrame extends d {
18490
18526
  constructor() {
18491
18527
  super(...arguments);
@@ -18589,7 +18625,7 @@ class ChatFrame extends d {
18589
18625
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18590
18626
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18591
18627
  const queryParams = {
18592
- embedVersion: "6bc9054".slice(0, 7),
18628
+ embedVersion: "ef0b30f".slice(0, 7),
18593
18629
  greeting,
18594
18630
  language,
18595
18631
  skipGreeting,
@@ -18893,7 +18929,8 @@ class ChatFrame extends d {
18893
18929
  } = this.props;
18894
18930
  const {
18895
18931
  chatter,
18896
- created
18932
+ created,
18933
+ sessionToken
18897
18934
  } = payload;
18898
18935
  const {
18899
18936
  chatterTokenCallback
@@ -18903,27 +18940,17 @@ class ChatFrame extends d {
18903
18940
  throw new AdaEmbedError("`client` is undefined");
18904
18941
  }
18905
18942
 
18906
- await setState({
18907
- chatterToken: chatter,
18908
- chatterCreated: created
18909
- });
18910
- /**
18911
- * Store the token so when embed loads in the future, it doesn't have to wait for it to
18912
- * come from chat. This is important for campaign and business event triggers.
18913
- */
18914
-
18915
- if (client.persistence === PERSISTENCE_NORMAL) {
18916
- safeLocalStorage.setItem(CHATTER_STORAGE_KEY, chatter);
18917
- safeLocalStorage.setItem(CHATTER_CREATED_STORAGE_KEY, created);
18918
- } else if (client.persistence === PERSISTENCE_SESSION) {
18919
- safeSessionStorage.setItem(CHATTER_STORAGE_KEY, chatter);
18920
- safeSessionStorage.setItem(CHATTER_CREATED_STORAGE_KEY, created);
18921
- }
18943
+ storeChatterEventDataInBrowser(client, payload);
18922
18944
 
18923
18945
  if (chatterTokenCallback) {
18924
18946
  chatterTokenCallback(chatter);
18925
18947
  }
18926
18948
 
18949
+ await setState({
18950
+ chatterToken: chatter,
18951
+ chatterCreated: created,
18952
+ sessionToken
18953
+ });
18927
18954
  break;
18928
18955
  }
18929
18956
 
@@ -20779,7 +20806,7 @@ class Embed {
20779
20806
 
20780
20807
  }
20781
20808
 
20782
- _defineProperty(Embed, "embed2Version", "6bc9054");
20809
+ _defineProperty(Embed, "embed2Version", "ef0b30f");
20783
20810
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20784
20811
 
20785
20812
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.3.2",
3
+ "version": "1.4.1",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",
@@ -73,6 +73,7 @@
73
73
  "lint-staged": "^11.2.3",
74
74
  "mock-xmlhttprequest": "^7.0.4",
75
75
  "npm-run-all": "^4.1.5",
76
+ "prettier": "2.7.1",
76
77
  "start-server-and-test": "^1.14.0",
77
78
  "testcafe": "^1.18.4",
78
79
  "testcafe-browser-provider-lambdatest": "^2.0.18",
@@ -97,6 +98,7 @@
97
98
  "babel-loader": "^8.2.3",
98
99
  "babel-preset-preact": "^2.0.0",
99
100
  "dotenv": "^8.2.0",
101
+ "eslint-config-prettier": "^8.5.0",
100
102
  "focus-visible": "^5.2.0",
101
103
  "html-webpack-plugin": "^5.5.0",
102
104
  "json-stable-stringify": "^1.0.1",