@ada-support/embed2 1.14.7 → 1.14.9
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/index.js
CHANGED
|
@@ -16125,7 +16125,7 @@ const client = new BrowserClient({
|
|
|
16125
16125
|
return event;
|
|
16126
16126
|
},
|
|
16127
16127
|
environment: "production",
|
|
16128
|
-
release: "1.14.
|
|
16128
|
+
release: "1.14.9-791d3a3",
|
|
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}/${"
|
|
16754
|
+
return `${host}/embed/${frameName}/${"791d3a3"}/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.
|
|
17541
|
+
version: "1.14.9",
|
|
17542
17542
|
isNpm: true,
|
|
17543
|
-
commitHash: "
|
|
17543
|
+
commitHash: "791d3a3"
|
|
17544
17544
|
}))
|
|
17545
17545
|
});
|
|
17546
17546
|
}
|
|
@@ -18713,6 +18713,16 @@ function isWithinSchedule(scheduleStart, scheduleEnd) {
|
|
|
18713
18713
|
}
|
|
18714
18714
|
return true;
|
|
18715
18715
|
}
|
|
18716
|
+
|
|
18717
|
+
// When several active proactives match the same URL, only the highest priority
|
|
18718
|
+
// fires: the lowest `order` wins, and any explicit rank beats an unranked one.
|
|
18719
|
+
function pickHighestPriorityMatch(matches) {
|
|
18720
|
+
return [...matches].sort((_ref, _ref2) => {
|
|
18721
|
+
let [, a] = _ref;
|
|
18722
|
+
let [, b] = _ref2;
|
|
18723
|
+
return (a.order ?? Infinity) - (b.order ?? Infinity);
|
|
18724
|
+
})[0];
|
|
18725
|
+
}
|
|
18716
18726
|
function addProactiveToStorageString(oldStorageValue, proactiveConversationId) {
|
|
18717
18727
|
return oldStorageValue ? `${oldStorageValue},${proactiveConversationId}` : proactiveConversationId;
|
|
18718
18728
|
}
|
|
@@ -18759,7 +18769,7 @@ function extractRichContent(proactiveConversation, language) {
|
|
|
18759
18769
|
} : undefined
|
|
18760
18770
|
};
|
|
18761
18771
|
}
|
|
18762
|
-
function proactiveTriggerImpl(
|
|
18772
|
+
function proactiveTriggerImpl(_ref3) {
|
|
18763
18773
|
let {
|
|
18764
18774
|
proactiveConversation,
|
|
18765
18775
|
triggerMethod,
|
|
@@ -18768,7 +18778,7 @@ function proactiveTriggerImpl(_ref) {
|
|
|
18768
18778
|
language,
|
|
18769
18779
|
setRecentProactiveConversationConfig,
|
|
18770
18780
|
clearProactiveConversation
|
|
18771
|
-
} =
|
|
18781
|
+
} = _ref3;
|
|
18772
18782
|
const {
|
|
18773
18783
|
handle
|
|
18774
18784
|
} = adaSettings;
|
|
@@ -18854,6 +18864,34 @@ function evaluateUrlTriggerConditions(conditions, url) {
|
|
|
18854
18864
|
}
|
|
18855
18865
|
return evalUrlMatchTriggerCondition(conditions, url);
|
|
18856
18866
|
}
|
|
18867
|
+
|
|
18868
|
+
// The proactives to fire for the current URL, among the active, non-template
|
|
18869
|
+
// ones whose schedule + URL conditions match and that haven't been suppressed
|
|
18870
|
+
// by their frequency this session (filtering frequency here, not just in
|
|
18871
|
+
// `proactiveTriggerImpl`, lets a lower-priority proactive still fire when the
|
|
18872
|
+
// top one has already been shown).
|
|
18873
|
+
//
|
|
18874
|
+
// Prioritization is configured only by clients on the
|
|
18875
|
+
// `proactive-messaging-image-support` flag — the only ones who can rank in the
|
|
18876
|
+
// dashboard. Embed has no flag access, so the presence of an `order` is the
|
|
18877
|
+
// signal: when any match is ranked, only the highest priority (lowest `order`)
|
|
18878
|
+
// fires; otherwise every match fires, the pre-ranking behavior.
|
|
18879
|
+
function selectProactivesToTriggerForUrl(proactiveConversations, url, handle) {
|
|
18880
|
+
const matches = Object.entries(proactiveConversations).filter(_ref4 => {
|
|
18881
|
+
let [key, conversation] = _ref4;
|
|
18882
|
+
const chatConfig = conversation.modality_config.chat;
|
|
18883
|
+
return chatConfig.active && !conversation.is_template && isWithinSchedule(chatConfig.schedule_start, chatConfig.schedule_end) && evaluateUrlTriggerConditions(chatConfig.url_trigger_conditions, url) && !proactiveShownWithinFrequency(key, chatConfig.frequency, handle);
|
|
18884
|
+
});
|
|
18885
|
+
const isRankingConfigured = matches.some(_ref5 => {
|
|
18886
|
+
let [, conversation] = _ref5;
|
|
18887
|
+
return typeof conversation.order === "number";
|
|
18888
|
+
});
|
|
18889
|
+
if (!isRankingConfigured) {
|
|
18890
|
+
return matches;
|
|
18891
|
+
}
|
|
18892
|
+
const top = pickHighestPriorityMatch(matches);
|
|
18893
|
+
return top ? [top] : [];
|
|
18894
|
+
}
|
|
18857
18895
|
;// ./src/services/chat-versioning/manifest.ts
|
|
18858
18896
|
|
|
18859
18897
|
|
|
@@ -20240,7 +20278,7 @@ class ChatFrame extends d {
|
|
|
20240
20278
|
log("Chat frame mount", {
|
|
20241
20279
|
handle,
|
|
20242
20280
|
chatUrl: this.url,
|
|
20243
|
-
embedVersion: "
|
|
20281
|
+
embedVersion: "791d3a3".slice(0, 7),
|
|
20244
20282
|
embedSettings: adaSettings
|
|
20245
20283
|
});
|
|
20246
20284
|
|
|
@@ -20328,7 +20366,7 @@ class ChatFrame extends d {
|
|
|
20328
20366
|
const hostPageUrlParams = new URL(window.location.href).searchParams;
|
|
20329
20367
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
20330
20368
|
const queryParams = {
|
|
20331
|
-
embedVersion: "
|
|
20369
|
+
embedVersion: "791d3a3".slice(0, 7),
|
|
20332
20370
|
greeting,
|
|
20333
20371
|
language,
|
|
20334
20372
|
skipGreeting,
|
|
@@ -21806,7 +21844,8 @@ class Container extends d {
|
|
|
21806
21844
|
}
|
|
21807
21845
|
evaluateProactiveConversationConditions() {
|
|
21808
21846
|
const {
|
|
21809
|
-
client
|
|
21847
|
+
client,
|
|
21848
|
+
adaSettings
|
|
21810
21849
|
} = this.props;
|
|
21811
21850
|
if (!client) {
|
|
21812
21851
|
throw new AdaEmbedError("`client` is not defined");
|
|
@@ -21816,15 +21855,15 @@ class Container extends d {
|
|
|
21816
21855
|
return;
|
|
21817
21856
|
}
|
|
21818
21857
|
const currentUrl = window.location.href;
|
|
21819
|
-
|
|
21858
|
+
|
|
21859
|
+
// When ranking is configured (any matching proactive has an `order`, which
|
|
21860
|
+
// only flag-enabled clients can set), a single highest-priority proactive
|
|
21861
|
+
// fires; otherwise every matching proactive fires.
|
|
21862
|
+
selectProactivesToTriggerForUrl(proactiveConversations, currentUrl, adaSettings.handle).forEach(_ref => {
|
|
21820
21863
|
let [key, conversation] = _ref;
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
this.handleProactiveTrigger(Container_objectSpread({
|
|
21825
|
-
key
|
|
21826
|
-
}, conversation), "url");
|
|
21827
|
-
}
|
|
21864
|
+
this.handleProactiveTrigger(Container_objectSpread({
|
|
21865
|
+
key
|
|
21866
|
+
}, conversation), "url");
|
|
21828
21867
|
});
|
|
21829
21868
|
}
|
|
21830
21869
|
async handleSettingDeviceToken(localChannel, payload, id) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { StartOptions } from "@ada-support/embed-types";
|
|
2
2
|
import type { MessageService } from "client/lib/message-service";
|
|
3
|
-
import type { ProactiveConversation, ProactiveConversationTriggerMethod, ProactiveConversationUrlTriggerConditions, RecentProactiveConversationConfig } from "./types";
|
|
3
|
+
import type { ProactiveConversation, ProactiveConversationTriggerMethod, ProactiveConversationUrlTriggerConditions, ProactiveConversations, RecentProactiveConversationConfig } from "./types";
|
|
4
4
|
export declare function isWithinSchedule(scheduleStart?: string | null, scheduleEnd?: string | null): boolean;
|
|
5
|
+
export declare function pickHighestPriorityMatch(matches: Array<[string, ProactiveConversation]>): [string, ProactiveConversation] | undefined;
|
|
5
6
|
export declare function proactiveTriggerImpl({ proactiveConversation, triggerMethod, adaSettings, messageService, language, setRecentProactiveConversationConfig, clearProactiveConversation, }: {
|
|
6
7
|
proactiveConversation: ProactiveConversation;
|
|
7
8
|
triggerMethod: ProactiveConversationTriggerMethod | null;
|
|
@@ -12,3 +13,4 @@ export declare function proactiveTriggerImpl({ proactiveConversation, triggerMet
|
|
|
12
13
|
clearProactiveConversation: () => void;
|
|
13
14
|
}): void;
|
|
14
15
|
export declare function evaluateUrlTriggerConditions(conditions: ProactiveConversationUrlTriggerConditions, url: string): boolean;
|
|
16
|
+
export declare function selectProactivesToTriggerForUrl(proactiveConversations: ProactiveConversations, url: string, handle: string): Array<[string, ProactiveConversation]>;
|