@segment/analytics-browser-actions-braze 1.0.0 → 1.3.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/.eslintcache +1 -0
- package/dist/cjs/braze-types.d.ts +7 -0
- package/dist/cjs/braze-types.js +3 -0
- package/dist/cjs/braze-types.js.map +1 -0
- package/dist/cjs/debounce/generated-types.d.ts +2 -0
- package/dist/cjs/debounce/generated-types.js +3 -0
- package/dist/cjs/debounce/generated-types.js.map +1 -0
- package/dist/cjs/debounce/index.d.ts +7 -0
- package/dist/cjs/debounce/index.js +48 -0
- package/dist/cjs/debounce/index.js.map +1 -0
- package/dist/cjs/generated-types.d.ts +27 -0
- package/dist/cjs/generated-types.js +3 -0
- package/dist/cjs/generated-types.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +304 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/trackEvent/generated-types.d.ts +6 -0
- package/dist/cjs/trackEvent/generated-types.js +3 -0
- package/dist/cjs/trackEvent/generated-types.js.map +1 -0
- package/dist/cjs/trackEvent/index.d.ts +6 -0
- package/dist/cjs/trackEvent/index.js +36 -0
- package/dist/cjs/trackEvent/index.js.map +1 -0
- package/dist/cjs/trackPurchase/generated-types.d.ts +11 -0
- package/dist/cjs/trackPurchase/generated-types.js +3 -0
- package/dist/cjs/trackPurchase/generated-types.js.map +1 -0
- package/dist/cjs/trackPurchase/index.d.ts +6 -0
- package/dist/cjs/trackPurchase/index.js +70 -0
- package/dist/cjs/trackPurchase/index.js.map +1 -0
- package/dist/cjs/updateUserProfile/generated-types.d.ts +23 -0
- package/dist/cjs/updateUserProfile/generated-types.js +3 -0
- package/dist/cjs/updateUserProfile/generated-types.js.map +1 -0
- package/dist/cjs/updateUserProfile/index.d.ts +6 -0
- package/dist/cjs/updateUserProfile/index.js +206 -0
- package/dist/cjs/updateUserProfile/index.js.map +1 -0
- package/dist/esm/braze-types.d.ts +7 -0
- package/dist/esm/braze-types.js +2 -0
- package/dist/esm/braze-types.js.map +1 -0
- package/dist/esm/debounce/generated-types.d.ts +2 -0
- package/dist/esm/debounce/generated-types.js +2 -0
- package/dist/esm/debounce/generated-types.js.map +1 -0
- package/dist/esm/debounce/index.d.ts +7 -0
- package/dist/esm/debounce/index.js +44 -0
- package/dist/esm/debounce/index.js.map +1 -0
- package/dist/esm/generated-types.d.ts +27 -0
- package/dist/esm/generated-types.js +2 -0
- package/dist/esm/generated-types.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +300 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/trackEvent/generated-types.d.ts +6 -0
- package/dist/esm/trackEvent/generated-types.js +2 -0
- package/dist/esm/trackEvent/generated-types.js.map +1 -0
- package/dist/esm/trackEvent/index.d.ts +6 -0
- package/dist/esm/trackEvent/index.js +34 -0
- package/dist/esm/trackEvent/index.js.map +1 -0
- package/dist/esm/trackPurchase/generated-types.d.ts +11 -0
- package/dist/esm/trackPurchase/generated-types.js +2 -0
- package/dist/esm/trackPurchase/generated-types.js.map +1 -0
- package/dist/esm/trackPurchase/index.d.ts +6 -0
- package/dist/esm/trackPurchase/index.js +68 -0
- package/dist/esm/trackPurchase/index.js.map +1 -0
- package/dist/esm/updateUserProfile/generated-types.d.ts +23 -0
- package/dist/esm/updateUserProfile/generated-types.js +2 -0
- package/dist/esm/updateUserProfile/generated-types.js.map +1 -0
- package/dist/esm/updateUserProfile/index.d.ts +6 -0
- package/dist/esm/updateUserProfile/index.js +203 -0
- package/dist/esm/updateUserProfile/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +5 -4
package/.eslintcache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"/home/kaari/action-destinations/packages/browser-destinations/destinations/braze/src/braze-types.ts":"1","/home/kaari/action-destinations/packages/browser-destinations/destinations/braze/src/generated-types.ts":"2","/home/kaari/action-destinations/packages/browser-destinations/destinations/braze/src/index.ts":"3"},{"size":225,"mtime":1686339431090,"results":"4","hashOfConfig":"5"},{"size":6519,"mtime":1686339431090,"results":"6","hashOfConfig":"5"},{"size":14548,"mtime":1686339475050,"results":"7","hashOfConfig":"5"},{"filePath":"8","messages":"9","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"9mz8gd",{"filePath":"10","messages":"11","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"12","messages":"13","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/kaari/action-destinations/packages/browser-destinations/destinations/braze/src/braze-types.ts",[],"/home/kaari/action-destinations/packages/browser-destinations/destinations/braze/src/generated-types.ts",[],"/home/kaari/action-destinations/packages/browser-destinations/destinations/braze/src/index.ts",[]]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"braze-types.js","sourceRoot":"","sources":["../../src/braze-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/debounce/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BrazeDestinationClient } from '../braze-types';
|
|
2
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
export declare function resetUserCache(): void;
|
|
6
|
+
declare const action: BrowserActionDefinition<Settings, BrazeDestinationClient, Payload>;
|
|
7
|
+
export default action;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetUserCache = void 0;
|
|
4
|
+
let cachedUser = {
|
|
5
|
+
id: undefined,
|
|
6
|
+
anonymousId: undefined,
|
|
7
|
+
traits: null
|
|
8
|
+
};
|
|
9
|
+
function resetUserCache() {
|
|
10
|
+
cachedUser = {
|
|
11
|
+
id: undefined,
|
|
12
|
+
anonymousId: undefined,
|
|
13
|
+
traits: null
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.resetUserCache = resetUserCache;
|
|
17
|
+
function shouldSendToBraze(event) {
|
|
18
|
+
if (event.userId && event.userId !== cachedUser.id) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
if (event.anonymousId && event.anonymousId !== cachedUser.anonymousId) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const traits = event.traits ?? {};
|
|
25
|
+
return JSON.stringify(cachedUser.traits) !== JSON.stringify(traits);
|
|
26
|
+
}
|
|
27
|
+
const action = {
|
|
28
|
+
title: 'Debounce Middleware',
|
|
29
|
+
description: 'When enabled, it ensures that only events where at least one changed trait value are sent to Braze, and events with duplicate traits are not sent. Debounce functionality requires a frontend client to work. Therefore, it cannot be used with server-side libraries or with Engage.',
|
|
30
|
+
platform: 'web',
|
|
31
|
+
defaultSubscription: 'type = "identify" or type = "group"',
|
|
32
|
+
fields: {},
|
|
33
|
+
lifecycleHook: 'before',
|
|
34
|
+
perform: (_client, data) => {
|
|
35
|
+
const event = data.context.event;
|
|
36
|
+
const analyticsUser = data.analytics.user();
|
|
37
|
+
const ctx = data.context;
|
|
38
|
+
const shouldSend = shouldSendToBraze(event);
|
|
39
|
+
ctx.updateEvent('integrations.Braze Web Mode (Actions)', shouldSend);
|
|
40
|
+
ctx.updateEvent('integrations.Braze Cloud Mode (Actions)', shouldSend);
|
|
41
|
+
ctx.updateEvent('integrations.Appboy', shouldSend);
|
|
42
|
+
cachedUser.id = analyticsUser.id();
|
|
43
|
+
cachedUser.anonymousId = analyticsUser.anonymousId();
|
|
44
|
+
cachedUser.traits = analyticsUser.traits();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.default = action;
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/debounce/index.ts"],"names":[],"mappings":";;;AAYA,IAAI,UAAU,GAAe;IAC3B,EAAE,EAAE,SAAS;IACb,WAAW,EAAE,SAAS;IACtB,MAAM,EAAE,IAAI;CACb,CAAA;AAED,SAAgB,cAAc;IAC5B,UAAU,GAAG;QACX,EAAE,EAAE,SAAS;QACb,WAAW,EAAE,SAAS;QACtB,MAAM,EAAE,IAAI;KACb,CAAA;AACH,CAAC;AAND,wCAMC;AAED,SAAS,iBAAiB,CAAC,KAAmB;IAC5C,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU,CAAC,EAAE,EAAE;QAClD,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW,EAAE;QACrE,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAA;IACjC,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;AACrE,CAAC;AAED,MAAM,MAAM,GAAuE;IACjF,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EACT,uRAAuR;IACzR,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,qCAAqC;IAC1D,MAAM,EAAE,EAAE;IACV,aAAa,EAAE,QAAQ;IACvB,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAA;QAIxB,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA;QAC3C,GAAG,CAAC,WAAW,CAAC,uCAAuC,EAAE,UAAU,CAAC,CAAA;QACpE,GAAG,CAAC,WAAW,CAAC,yCAAyC,EAAE,UAAU,CAAC,CAAA;QACtE,GAAG,CAAC,WAAW,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAA;QAGlD,UAAU,CAAC,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,CAAA;QAClC,UAAU,CAAC,WAAW,GAAG,aAAa,CAAC,WAAW,EAAE,CAAA;QACpD,UAAU,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,CAAA;IAC5C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface Settings {
|
|
2
|
+
sdkVersion: string;
|
|
3
|
+
api_key: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
allowCrawlerActivity?: boolean;
|
|
6
|
+
allowUserSuppliedJavascript?: boolean;
|
|
7
|
+
deferUntilIdentified?: boolean;
|
|
8
|
+
appVersion?: string;
|
|
9
|
+
contentSecurityNonce?: string;
|
|
10
|
+
devicePropertyAllowlist?: string[];
|
|
11
|
+
disablePushTokenMaintenance?: boolean;
|
|
12
|
+
doNotLoadFontAwesome?: boolean;
|
|
13
|
+
enableLogging?: boolean;
|
|
14
|
+
enableSdkAuthentication?: boolean;
|
|
15
|
+
inAppMessageZIndex?: number;
|
|
16
|
+
localization?: string;
|
|
17
|
+
automaticallyDisplayMessages?: boolean;
|
|
18
|
+
manageServiceWorkerExternally?: boolean;
|
|
19
|
+
minimumIntervalBetweenTriggerActionsInSeconds?: number;
|
|
20
|
+
noCookies?: boolean;
|
|
21
|
+
openCardsInNewTab?: boolean;
|
|
22
|
+
openInAppMessagesInNewTab?: boolean;
|
|
23
|
+
requireExplicitInAppMessageDismissal?: boolean;
|
|
24
|
+
safariWebsitePushId?: string;
|
|
25
|
+
serviceWorkerLocation?: string;
|
|
26
|
+
sessionTimeoutInSeconds?: number;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Settings } from './generated-types';
|
|
2
|
+
import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
+
import type braze from '@braze/web-sdk';
|
|
4
|
+
import type appboy from '@braze/web-sdk-v3';
|
|
5
|
+
import { BrazeDestinationClient } from './braze-types';
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
braze: typeof braze;
|
|
9
|
+
appboy: typeof appboy;
|
|
10
|
+
BRAZE_BASE_URL?: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare const destination: BrowserDestinationDefinition<Settings, BrazeDestinationClient>;
|
|
14
|
+
declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.destination = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const shim_1 = require("@segment/browser-destination-runtime/shim");
|
|
6
|
+
const trackEvent_1 = tslib_1.__importDefault(require("./trackEvent"));
|
|
7
|
+
const updateUserProfile_1 = tslib_1.__importDefault(require("./updateUserProfile"));
|
|
8
|
+
const trackPurchase_1 = tslib_1.__importDefault(require("./trackPurchase"));
|
|
9
|
+
const debounce_1 = tslib_1.__importStar(require("./debounce"));
|
|
10
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
11
|
+
const defaultVersion = '4.6';
|
|
12
|
+
const presets = [
|
|
13
|
+
{
|
|
14
|
+
name: 'Identify Calls',
|
|
15
|
+
subscribe: 'type = "identify" or type = "group"',
|
|
16
|
+
partnerAction: 'updateUserProfile',
|
|
17
|
+
mapping: actions_core_1.defaultValues(updateUserProfile_1.default.fields)
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Order Completed calls',
|
|
21
|
+
subscribe: 'type = "track" and event = "Order Completed"',
|
|
22
|
+
partnerAction: 'trackPurchase',
|
|
23
|
+
mapping: actions_core_1.defaultValues(trackPurchase_1.default.fields)
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Track Calls',
|
|
27
|
+
subscribe: 'type = "track" and event != "Order Completed"',
|
|
28
|
+
partnerAction: 'trackEvent',
|
|
29
|
+
mapping: {
|
|
30
|
+
...actions_core_1.defaultValues(trackEvent_1.default.fields),
|
|
31
|
+
eventName: {
|
|
32
|
+
'@path': '$.event'
|
|
33
|
+
},
|
|
34
|
+
eventProperties: {
|
|
35
|
+
'@path': '$.properties'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
exports.destination = {
|
|
41
|
+
name: 'Braze Web Mode (Actions)',
|
|
42
|
+
slug: 'actions-braze-web',
|
|
43
|
+
mode: 'device',
|
|
44
|
+
settings: {
|
|
45
|
+
sdkVersion: {
|
|
46
|
+
description: 'The version of the Braze SDK to use',
|
|
47
|
+
label: 'SDK Version',
|
|
48
|
+
type: 'string',
|
|
49
|
+
choices: [
|
|
50
|
+
{
|
|
51
|
+
value: '3.1',
|
|
52
|
+
label: '3.1'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
value: '3.3',
|
|
56
|
+
label: '3.3'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: '3.5',
|
|
60
|
+
label: '3.5'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: '4.1',
|
|
64
|
+
label: '4.1'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
value: '4.6',
|
|
68
|
+
label: '4.6'
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
default: defaultVersion,
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
api_key: {
|
|
75
|
+
description: 'Found in the Braze Dashboard under Manage Settings → Apps → Web',
|
|
76
|
+
label: 'API Key',
|
|
77
|
+
type: 'string',
|
|
78
|
+
required: true
|
|
79
|
+
},
|
|
80
|
+
endpoint: {
|
|
81
|
+
label: 'SDK Endpoint',
|
|
82
|
+
description: 'Your Braze SDK endpoint. [See more details](https://www.braze.com/docs/user_guide/administrative/access_braze/sdk_endpoints/)',
|
|
83
|
+
type: 'string',
|
|
84
|
+
format: 'uri',
|
|
85
|
+
choices: [
|
|
86
|
+
{ label: 'US-01 (https://dashboard-01.braze.com)', value: 'sdk.iad-01.braze.com' },
|
|
87
|
+
{ label: 'US-02 (https://dashboard-02.braze.com)', value: 'sdk.iad-02.braze.com' },
|
|
88
|
+
{ label: 'US-03 (https://dashboard-03.braze.com)', value: 'sdk.iad-03.braze.com' },
|
|
89
|
+
{ label: 'US-04 (https://dashboard-04.braze.com)', value: 'sdk.iad-04.braze.com' },
|
|
90
|
+
{ label: 'US-05 (https://dashboard-05.braze.com)', value: 'sdk.iad-05.braze.com' },
|
|
91
|
+
{ label: 'US-06 (https://dashboard-06.braze.com)', value: 'sdk.iad-06.braze.com' },
|
|
92
|
+
{ label: 'US-08 (https://dashboard-08.braze.com)', value: 'sdk.iad-08.braze.com' },
|
|
93
|
+
{ label: 'EU-01 (https://dashboard-01.braze.eu)', value: 'sdk.fra-01.braze.eu' },
|
|
94
|
+
{ label: 'EU-02 (https://dashboard-02.braze.eu)', value: 'sdk.fra-02.braze.eu' }
|
|
95
|
+
],
|
|
96
|
+
default: 'sdk.iad-01.braze.com',
|
|
97
|
+
required: true
|
|
98
|
+
},
|
|
99
|
+
allowCrawlerActivity: {
|
|
100
|
+
description: 'Allow Braze to log activity from crawlers. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)',
|
|
101
|
+
label: 'Allow Crawler Activity',
|
|
102
|
+
default: false,
|
|
103
|
+
type: 'boolean',
|
|
104
|
+
required: false
|
|
105
|
+
},
|
|
106
|
+
allowUserSuppliedJavascript: {
|
|
107
|
+
description: 'To indicate that you trust the Braze dashboard users to write non-malicious Javascript click actions, set this property to true. If enableHtmlInAppMessages is true, this option will also be set to true. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)',
|
|
108
|
+
label: 'Allow User Supplied Javascript',
|
|
109
|
+
default: false,
|
|
110
|
+
type: 'boolean',
|
|
111
|
+
required: false
|
|
112
|
+
},
|
|
113
|
+
deferUntilIdentified: {
|
|
114
|
+
description: 'If enabled, this setting delays initialization of the Braze SDK until the user has been identified. When enabled, events for anonymous users will no longer be sent to Braze.',
|
|
115
|
+
label: 'Only Track Known Users',
|
|
116
|
+
default: false,
|
|
117
|
+
type: 'boolean',
|
|
118
|
+
required: false
|
|
119
|
+
},
|
|
120
|
+
appVersion: {
|
|
121
|
+
description: 'Version to which user events sent to Braze will be associated with. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)',
|
|
122
|
+
label: 'App Version',
|
|
123
|
+
type: 'string',
|
|
124
|
+
required: false
|
|
125
|
+
},
|
|
126
|
+
contentSecurityNonce: {
|
|
127
|
+
description: 'Allows Braze to add the nonce to any <script> and <style> elements created by the SDK. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)',
|
|
128
|
+
label: 'Content Security nonce',
|
|
129
|
+
type: 'string',
|
|
130
|
+
required: false
|
|
131
|
+
},
|
|
132
|
+
devicePropertyAllowlist: {
|
|
133
|
+
label: 'Device Property Allow List',
|
|
134
|
+
description: 'By default, the Braze SDK automatically detects and collects all device properties in DeviceProperties. To override this behavior, provide an array of DeviceProperties. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)',
|
|
135
|
+
type: 'string',
|
|
136
|
+
required: false,
|
|
137
|
+
multiple: true
|
|
138
|
+
},
|
|
139
|
+
disablePushTokenMaintenance: {
|
|
140
|
+
label: 'Disable Push Token Maintenance',
|
|
141
|
+
type: 'boolean',
|
|
142
|
+
default: false,
|
|
143
|
+
required: false,
|
|
144
|
+
description: 'By default, users who have already granted web push permission will sync their push token with the Braze backend automatically on new session to ensure deliverability. To disable this behavior, set this option to true'
|
|
145
|
+
},
|
|
146
|
+
doNotLoadFontAwesome: {
|
|
147
|
+
label: 'Do Not Load Font Awesome',
|
|
148
|
+
type: 'boolean',
|
|
149
|
+
default: false,
|
|
150
|
+
description: 'Braze automatically loads FontAwesome 4.7.0 from the FontAwesome CDN. To disable this behavior set this option to true.'
|
|
151
|
+
},
|
|
152
|
+
enableLogging: {
|
|
153
|
+
label: 'Enable Logging',
|
|
154
|
+
required: false,
|
|
155
|
+
default: false,
|
|
156
|
+
type: 'boolean',
|
|
157
|
+
description: 'Set to true to enable logging by default'
|
|
158
|
+
},
|
|
159
|
+
enableSdkAuthentication: {
|
|
160
|
+
label: 'Enable SDK Authentication',
|
|
161
|
+
type: 'boolean',
|
|
162
|
+
required: false,
|
|
163
|
+
default: false,
|
|
164
|
+
description: 'Set to true to enable the SDK Authentication feature.'
|
|
165
|
+
},
|
|
166
|
+
inAppMessageZIndex: {
|
|
167
|
+
label: 'In-App Message Z Index',
|
|
168
|
+
type: 'number',
|
|
169
|
+
required: false,
|
|
170
|
+
description: "By default, the Braze SDK will show In-App Messages with a z-index of 1040 for the screen overlay, 1050 for the actual in-app message, and 1060 for the message's close button. Provide a value for this option to override these default z-indexes."
|
|
171
|
+
},
|
|
172
|
+
localization: {
|
|
173
|
+
label: 'Localization',
|
|
174
|
+
type: 'string',
|
|
175
|
+
default: 'en',
|
|
176
|
+
required: false,
|
|
177
|
+
description: "By default, any SDK-generated user-visible messages will be displayed in the user's browser language. Provide a value for this option to override that behavior and force a specific language. The value for this option should be a ISO 639-1 Language Code."
|
|
178
|
+
},
|
|
179
|
+
automaticallyDisplayMessages: {
|
|
180
|
+
label: 'Automatically Send In-App Messages',
|
|
181
|
+
type: 'boolean',
|
|
182
|
+
default: true,
|
|
183
|
+
required: false,
|
|
184
|
+
description: "When this is enabled, all In-App Messages that a user is eligible for are automatically delivered to the user. If you'd like to register your own display subscribers or send soft push notifications to your users, make sure to disable this option."
|
|
185
|
+
},
|
|
186
|
+
manageServiceWorkerExternally: {
|
|
187
|
+
label: 'Manage Service Worker Externally',
|
|
188
|
+
type: 'boolean',
|
|
189
|
+
default: false,
|
|
190
|
+
required: false,
|
|
191
|
+
description: 'If you have your own service worker that you register and control the lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)'
|
|
192
|
+
},
|
|
193
|
+
minimumIntervalBetweenTriggerActionsInSeconds: {
|
|
194
|
+
label: 'Minimum Interval Between Trigger Actions in Seconds',
|
|
195
|
+
type: 'number',
|
|
196
|
+
required: false,
|
|
197
|
+
default: 30,
|
|
198
|
+
description: 'Provide a value to override the default interval between trigger actions with a value of your own. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)'
|
|
199
|
+
},
|
|
200
|
+
noCookies: {
|
|
201
|
+
label: 'No Cookies',
|
|
202
|
+
type: 'boolean',
|
|
203
|
+
default: false,
|
|
204
|
+
required: false,
|
|
205
|
+
description: 'By default, the Braze SDK will store small amounts of data (user ids, session ids), in cookies. Pass true for this option to disable cookie storage and rely entirely on HTML 5 localStorage to identify users and sessions. [See more details](https://js.appboycdn.com/web-sdk/latest/doc/modules/appboy.html#initializationoptions)'
|
|
206
|
+
},
|
|
207
|
+
openCardsInNewTab: {
|
|
208
|
+
label: 'Open Cards In New Tab',
|
|
209
|
+
type: 'boolean',
|
|
210
|
+
default: false,
|
|
211
|
+
required: false,
|
|
212
|
+
description: 'By default, links from Card objects load in the current tab or window. Set this option to true to make links from cards open in a new tab or window.'
|
|
213
|
+
},
|
|
214
|
+
openInAppMessagesInNewTab: {
|
|
215
|
+
label: 'Open In-App Messages In New Tab',
|
|
216
|
+
type: 'boolean',
|
|
217
|
+
default: false,
|
|
218
|
+
required: false,
|
|
219
|
+
description: 'By default, links from in-app message clicks load in the current tab or a new tab as specified in the dashboard on a message-by-message basis. Set this option to true to force all links from in-app message clicks open in a new tab or window.'
|
|
220
|
+
},
|
|
221
|
+
requireExplicitInAppMessageDismissal: {
|
|
222
|
+
label: 'Require Explicit In-App Message Dismissal',
|
|
223
|
+
type: 'boolean',
|
|
224
|
+
required: false,
|
|
225
|
+
default: false,
|
|
226
|
+
description: 'By default, when an in-app message is showing, pressing the escape button or a click on the greyed-out background of the page will dismiss the message. Set this option to true to prevent this behavior and require an explicit button click to dismiss messages.'
|
|
227
|
+
},
|
|
228
|
+
safariWebsitePushId: {
|
|
229
|
+
label: 'Safari Website Push ID',
|
|
230
|
+
type: 'string',
|
|
231
|
+
required: false,
|
|
232
|
+
description: 'If you support Safari push, you must specify this option with the website push ID that you provided to Apple when creating your Safari push certificate (starts with "web", e.g. "web.com.example.domain").'
|
|
233
|
+
},
|
|
234
|
+
serviceWorkerLocation: {
|
|
235
|
+
label: 'Service Worker Location',
|
|
236
|
+
type: 'string',
|
|
237
|
+
required: false,
|
|
238
|
+
description: 'By default, when registering users for web push notifications Braze will look for the required service worker file in the root directory of your web server at /service-worker.js. If you want to host your service worker at a different path on that server, provide a value for this option that is the absolute path to the file, e.g. /mycustompath/my-worker.js. VERY IMPORTANT: setting a value here limits the scope of push notifications on your site. For instance, in the above example, because the service ,worker file is located within the /mycustompath/ directory, appboy.registerAppboyPushMessages MAY ONLY BE CALLED from web pages that start with http://yoursite.com/mycustompath/.'
|
|
239
|
+
},
|
|
240
|
+
sessionTimeoutInSeconds: {
|
|
241
|
+
label: 'Session Timeout in Seconds',
|
|
242
|
+
type: 'number',
|
|
243
|
+
default: 1800,
|
|
244
|
+
required: false,
|
|
245
|
+
description: 'By default, sessions time out after 30 minutes of inactivity. Provide a value for this configuration option to override that default with a value of your own.'
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
initialize: async ({ settings, analytics }, dependencies) => {
|
|
249
|
+
try {
|
|
250
|
+
const { endpoint, api_key, sdkVersion, automaticallyDisplayMessages, versionSettings, subscriptions, deferUntilIdentified, ...expectedConfig } = settings;
|
|
251
|
+
const version = sdkVersion ?? defaultVersion;
|
|
252
|
+
debounce_1.resetUserCache();
|
|
253
|
+
if (version.indexOf('3.') === 0) {
|
|
254
|
+
await dependencies.loadScript(`https://js.appboycdn.com/web-sdk/${version}/appboy.no-amd.min.js`);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
await dependencies.loadScript(`https://js.appboycdn.com/web-sdk/${version}/braze.no-module.min.js`);
|
|
258
|
+
}
|
|
259
|
+
let initialized = false;
|
|
260
|
+
const client = {
|
|
261
|
+
instance: version.indexOf('3.') === 0 ? window.appboy : window.braze,
|
|
262
|
+
ready: () => {
|
|
263
|
+
if (initialized) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
if (deferUntilIdentified && typeof analytics.user().id() !== 'string') {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
client.instance.initialize(api_key, {
|
|
270
|
+
baseUrl: window.BRAZE_BASE_URL || endpoint,
|
|
271
|
+
...expectedConfig
|
|
272
|
+
});
|
|
273
|
+
if (typeof client.instance.addSdkMetadata === 'function') {
|
|
274
|
+
client.instance.addSdkMetadata([client.instance.BrazeSdkMetadata.SEGMENT]);
|
|
275
|
+
}
|
|
276
|
+
if (automaticallyDisplayMessages) {
|
|
277
|
+
if ('display' in client.instance) {
|
|
278
|
+
client.instance.display.automaticallyShowNewInAppMessages();
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
client.instance.automaticallyShowInAppMessages();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
client.instance.openSession();
|
|
285
|
+
return (initialized = true);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
client.ready();
|
|
289
|
+
return client;
|
|
290
|
+
}
|
|
291
|
+
catch (e) {
|
|
292
|
+
throw new Error(`Failed to initialize Braze ${e}`);
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
presets,
|
|
296
|
+
actions: {
|
|
297
|
+
updateUserProfile: updateUserProfile_1.default,
|
|
298
|
+
trackEvent: trackEvent_1.default,
|
|
299
|
+
trackPurchase: trackPurchase_1.default,
|
|
300
|
+
debounce: debounce_1.default
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
exports.default = shim_1.browserDestination(exports.destination);
|
|
304
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAG9E,sEAAqC;AACrC,oFAAmD;AACnD,4EAA2C;AAC3C,+DAAqD;AACrD,wDAA4E;AAW5E,MAAM,cAAc,GAAG,KAAK,CAAA;AAE5B,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,qCAAqC;QAChD,aAAa,EAAE,mBAAmB;QAClC,OAAO,EAAE,4BAAa,CAAC,2BAAiB,CAAC,MAAM,CAAC;KACjD;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,SAAS,EAAE,8CAA8C;QACzD,aAAa,EAAE,eAAe;QAC9B,OAAO,EAAE,4BAAa,CAAC,uBAAa,CAAC,MAAM,CAAC;KAC7C;IACD;QACE,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,+CAA+C;QAC1D,aAAa,EAAE,YAAY;QAC3B,OAAO,EAAE;YACP,GAAG,4BAAa,CAAC,oBAAU,CAAC,MAAM,CAAC;YACnC,SAAS,EAAE;gBACT,OAAO,EAAE,SAAS;aACnB;YACD,eAAe,EAAE;gBACf,OAAO,EAAE,cAAc;aACxB;SACF;KACF;CACF,CAAA;AAEY,QAAA,WAAW,GAAmE;IACzF,IAAI,EAAE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BAE7B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;gBAC7B,CAAC;aACF,CAAA;YAED,MAAM,CAAC,KAAK,EAAE,CAAA;YAEd,OAAO,MAAM,CAAA;SACd;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,EAAE,CAAC,CAAA;SACnD;IACH,CAAC;IACD,OAAO;IACP,OAAO,EAAE;QACP,iBAAiB,EAAjB,2BAAiB;QACjB,UAAU,EAAV,oBAAU;QACV,aAAa,EAAb,uBAAa;QACb,QAAQ,EAAR,kBAAQ;KACT;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/trackEvent/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import type { Settings } from '../generated-types';
|
|
3
|
+
import type { Payload } from './generated-types';
|
|
4
|
+
import { BrazeDestinationClient } from '../braze-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, BrazeDestinationClient, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const action = {
|
|
4
|
+
title: 'Track Event',
|
|
5
|
+
description: 'Reports that the current user performed a custom named event.',
|
|
6
|
+
defaultSubscription: 'type = "track" and event != "Order Completed"',
|
|
7
|
+
platform: 'web',
|
|
8
|
+
fields: {
|
|
9
|
+
eventName: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
required: true,
|
|
12
|
+
description: 'The identifier for the event to track.',
|
|
13
|
+
label: 'Event Name',
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.event'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
eventProperties: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: false,
|
|
21
|
+
description: 'Hash of properties for this event.',
|
|
22
|
+
label: 'Event Properties',
|
|
23
|
+
default: {
|
|
24
|
+
'@path': '$.properties'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
perform: (client, event) => {
|
|
29
|
+
if (!client.ready()) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
client.instance.logCustomEvent(event.payload.eventName, event.payload.eventProperties);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.default = action;
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trackEvent/index.ts"],"names":[],"mappings":";;AAKA,MAAM,MAAM,GAAuE;IACjF,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,+DAA+D;IAC5E,mBAAmB,EAAE,+CAA+C;IACpE,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,wCAAwC;YACrD,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE;gBACP,OAAO,EAAE,SAAS;aACnB;SACF;QACD,eAAe,EAAE;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,oCAAoC;YACjD,KAAK,EAAE,kBAAkB;YACzB,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE;YACnB,OAAM;SACP;QAED,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACxF,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/trackPurchase/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BrazeDestinationClient } from '../braze-types';
|
|
2
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, BrazeDestinationClient, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const action = {
|
|
5
|
+
title: 'Track Purchase',
|
|
6
|
+
defaultSubscription: 'type = "track" and event = "Order Completed"',
|
|
7
|
+
description: 'Reports that the current user made an in-app purchase.',
|
|
8
|
+
platform: 'web',
|
|
9
|
+
fields: {
|
|
10
|
+
purchaseProperties: {
|
|
11
|
+
label: 'Purchase Properties',
|
|
12
|
+
type: 'object',
|
|
13
|
+
description: `Hash of properties for this purchase. Keys are limited to 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation. Values can be numeric, boolean, Date objects, strings 255 characters or shorter, or nested objects whose values can be numeric, boolean, Date objects, arrays, strings, or null. Total size of purchase properties cannot exceed 50KB.`,
|
|
14
|
+
default: {
|
|
15
|
+
'@path': '$.properties'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
products: {
|
|
19
|
+
label: 'Products',
|
|
20
|
+
description: 'List of products purchased by the user',
|
|
21
|
+
properties: {
|
|
22
|
+
product_id: {
|
|
23
|
+
label: 'Product ID',
|
|
24
|
+
type: 'string',
|
|
25
|
+
required: true,
|
|
26
|
+
description: `A string identifier for the product purchased, e.g. an SKU. Value is limited to 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.`
|
|
27
|
+
},
|
|
28
|
+
price: {
|
|
29
|
+
label: 'Price',
|
|
30
|
+
type: 'number',
|
|
31
|
+
required: true,
|
|
32
|
+
description: `The price paid. Base units depend on the currency. As an example, USD should be reported as Dollars.Cents, whereas JPY should be reported as a whole number of Yen. All provided values will be rounded to two digits with toFixed(2)`
|
|
33
|
+
},
|
|
34
|
+
currency: {
|
|
35
|
+
label: 'Currency Code',
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: `Default USD. Currencies should be represented as an ISO 4217 currency code`
|
|
38
|
+
},
|
|
39
|
+
quantity: {
|
|
40
|
+
label: 'Quantity',
|
|
41
|
+
type: 'number',
|
|
42
|
+
description: `Default 1. The quantity of items purchased expressed as a whole number. Must be at least 1 and at most 100.`
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
type: 'object',
|
|
46
|
+
multiple: true,
|
|
47
|
+
default: {
|
|
48
|
+
'@path': '$.properties.products'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
perform: (client, data) => {
|
|
53
|
+
if (!client.ready()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const payload = data.payload;
|
|
57
|
+
const reservedKeys = Object.keys(action.fields.products.properties ?? {});
|
|
58
|
+
const purchaseProperties = actions_core_1.omit(payload.purchaseProperties, reservedKeys);
|
|
59
|
+
if (purchaseProperties?.products && Array.isArray(purchaseProperties?.products)) {
|
|
60
|
+
purchaseProperties?.products?.forEach((product) => {
|
|
61
|
+
const result = client.instance.logPurchase(product.product_id.toString(), product.price, product.currency ?? 'USD', product.quantity ?? 1, purchaseProperties);
|
|
62
|
+
if (!result) {
|
|
63
|
+
console.warn('Braze failed to attach purchase to the session for product ', product.productId);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.default = action;
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/trackPurchase/index.ts"],"names":[],"mappings":";;AACA,wDAA4C;AAK5C,MAAM,MAAM,GAAuE;IACjF,KAAK,EAAE,gBAAgB;IACvB,mBAAmB,EAAE,8CAA8C;IACnE,WAAW,EAAE,wDAAwD;IACrE,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,kBAAkB,EAAE;YAClB,KAAK,EAAE,qBAAqB;YAC5B,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iZAAiZ;YAC9Z,OAAO,EAAE;gBACP,OAAO,EAAE,cAAc;aACxB;SACF;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,wCAAwC;YACrD,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,KAAK,EAAE,YAAY;oBACnB,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,gMAAgM;iBAC9M;gBACD,KAAK,EAAE;oBACL,KAAK,EAAE,OAAO;oBACd,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,uOAAuO;iBACrP;gBACD,QAAQ,EAAE;oBACR,KAAK,EAAE,eAAe;oBACtB,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,4EAA4E;iBAC1F;gBACD,QAAQ,EAAE;oBACR,KAAK,EAAE,UAAU;oBACjB,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6GAA6G;iBAC3H;aACF;YACD,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,uBAAuB;aACjC;SACF;KACF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QACxB,IAAI,CAAC,MAAM,CAAC,KAAK,EAA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