@ada-support/embed2 1.14.6 → 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
|
}
|
|
@@ -18685,6 +18685,44 @@ function proactiveShownWithinFrequency(proactiveConversationKey, frequency, hand
|
|
|
18685
18685
|
return false;
|
|
18686
18686
|
}
|
|
18687
18687
|
}
|
|
18688
|
+
|
|
18689
|
+
// A proactive only fires when `now` is within its optional scheduling window.
|
|
18690
|
+
// Bounds are absolute ISO 8601 UTC instants authored in the dashboard; either
|
|
18691
|
+
// may be unset for an open-ended window. This mirrors the declarative campaign
|
|
18692
|
+
// datetime gating: the start is after-inclusive and the end is before-exclusive,
|
|
18693
|
+
// evaluated through the shared trigger-condition evaluator so the semantics stay
|
|
18694
|
+
// identical across both surfaces.
|
|
18695
|
+
function isWithinSchedule(scheduleStart, scheduleEnd) {
|
|
18696
|
+
const now = new Date();
|
|
18697
|
+
const buildCondition = (operator, datetime) => ({
|
|
18698
|
+
type: "datetime",
|
|
18699
|
+
// Bounds are absolute UTC instants (the stored datetime carries a `Z`
|
|
18700
|
+
// offset). `timezone` is metadata the evaluator doesn't consult, but label
|
|
18701
|
+
// it UTC to match the data and stay correct if the evaluator ever honors it.
|
|
18702
|
+
timezone: "UTC",
|
|
18703
|
+
condition: {
|
|
18704
|
+
operator,
|
|
18705
|
+
datetime
|
|
18706
|
+
}
|
|
18707
|
+
});
|
|
18708
|
+
if (scheduleStart && !evalDatetimeTriggerCondition(buildCondition("after-inclusive", scheduleStart), now)) {
|
|
18709
|
+
return false;
|
|
18710
|
+
}
|
|
18711
|
+
if (scheduleEnd && !evalDatetimeTriggerCondition(buildCondition("before-exclusive", scheduleEnd), now)) {
|
|
18712
|
+
return false;
|
|
18713
|
+
}
|
|
18714
|
+
return true;
|
|
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
|
+
}
|
|
18688
18726
|
function addProactiveToStorageString(oldStorageValue, proactiveConversationId) {
|
|
18689
18727
|
return oldStorageValue ? `${oldStorageValue},${proactiveConversationId}` : proactiveConversationId;
|
|
18690
18728
|
}
|
|
@@ -18731,7 +18769,7 @@ function extractRichContent(proactiveConversation, language) {
|
|
|
18731
18769
|
} : undefined
|
|
18732
18770
|
};
|
|
18733
18771
|
}
|
|
18734
|
-
function proactiveTriggerImpl(
|
|
18772
|
+
function proactiveTriggerImpl(_ref3) {
|
|
18735
18773
|
let {
|
|
18736
18774
|
proactiveConversation,
|
|
18737
18775
|
triggerMethod,
|
|
@@ -18740,7 +18778,7 @@ function proactiveTriggerImpl(_ref) {
|
|
|
18740
18778
|
language,
|
|
18741
18779
|
setRecentProactiveConversationConfig,
|
|
18742
18780
|
clearProactiveConversation
|
|
18743
|
-
} =
|
|
18781
|
+
} = _ref3;
|
|
18744
18782
|
const {
|
|
18745
18783
|
handle
|
|
18746
18784
|
} = adaSettings;
|
|
@@ -18754,13 +18792,19 @@ function proactiveTriggerImpl(_ref) {
|
|
|
18754
18792
|
duration,
|
|
18755
18793
|
delay,
|
|
18756
18794
|
frequency,
|
|
18757
|
-
active
|
|
18795
|
+
active,
|
|
18796
|
+
schedule_start: scheduleStart,
|
|
18797
|
+
schedule_end: scheduleEnd
|
|
18758
18798
|
} = proactiveConversation.modality_config.chat;
|
|
18759
18799
|
let proactiveMessage = proactiveConversation.messages[language][0];
|
|
18760
18800
|
if (!active) {
|
|
18761
18801
|
warn("Proactive message is not active");
|
|
18762
18802
|
return;
|
|
18763
18803
|
}
|
|
18804
|
+
if (!isWithinSchedule(scheduleStart, scheduleEnd)) {
|
|
18805
|
+
warn("Proactive message is outside its scheduled window");
|
|
18806
|
+
return;
|
|
18807
|
+
}
|
|
18764
18808
|
if (isTemplate) {
|
|
18765
18809
|
if (Object.keys(params).length === 0) {
|
|
18766
18810
|
warn("Proactive message is a template but no parameters were provided");
|
|
@@ -18820,6 +18864,34 @@ function evaluateUrlTriggerConditions(conditions, url) {
|
|
|
18820
18864
|
}
|
|
18821
18865
|
return evalUrlMatchTriggerCondition(conditions, url);
|
|
18822
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
|
+
}
|
|
18823
18895
|
;// ./src/services/chat-versioning/manifest.ts
|
|
18824
18896
|
|
|
18825
18897
|
|
|
@@ -20206,7 +20278,7 @@ class ChatFrame extends d {
|
|
|
20206
20278
|
log("Chat frame mount", {
|
|
20207
20279
|
handle,
|
|
20208
20280
|
chatUrl: this.url,
|
|
20209
|
-
embedVersion: "
|
|
20281
|
+
embedVersion: "791d3a3".slice(0, 7),
|
|
20210
20282
|
embedSettings: adaSettings
|
|
20211
20283
|
});
|
|
20212
20284
|
|
|
@@ -20294,7 +20366,7 @@ class ChatFrame extends d {
|
|
|
20294
20366
|
const hostPageUrlParams = new URL(window.location.href).searchParams;
|
|
20295
20367
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
20296
20368
|
const queryParams = {
|
|
20297
|
-
embedVersion: "
|
|
20369
|
+
embedVersion: "791d3a3".slice(0, 7),
|
|
20298
20370
|
greeting,
|
|
20299
20371
|
language,
|
|
20300
20372
|
skipGreeting,
|
|
@@ -21772,7 +21844,8 @@ class Container extends d {
|
|
|
21772
21844
|
}
|
|
21773
21845
|
evaluateProactiveConversationConditions() {
|
|
21774
21846
|
const {
|
|
21775
|
-
client
|
|
21847
|
+
client,
|
|
21848
|
+
adaSettings
|
|
21776
21849
|
} = this.props;
|
|
21777
21850
|
if (!client) {
|
|
21778
21851
|
throw new AdaEmbedError("`client` is not defined");
|
|
@@ -21782,15 +21855,15 @@ class Container extends d {
|
|
|
21782
21855
|
return;
|
|
21783
21856
|
}
|
|
21784
21857
|
const currentUrl = window.location.href;
|
|
21785
|
-
|
|
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 => {
|
|
21786
21863
|
let [key, conversation] = _ref;
|
|
21787
|
-
|
|
21788
|
-
|
|
21789
|
-
|
|
21790
|
-
this.handleProactiveTrigger(Container_objectSpread({
|
|
21791
|
-
key
|
|
21792
|
-
}, conversation), "url");
|
|
21793
|
-
}
|
|
21864
|
+
this.handleProactiveTrigger(Container_objectSpread({
|
|
21865
|
+
key
|
|
21866
|
+
}, conversation), "url");
|
|
21794
21867
|
});
|
|
21795
21868
|
}
|
|
21796
21869
|
async handleSettingDeviceToken(localChannel, payload, id) {
|
|
@@ -1,6 +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
|
+
export declare function isWithinSchedule(scheduleStart?: string | null, scheduleEnd?: string | null): boolean;
|
|
5
|
+
export declare function pickHighestPriorityMatch(matches: Array<[string, ProactiveConversation]>): [string, ProactiveConversation] | undefined;
|
|
4
6
|
export declare function proactiveTriggerImpl({ proactiveConversation, triggerMethod, adaSettings, messageService, language, setRecentProactiveConversationConfig, clearProactiveConversation, }: {
|
|
5
7
|
proactiveConversation: ProactiveConversation;
|
|
6
8
|
triggerMethod: ProactiveConversationTriggerMethod | null;
|
|
@@ -11,3 +13,4 @@ export declare function proactiveTriggerImpl({ proactiveConversation, triggerMet
|
|
|
11
13
|
clearProactiveConversation: () => void;
|
|
12
14
|
}): void;
|
|
13
15
|
export declare function evaluateUrlTriggerConditions(conditions: ProactiveConversationUrlTriggerConditions, url: string): boolean;
|
|
16
|
+
export declare function selectProactivesToTriggerForUrl(proactiveConversations: ProactiveConversations, url: string, handle: string): Array<[string, ProactiveConversation]>;
|
|
@@ -19,6 +19,8 @@ export interface ProactiveConversation {
|
|
|
19
19
|
delay: number;
|
|
20
20
|
duration: number;
|
|
21
21
|
frequency: ProactiveConversationFrequency;
|
|
22
|
+
schedule_start?: string | null;
|
|
23
|
+
schedule_end?: string | null;
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
26
|
is_template: boolean;
|
|
@@ -28,6 +30,7 @@ export interface ProactiveConversation {
|
|
|
28
30
|
[language: string]: ProactiveConversationImage[];
|
|
29
31
|
};
|
|
30
32
|
ctas?: ProactiveConversationCta[];
|
|
33
|
+
order?: number | null;
|
|
31
34
|
}
|
|
32
35
|
export interface ProactiveConversations {
|
|
33
36
|
[messageKey: string]: ProactiveConversation;
|