@ada-support/embed2 1.11.0 → 1.11.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/index.js
CHANGED
|
@@ -15919,7 +15919,7 @@ const client = new BrowserClient({
|
|
|
15919
15919
|
return event;
|
|
15920
15920
|
},
|
|
15921
15921
|
environment: "production",
|
|
15922
|
-
release: "1.11.
|
|
15922
|
+
release: "1.11.1-c291df9",
|
|
15923
15923
|
sampleRate: 0.25,
|
|
15924
15924
|
autoSessionTracking: false,
|
|
15925
15925
|
// Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
|
|
@@ -16368,45 +16368,22 @@ let ActionTypes = /*#__PURE__*/function (ActionTypes) {
|
|
|
16368
16368
|
ActionTypes["FOCUS_OFF_ADA_TYPE"] = "FOCUS_OFF_ADA";
|
|
16369
16369
|
return ActionTypes;
|
|
16370
16370
|
}({});
|
|
16371
|
-
;// CONCATENATED MODULE: ./src/
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
|
|
16375
|
-
|
|
16376
|
-
|
|
16377
|
-
return
|
|
16378
|
-
}
|
|
16379
|
-
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
|
|
16383
|
-
function subscribeEvent(eventKey, callback) {
|
|
16384
|
-
const id = getNextUniqueId();
|
|
16385
|
-
subscriptions.push({
|
|
16386
|
-
eventKey,
|
|
16387
|
-
callback,
|
|
16388
|
-
id
|
|
16389
|
-
});
|
|
16390
|
-
return id;
|
|
16391
|
-
}
|
|
16392
|
-
function publishEvent(eventKey, data) {
|
|
16393
|
-
subscriptions.forEach(subscription => {
|
|
16394
|
-
// Using startsWith instead of === allows subscribing to a specific event OR a namespace,
|
|
16395
|
-
// e.g. ada:campaigns subscribes to ada:campaigns:opened, ada:campaigns:engaged, and
|
|
16396
|
-
// ada:campaigns:shown. Broadcasting this way simultaneously reaches subscriptions
|
|
16397
|
-
// that have subscribed to a specific event, and those that have subscribed to a namespace
|
|
16398
|
-
if (eventKey.startsWith(subscription.eventKey)) {
|
|
16399
|
-
// try/catch to guard against missing or bad callbacks
|
|
16400
|
-
try {
|
|
16401
|
-
subscription.callback(data, {
|
|
16402
|
-
eventKey
|
|
16403
|
-
});
|
|
16404
|
-
} catch {
|
|
16405
|
-
// silently fail and proceed with remaining callbacks
|
|
16406
|
-
}
|
|
16407
|
-
}
|
|
16408
|
-
});
|
|
16371
|
+
;// CONCATENATED MODULE: ./src/services/helpers.ts
|
|
16372
|
+
const NO_OP_FUNCTION = () => {
|
|
16373
|
+
// Do nothing
|
|
16374
|
+
};
|
|
16375
|
+
function isStartOptions(input) {
|
|
16376
|
+
if (!(typeof input === "object")) {
|
|
16377
|
+
return false;
|
|
16378
|
+
}
|
|
16379
|
+
if (input === null) {
|
|
16380
|
+
return false;
|
|
16381
|
+
}
|
|
16382
|
+
return typeof input.handle === "string";
|
|
16409
16383
|
}
|
|
16384
|
+
// EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
|
|
16385
|
+
var lodash_memoize = __webpack_require__(7654);
|
|
16386
|
+
var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
|
|
16410
16387
|
;// CONCATENATED MODULE: ./src/common/helpers/http.ts
|
|
16411
16388
|
/**
|
|
16412
16389
|
* Vanilla HTTP request. Returns a Promise.
|
|
@@ -16451,6 +16428,101 @@ function httpRequest(obj) {
|
|
|
16451
16428
|
xhr.send(obj.body);
|
|
16452
16429
|
});
|
|
16453
16430
|
}
|
|
16431
|
+
;// CONCATENATED MODULE: ./src/services/logger/index.ts
|
|
16432
|
+
|
|
16433
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16434
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16435
|
+
|
|
16436
|
+
|
|
16437
|
+
const DEFAULT_LOG_SAMPLE_RATE = 0.01;
|
|
16438
|
+
const DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
|
|
16439
|
+
const DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1";
|
|
16440
|
+
|
|
16441
|
+
// We need memoization to ensure consistency of logs
|
|
16442
|
+
const shouldLog = lodash_memoize_default()(sampleRate => {
|
|
16443
|
+
if (!DD_TOKEN || sampleRate === 0) {
|
|
16444
|
+
return false;
|
|
16445
|
+
}
|
|
16446
|
+
return Math.random() < (sampleRate || DEFAULT_LOG_SAMPLE_RATE);
|
|
16447
|
+
});
|
|
16448
|
+
|
|
16449
|
+
/**
|
|
16450
|
+
* Sends log to Datadog
|
|
16451
|
+
*/
|
|
16452
|
+
async function log(message, extra, options) {
|
|
16453
|
+
if (!shouldLog(options === null || options === void 0 ? void 0 : options.sampleRate)) {
|
|
16454
|
+
return;
|
|
16455
|
+
}
|
|
16456
|
+
await httpRequest({
|
|
16457
|
+
url: `${DD_BASE_URL}${DD_TOKEN}?ddsource=browser&ddtags=version:1.5.0,env:${"production"}`,
|
|
16458
|
+
method: "POST",
|
|
16459
|
+
body: JSON.stringify(_objectSpread(_objectSpread({
|
|
16460
|
+
message
|
|
16461
|
+
}, extra), {}, {
|
|
16462
|
+
level: (options === null || options === void 0 ? void 0 : options.level) || "info",
|
|
16463
|
+
sampleRate: (options === null || options === void 0 ? void 0 : options.sampleRate) || DEFAULT_LOG_SAMPLE_RATE,
|
|
16464
|
+
service: "embed",
|
|
16465
|
+
env: "production",
|
|
16466
|
+
embedVersion: 2,
|
|
16467
|
+
version: "1.11.1",
|
|
16468
|
+
isNpm: true,
|
|
16469
|
+
commitHash: "c291df9"
|
|
16470
|
+
}))
|
|
16471
|
+
});
|
|
16472
|
+
}
|
|
16473
|
+
;// CONCATENATED MODULE: ./src/client/helpers/event-subscriptions/index.ts
|
|
16474
|
+
|
|
16475
|
+
|
|
16476
|
+
let subscriptions = [];
|
|
16477
|
+
const getNextUniqueId = (() => {
|
|
16478
|
+
let lastId = 0;
|
|
16479
|
+
return () => {
|
|
16480
|
+
lastId += 1;
|
|
16481
|
+
return lastId;
|
|
16482
|
+
};
|
|
16483
|
+
})();
|
|
16484
|
+
function unsubscribeEvent(id) {
|
|
16485
|
+
subscriptions = subscriptions.filter(s => s.id !== id);
|
|
16486
|
+
}
|
|
16487
|
+
function subscribeEvent(eventKey, callback) {
|
|
16488
|
+
const id = getNextUniqueId();
|
|
16489
|
+
|
|
16490
|
+
// Log chat_frame_timeout event subscriptions
|
|
16491
|
+
if (eventKey === "ada:chat_frame_timeout") {
|
|
16492
|
+
log("Client subscribed to chat_frame_timeout event", {
|
|
16493
|
+
handle: isStartOptions(window.adaSettings) ? window.adaSettings.handle : undefined,
|
|
16494
|
+
hostPage: window.location.href,
|
|
16495
|
+
timestamp: new Date().toISOString()
|
|
16496
|
+
}, {
|
|
16497
|
+
sampleRate: 0.1,
|
|
16498
|
+
level: "info"
|
|
16499
|
+
});
|
|
16500
|
+
}
|
|
16501
|
+
subscriptions.push({
|
|
16502
|
+
eventKey,
|
|
16503
|
+
callback,
|
|
16504
|
+
id
|
|
16505
|
+
});
|
|
16506
|
+
return id;
|
|
16507
|
+
}
|
|
16508
|
+
function publishEvent(eventKey, data) {
|
|
16509
|
+
subscriptions.forEach(subscription => {
|
|
16510
|
+
// Using startsWith instead of === allows subscribing to a specific event OR a namespace,
|
|
16511
|
+
// e.g. ada:campaigns subscribes to ada:campaigns:opened, ada:campaigns:engaged, and
|
|
16512
|
+
// ada:campaigns:shown. Broadcasting this way simultaneously reaches subscriptions
|
|
16513
|
+
// that have subscribed to a specific event, and those that have subscribed to a namespace
|
|
16514
|
+
if (eventKey.startsWith(subscription.eventKey)) {
|
|
16515
|
+
// try/catch to guard against missing or bad callbacks
|
|
16516
|
+
try {
|
|
16517
|
+
subscription.callback(data, {
|
|
16518
|
+
eventKey
|
|
16519
|
+
});
|
|
16520
|
+
} catch {
|
|
16521
|
+
// silently fail and proceed with remaining callbacks
|
|
16522
|
+
}
|
|
16523
|
+
}
|
|
16524
|
+
});
|
|
16525
|
+
}
|
|
16454
16526
|
;// CONCATENATED MODULE: ./src/common/helpers/config-info.ts
|
|
16455
16527
|
const isProduction = "production" === "production";
|
|
16456
16528
|
;// CONCATENATED MODULE: ./src/common/helpers/url/constants.ts
|
|
@@ -16468,8 +16540,8 @@ const ports = {
|
|
|
16468
16540
|
};
|
|
16469
16541
|
;// CONCATENATED MODULE: ./src/common/helpers/url/index.ts
|
|
16470
16542
|
|
|
16471
|
-
function
|
|
16472
|
-
function
|
|
16543
|
+
function url_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16544
|
+
function url_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? url_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : url_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16473
16545
|
|
|
16474
16546
|
|
|
16475
16547
|
const DEFAULT_ADA_DOMAIN = "ada";
|
|
@@ -16496,7 +16568,7 @@ function getEmbedURL(_ref) {
|
|
|
16496
16568
|
} else {
|
|
16497
16569
|
host = `http://${handle}.localhost:9001`;
|
|
16498
16570
|
}
|
|
16499
|
-
return `${host}/embed/${frameName}/${"
|
|
16571
|
+
return `${host}/embed/${frameName}/${"c291df9"}/index.html`;
|
|
16500
16572
|
}
|
|
16501
16573
|
function constructQueryString(query) {
|
|
16502
16574
|
return Object.keys(query).map(key => {
|
|
@@ -16544,7 +16616,7 @@ function getChatURL(_ref3) {
|
|
|
16544
16616
|
domain,
|
|
16545
16617
|
qp
|
|
16546
16618
|
} = _ref3;
|
|
16547
|
-
const queryParams =
|
|
16619
|
+
const queryParams = url_objectSpread(url_objectSpread({}, qp), {}, {
|
|
16548
16620
|
version
|
|
16549
16621
|
});
|
|
16550
16622
|
const queryString = constructQueryString(queryParams);
|
|
@@ -17303,19 +17375,6 @@ const get_browser_language_getBrowserLanguage = () => {
|
|
|
17303
17375
|
return browserLanguageString;
|
|
17304
17376
|
};
|
|
17305
17377
|
/* harmony default export */ var get_browser_language = (get_browser_language_getBrowserLanguage);
|
|
17306
|
-
;// CONCATENATED MODULE: ./src/services/helpers.ts
|
|
17307
|
-
const NO_OP_FUNCTION = () => {
|
|
17308
|
-
// Do nothing
|
|
17309
|
-
};
|
|
17310
|
-
function isStartOptions(input) {
|
|
17311
|
-
if (!(typeof input === "object")) {
|
|
17312
|
-
return false;
|
|
17313
|
-
}
|
|
17314
|
-
if (input === null) {
|
|
17315
|
-
return false;
|
|
17316
|
-
}
|
|
17317
|
-
return typeof input.handle === "string";
|
|
17318
|
-
}
|
|
17319
17378
|
;// CONCATENATED MODULE: ./src/campaigns/campaign.ts
|
|
17320
17379
|
|
|
17321
17380
|
function campaign_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -17638,51 +17697,6 @@ function getButtonText(client) {
|
|
|
17638
17697
|
}
|
|
17639
17698
|
return buttonTextMap[languageKey];
|
|
17640
17699
|
}
|
|
17641
|
-
// EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
|
|
17642
|
-
var lodash_memoize = __webpack_require__(7654);
|
|
17643
|
-
var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
|
|
17644
|
-
;// CONCATENATED MODULE: ./src/services/logger/index.ts
|
|
17645
|
-
|
|
17646
|
-
function logger_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17647
|
-
function logger_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? logger_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : logger_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17648
|
-
|
|
17649
|
-
|
|
17650
|
-
const DEFAULT_LOG_SAMPLE_RATE = 0.01; // 1% of logs will go through
|
|
17651
|
-
|
|
17652
|
-
const DD_BASE_URL = "https://browser-http-intake.logs.datadoghq.com/v1/input/";
|
|
17653
|
-
const DD_TOKEN = "pubfe23baedd2ea322bebb5ed2020fa2fa1";
|
|
17654
|
-
|
|
17655
|
-
// We need memoization to ensure consistency of logs
|
|
17656
|
-
const shouldLog = lodash_memoize_default()(sampleRate => {
|
|
17657
|
-
if (!DD_TOKEN || sampleRate === 0) {
|
|
17658
|
-
return false;
|
|
17659
|
-
}
|
|
17660
|
-
return Math.random() < (sampleRate || DEFAULT_LOG_SAMPLE_RATE);
|
|
17661
|
-
});
|
|
17662
|
-
|
|
17663
|
-
/**
|
|
17664
|
-
* Sends log to Datadog
|
|
17665
|
-
*/
|
|
17666
|
-
async function log(message, extra, options) {
|
|
17667
|
-
if (!shouldLog(options === null || options === void 0 ? void 0 : options.sampleRate)) {
|
|
17668
|
-
return;
|
|
17669
|
-
}
|
|
17670
|
-
await httpRequest({
|
|
17671
|
-
url: `${DD_BASE_URL}${DD_TOKEN}?ddsource=browser&ddtags=version:1.5.0,env:${"production"}`,
|
|
17672
|
-
method: "POST",
|
|
17673
|
-
body: JSON.stringify(logger_objectSpread(logger_objectSpread({
|
|
17674
|
-
message
|
|
17675
|
-
}, extra), {}, {
|
|
17676
|
-
sampleRate: (options === null || options === void 0 ? void 0 : options.sampleRate) || DEFAULT_LOG_SAMPLE_RATE,
|
|
17677
|
-
service: "embed",
|
|
17678
|
-
env: "production",
|
|
17679
|
-
embedVersion: 2,
|
|
17680
|
-
version: "1.11.0",
|
|
17681
|
-
isNpm: true,
|
|
17682
|
-
commitHash: "67295d0"
|
|
17683
|
-
}))
|
|
17684
|
-
});
|
|
17685
|
-
}
|
|
17686
17700
|
;// CONCATENATED MODULE: ./src/client/helpers/alternative-bot-rollout/index.ts
|
|
17687
17701
|
|
|
17688
17702
|
function alternative_bot_rollout_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -18334,12 +18348,26 @@ const CHAT_MANIFEST_PATH = "https://static.ada.support/chat-manifest.json";
|
|
|
18334
18348
|
const loadChatManifest = async () => {
|
|
18335
18349
|
try {
|
|
18336
18350
|
const r = await fetch(CHAT_MANIFEST_PATH);
|
|
18351
|
+
if (!r.ok) {
|
|
18352
|
+
log(`Failed to load chat manifest - HTTP ${r.status}`, {
|
|
18353
|
+
hostPage: window.location.href,
|
|
18354
|
+
manifestUrl: CHAT_MANIFEST_PATH
|
|
18355
|
+
}, {
|
|
18356
|
+
level: "error",
|
|
18357
|
+
sampleRate: 1.0
|
|
18358
|
+
});
|
|
18359
|
+
return undefined;
|
|
18360
|
+
}
|
|
18337
18361
|
return r.json();
|
|
18338
18362
|
} catch (e) {
|
|
18339
18363
|
// handling cases where r is undefined / other fetch errors
|
|
18340
18364
|
// by returning undefined, we tell the server to load the unversioned index.html file for chat
|
|
18341
18365
|
log("Failed to load chat manifest", {
|
|
18342
|
-
hostPage: window.location.href
|
|
18366
|
+
hostPage: window.location.href,
|
|
18367
|
+
manifestUrl: CHAT_MANIFEST_PATH
|
|
18368
|
+
}, {
|
|
18369
|
+
level: "error",
|
|
18370
|
+
sampleRate: 1.0
|
|
18343
18371
|
});
|
|
18344
18372
|
return undefined;
|
|
18345
18373
|
}
|
|
@@ -18930,6 +18958,8 @@ class ChatFrame extends d {
|
|
|
18930
18958
|
// We use this log to track number of chat impressions (times when users see chat iFrame render first time).
|
|
18931
18959
|
log("Chat frame mount", {
|
|
18932
18960
|
handle,
|
|
18961
|
+
chatUrl: this.url,
|
|
18962
|
+
embedVersion: "c291df9".slice(0, 7),
|
|
18933
18963
|
embedSettings: adaSettings
|
|
18934
18964
|
});
|
|
18935
18965
|
|
|
@@ -19013,7 +19043,7 @@ class ChatFrame extends d {
|
|
|
19013
19043
|
const hostPageUrlParams = new URL(window.location.href).searchParams;
|
|
19014
19044
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
19015
19045
|
const queryParams = {
|
|
19016
|
-
embedVersion: "
|
|
19046
|
+
embedVersion: "c291df9".slice(0, 7),
|
|
19017
19047
|
greeting,
|
|
19018
19048
|
language,
|
|
19019
19049
|
skipGreeting,
|
|
@@ -19615,6 +19645,15 @@ class ChatFrame extends d {
|
|
|
19615
19645
|
this.clearFallbackTimeout();
|
|
19616
19646
|
this.chatRenderTimeout = window.setTimeout(() => {
|
|
19617
19647
|
var _this$channel;
|
|
19648
|
+
log(`Chat frame took over ${CHAT_FALLBACK_DELAY_MS / 1000} seconds to respond`, {
|
|
19649
|
+
handle,
|
|
19650
|
+
chatUrl: this.url,
|
|
19651
|
+
embedVersion: "c291df9".slice(0, 7),
|
|
19652
|
+
embedSettings: adaSettings
|
|
19653
|
+
}, {
|
|
19654
|
+
level: "error",
|
|
19655
|
+
sampleRate: 1.0
|
|
19656
|
+
});
|
|
19618
19657
|
const {
|
|
19619
19658
|
isDrawerOpen: drawerIsOpen
|
|
19620
19659
|
} = this.props;
|