@ada-support/embed2 1.14.5 → 1.14.6

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.
@@ -10,6 +10,15 @@ export interface EmbedRequestPayloadByEvent {
10
10
  duration: number | null;
11
11
  delay?: number;
12
12
  responseId?: string | null;
13
+ image?: {
14
+ url: string;
15
+ alt: string;
16
+ };
17
+ cta?: {
18
+ label: string;
19
+ url: string;
20
+ openInNewTab: boolean;
21
+ };
13
22
  };
14
23
  DELETE_HISTORY: undefined;
15
24
  DISPATCH: StoreDispatchPayload;
@@ -13,6 +13,15 @@ export interface CurrentIntro {
13
13
  style: string;
14
14
  duration: number | null;
15
15
  delay: number;
16
+ image?: {
17
+ url: string;
18
+ alt: string;
19
+ };
20
+ cta?: {
21
+ label: string;
22
+ url: string;
23
+ openInNewTab: boolean;
24
+ };
16
25
  }
17
26
  export interface Features {
18
27
  "ui_customization"?: boolean;
@@ -16125,7 +16125,7 @@ const client = new BrowserClient({
16125
16125
  return event;
16126
16126
  },
16127
16127
  environment: "production",
16128
- release: "1.14.5-b0ec618",
16128
+ release: "1.14.6-f90a8e1",
16129
16129
  sampleRate: 0.25,
16130
16130
  autoSessionTracking: false,
16131
16131
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -16751,7 +16751,7 @@ function getEmbedURL(_ref) {
16751
16751
  } else {
16752
16752
  host = `http://${handle}.localhost:${ports.localhost.default}`;
16753
16753
  }
16754
- return `${host}/embed/${frameName}/${"b0ec618"}/index.html`;
16754
+ return `${host}/embed/${frameName}/${"f90a8e1"}/index.html`;
16755
16755
  }
16756
16756
  function constructQueryString(query) {
16757
16757
  return Object.keys(query).map(key => {
@@ -17538,9 +17538,9 @@ async function log(message, extra, options) {
17538
17538
  service: "embed",
17539
17539
  env: "production",
17540
17540
  embedVersion: 2,
17541
- version: "1.14.5",
17541
+ version: "1.14.6",
17542
17542
  isNpm: true,
17543
- commitHash: "b0ec618"
17543
+ commitHash: "f90a8e1"
17544
17544
  }))
17545
17545
  });
17546
17546
  }
@@ -18705,6 +18705,32 @@ function recordProactiveTrigger(proactiveConversationKey, frequency, handle) {
18705
18705
  break;
18706
18706
  }
18707
18707
  }
