@atomic.io/action-cards-web-sdk-cdn-icons 24.2.1
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/README.md +1766 -0
- package/package.json +88 -0
- package/public/LICENSES.txt +236 -0
- package/public/iframe-manager.js +9 -0
- package/public/sdk.d.ts +1233 -0
- package/public/sdk.js +9 -0
package/public/sdk.d.ts
ADDED
|
@@ -0,0 +1,1233 @@
|
|
|
1
|
+
/// <reference types="preact" />
|
|
2
|
+
|
|
3
|
+
import { SDKCardEvent as SDKCardEvent_2 } from 'src/lib/sdk-event';
|
|
4
|
+
|
|
5
|
+
export declare class AACHeadlessStreamContainer {
|
|
6
|
+
readonly resolvedConfiguration: HeadlessSDKConfiguration & InternalConfiguration;
|
|
7
|
+
readonly instanceId: string;
|
|
8
|
+
streamFilters: StreamFilter;
|
|
9
|
+
private analyticsQueue;
|
|
10
|
+
private pollCounter;
|
|
11
|
+
private pollTimer;
|
|
12
|
+
private store;
|
|
13
|
+
private boundActions;
|
|
14
|
+
constructor(config: HeadlessSDKConfiguration, internalConfig: InternalConfiguration, analyticsQueue: AnalyticsQueue);
|
|
15
|
+
/**
|
|
16
|
+
* Starts card feed updates to the stream container instance either via WebSocket or HTTP polling depending on SDK configuration.
|
|
17
|
+
*/
|
|
18
|
+
start(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Stops card feed updates.
|
|
21
|
+
*/
|
|
22
|
+
stop(): void;
|
|
23
|
+
tokenProvider: {
|
|
24
|
+
requestToken: () => Promise<string | undefined>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Polls the Atomic platform for card feed updates
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
private pollCardFeed;
|
|
31
|
+
private cancelCardListPolling;
|
|
32
|
+
private sendWebSocketFeedSubscriptionMessage;
|
|
33
|
+
/**
|
|
34
|
+
* Takes a WebSocket card feed update message and processes it as required
|
|
35
|
+
*/
|
|
36
|
+
private handleCardFeedUpdate;
|
|
37
|
+
/**
|
|
38
|
+
* Compares the stored feed with an updated feed just received and updates the card count observer if required
|
|
39
|
+
* @param currentFeed The card feed currently stored in application state
|
|
40
|
+
* @param incomingFeed The new feed received from the platform
|
|
41
|
+
*/
|
|
42
|
+
private trackCardCountChange;
|
|
43
|
+
/**
|
|
44
|
+
* Triggers the resolution of runtime variables for supplied cards
|
|
45
|
+
*/
|
|
46
|
+
private runtimeVariableResolver;
|
|
47
|
+
/**
|
|
48
|
+
* Takes analytics event data and augments it before attempting to send it on the WebSocket and add it to the analytics queue.
|
|
49
|
+
*/
|
|
50
|
+
private sendAnalyticsEvent;
|
|
51
|
+
/**
|
|
52
|
+
* Manually triggers update of the runtime variables and passes the updated cards to the card feed handler
|
|
53
|
+
*/
|
|
54
|
+
updateVariables(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Handles messages received from the SDK
|
|
57
|
+
* @param event
|
|
58
|
+
*/
|
|
59
|
+
onMessageReceived(event: any): void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A structured object representing a push notification that was successfully parsed from an iOS or Android payload.
|
|
64
|
+
*/
|
|
65
|
+
export declare interface AACPushNotification {
|
|
66
|
+
/** The instance ID of the card that the push notification relates to. Can be used to apply a filter on a stream container. */
|
|
67
|
+
cardInstanceId: string;
|
|
68
|
+
/** The ID of the stream container that generated the notification. */
|
|
69
|
+
containerId: string;
|
|
70
|
+
/** Detail object, defined as `notificationDetail` and sent as part of the event that generated the card. */
|
|
71
|
+
detail: object;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export declare class AACStreamContainer {
|
|
75
|
+
private iframe;
|
|
76
|
+
private modalIframe?;
|
|
77
|
+
private toastIframe?;
|
|
78
|
+
private outsideClickListener;
|
|
79
|
+
private queuedMessages;
|
|
80
|
+
private iframeLoaded;
|
|
81
|
+
private appOpen;
|
|
82
|
+
private launchButtonIconContainer?;
|
|
83
|
+
private launcher?;
|
|
84
|
+
private resizeObserver?;
|
|
85
|
+
readonly resolvedConfiguration: SDKConfiguration;
|
|
86
|
+
readonly instanceId: string;
|
|
87
|
+
streamFilters: any;
|
|
88
|
+
private config;
|
|
89
|
+
private analyticsQueue;
|
|
90
|
+
constructor(config: SDKConfiguration, internalConfig: InternalConfiguration, embedMode: EmbedMode, analyticsQueue: AnalyticsQueue, hostElement?: HTMLElement);
|
|
91
|
+
/**
|
|
92
|
+
* Stops the stream container instance, removing it from the page.
|
|
93
|
+
*/
|
|
94
|
+
stop(): void;
|
|
95
|
+
updateVariables(): void;
|
|
96
|
+
setOpen(open: boolean): void;
|
|
97
|
+
private getIcon;
|
|
98
|
+
private toggleAppOpen;
|
|
99
|
+
private updateAppOpen;
|
|
100
|
+
private initLauncherButton;
|
|
101
|
+
private initIframe;
|
|
102
|
+
onMessageReceived(event: any): Promise<void>;
|
|
103
|
+
private enqueueAnalyticsEvent;
|
|
104
|
+
private updateVisibilityForLauncher;
|
|
105
|
+
private handleRuntimeVariableResolution;
|
|
106
|
+
sendMessageToIframe<ReplyType>(message: SDKReply<ReplyType>, appHostWindow?: Window | null): void;
|
|
107
|
+
private flushMessages;
|
|
108
|
+
getWindowOrigin(): string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export declare interface AnalyticsCardContext {
|
|
112
|
+
cardInstanceId: string;
|
|
113
|
+
cardInstanceStatus: string;
|
|
114
|
+
cardViewState: CardViewState;
|
|
115
|
+
cardPresentation: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare interface AnalyticsEvent {
|
|
119
|
+
eventName: string;
|
|
120
|
+
properties?: AnalyticsEventProperties;
|
|
121
|
+
hostContext?: AnalyticsEventProperties;
|
|
122
|
+
cardInstanceId?: string;
|
|
123
|
+
cardViewState?: CardViewState;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export declare interface AnalyticsEventContext {
|
|
127
|
+
userLocalTimestamp: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare interface AnalyticsEventProperties {
|
|
131
|
+
[key: string]: any;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare type AnalyticsEventType = 'standard' | 'custom' | 'sdk-initialized';
|
|
135
|
+
|
|
136
|
+
export declare class AnalyticsQueue {
|
|
137
|
+
private eventQueue;
|
|
138
|
+
private flushTimeout;
|
|
139
|
+
private flushPromise;
|
|
140
|
+
constructor();
|
|
141
|
+
createEventPayload(eventData: AugmentedAnalyticsEvent | CustomAnalyticsEventData | SDKInitializedEventData, eventType: AnalyticsEventType): QueuedAnalyticsEvent | null;
|
|
142
|
+
enqueue(eventData: AugmentedAnalyticsEvent | CustomAnalyticsEventData | SDKInitializedEventData, eventType?: AnalyticsEventType): QueuedAnalyticsEvent | null;
|
|
143
|
+
removeProcessedEvents(eventIds: string[]): void;
|
|
144
|
+
private performFlush;
|
|
145
|
+
flush(): Promise<void>;
|
|
146
|
+
private scheduleFlush;
|
|
147
|
+
private persistQueue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export declare interface AnalyticsSDKContext {
|
|
151
|
+
containerId: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export declare interface AnalyticsStreamContext {
|
|
155
|
+
streamLength: number;
|
|
156
|
+
streamLengthVisible: number;
|
|
157
|
+
cardPositionInStream: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export declare type ApiCardActionType = 'dismiss' | 'snooze' | 'submit';
|
|
161
|
+
|
|
162
|
+
export declare type ApiProtocol = 'http' | 'webSockets';
|
|
163
|
+
|
|
164
|
+
export declare interface APIResponseMetric {
|
|
165
|
+
active: number;
|
|
166
|
+
unseen: number;
|
|
167
|
+
activeCardInstanceIds: string[];
|
|
168
|
+
unseenCardInstanceIds: string[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Supports the creation of stream containers in two embed modes:
|
|
173
|
+
* 1. `launcher`, which displays a launcher button in the bottom right of the page. Clicking the button toggles
|
|
174
|
+
* the display of the stream container;
|
|
175
|
+
* 2. `standalone`, which allows you to embed the stream container in a parent element. The iframe can then be
|
|
176
|
+
* managed as desired.
|
|
177
|
+
*/
|
|
178
|
+
declare class AtomicSDK {
|
|
179
|
+
private static hasPerformedInitialisation;
|
|
180
|
+
static webSocketDisabled: boolean;
|
|
181
|
+
private static cachedUserMetrics;
|
|
182
|
+
private static internalConfig;
|
|
183
|
+
private static cachedToken?;
|
|
184
|
+
static onError?: (error: Error) => void;
|
|
185
|
+
static sdkEventObserver: SDKEventCallback | null;
|
|
186
|
+
static readonly SDKEvents: SDKEventName;
|
|
187
|
+
static readonly userMetricsTriggerEvents: Set<"sdk-initialized" | "card-displayed" | "stream-displayed" | "card-completed" | "card-dismissed" | "card-snoozed" | "card-feed-updated">;
|
|
188
|
+
static onAuthTokenRequested: AuthTokenCallback | undefined;
|
|
189
|
+
static tokenRetryInterval: number;
|
|
190
|
+
static tokenRetryTimer: ReturnType<typeof setTimeout> | undefined;
|
|
191
|
+
static tokenExpiryInterval: number;
|
|
192
|
+
static authMessageResolve: () => void;
|
|
193
|
+
static authMessageReject: (error: any) => void;
|
|
194
|
+
static streamContainers: {
|
|
195
|
+
[instanceId: string]: {
|
|
196
|
+
sendMessageToIframe: (message: any) => void;
|
|
197
|
+
logout: () => void;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
static containersBroadcastChannel: ContainerBroadcastChannel | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* Sets the session delegate on the AtomicSDK
|
|
203
|
+
*
|
|
204
|
+
* @param sessionDelegate Callback that will return a JWT for authentication when requested by the SDK
|
|
205
|
+
* @param {string} [retryInterval] Optional time the SDK will wait for before calling session delegate again after failing to fetch a valid JWT
|
|
206
|
+
*/
|
|
207
|
+
static setSessionDelegate(sessionDelegate: AuthTokenCallback, retryInterval?: number): void;
|
|
208
|
+
/**
|
|
209
|
+
* Sets the interval from the token expiry timestamp, within which the SDK will consider the auth token expired and will request a new one.
|
|
210
|
+
*
|
|
211
|
+
* @param {number} [interval] number in seconds, greater than zero.
|
|
212
|
+
*/
|
|
213
|
+
static setTokenExpiryInterval(interval: number): void;
|
|
214
|
+
static readonly analyticsQueue: AnalyticsQueue;
|
|
215
|
+
/**
|
|
216
|
+
* Create a stream container using the launcher embed mode.
|
|
217
|
+
* In this mode, a launcher button displays in the bottom right, and clicking on it toggles the stream container.
|
|
218
|
+
*
|
|
219
|
+
* @param config Configuration for this stream container.
|
|
220
|
+
* @return An `AACStreamContainer` instance, which allows you to perform actions on the stream container after
|
|
221
|
+
* creation.
|
|
222
|
+
*/
|
|
223
|
+
static launch(config: SDKConfiguration): AACStreamContainer;
|
|
224
|
+
/**
|
|
225
|
+
* Create a stream container using the standalone embed mode.
|
|
226
|
+
* In this mode, the stream container iframe is added to the provided element, allowing the integrator
|
|
227
|
+
* to customise the display of the iframe as desired.
|
|
228
|
+
*
|
|
229
|
+
* @param hostElement The DOM element to embed the stream container in.
|
|
230
|
+
* @param config Configuration for this stream container.
|
|
231
|
+
* @param autosize Whether the iframe displaying the standalone embed should set its height to accommodate all available content and prevent it from scrolling. Defaults to false.
|
|
232
|
+
* @return An `AACStreamContainer` instance, which allows you to perform actions on the stream container after
|
|
233
|
+
* creation.
|
|
234
|
+
*/
|
|
235
|
+
static embed(hostElement: HTMLElement, config: SDKConfiguration, autosize?: Boolean): AACStreamContainer;
|
|
236
|
+
static singleCard(hostElement: HTMLElement, config: SDKConfiguration): AACStreamContainer;
|
|
237
|
+
/**
|
|
238
|
+
* Create a stream container instance that can be used to observe the card feed, it will not render any UI.
|
|
239
|
+
*
|
|
240
|
+
* @param config A configuration object for the observable stream container
|
|
241
|
+
* @returns An instance of the AACHeadlessStreamContainer
|
|
242
|
+
*/
|
|
243
|
+
static observableStreamContainer(config: HeadlessSDKConfiguration): AACHeadlessStreamContainer;
|
|
244
|
+
private static init;
|
|
245
|
+
static initialise(apiHost: string, apiKey: string, environmentId: string): Promise<void>;
|
|
246
|
+
private static initialiseSDKBroadcastChannel;
|
|
247
|
+
/**
|
|
248
|
+
* Sets the API protocol the Atomic SDK will use, must be called before intialising the SDK with `AtomicSDK.intialise`.
|
|
249
|
+
* @param protocol The protocol to use for the card feed api. Defaults to WebSockets.
|
|
250
|
+
*/
|
|
251
|
+
static setApiProtocol(protocol: ApiProtocol): void;
|
|
252
|
+
/**
|
|
253
|
+
* Sets the verbosity of debug logging to be output by the SDK.
|
|
254
|
+
* Level 0: Default, no logs exposed
|
|
255
|
+
* Level 1: Operations and transactions are exposed
|
|
256
|
+
* Level 2: Operations, transactions and its details are exposed, plus level 1.
|
|
257
|
+
* Level 3: Internal developer logs, plus level 2
|
|
258
|
+
* @param level The logging level to use for the SDK.
|
|
259
|
+
*/
|
|
260
|
+
static enableDebugMode(level?: LogLevel): void;
|
|
261
|
+
/**
|
|
262
|
+
* Establishes a websocket connection to the '/socket' endpoint
|
|
263
|
+
*/
|
|
264
|
+
private static createWebSocketConnection;
|
|
265
|
+
/**
|
|
266
|
+
* Re-initialises the current SDK WebSocket connection
|
|
267
|
+
*/
|
|
268
|
+
static reinitialiseWebSocketConnection(): void;
|
|
269
|
+
/**
|
|
270
|
+
* Sends auth token message on WebSocket connection, if connection is not already authenticated will wait for auth-success
|
|
271
|
+
* response message before proceeding.
|
|
272
|
+
*/
|
|
273
|
+
private static authenticateWebSocketConnection;
|
|
274
|
+
/**
|
|
275
|
+
* Method to simulate WebSocket errors on the platform:
|
|
276
|
+
* https://github.com/atomic-app/action-cards/blob/development/services/client-api/readme.md#error-simulation
|
|
277
|
+
* @param errorString string of format SOURCE_EVENT_CODE to be passed as error param on WebSocket URL
|
|
278
|
+
*/
|
|
279
|
+
private static simulateWebSocketError;
|
|
280
|
+
/**
|
|
281
|
+
* Sends a message to all active stream container instances to force them to fallback to http polling
|
|
282
|
+
*/
|
|
283
|
+
private static triggerPollingFallback;
|
|
284
|
+
/**
|
|
285
|
+
* Sets the value of the `X-Atomic-Test-Host` header used in HTTP requests to the client API.
|
|
286
|
+
* Also sets the test host query parameter used in WebSocket connections.
|
|
287
|
+
* Intended for local development purposes only.
|
|
288
|
+
*/
|
|
289
|
+
static setTestHostHeader(testHost?: string): void;
|
|
290
|
+
static setClientAppVersion(version: string): void;
|
|
291
|
+
/**
|
|
292
|
+
* If there has been a token retry interval set, creates a timer to wait for before allowing a subsequent auth token request
|
|
293
|
+
*/
|
|
294
|
+
private static setRetryTimer;
|
|
295
|
+
/**
|
|
296
|
+
* When a token is required for an authenticated request checks status of cached token
|
|
297
|
+
* and requests a fresh token if required.
|
|
298
|
+
* @param refresh If true will request a fresh token rather than return cached token
|
|
299
|
+
* @returns
|
|
300
|
+
*/
|
|
301
|
+
static handleTokenRequest(options?: {
|
|
302
|
+
skipCache?: boolean;
|
|
303
|
+
authWebSocket?: boolean;
|
|
304
|
+
}): Promise<AuthToken>;
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
* @returns The current authenticated user ID or an empty string if no user is authenticated
|
|
308
|
+
*/
|
|
309
|
+
static getCurrentUserId(): string;
|
|
310
|
+
/**
|
|
311
|
+
* Returns the total number of cards within the provided stream container
|
|
312
|
+
* @param {string} streamContainerId
|
|
313
|
+
*/
|
|
314
|
+
static requestCardCount(streamContainerId: string): Promise<CardCountResponse>;
|
|
315
|
+
/**
|
|
316
|
+
* @deprecated Since version 24.1.0 this method has been deprecated and will be removed in a future release.
|
|
317
|
+
* Sends an event to the Atomic Platform for the user identified by the given authentication token.
|
|
318
|
+
* @param {EventData} event
|
|
319
|
+
*/
|
|
320
|
+
static sendEvent(event: EventData): Promise<EventResponse>;
|
|
321
|
+
/**
|
|
322
|
+
* Queues a custom event to be sent to the Atomic platform
|
|
323
|
+
* @param data An object consisting of two properties: `eventName`, a string value to identify your event, and `properties`, an optional object containing data for the event.
|
|
324
|
+
* @throws Will throw an error if there is an issue preventing the custom event from being sent.
|
|
325
|
+
*/
|
|
326
|
+
static sendCustomEvent(data: {
|
|
327
|
+
eventName: string;
|
|
328
|
+
properties?: AnalyticsEventProperties;
|
|
329
|
+
}): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Sets a callback that will be called with an event payload whenever an event is triggered in the SDK.
|
|
332
|
+
*
|
|
333
|
+
* @param {SDKEventCallback} onSDKEvent either a callback that will be invoked with an event payload whenever an event is triggered in the SDK, or null if you wish to clear the event observation.
|
|
334
|
+
*/
|
|
335
|
+
static observeSDKEvents(onSDKEvent: SDKEventCallback | null): void;
|
|
336
|
+
/**
|
|
337
|
+
* Requests user metrics for the currently logged in user.
|
|
338
|
+
* User metrics include the total number of cards available to the user, the total number of cards that haven't yet
|
|
339
|
+
* been seen by the user, and the number of available and unseen cards in a specific stream container.
|
|
340
|
+
* Use the returned object to obtain these values.
|
|
341
|
+
*
|
|
342
|
+
* @returns A `UserMetrics` object that provides access to user metrics.
|
|
343
|
+
*/
|
|
344
|
+
static requestUserMetrics(): Promise<UserMetrics>;
|
|
345
|
+
/**
|
|
346
|
+
*
|
|
347
|
+
* @param {UserUpdate} userUpdate An object containing the profile & preference properties to be updated on the user
|
|
348
|
+
* @returns A boolean indicating whether the user update succeeded
|
|
349
|
+
* @throws Will throw an error if there is an issue preventing the user update
|
|
350
|
+
*/
|
|
351
|
+
static updateUser(userUpdate: UserUpdate): Promise<boolean>;
|
|
352
|
+
/**
|
|
353
|
+
* Attempts to execute the requested action on the specified card within the given stream container.
|
|
354
|
+
*
|
|
355
|
+
* @param streamContainerId a string identifying the stream container to execute the action in
|
|
356
|
+
* @param cardId a string identifying the card to execute the action on
|
|
357
|
+
* @returns an object with methods for 'dismiss', 'snooze' and 'submit' actions
|
|
358
|
+
*/
|
|
359
|
+
static onCardAction(streamContainerId: string, cardId: string): {
|
|
360
|
+
/**
|
|
361
|
+
*
|
|
362
|
+
* @param onActionSuccess a function to be invoked when the card is successfully dismissed
|
|
363
|
+
* @param onActionFailed a function to be invoked when the card fails to be dismissed, will be called with an error parameter
|
|
364
|
+
*/
|
|
365
|
+
dismiss: (onActionSuccess: () => void, onActionFailed: (error: Error) => void) => Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
*
|
|
368
|
+
* @param onActionSuccess a function to be invoked when the card is successfully snoozed
|
|
369
|
+
* @param onActionFailed a function to be invoked when the card fails to be snoozed, will be called with an error parameter
|
|
370
|
+
* @param interval the interval in seconds for which the card should be snoozed
|
|
371
|
+
*/
|
|
372
|
+
snooze: (onActionSuccess: () => void, onActionFailed: (error: Error) => void, interval: number) => Promise<void>;
|
|
373
|
+
/**
|
|
374
|
+
*
|
|
375
|
+
* @param onActionSuccess a function to be invoked when the card is successfully submitted
|
|
376
|
+
* @param onActionFailed a function to be invoked when the card fails to be submitted, will be called with an error parameter
|
|
377
|
+
* @param submitButtonName a string identifying the submit button pressed, this should be taken from the `name` attribute from the button node
|
|
378
|
+
* @param response an optional object containing response values for the card. Keys must be strings and values must be strings, numbers or booleans
|
|
379
|
+
*/
|
|
380
|
+
submit: (onActionSuccess: () => void, onActionFailed: (error: Error) => void, submitButtonName: string, response?: CardResponse | undefined) => Promise<void>;
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* Call this method each time the logged in user changes.
|
|
384
|
+
* Flushes any pending analytics events so that they are sent to the Atomic Platform immediately.
|
|
385
|
+
* Resets the state of active stream containers so no cards are displayed.
|
|
386
|
+
* Clears the auth token so SDK is ready to accept a new token for the new user.
|
|
387
|
+
* Resets the connection to the Atomic Platform so there will be no communication with the platform while unauthenticated.
|
|
388
|
+
* For iOS and Android apps this method will also de-register the device for notifications if the parameter is supplied.
|
|
389
|
+
* Stream containers elements are left in place so you can clean these up when appropriate to remove the container UI.
|
|
390
|
+
*
|
|
391
|
+
* @param {boolean} deregisterNotifications - If true, will de-register the device for notifications. Defaults to false.
|
|
392
|
+
*/
|
|
393
|
+
static logout(deregisterNotifications?: boolean): Promise<void>;
|
|
394
|
+
/**
|
|
395
|
+
* A convenience method that can be used to supply your apiHost, apiKey, environmentId & sessionDelegate in one call.
|
|
396
|
+
* Internally this will call AtomicSDK.initialise & AtomicSDK.setSessionDelegate with your supplied values.
|
|
397
|
+
*
|
|
398
|
+
* @param apiHost
|
|
399
|
+
* @param apiKey
|
|
400
|
+
* @param environmentId
|
|
401
|
+
* @param sessionDelegate Callback that will return a JWT for authentication when requested by the SDK
|
|
402
|
+
* @param {string} [retryInterval] Optional time the SDK will wait for before calling session delegate again after failing to fetch a valid JWT
|
|
403
|
+
*/
|
|
404
|
+
static login(apiHost: string, apiKey: string, environmentId: string, sessionDelegate: AuthTokenCallback, retryInterval?: number): void;
|
|
405
|
+
/**
|
|
406
|
+
* For iOS and Android apps only.
|
|
407
|
+
*
|
|
408
|
+
* Call this method when you are integrating the SDK inside of a native iOS or Android app. For example,
|
|
409
|
+
* if you use a wrapper such as Cordova or Capacitor, and want to use push notifications.
|
|
410
|
+
*
|
|
411
|
+
* Must be called before registerDeviceForNotifications, registerStreamContainersForNotifications, deregisterDeviceForNotifications.
|
|
412
|
+
*
|
|
413
|
+
* @param deviceInfo information about the platform and device
|
|
414
|
+
* @returns boolean true if the info was succesfully set
|
|
415
|
+
*/
|
|
416
|
+
static setNativeDeviceInfo(deviceInfo: DeviceInfo): boolean;
|
|
417
|
+
/**
|
|
418
|
+
* For iOS and Android apps only.
|
|
419
|
+
*
|
|
420
|
+
* Asks the SDK to register the given device token against the currently logged in user, identified by the auth
|
|
421
|
+
* token returned by the global session delegate.
|
|
422
|
+
*
|
|
423
|
+
* @param deviceToken Push device token provided by the operating system.
|
|
424
|
+
* @returns The returned promise is resolved if the registration succeeds, or is rejected if the request fails.
|
|
425
|
+
*/
|
|
426
|
+
static registerDeviceForNotifications(token: string): Promise<boolean>;
|
|
427
|
+
/**
|
|
428
|
+
* For iOS and Android apps only.
|
|
429
|
+
*
|
|
430
|
+
* Asks the SDK to deregister the current device for Atomic push notifications, within the current app.
|
|
431
|
+
*/
|
|
432
|
+
static deregisterDeviceForNotifications(): Promise<boolean>;
|
|
433
|
+
/**
|
|
434
|
+
* For iOS and Android apps only.
|
|
435
|
+
*
|
|
436
|
+
* Asks the SDK to register the currently logged in user for push notifications on the stream container IDs in the
|
|
437
|
+
* provided array. The user is identified by the token returned in the global session delegate.
|
|
438
|
+
* If you pass the optional `notificationsEnabled` argument, the user's notificationsEnabled preference will be
|
|
439
|
+
* updated in the Atomic Platform.
|
|
440
|
+
*
|
|
441
|
+
* @param streamContainerIds The stream container IDs to register the current user against for push notifications.
|
|
442
|
+
* @param notificationsEnabled (Optional) Whether push notifications, for the current user, should be enabled or disabled in the Atomic Platform.
|
|
443
|
+
*/
|
|
444
|
+
static registerStreamContainersForNotifications(streamContainersIds: [string], notificationsEnabled?: boolean): Promise<boolean>;
|
|
445
|
+
/**
|
|
446
|
+
* For iOS and Android apps only.
|
|
447
|
+
*
|
|
448
|
+
* Determines whether the given push notification payload is for a push notification sent by the Atomic Platform.
|
|
449
|
+
* If the push payload is for an Atomic push notification, this method returns an instance of
|
|
450
|
+
* `AACPushNotification` populated with details of the notification. Otherwise, it returns null.
|
|
451
|
+
*
|
|
452
|
+
* @param payload The push notification payload provided from the operating system.
|
|
453
|
+
*/
|
|
454
|
+
static notificationFromPushPayload(payload: unknown): AACPushNotification | null;
|
|
455
|
+
/**
|
|
456
|
+
* For iOS and Android apps only.
|
|
457
|
+
*
|
|
458
|
+
* Tracks that a push notification, with the given payload, was received by this device.
|
|
459
|
+
* If the payload does not represent an Atomic push notification, this method has no effect and returns false.
|
|
460
|
+
* Otherwise, this method dispatches an analytics event back to Atomic to indicate that the user's device received the
|
|
461
|
+
* notification and returns true.
|
|
462
|
+
*
|
|
463
|
+
* It is the responsibility of the integrator to ensure that this method is called at the correct location to
|
|
464
|
+
* ensure accurate tracking.
|
|
465
|
+
*
|
|
466
|
+
* @param payload The push notification payload to inspect.
|
|
467
|
+
*/
|
|
468
|
+
static trackPushNotificationReceived(payload: unknown): boolean;
|
|
469
|
+
}
|
|
470
|
+
export default AtomicSDK;
|
|
471
|
+
|
|
472
|
+
export declare interface AugmentedAnalyticsEvent extends AnalyticsEvent {
|
|
473
|
+
endUserId: string;
|
|
474
|
+
timestamp: Date;
|
|
475
|
+
containerId?: string;
|
|
476
|
+
streamLength?: number;
|
|
477
|
+
streamLengthVisible?: number;
|
|
478
|
+
streamCardPosition?: number;
|
|
479
|
+
cardInstanceStatus?: string;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export declare type AuthToken = string | undefined;
|
|
483
|
+
|
|
484
|
+
export declare type AuthTokenCallback = () => Promise<AuthToken>;
|
|
485
|
+
|
|
486
|
+
export declare type BroadcastChannelMessage = MessageEvent & {
|
|
487
|
+
data: {
|
|
488
|
+
type: CHANNEL_MESSAGE_TYPE;
|
|
489
|
+
};
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
export declare interface CardActions {
|
|
493
|
+
dismiss: CardActionType;
|
|
494
|
+
snooze: CardActionType;
|
|
495
|
+
voteDown: CardActionType;
|
|
496
|
+
voteUp: CardActionType;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export declare type CardActionType = {
|
|
500
|
+
overflow: boolean;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
export declare interface CardCountResponse {
|
|
504
|
+
totalCards: number;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export declare interface CardEvent {
|
|
508
|
+
type: CardEventType;
|
|
509
|
+
eventPayload?: CardEventPayload;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Different types of card events that the SDK can trigger
|
|
514
|
+
* in the host app.
|
|
515
|
+
*/
|
|
516
|
+
export declare type CardEventPayload = Omit<SDKCardEvent_2, 'sdkContext'>;
|
|
517
|
+
|
|
518
|
+
export declare enum CardEventType {
|
|
519
|
+
DISMISSED = "dismissed",
|
|
520
|
+
DISMISS_FAILED = "dismiss-failed",
|
|
521
|
+
SUBMITTED = "submitted",
|
|
522
|
+
SUBMIT_FAILED = "submit-failed",
|
|
523
|
+
SNOOZED = "snoozed",
|
|
524
|
+
SNOOZE_FAILED = "snooze-failed",
|
|
525
|
+
VOTED_USEFUL = "voted-useful",
|
|
526
|
+
VOTED_NOT_USEFUL = "voted-not-useful"
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export declare interface CardInstance {
|
|
530
|
+
defaultView: CardLayout;
|
|
531
|
+
actions: CardActions;
|
|
532
|
+
subviews: {
|
|
533
|
+
[key: string]: SubviewLayout;
|
|
534
|
+
};
|
|
535
|
+
instance: CardInstanceMetadata;
|
|
536
|
+
metadata: CardMetadata;
|
|
537
|
+
runtimeVariables?: Array<RuntimeVariable>;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
export declare interface CardInstanceMetadata {
|
|
541
|
+
id: string;
|
|
542
|
+
status: string;
|
|
543
|
+
created: string;
|
|
544
|
+
lifecycleId: string;
|
|
545
|
+
eventName: string;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export declare interface CardLayout {
|
|
549
|
+
nodes: Array<LayoutNode>;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export declare interface CardMetadata {
|
|
553
|
+
lastCardActiveTime: string;
|
|
554
|
+
receivedAt: string;
|
|
555
|
+
priority: number;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export declare interface CardResponse {
|
|
559
|
+
[key: string]: string | number | boolean | undefined | null;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export declare interface CardsAPIResponse {
|
|
563
|
+
ok: boolean;
|
|
564
|
+
event?: SDKCardEvent;
|
|
565
|
+
error?: Error;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export declare type CardViewState = 'topview' | 'subview';
|
|
569
|
+
|
|
570
|
+
export declare enum CHANNEL_MESSAGE_TYPE {
|
|
571
|
+
STATE = "state-update",
|
|
572
|
+
ANALYTICS_EVENT = "analytics-event-dispatched"
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Wrapper around the Broadcast Channel API to provide an interface that shows the open status of the channel object
|
|
577
|
+
* as well as a way to add and remove event listeners by id.
|
|
578
|
+
*/
|
|
579
|
+
export declare class ContainerBroadcastChannel {
|
|
580
|
+
private channel;
|
|
581
|
+
isOpen: boolean;
|
|
582
|
+
private eventListeners;
|
|
583
|
+
constructor();
|
|
584
|
+
/**
|
|
585
|
+
* Adds an event listener to this broadcast channel object
|
|
586
|
+
* @param eventName The name of the event to listen for. Can be 'message' or 'messageerror'.
|
|
587
|
+
* @param listener The callback to be invoked when the event is dispatched.
|
|
588
|
+
* @param id An optional string to identify the event listener. If not provided, a unique id will be generated.
|
|
589
|
+
* @returns The id identifying the event listener stored in this Broadcast Channel object.
|
|
590
|
+
*/
|
|
591
|
+
addEventListener(eventName: 'message' | 'messageerror', listener: (event: BroadcastChannelMessage) => void, id?: string): string | void;
|
|
592
|
+
/**
|
|
593
|
+
* Removes the event listener identified by the given id from this broadcast channel object
|
|
594
|
+
* @param id The id of the event listener to remove.
|
|
595
|
+
* @returns True if the event listener was removed, false otherwise.
|
|
596
|
+
*/
|
|
597
|
+
removeEventListener(id: string): boolean | void;
|
|
598
|
+
postMessage(message: any): void;
|
|
599
|
+
close(): void;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
export declare interface ContainerMetric extends APIResponseMetric {
|
|
603
|
+
containerId: string;
|
|
604
|
+
activeCardInstanceIds: string[];
|
|
605
|
+
unseenCardInstanceIds: string[];
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export declare interface CordovaConfiguration {
|
|
609
|
+
enabled: boolean;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export declare interface CustomAnalyticsEvent extends Omit<StandardAnalyticsEvent, 'cardContext' | 'streamContext' | 'hostContext' | 'sdkContext' | 'analyticsEvent' | 'properties'> {
|
|
613
|
+
eventType: 'custom';
|
|
614
|
+
analyticsEvent?: string;
|
|
615
|
+
eventName: string;
|
|
616
|
+
properties?: AnalyticsEventProperties;
|
|
617
|
+
sdkContext: {};
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export declare interface CustomAnalyticsEventData {
|
|
621
|
+
endUserId: string;
|
|
622
|
+
eventName: string;
|
|
623
|
+
properties?: AnalyticsEventProperties;
|
|
624
|
+
timestamp: Date;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export declare interface CustomStrings {
|
|
628
|
+
cardListTitle?: string;
|
|
629
|
+
awaitingFirstCard?: string;
|
|
630
|
+
allCardsCompleted?: string;
|
|
631
|
+
cardSnoozeTitle?: string;
|
|
632
|
+
votingUsefulTitle?: string;
|
|
633
|
+
votingNotUsefulTitle?: string;
|
|
634
|
+
votingFeedbackTitle?: string;
|
|
635
|
+
noInternetConnectionMessage?: string;
|
|
636
|
+
dataLoadFailedMessage?: string;
|
|
637
|
+
tryAgainTitle?: string;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
export declare interface DeviceInfo {
|
|
641
|
+
platform: NativePlatform;
|
|
642
|
+
deviceId: string;
|
|
643
|
+
appId: string;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Different ways in which a stream container can be embedded:
|
|
648
|
+
* 1. launcher: Displays as a floating button in the bottom right of the screen. Tapping the button
|
|
649
|
+
* toggles the stream container iframe.
|
|
650
|
+
* 2. standalone: Embedded inside of a nominated element. Styling is controlled by the integrator.
|
|
651
|
+
* 3. preview: The SDK is being displayed inside the Workbench card builder.
|
|
652
|
+
* 4. single-card: The SDK is rendering a single card inside of an iframe.
|
|
653
|
+
* 5. modal-subview: The iframe is rendering a modal iframe - it will never render the card feed,
|
|
654
|
+
* and is designed to supplement the single card view.
|
|
655
|
+
* 6. toast: The iframe is rendering a toast iframe, this
|
|
656
|
+
*/
|
|
657
|
+
export declare type EmbedMode = 'launcher' | 'standalone' | 'preview' | 'single-card' | 'modal-subview' | 'toast' | 'headless';
|
|
658
|
+
|
|
659
|
+
export declare interface EventData {
|
|
660
|
+
name: string;
|
|
661
|
+
lifecycleId?: string;
|
|
662
|
+
payload?: EventPayload;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export declare interface EventPayload {
|
|
666
|
+
detail?: object;
|
|
667
|
+
metadata?: object;
|
|
668
|
+
notificationDetail?: object;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
export declare interface EventResponse {
|
|
672
|
+
batchId: string;
|
|
673
|
+
processedEvents: ProcessedEvent[];
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export declare interface FeatureFlags {
|
|
677
|
+
cordova?: CordovaConfiguration;
|
|
678
|
+
runtimeVariableAnalytics?: boolean;
|
|
679
|
+
cardVoting?: VotingOptions;
|
|
680
|
+
cardMinimumHeight?: number;
|
|
681
|
+
horizontalContainerConfig?: HorizontalContainerConfig;
|
|
682
|
+
controlledContainerOpenState?: boolean;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export declare type FilterObject = {
|
|
686
|
+
[key: string]: any;
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
export declare interface FirstLoadStyles {
|
|
690
|
+
backgroundColor: string;
|
|
691
|
+
textColor: string;
|
|
692
|
+
buttonTextColor: string;
|
|
693
|
+
loadingSpinnerColor: string;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export declare interface HeadlessSDKConfiguration {
|
|
697
|
+
streamContainerId: string;
|
|
698
|
+
cardFeedHandler: (cardInstances: Array<CardInstance>) => void;
|
|
699
|
+
cardListRefreshInterval?: number;
|
|
700
|
+
onRuntimeVariablesRequested?: RuntimeVariableResolverCallback;
|
|
701
|
+
runtimeVariableResolutionTimeout?: number;
|
|
702
|
+
onCardCountChanged?: (cardCount: number, totalCards: number) => void;
|
|
703
|
+
features?: Pick<FeatureFlags, "runtimeVariableAnalytics">;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export declare interface HorizontalContainerConfig {
|
|
707
|
+
enabled: boolean;
|
|
708
|
+
cardWidth: number;
|
|
709
|
+
emptyStyle?: ('standard' | 'shrink');
|
|
710
|
+
headerAlignment?: ('center' | 'left');
|
|
711
|
+
scrollMode?: ('snap' | 'free');
|
|
712
|
+
lastCardAlignment?: ('left' | 'center');
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export declare type InterfaceStyle = 'light' | 'dark' | 'automatic';
|
|
716
|
+
|
|
717
|
+
export declare interface InternalConfiguration {
|
|
718
|
+
apiHost?: string;
|
|
719
|
+
apiKey?: string;
|
|
720
|
+
environmentId?: string;
|
|
721
|
+
autosizeFrame?: Boolean;
|
|
722
|
+
testHost?: string;
|
|
723
|
+
clientAppVersion?: string;
|
|
724
|
+
webSocketDisabled?: boolean;
|
|
725
|
+
pollingFallbackDisabled?: boolean;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
export declare const LAUNCHER_BUTTON_CLASS = "atomic-sdk-launcher";
|
|
729
|
+
|
|
730
|
+
export declare const LAUNCHER_WRAPPER_CLASS = "atomic-sdk-launcher-wrapper";
|
|
731
|
+
|
|
732
|
+
export declare interface LauncherButtonConfig {
|
|
733
|
+
disabled?: boolean;
|
|
734
|
+
backgroundColor?: string;
|
|
735
|
+
openIconSrc?: string;
|
|
736
|
+
closeIconSrc?: string;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export declare interface LayoutNode {
|
|
740
|
+
type: string;
|
|
741
|
+
attributes: LayoutNodeAttributes;
|
|
742
|
+
key?: string;
|
|
743
|
+
children?: Array<LayoutNode>;
|
|
744
|
+
validations?: ValidationMap;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export declare interface LayoutNodeAttributes {
|
|
748
|
+
[key: string]: any;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Defines the level of detail for the logger. Higher levels include all the details of lower levels.
|
|
753
|
+
*/
|
|
754
|
+
export declare enum LogLevel {
|
|
755
|
+
DISABLED = 0,
|
|
756
|
+
TRANSACTIONS = 1,
|
|
757
|
+
PAYLOAD = 2,
|
|
758
|
+
FULL_DETAIL = 3
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export declare interface Metric {
|
|
762
|
+
active: number;
|
|
763
|
+
unseen: number;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export declare type NativePlatform = 'iOS' | 'Android';
|
|
767
|
+
|
|
768
|
+
export declare type NotifyDays = {
|
|
769
|
+
mon?: NotifyTimes[];
|
|
770
|
+
tue?: NotifyTimes[];
|
|
771
|
+
wed?: NotifyTimes[];
|
|
772
|
+
thu?: NotifyTimes[];
|
|
773
|
+
fri?: NotifyTimes[];
|
|
774
|
+
sat?: NotifyTimes[];
|
|
775
|
+
sun?: NotifyTimes[];
|
|
776
|
+
default?: NotifyTimes[];
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
export declare interface NotifyTimes {
|
|
780
|
+
from: {
|
|
781
|
+
hours: number;
|
|
782
|
+
minutes: number;
|
|
783
|
+
};
|
|
784
|
+
to: {
|
|
785
|
+
hours: number;
|
|
786
|
+
minutes: number;
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
export declare interface Operators<T> {
|
|
791
|
+
equals: (value: T) => void;
|
|
792
|
+
greaterThan: (value: T) => void;
|
|
793
|
+
greaterThanOrEqualTo: (value: T) => void;
|
|
794
|
+
in: (value: T[]) => void;
|
|
795
|
+
lessThan: (value: T) => void;
|
|
796
|
+
lessThanOrEqualTo: (value: T) => void;
|
|
797
|
+
notEqualTo: (value: T) => void;
|
|
798
|
+
notIn: (value: T[]) => void;
|
|
799
|
+
between: (value: [number, number]) => void;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export declare type PriorityFilterValue = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
803
|
+
|
|
804
|
+
export declare interface ProcessedEvent {
|
|
805
|
+
name: string;
|
|
806
|
+
version: number;
|
|
807
|
+
lifecycleId: string;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
export declare type QueuedAnalyticsEvent = StandardAnalyticsEvent | SDKInitializedEvent | CustomAnalyticsEvent;
|
|
811
|
+
|
|
812
|
+
export declare interface RuntimeVariable {
|
|
813
|
+
name: string;
|
|
814
|
+
defaultValue: any;
|
|
815
|
+
type: string;
|
|
816
|
+
defaultFormatterOption?: string;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
export declare interface RuntimeVariableResolutionCard {
|
|
820
|
+
eventName: string;
|
|
821
|
+
lifecycleId: string;
|
|
822
|
+
id: string;
|
|
823
|
+
runtimeVariables: Map<string, string>;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
export declare type RuntimeVariableResolverCallback = (cards: RuntimeVariableResolutionCard[], callback: (cards: RuntimeVariableResolutionCard[]) => void) => void;
|
|
827
|
+
|
|
828
|
+
export declare interface SDKAnalyticsEvent extends SDKEventBase {
|
|
829
|
+
eventName: SDKEventNameEnum;
|
|
830
|
+
analyticsEvent: SDKEventNameEnum;
|
|
831
|
+
sdkContext: {
|
|
832
|
+
containerId: string;
|
|
833
|
+
};
|
|
834
|
+
streamContext: {
|
|
835
|
+
streamLength: number;
|
|
836
|
+
streamLengthVisible: number;
|
|
837
|
+
cardPositionInStream: number;
|
|
838
|
+
};
|
|
839
|
+
cardContext: {
|
|
840
|
+
cardInstanceId: string;
|
|
841
|
+
cardInstanceStatus: string;
|
|
842
|
+
cardViewState: string;
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
export declare interface SDKCardCompletedEvent extends SDKCardEvent {
|
|
847
|
+
eventName: SDKEventNameEnum.cardCompleted;
|
|
848
|
+
analyticsEvent: SDKEventNameEnum.cardCompleted;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
export declare interface SDKCardDismissedEvent extends SDKCardEvent {
|
|
852
|
+
eventName: SDKEventNameEnum.cardDismissed;
|
|
853
|
+
analyticsEvent: SDKEventNameEnum.cardDismissed;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
export declare interface SDKCardDisplayedEvent extends SDKAnalyticsEvent {
|
|
857
|
+
eventName: SDKEventNameEnum.cardDisplayed;
|
|
858
|
+
analyticsEvent: SDKEventNameEnum.cardDisplayed;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
export declare interface SDKCardEvent {
|
|
862
|
+
id: string;
|
|
863
|
+
endUserId: string;
|
|
864
|
+
eventName: SDKEventNameEnum.cardCompleted | SDKEventNameEnum.cardDismissed | SDKEventNameEnum.cardSnoozed;
|
|
865
|
+
analyticsEvent: SDKEventNameEnum.cardCompleted | SDKEventNameEnum.cardDismissed | SDKEventNameEnum.cardSnoozed;
|
|
866
|
+
timestamp: string;
|
|
867
|
+
sdkContext: {
|
|
868
|
+
containerId: string;
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
export declare interface SDKCardSnoozedEvent extends SDKCardEvent {
|
|
873
|
+
eventName: SDKEventNameEnum.cardSnoozed;
|
|
874
|
+
analyticsEvent: SDKEventNameEnum.cardSnoozed;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export declare interface SDKCardVotedDownEvent extends SDKAnalyticsEvent {
|
|
878
|
+
eventName: SDKEventNameEnum.cardVotedDown;
|
|
879
|
+
analyticsEvent: SDKEventNameEnum.cardVotedDown;
|
|
880
|
+
properties: {
|
|
881
|
+
reason: string;
|
|
882
|
+
source: string;
|
|
883
|
+
message?: string;
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
export declare interface SDKCardVotedUpEvent extends SDKAnalyticsEvent {
|
|
888
|
+
eventName: SDKEventNameEnum.cardVotedUp;
|
|
889
|
+
analyticsEvent: SDKEventNameEnum.cardVotedUp;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
export declare interface SDKConfiguration {
|
|
893
|
+
streamContainerId?: string;
|
|
894
|
+
cardListRefreshInterval?: number;
|
|
895
|
+
runtimeVariableResolutionTimeout?: number;
|
|
896
|
+
onCardCountChanged?: (cardCount: number, totalCards: number) => void;
|
|
897
|
+
onRuntimeVariablesRequested?: RuntimeVariableResolverCallback;
|
|
898
|
+
onLinkButtonPressed?: (payload: any) => void;
|
|
899
|
+
onSubmitButtonPressed?: (payload: any) => void;
|
|
900
|
+
onSizeChanged?: (width: number, height: number) => void;
|
|
901
|
+
onCardEvent?: (event: CardEvent) => void;
|
|
902
|
+
onLauncherToggled?: (open?: boolean) => void;
|
|
903
|
+
customStrings?: CustomStrings;
|
|
904
|
+
enabledUiElements?: UIElements;
|
|
905
|
+
features?: FeatureFlags;
|
|
906
|
+
firstLoadStyles?: FirstLoadStyles;
|
|
907
|
+
interfaceStyle?: InterfaceStyle;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
export declare type SDKEvent = SDKCardCompletedEvent | SDKCardDismissedEvent | SDKCardSnoozedEvent | SDKFeedEvent | SDKCardDisplayedEvent | SDKCardVotedUpEvent | SDKCardVotedDownEvent | SDKRuntimeVarsUpdatedEvent | SDKStreamDisplayedEvent | SDKRedirectedEvent | SDKSnoozeOptionsDisplayedEvent | SDKSnoozeOptionsCanceledEvent | SDKSubviewDisplayedEvent | SDKSubviewExitedEvent | SDKVideoPlayedEvent | SDKVideoCompletedEvent | SDKInitEvent | SDKRequestFailedEvent | SDKNotificationReceivedEvent;
|
|
911
|
+
|
|
912
|
+
export declare interface SDKEventBase {
|
|
913
|
+
id: string;
|
|
914
|
+
endUserId: string;
|
|
915
|
+
timestamp: string;
|
|
916
|
+
eventContext: {
|
|
917
|
+
userLocalTimestamp: string;
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
export declare type SDKEventCallback = (event: SDKEvent) => void;
|
|
922
|
+
|
|
923
|
+
export declare const SDKEventName: SDKEventName;
|
|
924
|
+
|
|
925
|
+
export declare type SDKEventName = {
|
|
926
|
+
cardCompleted: 'card-completed';
|
|
927
|
+
cardDismissed: 'card-dismissed';
|
|
928
|
+
cardSnoozed: 'card-snoozed';
|
|
929
|
+
cardFeedUpdated: 'card-feed-updated';
|
|
930
|
+
cardDisplayed: 'card-displayed';
|
|
931
|
+
cardVotedUp: 'card-voted-up';
|
|
932
|
+
cardVotedDown: 'card-voted-down';
|
|
933
|
+
runtimeVarsUpdated: 'runtime-vars-updated';
|
|
934
|
+
streamDisplayed: 'stream-displayed';
|
|
935
|
+
userRedirected: 'user-redirected';
|
|
936
|
+
snoozeOptionsDisplayed: 'snooze-options-displayed';
|
|
937
|
+
snoozeOptionsCanceled: 'snooze-options-canceled';
|
|
938
|
+
cardSubviewDisplayed: 'card-subview-displayed';
|
|
939
|
+
cardSubviewExited: 'card-subview-exited';
|
|
940
|
+
videoPlayed: 'video-played';
|
|
941
|
+
videoCompleted: 'video-completed';
|
|
942
|
+
sdkInitialized: 'sdk-initialized';
|
|
943
|
+
requestFailed: 'request-failed';
|
|
944
|
+
notificationReceived: 'notification-received';
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
export declare enum SDKEventNameEnum {
|
|
948
|
+
cardCompleted = "card-completed",
|
|
949
|
+
cardDismissed = "card-dismissed",
|
|
950
|
+
cardSnoozed = "card-snoozed",
|
|
951
|
+
cardFeedUpdated = "card-feed-updated",
|
|
952
|
+
cardDisplayed = "card-displayed",
|
|
953
|
+
cardVotedUp = "card-voted-up",
|
|
954
|
+
cardVotedDown = "card-voted-down",
|
|
955
|
+
runtimeVarsUpdated = "runtime-vars-updated",
|
|
956
|
+
streamDisplayed = "stream-displayed",
|
|
957
|
+
userRedirected = "user-redirected",
|
|
958
|
+
snoozeOptionsDisplayed = "snooze-options-displayed",
|
|
959
|
+
snoozeOptionsCanceled = "snooze-options-canceled",
|
|
960
|
+
cardSubviewDisplayed = "card-subview-displayed",
|
|
961
|
+
cardSubviewExited = "card-subview-exited",
|
|
962
|
+
videoPlayed = "video-played",
|
|
963
|
+
videoCompleted = "video-completed",
|
|
964
|
+
sdkInitialized = "sdk-initialized",
|
|
965
|
+
requestFailed = "request-failed",
|
|
966
|
+
notificationReceived = "notification-received"
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
export declare interface SDKFeedEvent {
|
|
970
|
+
eventName: SDKEventNameEnum.cardFeedUpdated;
|
|
971
|
+
analyticsEvent: SDKEventNameEnum.cardFeedUpdated;
|
|
972
|
+
id: string;
|
|
973
|
+
endUserId: string;
|
|
974
|
+
timestamp: string;
|
|
975
|
+
eventContext: {
|
|
976
|
+
userLocalTimestamp: string;
|
|
977
|
+
};
|
|
978
|
+
sdkContext: {
|
|
979
|
+
containerId: string;
|
|
980
|
+
};
|
|
981
|
+
properties: {
|
|
982
|
+
cardCount: number;
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
export declare interface SDKInitEvent extends SDKEventBase {
|
|
987
|
+
eventName: SDKEventNameEnum.sdkInitialized;
|
|
988
|
+
analyticsEvent: SDKEventNameEnum.sdkInitialized;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
export declare interface SDKInitializedEvent extends Omit<StandardAnalyticsEvent, 'cardContext' | 'streamContext' | 'sdkContext'> {
|
|
992
|
+
cardContext: {};
|
|
993
|
+
streamContext: {};
|
|
994
|
+
sdkContext: {};
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
export declare interface SDKInitializedEventData extends Pick<AugmentedAnalyticsEvent, 'endUserId' | 'timestamp' | 'properties'> {
|
|
998
|
+
eventName: 'sdk-initialized';
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export declare interface SDKNotificationReceivedEvent extends SDKEventBase {
|
|
1002
|
+
eventName: SDKEventNameEnum.notificationReceived;
|
|
1003
|
+
analyticsEvent: SDKEventNameEnum.notificationReceived;
|
|
1004
|
+
sdkContext: {
|
|
1005
|
+
containerId: string;
|
|
1006
|
+
};
|
|
1007
|
+
cardContext: {
|
|
1008
|
+
cardInstanceId: string;
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
export declare interface SDKRedirectedEvent extends SDKAnalyticsEvent {
|
|
1013
|
+
eventName: SDKEventNameEnum.userRedirected;
|
|
1014
|
+
analyticsEvent: SDKEventNameEnum.userRedirected;
|
|
1015
|
+
properties: {
|
|
1016
|
+
linkMethod: string;
|
|
1017
|
+
url?: string;
|
|
1018
|
+
payload?: any;
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
export declare interface SDKReply<ValuesType> {
|
|
1023
|
+
action: string;
|
|
1024
|
+
values?: ValuesType;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
export declare interface SDKRequestFailedEvent extends SDKEventBase {
|
|
1028
|
+
eventName: SDKEventNameEnum.requestFailed;
|
|
1029
|
+
analyticsEvent: SDKEventNameEnum.requestFailed;
|
|
1030
|
+
properties: {
|
|
1031
|
+
path: string;
|
|
1032
|
+
statusCode: string;
|
|
1033
|
+
};
|
|
1034
|
+
sdkContext: {
|
|
1035
|
+
containerId?: string;
|
|
1036
|
+
};
|
|
1037
|
+
cardContext: {
|
|
1038
|
+
cardInstanceId?: string;
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
export declare interface SDKRuntimeVarsUpdatedEvent extends SDKAnalyticsEvent {
|
|
1043
|
+
eventName: SDKEventNameEnum.runtimeVarsUpdated;
|
|
1044
|
+
analyticsEvent: SDKEventNameEnum.runtimeVarsUpdated;
|
|
1045
|
+
properties: {
|
|
1046
|
+
resolvedVariables: {
|
|
1047
|
+
[key: string]: string;
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
export declare interface SDKSnoozeOptionsCanceledEvent extends SDKAnalyticsEvent {
|
|
1053
|
+
eventName: SDKEventNameEnum.snoozeOptionsCanceled;
|
|
1054
|
+
analyticsEvent: SDKEventNameEnum.snoozeOptionsCanceled;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
export declare interface SDKSnoozeOptionsDisplayedEvent extends SDKAnalyticsEvent {
|
|
1058
|
+
eventName: SDKEventNameEnum.snoozeOptionsDisplayed;
|
|
1059
|
+
analyticsEvent: SDKEventNameEnum.snoozeOptionsDisplayed;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
export declare interface SDKStreamDisplayedEvent extends SDKAnalyticsEvent {
|
|
1063
|
+
eventName: SDKEventNameEnum.streamDisplayed;
|
|
1064
|
+
analyticsEvent: SDKEventNameEnum.streamDisplayed;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
export declare interface SDKSubviewDisplayedEvent extends SDKAnalyticsEvent {
|
|
1068
|
+
eventName: SDKEventNameEnum.cardSubviewDisplayed;
|
|
1069
|
+
properties: {
|
|
1070
|
+
subviewId: string;
|
|
1071
|
+
subviewTitle: string;
|
|
1072
|
+
subviewLevel: number;
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
export declare interface SDKSubviewExitedEvent extends SDKAnalyticsEvent {
|
|
1077
|
+
eventName: SDKEventNameEnum.cardSubviewExited;
|
|
1078
|
+
properties: {
|
|
1079
|
+
subviewId: string;
|
|
1080
|
+
subviewTitle: string;
|
|
1081
|
+
subviewLevel: number;
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
export declare interface SDKVideoCompletedEvent extends SDKAnalyticsEvent {
|
|
1086
|
+
eventName: SDKEventNameEnum.videoCompleted;
|
|
1087
|
+
properties: {
|
|
1088
|
+
media: string;
|
|
1089
|
+
mediaURL: string;
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
export declare interface SDKVideoPlayedEvent extends SDKAnalyticsEvent {
|
|
1094
|
+
eventName: SDKEventNameEnum.videoPlayed;
|
|
1095
|
+
properties: {
|
|
1096
|
+
media: string;
|
|
1097
|
+
mediaURL: string;
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export declare interface StandardAnalyticsEvent {
|
|
1102
|
+
id: string;
|
|
1103
|
+
endUserId: string;
|
|
1104
|
+
analyticsEvent: string;
|
|
1105
|
+
timestamp: string;
|
|
1106
|
+
properties: AnalyticsEventProperties;
|
|
1107
|
+
hostContext: AnalyticsEventProperties;
|
|
1108
|
+
eventContext: AnalyticsEventContext;
|
|
1109
|
+
sdkContext: AnalyticsSDKContext;
|
|
1110
|
+
streamContext: AnalyticsStreamContext;
|
|
1111
|
+
cardContext: AnalyticsCardContext;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
export declare class StreamFilter {
|
|
1115
|
+
private filters;
|
|
1116
|
+
private onApplyFilter;
|
|
1117
|
+
private onClearFilter;
|
|
1118
|
+
constructor(onApplyFilter: () => void, onClearFilter: () => void);
|
|
1119
|
+
addVariableFilter: (key: string) => Operators<any>;
|
|
1120
|
+
addPayloadVariableFilter: (key: string) => Operators<any>;
|
|
1121
|
+
addPayloadMetadataFilter: (key: string) => Operators<any>;
|
|
1122
|
+
variableFilter: (namespace: string, key: string, callingFunctionName: string, propertyType?: string) => Operators<any>;
|
|
1123
|
+
addCardTemplateIdFilter: () => Pick<Operators<string>, "equals" | "in" | "notEqualTo" | "notIn">;
|
|
1124
|
+
addCardTemplateNameFilter: () => Pick<Operators<string>, "equals" | "in" | "notEqualTo" | "notIn">;
|
|
1125
|
+
addCardCreatedFilter: () => Pick<Operators<string | Date>, "greaterThan" | "greaterThanOrEqualTo" | "lessThan" | "lessThanOrEqualTo" | "equals" | "notEqualTo">;
|
|
1126
|
+
addCardPriorityFilter: () => Operators<PriorityFilterValue>;
|
|
1127
|
+
clearFilters: () => void;
|
|
1128
|
+
apply: () => void;
|
|
1129
|
+
getFilterObject: () => FilterObject;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
export declare interface SubviewLayout {
|
|
1133
|
+
title: string;
|
|
1134
|
+
nodes: Array<LayoutNode>;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
export declare interface ToastConfig {
|
|
1138
|
+
timeout?: number;
|
|
1139
|
+
toastMessages?: {
|
|
1140
|
+
submittedCard?: string;
|
|
1141
|
+
dismissedCard?: string;
|
|
1142
|
+
snoozedCard?: string;
|
|
1143
|
+
feedbackReceived?: string;
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
export declare interface UIElements {
|
|
1148
|
+
cardListToast?: boolean;
|
|
1149
|
+
customToastContainer?: boolean;
|
|
1150
|
+
toastConfig?: ToastConfig;
|
|
1151
|
+
cardListHeader?: boolean;
|
|
1152
|
+
customContainerHeader?: {
|
|
1153
|
+
scrollHeader?: boolean;
|
|
1154
|
+
headerElement: string;
|
|
1155
|
+
};
|
|
1156
|
+
launcherButton?: LauncherButtonConfig;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Returns card-related metrics for the current user.
|
|
1161
|
+
*
|
|
1162
|
+
* Metrics include:
|
|
1163
|
+
* - How many cards are visible for the user in a given stream container;
|
|
1164
|
+
* - How many cards _in total_ are visible for the user;
|
|
1165
|
+
* - How many cards remain unseen for the user in a given stream container;
|
|
1166
|
+
* - How many cards _in total_ are unseen for the user.
|
|
1167
|
+
*/
|
|
1168
|
+
export declare class UserMetrics {
|
|
1169
|
+
private totals;
|
|
1170
|
+
private metricsByContainer;
|
|
1171
|
+
constructor(data: UserMetricsResponse);
|
|
1172
|
+
unseenCards(): number;
|
|
1173
|
+
totalCards(): number;
|
|
1174
|
+
unseenCardsForStreamContainer(streamContainerId: string): number;
|
|
1175
|
+
totalCardsForStreamContainer(streamContainerId: string): number;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
export declare interface UserMetricsAggregates {
|
|
1179
|
+
cards: UserMetricsCards;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
export declare interface UserMetricsCards {
|
|
1183
|
+
byContainer: ContainerMetric[];
|
|
1184
|
+
total: APIResponseMetric;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
export declare interface UserMetricsResponse {
|
|
1188
|
+
aggregates: UserMetricsAggregates;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
export declare interface UserUpdate {
|
|
1192
|
+
/**
|
|
1193
|
+
* All profile fields are optional.
|
|
1194
|
+
* Custom profile fields can be supplied but must first be defined in the Workbench,
|
|
1195
|
+
* date values for a custom profile field must be a JS Date object or a valid ISO string.
|
|
1196
|
+
*/
|
|
1197
|
+
profile?: {
|
|
1198
|
+
external_id?: string;
|
|
1199
|
+
name?: string;
|
|
1200
|
+
email?: string;
|
|
1201
|
+
phone?: string;
|
|
1202
|
+
city?: string;
|
|
1203
|
+
country?: string;
|
|
1204
|
+
region?: string;
|
|
1205
|
+
[key: string]: string | undefined;
|
|
1206
|
+
};
|
|
1207
|
+
preferences?: {
|
|
1208
|
+
notifications?: NotifyDays;
|
|
1209
|
+
notificationsEnabled?: boolean;
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
export declare interface Validation {
|
|
1214
|
+
attributes: ValidationAttributes;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
export declare interface ValidationAttributes {
|
|
1218
|
+
[key: string]: string | number | boolean;
|
|
1219
|
+
errorMessage?: string;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
export declare interface ValidationMap {
|
|
1223
|
+
[key: ValidationType]: Validation;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
export declare type ValidationType = 'required';
|
|
1227
|
+
|
|
1228
|
+
export declare interface VotingOptions {
|
|
1229
|
+
canVoteUseful: boolean;
|
|
1230
|
+
canVoteNotUseful: boolean;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
export { }
|