@ada-support/embed2 1.4.19 → 1.4.20

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.
@@ -1,7 +1,8 @@
1
+ import type { AdaCluster } from "common/types";
1
2
  import type { ClientObject, ClientResponse } from "common/types/http";
2
3
  export declare function isClientObject(client: Record<string, unknown>): client is ClientObject;
3
4
  /**
4
5
  * Tries fetching the client from cache. If this fails, tries fetching it from API.
5
6
  * If this also fails, returns null.
6
7
  */
7
- export declare function fetchClient(handle: string, cluster: string, domain: string, language: string): Promise<ClientResponse | null>;
8
+ export declare function fetchClient(handle: string, cluster?: AdaCluster, domain?: string, language?: string): Promise<ClientResponse | null>;
@@ -1,7 +1,8 @@
1
+ import type { AdaCluster } from "common/types";
1
2
  interface GetEmbedUrlParams {
2
3
  frameName: "button" | "x-storage" | "intro" | "drawer-mask";
3
4
  handle: string;
4
- cluster?: string;
5
+ cluster?: AdaCluster;
5
6
  domain?: string;
6
7
  }
7
8
  interface QueryParams {
@@ -10,13 +11,13 @@ interface QueryParams {
10
11
  export interface CSInterface {
11
12
  name: "api";
12
13
  handle: string;
13
- cluster?: string;
14
+ cluster?: AdaCluster;
14
15
  domain?: string;
15
16
  route?: string;
16
17
  qp?: QueryParams;
17
18
  isEmbedFramed?: boolean;
18
19
  }
19
- export declare function getClientCacheUrl(handle: string, cluster?: string, domain?: string): string;
20
+ export declare function getClientCacheUrl(handle: string, cluster?: AdaCluster, domain?: string): string;
20
21
  export declare function getEmbedURL({ frameName, handle, cluster, domain, }: GetEmbedUrlParams): string;
21
22
  /**
22
23
  * Generate the Chat / API URL
@@ -25,7 +26,7 @@ export declare function getURL({ name, handle, cluster, domain, route, qp, }: CS
25
26
  export declare function getChatURL({ handle, version, cluster, domain, qp, }: {
26
27
  handle: string;
27
28
  version?: string;
28
- cluster?: string;
29
+ cluster?: AdaCluster;
29
30
  domain?: string;
30
31
  qp?: QueryParams;
31
32
  }): string;
@@ -1,7 +1,7 @@
1
1
  import type { CampaignParams, ResetParams } from "@ada-support/embed-types";
2
2
  import type { FetchEventStatusType } from "common/constants/events";
3
+ import type { SendGreetingParams, StoreDispatchPayload, StoreGetPayload, TrackEventParams } from "common/types";
3
4
  import type { AdaCustomEvent, Refhandler } from "common/types/events";
4
- import type { SendGreetingParams, StoreDispatchPayload, StoreGetPayload, TrackEventParams } from "common/types/index";
5
5
  import type { MetaFieldPayload } from "common/types/store";
6
6
  import type { StoreState } from "common/types/store-state";
7
7
  export interface EmbedRequestPayloadByEvent {
@@ -12,7 +12,7 @@ export declare class Client {
12
12
  privacy: boolean;
13
13
  features: Features;
14
14
  persistence: string;
15
- chat_button: ChatButton | null;
15
+ chat_button: ChatButton;
16
16
  business_events?: BusinessEvent[];
17
17
  marketing_campaigns_order?: string[];
18
18
  marketing_campaigns?: MarketingCampaign[];
@@ -4,7 +4,7 @@ export interface ChatButton {
4
4
  size: number;
5
5
  background_color: string;
6
6
  icon_path: string;
7
- icon_type: string;
7
+ icon_type: "default" | "custom";
8
8
  }
9
9
  export interface CurrentIntro {
10
10
  response_id: string;
@@ -32,7 +32,7 @@ export interface ClientObject {
32
32
  language: LanguageKey;
33
33
  privacy: boolean;
34
34
  tint: string;
35
- chat_button: ChatButton | null;
35
+ chat_button: ChatButton;
36
36
  intro?: CurrentIntro;
37
37
  features: Features;
38
38
  marketing_campaigns_order?: string[];
@@ -46,7 +46,7 @@ export interface CachedClientObject {
46
46
  language: LanguageKey;
47
47
  privacy: boolean;
48
48
  tint: string;
49
- chat_button: ChatButton | null;
49
+ chat_button: ChatButton;
50
50
  features: Features;
51
51
  business_events?: BusinessEvent[];
52
52
  marketing_campaigns_order?: string[];
@@ -1,6 +1,7 @@
1
1
  import type { AdaEmbedAPI } from "@ada-support/embed-types";
2
2
  import type { ActionTypes } from "common/constants/actions";
3
3
  import type { StoreState } from "./store-state";
4
+ export * from "./interface";
4
5
  export interface StoreAction {
5
6
  [key: string]: string | object | number;
6
7
  type: ActionTypes;
@@ -0,0 +1 @@
1
+ export declare type AdaCluster = "att" | "ca" | "eu" | "ficanex" | "maple" | undefined;
@@ -1,6 +1,7 @@
1
1
  import type { StartOptions } from "@ada-support/embed-types";
2
2
  import type { ConnectionState } from "common/constants/events";
3
3
  import type { Client } from "common/models/client";
4
+ import type { AdaCluster } from "common/types";
4
5
  export interface StoreState extends StartOptionsNoFunction {
5
6
  chatterCreated?: string | null;
6
7
  chatterToken?: string | null;
@@ -48,7 +49,7 @@ export interface StartOptionsNoFunction {
48
49
  styles?: string;
49
50
  embedStyles?: string;
50
51
  domain?: string;
51
- cluster?: string;
52
+ cluster?: AdaCluster;
52
53
  language?: string;
53
54
  greeting?: string;
54
55
  hideMask?: boolean;
@@ -7397,45 +7397,7 @@ var lodash_debounce_default = /*#__PURE__*/__webpack_require__.n(lodash_debounce
7397
7397
  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;
7398
7398
  //# sourceMappingURL=preact.module.js.map
7399
7399
 
7400
- // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/includes.js
7401
- var includes = __webpack_require__(8580);
7402
- var includes_default = /*#__PURE__*/__webpack_require__.n(includes);
7403
- ;// CONCATENATED MODULE: ./src/common/helpers/errors.ts
7404
-
7405
-
7406
- /**
7407
- * Creates a standardized Error type for Ada Embed.
7408
- */
7409
- class AdaEmbedError extends Error {
7410
- constructor(message) {
7411
- super(message);
7412
- this.name = "AdaEmbedError";
7413
- }
7414
-
7415
- }
7416
- /**
7417
- * This is needed to ensure we standardize warnings we expose to the client.
7418
- */
7419
-
7420
- function warn(warningText) {
7421
- // Nothing meaningful to warn about.
7422
- if (!warningText) {
7423
- return;
7424
- } // Capitalize
7425
-
7426
-
7427
- let text = warningText.charAt(0).toUpperCase() + warningText.slice(1);
7428
- const lastChar = text.charAt(text.length - 1);
7429
- const acceptedLastChars = [".", "?", "!"]; // Add period if one wasn't added
7430
-
7431
- if (!includes_default()(acceptedLastChars).call(acceptedLastChars, lastChar)) {
7432
- text = "".concat(text, ".");
7433
- }
7434
-
7435
- console.warn("Ada Embed - ".concat(text));
7436
- }
7437
7400
  ;// CONCATENATED MODULE: ./src/client/helpers/event-subscriptions/index.ts
7438
-
7439
7401
  let subscriptions = [];
7440
7402
 
7441
7403
  const getNextUniqueId = (() => {
@@ -7450,10 +7412,6 @@ function unsubscribeEvent(id) {
7450
7412
  subscriptions = subscriptions.filter(s => s.id !== id);
7451
7413
  }
7452
7414
  function subscribeEvent(eventKey, callback) {
7453
- if (!eventKey) {
7454
- throw new AdaEmbedError("Please provide a subscription key");
7455
- }
7456
-
7457
7415
  const id = getNextUniqueId();
7458
7416
  subscriptions.push({
7459
7417
  eventKey,
@@ -7483,6 +7441,43 @@ function publishEvent(eventKey, data) {
7483
7441
 
7484
7442
  const StoreContext = q(null);
7485
7443
  const MessageServiceContext = q(null);
7444
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/includes.js
7445
+ var includes = __webpack_require__(8580);
7446
+ var includes_default = /*#__PURE__*/__webpack_require__.n(includes);
7447
+ ;// CONCATENATED MODULE: ./src/common/helpers/errors.ts
7448
+
7449
+
7450
+ /**
7451
+ * Creates a standardized Error type for Ada Embed.
7452
+ */
7453
+ class AdaEmbedError extends Error {
7454
+ constructor(message) {
7455
+ super(message);
7456
+ this.name = "AdaEmbedError";
7457
+ }
7458
+
7459
+ }
7460
+ /**
7461
+ * This is needed to ensure we standardize warnings we expose to the client.
7462
+ */
7463
+
7464
+ function warn(warningText) {
7465
+ // Nothing meaningful to warn about.
7466
+ if (!warningText) {
7467
+ return;
7468
+ } // Capitalize
7469
+
7470
+
7471
+ let text = warningText.charAt(0).toUpperCase() + warningText.slice(1);
7472
+ const lastChar = text.charAt(text.length - 1);
7473
+ const acceptedLastChars = [".", "?", "!"]; // Add period if one wasn't added
7474
+
7475
+ if (!includes_default()(acceptedLastChars).call(acceptedLastChars, lastChar)) {
7476
+ text = "".concat(text, ".");
7477
+ }
7478
+
7479
+ console.warn("Ada Embed - ".concat(text));
7480
+ }
7486
7481
  // EXTERNAL MODULE: ./node_modules/uniqid/index.js
7487
7482
  var uniqid = __webpack_require__(6104);
7488
7483
  var uniqid_default = /*#__PURE__*/__webpack_require__.n(uniqid);
@@ -15811,7 +15806,7 @@ const client = new error_tracker_BrowserClient({
15811
15806
  },
15812
15807
 
15813
15808
  environment: "production",
15814
- release: "1.4.19-64c182e",
15809
+ release: "1.4.20-16915e5",
15815
15810
  sampleRate: 0.25,
15816
15811
  autoSessionTracking: false,
15817
15812
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -16441,7 +16436,7 @@ function getEmbedURL(_ref) {
16441
16436
  host = "http://".concat(window.location.hostname, ":9001");
16442
16437
  }
16443
16438
 
16444
- return "".concat(host, "/embed/").concat(frameName, "/").concat("64c182e", "/index.html");
16439
+ return "".concat(host, "/embed/").concat(frameName, "/").concat("16915e5", "/index.html");
16445
16440
  }
16446
16441
 
16447
16442
  function constructQueryString(query) {
@@ -17104,7 +17099,7 @@ const getInitialState = adaSettings => ({
17104
17099
  rolloutOverride: undefined,
17105
17100
  chatterToken: getValueFromStorage(CHATTER_TOKEN_STORAGE_KEY) || undefined,
17106
17101
  chatterCreated: getValueFromStorage(CHATTER_CREATED_STORAGE_KEY) || undefined,
17107
- sessionToken: getValueFromStorage(SESSION_AUTH_TOKEN_STORAGE_KEY || undefined),
17102
+ sessionToken: getValueFromStorage(SESSION_AUTH_TOKEN_STORAGE_KEY) || undefined,
17108
17103
  zdSessionId: getValueFromStorage(ZD_SESSION_STORAGE_KEY) || undefined,
17109
17104
  zdPreviousTags: getValueFromStorage(ZD_PREVIOUS_TAGS_STORAGE_KEY) || undefined,
17110
17105
  zdMessagingExternalUserId: getValueFromStorage(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY) || null,
@@ -17238,7 +17233,7 @@ function trackEventImpl(adaSettings, chatterToken, params) {
17238
17233
  const baseApiUrl = getURL({
17239
17234
  name: "api",
17240
17235
  handle,
17241
- cluster,
17236
+ cluster: cluster,
17242
17237
  domain
17243
17238
  });
17244
17239
 
@@ -17267,14 +17262,12 @@ function trackEventImpl(adaSettings, chatterToken, params) {
17267
17262
  })
17268
17263
  });
17269
17264
  }
17270
- const getEventsToTrigger = businessEvents => {
17271
- /**
17272
- * return all events that have ANY of their conditions met
17273
- * we may change this in the future
17274
- */
17275
- const eventsToTrigger = businessEvents.filter(businessEvent => businessEvent.trigger_conditions.some(triggerCondition => evalTriggerCondition(triggerCondition)));
17276
- return eventsToTrigger;
17277
- };
17265
+ const getEventsToTrigger = businessEvents =>
17266
+ /**
17267
+ * return all events that have ANY of their conditions met
17268
+ * we may change this in the future
17269
+ */
17270
+ businessEvents.filter(businessEvent => businessEvent.trigger_conditions.some(triggerCondition => evalTriggerCondition(triggerCondition)));
17278
17271
  ;// CONCATENATED MODULE: ./src/common/types/languages.ts
17279
17272
  const Languages = {
17280
17273
  en: "en",
@@ -17564,7 +17557,7 @@ function triggerCampaignImpl(_ref) {
17564
17557
  name: "api",
17565
17558
  route: "campaigns/trigger/".concat(campaign.campaign_key),
17566
17559
  handle,
17567
- cluster,
17560
+ cluster: cluster,
17568
17561
  domain
17569
17562
  }); // eslint-disable-next-line @typescript-eslint/ban-types
17570
17563
 
@@ -17622,25 +17615,23 @@ const popStateListener = dispatchEvent.bind(undefined, "locationchange");
17622
17615
  */
17623
17616
 
17624
17617
  function bindLocationChangeOverrides() {
17625
- window.history.pushState = (f => // eslint-disable-next-line @typescript-eslint/no-explicit-any
17626
- function pushState() {
17618
+ window.history.pushState = (f => function pushState() {
17627
17619
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
17628
17620
  args[_key] = arguments[_key];
17629
17621
  }
17630
17622
 
17631
- const ret = f.apply(this, args);
17623
+ const ret = f.apply(window.history, args);
17632
17624
  dispatchEvent("pushstate");
17633
17625
  dispatchEvent("locationchange");
17634
17626
  return ret;
17635
17627
  })(window.history.pushState);
17636
17628
 
17637
- window.history.replaceState = (f => // eslint-disable-next-line @typescript-eslint/no-explicit-any
17638
- function replaceState() {
17629
+ window.history.replaceState = (f => function replaceState() {
17639
17630
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
17640
17631
  args[_key2] = arguments[_key2];
17641
17632
  }
17642
17633
 
17643
- const ret = f.apply(this, args);
17634
+ const ret = f.apply(window.history, args);
17644
17635
  dispatchEvent("replacestate");
17645
17636
  dispatchEvent("locationchange");
17646
17637
  return ret;
@@ -18195,9 +18186,9 @@ async function log(message, extra, options) {
18195
18186
  service: "embed",
18196
18187
  env: "production",
18197
18188
  embedVersion: 2,
18198
- version: "1.4.19",
18189
+ version: "1.4.20",
18199
18190
  isNpm: true,
18200
- commitHash: "64c182e"
18191
+ commitHash: "16915e5"
18201
18192
  }))
18202
18193
  });
18203
18194
  }
@@ -18531,10 +18522,10 @@ class ButtonFrame extends d {
18531
18522
  }
18532
18523
 
18533
18524
  get styles() {
18525
+ var _client$ui_settings, _client$ui_settings$e;
18526
+
18534
18527
  const {
18535
18528
  client,
18536
- buttonSize,
18537
- buttonStyle,
18538
18529
  frameWidth,
18539
18530
  adaSettings
18540
18531
  } = this.props;
@@ -18543,6 +18534,8 @@ class ButtonFrame extends d {
18543
18534
  return "";
18544
18535
  }
18545
18536
 
18537
+ const buttonSize = client.chat_button.size;
18538
+ const buttonStyle = (_client$ui_settings = client.ui_settings) === null || _client$ui_settings === void 0 ? void 0 : (_client$ui_settings$e = _client$ui_settings.embed) === null || _client$ui_settings$e === void 0 ? void 0 : _client$ui_settings$e.style;
18546
18539
  const {
18547
18540
  delayedIsShown
18548
18541
  } = this.state; // 48 = (SHADOW BLUR=40) + (2 * SPREAD=8)
@@ -18607,15 +18600,11 @@ class ButtonFrame extends d {
18607
18600
  }
18608
18601
 
18609
18602
  function ButtonFrame_mapStateToProps(storeState) {
18610
- var _client$chat_button, _client$ui_settings, _client$ui_settings$e;
18611
-
18612
18603
  const {
18613
18604
  client,
18614
18605
  isDrawerOpen
18615
18606
  } = storeState;
18616
18607
  return {
18617
- buttonSize: client === null || client === void 0 ? void 0 : (_client$chat_button = client.chat_button) === null || _client$chat_button === void 0 ? void 0 : _client$chat_button.size,
18618
- buttonStyle: client === null || client === void 0 ? void 0 : (_client$ui_settings = client.ui_settings) === null || _client$ui_settings === void 0 ? void 0 : (_client$ui_settings$e = _client$ui_settings.embed) === null || _client$ui_settings$e === void 0 ? void 0 : _client$ui_settings$e.style,
18619
18608
  client,
18620
18609
  isDrawerOpen
18621
18610
  };
@@ -18772,7 +18761,7 @@ class ChatFrame extends d {
18772
18761
  const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
18773
18762
  const smsToken = hostPageUrlParams.get("adaSMSToken");
18774
18763
  const queryParams = {
18775
- embedVersion: "64c182e".slice(0, 7),
18764
+ embedVersion: "16915e5".slice(0, 7),
18776
18765
  greeting,
18777
18766
  language,
18778
18767
  skipGreeting,
@@ -18846,7 +18835,7 @@ class ChatFrame extends d {
18846
18835
  adaSettings
18847
18836
  } = this.props;
18848
18837
 
18849
- if (!(client !== null && client !== void 0 && client.chat_button)) {
18838
+ if (!client) {
18850
18839
  return "";
18851
18840
  } // delta is used to determine how much of the button's height should be ignored
18852
18841
  // when spacing the proactive message
@@ -19466,14 +19455,19 @@ class IntroFrame extends d {
19466
19455
  get styles() {
19467
19456
  const {
19468
19457
  client,
19469
- buttonSize,
19470
19458
  introDimensions,
19471
19459
  adaSettings
19472
19460
  } = this.props;
19461
+
19462
+ if (!client) {
19463
+ return "display: none";
19464
+ }
19465
+
19466
+ const buttonSize = client.chat_button.size;
19473
19467
  const INTRO_BUTTON_PADDING = 16;
19474
19468
  const introPositionRight = INTRO_BUTTON_PADDING + buttonSize;
19475
19469
  const stylesForHiding = "\n visibility: \"hidden\";\n top: -9999px !important;\n left: -9999px !important;\n ";
19476
- const styles = "\n position: fixed;\n ".concat(getAlignment(adaSettings), ": ").concat(introPositionRight, "px;\n bottom: 8px;\n z-index: 10000;\n max-height: 300px;\n max-width: 250px;\n opacity: ").concat(this.isShown ? "1" : "0", ";\n height: ").concat(introDimensions.height, "px;\n width: ").concat(introDimensions.width, "px;\n\n ").concat(Boolean(client === null || client === void 0 ? void 0 : client.features.chat_ui_v2) && "\n max-height: auto;\n max-width: 350px;\n z-index: 9999;\n ".concat(getAlignment(adaSettings), ": 0;\n bottom: ").concat(buttonSize - 20, "px;\n "), "\n ");
19470
+ const styles = "\n position: fixed;\n ".concat(getAlignment(adaSettings), ": ").concat(introPositionRight, "px;\n bottom: 8px;\n z-index: 10000;\n max-height: 300px;\n max-width: 250px;\n opacity: ").concat(this.isShown ? "1" : "0", ";\n height: ").concat(introDimensions.height, "px;\n width: ").concat(introDimensions.width, "px;\n\n ").concat(Boolean(client.features.chat_ui_v2) && "\n max-height: auto;\n max-width: 350px;\n z-index: 9999;\n ".concat(getAlignment(adaSettings), ": 0;\n bottom: ").concat(buttonSize - 20, "px;\n "), "\n ");
19477
19471
 
19478
19472
  if (!this.isShown) {
19479
19473
  return styles + stylesForHiding;
@@ -19494,8 +19488,6 @@ class IntroFrame extends d {
19494
19488
  }
19495
19489
 
19496
19490
  function IntroFrame_mapStateToProps(storeState) {
19497
- var _client$chat_button;
19498
-
19499
19491
  const {
19500
19492
  client,
19501
19493
  introDimensions,
@@ -19505,7 +19497,6 @@ function IntroFrame_mapStateToProps(storeState) {
19505
19497
  } = storeState;
19506
19498
  return {
19507
19499
  client,
19508
- buttonSize: client === null || client === void 0 ? void 0 : (_client$chat_button = client.chat_button) === null || _client$chat_button === void 0 ? void 0 : _client$chat_button.size,
19509
19500
  introDimensions,
19510
19501
  isIntroShown,
19511
19502
  isDrawerOpen,
@@ -19807,8 +19798,8 @@ class Container extends d {
19807
19798
  adaSettings,
19808
19799
  chatterToken,
19809
19800
  campaign: campaignToTrigger,
19810
- ignoreStatus: campaignTriggerOptions.ignoreStatus,
19811
- ignoreFrequency: campaignTriggerOptions.ignoreFrequency,
19801
+ ignoreStatus: Boolean(campaignTriggerOptions.ignoreStatus),
19802
+ ignoreFrequency: Boolean(campaignTriggerOptions.ignoreFrequency),
19812
19803
  clearCampaignToTrigger: () => this.setState({
19813
19804
  campaignToTrigger: null
19814
19805
  }),
@@ -19922,7 +19913,7 @@ class Container extends d {
19922
19913
  const buttonText = getButtonText(client); // create an element with the button text
19923
19914
 
19924
19915
  const dummyTextElement = document.createElement("span");
19925
- dummyTextElement.innerText = buttonText;
19916
+ dummyTextElement.innerText = buttonText || "";
19926
19917
  entryContainer.appendChild(dummyTextElement);
19927
19918
  const textButtonWidth = dummyTextElement.getBoundingClientRect().width; // compute width
19928
19919
 
@@ -19965,6 +19956,10 @@ class Container extends d {
19965
19956
  return;
19966
19957
  }
19967
19958
 
19959
+ if (!client.business_events) {
19960
+ return;
19961
+ }
19962
+
19968
19963
  const eventsToTrigger = getEventsToTrigger(client.business_events);
19969
19964
  eventsToTrigger.forEach(businessEvent => {
19970
19965
  this.trackEvent({
@@ -20028,6 +20023,11 @@ class Container extends d {
20028
20023
  adaSettings,
20029
20024
  client
20030
20025
  } = this.props;
20026
+
20027
+ if (!client) {
20028
+ throw new AdaEmbedError("`client` is not defined");
20029
+ }
20030
+
20031
20031
  const campaignToTrigger = getCampaignToTrigger(adaSettings, client.marketing_campaigns, params, !client.features.afm_proactive_messaging);
20032
20032
 
20033
20033
  if (campaignToTrigger) {
@@ -20086,6 +20086,10 @@ class Container extends d {
20086
20086
  switch (type) {
20087
20087
  case TRACK_EVENT:
20088
20088
  {
20089
+ if (!client) {
20090
+ throw new AdaEmbedError("`client` is not defined");
20091
+ }
20092
+
20089
20093
  if (!client.features.afm_business_events) {
20090
20094
  console.error("Ada Embed - business events not available in your feature set.");
20091
20095
  } else {
@@ -20098,6 +20102,10 @@ class Container extends d {
20098
20102
 
20099
20103
  case TRIGGER_CAMPAIGN:
20100
20104
  {
20105
+ if (!client) {
20106
+ throw new AdaEmbedError("`client` is not defined");
20107
+ }
20108
+
20101
20109
  if (!client.features.afm_proactive_messaging) {
20102
20110
  console.error("Ada Embed - proactive campaigns not available in your feature set.");
20103
20111
  } else {
@@ -20110,6 +20118,10 @@ class Container extends d {
20110
20118
 
20111
20119
  case EVAL_CAMPAIGN_CONDITIONS:
20112
20120
  {
20121
+ if (!client) {
20122
+ throw new AdaEmbedError("`client` is not defined");
20123
+ }
20124
+
20113
20125
  if (!client.features.afm_proactive_messaging) {
20114
20126
  console.error("Ada Embed - proactive campaigns not available in your feature set.");
20115
20127
  } else {
@@ -20279,18 +20291,17 @@ class Container extends d {
20279
20291
 
20280
20292
  case CREATE_PROACTIVE:
20281
20293
  {
20294
+ if (!client) {
20295
+ throw new AdaEmbedError("`client` is not defined");
20296
+ }
20297
+
20282
20298
  const {
20283
20299
  body,
20284
20300
  duration
20285
20301
  } = payload;
20286
- const EXTRA_PROACTIVE_DELAY = 1000;
20287
-
20288
- if (!client) {
20289
- throw new AdaEmbedError("`client` is not defined");
20290
- } // Do not feature flag gate this behind the developer_proactive flag
20302
+ const EXTRA_PROACTIVE_DELAY = 1000; // Do not feature flag gate this behind the developer_proactive flag
20291
20303
  // It's also used for free-tier campaigns, which are available to all clients
20292
20304
 
20293
-
20294
20305
  this.setState({
20295
20306
  hideIntroOverride: true
20296
20307
  }, async () => {
@@ -20315,7 +20326,7 @@ class Container extends d {
20315
20326
  hideIntroOverride: false
20316
20327
  });
20317
20328
  });
20318
- await wait(duration * 1000 + EXTRA_PROACTIVE_DELAY);
20329
+ await wait((duration || 0) * 1000 + EXTRA_PROACTIVE_DELAY);
20319
20330
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, null, id);
20320
20331
  break;
20321
20332
  }
@@ -20422,7 +20433,7 @@ class Container extends d {
20422
20433
  const baseApiUrl = getURL({
20423
20434
  name: "api",
20424
20435
  handle,
20425
- cluster,
20436
+ cluster: cluster,
20426
20437
  domain
20427
20438
  }); // fetch business events if they're not part of the cached client
20428
20439
 
@@ -20454,7 +20465,11 @@ class Container extends d {
20454
20465
 
20455
20466
 
20456
20467
  if (newClient.marketing_campaigns_order) {
20457
- newClient.marketing_campaigns = newClient.marketing_campaigns_order.map(campaignId => newClient.marketing_campaigns.find(c => c._id === campaignId)) // remove undefined campaigns, shouldn't happen but just in case
20468
+ newClient.marketing_campaigns = newClient.marketing_campaigns_order.map(campaignId => {
20469
+ var _newClient$marketing_;
20470
+
20471
+ return (_newClient$marketing_ = newClient.marketing_campaigns) === null || _newClient$marketing_ === void 0 ? void 0 : _newClient$marketing_.find(c => c._id === campaignId);
20472
+ }) // remove undefined campaigns, shouldn't happen but just in case
20458
20473
  // for example this happened once when we manually deleted a malformed campaign from the db
20459
20474
  .filter(campaign => Boolean(campaign));
20460
20475
  }
@@ -20494,7 +20509,10 @@ class Container extends d {
20494
20509
  chatterInLiveChat
20495
20510
  }));
20496
20511
  } catch (e) {
20497
- error_tracker.trackException(e);
20512
+ if (e instanceof Error) {
20513
+ error_tracker.trackException(e);
20514
+ }
20515
+
20498
20516
  this.unmount();
20499
20517
  }
20500
20518
  }
@@ -20958,7 +20976,7 @@ class Embed {
20958
20976
 
20959
20977
  }
20960
20978
 
20961
- _defineProperty(Embed, "embed2Version", "64c182e");
20979
+ _defineProperty(Embed, "embed2Version", "16915e5");
20962
20980
  ;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
20963
20981
 
20964
20982
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.4.19",
3
+ "version": "1.4.20",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",
@@ -11,7 +11,7 @@
11
11
  "build": "TS_NODE_PROJECT=wp.tsconfig.json NODE_ENV=production npx webpack --config webpack.prod.ts",
12
12
  "build:npm-types": "tsc --project tsconfig.npm.json --declaration --outDir dist/npm-entry --emitDeclarationOnly --allowJs false --checkJs false",
13
13
  "build:npm": "./npm-build.sh",
14
- "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 22",
14
+ "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 17",
15
15
  "lint:fix": "yarn lint --fix",
16
16
  "test": "jest --detectOpenHandles",
17
17
  "check-types": "./node_modules/typescript/bin/tsc --project ./tsconfig.json --noEmit --strict false",