@mrrocket/sdk 0.2.0 → 0.4.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.
@@ -0,0 +1,259 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * The part of the SDK that runs anywhere: experiment config, variant assignment, preview links and event shapes.
6
+ * No React, no browser APIs, so the server helper, the proxy helper and the client share it.
7
+ */
8
+ type VariantId = string;
9
+ /** This build of the SDK. Sent with the config request so MRRocket knows what the site runs (error tracking, flags). */
10
+ declare const SDK_VERSION = "0.4.0";
11
+ /** One variant of an experiment. `changes` replaces texts that the page marks with `<Text id>`. */
12
+ interface VariantConfig {
13
+ id: VariantId;
14
+ /** Share of traffic, 0 to 1. The weights of an experiment add up to 1. */
15
+ weight: number;
16
+ changes?: Record<string, string>;
17
+ }
18
+ interface ExperimentConfig {
19
+ /** The experiment's key, the same as in Cockpit. */
20
+ key: string;
21
+ status: "running" | "draft" | "stopped";
22
+ /** Control first. */
23
+ variants: VariantConfig[];
24
+ /** A winner that shipped: everyone gets it, and nobody is assigned anymore. */
25
+ winner?: VariantId;
26
+ }
27
+ interface CockpitConfig {
28
+ /** The product the public key belongs to. */
29
+ project: string;
30
+ experiments: ExperimentConfig[];
31
+ /** The product's affiliate program: how many days a partner's referral is kept. Missing without a program. */
32
+ referral?: {
33
+ cookieDays: number;
34
+ };
35
+ /** Session recordings: present only while the product records (Cockpit › Sessions). See `ReplayConfig`. */
36
+ replay?: ReplayConfig;
37
+ /** Feature flags of the product in Production (MRRocket › Build › Feature flags), evaluated by `useFlag` and `getFlag`. */
38
+ flags?: FlagConfig[];
39
+ }
40
+ /** One condition of a flag's audience, on a property of the person (`identify(id, props)`), the id or the page. */
41
+ interface FlagCondition {
42
+ /** "Email", "Plan", "Country", "id", "path" … Matched against the person's properties without regard to case. */
43
+ property: string;
44
+ op: "is" | "is not" | "in" | "not in" | "≥" | "in cohort";
45
+ values: string[];
46
+ }
47
+ /** Users who match every condition, of whom `rollout` percent get the flag. No conditions: everyone. */
48
+ interface FlagConditionSet {
49
+ conditions: FlagCondition[];
50
+ /** 0 to 100. */
51
+ rollout: number;
52
+ }
53
+ interface FlagConfig {
54
+ key: string;
55
+ /** Off: everyone gets the off side. */
56
+ on: boolean;
57
+ /** The first set a person matches decides; none matched: off. */
58
+ sets: FlagConditionSet[];
59
+ /** Multivariate flags: the variants and their split in percent (control included). Missing for an on/off flag. */
60
+ variants?: {
61
+ key: string;
62
+ split: number;
63
+ payload?: string;
64
+ }[];
65
+ }
66
+ /**
67
+ * Session recordings of a product, from the config. Recording also needs the visitor's own replay consent
68
+ * (`<CockpitProvider replay>` or `setConsent({ replay: true })`); without it nothing is recorded or buffered.
69
+ */
70
+ interface ReplayConfig {
71
+ /**
72
+ * Share of sessions uploaded from their start, 0 to 1 (default 0.1). The others keep only the last minute in
73
+ * memory and upload it when something goes wrong: a JS error, a rage click, a `purchase…` or `checkout…` event.
74
+ */
75
+ sampleRate: number;
76
+ }
77
+ /** One event as it goes over the wire to `POST /api/sdk/events`. */
78
+ interface CockpitEvent {
79
+ event: string;
80
+ /** The visitor. Missing in "cookieless" mode until identify(): the server then uses its daily visitor hash. */
81
+ distinctId?: string;
82
+ /** Ends after 30 minutes without an event. */
83
+ sessionId?: string;
84
+ props?: Record<string, unknown>;
85
+ /** Milliseconds since the epoch. */
86
+ ts: number;
87
+ url?: string;
88
+ /** `document.referrer` on the first page of a page load, the previous in-app URL after client-side navigation. */
89
+ referrer?: string;
90
+ utm_source?: string;
91
+ utm_medium?: string;
92
+ utm_campaign?: string;
93
+ utm_term?: string;
94
+ utm_content?: string;
95
+ /** The screen size in CSS pixels (points on a phone). */
96
+ screen?: {
97
+ w: number;
98
+ h: number;
99
+ };
100
+ /** The app that sent it (React Native only): MRRocket stores it with the event and fills OS and device from it. */
101
+ app?: AppContext;
102
+ }
103
+ /** Where a React Native event comes from. Every field is optional except the platform; nothing identifies the person. */
104
+ interface AppContext {
105
+ /** "ios" or "android" (React Native's `Platform.OS`). */
106
+ platform: string;
107
+ /** The app's version, like "1.4.0" (`expo-application`'s `nativeApplicationVersion`). */
108
+ appVersion?: string;
109
+ /** The build number, like "42". */
110
+ build?: string;
111
+ /** The OS version, like "17.4". */
112
+ osVersion?: string;
113
+ /** The device model, like "iPhone 15 Pro" (`expo-device`). */
114
+ deviceModel?: string;
115
+ /** "phone", "tablet", "desktop" or "tv" when `expo-device` knows it. */
116
+ deviceType?: string;
117
+ /** The first preferred locale, like "de-DE". */
118
+ locale?: string;
119
+ }
120
+
121
+ /**
122
+ * What the app may send and store.
123
+ * - "anonymous" (default): no id is stored on the device. Events go without a person id until `identify()` (MRRocket
124
+ * counts visitors by its daily hash); flags and experiments use a random id that lives until the app is closed.
125
+ * - "persistent": a random install id is stored on the device (removed with the app) and sent with every event.
126
+ * - "off": nothing is sent, and what the SDK stored is deleted.
127
+ */
128
+ type NativeConsent = "anonymous" | "persistent" | "off";
129
+ interface MRRocketOptions {
130
+ /** The product's public key (MRRocket › Settings › Products), the same as on the website. */
131
+ apiKey: string;
132
+ /** Where MRRocket runs. Default `https://app.mrrocket.dev`. */
133
+ host?: string;
134
+ /** Default "anonymous". The SDK does not remember it: pass it on every start (from your consent screen's stored answer). */
135
+ consent?: NativeConsent;
136
+ /** Uncaught JavaScript errors and `captureError` go to Build › Errors (default true). */
137
+ errors?: boolean;
138
+ /** Your release, for Build › Errors. Default: the app version and build, like "1.4.0 (42)". */
139
+ release?: string;
140
+ /** `$app_open` and `$app_background` events (default true). */
141
+ lifecycle?: boolean;
142
+ /** Read UTM and referral parameters of the deep link that opened the app the first time, sent with `$install` (default true). */
143
+ attribution?: boolean;
144
+ /** How often the queue is sent while the app is open, in ms (default 10 000). It is also sent when the app goes to the background. */
145
+ flushIntervalMs?: number;
146
+ /** At most this many events wait on the device; the oldest go first (default 1,000). */
147
+ maxQueue?: number;
148
+ /** Log what the SDK does to the console. */
149
+ debug?: boolean;
150
+ }
151
+ /** AsyncStorage's shape. */
152
+ interface KeyValueStorage {
153
+ getItem(key: string): Promise<string | null>;
154
+ setItem(key: string, value: string): Promise<void>;
155
+ removeItem(key: string): Promise<void>;
156
+ }
157
+ /** What the app (and the React hooks) use. */
158
+ interface MRRocketClient {
159
+ track(event: string, props?: Record<string, unknown>): void;
160
+ /** A screen view: a route name ("Settings") or an Expo Router path ("/settings"). */
161
+ screen(name: string, props?: Record<string, unknown>): void;
162
+ identify(id: string, props?: Record<string, unknown>): void;
163
+ /** Forgets the signed-in person (sign-out): a new anonymous id and a new session. */
164
+ reset(): void;
165
+ setConsent(consent: NativeConsent): void;
166
+ captureError(error: unknown): void;
167
+ getFlag(key: string): boolean;
168
+ getFlagVariant(key: string): string | null;
169
+ /** The variant of an experiment ("control" until the config is known); records the exposure once per screen. */
170
+ getVariant(key: string): VariantId;
171
+ /** The variant without recording anything (render code); pair it with `expose`. */
172
+ peekVariant(key: string): VariantId;
173
+ /** Records that the person saw `variant` of `key`, once per screen. */
174
+ expose(key: string, variant: VariantId): void;
175
+ /** Sends what is queued now. */
176
+ flush(): Promise<void>;
177
+ /** Resolves once stored state and the config (cached or fetched) are known. */
178
+ ready: Promise<void>;
179
+ isReady(): boolean;
180
+ getDistinctId(): string;
181
+ getConsent(): NativeConsent;
182
+ getConfig(): CockpitConfig | null;
183
+ /** For React: called after every change flags, variants or the consent depend on. Returns the unsubscribe. */
184
+ subscribe(listener: () => void): () => void;
185
+ /** Grows with every such change (useSyncExternalStore's snapshot). */
186
+ getVersion(): number;
187
+ /** Stops timers and listeners and sends what is queued (tests, or an app that tears the SDK down). */
188
+ close(): Promise<void>;
189
+ /** For tests: what waits to be sent. */
190
+ queued(): readonly CockpitEvent[];
191
+ }
192
+ /** The name of the screen a React Navigation state shows: the focused route, followed into nested navigators. */
193
+ declare const activeRouteName: (state: unknown) => string | undefined;
194
+
195
+ /**
196
+ * The SDK's client outside React (a background task, a store, an API layer): the one the provider made, or a new one.
197
+ * One client per app; a second call returns the first.
198
+ */
199
+ declare const createMRRocket: (options: MRRocketOptions & {
200
+ storage?: KeyValueStorage | null;
201
+ }) => MRRocketClient;
202
+ /** The running client, or null before the provider (or createMRRocket) started it. */
203
+ declare const getMRRocket: () => MRRocketClient | null;
204
+ interface MRRocketProviderProps extends Partial<MRRocketOptions> {
205
+ /** The product's public key (MRRocket › Settings › Products), the same as on the website. */
206
+ apiKey: string;
207
+ /** A storage with AsyncStorage's shape instead of AsyncStorage (MMKV, SecureStore); null keeps everything in memory. */
208
+ storage?: KeyValueStorage | null;
209
+ /** A client you made with createMRRocket; the other props are then ignored. */
210
+ client?: MRRocketClient;
211
+ children?: ReactNode;
212
+ }
213
+ /**
214
+ * Put it once around your app (Expo Router: app/_layout.tsx; React Navigation: around the NavigationContainer). It
215
+ * starts the SDK: lifecycle events, the event queue, flags and experiments, error capture. Changing `consent` later
216
+ * calls setConsent.
217
+ */
218
+ declare const MRRocketProvider: ({ client: given, children, consent, ...options }: MRRocketProviderProps) => react.FunctionComponentElement<react.ProviderProps<MRRocketClient | null>>;
219
+ /**
220
+ * `track`, `screen`, `identify`, `reset`, `setConsent`, `captureError`, `flush`, the visitor id, the consent and whether
221
+ * flags and experiments have loaded.
222
+ */
223
+ declare const useMRRocket: () => {
224
+ track: (event: string, props?: Record<string, unknown>) => void;
225
+ screen: (name: string, props?: Record<string, unknown>) => void;
226
+ identify: (id: string, props?: Record<string, unknown>) => void;
227
+ reset: () => void;
228
+ setConsent: (consent: NativeConsent) => void;
229
+ captureError: (error: unknown) => void;
230
+ flush: () => Promise<void>;
231
+ distinctId: string;
232
+ consent: NativeConsent;
233
+ ready: boolean;
234
+ };
235
+ /** A feature flag from MRRocket › Build › Feature flags: true while it is on for this person; false while off, unknown or loading. */
236
+ declare const useFlag: (key: string) => boolean;
237
+ /** The variant of a multivariate flag ("control", "test" …), or null while it is off. */
238
+ declare const useFlagVariant: (key: string) => string | null;
239
+ /**
240
+ * The variant of an experiment this person sees ("control" until the config is known; the cached config is used on a
241
+ * cold start, so the first screen is already stable). Records the exposure once per screen.
242
+ */
243
+ declare const useVariant: (key: string) => VariantId;
244
+ /**
245
+ * Screen views for Expo Router: one `$screen` per path ("/settings", "/product/[id]" as its real path). Call it in a
246
+ * component inside both the router and MRRocketProvider, for example the root layout's child.
247
+ */
248
+ declare const useExpoRouterTracking: () => void;
249
+ /**
250
+ * Screen views for React Navigation: pass the result to the container's `onStateChange`, and call it once in `onReady`
251
+ * with the root state, so the first screen counts too.
252
+ *
253
+ * const ref = useNavigationContainerRef();
254
+ * const onStateChange = useNavigationTracking();
255
+ * <NavigationContainer ref={ref} onReady={() => onStateChange(ref.getRootState())} onStateChange={onStateChange}>
256
+ */
257
+ declare const useNavigationTracking: () => (state: unknown) => void;
258
+
259
+ export { type AppContext, type CockpitConfig, type FlagConfig, type KeyValueStorage, type MRRocketClient, type MRRocketOptions, MRRocketProvider, type MRRocketProviderProps, type NativeConsent, SDK_VERSION, type VariantId, activeRouteName, createMRRocket, getMRRocket, useExpoRouterTracking, useFlag, useFlagVariant, useMRRocket, useNavigationTracking, useVariant };
@@ -0,0 +1,259 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * The part of the SDK that runs anywhere: experiment config, variant assignment, preview links and event shapes.
6
+ * No React, no browser APIs, so the server helper, the proxy helper and the client share it.
7
+ */
8
+ type VariantId = string;
9
+ /** This build of the SDK. Sent with the config request so MRRocket knows what the site runs (error tracking, flags). */
10
+ declare const SDK_VERSION = "0.4.0";
11
+ /** One variant of an experiment. `changes` replaces texts that the page marks with `<Text id>`. */
12
+ interface VariantConfig {
13
+ id: VariantId;
14
+ /** Share of traffic, 0 to 1. The weights of an experiment add up to 1. */
15
+ weight: number;
16
+ changes?: Record<string, string>;
17
+ }
18
+ interface ExperimentConfig {
19
+ /** The experiment's key, the same as in Cockpit. */
20
+ key: string;
21
+ status: "running" | "draft" | "stopped";
22
+ /** Control first. */
23
+ variants: VariantConfig[];
24
+ /** A winner that shipped: everyone gets it, and nobody is assigned anymore. */
25
+ winner?: VariantId;
26
+ }
27
+ interface CockpitConfig {
28
+ /** The product the public key belongs to. */
29
+ project: string;
30
+ experiments: ExperimentConfig[];
31
+ /** The product's affiliate program: how many days a partner's referral is kept. Missing without a program. */
32
+ referral?: {
33
+ cookieDays: number;
34
+ };
35
+ /** Session recordings: present only while the product records (Cockpit › Sessions). See `ReplayConfig`. */
36
+ replay?: ReplayConfig;
37
+ /** Feature flags of the product in Production (MRRocket › Build › Feature flags), evaluated by `useFlag` and `getFlag`. */
38
+ flags?: FlagConfig[];
39
+ }
40
+ /** One condition of a flag's audience, on a property of the person (`identify(id, props)`), the id or the page. */
41
+ interface FlagCondition {
42
+ /** "Email", "Plan", "Country", "id", "path" … Matched against the person's properties without regard to case. */
43
+ property: string;
44
+ op: "is" | "is not" | "in" | "not in" | "≥" | "in cohort";
45
+ values: string[];
46
+ }
47
+ /** Users who match every condition, of whom `rollout` percent get the flag. No conditions: everyone. */
48
+ interface FlagConditionSet {
49
+ conditions: FlagCondition[];
50
+ /** 0 to 100. */
51
+ rollout: number;
52
+ }
53
+ interface FlagConfig {
54
+ key: string;
55
+ /** Off: everyone gets the off side. */
56
+ on: boolean;
57
+ /** The first set a person matches decides; none matched: off. */
58
+ sets: FlagConditionSet[];
59
+ /** Multivariate flags: the variants and their split in percent (control included). Missing for an on/off flag. */
60
+ variants?: {
61
+ key: string;
62
+ split: number;
63
+ payload?: string;
64
+ }[];
65
+ }
66
+ /**
67
+ * Session recordings of a product, from the config. Recording also needs the visitor's own replay consent
68
+ * (`<CockpitProvider replay>` or `setConsent({ replay: true })`); without it nothing is recorded or buffered.
69
+ */
70
+ interface ReplayConfig {
71
+ /**
72
+ * Share of sessions uploaded from their start, 0 to 1 (default 0.1). The others keep only the last minute in
73
+ * memory and upload it when something goes wrong: a JS error, a rage click, a `purchase…` or `checkout…` event.
74
+ */
75
+ sampleRate: number;
76
+ }
77
+ /** One event as it goes over the wire to `POST /api/sdk/events`. */
78
+ interface CockpitEvent {
79
+ event: string;
80
+ /** The visitor. Missing in "cookieless" mode until identify(): the server then uses its daily visitor hash. */
81
+ distinctId?: string;
82
+ /** Ends after 30 minutes without an event. */
83
+ sessionId?: string;
84
+ props?: Record<string, unknown>;
85
+ /** Milliseconds since the epoch. */
86
+ ts: number;
87
+ url?: string;
88
+ /** `document.referrer` on the first page of a page load, the previous in-app URL after client-side navigation. */
89
+ referrer?: string;
90
+ utm_source?: string;
91
+ utm_medium?: string;
92
+ utm_campaign?: string;
93
+ utm_term?: string;
94
+ utm_content?: string;
95
+ /** The screen size in CSS pixels (points on a phone). */
96
+ screen?: {
97
+ w: number;
98
+ h: number;
99
+ };
100
+ /** The app that sent it (React Native only): MRRocket stores it with the event and fills OS and device from it. */
101
+ app?: AppContext;
102
+ }
103
+ /** Where a React Native event comes from. Every field is optional except the platform; nothing identifies the person. */
104
+ interface AppContext {
105
+ /** "ios" or "android" (React Native's `Platform.OS`). */
106
+ platform: string;
107
+ /** The app's version, like "1.4.0" (`expo-application`'s `nativeApplicationVersion`). */
108
+ appVersion?: string;
109
+ /** The build number, like "42". */
110
+ build?: string;
111
+ /** The OS version, like "17.4". */
112
+ osVersion?: string;
113
+ /** The device model, like "iPhone 15 Pro" (`expo-device`). */
114
+ deviceModel?: string;
115
+ /** "phone", "tablet", "desktop" or "tv" when `expo-device` knows it. */
116
+ deviceType?: string;
117
+ /** The first preferred locale, like "de-DE". */
118
+ locale?: string;
119
+ }
120
+
121
+ /**
122
+ * What the app may send and store.
123
+ * - "anonymous" (default): no id is stored on the device. Events go without a person id until `identify()` (MRRocket
124
+ * counts visitors by its daily hash); flags and experiments use a random id that lives until the app is closed.
125
+ * - "persistent": a random install id is stored on the device (removed with the app) and sent with every event.
126
+ * - "off": nothing is sent, and what the SDK stored is deleted.
127
+ */
128
+ type NativeConsent = "anonymous" | "persistent" | "off";
129
+ interface MRRocketOptions {
130
+ /** The product's public key (MRRocket › Settings › Products), the same as on the website. */
131
+ apiKey: string;
132
+ /** Where MRRocket runs. Default `https://app.mrrocket.dev`. */
133
+ host?: string;
134
+ /** Default "anonymous". The SDK does not remember it: pass it on every start (from your consent screen's stored answer). */
135
+ consent?: NativeConsent;
136
+ /** Uncaught JavaScript errors and `captureError` go to Build › Errors (default true). */
137
+ errors?: boolean;
138
+ /** Your release, for Build › Errors. Default: the app version and build, like "1.4.0 (42)". */
139
+ release?: string;
140
+ /** `$app_open` and `$app_background` events (default true). */
141
+ lifecycle?: boolean;
142
+ /** Read UTM and referral parameters of the deep link that opened the app the first time, sent with `$install` (default true). */
143
+ attribution?: boolean;
144
+ /** How often the queue is sent while the app is open, in ms (default 10 000). It is also sent when the app goes to the background. */
145
+ flushIntervalMs?: number;
146
+ /** At most this many events wait on the device; the oldest go first (default 1,000). */
147
+ maxQueue?: number;
148
+ /** Log what the SDK does to the console. */
149
+ debug?: boolean;
150
+ }
151
+ /** AsyncStorage's shape. */
152
+ interface KeyValueStorage {
153
+ getItem(key: string): Promise<string | null>;
154
+ setItem(key: string, value: string): Promise<void>;
155
+ removeItem(key: string): Promise<void>;
156
+ }
157
+ /** What the app (and the React hooks) use. */
158
+ interface MRRocketClient {
159
+ track(event: string, props?: Record<string, unknown>): void;
160
+ /** A screen view: a route name ("Settings") or an Expo Router path ("/settings"). */
161
+ screen(name: string, props?: Record<string, unknown>): void;
162
+ identify(id: string, props?: Record<string, unknown>): void;
163
+ /** Forgets the signed-in person (sign-out): a new anonymous id and a new session. */
164
+ reset(): void;
165
+ setConsent(consent: NativeConsent): void;
166
+ captureError(error: unknown): void;
167
+ getFlag(key: string): boolean;
168
+ getFlagVariant(key: string): string | null;
169
+ /** The variant of an experiment ("control" until the config is known); records the exposure once per screen. */
170
+ getVariant(key: string): VariantId;
171
+ /** The variant without recording anything (render code); pair it with `expose`. */
172
+ peekVariant(key: string): VariantId;
173
+ /** Records that the person saw `variant` of `key`, once per screen. */
174
+ expose(key: string, variant: VariantId): void;
175
+ /** Sends what is queued now. */
176
+ flush(): Promise<void>;
177
+ /** Resolves once stored state and the config (cached or fetched) are known. */
178
+ ready: Promise<void>;
179
+ isReady(): boolean;
180
+ getDistinctId(): string;
181
+ getConsent(): NativeConsent;
182
+ getConfig(): CockpitConfig | null;
183
+ /** For React: called after every change flags, variants or the consent depend on. Returns the unsubscribe. */
184
+ subscribe(listener: () => void): () => void;
185
+ /** Grows with every such change (useSyncExternalStore's snapshot). */
186
+ getVersion(): number;
187
+ /** Stops timers and listeners and sends what is queued (tests, or an app that tears the SDK down). */
188
+ close(): Promise<void>;
189
+ /** For tests: what waits to be sent. */
190
+ queued(): readonly CockpitEvent[];
191
+ }
192
+ /** The name of the screen a React Navigation state shows: the focused route, followed into nested navigators. */
193
+ declare const activeRouteName: (state: unknown) => string | undefined;
194
+
195
+ /**
196
+ * The SDK's client outside React (a background task, a store, an API layer): the one the provider made, or a new one.
197
+ * One client per app; a second call returns the first.
198
+ */
199
+ declare const createMRRocket: (options: MRRocketOptions & {
200
+ storage?: KeyValueStorage | null;
201
+ }) => MRRocketClient;
202
+ /** The running client, or null before the provider (or createMRRocket) started it. */
203
+ declare const getMRRocket: () => MRRocketClient | null;
204
+ interface MRRocketProviderProps extends Partial<MRRocketOptions> {
205
+ /** The product's public key (MRRocket › Settings › Products), the same as on the website. */
206
+ apiKey: string;
207
+ /** A storage with AsyncStorage's shape instead of AsyncStorage (MMKV, SecureStore); null keeps everything in memory. */
208
+ storage?: KeyValueStorage | null;
209
+ /** A client you made with createMRRocket; the other props are then ignored. */
210
+ client?: MRRocketClient;
211
+ children?: ReactNode;
212
+ }
213
+ /**
214
+ * Put it once around your app (Expo Router: app/_layout.tsx; React Navigation: around the NavigationContainer). It
215
+ * starts the SDK: lifecycle events, the event queue, flags and experiments, error capture. Changing `consent` later
216
+ * calls setConsent.
217
+ */
218
+ declare const MRRocketProvider: ({ client: given, children, consent, ...options }: MRRocketProviderProps) => react.FunctionComponentElement<react.ProviderProps<MRRocketClient | null>>;
219
+ /**
220
+ * `track`, `screen`, `identify`, `reset`, `setConsent`, `captureError`, `flush`, the visitor id, the consent and whether
221
+ * flags and experiments have loaded.
222
+ */
223
+ declare const useMRRocket: () => {
224
+ track: (event: string, props?: Record<string, unknown>) => void;
225
+ screen: (name: string, props?: Record<string, unknown>) => void;
226
+ identify: (id: string, props?: Record<string, unknown>) => void;
227
+ reset: () => void;
228
+ setConsent: (consent: NativeConsent) => void;
229
+ captureError: (error: unknown) => void;
230
+ flush: () => Promise<void>;
231
+ distinctId: string;
232
+ consent: NativeConsent;
233
+ ready: boolean;
234
+ };
235
+ /** A feature flag from MRRocket › Build › Feature flags: true while it is on for this person; false while off, unknown or loading. */
236
+ declare const useFlag: (key: string) => boolean;
237
+ /** The variant of a multivariate flag ("control", "test" …), or null while it is off. */
238
+ declare const useFlagVariant: (key: string) => string | null;
239
+ /**
240
+ * The variant of an experiment this person sees ("control" until the config is known; the cached config is used on a
241
+ * cold start, so the first screen is already stable). Records the exposure once per screen.
242
+ */
243
+ declare const useVariant: (key: string) => VariantId;
244
+ /**
245
+ * Screen views for Expo Router: one `$screen` per path ("/settings", "/product/[id]" as its real path). Call it in a
246
+ * component inside both the router and MRRocketProvider, for example the root layout's child.
247
+ */
248
+ declare const useExpoRouterTracking: () => void;
249
+ /**
250
+ * Screen views for React Navigation: pass the result to the container's `onStateChange`, and call it once in `onReady`
251
+ * with the root state, so the first screen counts too.
252
+ *
253
+ * const ref = useNavigationContainerRef();
254
+ * const onStateChange = useNavigationTracking();
255
+ * <NavigationContainer ref={ref} onReady={() => onStateChange(ref.getRootState())} onStateChange={onStateChange}>
256
+ */
257
+ declare const useNavigationTracking: () => (state: unknown) => void;
258
+
259
+ export { type AppContext, type CockpitConfig, type FlagConfig, type KeyValueStorage, type MRRocketClient, type MRRocketOptions, MRRocketProvider, type MRRocketProviderProps, type NativeConsent, SDK_VERSION, type VariantId, activeRouteName, createMRRocket, getMRRocket, useExpoRouterTracking, useFlag, useFlagVariant, useMRRocket, useNavigationTracking, useVariant };