@ada-support/embed2 1.7.26 → 1.7.29

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,4 +1,4 @@
1
- import type { CampaignParams, ResetParams, StartOptions, WindowInfo } from "@ada-support/embed-types";
1
+ import type { CampaignParams, ResetParams, StartOptions, TriggerProactiveParams, 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";
@@ -20,5 +20,6 @@ export declare function createEmbed(adaSettings: StartOptions): {
20
20
  readonly createProactive: (body: string, duration: number, responseId?: string) => Promise<void>;
21
21
  readonly closeCampaign: () => Promise<void>;
22
22
  readonly setDeviceToken: (token: string) => Promise<void>;
23
+ readonly triggerProactive: (triggerProactiveParams: TriggerProactiveParams) => Promise<void>;
23
24
  };
24
25
  export declare type Embed = ReturnType<typeof createEmbed>;
@@ -74,6 +74,8 @@ export declare const CLOSE_CAMPAIGN = "CLOSE_CAMPAIGN";
74
74
  export declare const CLOSE_CAMPAIGN_RESPONSE = "CLOSE_CAMPAIGN_RESPONSE";
75
75
  export declare const SET_DEVICE_TOKEN = "SET_DEVICE_TOKEN";
76
76
  export declare const SET_DEVICE_TOKEN_RESPONSE = "SET_DEVICE_TOKEN_RESPONSE";
77
+ export declare const TRIGGER_PROACTIVE = "TRIGGER_PROACTIVE";
78
+ export declare const TRIGGER_PROACTIVE_RESPONSE = "TRIGGER_PROACTIVE_RESPONSE";
77
79
  export declare const SEND_GREETING = "SEND_GREETING";
78
80
  /**
79
81
  * Fetch Event Status
@@ -1,4 +1,4 @@
1
- import type { CampaignParams, ResetParams } from "@ada-support/embed-types";
1
+ import type { CampaignParams, ResetParams, TriggerProactiveParams } from "@ada-support/embed-types";
2
2
  import type { FetchEventStatusType } from "common/constants/events";
3
3
  import type { SendGreetingParams, StoreDispatchPayload, StoreGetPayload, TrackEventParams } from "common/types";
4
4
  import type { AdaCustomEvent, Refhandler } from "common/types/events";
@@ -33,6 +33,7 @@ export interface EmbedRequestPayloadByEvent {
33
33
  SET_LANGUAGE: {
34
34
  language: string;
35
35
  };
36
+ TRIGGER_PROACTIVE: TriggerProactiveParams;
36
37
  }
37
38
  export declare type EmbedRequestEvent = keyof EmbedRequestPayloadByEvent;
38
39
  export interface EmbedResponsePayloadByEvent {
@@ -65,6 +66,7 @@ export interface EmbedResponsePayloadByEvent {
65
66
  "chat_INIT": unknown;
66
67
  "x-storage_INIT": unknown;
67
68
  "SET_DEVICE_TOKEN_RESPONSE": unknown;
69
+ "TRIGGER_PROACTIVE_RESPONSE": unknown;
68
70
  }
69
71
  export declare type EmbedResponseEvent = keyof EmbedResponsePayloadByEvent;
70
72
  export declare type EmbedEvent = EmbedRequestEvent | EmbedResponseEvent;
@@ -2,6 +2,7 @@ import type { BusinessEvent } from "businessEvents/types";
2
2
  import type { ChatButton, ClientResponse, CurrentIntro, Features } from "common/types/http";
3
3
  import type { LanguageKey, LanguageMap } from "common/types/languages";
4
4
  import type { MarketingCampaign } from "src/campaigns/types";
5
+ import type { ProactiveConversations } from "src/proactiveConversations/types";
5
6
  export declare class Client {
6
7
  tint: string;
7
8
  chat: boolean;
@@ -31,6 +32,7 @@ export declare class Client {
31
32
  };
32
33
  };
33
34
  translated_languages: string[];
35
+ proactive_conversations?: ProactiveConversations;
34
36
  [key: string]: unknown;
35
37
  constructor(clientResponse: ClientResponse["client"]);
36
38
  }
@@ -1,5 +1,6 @@
1
1
  import type { BusinessEvent } from "businessEvents/types";
2
2
  import type { LanguageKey } from "common/types/languages";
3
+ import type { ProactiveConversations } from "src/proactiveConversations/types";
3
4
  export interface ChatButton {
4
5
  size: number;
5
6
  background_color: string;
@@ -36,6 +37,7 @@ export interface ClientObject {
36
37
  features: Features;
37
38
  marketing_campaigns_order?: string[];
38
39
  translated_languages: string[];
40
+ proactive_conversations?: ProactiveConversations;
39
41
  [key: string]: unknown;
40
42
  }
41
43
  export interface CachedClientObject {
@@ -54,6 +56,7 @@ export interface CachedClientObject {
54
56
  features: Features;
55
57
  business_events?: BusinessEvent[];
56
58
  marketing_campaigns_order?: string[];
59
+ proactive_conversations?: ProactiveConversations;
57
60
  [key: string]: unknown;
58
61
  }
59
62
  export interface ClientResponse {
@@ -13949,7 +13949,7 @@ const client = new BrowserClient({
13949
13949
  return event;
13950
13950
  },
13951
13951
  environment: "production",
13952
- release: "1.7.26-06c760b",
13952
+ release: "1.7.29-6752092",
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
@@ -14064,6 +14064,8 @@ const CLOSE_CAMPAIGN = "CLOSE_CAMPAIGN";
14064
14064
  const CLOSE_CAMPAIGN_RESPONSE = "CLOSE_CAMPAIGN_RESPONSE";
14065
14065
  const SET_DEVICE_TOKEN = "SET_DEVICE_TOKEN";
14066
14066
  const SET_DEVICE_TOKEN_RESPONSE = "SET_DEVICE_TOKEN_RESPONSE";
14067
+ const TRIGGER_PROACTIVE = "TRIGGER_PROACTIVE";
14068
+ const TRIGGER_PROACTIVE_RESPONSE = "TRIGGER_PROACTIVE_RESPONSE";
14067
14069
 
14068
14070
  // Tells chat to send a greeting
14069
14071
  const SEND_GREETING = "SEND_GREETING";
@@ -14521,7 +14523,7 @@ function getEmbedURL(_ref) {
14521
14523
  } else {
14522
14524
  host = `http://${handle}.localhost:9001`;
14523
14525
  }
14524
- return `${host}/embed/${frameName}/${"06c760b"}/index.html`;
14526
+ return `${host}/embed/${frameName}/${"6752092"}/index.html`;
14525
14527
  }
14526
14528
  function constructQueryString(query) {
14527
14529
  return Object.keys(query).map(key => {
@@ -15615,6 +15617,7 @@ class Client {
15615
15617
  _defineProperty(this, "marketing_campaigns", void 0);
15616
15618
  _defineProperty(this, "ui_settings", void 0);
15617
15619
  _defineProperty(this, "translated_languages", void 0);
15620
+ _defineProperty(this, "proactive_conversations", void 0);
15618
15621
  const {
15619
15622
  chat,
15620
15623
  chat_button: chatButton,
@@ -15699,9 +15702,9 @@ async function log(message, extra, options) {
15699
15702
  service: "embed",
15700
15703
  env: "production",
15701
15704
  embedVersion: 2,
15702
- version: "1.7.26",
15705
+ version: "1.7.29",
15703
15706
  isNpm: true,
15704
- commitHash: "06c760b"
15707
+ commitHash: "6752092"
15705
15708
  }))
15706
15709
  });
15707
15710
  }
@@ -15875,8 +15878,12 @@ async function fetchClientUsingAlternativeBotRollout(primaryBotClientObject, alt
15875
15878
  language
15876
15879
  } = adaSettings;
15877
15880
  if (adaBotHandleOverride) {
15881
+ var _primaryBotClientObje;
15878
15882
  const sanitizedAdaBotHandleOverride = escapeUrlParam(adaBotHandleOverride);
15879
- if (sanitizedAdaBotHandleOverride !== adaBotHandleOverride) {
15883
+
15884
+ // Only allow overriding to primary or alternative bot
15885
+ const isAllowedBot = sanitizedAdaBotHandleOverride === primaryBotClientObject.handle || sanitizedAdaBotHandleOverride === ((_primaryBotClientObje = primaryBotClientObject.alternative_bot) === null || _primaryBotClientObje === void 0 ? void 0 : _primaryBotClientObje.handle);
15886
+ if (!isAllowedBot) {
15880
15887
  return primaryBotClientObject;
15881
15888
  }
15882
15889
  const overrideBotClientObject = await fetchClient(sanitizedAdaBotHandleOverride, cluster, domain, language || get_browser_language());
@@ -16744,7 +16751,7 @@ class ChatFrame extends d {
16744
16751
  const hostPageUrlParams = new URL(window.location.href).searchParams;
16745
16752
  const smsToken = hostPageUrlParams.get("adaSMSToken");
16746
16753
  const queryParams = {
16747
- embedVersion: "06c760b".slice(0, 7),
16754
+ embedVersion: "6752092".slice(0, 7),
16748
16755
  greeting,
16749
16756
  language,
16750
16757
  skipGreeting,
@@ -18238,6 +18245,25 @@ class Container extends d {
18238
18245
  this.handleSettingDeviceToken(localChannel, payload, id);
18239
18246
  break;
18240
18247
  }
18248
+ case TRIGGER_PROACTIVE:
18249
+ {
18250
+ var _client$proactive_con;
18251
+ if (!client) {
18252
+ throw new AdaEmbedError("`client` is not defined");
18253
+ }
18254
+ const language = adaSettings.language || get_browser_language();
18255
+ const {
18256
+ messageKey
18257
+ } = payload;
18258
+ if ((_client$proactive_con = client.proactive_conversations) !== null && _client$proactive_con !== void 0 && _client$proactive_con[messageKey]) {
18259
+ // eslint-disable-next-line no-console
18260
+ console.log("Proactive message: ", client.proactive_conversations[messageKey].messages[language]);
18261
+ } else {
18262
+ // eslint-disable-next-line no-console
18263
+ console.log("Proactive message not found");
18264
+ }
18265
+ break;
18266
+ }
18241
18267
  default:
18242
18268
  {
18243
18269
  // Do nothing
@@ -18776,6 +18802,10 @@ function createEmbed(adaSettings) {
18776
18802
  await localChannel.fetch(SET_DEVICE_TOKEN, SET_DEVICE_TOKEN_RESPONSE, {
18777
18803
  token
18778
18804
  });
18805
+ },
18806
+ async triggerProactive(triggerProactiveParams) {
18807
+ await initialized;
18808
+ await localChannel.fetch(TRIGGER_PROACTIVE, TRIGGER_PROACTIVE_RESPONSE, triggerProactiveParams);
18779
18809
  }
18780
18810
  };
18781
18811
  }
@@ -18943,6 +18973,12 @@ function createEmbedInterface() {
18943
18973
  channel.postMessage("TRIGGER_ANSWER", {
18944
18974
  answerId
18945
18975
  });
18976
+ },
18977
+ triggerProactive: triggerProactiveParams => {
18978
+ if (!embed) {
18979
+ throw EMBED_NOT_INITIALIZED_ERROR;
18980
+ }
18981
+ return embed.triggerProactive(triggerProactiveParams);
18946
18982
  }
18947
18983
  });
18948
18984
  }
@@ -0,0 +1,16 @@
1
+ export interface ProactiveConversations {
2
+ [messageKey: string]: {
3
+ messages: {
4
+ [language: string]: string[];
5
+ };
6
+ modality_config: {
7
+ [modality: string]: {
8
+ active: boolean;
9
+ url_trigger_conditions: string[];
10
+ delay: number;
11
+ duration: number;
12
+ frequency: string;
13
+ };
14
+ };
15
+ };
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.7.26",
3
+ "version": "1.7.29",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index-npm.d.ts",
@@ -60,6 +60,7 @@
60
60
  "enzyme": "^3.11.0",
61
61
  "enzyme-adapter-preact-pure": "^4.0.1",
62
62
  "eslint": "^8.8.0",
63
+ "eslint-config-prettier": "^8.5.0",
63
64
  "eslint-plugin-chai-friendly": "^0.7.2",
64
65
  "eslint-plugin-compat": "^4.0.2",
65
66
  "eslint-plugin-cypress": "^2.12.1",
@@ -78,7 +79,7 @@
78
79
  "webpack-dev-server": "^4.3.1"
79
80
  },
80
81
  "dependencies": {
81
- "@ada-support/embed-types": "^1.7.1",
82
+ "@ada-support/embed-types": "^1.8.0",
82
83
  "@ada-support/web-storage": "^1.2.6",
83
84
  "@babel/core": "^7.23.2",
84
85
  "@babel/plugin-proposal-class-properties": "^7.16.7",
@@ -95,7 +96,6 @@
95
96
  "babel-loader": "9.1.2",
96
97
  "babel-preset-preact": "^2.0.0",
97
98
  "dotenv": "^8.2.0",
98
- "eslint-config-prettier": "^8.5.0",
99
99
  "focus-visible": "^5.2.0",
100
100
  "html-webpack-plugin": "^5.5.0",
101
101
  "json-stable-stringify": "^1.0.1",
@@ -105,7 +105,7 @@
105
105
  "typescript": "^4.6.2",
106
106
  "uniqid": "^5.3.0",
107
107
  "webpack": "^5.76.0",
108
- "webpack-cli": "^4.9.2",
108
+ "webpack-cli": "^5.1.4",
109
109
  "webpack-merge": "^5.8.0"
110
110
  },
111
111
  "resolutions": {