@ada-support/embed2 1.14.7 → 1.14.10
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.10-df84716",
|
|
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}/${"df84716"}/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.10",
|
|
17542
17542
|
isNpm: true,
|
|
17543
|
-
commitHash: "
|
|
17543
|
+
commitHash: "df84716"
|
|
17544
17544
|
}))
|
|
17545
17545
|
});
|
|
17546
17546
|
}
|
|
@@ -18686,6 +18686,29 @@ function proactiveShownWithinFrequency(proactiveConversationKey, frequency, hand
|
|
|
18686
18686
|
}
|
|
18687
18687
|
}
|
|
18688
18688
|
|
|
18689
|
+
// Ranking advances across visits: once a proactive fires it's remembered so a
|
|
18690
|
+
// later visit surfaces the next-highest priority instead of repeating it. This
|
|
18691
|
+
// "shown" set persists in localStorage (across visits, unlike the per-session
|
|
18692
|
+
// frequency record above) under the same disclosed `proactive_conversations_shown`
|
|
18693
|
+
// key, scoped by handle.
|
|
18694
|
+
function getRankedShownKeys(handle) {
|
|
18695
|
+
const storageValue = dist/* adaLocalStorage */.BB.getFnItem("proactive_conversations_shown");
|
|
18696
|
+
const stored = storageValue ? storageValue[handle] : undefined;
|
|
18697
|
+
return stored ? stored.split(",") : [];
|
|
18698
|
+
}
|
|
18699
|
+
function setRankedShownKeys(handle, keys) {
|
|
18700
|
+
const storageValue = dist/* adaLocalStorage */.BB.getFnItem("proactive_conversations_shown") || {};
|
|
18701
|
+
dist/* adaLocalStorage */.BB.setFnItem("proactive_conversations_shown", proactiveConversation_objectSpread(proactiveConversation_objectSpread({}, storageValue), {}, {
|
|
18702
|
+
[handle]: keys.join(",")
|
|
18703
|
+
}));
|
|
18704
|
+
}
|
|
18705
|
+
function recordRankedShown(handle, proactiveConversationKey) {
|
|
18706
|
+
const keys = getRankedShownKeys(handle);
|
|
18707
|
+
if (!keys.includes(proactiveConversationKey)) {
|
|
18708
|
+
setRankedShownKeys(handle, [...keys, proactiveConversationKey]);
|
|
18709
|
+
}
|
|
18710
|
+
}
|
|
18711
|
+
|
|
18689
18712
|
// A proactive only fires when `now` is within its optional scheduling window.
|
|
18690
18713
|
// Bounds are absolute ISO 8601 UTC instants authored in the dashboard; either
|
|
18691
18714
|
// may be unset for an open-ended window. This mirrors the declarative campaign
|
|
@@ -18713,6 +18736,16 @@ function isWithinSchedule(scheduleStart, scheduleEnd) {
|
|
|
18713
18736
|
}
|
|
18714
18737
|
return true;
|
|
18715
18738
|
}
|
|
18739
|
+
|
|
18740
|
+
// When several active proactives match the same URL, only the highest priority
|
|
18741
|
+
// fires: the lowest `order` wins, and any explicit rank beats an unranked one.
|
|
18742
|
+
function pickHighestPriorityMatch(matches) {
|
|
18743
|
+
return [...matches].sort((_ref, _ref2) => {
|
|
18744
|
+
let [, a] = _ref;
|
|
18745
|
+
let [, b] = _ref2;
|
|
18746
|
+
return (a.order ?? Infinity) - (b.order ?? Infinity);
|
|
18747
|
+
})[0];
|
|
18748
|
+
}
|
|
18716
18749
|
function addProactiveToStorageString(oldStorageValue, proactiveConversationId) {
|
|
18717
18750
|
return oldStorageValue ? `${oldStorageValue},${proactiveConversationId}` : proactiveConversationId;
|
|
18718
18751
|
}
|
|
@@ -18759,7 +18792,7 @@ function extractRichContent(proactiveConversation, language) {
|
|
|
18759
18792
|
} : undefined
|
|
18760
18793
|
};
|
|
18761
18794
|
}
|
|
18762
|
-
function proactiveTriggerImpl(
|
|
18795
|
+
function proactiveTriggerImpl(_ref3) {
|
|
18763
18796
|
let {
|
|
18764
18797
|
proactiveConversation,
|
|
18765
18798
|
triggerMethod,
|
|
@@ -18768,7 +18801,7 @@ function proactiveTriggerImpl(_ref) {
|
|
|
18768
18801
|
language,
|
|
18769
18802
|
setRecentProactiveConversationConfig,
|
|
18770
18803
|
clearProactiveConversation
|
|
18771
|
-
} =
|
|
18804
|
+
} = _ref3;
|
|
18772
18805
|
const {
|
|
18773
18806
|
handle
|
|
18774
18807
|
} = adaSettings;
|
|
@@ -18824,6 +18857,14 @@ function proactiveTriggerImpl(_ref) {
|
|
|
18824
18857
|
|
|
18825
18858
|
// Record the proactive message as being shown
|
|
18826
18859
|
recordProactiveTrigger(messageKey, frequency, handle);
|
|
18860
|
+
|
|
18861
|
+
// Remember URL-triggered shows so ranking advances to the next proactive on
|
|
18862
|
+
// the next visit. Recording every URL trigger (not just ranked ones) is safe:
|
|
18863
|
+
// the unranked fire-all path never reads this set, and the loop-reset in
|
|
18864
|
+
// `selectProactivesToTriggerForUrl` clears any stale keys.
|
|
18865
|
+
if (triggerMethod === "url") {
|
|
18866
|
+
recordRankedShown(handle, messageKey);
|
|
18867
|
+
}
|
|
18827
18868
|
setRecentProactiveConversationConfig({
|
|
18828
18869
|
key: messageKey,
|
|
18829
18870
|
params
|
|
@@ -18854,6 +18895,55 @@ function evaluateUrlTriggerConditions(conditions, url) {
|
|
|
18854
18895
|
}
|
|
18855
18896
|
return evalUrlMatchTriggerCondition(conditions, url);
|
|
18856
18897
|
}
|
|
18898
|
+
|
|
18899
|
+
// The proactives to fire for the current URL, among the active, non-template
|
|
18900
|
+
// ones whose schedule + URL conditions match and that haven't been suppressed
|
|
18901
|
+
// by their frequency this session (filtering frequency here, not just in
|
|
18902
|
+
// `proactiveTriggerImpl`, lets a lower-priority proactive still fire when the
|
|
18903
|
+
// top one has already been shown).
|
|
18904
|
+
//
|
|
18905
|
+
// Prioritization is configured only by clients on the
|
|
18906
|
+
// `proactive-messaging-image-support` flag — the only ones who can rank in the
|
|
18907
|
+
// dashboard. Embed has no flag access, so the presence of an `order` is the
|
|
18908
|
+
// signal: when any match is ranked, exactly one fires and successive visits
|
|
18909
|
+
// advance down the ranking (the highest priority that hasn't been shown yet,
|
|
18910
|
+
// looping back to the top once all have), rather than firing every match — the
|
|
18911
|
+
// pre-ranking behavior kept for unranked clients.
|
|
18912
|
+
function selectProactivesToTriggerForUrl(proactiveConversations, url, handle) {
|
|
18913
|
+
const matches = Object.entries(proactiveConversations).filter(_ref4 => {
|
|
18914
|
+
let [key, conversation] = _ref4;
|
|
18915
|
+
const chatConfig = conversation.modality_config.chat;
|
|
18916
|
+
return chatConfig.active && !conversation.is_template && isWithinSchedule(chatConfig.schedule_start, chatConfig.schedule_end) && evaluateUrlTriggerConditions(chatConfig.url_trigger_conditions, url) && !proactiveShownWithinFrequency(key, chatConfig.frequency, handle);
|
|
18917
|
+
});
|
|
18918
|
+
const isRankingConfigured = matches.some(_ref5 => {
|
|
18919
|
+
let [, conversation] = _ref5;
|
|
18920
|
+
return typeof conversation.order === "number";
|
|
18921
|
+
});
|
|
18922
|
+
if (!isRankingConfigured) {
|
|
18923
|
+
return matches;
|
|
18924
|
+
}
|
|
18925
|
+
|
|
18926
|
+
// Ranking fires one proactive per visit and advances down the list: matches
|
|
18927
|
+
// already shown on previous visits are skipped so the next-highest priority
|
|
18928
|
+
// fires. Once every current match has been shown, clear their records so the
|
|
18929
|
+
// cycle loops back to the top.
|
|
18930
|
+
const shownKeys = getRankedShownKeys(handle);
|
|
18931
|
+
const unshown = matches.filter(_ref6 => {
|
|
18932
|
+
let [key] = _ref6;
|
|
18933
|
+
return !shownKeys.includes(key);
|
|
18934
|
+
});
|
|
18935
|
+
if (unshown.length === 0) {
|
|
18936
|
+
const matchKeys = matches.map(_ref7 => {
|
|
18937
|
+
let [key] = _ref7;
|
|
18938
|
+
return key;
|
|
18939
|
+
});
|
|
18940
|
+
setRankedShownKeys(handle, shownKeys.filter(key => !matchKeys.includes(key)));
|
|
18941
|
+
const top = pickHighestPriorityMatch(matches);
|
|
18942
|
+
return top ? [top] : [];
|
|
18943
|
+
}
|
|
18944
|
+
const top = pickHighestPriorityMatch(unshown);
|
|
18945
|
+
return top ? [top] : [];
|
|
18946
|
+
}
|
|
18857
18947
|
;// ./src/services/chat-versioning/manifest.ts
|
|
18858
18948
|
|
|
18859
18949
|
|
|
@@ -20240,7 +20330,7 @@ class ChatFrame extends d {
|
|
|
20240
20330
|
log("Chat frame mount", {
|
|
20241
20331
|
handle,
|
|
20242
20332
|
chatUrl: this.url,
|
|
20243
|
-
embedVersion: "
|
|
20333
|
+
embedVersion: "df84716".slice(0, 7),
|
|
20244
20334
|
embedSettings: adaSettings
|
|
20245
20335
|
});
|
|
20246
20336
|
|
|
@@ -20328,7 +20418,7 @@ class ChatFrame extends d {
|
|
|
20328
20418
|
const hostPageUrlParams = new URL(window.location.href).searchParams;
|
|
20329
20419
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
20330
20420
|
const queryParams = {
|
|
20331
|
-
embedVersion: "
|
|
20421
|
+
embedVersion: "df84716".slice(0, 7),
|
|
20332
20422
|
greeting,
|
|
20333
20423
|
language,
|
|
20334
20424
|
skipGreeting,
|
|
@@ -21806,7 +21896,8 @@ class Container extends d {
|
|
|
21806
21896
|
}
|
|
21807
21897
|
evaluateProactiveConversationConditions() {
|
|
21808
21898
|
const {
|
|
21809
|
-
client
|
|
21899
|
+
client,
|
|
21900
|
+
adaSettings
|
|
21810
21901
|
} = this.props;
|
|
21811
21902
|
if (!client) {
|
|
21812
21903
|
throw new AdaEmbedError("`client` is not defined");
|
|
@@ -21816,15 +21907,15 @@ class Container extends d {
|
|
|
21816
21907
|
return;
|
|
21817
21908
|
}
|
|
21818
21909
|
const currentUrl = window.location.href;
|
|
21819
|
-
|
|
21910
|
+
|
|
21911
|
+
// When ranking is configured (any matching proactive has an `order`, which
|
|
21912
|
+
// only flag-enabled clients can set), a single highest-priority proactive
|
|
21913
|
+
// fires; otherwise every matching proactive fires.
|
|
21914
|
+
selectProactivesToTriggerForUrl(proactiveConversations, currentUrl, adaSettings.handle).forEach(_ref => {
|
|
21820
21915
|
let [key, conversation] = _ref;
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
this.handleProactiveTrigger(Container_objectSpread({
|
|
21825
|
-
key
|
|
21826
|
-
}, conversation), "url");
|
|
21827
|
-
}
|
|
21916
|
+
this.handleProactiveTrigger(Container_objectSpread({
|
|
21917
|
+
key
|
|
21918
|
+
}, conversation), "url");
|
|
21828
21919
|
});
|
|
21829
21920
|
}
|
|
21830
21921
|
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]>;
|