@ada-support/embed2 1.2.17 → 1.3.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.
- package/dist/npm-entry/client/components/ChatFrame/index.d.ts +1 -0
- package/dist/npm-entry/client/components/Container/index.d.ts +2 -2
- package/dist/npm-entry/common/helpers/url/constants.d.ts +12 -1
- package/dist/npm-entry/common/helpers/url/index.d.ts +12 -4
- package/dist/npm-entry/index.js +221 -53
- package/dist/npm-entry/services/chat-versioning/index.d.ts +3 -0
- package/dist/npm-entry/services/chat-versioning/manifest.d.ts +10 -0
- package/package.json +3 -3
|
@@ -11,5 +11,5 @@ interface OwnProps {
|
|
|
11
11
|
initializationResolve?: () => void;
|
|
12
12
|
initializationReject?: (error: Error) => void;
|
|
13
13
|
}
|
|
14
|
-
declare const
|
|
15
|
-
export
|
|
14
|
+
export declare const ConnectedContainer: (ownProps: OwnProps) => h.JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -4,4 +4,15 @@ export interface Hosts {
|
|
|
4
4
|
export interface Ports {
|
|
5
5
|
[key: string]: number;
|
|
6
6
|
}
|
|
7
|
-
export declare const ports:
|
|
7
|
+
export declare const ports: {
|
|
8
|
+
readonly localhost: {
|
|
9
|
+
readonly api: 8000;
|
|
10
|
+
readonly chat: 8002;
|
|
11
|
+
readonly default: 9001;
|
|
12
|
+
};
|
|
13
|
+
readonly e2ereference: {
|
|
14
|
+
readonly api: 8000;
|
|
15
|
+
readonly chat: 8002;
|
|
16
|
+
readonly default: 9001;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -4,15 +4,16 @@ interface GetEmbedUrlParams {
|
|
|
4
4
|
cluster?: string;
|
|
5
5
|
domain?: string;
|
|
6
6
|
}
|
|
7
|
+
interface QueryParams {
|
|
8
|
+
[key: string]: string | boolean | number | null | undefined;
|
|
9
|
+
}
|
|
7
10
|
export interface CSInterface {
|
|
8
|
-
name: "api"
|
|
11
|
+
name: "api";
|
|
9
12
|
handle: string;
|
|
10
13
|
cluster?: string;
|
|
11
14
|
domain?: string;
|
|
12
15
|
route?: string;
|
|
13
|
-
qp?:
|
|
14
|
-
[key: string]: string | boolean | number | null | undefined;
|
|
15
|
-
};
|
|
16
|
+
qp?: QueryParams;
|
|
16
17
|
isEmbedFramed?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare function getClientCacheUrl(handle: string, cluster?: string, domain?: string): string;
|
|
@@ -21,4 +22,11 @@ export declare function getEmbedURL({ frameName, handle, cluster, domain, }: Get
|
|
|
21
22
|
* Generate the Chat / API URL
|
|
22
23
|
*/
|
|
23
24
|
export declare function getURL({ name, handle, cluster, domain, route, qp, }: CSInterface): string;
|
|
25
|
+
export declare function getChatURL({ handle, version, cluster, domain, qp, }: {
|
|
26
|
+
handle: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
cluster?: string;
|
|
29
|
+
domain?: string;
|
|
30
|
+
qp?: QueryParams;
|
|
31
|
+
}): string;
|
|
24
32
|
export {};
|
package/dist/npm-entry/index.js
CHANGED
|
@@ -15811,7 +15811,7 @@ const client = new error_tracker_BrowserClient({
|
|
|
15811
15811
|
},
|
|
15812
15812
|
|
|
15813
15813
|
environment: "production",
|
|
15814
|
-
release: "1.
|
|
15814
|
+
release: "1.3.1-512664b",
|
|
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
|
|
@@ -16398,6 +16398,12 @@ const ports = {
|
|
|
16398
16398
|
;// CONCATENATED MODULE: ./src/common/helpers/url/index.ts
|
|
16399
16399
|
|
|
16400
16400
|
|
|
16401
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16402
|
+
|
|
16403
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16404
|
+
|
|
16405
|
+
|
|
16406
|
+
|
|
16401
16407
|
|
|
16402
16408
|
const DEFAULT_ADA_DOMAIN = "ada";
|
|
16403
16409
|
function getClientCacheUrl(handle, cluster, domain) {
|
|
@@ -16426,12 +16432,25 @@ function getEmbedURL(_ref) {
|
|
|
16426
16432
|
host = "http://".concat(window.location.hostname, ":9001");
|
|
16427
16433
|
}
|
|
16428
16434
|
|
|
16429
|
-
return "".concat(host, "/embed/").concat(frameName, "/").concat("
|
|
16435
|
+
return "".concat(host, "/embed/").concat(frameName, "/").concat("512664b", "/index.html");
|
|
16436
|
+
}
|
|
16437
|
+
|
|
16438
|
+
function constructQueryString(query) {
|
|
16439
|
+
return Object.keys(query).map(key => {
|
|
16440
|
+
const value = query[key];
|
|
16441
|
+
|
|
16442
|
+
if (value === undefined || value === null) {
|
|
16443
|
+
return null;
|
|
16444
|
+
}
|
|
16445
|
+
|
|
16446
|
+
return "".concat(key, "=").concat(window.encodeURIComponent(value));
|
|
16447
|
+
}).filter(v => v !== null).join("&");
|
|
16430
16448
|
}
|
|
16431
16449
|
/**
|
|
16432
16450
|
* Generate the Chat / API URL
|
|
16433
16451
|
*/
|
|
16434
16452
|
|
|
16453
|
+
|
|
16435
16454
|
function getURL(_ref2) {
|
|
16436
16455
|
var _context;
|
|
16437
16456
|
|
|
@@ -16443,15 +16462,7 @@ function getURL(_ref2) {
|
|
|
16443
16462
|
route,
|
|
16444
16463
|
qp = {}
|
|
16445
16464
|
} = _ref2;
|
|
16446
|
-
const queryString =
|
|
16447
|
-
const value = qp[key];
|
|
16448
|
-
|
|
16449
|
-
if (value === undefined || value === null) {
|
|
16450
|
-
return null;
|
|
16451
|
-
}
|
|
16452
|
-
|
|
16453
|
-
return "".concat(key, "=").concat(window.encodeURIComponent(value));
|
|
16454
|
-
}).filter(v => v !== null).join("&");
|
|
16465
|
+
const queryString = constructQueryString(qp);
|
|
16455
16466
|
const questionSym = queryString.length ? "?" : "";
|
|
16456
16467
|
const routeString = route ? "".concat(route, "/") : "";
|
|
16457
16468
|
const clusterString = cluster ? ".".concat(cluster) : "";
|
|
@@ -16465,22 +16476,51 @@ function getURL(_ref2) {
|
|
|
16465
16476
|
if (includes_default()(_context = window.location.hostname).call(_context, "localhost") || handle === "e2ereference") {
|
|
16466
16477
|
var _context2;
|
|
16467
16478
|
|
|
16468
|
-
let host = window.location.hostname;
|
|
16469
16479
|
const domainName = includes_default()(_context2 = window.location.hostname).call(_context2, "localhost") ? "localhost" : "e2ereference";
|
|
16480
|
+
const host = "".concat(window.location.hostname, ":").concat(ports[domainName].api);
|
|
16481
|
+
return "http://".concat(host, "/").concat(routeString).concat(questionSym).concat(queryString);
|
|
16482
|
+
}
|
|
16483
|
+
|
|
16484
|
+
return prodUrl;
|
|
16485
|
+
}
|
|
16486
|
+
function getChatURL(_ref3) {
|
|
16487
|
+
var _context3;
|
|
16470
16488
|
|
|
16471
|
-
|
|
16489
|
+
let {
|
|
16490
|
+
handle,
|
|
16491
|
+
version,
|
|
16492
|
+
cluster,
|
|
16493
|
+
domain,
|
|
16494
|
+
qp
|
|
16495
|
+
} = _ref3;
|
|
16496
|
+
|
|
16497
|
+
const queryParams = _objectSpread(_objectSpread({}, qp), {}, {
|
|
16498
|
+
version
|
|
16499
|
+
});
|
|
16500
|
+
|
|
16501
|
+
const queryString = constructQueryString(queryParams);
|
|
16502
|
+
const questionSym = queryString.length ? "?" : "";
|
|
16503
|
+
const clusterString = cluster ? ".".concat(cluster) : "";
|
|
16504
|
+
const domainString = domain || DEFAULT_ADA_DOMAIN;
|
|
16505
|
+
const prodUrl = "https://".concat(handle).concat(clusterString, ".").concat(domainString, ".support/chat/").concat(questionSym).concat(queryString);
|
|
16506
|
+
|
|
16507
|
+
if (isProduction || false || domain) {
|
|
16508
|
+
return prodUrl;
|
|
16509
|
+
}
|
|
16510
|
+
|
|
16511
|
+
if (includes_default()(_context3 = window.location.hostname).call(_context3, "localhost") || handle === "e2ereference") {
|
|
16512
|
+
var _context4;
|
|
16513
|
+
|
|
16514
|
+
const domainName = includes_default()(_context4 = window.location.hostname).call(_context4, "localhost") ? "localhost" : "e2ereference";
|
|
16515
|
+
|
|
16516
|
+
if (domainName === "localhost") {
|
|
16472
16517
|
// Chat should be on a different domain (even though the port is different).
|
|
16473
16518
|
// We need this to test Embed+Chat behaviour when third-party cookies are disabled (incognito mode).
|
|
16474
|
-
return "".concat(window.location.protocol, "//").concat(handle, ".chat:8002/").concat(
|
|
16519
|
+
return "".concat(window.location.protocol, "//").concat(handle, ".chat:8002/").concat(questionSym).concat(queryString);
|
|
16475
16520
|
}
|
|
16476
16521
|
|
|
16477
|
-
|
|
16478
|
-
|
|
16479
|
-
} else {
|
|
16480
|
-
host += ":".concat(ports[domainName].default);
|
|
16481
|
-
}
|
|
16482
|
-
|
|
16483
|
-
return "http://".concat(host, "/").concat(routeString).concat(questionSym).concat(queryString);
|
|
16522
|
+
const host = "".concat(window.location.hostname, ":").concat(ports[domainName].chat);
|
|
16523
|
+
return "http://".concat(host, "/").concat(questionSym).concat(queryString);
|
|
16484
16524
|
}
|
|
16485
16525
|
|
|
16486
16526
|
return prodUrl;
|
|
@@ -16695,9 +16735,9 @@ const safeSessionStorage = new SafeStorage(StorageTypes.Session);
|
|
|
16695
16735
|
;// CONCATENATED MODULE: ./src/client/store/mutations/index.ts
|
|
16696
16736
|
|
|
16697
16737
|
|
|
16698
|
-
function
|
|
16738
|
+
function mutations_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16699
16739
|
|
|
16700
|
-
function
|
|
16740
|
+
function mutations_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? mutations_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : mutations_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16701
16741
|
|
|
16702
16742
|
|
|
16703
16743
|
|
|
@@ -16720,7 +16760,7 @@ const mutations = (state, action) => {
|
|
|
16720
16760
|
}
|
|
16721
16761
|
|
|
16722
16762
|
safeLocalStorage.setItem(IS_DRAWER_OPEN_STORAGE_KEY, !state.isDrawerOpen);
|
|
16723
|
-
return
|
|
16763
|
+
return mutations_objectSpread(mutations_objectSpread({}, state), {}, {
|
|
16724
16764
|
isDrawerOpen: !state.isDrawerOpen,
|
|
16725
16765
|
isIntroShown: false,
|
|
16726
16766
|
drawerHasBeenOpened: true,
|
|
@@ -16730,7 +16770,7 @@ const mutations = (state, action) => {
|
|
|
16730
16770
|
}
|
|
16731
16771
|
|
|
16732
16772
|
case ActionTypes.SET_STATE_TYPE:
|
|
16733
|
-
return
|
|
16773
|
+
return mutations_objectSpread(mutations_objectSpread({}, state), action.payload);
|
|
16734
16774
|
|
|
16735
16775
|
case ActionTypes.INCREMENT_MESSAGE_COUNT_TYPE:
|
|
16736
16776
|
{
|
|
@@ -16739,14 +16779,14 @@ const mutations = (state, action) => {
|
|
|
16739
16779
|
} = action.payload; // Filter out Proactive Messages
|
|
16740
16780
|
|
|
16741
16781
|
const nonProactive = messages.filter(message => !message.campaign_key);
|
|
16742
|
-
return
|
|
16782
|
+
return mutations_objectSpread(mutations_objectSpread({}, state), {}, {
|
|
16743
16783
|
unreadMessageCount: nonProactive.length
|
|
16744
16784
|
});
|
|
16745
16785
|
}
|
|
16746
16786
|
|
|
16747
16787
|
case ActionTypes.SET_CONNECTION_STATE_TYPE:
|
|
16748
16788
|
{
|
|
16749
|
-
const newConnections =
|
|
16789
|
+
const newConnections = mutations_objectSpread(mutations_objectSpread({}, state.connections), action.payload);
|
|
16750
16790
|
|
|
16751
16791
|
const connectionValues = Object.values(newConnections);
|
|
16752
16792
|
let appConnectionState;
|
|
@@ -16764,7 +16804,7 @@ const mutations = (state, action) => {
|
|
|
16764
16804
|
appConnectionState = ConnectionState.Uninitiated;
|
|
16765
16805
|
}
|
|
16766
16806
|
|
|
16767
|
-
return
|
|
16807
|
+
return mutations_objectSpread(mutations_objectSpread({}, state), {}, {
|
|
16768
16808
|
connections: newConnections,
|
|
16769
16809
|
appConnectionState
|
|
16770
16810
|
});
|
|
@@ -17958,6 +17998,102 @@ function retrieveStorage(key, client, privateMode) {
|
|
|
17958
17998
|
|
|
17959
17999
|
return null;
|
|
17960
18000
|
}
|
|
18001
|
+
;// CONCATENATED MODULE: ./src/services/chat-versioning/manifest.ts
|
|
18002
|
+
|
|
18003
|
+
const CHAT_MANIFEST_PATH = "https://static.ada.support/chat-manifest.json";
|
|
18004
|
+
const loadChatManifest = async () => {
|
|
18005
|
+
const r = await fetch(CHAT_MANIFEST_PATH);
|
|
18006
|
+
return r.json();
|
|
18007
|
+
}; // Use one message for different errors to reduce the bundle size
|
|
18008
|
+
|
|
18009
|
+
const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
|
|
18010
|
+
const isManifest = input => {
|
|
18011
|
+
if (!(typeof input === "object")) {
|
|
18012
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18013
|
+
}
|
|
18014
|
+
|
|
18015
|
+
if (input === null) {
|
|
18016
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18017
|
+
}
|
|
18018
|
+
|
|
18019
|
+
const objectInput = input;
|
|
18020
|
+
|
|
18021
|
+
if (!Array.isArray(objectInput.versions)) {
|
|
18022
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18023
|
+
}
|
|
18024
|
+
|
|
18025
|
+
if (!objectInput.versions.length) {
|
|
18026
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18027
|
+
}
|
|
18028
|
+
|
|
18029
|
+
if (!(typeof objectInput.versions[0].hash === "string")) {
|
|
18030
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18031
|
+
}
|
|
18032
|
+
|
|
18033
|
+
if (!objectInput.versions[0].hash) {
|
|
18034
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18035
|
+
}
|
|
18036
|
+
|
|
18037
|
+
if (!(typeof objectInput.versions[0].weight === "number")) {
|
|
18038
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18039
|
+
}
|
|
18040
|
+
|
|
18041
|
+
if (objectInput.versions.reduce((s, v) => s + v.weight, 0) !== 1) {
|
|
18042
|
+
throw new AdaEmbedError("The sum of version weights must be \"1\"");
|
|
18043
|
+
}
|
|
18044
|
+
|
|
18045
|
+
return true;
|
|
18046
|
+
};
|
|
18047
|
+
;// CONCATENATED MODULE: ./src/services/chat-versioning/index.ts
|
|
18048
|
+
// TODO CHATX-1613: Turn on persistence when we're allowed to
|
|
18049
|
+
// import { persistence } from "services/persistence";
|
|
18050
|
+
|
|
18051
|
+
|
|
18052
|
+
const getChatVersionFromManifest = manifest => {
|
|
18053
|
+
/* istanbul ignore next */
|
|
18054
|
+
if (!isManifest(manifest)) {
|
|
18055
|
+
// This should never happen since isManifest throws an error for invalid input
|
|
18056
|
+
throw new AdaEmbedError(MANIFEST_VALIDATION_ERROR_MESSAGE);
|
|
18057
|
+
} // TODO CHATX-1613: Turn on persistence when we're allowed to
|
|
18058
|
+
// const manifestString = JSON.stringify(manifest);
|
|
18059
|
+
// const manifestCache = persistence.get("ada-embed_chat-manifest-cache");
|
|
18060
|
+
// if (manifestString === manifestCache) {
|
|
18061
|
+
// const assignedVersion = persistence.get("ada-embed_chat-assigned-version");
|
|
18062
|
+
//
|
|
18063
|
+
// /* istanbul ignore else */
|
|
18064
|
+
// if (assignedVersion) {
|
|
18065
|
+
// return assignedVersion;
|
|
18066
|
+
// }
|
|
18067
|
+
// }
|
|
18068
|
+
|
|
18069
|
+
|
|
18070
|
+
const random = Math.random();
|
|
18071
|
+
const {
|
|
18072
|
+
versions
|
|
18073
|
+
} = manifest; // Use hash from last version in array by default
|
|
18074
|
+
|
|
18075
|
+
let {
|
|
18076
|
+
hash
|
|
18077
|
+
} = versions[versions.length - 1]; // Loop through versions
|
|
18078
|
+
|
|
18079
|
+
for (let i = 0; i < versions.length; i += 1) {
|
|
18080
|
+
const v = versions[i]; // If random falls into version weight
|
|
18081
|
+
|
|
18082
|
+
if (random <= v.weight) {
|
|
18083
|
+
hash = v.hash;
|
|
18084
|
+
break;
|
|
18085
|
+
}
|
|
18086
|
+
} // TODO CHATX-1613: Turn on persistence when we're allowed to
|
|
18087
|
+
// persistence.set("ada-embed_chat-assigned-version", hash);
|
|
18088
|
+
// persistence.set("ada-embed_chat-manifest-cache", manifestString);
|
|
18089
|
+
|
|
18090
|
+
|
|
18091
|
+
return hash;
|
|
18092
|
+
};
|
|
18093
|
+
const getChatVersion = async () => {
|
|
18094
|
+
const manifest = await loadChatManifest();
|
|
18095
|
+
return getChatVersionFromManifest(manifest);
|
|
18096
|
+
};
|
|
17961
18097
|
// EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
|
|
17962
18098
|
var lodash_memoize = __webpack_require__(773);
|
|
17963
18099
|
var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
|
|
@@ -18001,9 +18137,9 @@ async function log(message, extra, options) {
|
|
|
18001
18137
|
service: "embed",
|
|
18002
18138
|
env: "production",
|
|
18003
18139
|
embedVersion: 2,
|
|
18004
|
-
version: "1.
|
|
18140
|
+
version: "1.3.1",
|
|
18005
18141
|
isNpm: true,
|
|
18006
|
-
commitHash: "
|
|
18142
|
+
commitHash: "512664b"
|
|
18007
18143
|
}))
|
|
18008
18144
|
});
|
|
18009
18145
|
}
|
|
@@ -18413,13 +18549,14 @@ class ChatFrame extends d {
|
|
|
18413
18549
|
wasIntroShown,
|
|
18414
18550
|
privateMode,
|
|
18415
18551
|
testMode,
|
|
18416
|
-
adaSettings
|
|
18552
|
+
adaSettings,
|
|
18553
|
+
chatVersion
|
|
18417
18554
|
} = this.props; // check the host page URL for an adaSMSToken and add it as a chatterToken query param for chat's iframe URL
|
|
18418
18555
|
|
|
18419
18556
|
const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
|
|
18420
18557
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
18421
18558
|
const queryParams = {
|
|
18422
|
-
embedVersion: "
|
|
18559
|
+
embedVersion: "512664b".slice(0, 7),
|
|
18423
18560
|
greeting,
|
|
18424
18561
|
language,
|
|
18425
18562
|
skipGreeting,
|
|
@@ -18434,8 +18571,8 @@ class ChatFrame extends d {
|
|
|
18434
18571
|
queryParams.adaSMSToken = smsToken;
|
|
18435
18572
|
}
|
|
18436
18573
|
|
|
18437
|
-
return
|
|
18438
|
-
|
|
18574
|
+
return getChatURL({
|
|
18575
|
+
version: chatVersion,
|
|
18439
18576
|
handle,
|
|
18440
18577
|
cluster,
|
|
18441
18578
|
domain,
|
|
@@ -19297,6 +19434,7 @@ function Container_objectSpread(target) { for (var i = 1; i < arguments.length;
|
|
|
19297
19434
|
|
|
19298
19435
|
|
|
19299
19436
|
|
|
19437
|
+
|
|
19300
19438
|
|
|
19301
19439
|
|
|
19302
19440
|
class Container extends d {
|
|
@@ -19312,7 +19450,9 @@ class Container extends d {
|
|
|
19312
19450
|
chatHasBeenRendered: false,
|
|
19313
19451
|
hideChatOverride: false,
|
|
19314
19452
|
hideIntroOverride: false,
|
|
19315
|
-
followUpResponseId: null
|
|
19453
|
+
followUpResponseId: null,
|
|
19454
|
+
chatVersion: undefined,
|
|
19455
|
+
readyToRenderChatFrame: false
|
|
19316
19456
|
});
|
|
19317
19457
|
|
|
19318
19458
|
_defineProperty(this, "resetChatBound", this.resetChat.bind(this));
|
|
@@ -19334,7 +19474,7 @@ class Container extends d {
|
|
|
19334
19474
|
})());
|
|
19335
19475
|
}
|
|
19336
19476
|
|
|
19337
|
-
componentDidMount() {
|
|
19477
|
+
async componentDidMount() {
|
|
19338
19478
|
const {
|
|
19339
19479
|
adaSettings,
|
|
19340
19480
|
setState
|
|
@@ -19355,7 +19495,20 @@ class Container extends d {
|
|
|
19355
19495
|
this.notificationPermHandler();
|
|
19356
19496
|
bindLocationChangeOverrides();
|
|
19357
19497
|
addServiceWorkerListeners();
|
|
19358
|
-
window.addEventListener("locationchange", this.locationChangeHandlerBound);
|
|
19498
|
+
window.addEventListener("locationchange", this.locationChangeHandlerBound); // Get chat version. Skip for ATT cluster.
|
|
19499
|
+
|
|
19500
|
+
const chatVersion = await (async () => {
|
|
19501
|
+
if (adaSettings.cluster === "att") {
|
|
19502
|
+
return undefined;
|
|
19503
|
+
}
|
|
19504
|
+
|
|
19505
|
+
return getChatVersion();
|
|
19506
|
+
})();
|
|
19507
|
+
this.setState({
|
|
19508
|
+
chatVersion,
|
|
19509
|
+
// We shouldn't try to render chat frame until version is attempted to be retrieved.
|
|
19510
|
+
readyToRenderChatFrame: true
|
|
19511
|
+
});
|
|
19359
19512
|
}
|
|
19360
19513
|
/** To be called when `props.appConnectionState` value changes */
|
|
19361
19514
|
|
|
@@ -19515,9 +19668,14 @@ class Container extends d {
|
|
|
19515
19668
|
} = adaSettings;
|
|
19516
19669
|
const {
|
|
19517
19670
|
chatHasBeenRendered,
|
|
19518
|
-
hideChatOverride
|
|
19671
|
+
hideChatOverride,
|
|
19672
|
+
readyToRenderChatFrame
|
|
19519
19673
|
} = this.state;
|
|
19520
19674
|
|
|
19675
|
+
if (!readyToRenderChatFrame) {
|
|
19676
|
+
return false;
|
|
19677
|
+
}
|
|
19678
|
+
|
|
19521
19679
|
if (hideChatOverride) {
|
|
19522
19680
|
return false;
|
|
19523
19681
|
}
|
|
@@ -20136,7 +20294,15 @@ class Container extends d {
|
|
|
20136
20294
|
const {
|
|
20137
20295
|
chatHasBeenRendered
|
|
20138
20296
|
} = this.state;
|
|
20139
|
-
messageService.getChannel(XSTORAGE_IFRAME)
|
|
20297
|
+
const xStorageChannel = messageService.getChannel(XSTORAGE_IFRAME);
|
|
20298
|
+
/* istanbul ignore next */
|
|
20299
|
+
|
|
20300
|
+
if (!xStorageChannel) {
|
|
20301
|
+
// This should never happen (ideally).
|
|
20302
|
+
throw new AdaEmbedError("`xStorageChannel` is null");
|
|
20303
|
+
}
|
|
20304
|
+
|
|
20305
|
+
xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
|
|
20140
20306
|
|
|
20141
20307
|
if (chatHasBeenRendered) {
|
|
20142
20308
|
this.setState({
|
|
@@ -20168,21 +20334,23 @@ class Container extends d {
|
|
|
20168
20334
|
} = this.props;
|
|
20169
20335
|
const {
|
|
20170
20336
|
campaignToTrigger,
|
|
20171
|
-
followUpResponseId
|
|
20337
|
+
followUpResponseId,
|
|
20338
|
+
chatVersion
|
|
20172
20339
|
} = this.state;
|
|
20173
20340
|
|
|
20174
|
-
if (this.shouldRenderChatFrame) {
|
|
20175
|
-
return
|
|
20176
|
-
setChatHasBeenRendered: this.setChatHasBeenRenderedBound,
|
|
20177
|
-
adaSettings: adaSettings,
|
|
20178
|
-
store: store,
|
|
20179
|
-
messageService: messageService,
|
|
20180
|
-
resetChat: this.resetChatBound,
|
|
20181
|
-
skipGreeting: Boolean(campaignToTrigger || followUpResponseId)
|
|
20182
|
-
});
|
|
20341
|
+
if (!this.shouldRenderChatFrame) {
|
|
20342
|
+
return null;
|
|
20183
20343
|
}
|
|
20184
20344
|
|
|
20185
|
-
return
|
|
20345
|
+
return v(components_ChatFrame, {
|
|
20346
|
+
chatVersion: chatVersion,
|
|
20347
|
+
setChatHasBeenRendered: this.setChatHasBeenRenderedBound,
|
|
20348
|
+
adaSettings: adaSettings,
|
|
20349
|
+
store: store,
|
|
20350
|
+
messageService: messageService,
|
|
20351
|
+
resetChat: this.resetChatBound,
|
|
20352
|
+
skipGreeting: Boolean(campaignToTrigger || followUpResponseId)
|
|
20353
|
+
});
|
|
20186
20354
|
}
|
|
20187
20355
|
|
|
20188
20356
|
renderIntroFrame() {
|
|
@@ -20348,7 +20516,7 @@ function Container_mapDispatchToProps(dispatch) {
|
|
|
20348
20516
|
};
|
|
20349
20517
|
}
|
|
20350
20518
|
|
|
20351
|
-
|
|
20519
|
+
const ConnectedContainer = connect(Container_mapStateToProps, Container_mapDispatchToProps)(Container);
|
|
20352
20520
|
;// CONCATENATED MODULE: ./src/client/embed.tsx
|
|
20353
20521
|
|
|
20354
20522
|
|
|
@@ -20438,7 +20606,7 @@ class Embed {
|
|
|
20438
20606
|
value: this.store
|
|
20439
20607
|
}, v(MessageServiceContext.Provider, {
|
|
20440
20608
|
value: this.messageService
|
|
20441
|
-
}, v(
|
|
20609
|
+
}, v(ConnectedContainer, {
|
|
20442
20610
|
store: this.store,
|
|
20443
20611
|
messageService: this.messageService,
|
|
20444
20612
|
adaSettings: this.adaSettings,
|
|
@@ -20578,7 +20746,7 @@ class Embed {
|
|
|
20578
20746
|
|
|
20579
20747
|
}
|
|
20580
20748
|
|
|
20581
|
-
_defineProperty(Embed, "embed2Version", "
|
|
20749
|
+
_defineProperty(Embed, "embed2Version", "512664b");
|
|
20582
20750
|
;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
|
|
20583
20751
|
|
|
20584
20752
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const CHAT_MANIFEST_PATH = "https://static.ada.support/chat-manifest.json";
|
|
2
|
+
export interface Manifest {
|
|
3
|
+
versions: {
|
|
4
|
+
hash: string;
|
|
5
|
+
weight: number;
|
|
6
|
+
}[];
|
|
7
|
+
}
|
|
8
|
+
export declare const loadChatManifest: () => Promise<Manifest>;
|
|
9
|
+
export declare const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
|
|
10
|
+
export declare const isManifest: (input: unknown) => input is Manifest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ada-support/embed2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/npm-entry",
|
|
6
6
|
"typings": "dist/npm-entry/index-npm.d.ts",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"build": "TS_NODE_PROJECT=wp.tsconfig.json NODE_ENV=production npx webpack --config webpack.prod.ts",
|
|
12
12
|
"build:npm-types": "tsc --project tsconfig.npm.json --declaration --outDir dist/npm-entry --emitDeclarationOnly --allowJs false --checkJs false",
|
|
13
13
|
"build:npm": "./npm-build.sh",
|
|
14
|
-
"lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings
|
|
14
|
+
"lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 22",
|
|
15
15
|
"lint:fix": "yarn lint --fix",
|
|
16
|
-
"test": "jest",
|
|
16
|
+
"test": "jest --detectOpenHandles",
|
|
17
17
|
"check-types": "./node_modules/typescript/bin/tsc --project ./tsconfig.json --noEmit --strict false",
|
|
18
18
|
"check-types-strict": "./node_modules/typescript/bin/tsc --project ./tsconfig.json --noEmit",
|
|
19
19
|
"tc": "export $(cat .env | xargs) && testcafe",
|