@microsurveysai/react-native 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +380 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -2
- package/dist/index.d.ts +53 -2
- package/dist/index.js +380 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -99,6 +99,18 @@ interface SDKConfig {
|
|
|
99
99
|
fetchedAt?: string | null;
|
|
100
100
|
theme: ProjectTheme | null;
|
|
101
101
|
surveys: Survey[];
|
|
102
|
+
/** The project turned event signals on: count tracked events and upload the
|
|
103
|
+
* counts (see eventCounter.ts). Absent on older servers, which means off. */
|
|
104
|
+
eventSignals: boolean;
|
|
105
|
+
/** Hashes of the project's test devices for the live debugger (see debug.ts).
|
|
106
|
+
* Empty when none are set, or on older servers. */
|
|
107
|
+
debugUsers: string[];
|
|
108
|
+
/** The project has server events waiting to be picked up: check the mailbox
|
|
109
|
+
* (`POST /api/sdk/pending`). Absent on older servers, which means off. */
|
|
110
|
+
pendingEvents: boolean;
|
|
111
|
+
/** Trigger event names that arrive by server stream rather than from the app.
|
|
112
|
+
* A sequence waiting on one of them as its next step checks more often. */
|
|
113
|
+
serverEvents: string[];
|
|
102
114
|
}
|
|
103
115
|
/** Brand-level survey appearance (API-CONTRACT §Theme). All keys optional. */
|
|
104
116
|
interface ProjectTheme {
|
|
@@ -186,6 +198,10 @@ interface CreateClientOptions {
|
|
|
186
198
|
storage: KeyValueStorage;
|
|
187
199
|
/** Subscribes to "app came to the foreground"; returns an unsubscribe. */
|
|
188
200
|
subscribeForeground: (onForeground: () => void) => () => void;
|
|
201
|
+
/** Subscribes to "app went to the background"; returns an unsubscribe. Used
|
|
202
|
+
* to upload event counts before the app may be suspended, and to stop the
|
|
203
|
+
* server events mailbox timers. */
|
|
204
|
+
subscribeBackground?: (onBackground: () => void) => () => void;
|
|
189
205
|
}
|
|
190
206
|
/** An auto-triggered survey the host should present. Call `close` exactly once
|
|
191
207
|
* when the UI dismisses (completed, partial, or dismissed). */
|
|
@@ -208,14 +224,24 @@ declare class MicroSurveysClient {
|
|
|
208
224
|
private readonly osVersion;
|
|
209
225
|
private readonly appVersion;
|
|
210
226
|
private readonly subscribeForeground;
|
|
227
|
+
private readonly subscribeBackground;
|
|
228
|
+
private readonly eventCounter;
|
|
229
|
+
private eventCountsTimer;
|
|
230
|
+
/** Decisions collected while one event is processed, for the live debugger. */
|
|
231
|
+
private collecting;
|
|
232
|
+
private unsubscribeBackground;
|
|
233
|
+
/** Mailbox timers, cleared on background and stop. */
|
|
234
|
+
private pendingTimers;
|
|
235
|
+
private pendingIntervals;
|
|
236
|
+
private pendingInFlight;
|
|
211
237
|
private readonly presentListeners;
|
|
212
238
|
private readonly configListeners;
|
|
213
239
|
private active;
|
|
214
240
|
private started;
|
|
215
241
|
private unsubscribeForeground;
|
|
216
242
|
constructor(opts: CreateClientOptions);
|
|
217
|
-
/** Flush any queued ingest, refresh config,
|
|
218
|
-
*
|
|
243
|
+
/** Flush any queued ingest, refresh config, wire the foreground refresh
|
|
244
|
+
* (optional) and the server events mailbox checks. Safe to call once early. */
|
|
219
245
|
start(): void;
|
|
220
246
|
/** Tear down listeners + pending timers. */
|
|
221
247
|
stop(): void;
|
|
@@ -225,6 +251,31 @@ declare class MicroSurveysClient {
|
|
|
225
251
|
refreshConfigIfStale(): void;
|
|
226
252
|
identify(userId: string | null | undefined, properties?: Record<string, unknown>): void;
|
|
227
253
|
track(name: string, properties?: Record<string, unknown>): void;
|
|
254
|
+
/** Runs one event through the engine, reporting to the live debugger on test
|
|
255
|
+
* devices. `occurredAt` (ms epoch) is set for a replayed server event. */
|
|
256
|
+
private processEvent;
|
|
257
|
+
/** Checks now, then 30 s and 90 s later, every 5 minutes, and every 60 s while
|
|
258
|
+
* a sequence waits on a server event. Restarts the schedule; no-op unless the
|
|
259
|
+
* config has `pendingEvents`. */
|
|
260
|
+
private startPendingChecks;
|
|
261
|
+
private stopPendingChecks;
|
|
262
|
+
/** Fetches and replays this user's waiting server events. One request at a
|
|
263
|
+
* time; a full page is followed by one more call. Failures are silent: the
|
|
264
|
+
* next scheduled check retries. */
|
|
265
|
+
private checkPending;
|
|
266
|
+
/** Replays server events like `track`, oldest first, at the time each one
|
|
267
|
+
* happened. Not counted in event signals: the app didn't send them. */
|
|
268
|
+
private replayPending;
|
|
269
|
+
/** True while a SEQUENCE trigger for the current user has started and its next
|
|
270
|
+
* step's event arrives by server stream, up to 3 hours after it started. */
|
|
271
|
+
private isWaitingOnServerEvent;
|
|
272
|
+
/** True when the dashboard picked the current user as a test device. */
|
|
273
|
+
private isDebugDevice;
|
|
274
|
+
private handleDecision;
|
|
275
|
+
/** `at` (ms epoch) defaults to now; a replayed server event passes its `occurredAt`. */
|
|
276
|
+
private sendDebug;
|
|
277
|
+
/** Uploads the events counted since the last upload (no-op when there are none). */
|
|
278
|
+
flushEventCounts(): void;
|
|
228
279
|
/** Merge identity forwarded by an analytics SDK (e.g. the Amplitude plugin).
|
|
229
280
|
* Its user/device id take precedence over `identify()` for `endUserId`. */
|
|
230
281
|
updateAnalyticsIdentity(update: AnalyticsIdentity): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -99,6 +99,18 @@ interface SDKConfig {
|
|
|
99
99
|
fetchedAt?: string | null;
|
|
100
100
|
theme: ProjectTheme | null;
|
|
101
101
|
surveys: Survey[];
|
|
102
|
+
/** The project turned event signals on: count tracked events and upload the
|
|
103
|
+
* counts (see eventCounter.ts). Absent on older servers, which means off. */
|
|
104
|
+
eventSignals: boolean;
|
|
105
|
+
/** Hashes of the project's test devices for the live debugger (see debug.ts).
|
|
106
|
+
* Empty when none are set, or on older servers. */
|
|
107
|
+
debugUsers: string[];
|
|
108
|
+
/** The project has server events waiting to be picked up: check the mailbox
|
|
109
|
+
* (`POST /api/sdk/pending`). Absent on older servers, which means off. */
|
|
110
|
+
pendingEvents: boolean;
|
|
111
|
+
/** Trigger event names that arrive by server stream rather than from the app.
|
|
112
|
+
* A sequence waiting on one of them as its next step checks more often. */
|
|
113
|
+
serverEvents: string[];
|
|
102
114
|
}
|
|
103
115
|
/** Brand-level survey appearance (API-CONTRACT §Theme). All keys optional. */
|
|
104
116
|
interface ProjectTheme {
|
|
@@ -186,6 +198,10 @@ interface CreateClientOptions {
|
|
|
186
198
|
storage: KeyValueStorage;
|
|
187
199
|
/** Subscribes to "app came to the foreground"; returns an unsubscribe. */
|
|
188
200
|
subscribeForeground: (onForeground: () => void) => () => void;
|
|
201
|
+
/** Subscribes to "app went to the background"; returns an unsubscribe. Used
|
|
202
|
+
* to upload event counts before the app may be suspended, and to stop the
|
|
203
|
+
* server events mailbox timers. */
|
|
204
|
+
subscribeBackground?: (onBackground: () => void) => () => void;
|
|
189
205
|
}
|
|
190
206
|
/** An auto-triggered survey the host should present. Call `close` exactly once
|
|
191
207
|
* when the UI dismisses (completed, partial, or dismissed). */
|
|
@@ -208,14 +224,24 @@ declare class MicroSurveysClient {
|
|
|
208
224
|
private readonly osVersion;
|
|
209
225
|
private readonly appVersion;
|
|
210
226
|
private readonly subscribeForeground;
|
|
227
|
+
private readonly subscribeBackground;
|
|
228
|
+
private readonly eventCounter;
|
|
229
|
+
private eventCountsTimer;
|
|
230
|
+
/** Decisions collected while one event is processed, for the live debugger. */
|
|
231
|
+
private collecting;
|
|
232
|
+
private unsubscribeBackground;
|
|
233
|
+
/** Mailbox timers, cleared on background and stop. */
|
|
234
|
+
private pendingTimers;
|
|
235
|
+
private pendingIntervals;
|
|
236
|
+
private pendingInFlight;
|
|
211
237
|
private readonly presentListeners;
|
|
212
238
|
private readonly configListeners;
|
|
213
239
|
private active;
|
|
214
240
|
private started;
|
|
215
241
|
private unsubscribeForeground;
|
|
216
242
|
constructor(opts: CreateClientOptions);
|
|
217
|
-
/** Flush any queued ingest, refresh config,
|
|
218
|
-
*
|
|
243
|
+
/** Flush any queued ingest, refresh config, wire the foreground refresh
|
|
244
|
+
* (optional) and the server events mailbox checks. Safe to call once early. */
|
|
219
245
|
start(): void;
|
|
220
246
|
/** Tear down listeners + pending timers. */
|
|
221
247
|
stop(): void;
|
|
@@ -225,6 +251,31 @@ declare class MicroSurveysClient {
|
|
|
225
251
|
refreshConfigIfStale(): void;
|
|
226
252
|
identify(userId: string | null | undefined, properties?: Record<string, unknown>): void;
|
|
227
253
|
track(name: string, properties?: Record<string, unknown>): void;
|
|
254
|
+
/** Runs one event through the engine, reporting to the live debugger on test
|
|
255
|
+
* devices. `occurredAt` (ms epoch) is set for a replayed server event. */
|
|
256
|
+
private processEvent;
|
|
257
|
+
/** Checks now, then 30 s and 90 s later, every 5 minutes, and every 60 s while
|
|
258
|
+
* a sequence waits on a server event. Restarts the schedule; no-op unless the
|
|
259
|
+
* config has `pendingEvents`. */
|
|
260
|
+
private startPendingChecks;
|
|
261
|
+
private stopPendingChecks;
|
|
262
|
+
/** Fetches and replays this user's waiting server events. One request at a
|
|
263
|
+
* time; a full page is followed by one more call. Failures are silent: the
|
|
264
|
+
* next scheduled check retries. */
|
|
265
|
+
private checkPending;
|
|
266
|
+
/** Replays server events like `track`, oldest first, at the time each one
|
|
267
|
+
* happened. Not counted in event signals: the app didn't send them. */
|
|
268
|
+
private replayPending;
|
|
269
|
+
/** True while a SEQUENCE trigger for the current user has started and its next
|
|
270
|
+
* step's event arrives by server stream, up to 3 hours after it started. */
|
|
271
|
+
private isWaitingOnServerEvent;
|
|
272
|
+
/** True when the dashboard picked the current user as a test device. */
|
|
273
|
+
private isDebugDevice;
|
|
274
|
+
private handleDecision;
|
|
275
|
+
/** `at` (ms epoch) defaults to now; a replayed server event passes its `occurredAt`. */
|
|
276
|
+
private sendDebug;
|
|
277
|
+
/** Uploads the events counted since the last upload (no-op when there are none). */
|
|
278
|
+
flushEventCounts(): void;
|
|
228
279
|
/** Merge identity forwarded by an analytics SDK (e.g. the Amplitude plugin).
|
|
229
280
|
* Its user/device id take precedence over `identify()` for `endUserId`. */
|
|
230
281
|
updateAnalyticsIdentity(update: AnalyticsIdentity): void;
|