@ada-support/embed2 1.6.22 → 1.6.24
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.
|
@@ -14,12 +14,11 @@ export declare class Embed {
|
|
|
14
14
|
adaSettings: StartOptions;
|
|
15
15
|
initialized: Promise<void>;
|
|
16
16
|
entryContainer?: HTMLElement;
|
|
17
|
-
unmountCallback: () => void;
|
|
18
17
|
initializationReject?: (error: Error) => void;
|
|
19
18
|
initializationResolve?: () => void;
|
|
20
19
|
private debounceCampaignTrigger;
|
|
21
20
|
static embed2Version: string;
|
|
22
|
-
constructor(adaSettings: StartOptions
|
|
21
|
+
constructor(adaSettings: StartOptions);
|
|
23
22
|
renderPreactApp(): void;
|
|
24
23
|
setUpFrameParent(): HTMLElement | null;
|
|
25
24
|
toggle(): Promise<void>;
|
package/dist/npm-entry/index.js
CHANGED
|
@@ -15917,7 +15917,7 @@ const client = new error_tracker_BrowserClient({
|
|
|
15917
15917
|
},
|
|
15918
15918
|
|
|
15919
15919
|
environment: "production",
|
|
15920
|
-
release: "1.6.
|
|
15920
|
+
release: "1.6.24-6882ca0",
|
|
15921
15921
|
sampleRate: 0.25,
|
|
15922
15922
|
autoSessionTracking: false,
|
|
15923
15923
|
// Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
|
|
@@ -16547,7 +16547,7 @@ function getEmbedURL(_ref) {
|
|
|
16547
16547
|
host = "http://".concat(window.location.hostname, ":9001");
|
|
16548
16548
|
}
|
|
16549
16549
|
|
|
16550
|
-
return "".concat(host, "/embed/").concat(frameName, "/").concat("
|
|
16550
|
+
return "".concat(host, "/embed/").concat(frameName, "/").concat("6882ca0", "/index.html");
|
|
16551
16551
|
}
|
|
16552
16552
|
|
|
16553
16553
|
function constructQueryString(query) {
|
|
@@ -18199,9 +18199,9 @@ async function log(message, extra, options) {
|
|
|
18199
18199
|
service: "embed",
|
|
18200
18200
|
env: "production",
|
|
18201
18201
|
embedVersion: 2,
|
|
18202
|
-
version: "1.6.
|
|
18202
|
+
version: "1.6.24",
|
|
18203
18203
|
isNpm: true,
|
|
18204
|
-
commitHash: "
|
|
18204
|
+
commitHash: "6882ca0"
|
|
18205
18205
|
}))
|
|
18206
18206
|
});
|
|
18207
18207
|
}
|
|
@@ -18771,7 +18771,7 @@ class ChatFrame extends d {
|
|
|
18771
18771
|
const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
|
|
18772
18772
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
18773
18773
|
const queryParams = {
|
|
18774
|
-
embedVersion: "
|
|
18774
|
+
embedVersion: "6882ca0".slice(0, 7),
|
|
18775
18775
|
greeting,
|
|
18776
18776
|
language,
|
|
18777
18777
|
skipGreeting,
|
|
@@ -19939,8 +19939,7 @@ class Container extends d {
|
|
|
19939
19939
|
|
|
19940
19940
|
const {
|
|
19941
19941
|
entryContainer,
|
|
19942
|
-
messageService
|
|
19943
|
-
unmountCallback
|
|
19942
|
+
messageService
|
|
19944
19943
|
} = this.props;
|
|
19945
19944
|
(_entryContainer$paren = entryContainer.parentNode) === null || _entryContainer$paren === void 0 ? void 0 : _entryContainer$paren.removeChild(entryContainer);
|
|
19946
19945
|
messageService.getAllChannels().forEach(channel => {
|
|
@@ -19948,7 +19947,6 @@ class Container extends d {
|
|
|
19948
19947
|
});
|
|
19949
19948
|
unbindLocationChangeOverrides();
|
|
19950
19949
|
window.removeEventListener("locationchange", this.locationChangeHandlerBound);
|
|
19951
|
-
unmountCallback();
|
|
19952
19950
|
}
|
|
19953
19951
|
|
|
19954
19952
|
trackEvent(trackEventParams) {
|
|
@@ -20779,7 +20777,7 @@ function embed_objectSpread(target) { for (var i = 1; i < arguments.length; i++)
|
|
|
20779
20777
|
|
|
20780
20778
|
|
|
20781
20779
|
class Embed {
|
|
20782
|
-
constructor(adaSettings
|
|
20780
|
+
constructor(adaSettings) {
|
|
20783
20781
|
var _this = this;
|
|
20784
20782
|
|
|
20785
20783
|
_defineProperty(this, "client", void 0);
|
|
@@ -20798,8 +20796,6 @@ class Embed {
|
|
|
20798
20796
|
|
|
20799
20797
|
_defineProperty(this, "entryContainer", void 0);
|
|
20800
20798
|
|
|
20801
|
-
_defineProperty(this, "unmountCallback", void 0);
|
|
20802
|
-
|
|
20803
20799
|
_defineProperty(this, "initializationReject", void 0);
|
|
20804
20800
|
|
|
20805
20801
|
_defineProperty(this, "initializationResolve", void 0);
|
|
@@ -20807,7 +20803,6 @@ class Embed {
|
|
|
20807
20803
|
_defineProperty(this, "debounceCampaignTrigger", void 0);
|
|
20808
20804
|
|
|
20809
20805
|
this.adaSettings = adaSettings;
|
|
20810
|
-
this.unmountCallback = unmountCallback;
|
|
20811
20806
|
this.messageService = new MessageService();
|
|
20812
20807
|
const initialState = getInitialState(adaSettings);
|
|
20813
20808
|
this.store = new StoreProxy(initialState, this.messageService);
|
|
@@ -20853,7 +20848,6 @@ class Embed {
|
|
|
20853
20848
|
store: this.store,
|
|
20854
20849
|
messageService: this.messageService,
|
|
20855
20850
|
adaSettings: this.adaSettings,
|
|
20856
|
-
unmountCallback: this.unmountCallback,
|
|
20857
20851
|
entryContainer: this.entryContainer,
|
|
20858
20852
|
initializationReject: this.initializationReject,
|
|
20859
20853
|
initializationResolve: this.initializationResolve
|
|
@@ -20989,43 +20983,30 @@ class Embed {
|
|
|
20989
20983
|
|
|
20990
20984
|
}
|
|
20991
20985
|
|
|
20992
|
-
_defineProperty(Embed, "embed2Version", "
|
|
20986
|
+
_defineProperty(Embed, "embed2Version", "6882ca0");
|
|
20993
20987
|
;// CONCATENATED MODULE: ./src/interface.ts
|
|
20994
20988
|
|
|
20995
20989
|
|
|
20996
20990
|
|
|
20991
|
+
|
|
20992
|
+
const EMBED_NOT_INITIALIZED_ERROR = new AdaEmbedError("Actions cannot be called until Embed has been instantiated. Try running `adaEmbed.start({...})`.");
|
|
20997
20993
|
/**
|
|
20998
20994
|
* Returns the public Embed methods to be bound to the window object.
|
|
20999
20995
|
*/
|
|
21000
20996
|
|
|
21001
20997
|
function createEmbedInterface() {
|
|
21002
20998
|
let embed = null;
|
|
21003
|
-
let startEmbedResolve;
|
|
21004
|
-
let startEmbed = null;
|
|
21005
|
-
|
|
21006
|
-
const waitForEmbedInit = async () => {
|
|
21007
|
-
if (startEmbed === null) {
|
|
21008
|
-
throw new AdaEmbedError("Actions cannot be called until Embed has been instantiated. Try running `adaEmbed.start({...})`.");
|
|
21009
|
-
}
|
|
21010
|
-
|
|
21011
|
-
await startEmbed;
|
|
21012
|
-
};
|
|
21013
|
-
|
|
21014
20999
|
return Object.freeze({
|
|
21015
21000
|
start: async adaSettings => {
|
|
21016
|
-
if (
|
|
21001
|
+
if (!isStartOptions(adaSettings)) {
|
|
21002
|
+
throw new AdaEmbedError("`start` method requires `StartOptions` argument");
|
|
21003
|
+
}
|
|
21004
|
+
|
|
21005
|
+
if (embed) {
|
|
21017
21006
|
throw new AdaEmbedError("Ada Embed has already been started.");
|
|
21018
21007
|
}
|
|
21019
21008
|
|
|
21020
|
-
|
|
21021
|
-
startEmbedResolve = resolve;
|
|
21022
|
-
});
|
|
21023
|
-
embed = new Embed(adaSettings, () => {
|
|
21024
|
-
// Remove Embed instance in teardown callback
|
|
21025
|
-
startEmbed = null;
|
|
21026
|
-
embed = null;
|
|
21027
|
-
});
|
|
21028
|
-
startEmbedResolve();
|
|
21009
|
+
embed = new Embed(adaSettings);
|
|
21029
21010
|
|
|
21030
21011
|
if (window.adaEmbedLoadedCallback) {
|
|
21031
21012
|
window.adaEmbedLoadedCallback();
|
|
@@ -21040,65 +21021,70 @@ function createEmbedInterface() {
|
|
|
21040
21021
|
return embed.initialized;
|
|
21041
21022
|
},
|
|
21042
21023
|
stop: async () => {
|
|
21043
|
-
|
|
21024
|
+
if (!embed) {
|
|
21025
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21026
|
+
}
|
|
21044
21027
|
|
|
21045
|
-
|
|
21046
|
-
|
|
21028
|
+
const stopPromise = embed.stop();
|
|
21029
|
+
embed = null;
|
|
21030
|
+
return stopPromise;
|
|
21047
21031
|
},
|
|
21048
21032
|
toggle: async () => {
|
|
21049
|
-
|
|
21033
|
+
if (!embed) {
|
|
21034
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21035
|
+
}
|
|
21050
21036
|
|
|
21051
|
-
|
|
21052
|
-
return (_embed2 = embed) === null || _embed2 === void 0 ? void 0 : _embed2.toggle();
|
|
21037
|
+
return embed.toggle();
|
|
21053
21038
|
},
|
|
21054
21039
|
deleteHistory: async () => {
|
|
21055
|
-
|
|
21040
|
+
if (!embed) {
|
|
21041
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21042
|
+
}
|
|
21056
21043
|
|
|
21057
|
-
|
|
21058
|
-
return (_embed3 = embed) === null || _embed3 === void 0 ? void 0 : _embed3.deleteHistory();
|
|
21044
|
+
return embed.deleteHistory();
|
|
21059
21045
|
},
|
|
21060
21046
|
setMetaFields: async options => {
|
|
21061
|
-
|
|
21047
|
+
if (!embed) {
|
|
21048
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21049
|
+
}
|
|
21062
21050
|
|
|
21063
|
-
|
|
21064
|
-
return (_embed4 = embed) === null || _embed4 === void 0 ? void 0 : _embed4.setMetaFields(options);
|
|
21051
|
+
return embed.setMetaFields(options);
|
|
21065
21052
|
},
|
|
21066
21053
|
setSensitiveMetaFields: async options => {
|
|
21067
|
-
|
|
21054
|
+
if (!embed) {
|
|
21055
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21056
|
+
}
|
|
21068
21057
|
|
|
21069
|
-
|
|
21070
|
-
return (_embed5 = embed) === null || _embed5 === void 0 ? void 0 : _embed5.setSensitiveMetaFields(options);
|
|
21058
|
+
return embed.setSensitiveMetaFields(options);
|
|
21071
21059
|
},
|
|
21072
21060
|
getInfo: async () => {
|
|
21073
|
-
await waitForEmbedInit();
|
|
21074
|
-
|
|
21075
21061
|
if (!embed) {
|
|
21076
|
-
throw
|
|
21062
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21077
21063
|
}
|
|
21078
21064
|
|
|
21079
21065
|
return embed.getInfo();
|
|
21080
21066
|
},
|
|
21081
21067
|
reset: async resetParams => {
|
|
21082
|
-
|
|
21068
|
+
if (!embed) {
|
|
21069
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21070
|
+
}
|
|
21083
21071
|
|
|
21084
|
-
await waitForEmbedInit();
|
|
21085
21072
|
log("Embed reset", {
|
|
21086
21073
|
initialURL: window.location.href,
|
|
21087
21074
|
// not sure if the handle will be present so adding the URL to help out with id'ing the client
|
|
21088
21075
|
resetChatHistory: resetParams === null || resetParams === void 0 ? void 0 : resetParams.resetChatHistory,
|
|
21089
21076
|
greeting: resetParams === null || resetParams === void 0 ? void 0 : resetParams.greeting
|
|
21090
21077
|
});
|
|
21091
|
-
return
|
|
21078
|
+
return embed.reset(resetParams);
|
|
21092
21079
|
},
|
|
21093
21080
|
trackEvent: async (eventKey, value, meta) => {
|
|
21094
|
-
|
|
21081
|
+
if (!embed) {
|
|
21082
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21083
|
+
}
|
|
21095
21084
|
|
|
21096
|
-
|
|
21097
|
-
return (_embed7 = embed) === null || _embed7 === void 0 ? void 0 : _embed7.trackEvent(eventKey, value, meta);
|
|
21085
|
+
return embed.trackEvent(eventKey, value, meta);
|
|
21098
21086
|
},
|
|
21099
21087
|
createProactive: async function (body) {
|
|
21100
|
-
var _embed8;
|
|
21101
|
-
|
|
21102
21088
|
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
|
|
21103
21089
|
let responseId = arguments.length > 2 ? arguments[2] : undefined;
|
|
21104
21090
|
|
|
@@ -21106,77 +21092,81 @@ function createEmbedInterface() {
|
|
|
21106
21092
|
throw new AdaEmbedError("Cannot call createProactive without body set.");
|
|
21107
21093
|
}
|
|
21108
21094
|
|
|
21109
|
-
|
|
21110
|
-
|
|
21095
|
+
if (!embed) {
|
|
21096
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21097
|
+
}
|
|
21098
|
+
|
|
21099
|
+
return embed.createProactive(body, duration, responseId);
|
|
21111
21100
|
},
|
|
21112
21101
|
triggerCampaign: async (campaignKey, options) => {
|
|
21113
|
-
|
|
21102
|
+
if (!embed) {
|
|
21103
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21104
|
+
}
|
|
21114
21105
|
|
|
21115
|
-
|
|
21116
|
-
return (_embed9 = embed) === null || _embed9 === void 0 ? void 0 : _embed9.triggerCampaign(campaignKey, options);
|
|
21106
|
+
return embed.triggerCampaign(campaignKey, options);
|
|
21117
21107
|
},
|
|
21118
21108
|
evaluateCampaignConditions: async options => {
|
|
21119
|
-
|
|
21109
|
+
if (!embed) {
|
|
21110
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21111
|
+
}
|
|
21120
21112
|
|
|
21121
|
-
|
|
21122
|
-
return (_embed10 = embed) === null || _embed10 === void 0 ? void 0 : _embed10.evaluateCampaignConditions(options);
|
|
21113
|
+
return embed.evaluateCampaignConditions(options);
|
|
21123
21114
|
},
|
|
21124
21115
|
subscribeEvent: async (eventKey, callback) => {
|
|
21125
|
-
await waitForEmbedInit();
|
|
21126
|
-
|
|
21127
21116
|
if (!embed) {
|
|
21128
|
-
throw
|
|
21117
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21129
21118
|
}
|
|
21130
21119
|
|
|
21131
21120
|
return embed.subscribeEvent(eventKey, callback);
|
|
21132
21121
|
},
|
|
21133
21122
|
unsubscribeEvent: async id => {
|
|
21134
|
-
|
|
21123
|
+
if (!embed) {
|
|
21124
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21125
|
+
}
|
|
21135
21126
|
|
|
21136
|
-
|
|
21137
|
-
return (_embed11 = embed) === null || _embed11 === void 0 ? void 0 : _embed11.unsubscribeEvent(id);
|
|
21127
|
+
return embed.unsubscribeEvent(id);
|
|
21138
21128
|
},
|
|
21139
21129
|
closeCampaign: async () => {
|
|
21140
|
-
|
|
21130
|
+
if (!embed) {
|
|
21131
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21132
|
+
}
|
|
21141
21133
|
|
|
21142
|
-
|
|
21143
|
-
return (_embed12 = embed) === null || _embed12 === void 0 ? void 0 : _embed12.closeCampaign();
|
|
21134
|
+
return embed.closeCampaign();
|
|
21144
21135
|
},
|
|
21145
21136
|
setDeviceToken: async token => {
|
|
21146
|
-
|
|
21137
|
+
if (!embed) {
|
|
21138
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21139
|
+
}
|
|
21147
21140
|
|
|
21148
|
-
|
|
21149
|
-
return (_embed13 = embed) === null || _embed13 === void 0 ? void 0 : _embed13.setDeviceToken(token);
|
|
21141
|
+
return embed.setDeviceToken(token);
|
|
21150
21142
|
},
|
|
21151
|
-
setLanguage:
|
|
21152
|
-
|
|
21143
|
+
setLanguage: language => {
|
|
21144
|
+
if (!embed) {
|
|
21145
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21146
|
+
}
|
|
21153
21147
|
|
|
21154
|
-
|
|
21155
|
-
const channel = (_embed14 = embed) === null || _embed14 === void 0 ? void 0 : _embed14.messageService.getChannel("chat");
|
|
21148
|
+
const channel = embed.messageService.getChannel("chat");
|
|
21156
21149
|
channel === null || channel === void 0 ? void 0 : channel.postMessage("SET_LANGUAGE", {
|
|
21157
21150
|
language
|
|
21158
21151
|
});
|
|
21159
21152
|
},
|
|
21160
21153
|
handleNotification: async () => {
|
|
21161
|
-
|
|
21162
|
-
|
|
21163
|
-
await waitForEmbedInit();
|
|
21164
|
-
const windowInfo = await ((_embed15 = embed) === null || _embed15 === void 0 ? void 0 : _embed15.getInfo());
|
|
21165
|
-
|
|
21166
|
-
if (!windowInfo) {
|
|
21167
|
-
return;
|
|
21154
|
+
if (!embed) {
|
|
21155
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21168
21156
|
}
|
|
21169
21157
|
|
|
21170
|
-
|
|
21171
|
-
var _embed16;
|
|
21158
|
+
const windowInfo = await embed.getInfo();
|
|
21172
21159
|
|
|
21173
|
-
|
|
21160
|
+
if (!windowInfo.isChatOpen) {
|
|
21161
|
+
embed.toggle();
|
|
21174
21162
|
}
|
|
21175
21163
|
},
|
|
21176
21164
|
triggerAnswer: answerId => {
|
|
21177
|
-
|
|
21165
|
+
if (!embed) {
|
|
21166
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21167
|
+
}
|
|
21178
21168
|
|
|
21179
|
-
const channel =
|
|
21169
|
+
const channel = embed.messageService.getChannel("chat");
|
|
21180
21170
|
channel === null || channel === void 0 ? void 0 : channel.postMessage("TRIGGER_ANSWER", {
|
|
21181
21171
|
answerId
|
|
21182
21172
|
});
|