@ada-support/embed2 1.7.37 → 1.8.0
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/businessEvents/types.d.ts +1 -1
- package/dist/npm-entry/campaigns/types.d.ts +18 -1
- package/dist/npm-entry/common/constants/events.d.ts +1 -0
- package/dist/npm-entry/common/helpers/TriggerConditionEvaluator.d.ts +3 -2
- package/dist/npm-entry/common/lib/channel.d.ts +3 -0
- package/dist/npm-entry/common/types/helpers.d.ts +0 -18
- package/dist/npm-entry/index.js +37 -27
- package/dist/npm-entry/proactiveConversations/proactiveConversation.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import type { TriggerCondition } from "common/types/helpers";
|
|
2
1
|
export declare type GoalEvent = unknown;
|
|
3
2
|
export declare type CampaignFrequency = "every-time" | "once-per-session" | "once-per-user";
|
|
3
|
+
export declare type TriggerCondition = URLMatchTriggerCondition | DateTimeTriggerCondition;
|
|
4
|
+
export interface URLMatchTriggerCondition {
|
|
5
|
+
type: "url-match";
|
|
6
|
+
conditions_any: [
|
|
7
|
+
{
|
|
8
|
+
type: "ends-with" | "contains" | "equals" | "regex";
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
export interface DateTimeTriggerCondition {
|
|
14
|
+
type: "datetime";
|
|
15
|
+
timezone: string;
|
|
16
|
+
condition: {
|
|
17
|
+
operator: "before-exclusive" | "after-inclusive";
|
|
18
|
+
datetime: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
4
21
|
export interface MarketingCampaign {
|
|
5
22
|
_id: string;
|
|
6
23
|
version: "2021-01-12";
|
|
@@ -77,6 +77,7 @@ export declare const SET_DEVICE_TOKEN_RESPONSE = "SET_DEVICE_TOKEN_RESPONSE";
|
|
|
77
77
|
export declare const TRIGGER_PROACTIVE = "TRIGGER_PROACTIVE";
|
|
78
78
|
export declare const TRIGGER_PROACTIVE_RESPONSE = "TRIGGER_PROACTIVE_RESPONSE";
|
|
79
79
|
export declare const SEND_GREETING = "SEND_GREETING";
|
|
80
|
+
export declare const INJECT_PROACTIVE_CONVERSATION = "INJECT_PROACTIVE_CONVERSATION";
|
|
80
81
|
/**
|
|
81
82
|
* Fetch Event Status
|
|
82
83
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { DateTimeTriggerCondition, TriggerCondition
|
|
2
|
-
|
|
1
|
+
import type { DateTimeTriggerCondition, TriggerCondition } from "campaigns/types";
|
|
2
|
+
import type { UrlTriggerCondition } from "proactiveConversations/types";
|
|
3
|
+
export declare const evalUrlMatchTriggerCondition: (triggerConditions: UrlTriggerCondition[], url: string) => boolean;
|
|
3
4
|
export declare const evalDatetimeTriggerCondition: (triggerCondition: DateTimeTriggerCondition, currentDateTime: Date) => boolean;
|
|
4
5
|
export declare const evalTriggerCondition: (triggerCondition: TriggerCondition) => boolean;
|
|
@@ -35,6 +35,9 @@ export interface EmbedRequestPayloadByEvent {
|
|
|
35
35
|
language: string;
|
|
36
36
|
};
|
|
37
37
|
TRIGGER_PROACTIVE: TriggerProactiveParams;
|
|
38
|
+
INJECT_PROACTIVE_CONVERSATION: {
|
|
39
|
+
key: string;
|
|
40
|
+
};
|
|
38
41
|
}
|
|
39
42
|
export declare type EmbedRequestEvent = keyof EmbedRequestPayloadByEvent;
|
|
40
43
|
export interface EmbedResponsePayloadByEvent {
|
|
@@ -1,21 +1,3 @@
|
|
|
1
1
|
export declare type PartialRecord<K extends keyof any, T> = {
|
|
2
2
|
[P in K]?: T;
|
|
3
3
|
};
|
|
4
|
-
export declare type TriggerCondition = URLMatchTriggerCondition | DateTimeTriggerCondition;
|
|
5
|
-
export interface URLMatchTriggerCondition {
|
|
6
|
-
type: "url-match";
|
|
7
|
-
conditions_any: [
|
|
8
|
-
{
|
|
9
|
-
type: "ends-with" | "contains" | "equals" | "regex";
|
|
10
|
-
value: string;
|
|
11
|
-
}
|
|
12
|
-
];
|
|
13
|
-
}
|
|
14
|
-
export interface DateTimeTriggerCondition {
|
|
15
|
-
type: "datetime";
|
|
16
|
-
timezone: string;
|
|
17
|
-
condition: {
|
|
18
|
-
operator: "before-exclusive" | "after-inclusive";
|
|
19
|
-
datetime: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
package/dist/npm-entry/index.js
CHANGED
|
@@ -13949,7 +13949,7 @@ const client = new BrowserClient({
|
|
|
13949
13949
|
return event;
|
|
13950
13950
|
},
|
|
13951
13951
|
environment: "production",
|
|
13952
|
-
release: "1.
|
|
13952
|
+
release: "1.8.0-65176dc",
|
|
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
|
|
@@ -14069,6 +14069,7 @@ const TRIGGER_PROACTIVE_RESPONSE = "TRIGGER_PROACTIVE_RESPONSE";
|
|
|
14069
14069
|
|
|
14070
14070
|
// Tells chat to send a greeting
|
|
14071
14071
|
const SEND_GREETING = "SEND_GREETING";
|
|
14072
|
+
const INJECT_PROACTIVE_CONVERSATION = "INJECT_PROACTIVE_CONVERSATION";
|
|
14072
14073
|
|
|
14073
14074
|
/**
|
|
14074
14075
|
* Fetch Event Status
|
|
@@ -14523,7 +14524,7 @@ function getEmbedURL(_ref) {
|
|
|
14523
14524
|
} else {
|
|
14524
14525
|
host = `http://${handle}.localhost:9001`;
|
|
14525
14526
|
}
|
|
14526
|
-
return `${host}/embed/${frameName}/${"
|
|
14527
|
+
return `${host}/embed/${frameName}/${"65176dc"}/index.html`;
|
|
14527
14528
|
}
|
|
14528
14529
|
function constructQueryString(query) {
|
|
14529
14530
|
return Object.keys(query).map(key => {
|
|
@@ -15072,7 +15073,7 @@ function doesUrlMatchPath(url, path) {
|
|
|
15072
15073
|
;// CONCATENATED MODULE: ./src/common/helpers/TriggerConditionEvaluator.ts
|
|
15073
15074
|
|
|
15074
15075
|
const stripTrailingSlash = url => url.endsWith("/") ? url.slice(0, -1) : url;
|
|
15075
|
-
const evalUrlMatchTriggerCondition = (
|
|
15076
|
+
const evalUrlMatchTriggerCondition = (triggerConditions, url) => {
|
|
15076
15077
|
/**
|
|
15077
15078
|
* Behaviour
|
|
15078
15079
|
* regex Regex match (as per javascript string .match) over the whole string including
|
|
@@ -15082,7 +15083,7 @@ const evalUrlMatchTriggerCondition = (triggerCondition, url) => {
|
|
|
15082
15083
|
* equals Matches the exact URL, without query params
|
|
15083
15084
|
*/
|
|
15084
15085
|
const urlWithoutQueryParams = url.split("?")[0];
|
|
15085
|
-
return
|
|
15086
|
+
return triggerConditions.some(condition => {
|
|
15086
15087
|
switch (condition.type) {
|
|
15087
15088
|
case "ends-with":
|
|
15088
15089
|
{
|
|
@@ -15121,7 +15122,7 @@ const evalDatetimeTriggerCondition = (triggerCondition, currentDateTime) => {
|
|
|
15121
15122
|
const evalTriggerCondition = triggerCondition => {
|
|
15122
15123
|
switch (triggerCondition.type) {
|
|
15123
15124
|
case "url-match":
|
|
15124
|
-
return evalUrlMatchTriggerCondition(triggerCondition, window.location.href);
|
|
15125
|
+
return evalUrlMatchTriggerCondition(triggerCondition.conditions_any, window.location.href);
|
|
15125
15126
|
case "datetime":
|
|
15126
15127
|
return evalDatetimeTriggerCondition(triggerCondition, new Date());
|
|
15127
15128
|
// If an unknown trigger type is found, ignore the trigger condition - do not block campaign
|
|
@@ -15701,9 +15702,9 @@ async function log(message, extra, options) {
|
|
|
15701
15702
|
service: "embed",
|
|
15702
15703
|
env: "production",
|
|
15703
15704
|
embedVersion: 2,
|
|
15704
|
-
version: "1.
|
|
15705
|
+
version: "1.8.0",
|
|
15705
15706
|
isNpm: true,
|
|
15706
|
-
commitHash: "
|
|
15707
|
+
commitHash: "65176dc"
|
|
15707
15708
|
}))
|
|
15708
15709
|
});
|
|
15709
15710
|
}
|
|
@@ -16235,6 +16236,7 @@ function proactiveConversation_objectSpread(e) { for (var r = 1; r < arguments.l
|
|
|
16235
16236
|
|
|
16236
16237
|
|
|
16237
16238
|
|
|
16239
|
+
|
|
16238
16240
|
function proactiveShownWithinFrequency(proactiveConversationKey, frequency, handle) {
|
|
16239
16241
|
switch (frequency) {
|
|
16240
16242
|
case "always":
|
|
@@ -16275,7 +16277,8 @@ function proactiveTriggerImpl(_ref) {
|
|
|
16275
16277
|
messageKey,
|
|
16276
16278
|
adaSettings,
|
|
16277
16279
|
messageService,
|
|
16278
|
-
|
|
16280
|
+
setRecentProactiveConversationKey,
|
|
16281
|
+
clearProactiveConversation
|
|
16279
16282
|
} = _ref;
|
|
16280
16283
|
const {
|
|
16281
16284
|
handle
|
|
@@ -16294,7 +16297,8 @@ function proactiveTriggerImpl(_ref) {
|
|
|
16294
16297
|
|
|
16295
16298
|
// Record the proactive message as being shown
|
|
16296
16299
|
recordProactiveTrigger(messageKey, frequency, handle);
|
|
16297
|
-
|
|
16300
|
+
setRecentProactiveConversationKey(messageKey);
|
|
16301
|
+
clearProactiveConversation();
|
|
16298
16302
|
const localChannel = messageService.getChannel("local");
|
|
16299
16303
|
const lang = adaSettings.language || get_browser_language();
|
|
16300
16304
|
const message = proactiveConversation.messages[lang][0];
|
|
@@ -16305,20 +16309,10 @@ function proactiveTriggerImpl(_ref) {
|
|
|
16305
16309
|
});
|
|
16306
16310
|
}
|
|
16307
16311
|
function evaluateUrlTriggerConditions(conditions, url) {
|
|
16308
|
-
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
|
|
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
|
-
});
|
|
16312
|
+
if (!conditions.length) {
|
|
16313
|
+
return false;
|
|
16314
|
+
}
|
|
16315
|
+
return evalUrlMatchTriggerCondition(conditions, url);
|
|
16322
16316
|
}
|
|
16323
16317
|
;// CONCATENATED MODULE: ./src/services/chat-versioning/manifest.ts
|
|
16324
16318
|
|
|
@@ -16846,7 +16840,7 @@ class ChatFrame extends d {
|
|
|
16846
16840
|
const hostPageUrlParams = new URL(window.location.href).searchParams;
|
|
16847
16841
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
16848
16842
|
const queryParams = {
|
|
16849
|
-
embedVersion: "
|
|
16843
|
+
embedVersion: "65176dc".slice(0, 7),
|
|
16850
16844
|
greeting,
|
|
16851
16845
|
language,
|
|
16852
16846
|
skipGreeting,
|
|
@@ -17722,7 +17716,8 @@ class Container extends d {
|
|
|
17722
17716
|
followUpResponseId: null,
|
|
17723
17717
|
chatVersion: undefined,
|
|
17724
17718
|
readyToRenderChatFrame: false,
|
|
17725
|
-
proactiveConversation: null
|
|
17719
|
+
proactiveConversation: null,
|
|
17720
|
+
recentProactiveConversationKey: null
|
|
17726
17721
|
});
|
|
17727
17722
|
_defineProperty(this, "resetChatBound", this.resetChat.bind(this));
|
|
17728
17723
|
_defineProperty(this, "locationChangeHandlerBound", this.locationChangeHandler.bind(this));
|
|
@@ -17837,7 +17832,8 @@ class Container extends d {
|
|
|
17837
17832
|
campaignToTrigger,
|
|
17838
17833
|
campaignTriggerOptions,
|
|
17839
17834
|
followUpResponseId,
|
|
17840
|
-
proactiveConversation
|
|
17835
|
+
proactiveConversation,
|
|
17836
|
+
recentProactiveConversationKey
|
|
17841
17837
|
} = this.state;
|
|
17842
17838
|
|
|
17843
17839
|
/* We wait for all necessary preconditions (e.g. necessary connections established) to be true,
|
|
@@ -17869,7 +17865,10 @@ class Container extends d {
|
|
|
17869
17865
|
messageKey: proactiveConversation.key,
|
|
17870
17866
|
adaSettings,
|
|
17871
17867
|
messageService,
|
|
17872
|
-
|
|
17868
|
+
setRecentProactiveConversationKey: key => this.setState({
|
|
17869
|
+
recentProactiveConversationKey: key
|
|
17870
|
+
}),
|
|
17871
|
+
clearProactiveConversation: () => this.setState({
|
|
17873
17872
|
proactiveConversation: null
|
|
17874
17873
|
})
|
|
17875
17874
|
});
|
|
@@ -17893,6 +17892,17 @@ class Container extends d {
|
|
|
17893
17892
|
});
|
|
17894
17893
|
}
|
|
17895
17894
|
}
|
|
17895
|
+
if (isChatWebsocketConnected && isDrawerOpen && recentProactiveConversationKey) {
|
|
17896
|
+
const chatChannel = messageService.getChannel(CHAT_IFRAME);
|
|
17897
|
+
if (chatChannel) {
|
|
17898
|
+
chatChannel.postMessage(INJECT_PROACTIVE_CONVERSATION, {
|
|
17899
|
+
key: recentProactiveConversationKey
|
|
17900
|
+
});
|
|
17901
|
+
this.setState({
|
|
17902
|
+
recentProactiveConversationKey: null
|
|
17903
|
+
});
|
|
17904
|
+
}
|
|
17905
|
+
}
|
|
17896
17906
|
if (prevProps.isDrawerOpen !== isDrawerOpen && toggleCallback) {
|
|
17897
17907
|
toggleCallback(isDrawerOpen);
|
|
17898
17908
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { StartOptions } from "@ada-support/embed-types";
|
|
2
2
|
import type { MessageService } from "client/lib/message-service";
|
|
3
3
|
import type { ProactiveConversation, UrlTriggerCondition } from "./types";
|
|
4
|
-
export declare function proactiveTriggerImpl({ proactiveConversation, messageKey, adaSettings, messageService,
|
|
4
|
+
export declare function proactiveTriggerImpl({ proactiveConversation, messageKey, adaSettings, messageService, setRecentProactiveConversationKey, clearProactiveConversation, }: {
|
|
5
5
|
proactiveConversation: ProactiveConversation;
|
|
6
6
|
messageKey: string;
|
|
7
7
|
adaSettings: StartOptions;
|
|
8
8
|
messageService: MessageService;
|
|
9
|
-
|
|
9
|
+
setRecentProactiveConversationKey: (key: string) => void;
|
|
10
|
+
clearProactiveConversation: () => void;
|
|
10
11
|
}): void;
|
|
11
12
|
export declare function evaluateUrlTriggerConditions(conditions: UrlTriggerCondition[], url: string): boolean;
|