@ada-support/embed2 1.6.25 → 1.6.27
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 +20 -35
- 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 +235 -281
- package/package.json +1 -1
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CampaignParams, ResetParams, StartOptions, WindowInfo } from "@ada-support/embed-types";
|
|
2
2
|
import { MessageService } from "client/lib/message-service";
|
|
3
3
|
import { StoreProxy } from "client/lib/store-proxy";
|
|
4
4
|
import "client/lib/error-tracker";
|
|
5
|
-
import type { Client } from "common/models/client";
|
|
6
5
|
import type { MetaFieldPayload } from "common/types/store";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
setMetaFields(options: MetaFieldPayload): Promise<void>;
|
|
27
|
-
setSensitiveMetaFields(options: MetaFieldPayload): Promise<void>;
|
|
28
|
-
stop(): Promise<void>;
|
|
29
|
-
deleteHistory(): Promise<void>;
|
|
30
|
-
reset(resetParams?: ResetParams): Promise<void>;
|
|
31
|
-
trackEvent(eventKey: string, value: number, meta?: {}): Promise<void>;
|
|
32
|
-
triggerCampaign(campaignKey: string, triggerCampaignParams?: {}): Promise<void>;
|
|
33
|
-
evaluateCampaignConditions(options: CampaignParams): Promise<void>;
|
|
34
|
-
createProactive(body: string, duration: number, responseId?: string): Promise<void>;
|
|
35
|
-
subscribeEvent<K extends AdaEventKey>(eventKey: K, callback: AdaEventSubscriptionCallback<K>): number;
|
|
36
|
-
unsubscribeEvent(id: number): void;
|
|
37
|
-
closeCampaign(): Promise<void>;
|
|
38
|
-
setDeviceToken(token: string): Promise<void>;
|
|
39
|
-
}
|
|
6
|
+
export declare function createEmbed(adaSettings: StartOptions): {
|
|
7
|
+
readonly initialized: Promise<void>;
|
|
8
|
+
readonly messageService: MessageService;
|
|
9
|
+
readonly store: StoreProxy;
|
|
10
|
+
readonly adaSettings: StartOptions;
|
|
11
|
+
readonly getInfo: () => Promise<WindowInfo>;
|
|
12
|
+
readonly setMetaFields: (options: MetaFieldPayload) => Promise<void>;
|
|
13
|
+
readonly setSensitiveMetaFields: (options: MetaFieldPayload) => Promise<void>;
|
|
14
|
+
readonly stop: () => Promise<void>;
|
|
15
|
+
readonly deleteHistory: () => Promise<void>;
|
|
16
|
+
readonly reset: (resetParams?: ResetParams) => Promise<void>;
|
|
17
|
+
readonly trackEvent: (eventKey: string, value: number, meta?: {}) => Promise<void>;
|
|
18
|
+
readonly triggerCampaign: (campaignKey: string, triggerCampaignParams?: {}) => Promise<void>;
|
|
19
|
+
readonly evaluateCampaignConditions: (options: CampaignParams) => Promise<void>;
|
|
20
|
+
readonly createProactive: (body: string, duration: number, responseId?: string) => Promise<void>;
|
|
21
|
+
readonly closeCampaign: () => Promise<void>;
|
|
22
|
+
readonly setDeviceToken: (token: string) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export declare type Embed = ReturnType<typeof createEmbed>;
|
|
@@ -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
|
@@ -7508,46 +7508,6 @@ var lodash_debounce_default = /*#__PURE__*/__webpack_require__.n(lodash_debounce
|
|
|
7508
7508
|
var n,l,u,i,t,r,o,f={},e=[],c=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function s(n,l){for(var u in l)n[u]=l[u];return n}function a(n){var l=n.parentNode;l&&l.removeChild(n)}function v(n,l,u){var i,t=arguments,r={};for(i in l)"key"!==i&&"ref"!==i&&(r[i]=l[i]);if(arguments.length>3)for(u=[u],i=3;i<arguments.length;i++)u.push(t[i]);if(null!=u&&(r.children=u),"function"==typeof n&&null!=n.defaultProps)for(i in n.defaultProps)void 0===r[i]&&(r[i]=n.defaultProps[i]);return h(n,r,l&&l.key,l&&l.ref,null)}function h(l,u,i,t,r){var o={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:r};return null==r&&(o.__v=o),n.vnode&&n.vnode(o),o}function y(){return{current:null}}function p(n){return n.children}function d(n,l){this.props=n,this.context=l}function _(n,l){if(null==l)return n.__?_(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?_(n):null}function k(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k(n)}}function w(l){(!l.__d&&(l.__d=!0)&&u.push(l)&&!m.__r++||t!==n.debounceRendering)&&((t=n.debounceRendering)||i)(m)}function m(){for(var n;m.__r=u.length;)n=u.sort(function(n,l){return n.__v.__b-l.__v.__b}),u=[],n.some(function(n){var l,u,i,t,r,o,f;n.__d&&(o=(r=(l=n).__v).__e,(f=l.__P)&&(u=[],(i=s({},r)).__v=i,t=T(f,r,i,l.__n,void 0!==f.ownerSVGElement,null,u,null==o?_(r):o),$(u,r),t!=o&&k(r)))})}function g(n,l,u,i,t,r,o,c,s,v){var y,d,k,w,m,g,b,A=i&&i.__k||e,P=A.length;for(s==f&&(s=null!=o?o[0]:P?_(i,0):null),u.__k=[],y=0;y<l.length;y++)if(null!=(w=u.__k[y]=null==(w=l[y])||"boolean"==typeof w?null:"string"==typeof w||"number"==typeof w?h(null,w,null,null,w):Array.isArray(w)?h(p,{children:w},null,null,null):null!=w.__e||null!=w.__c?h(w.type,w.props,w.key,null,w.__v):w)){if(w.__=u,w.__b=u.__b+1,null===(k=A[y])||k&&w.key==k.key&&w.type===k.type)A[y]=void 0;else for(d=0;d<P;d++){if((k=A[d])&&w.key==k.key&&w.type===k.type){A[d]=void 0;break}k=null}m=T(n,w,k=k||f,t,r,o,c,s,v),(d=w.ref)&&k.ref!=d&&(b||(b=[]),k.ref&&b.push(k.ref,null,w),b.push(d,w.__c||m,w)),null!=m?(null==g&&(g=m),s=x(n,w,k,A,o,m,s),"option"==u.type?n.value="":"function"==typeof u.type&&(u.__d=s)):s&&k.__e==s&&s.parentNode!=n&&(s=_(k))}if(u.__e=g,null!=o&&"function"!=typeof u.type)for(y=o.length;y--;)null!=o[y]&&a(o[y]);for(y=P;y--;)null!=A[y]&&I(A[y],A[y]);if(b)for(y=0;y<b.length;y++)H(b[y],b[++y],b[++y])}function b(n){return null==n||"boolean"==typeof n?[]:Array.isArray(n)?e.concat.apply([],n.map(b)):[n]}function x(n,l,u,i,t,r,o){var f,e,c;if(void 0!==l.__d)f=l.__d,l.__d=void 0;else if(t==u||r!=o||null==r.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(r),f=null;else{for(e=o,c=0;(e=e.nextSibling)&&c<i.length;c+=2)if(e==r)break n;n.insertBefore(r,o),f=o}return void 0!==f?f:r.nextSibling}function A(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||C(n,r,null,u[r],i);for(r in l)t&&"function"!=typeof l[r]||"children"===r||"key"===r||"value"===r||"checked"===r||u[r]===l[r]||C(n,r,l[r],u[r],i)}function P(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]="number"==typeof u&&!1===c.test(l)?u+"px":null==u?"":u}function C(n,l,u,i,t){var r,o,f,e,c;if(t?"className"===l&&(l="class"):"class"===l&&(l="className"),"style"===l)if(r=n.style,"string"==typeof u)r.cssText=u;else{if("string"==typeof i&&(r.cssText="",i=null),i)for(e in i)u&&e in u||P(r,e,"");if(u)for(c in u)i&&u[c]===i[c]||P(r,c,u[c])}else"o"===l[0]&&"n"===l[1]?(o=l!==(l=l.replace(/Capture$/,"")),f=l.toLowerCase(),l=(f in n?f:l).slice(2),u?(i||n.addEventListener(l,N,o),(n.l||(n.l={}))[l]=u):n.removeEventListener(l,N,o)):"list"!==l&&"tagName"!==l&&"form"!==l&&"type"!==l&&"size"!==l&&!t&&l in n?n[l]=null==u?"":u:"function"!=typeof u&&"dangerouslySetInnerHTML"!==l&&(l!==(l=l.replace(/^xlink:?/,""))?null==u||!1===u?n.removeAttributeNS("http://www.w3.org/1999/xlink",l.toLowerCase()):n.setAttributeNS("http://www.w3.org/1999/xlink",l.toLowerCase(),u):null==u||!1===u&&!/^ar/.test(l)?n.removeAttribute(l):n.setAttribute(l,u))}function N(l){this.l[l.type](n.event?n.event(l):l)}function z(n,l,u){var i,t;for(i=0;i<n.__k.length;i++)(t=n.__k[i])&&(t.__=n,t.__e&&("function"==typeof t.type&&t.__k.length>1&&z(t,l,u),l=x(u,t,t,n.__k,null,t.__e,l),"function"==typeof n.type&&(n.__d=l)))}function T(l,u,i,t,r,o,f,e,c){var a,v,h,y,_,k,w,m,b,x,A,P=u.type;if(void 0!==u.constructor)return null;(a=n.__b)&&a(u);try{n:if("function"==typeof P){if(m=u.props,b=(a=P.contextType)&&t[a.__c],x=a?b?b.props.value:a.__:t,i.__c?w=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(m,x):(u.__c=v=new d(m,x),v.constructor=P,v.render=L),b&&b.sub(v),v.props=m,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=s({},v.__s)),s(v.__s,P.getDerivedStateFromProps(m,v.__s))),y=v.props,_=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else{if(null==P.getDerivedStateFromProps&&m!==y&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(m,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(m,v.__s,x)||u.__v===i.__v){v.props=m,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,v.__h.length&&f.push(v),z(u,e,l);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(m,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(y,_,k)})}v.context=x,v.props=m,v.state=v.__s,(a=n.__r)&&a(u),v.__d=!1,v.__v=u,v.__P=l,a=v.render(v.props,v.state,v.context),v.state=v.__s,null!=v.getChildContext&&(t=s(s({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(k=v.getSnapshotBeforeUpdate(y,_)),A=null!=a&&a.type==p&&null==a.key?a.props.children:a,g(l,Array.isArray(A)?A:[A],u,i,t,r,o,f,e,c),v.base=u.__e,v.__h.length&&f.push(v),w&&(v.__E=v.__=null),v.__e=!1}else null==o&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=j(i.__e,u,i,t,r,o,f,c);(a=n.diffed)&&a(u)}catch(l){u.__v=null,n.__e(l,u,i)}return u.__e}function $(l,u){n.__c&&n.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u)})}catch(l){n.__e(l,u.__v)}})}function j(n,l,u,i,t,r,o,c){var s,a,v,h,y,p=u.props,d=l.props;if(t="svg"===l.type||t,null!=r)for(s=0;s<r.length;s++)if(null!=(a=r[s])&&((null===l.type?3===a.nodeType:a.localName===l.type)||n==a)){n=a,r[s]=null;break}if(null==n){if(null===l.type)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",l.type):document.createElement(l.type,d.is&&{is:d.is}),r=null,c=!1}if(null===l.type)p!==d&&n.data!=d&&(n.data=d);else{if(null!=r&&(r=e.slice.call(n.childNodes)),v=(p=u.props||f).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!c){if(null!=r)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(h||v)&&(h&&v&&h.__html==v.__html||(n.innerHTML=h&&h.__html||""))}A(n,d,p,t,c),h?l.__k=[]:(s=l.props.children,g(n,Array.isArray(s)?s:[s],l,u,i,"foreignObject"!==l.type&&t,r,o,f,c)),c||("value"in d&&void 0!==(s=d.value)&&s!==n.value&&C(n,"value",s,p.value,!1),"checked"in d&&void 0!==(s=d.checked)&&s!==n.checked&&C(n,"checked",s,p.checked,!1))}return n}function H(l,u,i){try{"function"==typeof l?l(u):l.current=u}catch(l){n.__e(l,i)}}function I(l,u,i){var t,r,o;if(n.unmount&&n.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||H(t,null,u)),i||"function"==typeof l.type||(i=null!=(r=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount()}catch(l){n.__e(l,u)}t.base=t.__P=null}if(t=l.__k)for(o=0;o<t.length;o++)t[o]&&I(t[o],u,i);null!=r&&a(r)}function L(n,l,u){return this.constructor(n,u)}function M(l,u,i){var t,o,c;n.__&&n.__(l,u),o=(t=i===r)?null:i&&i.__k||u.__k,l=v(p,null,[l]),c=[],T(u,(t?u:i||u).__k=l,o||f,f,void 0!==u.ownerSVGElement,i&&!t?[i]:o?null:u.childNodes.length?e.slice.call(u.childNodes):null,c,i||f,t),$(c,l)}function O(n,l){M(n,l,r)}function S(n,l){var u,i;for(i in l=s(s({},n.props),l),arguments.length>2&&(l.children=e.slice.call(arguments,2)),u={},l)"key"!==i&&"ref"!==i&&(u[i]=l[i]);return h(n.type,u,l.key||n.key,l.ref||n.ref,null)}function q(n){var l={},u={__c:"__cC"+o++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var i,t=this;return this.getChildContext||(i=[],this.getChildContext=function(){return l[u.__c]=t,l},this.shouldComponentUpdate=function(n){t.props.value!==n.value&&i.some(function(l){l.context=n.value,w(l)})},this.sub=function(n){i.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){i.splice(i.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Consumer.contextType=u,u.Provider.__=u,u}n={__e:function(n,l){for(var u,i;l=l.__;)if((u=l.__c)&&!u.__)try{if(u.constructor&&null!=u.constructor.getDerivedStateFromError&&(i=!0,u.setState(u.constructor.getDerivedStateFromError(n))),null!=u.componentDidCatch&&(i=!0,u.componentDidCatch(n)),i)return w(u.__E=u)}catch(l){n=l}throw n}},l=function(n){return null!=n&&void 0===n.constructor},d.prototype.setState=function(n,l){var u;u=this.__s!==this.state?this.__s:this.__s=s({},this.state),"function"==typeof n&&(n=n(u,this.props)),n&&s(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),w(this))},d.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),w(this))},d.prototype.render=p,u=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,m.__r=0,r=f,o=0;
|
|
7509
7509
|
//# sourceMappingURL=preact.module.js.map
|
|
7510
7510
|
|
|
7511
|
-
;// CONCATENATED MODULE: ./src/client/helpers/event-subscriptions/index.ts
|
|
7512
|
-
let subscriptions = [];
|
|
7513
|
-
|
|
7514
|
-
const getNextUniqueId = (() => {
|
|
7515
|
-
let lastId = 0;
|
|
7516
|
-
return () => {
|
|
7517
|
-
lastId += 1;
|
|
7518
|
-
return lastId;
|
|
7519
|
-
};
|
|
7520
|
-
})();
|
|
7521
|
-
|
|
7522
|
-
function unsubscribeEvent(id) {
|
|
7523
|
-
subscriptions = subscriptions.filter(s => s.id !== id);
|
|
7524
|
-
}
|
|
7525
|
-
function subscribeEvent(eventKey, callback) {
|
|
7526
|
-
const id = getNextUniqueId();
|
|
7527
|
-
subscriptions.push({
|
|
7528
|
-
eventKey,
|
|
7529
|
-
callback,
|
|
7530
|
-
id
|
|
7531
|
-
});
|
|
7532
|
-
return id;
|
|
7533
|
-
}
|
|
7534
|
-
function publishEvent(eventKey, data) {
|
|
7535
|
-
subscriptions.forEach(subscription => {
|
|
7536
|
-
// Using startsWith instead of === allows subscribing to a specific event OR a namespace,
|
|
7537
|
-
// e.g. ada:campaigns subscribes to ada:campaigns:opened, ada:campaigns:engaged, and
|
|
7538
|
-
// ada:campaigns:shown. Broadcasting this way simultaneously reaches subscriptions
|
|
7539
|
-
// that have subscribed to a specific event, and those that have subscribed to a namespace
|
|
7540
|
-
if (eventKey.startsWith(subscription.eventKey)) {
|
|
7541
|
-
// try/catch to guard against missing or bad callbacks
|
|
7542
|
-
try {
|
|
7543
|
-
subscription.callback(data, {
|
|
7544
|
-
eventKey
|
|
7545
|
-
});
|
|
7546
|
-
} catch {// silently fail and proceed with remaining callbacks
|
|
7547
|
-
}
|
|
7548
|
-
}
|
|
7549
|
-
});
|
|
7550
|
-
}
|
|
7551
7511
|
;// CONCATENATED MODULE: ./src/client/lib/contexts.ts
|
|
7552
7512
|
|
|
7553
7513
|
const StoreContext = q(null);
|
|
@@ -15917,7 +15877,7 @@ const client = new error_tracker_BrowserClient({
|
|
|
15917
15877
|
},
|
|
15918
15878
|
|
|
15919
15879
|
environment: "production",
|
|
15920
|
-
release: "1.6.
|
|
15880
|
+
release: "1.6.27-baf68c5",
|
|
15921
15881
|
sampleRate: 0.25,
|
|
15922
15882
|
autoSessionTracking: false,
|
|
15923
15883
|
// Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
|
|
@@ -16015,8 +15975,6 @@ let ConnectionState;
|
|
|
16015
15975
|
ConnectionState["Uninitiated"] = "UNINITIATED";
|
|
16016
15976
|
})(ConnectionState || (ConnectionState = {}));
|
|
16017
15977
|
|
|
16018
|
-
const TOGGLE = "TOGGLE";
|
|
16019
|
-
const TOGGLE_RESPONSE = "TOGGLE_RESPONSE";
|
|
16020
15978
|
const GET_INFO = "GET_INFO";
|
|
16021
15979
|
const GET_INFO_RESPONSE = "GET_INFO_RESPONSE";
|
|
16022
15980
|
const SET_META_FIELDS = "SET_META_FIELDS";
|
|
@@ -16404,14 +16362,7 @@ class MessageService {
|
|
|
16404
16362
|
}
|
|
16405
16363
|
|
|
16406
16364
|
getChannel(name) {
|
|
16407
|
-
|
|
16408
|
-
|
|
16409
|
-
if (!channel) {
|
|
16410
|
-
warn("Channel \"".concat(name, "\" has not been registered. You may need to wait until app has finished initializing."));
|
|
16411
|
-
return null;
|
|
16412
|
-
}
|
|
16413
|
-
|
|
16414
|
-
return channel;
|
|
16365
|
+
return this.channels[name];
|
|
16415
16366
|
}
|
|
16416
16367
|
|
|
16417
16368
|
getAllChannels() {
|
|
@@ -16441,6 +16392,46 @@ let ActionTypes;
|
|
|
16441
16392
|
ActionTypes["SET_CONNECTION_STATE_TYPE"] = "SET_CONNECTION_STATE";
|
|
16442
16393
|
ActionTypes["INCREMENT_MESSAGE_COUNT_TYPE"] = "INCREMENT_MESSAGE_COUNT";
|
|
16443
16394
|
})(ActionTypes || (ActionTypes = {}));
|
|
16395
|
+
;// CONCATENATED MODULE: ./src/client/helpers/event-subscriptions/index.ts
|
|
16396
|
+
let subscriptions = [];
|
|
16397
|
+
|
|
16398
|
+
const getNextUniqueId = (() => {
|
|
16399
|
+
let lastId = 0;
|
|
16400
|
+
return () => {
|
|
16401
|
+
lastId += 1;
|
|
16402
|
+
return lastId;
|
|
16403
|
+
};
|
|
16404
|
+
})();
|
|
16405
|
+
|
|
16406
|
+
function unsubscribeEvent(id) {
|
|
16407
|
+
subscriptions = subscriptions.filter(s => s.id !== id);
|
|
16408
|
+
}
|
|
16409
|
+
function subscribeEvent(eventKey, callback) {
|
|
16410
|
+
const id = getNextUniqueId();
|
|
16411
|
+
subscriptions.push({
|
|
16412
|
+
eventKey,
|
|
16413
|
+
callback,
|
|
16414
|
+
id
|
|
16415
|
+
});
|
|
16416
|
+
return id;
|
|
16417
|
+
}
|
|
16418
|
+
function publishEvent(eventKey, data) {
|
|
16419
|
+
subscriptions.forEach(subscription => {
|
|
16420
|
+
// Using startsWith instead of === allows subscribing to a specific event OR a namespace,
|
|
16421
|
+
// e.g. ada:campaigns subscribes to ada:campaigns:opened, ada:campaigns:engaged, and
|
|
16422
|
+
// ada:campaigns:shown. Broadcasting this way simultaneously reaches subscriptions
|
|
16423
|
+
// that have subscribed to a specific event, and those that have subscribed to a namespace
|
|
16424
|
+
if (eventKey.startsWith(subscription.eventKey)) {
|
|
16425
|
+
// try/catch to guard against missing or bad callbacks
|
|
16426
|
+
try {
|
|
16427
|
+
subscription.callback(data, {
|
|
16428
|
+
eventKey
|
|
16429
|
+
});
|
|
16430
|
+
} catch {// silently fail and proceed with remaining callbacks
|
|
16431
|
+
}
|
|
16432
|
+
}
|
|
16433
|
+
});
|
|
16434
|
+
}
|
|
16444
16435
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/url.js
|
|
16445
16436
|
var url = __webpack_require__(9969);
|
|
16446
16437
|
var url_default = /*#__PURE__*/__webpack_require__.n(url);
|
|
@@ -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("baf68c5", "/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.27",
|
|
18203
18194
|
isNpm: true,
|
|
18204
|
-
commitHash: "
|
|
18195
|
+
commitHash: "baf68c5"
|
|
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: "baf68c5".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
|
|
|
@@ -20776,219 +20747,196 @@ function embed_objectSpread(target) { for (var i = 1; i < arguments.length; i++)
|
|
|
20776
20747
|
|
|
20777
20748
|
|
|
20778
20749
|
|
|
20779
|
-
|
|
20780
|
-
|
|
20781
|
-
|
|
20782
|
-
|
|
20783
|
-
|
|
20784
|
-
|
|
20785
|
-
|
|
20786
|
-
|
|
20787
|
-
|
|
20788
|
-
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20793
|
-
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
_defineProperty(this, "entryContainer", void 0);
|
|
20798
|
-
|
|
20799
|
-
_defineProperty(this, "initializationReject", void 0);
|
|
20800
|
-
|
|
20801
|
-
_defineProperty(this, "initializationResolve", void 0);
|
|
20802
|
-
|
|
20803
|
-
_defineProperty(this, "debounceCampaignTrigger", void 0);
|
|
20804
|
-
|
|
20805
|
-
this.adaSettings = adaSettings;
|
|
20806
|
-
this.messageService = new MessageService();
|
|
20807
|
-
const initialState = getInitialState(adaSettings);
|
|
20808
|
-
this.store = new StoreProxy(initialState, this.messageService);
|
|
20809
|
-
this.localChannel = this.messageService.channels.local;
|
|
20810
|
-
this.initialized = new Promise((resolve, reject) => {
|
|
20811
|
-
this.initializationResolve = resolve;
|
|
20812
|
-
this.initializationReject = reject;
|
|
20813
|
-
});
|
|
20814
|
-
this.renderPreactApp();
|
|
20815
|
-
this.debounceCampaignTrigger = lodash_debounce_default()(async function (campaignKey) {
|
|
20816
|
-
let triggerCampaignParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
20817
|
-
await _this.initialized;
|
|
20818
|
-
await _this.localChannel.fetch(TRIGGER_CAMPAIGN, TRIGGER_CAMPAIGN_RESPONSE, embed_objectSpread({
|
|
20819
|
-
campaignKey
|
|
20820
|
-
}, triggerCampaignParams));
|
|
20821
|
-
}, 1000, {
|
|
20822
|
-
leading: true
|
|
20750
|
+
function renderApp(_ref) {
|
|
20751
|
+
let {
|
|
20752
|
+
adaSettings,
|
|
20753
|
+
initializationResolve,
|
|
20754
|
+
initializationReject,
|
|
20755
|
+
messageService,
|
|
20756
|
+
store
|
|
20757
|
+
} = _ref;
|
|
20758
|
+
let parentContainer;
|
|
20759
|
+
const entryContainer = document.createElement("div");
|
|
20760
|
+
entryContainer.id = "ada-entry";
|
|
20761
|
+
|
|
20762
|
+
if (adaSettings.parentElement) {
|
|
20763
|
+
// Just to reduce the diff size in PR (can be removed)
|
|
20764
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
20765
|
+
parentContainer = getParentContainer({
|
|
20766
|
+
adaSettings
|
|
20823
20767
|
});
|
|
20768
|
+
entryContainer.style.height = "100%";
|
|
20769
|
+
} else {
|
|
20770
|
+
parentContainer = document.body;
|
|
20824
20771
|
}
|
|
20825
20772
|
|
|
20826
|
-
|
|
20827
|
-
|
|
20828
|
-
this.entryContainer = document.createElement("div");
|
|
20829
|
-
this.entryContainer.id = "ada-entry";
|
|
20830
|
-
|
|
20831
|
-
if (this.adaSettings.parentElement) {
|
|
20832
|
-
parentContainer = this.setUpFrameParent();
|
|
20833
|
-
this.entryContainer.style.height = "100%";
|
|
20834
|
-
} else {
|
|
20835
|
-
parentContainer = document.body;
|
|
20836
|
-
}
|
|
20837
|
-
|
|
20838
|
-
if (!parentContainer) {
|
|
20839
|
-
throw new AdaEmbedError("`parentContainer` is null");
|
|
20840
|
-
}
|
|
20841
|
-
|
|
20842
|
-
parentContainer.appendChild(this.entryContainer);
|
|
20843
|
-
M(v(StoreContext.Provider, {
|
|
20844
|
-
value: this.store
|
|
20845
|
-
}, v(MessageServiceContext.Provider, {
|
|
20846
|
-
value: this.messageService
|
|
20847
|
-
}, v(ConnectedContainer, {
|
|
20848
|
-
store: this.store,
|
|
20849
|
-
messageService: this.messageService,
|
|
20850
|
-
adaSettings: this.adaSettings,
|
|
20851
|
-
entryContainer: this.entryContainer,
|
|
20852
|
-
initializationReject: this.initializationReject,
|
|
20853
|
-
initializationResolve: this.initializationResolve
|
|
20854
|
-
}))), this.entryContainer);
|
|
20773
|
+
if (!parentContainer) {
|
|
20774
|
+
throw new AdaEmbedError("`parentContainer` is null");
|
|
20855
20775
|
}
|
|
20856
20776
|
|
|
20857
|
-
|
|
20858
|
-
|
|
20859
|
-
|
|
20860
|
-
|
|
20861
|
-
|
|
20862
|
-
|
|
20863
|
-
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20867
|
-
|
|
20868
|
-
|
|
20869
|
-
|
|
20870
|
-
|
|
20871
|
-
}
|
|
20872
|
-
|
|
20873
|
-
if (!targetElement) {
|
|
20874
|
-
throw new AdaEmbedError("parentElement requires a string or HTMLElement.");
|
|
20875
|
-
}
|
|
20876
|
-
|
|
20877
|
-
return targetElement;
|
|
20878
|
-
}
|
|
20777
|
+
parentContainer.appendChild(entryContainer);
|
|
20778
|
+
M(v(StoreContext.Provider, {
|
|
20779
|
+
value: store
|
|
20780
|
+
}, v(MessageServiceContext.Provider, {
|
|
20781
|
+
value: messageService
|
|
20782
|
+
}, v(ConnectedContainer, {
|
|
20783
|
+
store: store,
|
|
20784
|
+
messageService: messageService,
|
|
20785
|
+
adaSettings: adaSettings,
|
|
20786
|
+
entryContainer: entryContainer,
|
|
20787
|
+
initializationReject: initializationReject,
|
|
20788
|
+
initializationResolve: initializationResolve
|
|
20789
|
+
}))), entryContainer);
|
|
20790
|
+
}
|
|
20879
20791
|
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20792
|
+
function getParentContainer(_ref2) {
|
|
20793
|
+
let {
|
|
20794
|
+
adaSettings
|
|
20795
|
+
} = _ref2;
|
|
20796
|
+
const {
|
|
20797
|
+
parentElement
|
|
20798
|
+
} = adaSettings;
|
|
20799
|
+
let targetElement = null;
|
|
20884
20800
|
|
|
20885
|
-
|
|
20886
|
-
|
|
20801
|
+
if (!parentElement) {
|
|
20802
|
+
return null;
|
|
20887
20803
|
}
|
|
20888
20804
|
|
|
20889
|
-
|
|
20890
|
-
|
|
20891
|
-
|
|
20805
|
+
if (typeof parentElement === "string") {
|
|
20806
|
+
targetElement = document.getElementById(parentElement);
|
|
20807
|
+
} else if (parentElement instanceof HTMLElement) {
|
|
20808
|
+
targetElement = parentElement;
|
|
20892
20809
|
}
|
|
20893
20810
|
|
|
20894
|
-
|
|
20895
|
-
|
|
20896
|
-
await this.localChannel.fetch(SET_META_FIELDS, SET_META_FIELDS_RESPONSE, options);
|
|
20811
|
+
if (!targetElement) {
|
|
20812
|
+
throw new AdaEmbedError("parentElement requires a string or HTMLElement.");
|
|
20897
20813
|
}
|
|
20898
20814
|
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
await this.localChannel.fetch("SET_SENSITIVE_META_FIELDS", "SET_SENSITIVE_META_FIELDS_RESPONSE", options);
|
|
20902
|
-
}
|
|
20815
|
+
return targetElement;
|
|
20816
|
+
}
|
|
20903
20817
|
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
|
|
20818
|
+
function createEmbed(adaSettings) {
|
|
20819
|
+
const messageService = new MessageService();
|
|
20820
|
+
const localChannel = messageService.channels.local;
|
|
20821
|
+
const initialState = getInitialState(adaSettings);
|
|
20822
|
+
const store = new StoreProxy(initialState, messageService);
|
|
20823
|
+
const initialized = new Promise((resolve, reject) => {
|
|
20824
|
+
renderApp({
|
|
20825
|
+
adaSettings,
|
|
20826
|
+
messageService,
|
|
20827
|
+
store,
|
|
20828
|
+
initializationResolve: resolve,
|
|
20829
|
+
initializationReject: reject
|
|
20830
|
+
});
|
|
20831
|
+
});
|
|
20832
|
+
const debounceCampaignTrigger = lodash_debounce_default()(async function (campaignKey) {
|
|
20833
|
+
let triggerCampaignParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
20834
|
+
await initialized;
|
|
20835
|
+
await localChannel.fetch(TRIGGER_CAMPAIGN, TRIGGER_CAMPAIGN_RESPONSE, embed_objectSpread({
|
|
20836
|
+
campaignKey
|
|
20837
|
+
}, triggerCampaignParams));
|
|
20838
|
+
}, 1000, {
|
|
20839
|
+
leading: true
|
|
20840
|
+
});
|
|
20841
|
+
return {
|
|
20842
|
+
initialized,
|
|
20843
|
+
messageService,
|
|
20844
|
+
store,
|
|
20845
|
+
adaSettings,
|
|
20908
20846
|
|
|
20909
|
-
|
|
20910
|
-
|
|
20911
|
-
|
|
20912
|
-
|
|
20847
|
+
async getInfo() {
|
|
20848
|
+
await initialized;
|
|
20849
|
+
return await localChannel.fetch(GET_INFO, GET_INFO_RESPONSE);
|
|
20850
|
+
},
|
|
20913
20851
|
|
|
20914
|
-
|
|
20915
|
-
|
|
20916
|
-
|
|
20917
|
-
|
|
20918
|
-
}
|
|
20852
|
+
async setMetaFields(options) {
|
|
20853
|
+
await initialized;
|
|
20854
|
+
await localChannel.fetch(SET_META_FIELDS, SET_META_FIELDS_RESPONSE, options);
|
|
20855
|
+
},
|
|
20919
20856
|
|
|
20920
|
-
|
|
20921
|
-
|
|
20922
|
-
|
|
20923
|
-
|
|
20924
|
-
eventKey,
|
|
20925
|
-
value,
|
|
20926
|
-
meta
|
|
20927
|
-
});
|
|
20928
|
-
}
|
|
20857
|
+
async setSensitiveMetaFields(options) {
|
|
20858
|
+
await initialized;
|
|
20859
|
+
await localChannel.fetch("SET_SENSITIVE_META_FIELDS", "SET_SENSITIVE_META_FIELDS_RESPONSE", options);
|
|
20860
|
+
},
|
|
20929
20861
|
|
|
20930
|
-
|
|
20931
|
-
|
|
20932
|
-
|
|
20933
|
-
|
|
20862
|
+
async stop() {
|
|
20863
|
+
await initialized;
|
|
20864
|
+
await localChannel.fetch(STOP, STOP_RESPONSE);
|
|
20865
|
+
},
|
|
20934
20866
|
|
|
20935
|
-
|
|
20936
|
-
|
|
20937
|
-
|
|
20938
|
-
|
|
20867
|
+
async deleteHistory() {
|
|
20868
|
+
await initialized;
|
|
20869
|
+
await localChannel.fetch(DELETE_HISTORY, DELETE_HISTORY_RESPONSE);
|
|
20870
|
+
},
|
|
20939
20871
|
|
|
20940
|
-
|
|
20941
|
-
|
|
20942
|
-
|
|
20943
|
-
|
|
20872
|
+
async reset() {
|
|
20873
|
+
let resetParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20874
|
+
await initialized;
|
|
20875
|
+
await localChannel.fetch(RESET, RESET_RESPONSE, resetParams);
|
|
20876
|
+
},
|
|
20944
20877
|
|
|
20945
|
-
|
|
20878
|
+
async trackEvent(eventKey, value) {
|
|
20879
|
+
let meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
20880
|
+
await initialized;
|
|
20881
|
+
await localChannel.fetch(TRACK_EVENT, TRACK_EVENT_RESPONSE, {
|
|
20882
|
+
eventKey,
|
|
20883
|
+
value,
|
|
20884
|
+
meta
|
|
20885
|
+
});
|
|
20886
|
+
},
|
|
20946
20887
|
|
|
20947
|
-
|
|
20948
|
-
|
|
20949
|
-
|
|
20950
|
-
|
|
20951
|
-
responseId
|
|
20952
|
-
}, // The timeoutOverride is the duration the proactive is open for, plus a
|
|
20953
|
-
// 2s buffer. Without this, a very long duration could exceed the
|
|
20954
|
-
// default timeout.
|
|
20955
|
-
duration * 1000 + 2000);
|
|
20956
|
-
} catch (e) {
|
|
20957
|
-
throw new AdaEmbedError("".concat(e));
|
|
20958
|
-
}
|
|
20959
|
-
} // We want it in the class so clients can do `adaEmbed.subscribeEvent`
|
|
20960
|
-
// eslint-disable-next-line class-methods-use-this
|
|
20888
|
+
async triggerCampaign(campaignKey) {
|
|
20889
|
+
let triggerCampaignParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
20890
|
+
debounceCampaignTrigger(campaignKey, triggerCampaignParams);
|
|
20891
|
+
},
|
|
20961
20892
|
|
|
20893
|
+
async evaluateCampaignConditions(options) {
|
|
20894
|
+
await initialized;
|
|
20895
|
+
await localChannel.fetch(EVAL_CAMPAIGN_CONDITIONS, EVAL_CAMPAIGN_CONDITIONS_RESPONSE, options);
|
|
20896
|
+
},
|
|
20962
20897
|
|
|
20963
|
-
|
|
20964
|
-
|
|
20965
|
-
|
|
20898
|
+
async createProactive(body, duration, responseId) {
|
|
20899
|
+
if (adaSettings.parentElement) {
|
|
20900
|
+
throw new AdaEmbedError("Cannot call createProactive when using parentElement.");
|
|
20901
|
+
}
|
|
20966
20902
|
|
|
20903
|
+
await initialized;
|
|
20967
20904
|
|
|
20968
|
-
|
|
20969
|
-
|
|
20970
|
-
|
|
20905
|
+
try {
|
|
20906
|
+
await localChannel.fetch(CREATE_PROACTIVE, CREATE_PROACTIVE_RESPONSE, {
|
|
20907
|
+
body,
|
|
20908
|
+
duration,
|
|
20909
|
+
responseId
|
|
20910
|
+
}, // The timeoutOverride is the duration the proactive is open for, plus a
|
|
20911
|
+
// 2s buffer. Without this, a very long duration could exceed the
|
|
20912
|
+
// default timeout.
|
|
20913
|
+
duration * 1000 + 2000);
|
|
20914
|
+
} catch (e) {
|
|
20915
|
+
throw new AdaEmbedError("".concat(e));
|
|
20916
|
+
}
|
|
20917
|
+
},
|
|
20971
20918
|
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
20975
|
-
|
|
20919
|
+
async closeCampaign() {
|
|
20920
|
+
await initialized;
|
|
20921
|
+
await localChannel.fetch(CLOSE_CAMPAIGN, CLOSE_CAMPAIGN_RESPONSE);
|
|
20922
|
+
},
|
|
20976
20923
|
|
|
20977
|
-
|
|
20978
|
-
|
|
20979
|
-
|
|
20980
|
-
|
|
20981
|
-
|
|
20982
|
-
|
|
20924
|
+
async setDeviceToken(token) {
|
|
20925
|
+
await initialized;
|
|
20926
|
+
await localChannel.fetch(SET_DEVICE_TOKEN, SET_DEVICE_TOKEN_RESPONSE, {
|
|
20927
|
+
token
|
|
20928
|
+
});
|
|
20929
|
+
}
|
|
20983
20930
|
|
|
20931
|
+
};
|
|
20984
20932
|
}
|
|
20985
|
-
|
|
20986
|
-
_defineProperty(Embed, "embed2Version", "1094e92");
|
|
20987
20933
|
;// CONCATENATED MODULE: ./src/interface.ts
|
|
20988
20934
|
|
|
20989
20935
|
|
|
20990
20936
|
|
|
20991
20937
|
|
|
20938
|
+
|
|
20939
|
+
|
|
20992
20940
|
const EMBED_NOT_INITIALIZED_ERROR = new AdaEmbedError("Actions cannot be called until Embed has been instantiated. Try running `adaEmbed.start({...})`.");
|
|
20993
20941
|
/**
|
|
20994
20942
|
* Returns the public Embed methods to be bound to the window object.
|
|
@@ -20996,6 +20944,20 @@ const EMBED_NOT_INITIALIZED_ERROR = new AdaEmbedError("Actions cannot be called
|
|
|
20996
20944
|
|
|
20997
20945
|
function createEmbedInterface() {
|
|
20998
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
|
+
|
|
20999
20961
|
return Object.freeze({
|
|
21000
20962
|
start: async adaSettings => {
|
|
21001
20963
|
if (!isStartOptions(adaSettings)) {
|
|
@@ -21006,7 +20968,7 @@ function createEmbedInterface() {
|
|
|
21006
20968
|
throw new AdaEmbedError("Ada Embed has already been started.");
|
|
21007
20969
|
}
|
|
21008
20970
|
|
|
21009
|
-
embed =
|
|
20971
|
+
embed = createEmbed(adaSettings);
|
|
21010
20972
|
|
|
21011
20973
|
if (window.adaEmbedLoadedCallback) {
|
|
21012
20974
|
window.adaEmbedLoadedCallback();
|
|
@@ -21029,13 +20991,7 @@ function createEmbedInterface() {
|
|
|
21029
20991
|
embed = null;
|
|
21030
20992
|
return stopPromise;
|
|
21031
20993
|
},
|
|
21032
|
-
toggle
|
|
21033
|
-
if (!embed) {
|
|
21034
|
-
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21035
|
-
}
|
|
21036
|
-
|
|
21037
|
-
return embed.toggle();
|
|
21038
|
-
},
|
|
20994
|
+
toggle,
|
|
21039
20995
|
deleteHistory: async () => {
|
|
21040
20996
|
if (!embed) {
|
|
21041
20997
|
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
@@ -21071,7 +21027,7 @@ function createEmbedInterface() {
|
|
|
21071
21027
|
|
|
21072
21028
|
log("Embed reset", {
|
|
21073
21029
|
initialURL: window.location.href,
|
|
21074
|
-
// not sure if the handle will be present so adding the URL to help out with
|
|
21030
|
+
// not sure if the handle will be present so adding the URL to help out with identifying the client
|
|
21075
21031
|
resetChatHistory: resetParams === null || resetParams === void 0 ? void 0 : resetParams.resetChatHistory,
|
|
21076
21032
|
greeting: resetParams === null || resetParams === void 0 ? void 0 : resetParams.greeting
|
|
21077
21033
|
});
|
|
@@ -21112,20 +21068,8 @@ function createEmbedInterface() {
|
|
|
21112
21068
|
|
|
21113
21069
|
return embed.evaluateCampaignConditions(options);
|
|
21114
21070
|
},
|
|
21115
|
-
subscribeEvent: async (eventKey, callback) =>
|
|
21116
|
-
|
|
21117
|
-
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21118
|
-
}
|
|
21119
|
-
|
|
21120
|
-
return embed.subscribeEvent(eventKey, callback);
|
|
21121
|
-
},
|
|
21122
|
-
unsubscribeEvent: async id => {
|
|
21123
|
-
if (!embed) {
|
|
21124
|
-
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
21125
|
-
}
|
|
21126
|
-
|
|
21127
|
-
return embed.unsubscribeEvent(id);
|
|
21128
|
-
},
|
|
21071
|
+
subscribeEvent: async (eventKey, callback) => subscribeEvent(eventKey, callback),
|
|
21072
|
+
unsubscribeEvent: async id => unsubscribeEvent(id),
|
|
21129
21073
|
closeCampaign: async () => {
|
|
21130
21074
|
if (!embed) {
|
|
21131
21075
|
throw EMBED_NOT_INITIALIZED_ERROR;
|
|
@@ -21146,7 +21090,12 @@ function createEmbedInterface() {
|
|
|
21146
21090
|
}
|
|
21147
21091
|
|
|
21148
21092
|
const channel = embed.messageService.getChannel("chat");
|
|
21149
|
-
|
|
21093
|
+
|
|
21094
|
+
if (!channel) {
|
|
21095
|
+
throw new AdaEmbedError("Chat is not ready yet to have language changed.");
|
|
21096
|
+
}
|
|
21097
|
+
|
|
21098
|
+
channel.postMessage("SET_LANGUAGE", {
|
|
21150
21099
|
language
|
|
21151
21100
|
});
|
|
21152
21101
|
},
|
|
@@ -21158,7 +21107,7 @@ function createEmbedInterface() {
|
|
|
21158
21107
|
const windowInfo = await embed.getInfo();
|
|
21159
21108
|
|
|
21160
21109
|
if (!windowInfo.isChatOpen) {
|
|
21161
|
-
|
|
21110
|
+
await toggle();
|
|
21162
21111
|
}
|
|
21163
21112
|
},
|
|
21164
21113
|
triggerAnswer: answerId => {
|
|
@@ -21167,7 +21116,12 @@ function createEmbedInterface() {
|
|
|
21167
21116
|
}
|
|
21168
21117
|
|
|
21169
21118
|
const channel = embed.messageService.getChannel("chat");
|
|
21170
|
-
|
|
21119
|
+
|
|
21120
|
+
if (!channel) {
|
|
21121
|
+
throw new AdaEmbedError("Chat is not ready yet to have answer triggered.");
|
|
21122
|
+
}
|
|
21123
|
+
|
|
21124
|
+
channel.postMessage("TRIGGER_ANSWER", {
|
|
21171
21125
|
answerId
|
|
21172
21126
|
});
|
|
21173
21127
|
}
|