18708
+
18709
+ // Rich content (image + single CTA) is optional. The image is keyed by
18710
+ // language; fall back to the first language by sorted key (the URL is shared
18711
+ // across languages — only the alt text is translated — so the fallback is
18712
+ // deterministic rather than relying on object key order).
18713
+ function extractRichContent(proactiveConversation, language) {
18714
+ var _images$language, _images$fallbackLangu;
18715
+ const {
18716
+ images,
18717
+ ctas
18718
+ } = proactiveConversation;
18719
+ const fallbackLanguage = images ? Object.keys(images).sort()[0] : undefined;
18720
+ const imageConfig = (images === null || images === void 0 ? void 0 : (_images$language = images[language]) === null || _images$language === void 0 ? void 0 : _images$language[0]) ?? (fallbackLanguage ? images === null || images === void 0 ? void 0 : (_images$fallbackLangu = images[fallbackLanguage]) === null || _images$fallbackLangu === void 0 ? void 0 : _images$fallbackLangu[0] : undefined);
18721
+ const ctaConfig = ctas === null || ctas === void 0 ? void 0 : ctas[0];
18722
+ return {
18723
+ image: imageConfig ? {
18724
+ url: imageConfig.url,
18725
+ alt: imageConfig.alt
18726
+ } : undefined,
18727
+ cta: ctaConfig ? {
18728
+ label: ctaConfig.cta_label,
18729
+ url: ctaConfig.cta_url,
18730
+ openInNewTab: ctaConfig.cta_open_in_new_tab
18731
+ } : undefined
18732
+ };
18733
+ }
18708
18734
  function proactiveTriggerImpl(_ref) {
18709
18735
  let {
18710
18736
  proactiveConversation,
@@ -18768,12 +18794,18 @@ function proactiveTriggerImpl(_ref) {
18768
18794
  key: messageKey,
18769
18795
  params
18770
18796
  });
18797
+ const {
18798
+ image,
18799
+ cta
18800
+ } = extractRichContent(proactiveConversation, language);
18771
18801
  clearProactiveConversation();
18772
18802
  const localChannel = messageService.getChannel("local");
18773
18803
  localChannel.postMessage(CREATE_PROACTIVE, {
18774
18804
  body: proactiveMessage,
18775
18805
  duration,
18776
- delay
18806
+ delay,
18807
+ image,
18808
+ cta
18777
18809
  });
18778
18810
  log("Proactive message displayed", {
18779
18811
  handle,
@@ -20174,7 +20206,7 @@ class ChatFrame extends d {
20174
20206
  log("Chat frame mount", {
20175
20207
  handle,
20176
20208
  chatUrl: this.url,
20177
- embedVersion: "b0ec618".slice(0, 7),
20209
+ embedVersion: "f90a8e1".slice(0, 7),
20178
20210
  embedSettings: adaSettings
20179
20211
  });
20180
20212
 
@@ -20262,7 +20294,7 @@ class ChatFrame extends d {
20262
20294
  const hostPageUrlParams = new URL(window.location.href).searchParams;
20263
20295
  const smsToken = hostPageUrlParams.get("adaSMSToken");
20264
20296
  const queryParams = {
20265
- embedVersion: "b0ec618".slice(0, 7),
20297
+ embedVersion: "f90a8e1".slice(0, 7),
20266
20298
  greeting,
20267
20299
  language,
20268
20300
  skipGreeting,
@@ -21084,8 +21116,6 @@ class IntroFrame extends d {
21084
21116
  return `display: none`;
21085
21117
  }
21086
21118
  const buttonSize = client.chat_button.size;
21087
- const INTRO_BUTTON_PADDING = 16;
21088
- const introPositionRight = INTRO_BUTTON_PADDING + buttonSize;
21089
21119
  const stylesForHiding = `
21090
21120
  visibility: "hidden";
21091
21121
  top: -9999px !important;
@@ -21093,19 +21123,14 @@ class IntroFrame extends d {
21093
21123
  `;
21094
21124
  const styles = `
21095
21125
  position: fixed;
21096
- ${getAlignment(adaSettings)}: ${introPositionRight}px;
21097
- bottom: 8px;
21098
- z-index: 10000;
21099
- max-height: 300px;
21100
- max-width: 250px;
21126
+ ${getAlignment(adaSettings)}: 0;
21127
+ bottom: ${buttonSize - 20}px;
21128
+ z-index: 9999;
21129
+ max-width: 350px;
21101
21130
  opacity: ${this.isShown ? "1" : "0"};
21102
21131
  height: ${introDimensions.height}px;
21103
21132
  width: ${introDimensions.width}px;
21104
- max-height: auto;
21105
- max-width: 350px;
21106
- z-index: 9999;
21107
- ${getAlignment(adaSettings)}: 0;
21108
- bottom: ${buttonSize - 20}px;
21133
+ transition: height 300ms ease;
21109
21134
  `;
21110
21135
  if (!this.isShown) {
21111
21136
  return styles + stylesForHiding;
@@ -22025,7 +22050,9 @@ class Container extends d {
22025
22050
  const {
22026
22051
  body,
22027
22052
  duration,
22028
- delay
22053
+ delay,
22054
+ image,
22055
+ cta
22029
22056
  } = payload;
22030
22057
  const EXTRA_PROACTIVE_DELAY = 1000;
22031
22058
  this.setState({
@@ -22041,7 +22068,9 @@ class Container extends d {
22041
22068
  // Not just duration || null because we want to preserve 0 duration
22042
22069
  duration: duration || duration === 0 ? duration : null,
22043
22070
  style: "Text",
22044
- response_id: ""
22071
+ response_id: "",
22072
+ image,
22073
+ cta
22045
22074
  }
22046
22075
  }));
22047
22076
  await setGlobalState({
@@ -1,4 +1,13 @@
1
1
  export type ProactiveConversationUrlTriggerConditions = UrlTriggerCondition[] | null;
2
+ export interface ProactiveConversationImage {
3
+ url: string;
4
+ alt: string;
5
+ }
6
+ export interface ProactiveConversationCta {
7
+ cta_label: string;
8
+ cta_url: string;
9
+ cta_open_in_new_tab: boolean;
10
+ }
2
11
  export interface ProactiveConversation {
3
12
  messages: {
4
13
  [language: string]: string[];
@@ -15,6 +24,10 @@ export interface ProactiveConversation {
15
24
  is_template: boolean;
16
25
  params?: Record<string, string>;
17
26
  key?: string;
27
+ images?: {
28
+ [language: string]: ProactiveConversationImage[];
29
+ };
30
+ ctas?: ProactiveConversationCta[];
18
31
  }
19
32
  export interface ProactiveConversations {
20
33
  [messageKey: string]: ProactiveConversation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.14.5",
3
+ "version": "1.14.6",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",