@sovaria/sdk 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/README.md +248 -2
- package/dist/analytics.d.ts +92 -0
- package/dist/analytics.js +236 -0
- package/dist/client.d.ts +146 -0
- package/dist/client.js +583 -0
- package/dist/collections.d.ts +255 -0
- package/dist/collections.js +569 -0
- package/dist/complete-api.d.ts +54 -0
- package/dist/complete-api.js +71 -0
- package/dist/crashes.d.ts +111 -0
- package/dist/crashes.js +244 -0
- package/dist/crypto.d.ts +37 -0
- package/dist/crypto.js +189 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.js +258 -0
- package/dist/firestore.d.ts +239 -0
- package/dist/firestore.js +431 -0
- package/dist/generated.d.ts +2462 -0
- package/dist/generated.js +1962 -0
- package/dist/inapp.d.ts +52 -0
- package/dist/inapp.js +48 -0
- package/dist/index.d.ts +3562 -0
- package/dist/index.js +3018 -0
- package/dist/offline.d.ts +92 -0
- package/dist/offline.js +575 -0
- package/dist/passkeys.d.ts +17 -0
- package/dist/passkeys.js +76 -0
- package/dist/perf.d.ts +76 -0
- package/dist/perf.js +212 -0
- package/dist/remote-config.d.ts +87 -0
- package/dist/remote-config.js +182 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.js +1 -0
- package/dist/webpush.d.ts +46 -0
- package/dist/webpush.js +99 -0
- package/package.json +74 -4
package/dist/inapp.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-app messages and message engagement (opens and clicks).
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* // On app start (and on screens / events you target in the console):
|
|
6
|
+
* const [msg] = await sov.inApp.fetch('app_open')
|
|
7
|
+
* if (msg) { showBanner(msg.content); await sov.inApp.impression(msg.id) }
|
|
8
|
+
* // button → await sov.inApp.click(msg.id); close → await sov.inApp.dismiss(msg.id)
|
|
9
|
+
*
|
|
10
|
+
* // When the user opens a push notification (its data has sov_send):
|
|
11
|
+
* await sov.inApp.trackOpen(notification.data)
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Messages are headless: your app draws them (`content.layout` is `banner`, `modal` or `card`, with `title`, `body`,
|
|
15
|
+
* `image` and up to two `buttons` `{label, action}`), so they match your design. A message is shown to a user at most
|
|
16
|
+
* its `max_impressions` times, and never again after a dismissal.
|
|
17
|
+
*/
|
|
18
|
+
export interface InAppMessage {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
trigger: string;
|
|
22
|
+
priority: number;
|
|
23
|
+
content: {
|
|
24
|
+
title: string;
|
|
25
|
+
body: string;
|
|
26
|
+
image: string | null;
|
|
27
|
+
layout: 'banner' | 'modal' | 'card';
|
|
28
|
+
buttons: {
|
|
29
|
+
label: string;
|
|
30
|
+
action: string | null;
|
|
31
|
+
}[];
|
|
32
|
+
data: Record<string, string>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
type Requester = <T>(method: string, path: string, options?: {
|
|
36
|
+
body?: unknown;
|
|
37
|
+
query?: Record<string, string | number>;
|
|
38
|
+
requiresScope?: boolean;
|
|
39
|
+
}) => Promise<T>;
|
|
40
|
+
export declare class InAppMessages {
|
|
41
|
+
private readonly request;
|
|
42
|
+
constructor(request: Requester);
|
|
43
|
+
/** Messages the signed-in user should see now for `trigger` (`app_open`, `screen:<name>`, `event:<name>`). */
|
|
44
|
+
fetch(trigger?: string, limit?: number): Promise<InAppMessage[]>;
|
|
45
|
+
impression(id: string): Promise<unknown>;
|
|
46
|
+
click(id: string): Promise<unknown>;
|
|
47
|
+
dismiss(id: string): Promise<unknown>;
|
|
48
|
+
/** Report that the user opened a push from a messaging send (`data.sov_send`); does nothing for other pushes. */
|
|
49
|
+
trackOpen(data: Record<string, unknown> | null | undefined, kind?: 'open' | 'click'): Promise<boolean>;
|
|
50
|
+
private event;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
package/dist/inapp.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-app messages and message engagement (opens and clicks).
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* // On app start (and on screens / events you target in the console):
|
|
6
|
+
* const [msg] = await sov.inApp.fetch('app_open')
|
|
7
|
+
* if (msg) { showBanner(msg.content); await sov.inApp.impression(msg.id) }
|
|
8
|
+
* // button → await sov.inApp.click(msg.id); close → await sov.inApp.dismiss(msg.id)
|
|
9
|
+
*
|
|
10
|
+
* // When the user opens a push notification (its data has sov_send):
|
|
11
|
+
* await sov.inApp.trackOpen(notification.data)
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Messages are headless: your app draws them (`content.layout` is `banner`, `modal` or `card`, with `title`, `body`,
|
|
15
|
+
* `image` and up to two `buttons` `{label, action}`), so they match your design. A message is shown to a user at most
|
|
16
|
+
* its `max_impressions` times, and never again after a dismissal.
|
|
17
|
+
*/
|
|
18
|
+
export class InAppMessages {
|
|
19
|
+
request;
|
|
20
|
+
constructor(request) {
|
|
21
|
+
this.request = request;
|
|
22
|
+
}
|
|
23
|
+
/** Messages the signed-in user should see now for `trigger` (`app_open`, `screen:<name>`, `event:<name>`). */
|
|
24
|
+
async fetch(trigger = 'app_open', limit = 3) {
|
|
25
|
+
const out = await this.request('GET', '/api/v1/messaging/in-app', { query: { trigger, limit }, requiresScope: false });
|
|
26
|
+
return out.messages ?? [];
|
|
27
|
+
}
|
|
28
|
+
impression(id) {
|
|
29
|
+
return this.event(id, 'impression');
|
|
30
|
+
}
|
|
31
|
+
click(id) {
|
|
32
|
+
return this.event(id, 'click');
|
|
33
|
+
}
|
|
34
|
+
dismiss(id) {
|
|
35
|
+
return this.event(id, 'dismiss');
|
|
36
|
+
}
|
|
37
|
+
/** Report that the user opened a push from a messaging send (`data.sov_send`); does nothing for other pushes. */
|
|
38
|
+
async trackOpen(data, kind = 'open') {
|
|
39
|
+
const sendId = typeof data?.sov_send === 'string' ? data.sov_send : '';
|
|
40
|
+
if (!sendId)
|
|
41
|
+
return false;
|
|
42
|
+
const out = await this.request('POST', '/api/v1/messaging/events', { body: { send_id: sendId, channel: 'push', kind }, requiresScope: false });
|
|
43
|
+
return Boolean(out?.recorded);
|
|
44
|
+
}
|
|
45
|
+
event(id, kind) {
|
|
46
|
+
return this.request('POST', `/api/v1/messaging/in-app/${encodeURIComponent(id)}/events`, { body: { kind }, requiresScope: false });
|
|
47
|
+
}
|
|
48
|
+
}
|