@ada-support/embed2 1.7.29 → 1.7.31
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
|
@@ -13949,7 +13949,7 @@ const client = new BrowserClient({
|
|
|
13949
13949
|
return event;
|
|
13950
13950
|
},
|
|
13951
13951
|
environment: "production",
|
|
13952
|
-
release: "1.7.
|
|
13952
|
+
release: "1.7.31-645ffae",
|
|
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
|
|
@@ -14523,7 +14523,7 @@ function getEmbedURL(_ref) {
|
|
|
14523
14523
|
} else {
|
|
14524
14524
|
host = `http://${handle}.localhost:9001`;
|
|
14525
14525
|
}
|
|
14526
|
-
return `${host}/embed/${frameName}/${"
|
|
14526
|
+
return `${host}/embed/${frameName}/${"645ffae"}/index.html`;
|
|
14527
14527
|
}
|
|
14528
14528
|
function constructQueryString(query) {
|
|
14529
14529
|
return Object.keys(query).map(key => {
|
|
@@ -14928,7 +14928,7 @@ class StoreProxy {
|
|
|
14928
14928
|
}
|
|
14929
14929
|
}
|
|
14930
14930
|
;// CONCATENATED MODULE: ./src/client/helpers/local-notifications/index.ts
|
|
14931
|
-
const browserHasNotificationSupport =
|
|
14931
|
+
const browserHasNotificationSupport = "Notification" in window;
|
|
14932
14932
|
function checkIfUserHasGivenPermission() {
|
|
14933
14933
|
if (!browserHasNotificationSupport) {
|
|
14934
14934
|
return false;
|
|
@@ -15467,7 +15467,6 @@ function triggerCampaignImpl(_ref) {
|
|
|
15467
15467
|
}).catch(NO_OP_FUNCTION); // we don't want to log errors here, it may fail because of rate limiting
|
|
15468
15468
|
}
|
|
15469
15469
|
}
|
|
15470
|
-
|
|
15471
15470
|
const getCampaignToTrigger = (adaSettings, marketingCampaigns, options, onlyBasic) => {
|
|
15472
15471
|
const {
|
|
15473
15472
|
ignoreStatus = false,
|
|
@@ -15702,9 +15701,9 @@ async function log(message, extra, options) {
|
|
|
15702
15701
|
service: "embed",
|
|
15703
15702
|
env: "production",
|
|
15704
15703
|
embedVersion: 2,
|
|
15705
|
-
version: "1.7.
|
|
15704
|
+
version: "1.7.31",
|
|
15706
15705
|
isNpm: true,
|
|
15707
|
-
commitHash: "
|
|
15706
|
+
commitHash: "645ffae"
|
|
15708
15707
|
}))
|
|
15709
15708
|
});
|
|
15710
15709
|
}
|
|
@@ -16229,6 +16228,82 @@ function setBrowserStorageItem(key, value, persistenceSetting) {
|
|
|
16229
16228
|
dist/* adaSessionStorage */.ad.setItem(key, value);
|
|
16230
16229
|
}
|
|
16231
16230
|
}
|
|
16231
|
+
;// CONCATENATED MODULE: ./src/proactiveConversations/proactiveConversation.ts
|
|
16232
|
+
|
|
16233
|
+
function proactiveConversation_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16234
|
+
function proactiveConversation_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? proactiveConversation_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : proactiveConversation_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16235
|
+
|
|
16236
|
+
|
|
16237
|
+
|
|
16238
|
+
function proactiveShownWithinFrequency(proactiveConversationKey, frequency, handle) {
|
|
16239
|
+
switch (frequency) {
|
|
16240
|
+
case "always":
|
|
16241
|
+
return false;
|
|
16242
|
+
case "session":
|
|
16243
|
+
{
|
|
16244
|
+
const storageValue = dist/* adaSessionStorage */.ad.getFnItem("marketing_campaigns_shown");
|
|
16245
|
+
const perSessionProactives = storageValue ? (storageValue[handle] || "").split(",") : [];
|
|
16246
|
+
return perSessionProactives.includes(proactiveConversationKey);
|
|
16247
|
+
}
|
|
16248
|
+
default:
|
|
16249
|
+
return false;
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
function addProactiveToStorageString(oldStorageValue, proactiveConversationId) {
|
|
16253
|
+
return oldStorageValue ? `${oldStorageValue},${proactiveConversationId}` : proactiveConversationId;
|
|
16254
|
+
}
|
|
16255
|
+
function recordProactiveTrigger(proactiveConversationKey, frequency, handle) {
|
|
16256
|
+
switch (frequency) {
|
|
16257
|
+
case "always":
|
|
16258
|
+
break;
|
|
16259
|
+
case "session":
|
|
16260
|
+
{
|
|
16261
|
+
const currentStorageValue = dist/* adaSessionStorage */.ad.getFnItem("marketing_campaigns_shown");
|
|
16262
|
+
const newStorageValue = addProactiveToStorageString(currentStorageValue ? currentStorageValue[handle] || "" : "", proactiveConversationKey);
|
|
16263
|
+
dist/* adaSessionStorage */.ad.setFnItem("marketing_campaigns_shown", proactiveConversation_objectSpread(proactiveConversation_objectSpread({}, currentStorageValue), {}, {
|
|
16264
|
+
[handle]: newStorageValue
|
|
16265
|
+
}));
|
|
16266
|
+
break;
|
|
16267
|
+
}
|
|
16268
|
+
default:
|
|
16269
|
+
break;
|
|
16270
|
+
}
|
|
16271
|
+
}
|
|
16272
|
+
function proactiveTriggerImpl(_ref) {
|
|
16273
|
+
let {
|
|
16274
|
+
proactiveConversation,
|
|
16275
|
+
messageKey,
|
|
16276
|
+
adaSettings,
|
|
16277
|
+
messageService,
|
|
16278
|
+
clearProactiveMessage
|
|
16279
|
+
} = _ref;
|
|
16280
|
+
const {
|
|
16281
|
+
handle
|
|
16282
|
+
} = adaSettings;
|
|
16283
|
+
const {
|
|
16284
|
+
duration,
|
|
16285
|
+
delay,
|
|
16286
|
+
frequency
|
|
16287
|
+
} = proactiveConversation.modality_config.chat;
|
|
16288
|
+
|
|
16289
|
+
// Check if the proactive message has been shown within the specified frequency
|
|
16290
|
+
const doesPassFrequencyCheck = !proactiveShownWithinFrequency(messageKey, frequency, handle);
|
|
16291
|
+
if (!doesPassFrequencyCheck) {
|
|
16292
|
+
return;
|
|
16293
|
+
}
|
|
16294
|
+
|
|
16295
|
+
// Record the proactive message as being shown
|
|
16296
|
+
recordProactiveTrigger(messageKey, frequency, handle);
|
|
16297
|
+
clearProactiveMessage();
|
|
16298
|
+
const localChannel = messageService.getChannel("local");
|
|
16299
|
+
const lang = adaSettings.language || get_browser_language();
|
|
16300
|
+
const message = proactiveConversation.messages[lang][0];
|
|
16301
|
+
localChannel.postMessage(CREATE_PROACTIVE, {
|
|
16302
|
+
body: message,
|
|
16303
|
+
duration,
|
|
16304
|
+
delay
|
|
16305
|
+
});
|
|
16306
|
+
}
|
|
16232
16307
|
;// CONCATENATED MODULE: ./src/services/chat-versioning/manifest.ts
|
|
16233
16308
|
|
|
16234
16309
|
|
|
@@ -16751,7 +16826,7 @@ class ChatFrame extends d {
|
|
|
16751
16826
|
const hostPageUrlParams = new URL(window.location.href).searchParams;
|
|
16752
16827
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
16753
16828
|
const queryParams = {
|
|
16754
|
-
embedVersion: "
|
|
16829
|
+
embedVersion: "645ffae".slice(0, 7),
|
|
16755
16830
|
greeting,
|
|
16756
16831
|
language,
|
|
16757
16832
|
skipGreeting,
|
|
@@ -17605,6 +17680,7 @@ function Container_objectSpread(e) { for (var r = 1; r < arguments.length; r++)
|
|
|
17605
17680
|
|
|
17606
17681
|
|
|
17607
17682
|
|
|
17683
|
+
|
|
17608
17684
|
|
|
17609
17685
|
|
|
17610
17686
|
class Container extends d {
|
|
@@ -17621,7 +17697,8 @@ class Container extends d {
|
|
|
17621
17697
|
hideIntroOverride: false,
|
|
17622
17698
|
followUpResponseId: null,
|
|
17623
17699
|
chatVersion: undefined,
|
|
17624
|
-
readyToRenderChatFrame: false
|
|
17700
|
+
readyToRenderChatFrame: false,
|
|
17701
|
+
proactiveConversation: null
|
|
17625
17702
|
});
|
|
17626
17703
|
_defineProperty(this, "resetChatBound", this.resetChat.bind(this));
|
|
17627
17704
|
_defineProperty(this, "locationChangeHandlerBound", this.locationChangeHandler.bind(this));
|
|
@@ -17735,7 +17812,8 @@ class Container extends d {
|
|
|
17735
17812
|
const {
|
|
17736
17813
|
campaignToTrigger,
|
|
17737
17814
|
campaignTriggerOptions,
|
|
17738
|
-
followUpResponseId
|
|
17815
|
+
followUpResponseId,
|
|
17816
|
+
proactiveConversation
|
|
17739
17817
|
} = this.state;
|
|
17740
17818
|
|
|
17741
17819
|
/* We wait for all necessary preconditions (e.g. necessary connections established) to be true,
|
|
@@ -17761,6 +17839,17 @@ class Container extends d {
|
|
|
17761
17839
|
messageService
|
|
17762
17840
|
});
|
|
17763
17841
|
}
|
|
17842
|
+
if (proactiveConversation) {
|
|
17843
|
+
proactiveTriggerImpl({
|
|
17844
|
+
proactiveConversation,
|
|
17845
|
+
messageKey: proactiveConversation.key,
|
|
17846
|
+
adaSettings,
|
|
17847
|
+
messageService,
|
|
17848
|
+
clearProactiveMessage: () => this.setState({
|
|
17849
|
+
proactiveConversation: null
|
|
17850
|
+
})
|
|
17851
|
+
});
|
|
17852
|
+
}
|
|
17764
17853
|
|
|
17765
17854
|
// If a follow-up response has been queued by a triggered Campaign, tell chat to show it
|
|
17766
17855
|
if (isChatWebsocketConnected && isDrawerOpen && followUpResponseId) {
|
|
@@ -18004,6 +18093,17 @@ class Container extends d {
|
|
|
18004
18093
|
});
|
|
18005
18094
|
localChannel.postMessage(SET_DEVICE_TOKEN_RESPONSE, null, id);
|
|
18006
18095
|
}
|
|
18096
|
+
handleProactiveTrigger(proactiveConversation) {
|
|
18097
|
+
const {
|
|
18098
|
+
isDrawerOpen
|
|
18099
|
+
} = this.props;
|
|
18100
|
+
if (isDrawerOpen) {
|
|
18101
|
+
return;
|
|
18102
|
+
}
|
|
18103
|
+
this.setState({
|
|
18104
|
+
proactiveConversation
|
|
18105
|
+
});
|
|
18106
|
+
}
|
|
18007
18107
|
async handleEmbedAction(type, payload, id) {
|
|
18008
18108
|
const {
|
|
18009
18109
|
client,
|
|
@@ -18200,7 +18300,8 @@ class Container extends d {
|
|
|
18200
18300
|
}
|
|
18201
18301
|
const {
|
|
18202
18302
|
body,
|
|
18203
|
-
duration
|
|
18303
|
+
duration,
|
|
18304
|
+
delay
|
|
18204
18305
|
} = payload;
|
|
18205
18306
|
const EXTRA_PROACTIVE_DELAY = 1000;
|
|
18206
18307
|
this.setState({
|
|
@@ -18212,7 +18313,7 @@ class Container extends d {
|
|
|
18212
18313
|
const newClient = new Client(Container_objectSpread(Container_objectSpread({}, client), {}, {
|
|
18213
18314
|
intro: {
|
|
18214
18315
|
body,
|
|
18215
|
-
delay: 0,
|
|
18316
|
+
delay: delay || 0,
|
|
18216
18317
|
// Not just duration || null because we want to preserve 0 duration
|
|
18217
18318
|
duration: duration || duration === 0 ? duration : null,
|
|
18218
18319
|
style: "Text",
|
|
@@ -18251,17 +18352,18 @@ class Container extends d {
|
|
|
18251
18352
|
if (!client) {
|
|
18252
18353
|
throw new AdaEmbedError("`client` is not defined");
|
|
18253
18354
|
}
|
|
18254
|
-
const language = adaSettings.language || get_browser_language();
|
|
18255
18355
|
const {
|
|
18256
18356
|
messageKey
|
|
18257
18357
|
} = payload;
|
|
18258
18358
|
if ((_client$proactive_con = client.proactive_conversations) !== null && _client$proactive_con !== void 0 && _client$proactive_con[messageKey]) {
|
|
18259
|
-
|
|
18260
|
-
|
|
18359
|
+
const proactiveConversation = client.proactive_conversations[messageKey];
|
|
18360
|
+
this.handleProactiveTrigger(Container_objectSpread(Container_objectSpread({}, proactiveConversation), {}, {
|
|
18361
|
+
key: messageKey
|
|
18362
|
+
}));
|
|
18261
18363
|
} else {
|
|
18262
|
-
|
|
18263
|
-
console.log("Proactive message not found");
|
|
18364
|
+
warn(`Proactive message with key ${messageKey} not found`);
|
|
18264
18365
|
}
|
|
18366
|
+
localChannel.postMessage(TRIGGER_PROACTIVE_RESPONSE, null, id);
|
|
18265
18367
|
break;
|
|
18266
18368
|
}
|
|
18267
18369
|
default:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StartOptions } from "@ada-support/embed-types";
|
|
2
|
+
import type { MessageService } from "client/lib/message-service";
|
|
3
|
+
import type { ProactiveConversation } from "./types";
|
|
4
|
+
export declare function proactiveTriggerImpl({ proactiveConversation, messageKey, adaSettings, messageService, clearProactiveMessage, }: {
|
|
5
|
+
proactiveConversation: ProactiveConversation;
|
|
6
|
+
messageKey: string;
|
|
7
|
+
adaSettings: StartOptions;
|
|
8
|
+
messageService: MessageService;
|
|
9
|
+
clearProactiveMessage: () => void;
|
|
10
|
+
}): void;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
frequency: string;
|
|
13
|
-
};
|
|
1
|
+
export interface ProactiveConversation {
|
|
2
|
+
messages: {
|
|
3
|
+
[language: string]: string[];
|
|
4
|
+
};
|
|
5
|
+
modality_config: {
|
|
6
|
+
[modality: string]: {
|
|
7
|
+
active: boolean;
|
|
8
|
+
url_trigger_conditions: string[];
|
|
9
|
+
delay: number;
|
|
10
|
+
duration: number;
|
|
11
|
+
frequency: ProactiveConversationFrequency;
|
|
14
12
|
};
|
|
15
13
|
};
|
|
14
|
+
key?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ProactiveConversations {
|
|
17
|
+
[messageKey: string]: ProactiveConversation;
|
|
16
18
|
}
|
|
19
|
+
export declare type ProactiveConversationFrequency = "always" | "session";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ada-support/embed2",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.31",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/npm-entry",
|
|
6
6
|
"typings": "dist/npm-entry/index-npm.d.ts",
|
|
@@ -43,6 +43,15 @@
|
|
|
43
43
|
"license": "ISC",
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@ada-support/eslint-config-ada": "^1.2.5",
|
|
46
|
+
"@babel/core": "^7.23.2",
|
|
47
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
48
|
+
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
|
|
49
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.16.7",
|
|
50
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
51
|
+
"@babel/plugin-transform-react-jsx": "^7.16.7",
|
|
52
|
+
"@babel/plugin-transform-runtime": "^7.16.10",
|
|
53
|
+
"@babel/preset-env": "^7.23.2",
|
|
54
|
+
"@babel/preset-typescript": "^7.23.2",
|
|
46
55
|
"@testing-library/preact": "^2.0.1",
|
|
47
56
|
"@types/enzyme": "^3.10.11",
|
|
48
57
|
"@types/jest": "^27.0.2",
|
|
@@ -54,9 +63,12 @@
|
|
|
54
63
|
"@types/webpack": "^5.28.0",
|
|
55
64
|
"@types/webpack-bundle-analyzer": "^4.4.1",
|
|
56
65
|
"@types/webpack-dev-server": "^4.7.2",
|
|
66
|
+
"babel-loader": "9.1.2",
|
|
67
|
+
"babel-preset-preact": "^2.0.0",
|
|
57
68
|
"browserslist": "^4.17.4",
|
|
58
69
|
"cypress": "^9.6.1",
|
|
59
70
|
"depcheck": "^1.4.3",
|
|
71
|
+
"dotenv": "^8.2.0",
|
|
60
72
|
"enzyme": "^3.11.0",
|
|
61
73
|
"enzyme-adapter-preact-pure": "^4.0.1",
|
|
62
74
|
"eslint": "^8.8.0",
|
|
@@ -66,6 +78,7 @@
|
|
|
66
78
|
"eslint-plugin-cypress": "^2.12.1",
|
|
67
79
|
"eslint-plugin-sonarjs": "^0.11.0",
|
|
68
80
|
"husky": "^7.0.0",
|
|
81
|
+
"html-webpack-plugin": "^5.5.0",
|
|
69
82
|
"jest": "^27.5.1",
|
|
70
83
|
"jest-localstorage-mock": "^2.4.0",
|
|
71
84
|
"lint-staged": "^11.2.3",
|
|
@@ -75,38 +88,25 @@
|
|
|
75
88
|
"start-server-and-test": "^2.0.4",
|
|
76
89
|
"ts-node": "^10.2.1",
|
|
77
90
|
"tsconfig-paths": "^3.11.0",
|
|
91
|
+
"typescript": "^4.6.2",
|
|
92
|
+
"webpack": "^5.76.0",
|
|
78
93
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
79
|
-
"webpack-
|
|
94
|
+
"webpack-cli": "^5.1.4",
|
|
95
|
+
"webpack-dev-server": "^4.3.1",
|
|
96
|
+
"webpack-merge": "^5.8.0"
|
|
80
97
|
},
|
|
81
98
|
"dependencies": {
|
|
82
99
|
"@ada-support/embed-types": "^1.8.0",
|
|
83
100
|
"@ada-support/web-storage": "^1.2.6",
|
|
84
|
-
"@babel/core": "^7.23.2",
|
|
85
|
-
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
86
|
-
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
|
|
87
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.7",
|
|
88
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
89
|
-
"@babel/plugin-transform-react-jsx": "^7.16.7",
|
|
90
|
-
"@babel/plugin-transform-runtime": "^7.16.10",
|
|
91
|
-
"@babel/preset-env": "^7.23.2",
|
|
92
|
-
"@babel/preset-typescript": "^7.23.2",
|
|
93
101
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
94
102
|
"@sentry/browser": "^8.33.0",
|
|
95
103
|
"@sentry/types": "^8.33.1",
|
|
96
|
-
"babel-loader": "9.1.2",
|
|
97
|
-
"babel-preset-preact": "^2.0.0",
|
|
98
|
-
"dotenv": "^8.2.0",
|
|
99
104
|
"focus-visible": "^5.2.0",
|
|
100
|
-
"html-webpack-plugin": "^5.5.0",
|
|
101
105
|
"json-stable-stringify": "^1.0.1",
|
|
102
106
|
"lodash.debounce": "^4.0.8",
|
|
103
107
|
"lodash.memoize": "^4.1.2",
|
|
104
108
|
"preact": "10.4.5",
|
|
105
|
-
"
|
|
106
|
-
"uniqid": "^5.3.0",
|
|
107
|
-
"webpack": "^5.76.0",
|
|
108
|
-
"webpack-cli": "^5.1.4",
|
|
109
|
-
"webpack-merge": "^5.8.0"
|
|
109
|
+
"uniqid": "^5.3.0"
|
|
110
110
|
},
|
|
111
111
|
"resolutions": {
|
|
112
112
|
"@lambdatest/node-tunnel": ">=3.0.2",
|