@ada-support/embed2 1.6.26 → 1.6.28
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/embed.d.ts +3 -1
- package/dist/npm-entry/client/lib/message-service.d.ts +3 -3
- package/dist/npm-entry/common/constants/events.d.ts +0 -2
- package/dist/npm-entry/common/lib/channel.d.ts +27 -29
- package/dist/npm-entry/common/types/channels.d.ts +1 -1
- package/dist/npm-entry/index.js +27 -54
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { CampaignParams, ResetParams, StartOptions, WindowInfo } from "@ada-support/embed-types";
|
|
2
2
|
import { MessageService } from "client/lib/message-service";
|
|
3
|
+
import { StoreProxy } from "client/lib/store-proxy";
|
|
3
4
|
import "client/lib/error-tracker";
|
|
4
5
|
import type { MetaFieldPayload } from "common/types/store";
|
|
5
6
|
export declare function createEmbed(adaSettings: StartOptions): {
|
|
6
7
|
readonly initialized: Promise<void>;
|
|
7
8
|
readonly messageService: MessageService;
|
|
8
|
-
readonly
|
|
9
|
+
readonly store: StoreProxy;
|
|
10
|
+
readonly adaSettings: StartOptions;
|
|
9
11
|
readonly getInfo: () => Promise<WindowInfo>;
|
|
10
12
|
readonly setMetaFields: (options: MetaFieldPayload) => Promise<void>;
|
|
11
13
|
readonly setSensitiveMetaFields: (options: MetaFieldPayload) => Promise<void>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FrameChannel } from "common/lib/fc";
|
|
2
|
-
import type { Channels } from "common/types/channels";
|
|
2
|
+
import type { Channels, FrameChannels } from "common/types/channels";
|
|
3
3
|
import type { Module } from "common/types/modules";
|
|
4
4
|
import { CustomEventChannel } from "./ce";
|
|
5
5
|
export declare class MessageService {
|
|
6
6
|
channels: Channels;
|
|
7
7
|
registerFrameChannel(name: Module, targetWindow: Window, targetOrigin?: string): FrameChannel;
|
|
8
|
-
unregisterChannel(name: keyof
|
|
9
|
-
getChannel(name:
|
|
8
|
+
unregisterChannel(name: keyof FrameChannels): void;
|
|
9
|
+
getChannel<N extends keyof Channels>(name: N): Channels[N];
|
|
10
10
|
getAllChannels(): (FrameChannel | CustomEventChannel)[];
|
|
11
11
|
}
|
|
@@ -52,8 +52,6 @@ export declare enum ConnectionState {
|
|
|
52
52
|
/**
|
|
53
53
|
* Embed Custom Events
|
|
54
54
|
*/
|
|
55
|
-
export declare const TOGGLE = "TOGGLE";
|
|
56
|
-
export declare const TOGGLE_RESPONSE = "TOGGLE_RESPONSE";
|
|
57
55
|
export declare const GET_INFO = "GET_INFO";
|
|
58
56
|
export declare const GET_INFO_RESPONSE = "GET_INFO_RESPONSE";
|
|
59
57
|
export declare const SET_META_FIELDS = "SET_META_FIELDS";
|
|
@@ -20,7 +20,6 @@ export interface EmbedRequestPayloadByEvent {
|
|
|
20
20
|
SET_META_FIELDS: MetaFieldPayload;
|
|
21
21
|
SET_SENSITIVE_META_FIELDS: MetaFieldPayload;
|
|
22
22
|
STOP: unknown;
|
|
23
|
-
TOGGLE: unknown;
|
|
24
23
|
TRIGGER_CAMPAIGN: unknown;
|
|
25
24
|
TRACK_EVENT: TrackEventParams;
|
|
26
25
|
SEND_GREETING: SendGreetingParams;
|
|
@@ -37,36 +36,35 @@ export interface EmbedRequestPayloadByEvent {
|
|
|
37
36
|
}
|
|
38
37
|
export declare type EmbedRequestEvent = keyof EmbedRequestPayloadByEvent;
|
|
39
38
|
export interface EmbedResponsePayloadByEvent {
|
|
40
|
-
ALL_FRAMES_LOADED: unknown;
|
|
41
|
-
BROWSER_HAS_NOTIFICATIONS_RESPONSE: unknown;
|
|
42
|
-
CREATE_PROACTIVE_RESPONSE: string | null;
|
|
43
|
-
DELETE_HISTORY: unknown;
|
|
44
|
-
DELETE_HISTORY_RESPONSE: unknown;
|
|
45
|
-
DISPATCH_RESPONSE: StoreState;
|
|
46
|
-
EVAL_CAMPAIGN_CONDITIONS_RESPONSE: unknown;
|
|
47
|
-
GET_RESPONSE: StoreState[keyof StoreState];
|
|
48
|
-
GET_INFO_RESPONSE: unknown;
|
|
49
|
-
GET_STATE_RESPONSE: StoreState;
|
|
50
|
-
GREETING: unknown;
|
|
51
|
-
JWT_AUTH_RESPONSE: unknown;
|
|
52
|
-
RESET_RESPONSE: unknown;
|
|
53
|
-
SET_META_FIELDS_RESPONSE: unknown;
|
|
54
|
-
SET_SENSITIVE_META_FIELDS_RESPONSE: unknown;
|
|
55
|
-
SET_WINDOW_ORIGIN: Location;
|
|
56
|
-
STATE_CHANGE: StoreState;
|
|
57
|
-
STOP_RESPONSE: unknown;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
intro_INIT: unknown;
|
|
39
|
+
"ALL_FRAMES_LOADED": unknown;
|
|
40
|
+
"BROWSER_HAS_NOTIFICATIONS_RESPONSE": unknown;
|
|
41
|
+
"CREATE_PROACTIVE_RESPONSE": string | null;
|
|
42
|
+
"DELETE_HISTORY": unknown;
|
|
43
|
+
"DELETE_HISTORY_RESPONSE": unknown;
|
|
44
|
+
"DISPATCH_RESPONSE": StoreState;
|
|
45
|
+
"EVAL_CAMPAIGN_CONDITIONS_RESPONSE": unknown;
|
|
46
|
+
"GET_RESPONSE": StoreState[keyof StoreState];
|
|
47
|
+
"GET_INFO_RESPONSE": unknown;
|
|
48
|
+
"GET_STATE_RESPONSE": StoreState;
|
|
49
|
+
"GREETING": unknown;
|
|
50
|
+
"JWT_AUTH_RESPONSE": unknown;
|
|
51
|
+
"RESET_RESPONSE": unknown;
|
|
52
|
+
"SET_META_FIELDS_RESPONSE": unknown;
|
|
53
|
+
"SET_SENSITIVE_META_FIELDS_RESPONSE": unknown;
|
|
54
|
+
"SET_WINDOW_ORIGIN": Location;
|
|
55
|
+
"STATE_CHANGE": StoreState;
|
|
56
|
+
"STOP_RESPONSE": unknown;
|
|
57
|
+
"TRACK_EVENT_RESPONSE": string | null;
|
|
58
|
+
"TRIGGER_CAMPAIGN_RESPONSE": string | null;
|
|
59
|
+
"CLOSE_CAMPAIGN_RESPONSE": unknown;
|
|
60
|
+
"entry_INIT": unknown;
|
|
61
|
+
"client_INIT": unknown;
|
|
62
|
+
"button_INIT": unknown;
|
|
63
|
+
"intro_INIT": unknown;
|
|
66
64
|
"drawer-mask_INIT": unknown;
|
|
67
|
-
chat_INIT: unknown;
|
|
65
|
+
"chat_INIT": unknown;
|
|
68
66
|
"x-storage_INIT": unknown;
|
|
69
|
-
SET_DEVICE_TOKEN_RESPONSE: unknown;
|
|
67
|
+
"SET_DEVICE_TOKEN_RESPONSE": unknown;
|
|
70
68
|
}
|
|
71
69
|
export declare type EmbedResponseEvent = keyof EmbedResponsePayloadByEvent;
|
|
72
70
|
export declare type EmbedEvent = EmbedRequestEvent | EmbedResponseEvent;
|
|
@@ -2,7 +2,7 @@ import type { CustomEventChannel } from "client/lib/ce";
|
|
|
2
2
|
import type { FrameChannel } from "common/lib/fc";
|
|
3
3
|
import type { PartialRecord } from "common/types/helpers";
|
|
4
4
|
import type { Module } from "common/types/modules";
|
|
5
|
-
declare type FrameChannels = PartialRecord<Module, FrameChannel>;
|
|
5
|
+
export declare type FrameChannels = PartialRecord<Module, FrameChannel>;
|
|
6
6
|
interface LocalChannel {
|
|
7
7
|
local: CustomEventChannel;
|
|
8
8
|
}
|
package/dist/npm-entry/index.js
CHANGED
|
@@ -15877,7 +15877,7 @@ const client = new error_tracker_BrowserClient({
|
|
|
15877
15877
|
},
|
|
15878
15878
|
|
|
15879
15879
|
environment: "production",
|
|
15880
|
-
release: "1.6.
|
|
15880
|
+
release: "1.6.28-0cbed86",
|
|
15881
15881
|
sampleRate: 0.25,
|
|
15882
15882
|
autoSessionTracking: false,
|
|
15883
15883
|
// Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
|
|
@@ -15975,8 +15975,6 @@ let ConnectionState;
|
|
|
15975
15975
|
ConnectionState["Uninitiated"] = "UNINITIATED";
|
|
15976
15976
|
})(ConnectionState || (ConnectionState = {}));
|
|
15977
15977
|
|
|
15978
|
-
const TOGGLE = "TOGGLE";
|
|
15979
|
-
const TOGGLE_RESPONSE = "TOGGLE_RESPONSE";
|
|
15980
15978
|
const GET_INFO = "GET_INFO";
|
|
15981
15979
|
const GET_INFO_RESPONSE = "GET_INFO_RESPONSE";
|
|
15982
15980
|
const SET_META_FIELDS = "SET_META_FIELDS";
|
|
@@ -16364,14 +16362,7 @@ class MessageService {
|
|
|
16364
16362
|
}
|
|
16365
16363
|
|
|
16366
16364
|
getChannel(name) {
|
|
16367
|
-
|
|
16368
|
-
|
|
16369
|
-
if (!channel) {
|
|
16370
|
-
warn("Channel \"".concat(name, "\" has not been registered. You may need to wait until app has finished initializing."));
|
|
16371
|
-
return null;
|
|
16372
|
-
}
|
|
16373
|
-
|
|
16374
|
-
return channel;
|
|
16365
|
+
return this.channels[name];
|
|
16375
16366
|
}
|
|
16376
16367
|
|
|
16377
16368
|
getAllChannels() {
|
|
@@ -16547,7 +16538,7 @@ function getEmbedURL(_ref) {
|
|
|
16547
16538
|
host = "http://".concat(window.location.hostname, ":9001");
|
|
16548
16539
|
}
|
|
16549
16540
|
|
|
16550
|
-
return "".concat(host, "/embed/").concat(frameName, "/").concat("
|
|
16541
|
+
return "".concat(host, "/embed/").concat(frameName, "/").concat("0cbed86", "/index.html");
|
|
16551
16542
|
}
|
|
16552
16543
|
|
|
16553
16544
|
function constructQueryString(query) {
|
|
@@ -17566,7 +17557,7 @@ function triggerCampaignImpl(_ref) {
|
|
|
17566
17557
|
const responseId = campaign.follow_up_response_id;
|
|
17567
17558
|
|
|
17568
17559
|
if (body) {
|
|
17569
|
-
localChannel
|
|
17560
|
+
localChannel.postMessage(CREATE_PROACTIVE, {
|
|
17570
17561
|
body,
|
|
17571
17562
|
duration,
|
|
17572
17563
|
responseId
|
|
@@ -18199,9 +18190,9 @@ async function log(message, extra, options) {
|
|
|
18199
18190
|
service: "embed",
|
|
18200
18191
|
env: "production",
|
|
18201
18192
|
embedVersion: 2,
|
|
18202
|
-
version: "1.6.
|
|
18193
|
+
version: "1.6.28",
|
|
18203
18194
|
isNpm: true,
|
|
18204
|
-
commitHash: "
|
|
18195
|
+
commitHash: "0cbed86"
|
|
18205
18196
|
}))
|
|
18206
18197
|
});
|
|
18207
18198
|
}
|
|
@@ -18771,7 +18762,7 @@ class ChatFrame extends d {
|
|
|
18771
18762
|
const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
|
|
18772
18763
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
18773
18764
|
const queryParams = {
|
|
18774
|
-
embedVersion: "
|
|
18765
|
+
embedVersion: "0cbed86".slice(0, 7),
|
|
18775
18766
|
greeting,
|
|
18776
18767
|
language,
|
|
18777
18768
|
skipGreeting,
|
|
@@ -20089,10 +20080,6 @@ class Container extends d {
|
|
|
20089
20080
|
const localChannel = messageService.getChannel("local");
|
|
20090
20081
|
const xStorageChannel = messageService.getChannel(XSTORAGE_IFRAME);
|
|
20091
20082
|
|
|
20092
|
-
if (!localChannel) {
|
|
20093
|
-
throw new AdaEmbedError("`localChannel` is null");
|
|
20094
|
-
}
|
|
20095
|
-
|
|
20096
20083
|
switch (type) {
|
|
20097
20084
|
case TRACK_EVENT:
|
|
20098
20085
|
{
|
|
@@ -20142,16 +20129,6 @@ class Container extends d {
|
|
|
20142
20129
|
break;
|
|
20143
20130
|
}
|
|
20144
20131
|
|
|
20145
|
-
case TOGGLE:
|
|
20146
|
-
{
|
|
20147
|
-
const {
|
|
20148
|
-
toggleChat
|
|
20149
|
-
} = this.props;
|
|
20150
|
-
await toggleChat();
|
|
20151
|
-
localChannel.postMessage(TOGGLE_RESPONSE, null, id);
|
|
20152
|
-
break;
|
|
20153
|
-
}
|
|
20154
|
-
|
|
20155
20132
|
case GET_INFO:
|
|
20156
20133
|
{
|
|
20157
20134
|
const {
|
|
@@ -20370,11 +20347,6 @@ class Container extends d {
|
|
|
20370
20347
|
messageService
|
|
20371
20348
|
} = this.props;
|
|
20372
20349
|
const localChannel = messageService.getChannel("local");
|
|
20373
|
-
|
|
20374
|
-
if (!localChannel) {
|
|
20375
|
-
throw new AdaEmbedError("localChannel is undefined");
|
|
20376
|
-
}
|
|
20377
|
-
|
|
20378
20350
|
return localChannel.addEventListener((type, payload, id) => {
|
|
20379
20351
|
this.handleEmbedAction(type, payload, id);
|
|
20380
20352
|
});
|
|
@@ -20752,8 +20724,7 @@ function Container_mapStateToProps(storeState) {
|
|
|
20752
20724
|
|
|
20753
20725
|
function Container_mapDispatchToProps(dispatch) {
|
|
20754
20726
|
return {
|
|
20755
|
-
setGlobalState: bindActionCreators(ActionCreators.SET_STATE_ACTION, dispatch)
|
|
20756
|
-
toggleChat: bindActionCreators(ActionCreators.TOGGLE_CHAT_ACTION, dispatch)
|
|
20727
|
+
setGlobalState: bindActionCreators(ActionCreators.SET_STATE_ACTION, dispatch)
|
|
20757
20728
|
};
|
|
20758
20729
|
}
|
|
20759
20730
|
|
|
@@ -20870,15 +20841,8 @@ function createEmbed(adaSettings) {
|
|
|
20870
20841
|
return {
|
|
20871
20842
|
initialized,
|
|
20872
20843
|
messageService,
|
|
20873
|
-
|
|
20874
|
-
|
|
20875
|
-
if (adaSettings.parentElement) {
|
|
20876
|
-
throw new AdaEmbedError("Cannot toggle when using parentElement.");
|
|
20877
|
-
}
|
|
20878
|
-
|
|
20879
|
-
await initialized;
|
|
20880
|
-
await localChannel.fetch(TOGGLE, TOGGLE_RESPONSE);
|
|
20881
|
-
},
|
|
20844
|
+
store,
|
|
20845
|
+
adaSettings,
|
|
20882
20846
|
|
|
20883
20847
|
async getInfo() {
|
|
20884
20848
|
await initialized;
|
|
@@ -20972,6 +20936,7 @@ function createEmbed(adaSettings) {
|
|
|
20972
20936
|
|
|
20973
20937
|
|
|
20974
20938
|
|
|
20939
|
+
|
|
20975
20940
|
const EMBED_NOT_INITIALIZED_ERROR = new AdaEmbedError("Actions cannot be called until Embed has been instantiated. Try running `adaEmbed.start({...})`.");
|
|
20976
20941
|
/**
|
|
20977
20942
|
* Returns the public Embed methods to be bound to the window object.
|
|
@@ -20979,6 +20944,20 @@ const EMBED_NOT_INITIALIZED_ERROR = new AdaEmbedError("Actions cannot be called
|
|
|
20979
20944
|
|
|
20980
20945
|
function createEmbedInterface() {
|
|
20981
20946
|
let embed = null;
|
|
20947
|
+
|
|
20948
|
+
const toggle = async () => {
|
|
20949
|
+
if (!embed) {
|
|
20950
|
+
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
20951
|
+
}
|
|
20952
|
+
|
|
20953
|
+
if (embed.adaSettings.parentElement) {
|
|
20954
|
+
throw new AdaEmbedError("Cannot toggle when using parentElement.");
|
|
20955
|
+
}
|
|
20956
|
+
|
|
20957
|
+
await embed.initialized;
|
|
20958
|
+
await embed.store.dispatch(ActionCreators.TOGGLE_CHAT_ACTION);
|
|
20959
|
+
};
|
|
20960
|
+
|
|
20982
20961
|
return Object.freeze({
|
|
20983
20962
|
start: async adaSettings => {
|
|
20984
20963
|
if (!isStartOptions(adaSettings)) {
|
|
@@ -21012,13 +20991,7 @@ function createEmbedInterface() {
|
|
|
21012
20991
|
embed = null;
|
|
21013
20992
|
return stopPromise;
|
|
21014
20993
|
},
|
|
21015
|
-
toggle
|
|
21016
|
-
if (!embed) {
|
|
21017
|
-
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21018
|
-
}
|
|
21019
|
-
|
|
21020
|
-
return embed.toggle();
|
|
21021
|
-
},
|
|
20994
|
+
toggle,
|
|
21022
20995
|
deleteHistory: async () => {
|
|
21023
20996
|
if (!embed) {
|
|
21024
20997
|
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
@@ -21134,7 +21107,7 @@ function createEmbedInterface() {
|
|
|
21134
21107
|
const windowInfo = await embed.getInfo();
|
|
21135
21108
|
|
|
21136
21109
|
if (!windowInfo.isChatOpen) {
|
|
21137
|
-
|
|
21110
|
+
await toggle();
|
|
21138
21111
|
}
|
|
21139
21112
|
},
|
|
21140
21113
|
triggerAnswer: answerId => {
|