@ada-support/embed2 1.4.9 → 1.4.12
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/index.js
CHANGED
|
@@ -15811,7 +15811,7 @@ const client = new error_tracker_BrowserClient({
|
|
|
15811
15811
|
},
|
|
15812
15812
|
|
|
15813
15813
|
environment: "production",
|
|
15814
|
-
release: "1.4.
|
|
15814
|
+
release: "1.4.12-95c61ad",
|
|
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("
|
|
16435
|
+
return "".concat(host, "/embed/").concat(frameName, "/").concat("95c61ad", "/index.html");
|
|
16436
16436
|
}
|
|
16437
16437
|
|
|
16438
16438
|
function constructQueryString(query) {
|
|
@@ -18143,12 +18143,69 @@ const persistence = {
|
|
|
18143
18143
|
}
|
|
18144
18144
|
}
|
|
18145
18145
|
};
|
|
18146
|
+
// EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
|
|
18147
|
+
var lodash_memoize = __webpack_require__(773);
|
|
18148
|
+
var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
|
|
18149
|
+
;// CONCATENATED MODULE: ./src/services/logger/index.ts
|
|
18150
|
+
|
|
18151
|
+
|
|
18152
|
+
function logger_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; }
|
|
18153
|
+
|
|
18154
|
+
function logger_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? logger_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : logger_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18155
|
+
|
|
18156
|
+
|
|
18157
|
+
|
|
18158
|
+
const DEFAULT_LOG_SAMPLE_RATE = 0.01; // 1% of logs will go through
|
|
18159
|
+
|
|
18160
|
+
const DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
|
|
18161
|
+
const DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1"; // We need memoization to ensure consistency of logs
|
|
18162
|
+
|
|
18163
|
+
const shouldLog = lodash_memoize_default()(sampleRate => {
|
|
18164
|
+
if (!DD_TOKEN || sampleRate === 0) {
|
|
18165
|
+
return false;
|
|
18166
|
+
}
|
|
18167
|
+
|
|
18168
|
+
return Math.random() < (sampleRate || DEFAULT_LOG_SAMPLE_RATE);
|
|
18169
|
+
});
|
|
18170
|
+
/**
|
|
18171
|
+
* Sends log to Datadog
|
|
18172
|
+
*/
|
|
18173
|
+
|
|
18174
|
+
async function log(message, extra, options) {
|
|
18175
|
+
if (!shouldLog(options === null || options === void 0 ? void 0 : options.sampleRate)) {
|
|
18176
|
+
return;
|
|
18177
|
+
}
|
|
18178
|
+
|
|
18179
|
+
await httpRequest({
|
|
18180
|
+
url: "".concat(DD_BASE_URL).concat(DD_TOKEN, "?ddsource=browser&ddtags=version:1.5.0,env:").concat("production"),
|
|
18181
|
+
method: "POST",
|
|
18182
|
+
body: JSON.stringify(logger_objectSpread(logger_objectSpread({
|
|
18183
|
+
message
|
|
18184
|
+
}, extra), {}, {
|
|
18185
|
+
sampleRate: (options === null || options === void 0 ? void 0 : options.sampleRate) || DEFAULT_LOG_SAMPLE_RATE,
|
|
18186
|
+
service: "embed",
|
|
18187
|
+
env: "production",
|
|
18188
|
+
embedVersion: 2,
|
|
18189
|
+
version: "1.4.12",
|
|
18190
|
+
isNpm: true,
|
|
18191
|
+
commitHash: "95c61ad"
|
|
18192
|
+
}))
|
|
18193
|
+
});
|
|
18194
|
+
}
|
|
18146
18195
|
;// CONCATENATED MODULE: ./src/services/chat-versioning/manifest.ts
|
|
18147
18196
|
|
|
18197
|
+
|
|
18148
18198
|
const CHAT_MANIFEST_PATH = "https://static.ada.support/chat-manifest.json";
|
|
18149
18199
|
const loadChatManifest = async () => {
|
|
18150
|
-
|
|
18151
|
-
|
|
18200
|
+
try {
|
|
18201
|
+
const r = await fetch(CHAT_MANIFEST_PATH);
|
|
18202
|
+
return r.json();
|
|
18203
|
+
} catch (e) {
|
|
18204
|
+
// handling cases where r is undefined / other fetch errors
|
|
18205
|
+
// by returning undefined, we tell the server to load the unversioned index.html file for chat
|
|
18206
|
+
log("Failed to load chat manifest");
|
|
18207
|
+
return undefined;
|
|
18208
|
+
}
|
|
18152
18209
|
}; // Use one message for different errors to reduce the bundle size
|
|
18153
18210
|
|
|
18154
18211
|
const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
|
|
@@ -18246,64 +18303,29 @@ const getChatVersionFromManifest = manifest => {
|
|
|
18246
18303
|
persistence.set("ada-embed_chat-manifest-cache", manifestString);
|
|
18247
18304
|
return hash;
|
|
18248
18305
|
};
|
|
18249
|
-
const getChatVersion = async
|
|
18250
|
-
|
|
18251
|
-
|
|
18306
|
+
const getChatVersion = async adaSettings => {
|
|
18307
|
+
// allow versioning using global variable
|
|
18252
18308
|
if (window.__AdaChatVersion) {
|
|
18253
18309
|
return window.__AdaChatVersion;
|
|
18254
18310
|
}
|
|
18255
18311
|
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
18260
|
-
var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
|
|
18261
|
-
;// CONCATENATED MODULE: ./src/services/logger/index.ts
|
|
18262
|
-
|
|
18263
|
-
|
|
18264
|
-
function logger_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; }
|
|
18265
|
-
|
|
18266
|
-
function logger_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? logger_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : logger_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
const DEFAULT_LOG_SAMPLE_RATE = 0.01; // 1% of logs will go through
|
|
18271
|
-
|
|
18272
|
-
const DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
|
|
18273
|
-
const DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1"; // We need memoization to ensure consistency of logs
|
|
18312
|
+
const {
|
|
18313
|
+
cluster,
|
|
18314
|
+
domain
|
|
18315
|
+
} = adaSettings; // Skip automatic versioning for ATT and dev/stage clusters but allow override through __AdaChatVersion
|
|
18274
18316
|
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
return false;
|
|
18317
|
+
if (cluster === "att" || domain !== null && domain !== void 0 && domain.match(/ada-(dev|dev2|stage)/)) {
|
|
18318
|
+
return undefined;
|
|
18278
18319
|
}
|
|
18279
18320
|
|
|
18280
|
-
|
|
18281
|
-
});
|
|
18282
|
-
/**
|
|
18283
|
-
* Sends log to Datadog
|
|
18284
|
-
*/
|
|
18321
|
+
const manifest = await loadChatManifest();
|
|
18285
18322
|
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
return;
|
|
18323
|
+
if (!manifest) {
|
|
18324
|
+
return undefined;
|
|
18289
18325
|
}
|
|
18290
18326
|
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
method: "POST",
|
|
18294
|
-
body: JSON.stringify(logger_objectSpread(logger_objectSpread({
|
|
18295
|
-
message
|
|
18296
|
-
}, extra), {}, {
|
|
18297
|
-
sampleRate: (options === null || options === void 0 ? void 0 : options.sampleRate) || DEFAULT_LOG_SAMPLE_RATE,
|
|
18298
|
-
service: "embed",
|
|
18299
|
-
env: "production",
|
|
18300
|
-
embedVersion: 2,
|
|
18301
|
-
version: "1.4.9",
|
|
18302
|
-
isNpm: true,
|
|
18303
|
-
commitHash: "737fcae"
|
|
18304
|
-
}))
|
|
18305
|
-
});
|
|
18306
|
-
}
|
|
18327
|
+
return getChatVersionFromManifest(manifest);
|
|
18328
|
+
};
|
|
18307
18329
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/url.js
|
|
18308
18330
|
var url = __webpack_require__(9969);
|
|
18309
18331
|
var url_default = /*#__PURE__*/__webpack_require__.n(url);
|
|
@@ -18742,7 +18764,7 @@ class ChatFrame extends d {
|
|
|
18742
18764
|
const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
|
|
18743
18765
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
18744
18766
|
const queryParams = {
|
|
18745
|
-
embedVersion: "
|
|
18767
|
+
embedVersion: "95c61ad".slice(0, 7),
|
|
18746
18768
|
greeting,
|
|
18747
18769
|
language,
|
|
18748
18770
|
skipGreeting,
|
|
@@ -19672,15 +19694,8 @@ class Container extends d {
|
|
|
19672
19694
|
this.notificationPermHandler();
|
|
19673
19695
|
bindLocationChangeOverrides();
|
|
19674
19696
|
addServiceWorkerListeners();
|
|
19675
|
-
window.addEventListener("locationchange", this.locationChangeHandlerBound);
|
|
19676
|
-
|
|
19677
|
-
const chatVersion = await (async () => {
|
|
19678
|
-
if (adaSettings.cluster === "att") {
|
|
19679
|
-
return undefined;
|
|
19680
|
-
}
|
|
19681
|
-
|
|
19682
|
-
return getChatVersion();
|
|
19683
|
-
})();
|
|
19697
|
+
window.addEventListener("locationchange", this.locationChangeHandlerBound);
|
|
19698
|
+
const chatVersion = await getChatVersion(adaSettings);
|
|
19684
19699
|
this.setState({
|
|
19685
19700
|
chatVersion,
|
|
19686
19701
|
// We shouldn't try to render chat frame until version is attempted to be retrieved.
|
|
@@ -20924,7 +20939,7 @@ class Embed {
|
|
|
20924
20939
|
|
|
20925
20940
|
}
|
|
20926
20941
|
|
|
20927
|
-
_defineProperty(Embed, "embed2Version", "
|
|
20942
|
+
_defineProperty(Embed, "embed2Version", "95c61ad");
|
|
20928
20943
|
;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
|
|
20929
20944
|
|
|
20930
20945
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StartOptions } from "@ada-support/embed-types";
|
|
1
2
|
import type { Manifest } from "./manifest";
|
|
2
3
|
export declare const getChatVersionFromManifest: (manifest: Manifest | unknown) => string;
|
|
3
|
-
export declare const getChatVersion: () => Promise<string>;
|
|
4
|
+
export declare const getChatVersion: (adaSettings: StartOptions) => Promise<string>;
|
|
@@ -5,6 +5,6 @@ export interface Manifest {
|
|
|
5
5
|
weight: number;
|
|
6
6
|
}[];
|
|
7
7
|
}
|
|
8
|
-
export declare const loadChatManifest: () => Promise<Manifest>;
|
|
8
|
+
export declare const loadChatManifest: () => Promise<Manifest | undefined>;
|
|
9
9
|
export declare const MANIFEST_VALIDATION_ERROR_MESSAGE = "The format of manifest file is incorrect";
|
|
10
10
|
export declare const isManifest: (input: unknown) => input is Manifest;
|