@ada-support/embed2 1.7.31 → 1.7.32

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.
@@ -13949,7 +13949,7 @@ const client = new BrowserClient({
13949
13949
  return event;
13950
13950
  },
13951
13951
  environment: "production",
13952
- release: "1.7.31-645ffae",
13952
+ release: "1.7.32-26543c8",
13953
13953
  sampleRate: 0.25,
13954
13954
  autoSessionTracking: false,
13955
13955
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -14523,7 +14523,7 @@ function getEmbedURL(_ref) {
14523
14523
  } else {
14524
14524
  host = `http://${handle}.localhost:9001`;
14525
14525
  }
14526
- return `${host}/embed/${frameName}/${"645ffae"}/index.html`;
14526
+ return `${host}/embed/${frameName}/${"26543c8"}/index.html`;
14527
14527
  }
14528
14528
  function constructQueryString(query) {
14529
14529
  return Object.keys(query).map(key => {
@@ -15701,9 +15701,9 @@ async function log(message, extra, options) {
15701
15701
  service: "embed",
15702
15702
  env: "production",
15703
15703
  embedVersion: 2,
15704
- version: "1.7.31",
15704
+ version: "1.7.32",
15705
15705
  isNpm: true,
15706
- commitHash: "645ffae"
15706
+ commitHash: "26543c8"
15707
15707
  }))
15708
15708
  });
15709
15709
  }
@@ -16304,6 +16304,22 @@ function proactiveTriggerImpl(_ref) {
16304
16304
  delay
16305
16305
  });
16306
16306
  }
16307
+ function evaluateUrlTriggerConditions(conditions, url) {
16308
+ return conditions.every(condition => {
16309
+ switch (condition.type) {
16310
+ case "equals":
16311
+ return url === condition.value;
16312
+ case "ends-with":
16313
+ return url.endsWith(condition.value);
16314
+ case "regex":
16315
+ return new RegExp(condition.value).test(url);
16316
+ case "contains":
16317
+ return url.includes(condition.value);
16318
+ default:
16319
+ return false;
16320
+ }
16321
+ });
16322
+ }
16307
16323
  ;// CONCATENATED MODULE: ./src/services/chat-versioning/manifest.ts
16308
16324
 
16309
16325
 
@@ -16826,7 +16842,7 @@ class ChatFrame extends d {
16826
16842
  const hostPageUrlParams = new URL(window.location.href).searchParams;
16827
16843
  const smsToken = hostPageUrlParams.get("adaSMSToken");
16828
16844
  const queryParams = {
16829
- embedVersion: "645ffae".slice(0, 7),
16845
+ embedVersion: "26543c8".slice(0, 7),
16830
16846
  greeting,
16831
16847
  language,
16832
16848
  skipGreeting,
@@ -17839,7 +17855,7 @@ class Container extends d {
17839
17855
  messageService
17840
17856
  });
17841
17857
  }
17842
- if (proactiveConversation) {
17858
+ if (proactiveConversation && appConnectionState === ConnectionState.Done) {
17843
17859
  proactiveTriggerImpl({
17844
17860
  proactiveConversation,
17845
17861
  messageKey: proactiveConversation.key,
@@ -17876,6 +17892,7 @@ class Container extends d {
17876
17892
  // Wait for client to be available, then set campaign to trigger
17877
17893
  if (client && !prevProps.client) {
17878
17894
  this.evaluateCampaignConditions({}, true);
17895
+ this.evaluateProactiveConversationConditions();
17879
17896
  }
17880
17897
 
17881
17898
  /**
@@ -18072,6 +18089,28 @@ class Container extends d {
18072
18089
  }
18073
18090
  }
18074
18091
  }
18092
+ evaluateProactiveConversationConditions() {
18093
+ const {
18094
+ client
18095
+ } = this.props;
18096
+ if (!client) {
18097
+ throw new AdaEmbedError("`client` is not defined");
18098
+ }
18099
+ const proactiveConversations = client.proactive_conversations;
18100
+ if (!proactiveConversations) {
18101
+ return;
18102
+ }
18103
+ const currentUrl = window.location.href;
18104
+ Object.entries(proactiveConversations).forEach(_ref => {
18105
+ let [key, conversation] = _ref;
18106
+ const chatConfig = conversation.modality_config.chat;
18107
+ if (chatConfig.active && evaluateUrlTriggerConditions(chatConfig.url_trigger_conditions, currentUrl)) {
18108
+ this.handleProactiveTrigger(Container_objectSpread({
18109
+ key
18110
+ }, conversation));
18111
+ }
18112
+ });
18113
+ }
18075
18114
  async handleSettingDeviceToken(localChannel, payload, id) {
18076
18115
  const {
18077
18116
  setGlobalState,
@@ -18394,6 +18433,7 @@ class Container extends d {
18394
18433
  });
18395
18434
  this.evaluateCampaignConditions({}, true);
18396
18435
  this.evaluateBusinessEventConditions();
18436
+ this.evaluateProactiveConversationConditions();
18397
18437
  });
18398
18438
  });
18399
18439
  }
@@ -1,6 +1,6 @@
1
1
  import type { StartOptions } from "@ada-support/embed-types";
2
2
  import type { MessageService } from "client/lib/message-service";
3
- import type { ProactiveConversation } from "./types";
3
+ import type { ProactiveConversation, UrlTriggerCondition } from "./types";
4
4
  export declare function proactiveTriggerImpl({ proactiveConversation, messageKey, adaSettings, messageService, clearProactiveMessage, }: {
5
5
  proactiveConversation: ProactiveConversation;
6
6
  messageKey: string;
@@ -8,3 +8,4 @@ export declare function proactiveTriggerImpl({ proactiveConversation, messageKey
8
8
  messageService: MessageService;
9
9
  clearProactiveMessage: () => void;
10
10
  }): void;
11
+ export declare function evaluateUrlTriggerConditions(conditions: UrlTriggerCondition[], url: string): boolean;
@@ -5,7 +5,7 @@ export interface ProactiveConversation {
5
5
  modality_config: {
6
6
  [modality: string]: {
7
7
  active: boolean;
8
- url_trigger_conditions: string[];
8
+ url_trigger_conditions: UrlTriggerCondition[];
9
9
  delay: number;
10
10
  duration: number;
11
11
  frequency: ProactiveConversationFrequency;
@@ -17,3 +17,8 @@ export interface ProactiveConversations {
17
17
  [messageKey: string]: ProactiveConversation;
18
18
  }
19
19
  export declare type ProactiveConversationFrequency = "always" | "session";
20
+ export declare type ProactiveConversationUrlTriggerConditionType = "equals" | "ends-with" | "regex" | "contains";
21
+ export interface UrlTriggerCondition {
22
+ type: ProactiveConversationUrlTriggerConditionType;
23
+ value: string;
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.7.31",
3
+ "version": "1.7.32",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",