@ada-support/embed2 1.1.46 → 1.2.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/campaigns/campaign.d.ts +2 -2
- package/dist/npm-entry/client/embed.d.ts +3 -2
- package/dist/npm-entry/client/helpers/web-notifications/index.d.ts +1 -0
- package/dist/npm-entry/client/helpers/web-notifications/web-notification-events.d.ts +3 -0
- package/dist/npm-entry/common/constants/events.d.ts +2 -0
- package/dist/npm-entry/common/lib/channel.d.ts +6 -2
- package/dist/npm-entry/common/types/store-state.d.ts +1 -0
- package/dist/npm-entry/index.js +87 -8
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CampaignParams, StartOptions } from "@ada-support/embed-types";
|
|
2
2
|
import type { MessageService } from "client/lib/message-service";
|
|
3
3
|
import type { MarketingCampaign } from "./types";
|
|
4
4
|
interface TriggerCampaignImplParams {
|
|
@@ -11,5 +11,5 @@ interface TriggerCampaignImplParams {
|
|
|
11
11
|
messageService: MessageService;
|
|
12
12
|
}
|
|
13
13
|
export declare function triggerCampaignImpl({ adaSettings, chatterToken, campaign, ignoreStatus, ignoreFrequency, clearCampaignToTrigger, messageService, }: TriggerCampaignImplParams): void;
|
|
14
|
-
export declare const getCampaignToTrigger: (adaSettings: StartOptions, marketingCampaigns: MarketingCampaign[] | undefined, options:
|
|
14
|
+
export declare const getCampaignToTrigger: (adaSettings: StartOptions, marketingCampaigns: MarketingCampaign[] | undefined, options: CampaignParams, onlyBasic: boolean) => MarketingCampaign | undefined;
|
|
15
15
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdaEventKey, AdaEventSubscriptionCallback,
|
|
1
|
+
import type { AdaEventKey, AdaEventSubscriptionCallback, CampaignParams, ResetParams, StartOptions, WindowInfo } from "@ada-support/embed-types";
|
|
2
2
|
import { MessageService } from "client/lib/message-service";
|
|
3
3
|
import { StoreProxy } from "client/lib/store-proxy";
|
|
4
4
|
import "client/lib/error-tracker";
|
|
@@ -31,9 +31,10 @@ export declare class Embed {
|
|
|
31
31
|
reset(resetParams?: ResetParams): Promise<void>;
|
|
32
32
|
trackEvent(eventKey: string, value: number, meta?: {}): Promise<void>;
|
|
33
33
|
triggerCampaign(campaignKey: string, triggerCampaignParams?: {}): Promise<void>;
|
|
34
|
-
evaluateCampaignConditions(options:
|
|
34
|
+
evaluateCampaignConditions(options: CampaignParams): Promise<void>;
|
|
35
35
|
createProactive(body: string, duration: number, responseId?: string): Promise<void>;
|
|
36
36
|
subscribeEvent<K extends AdaEventKey>(eventKey: K, callback: AdaEventSubscriptionCallback<K>): number;
|
|
37
37
|
unsubscribeEvent(id: number): void;
|
|
38
38
|
closeCampaign(): Promise<void>;
|
|
39
|
+
setDeviceToken(token: string): Promise<void>;
|
|
39
40
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addServiceWorkerListeners(): void;
|
|
@@ -74,6 +74,8 @@ export declare const EVAL_CAMPAIGN_CONDITIONS = "EVAL_CAMPAIGN_CONDITIONS";
|
|
|
74
74
|
export declare const EVAL_CAMPAIGN_CONDITIONS_RESPONSE = "EVAL_CAMPAIGN_CONDITIONS_RESPONSE";
|
|
75
75
|
export declare const CLOSE_CAMPAIGN = "CLOSE_CAMPAIGN";
|
|
76
76
|
export declare const CLOSE_CAMPAIGN_RESPONSE = "CLOSE_CAMPAIGN_RESPONSE";
|
|
77
|
+
export declare const SET_DEVICE_TOKEN = "SET_DEVICE_TOKEN";
|
|
78
|
+
export declare const SET_DEVICE_TOKEN_RESPONSE = "SET_DEVICE_TOKEN_RESPONSE";
|
|
77
79
|
export declare const SEND_GREETING = "SEND_GREETING";
|
|
78
80
|
/**
|
|
79
81
|
* Fetch Event Status
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CampaignParams, ResetParams } from "@ada-support/embed-types";
|
|
2
2
|
import type { FetchEventStatusType } from "common/constants/events";
|
|
3
3
|
import type { AdaCustomEvent, Refhandler } from "common/types/events";
|
|
4
4
|
import type { SendGreetingParams, StoreDispatchPayload, StoreGetPayload, TrackEventParams } from "common/types/index";
|
|
@@ -12,7 +12,7 @@ export interface EmbedRequestPayloadByEvent {
|
|
|
12
12
|
};
|
|
13
13
|
DELETE_HISTORY: unknown;
|
|
14
14
|
DISPATCH: StoreDispatchPayload;
|
|
15
|
-
EVAL_CAMPAIGN_CONDITIONS:
|
|
15
|
+
EVAL_CAMPAIGN_CONDITIONS: CampaignParams;
|
|
16
16
|
GET: StoreGetPayload;
|
|
17
17
|
GET_INFO: unknown;
|
|
18
18
|
GET_STATE: unknown;
|
|
@@ -25,6 +25,9 @@ export interface EmbedRequestPayloadByEvent {
|
|
|
25
25
|
TRACK_EVENT: TrackEventParams;
|
|
26
26
|
SEND_GREETING: SendGreetingParams;
|
|
27
27
|
CLOSE_CAMPAIGN: unknown;
|
|
28
|
+
SET_DEVICE_TOKEN: {
|
|
29
|
+
token: string;
|
|
30
|
+
};
|
|
28
31
|
}
|
|
29
32
|
export declare type EmbedRequestEvent = keyof EmbedRequestPayloadByEvent;
|
|
30
33
|
export interface EmbedResponsePayloadByEvent {
|
|
@@ -57,6 +60,7 @@ export interface EmbedResponsePayloadByEvent {
|
|
|
57
60
|
"drawer-mask_INIT": unknown;
|
|
58
61
|
chat_INIT: unknown;
|
|
59
62
|
"x-storage_INIT": unknown;
|
|
63
|
+
SET_DEVICE_TOKEN_RESPONSE: unknown;
|
|
60
64
|
}
|
|
61
65
|
export declare type EmbedResponseEvent = keyof EmbedResponsePayloadByEvent;
|
|
62
66
|
export declare type EmbedEvent = (EmbedRequestEvent | EmbedResponseEvent);
|
|
@@ -39,6 +39,7 @@ export interface StoreState extends StartOptionsNoFunction {
|
|
|
39
39
|
adaSettings: StartOptions;
|
|
40
40
|
wasCampaignShownButNowClosed: boolean;
|
|
41
41
|
proactiveCampaignHadMessages: boolean;
|
|
42
|
+
deviceToken: string | null;
|
|
42
43
|
}
|
|
43
44
|
export interface StartOptionsNoFunction {
|
|
44
45
|
handle?: string;
|
package/dist/npm-entry/index.js
CHANGED
|
@@ -15635,7 +15635,7 @@ const client = new error_tracker_BrowserClient({
|
|
|
15635
15635
|
},
|
|
15636
15636
|
|
|
15637
15637
|
environment: "production",
|
|
15638
|
-
release: "1.
|
|
15638
|
+
release: "1.2.0-1e8cda1",
|
|
15639
15639
|
sampleRate: 0.25,
|
|
15640
15640
|
autoSessionTracking: false,
|
|
15641
15641
|
// Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
|
|
@@ -15754,7 +15754,9 @@ const TRIGGER_CAMPAIGN_RESPONSE = "TRIGGER_CAMPAIGN_RESPONSE";
|
|
|
15754
15754
|
const EVAL_CAMPAIGN_CONDITIONS = "EVAL_CAMPAIGN_CONDITIONS";
|
|
15755
15755
|
const EVAL_CAMPAIGN_CONDITIONS_RESPONSE = "EVAL_CAMPAIGN_CONDITIONS_RESPONSE";
|
|
15756
15756
|
const CLOSE_CAMPAIGN = "CLOSE_CAMPAIGN";
|
|
15757
|
-
const CLOSE_CAMPAIGN_RESPONSE = "CLOSE_CAMPAIGN_RESPONSE";
|
|
15757
|
+
const CLOSE_CAMPAIGN_RESPONSE = "CLOSE_CAMPAIGN_RESPONSE";
|
|
15758
|
+
const SET_DEVICE_TOKEN = "SET_DEVICE_TOKEN";
|
|
15759
|
+
const SET_DEVICE_TOKEN_RESPONSE = "SET_DEVICE_TOKEN_RESPONSE"; // Tells chat to send a greeting
|
|
15758
15760
|
|
|
15759
15761
|
const SEND_GREETING = "SEND_GREETING";
|
|
15760
15762
|
/**
|
|
@@ -16233,7 +16235,7 @@ function getEmbedURL(_ref) {
|
|
|
16233
16235
|
host = "http://".concat(window.location.hostname, ":9001");
|
|
16234
16236
|
}
|
|
16235
16237
|
|
|
16236
|
-
return "".concat(host, "/embed/").concat(frameName, "/").concat("
|
|
16238
|
+
return "".concat(host, "/embed/").concat(frameName, "/").concat("1e8cda1", "/index.html");
|
|
16237
16239
|
}
|
|
16238
16240
|
/**
|
|
16239
16241
|
* Generate the Chat / API URL
|
|
@@ -16692,7 +16694,8 @@ const defaultState = {
|
|
|
16692
16694
|
chatterInLiveChat: false,
|
|
16693
16695
|
adaSettings: {},
|
|
16694
16696
|
wasCampaignShownButNowClosed: false,
|
|
16695
|
-
proactiveCampaignHadMessages: false
|
|
16697
|
+
proactiveCampaignHadMessages: false,
|
|
16698
|
+
deviceToken: null
|
|
16696
16699
|
};
|
|
16697
16700
|
;// CONCATENATED MODULE: ./src/client/store/index.ts
|
|
16698
16701
|
|
|
@@ -17367,6 +17370,36 @@ function checkRollout(rollout, handle) {
|
|
|
17367
17370
|
|
|
17368
17371
|
return true;
|
|
17369
17372
|
}
|
|
17373
|
+
;// CONCATENATED MODULE: ./src/client/helpers/web-notifications/web-notification-events.ts
|
|
17374
|
+
let WebNotificationEvents;
|
|
17375
|
+
|
|
17376
|
+
(function (WebNotificationEvents) {
|
|
17377
|
+
WebNotificationEvents["NOTIFICATION_CLICK"] = "ada:web_notification:click";
|
|
17378
|
+
})(WebNotificationEvents || (WebNotificationEvents = {}));
|
|
17379
|
+
;// CONCATENATED MODULE: ./src/client/helpers/web-notifications/index.ts
|
|
17380
|
+
|
|
17381
|
+
|
|
17382
|
+
function handleWebNotificationClick(data) {
|
|
17383
|
+
if (data.type === WebNotificationEvents.NOTIFICATION_CLICK) {
|
|
17384
|
+
var _window$adaEmbed;
|
|
17385
|
+
|
|
17386
|
+
(_window$adaEmbed = window.adaEmbed) === null || _window$adaEmbed === void 0 ? void 0 : _window$adaEmbed.handleNotification();
|
|
17387
|
+
}
|
|
17388
|
+
} // the Firebase client will post messages to the host page running the bot.
|
|
17389
|
+
// the messages will contain event data that embed would need to take action on
|
|
17390
|
+
// such as handling what happens when the notification is clicked
|
|
17391
|
+
|
|
17392
|
+
|
|
17393
|
+
function addServiceWorkerListeners() {
|
|
17394
|
+
if ("serviceWorker" in navigator) {
|
|
17395
|
+
navigator.serviceWorker.addEventListener("message", event => {
|
|
17396
|
+
const {
|
|
17397
|
+
data
|
|
17398
|
+
} = event;
|
|
17399
|
+
handleWebNotificationClick(data);
|
|
17400
|
+
});
|
|
17401
|
+
}
|
|
17402
|
+
}
|
|
17370
17403
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/assign.js
|
|
17371
17404
|
var object_assign = __webpack_require__(2088);
|
|
17372
17405
|
;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/extends.js
|
|
@@ -17758,9 +17791,9 @@ async function log(message, extra, options) {
|
|
|
17758
17791
|
service: "embed",
|
|
17759
17792
|
env: "production",
|
|
17760
17793
|
embedVersion: 2,
|
|
17761
|
-
version: "1.
|
|
17794
|
+
version: "1.2.0",
|
|
17762
17795
|
isNpm: true,
|
|
17763
|
-
commitHash: "
|
|
17796
|
+
commitHash: "1e8cda1"
|
|
17764
17797
|
}))
|
|
17765
17798
|
});
|
|
17766
17799
|
}
|
|
@@ -18165,7 +18198,7 @@ class ChatFrame extends d {
|
|
|
18165
18198
|
const hostPageUrlParams = new (url_default())(window.location.href).searchParams;
|
|
18166
18199
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
18167
18200
|
const queryParams = {
|
|
18168
|
-
embedVersion: "
|
|
18201
|
+
embedVersion: "1e8cda1".slice(0, 7),
|
|
18169
18202
|
greeting,
|
|
18170
18203
|
language,
|
|
18171
18204
|
skipGreeting,
|
|
@@ -19042,6 +19075,7 @@ function Container_objectSpread(target) { for (var i = 1; i < arguments.length;
|
|
|
19042
19075
|
|
|
19043
19076
|
|
|
19044
19077
|
|
|
19078
|
+
|
|
19045
19079
|
|
|
19046
19080
|
|
|
19047
19081
|
class Container extends d {
|
|
@@ -19099,6 +19133,7 @@ class Container extends d {
|
|
|
19099
19133
|
this.initialize();
|
|
19100
19134
|
this.notificationPermHandler();
|
|
19101
19135
|
bindLocationChangeOverrides();
|
|
19136
|
+
addServiceWorkerListeners();
|
|
19102
19137
|
window.addEventListener("locationchange", this.locationChangeHandlerBound);
|
|
19103
19138
|
}
|
|
19104
19139
|
/** To be called when `props.appConnectionState` value changes */
|
|
@@ -19684,6 +19719,21 @@ class Container extends d {
|
|
|
19684
19719
|
break;
|
|
19685
19720
|
}
|
|
19686
19721
|
|
|
19722
|
+
case SET_DEVICE_TOKEN:
|
|
19723
|
+
{
|
|
19724
|
+
const {
|
|
19725
|
+
setState
|
|
19726
|
+
} = this.props;
|
|
19727
|
+
const {
|
|
19728
|
+
token
|
|
19729
|
+
} = payload;
|
|
19730
|
+
await setState({
|
|
19731
|
+
deviceToken: token
|
|
19732
|
+
});
|
|
19733
|
+
localChannel.postMessage(SET_DEVICE_TOKEN_RESPONSE, null, id);
|
|
19734
|
+
break;
|
|
19735
|
+
}
|
|
19736
|
+
|
|
19687
19737
|
default:
|
|
19688
19738
|
{// Do nothing
|
|
19689
19739
|
}
|
|
@@ -20283,9 +20333,16 @@ class Embed {
|
|
|
20283
20333
|
await this.localChannel.fetch(CLOSE_CAMPAIGN, CLOSE_CAMPAIGN_RESPONSE);
|
|
20284
20334
|
}
|
|
20285
20335
|
|
|
20336
|
+
async setDeviceToken(token) {
|
|
20337
|
+
await this.initialized;
|
|
20338
|
+
await this.localChannel.fetch(SET_DEVICE_TOKEN, SET_DEVICE_TOKEN_RESPONSE, {
|
|
20339
|
+
token
|
|
20340
|
+
});
|
|
20341
|
+
}
|
|
20342
|
+
|
|
20286
20343
|
}
|
|
20287
20344
|
|
|
20288
|
-
_defineProperty(Embed, "embed2Version", "
|
|
20345
|
+
_defineProperty(Embed, "embed2Version", "1e8cda1");
|
|
20289
20346
|
;// CONCATENATED MODULE: ./src/common/helpers/startup.ts
|
|
20290
20347
|
|
|
20291
20348
|
|
|
@@ -20431,6 +20488,28 @@ function createEmbedObject() {
|
|
|
20431
20488
|
|
|
20432
20489
|
await waitForEmbedInit();
|
|
20433
20490
|
return (_embed12 = embed) === null || _embed12 === void 0 ? void 0 : _embed12.closeCampaign();
|
|
20491
|
+
},
|
|
20492
|
+
setDeviceToken: async token => {
|
|
20493
|
+
var _embed13;
|
|
20494
|
+
|
|
20495
|
+
await waitForEmbedInit();
|
|
20496
|
+
return (_embed13 = embed) === null || _embed13 === void 0 ? void 0 : _embed13.setDeviceToken(token);
|
|
20497
|
+
},
|
|
20498
|
+
handleNotification: async () => {
|
|
20499
|
+
var _embed14;
|
|
20500
|
+
|
|
20501
|
+
await waitForEmbedInit();
|
|
20502
|
+
const windowInfo = await ((_embed14 = embed) === null || _embed14 === void 0 ? void 0 : _embed14.getInfo());
|
|
20503
|
+
|
|
20504
|
+
if (!windowInfo) {
|
|
20505
|
+
return;
|
|
20506
|
+
}
|
|
20507
|
+
|
|
20508
|
+
if (!windowInfo.isChatOpen) {
|
|
20509
|
+
var _embed15;
|
|
20510
|
+
|
|
20511
|
+
(_embed15 = embed) === null || _embed15 === void 0 ? void 0 : _embed15.toggle();
|
|
20512
|
+
}
|
|
20434
20513
|
}
|
|
20435
20514
|
});
|
|
20436
20515
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ada-support/embed2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/npm-entry",
|
|
6
6
|
"typings": "dist/npm-entry/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"author": "",
|
|
46
46
|
"license": "ISC",
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@ada-support/embed-types": "^1.0
|
|
48
|
+
"@ada-support/embed-types": "^1.1.0",
|
|
49
49
|
"@ada-support/eslint-config-ada": "^1.2.1",
|
|
50
50
|
"@testing-library/preact": "^2.0.1",
|
|
51
51
|
"@types/enzyme": "^3.10.11",
|