@microsurveysai/react-native 0.1.6 → 0.1.8
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 +1 -1
- package/dist/index.cjs +234 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -8
- package/dist/index.d.ts +33 -8
- package/dist/index.js +235 -74
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -74,6 +74,8 @@ interface Trigger {
|
|
|
74
74
|
warmupCount: number;
|
|
75
75
|
steps: TriggerStep[];
|
|
76
76
|
}
|
|
77
|
+
/** Thank-you pace; anything else (or null) is normal. */
|
|
78
|
+
type SuccessPace = "slow" | "fast";
|
|
77
79
|
interface Survey {
|
|
78
80
|
id: string;
|
|
79
81
|
name: string;
|
|
@@ -89,6 +91,8 @@ interface Survey {
|
|
|
89
91
|
/** `"sheet"` | `"dialog"` | null (inherit the project theme's position). */
|
|
90
92
|
presentation?: string | null;
|
|
91
93
|
successMessage?: string | null;
|
|
94
|
+
/** How long the thank-you stays up: "slow" | "fast" | null (normal). */
|
|
95
|
+
successPace?: SuccessPace | null;
|
|
92
96
|
/** Platform targeting for auto-presentation. Empty/absent = all platforms.
|
|
93
97
|
* The engine skips a survey whose list is non-empty and excludes the client's
|
|
94
98
|
* platform. Explicit inline `<MicroSurvey>` embeds ignore this. */
|
|
@@ -203,12 +207,20 @@ interface CreateClientOptions {
|
|
|
203
207
|
* server events mailbox timers. */
|
|
204
208
|
subscribeBackground?: (onBackground: () => void) => () => void;
|
|
205
209
|
}
|
|
206
|
-
/**
|
|
207
|
-
* when the UI
|
|
210
|
+
/** A survey the host should present. Call `shown` once it is on screen (this
|
|
211
|
+
* sends the impression), then `close` once when the UI goes away (completed,
|
|
212
|
+
* partial, or dismissed). Both are safe to call more than once. */
|
|
208
213
|
interface ActiveSurvey {
|
|
209
214
|
survey: Survey;
|
|
215
|
+
/** The trigger that fired; null for an inline survey. */
|
|
210
216
|
trigger: Trigger | null;
|
|
211
|
-
|
|
217
|
+
/** The survey is on screen: queues its impression (`dismissed: false`). */
|
|
218
|
+
shown(): void;
|
|
219
|
+
/** The survey went away. A dismissal re-sends the impression with
|
|
220
|
+
* `dismissed: true`; answers are sent as a response. Without a result (the
|
|
221
|
+
* survey never got to show), nothing more is sent. If `shown` was never
|
|
222
|
+
* called, the impression is sent now, with the final `dismissed`. */
|
|
223
|
+
close(result?: SurveyResult | null): void;
|
|
212
224
|
}
|
|
213
225
|
type PresentListener = (active: ActiveSurvey) => void;
|
|
214
226
|
type ConfigListener = () => void;
|
|
@@ -288,8 +300,16 @@ declare class MicroSurveysClient {
|
|
|
288
300
|
* survey is already active, the new subscriber is notified immediately. */
|
|
289
301
|
onPresent(cb: PresentListener): () => void;
|
|
290
302
|
private handlePresent;
|
|
303
|
+
private newPresentation;
|
|
291
304
|
private toActiveSurvey;
|
|
292
|
-
/**
|
|
305
|
+
/** Queues the impression the moment the survey is on screen, so it counts even
|
|
306
|
+
* if the app is killed before the survey closes. */
|
|
307
|
+
private markShown;
|
|
308
|
+
/** An **inline** `<MicroSurvey>` (no trigger, no gate, not "the" active survey).
|
|
309
|
+
* Call `shown` when it renders and `close` with its outcome. */
|
|
310
|
+
presentInline(survey: Survey): ActiveSurvey;
|
|
311
|
+
/** Records the outcome of an inline survey in one go, at close. Prefer
|
|
312
|
+
* `presentInline`, which sends the impression when the survey appears. */
|
|
293
313
|
recordInline(survey: Survey, result: SurveyResult, shownAt: Date): void;
|
|
294
314
|
private recordOutcome;
|
|
295
315
|
/** Where this showing happened. The language is read at record time: the user
|
|
@@ -337,8 +357,9 @@ interface MicroSurveysOptions {
|
|
|
337
357
|
apiKey: string;
|
|
338
358
|
/** Override for self-hosted deployments. Defaults to https://console.microsurveys.ai. */
|
|
339
359
|
apiBaseURL?: string;
|
|
340
|
-
/** Refresh config (when stale)
|
|
341
|
-
*
|
|
360
|
+
/** Refresh config (when stale) whenever the app returns to the foreground.
|
|
361
|
+
* Default true. (Queued impressions/responses are retried on every foreground
|
|
362
|
+
* either way.) */
|
|
342
363
|
refreshOnForeground?: boolean;
|
|
343
364
|
/** Foreground freshness window for the cached config, in ms. Default 12h. */
|
|
344
365
|
configTTLms?: number;
|
|
@@ -386,7 +407,11 @@ declare class MicroSurveys {
|
|
|
386
407
|
onConfigChange(cb: () => void): () => void;
|
|
387
408
|
/** Subscribe to auto-triggered surveys. Returns an unsubscribe function. */
|
|
388
409
|
onPresent(cb: (active: ActiveSurvey) => void): () => void;
|
|
389
|
-
/**
|
|
410
|
+
/** Starts one showing of an inline `<MicroSurvey>`: call `shown` once it
|
|
411
|
+
* renders (sends the impression) and `close` with its outcome. */
|
|
412
|
+
presentInline(survey: Survey): ActiveSurvey;
|
|
413
|
+
/** Records the outcome of an inline survey in one go, at close. Prefer
|
|
414
|
+
* `presentInline`, which sends the impression when the survey appears. */
|
|
390
415
|
recordInline(survey: Survey, result: SurveyResult, shownAt: Date): void;
|
|
391
416
|
}
|
|
392
417
|
|
|
@@ -441,4 +466,4 @@ interface SurveyModalProps {
|
|
|
441
466
|
}
|
|
442
467
|
declare function SurveyModal({ survey, theme: projectTheme, fontFamily, onResult, onClose }: SurveyModalProps): react.JSX.Element | null;
|
|
443
468
|
|
|
444
|
-
export { type AmplitudeEvent, type AnswerValue, type AsyncKeyValueStorage, type KeyValueStorage, MicroSurvey, type MicroSurveyProps, MicroSurveys, type MicroSurveysAmplitudePlugin, type MicroSurveysOptions, MicroSurveysProvider, type MicroSurveysProviderProps, type ProjectTheme, type Question, type Survey, type SurveyAnswer, SurveyModal, type SurveyModalProps, type SurveyResult, hydrateAsyncStorage, parseConfig, useMicroSurveys, useMicroSurveysInstance };
|
|
469
|
+
export { type AmplitudeEvent, type AnswerValue, type AsyncKeyValueStorage, type KeyValueStorage, MicroSurvey, type MicroSurveyProps, MicroSurveys, type MicroSurveysAmplitudePlugin, type MicroSurveysOptions, MicroSurveysProvider, type MicroSurveysProviderProps, type ProjectTheme, type Question, type SuccessPace, type Survey, type SurveyAnswer, SurveyModal, type SurveyModalProps, type SurveyResult, hydrateAsyncStorage, parseConfig, useMicroSurveys, useMicroSurveysInstance };
|
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,8 @@ interface Trigger {
|
|
|
74
74
|
warmupCount: number;
|
|
75
75
|
steps: TriggerStep[];
|
|
76
76
|
}
|
|
77
|
+
/** Thank-you pace; anything else (or null) is normal. */
|
|
78
|
+
type SuccessPace = "slow" | "fast";
|
|
77
79
|
interface Survey {
|
|
78
80
|
id: string;
|
|
79
81
|
name: string;
|
|
@@ -89,6 +91,8 @@ interface Survey {
|
|
|
89
91
|
/** `"sheet"` | `"dialog"` | null (inherit the project theme's position). */
|
|
90
92
|
presentation?: string | null;
|
|
91
93
|
successMessage?: string | null;
|
|
94
|
+
/** How long the thank-you stays up: "slow" | "fast" | null (normal). */
|
|
95
|
+
successPace?: SuccessPace | null;
|
|
92
96
|
/** Platform targeting for auto-presentation. Empty/absent = all platforms.
|
|
93
97
|
* The engine skips a survey whose list is non-empty and excludes the client's
|
|
94
98
|
* platform. Explicit inline `<MicroSurvey>` embeds ignore this. */
|
|
@@ -203,12 +207,20 @@ interface CreateClientOptions {
|
|
|
203
207
|
* server events mailbox timers. */
|
|
204
208
|
subscribeBackground?: (onBackground: () => void) => () => void;
|
|
205
209
|
}
|
|
206
|
-
/**
|
|
207
|
-
* when the UI
|
|
210
|
+
/** A survey the host should present. Call `shown` once it is on screen (this
|
|
211
|
+
* sends the impression), then `close` once when the UI goes away (completed,
|
|
212
|
+
* partial, or dismissed). Both are safe to call more than once. */
|
|
208
213
|
interface ActiveSurvey {
|
|
209
214
|
survey: Survey;
|
|
215
|
+
/** The trigger that fired; null for an inline survey. */
|
|
210
216
|
trigger: Trigger | null;
|
|
211
|
-
|
|
217
|
+
/** The survey is on screen: queues its impression (`dismissed: false`). */
|
|
218
|
+
shown(): void;
|
|
219
|
+
/** The survey went away. A dismissal re-sends the impression with
|
|
220
|
+
* `dismissed: true`; answers are sent as a response. Without a result (the
|
|
221
|
+
* survey never got to show), nothing more is sent. If `shown` was never
|
|
222
|
+
* called, the impression is sent now, with the final `dismissed`. */
|
|
223
|
+
close(result?: SurveyResult | null): void;
|
|
212
224
|
}
|
|
213
225
|
type PresentListener = (active: ActiveSurvey) => void;
|
|
214
226
|
type ConfigListener = () => void;
|
|
@@ -288,8 +300,16 @@ declare class MicroSurveysClient {
|
|
|
288
300
|
* survey is already active, the new subscriber is notified immediately. */
|
|
289
301
|
onPresent(cb: PresentListener): () => void;
|
|
290
302
|
private handlePresent;
|
|
303
|
+
private newPresentation;
|
|
291
304
|
private toActiveSurvey;
|
|
292
|
-
/**
|
|
305
|
+
/** Queues the impression the moment the survey is on screen, so it counts even
|
|
306
|
+
* if the app is killed before the survey closes. */
|
|
307
|
+
private markShown;
|
|
308
|
+
/** An **inline** `<MicroSurvey>` (no trigger, no gate, not "the" active survey).
|
|
309
|
+
* Call `shown` when it renders and `close` with its outcome. */
|
|
310
|
+
presentInline(survey: Survey): ActiveSurvey;
|
|
311
|
+
/** Records the outcome of an inline survey in one go, at close. Prefer
|
|
312
|
+
* `presentInline`, which sends the impression when the survey appears. */
|
|
293
313
|
recordInline(survey: Survey, result: SurveyResult, shownAt: Date): void;
|
|
294
314
|
private recordOutcome;
|
|
295
315
|
/** Where this showing happened. The language is read at record time: the user
|
|
@@ -337,8 +357,9 @@ interface MicroSurveysOptions {
|
|
|
337
357
|
apiKey: string;
|
|
338
358
|
/** Override for self-hosted deployments. Defaults to https://console.microsurveys.ai. */
|
|
339
359
|
apiBaseURL?: string;
|
|
340
|
-
/** Refresh config (when stale)
|
|
341
|
-
*
|
|
360
|
+
/** Refresh config (when stale) whenever the app returns to the foreground.
|
|
361
|
+
* Default true. (Queued impressions/responses are retried on every foreground
|
|
362
|
+
* either way.) */
|
|
342
363
|
refreshOnForeground?: boolean;
|
|
343
364
|
/** Foreground freshness window for the cached config, in ms. Default 12h. */
|
|
344
365
|
configTTLms?: number;
|
|
@@ -386,7 +407,11 @@ declare class MicroSurveys {
|
|
|
386
407
|
onConfigChange(cb: () => void): () => void;
|
|
387
408
|
/** Subscribe to auto-triggered surveys. Returns an unsubscribe function. */
|
|
388
409
|
onPresent(cb: (active: ActiveSurvey) => void): () => void;
|
|
389
|
-
/**
|
|
410
|
+
/** Starts one showing of an inline `<MicroSurvey>`: call `shown` once it
|
|
411
|
+
* renders (sends the impression) and `close` with its outcome. */
|
|
412
|
+
presentInline(survey: Survey): ActiveSurvey;
|
|
413
|
+
/** Records the outcome of an inline survey in one go, at close. Prefer
|
|
414
|
+
* `presentInline`, which sends the impression when the survey appears. */
|
|
390
415
|
recordInline(survey: Survey, result: SurveyResult, shownAt: Date): void;
|
|
391
416
|
}
|
|
392
417
|
|
|
@@ -441,4 +466,4 @@ interface SurveyModalProps {
|
|
|
441
466
|
}
|
|
442
467
|
declare function SurveyModal({ survey, theme: projectTheme, fontFamily, onResult, onClose }: SurveyModalProps): react.JSX.Element | null;
|
|
443
468
|
|
|
444
|
-
export { type AmplitudeEvent, type AnswerValue, type AsyncKeyValueStorage, type KeyValueStorage, MicroSurvey, type MicroSurveyProps, MicroSurveys, type MicroSurveysAmplitudePlugin, type MicroSurveysOptions, MicroSurveysProvider, type MicroSurveysProviderProps, type ProjectTheme, type Question, type Survey, type SurveyAnswer, SurveyModal, type SurveyModalProps, type SurveyResult, hydrateAsyncStorage, parseConfig, useMicroSurveys, useMicroSurveysInstance };
|
|
469
|
+
export { type AmplitudeEvent, type AnswerValue, type AsyncKeyValueStorage, type KeyValueStorage, MicroSurvey, type MicroSurveyProps, MicroSurveys, type MicroSurveysAmplitudePlugin, type MicroSurveysOptions, MicroSurveysProvider, type MicroSurveysProviderProps, type ProjectTheme, type Question, type SuccessPace, type Survey, type SurveyAnswer, SurveyModal, type SurveyModalProps, type SurveyResult, hydrateAsyncStorage, parseConfig, useMicroSurveys, useMicroSurveysInstance };
|