@metarouter/react-native-sdk 1.0.2 → 1.1.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 CHANGED
@@ -16,14 +16,14 @@ npm install @metarouter/react-native-sdk @react-native-async-storage/async-stora
16
16
  ### Basic Setup
17
17
 
18
18
  ```js
19
- import MetaRouter from "@metarouter/react-native-sdk";
19
+ import { createAnalyticsClient } from "@metarouter/react-native-sdk";
20
20
 
21
21
  // Initialize the analytics client
22
- const analytics = await MetaRouter.analytics.init({
22
+ const analytics = await createAnalyticsClient({
23
23
  writeKey: "your-write-key",
24
24
  ingestionHost: "https://your-ingestion-endpoint.com",
25
25
  debug: true, // Optional: enable debug mode
26
- flushInterval: 30, // Optional: flush events every 30 seconds
26
+ flushIntervalSeconds: 30, // Optional: flush events every 30 seconds
27
27
  });
28
28
  ```
29
29
 
@@ -31,37 +31,38 @@ const analytics = await MetaRouter.analytics.init({
31
31
 
32
32
  ```jsx
33
33
  import React, { useEffect, useState } from "react";
34
- import MetaRouter, {
34
+ import {
35
+ createAnalyticsClient,
35
36
  MetaRouterProvider,
36
37
  useMetaRouter,
37
38
  } from "@metarouter/react-native-sdk";
38
39
 
39
40
  const App = () => {
40
- const [metaRouterInstance, setMetaRouterInstance] = useState(null);
41
+ const [analyticsClient, setAnalyticsClient] = useState(null);
41
42
  const [isLoading, setIsLoading] = useState(true);
42
43
 
43
44
  useEffect(() => {
44
45
  const initializeAnalytics = async () => {
45
46
  try {
46
47
  // Initialize the analytics client
47
- await MetaRouter.analytics.init({
48
+ const client = await createAnalyticsClient({
48
49
  writeKey: "your-write-key",
49
50
  ingestionHost: "https://your-ingestion-endpoint.com",
50
51
  });
51
-
52
- setMetaRouterInstance(MetaRouter);
52
+ setAnalyticsClient(client);
53
53
  } catch (error) {
54
54
  console.error("Failed to initialize analytics:", error);
55
55
  } finally {
56
56
  setIsLoading(false);
57
57
  }
58
58
  };
59
-
60
59
  initializeAnalytics();
61
60
  }, []);
62
61
 
62
+ if (isLoading) return null; // or a loading spinner
63
+
63
64
  return (
64
- <MetaRouterProvider instance={metaRouterInstance}>
65
+ <MetaRouterProvider analyticsClient={analyticsClient}>
65
66
  <YourApp />
66
67
  </MetaRouterProvider>
67
68
  );
@@ -69,8 +70,7 @@ const App = () => {
69
70
 
70
71
  // Use analytics in any component
71
72
  const MyComponent = () => {
72
- const metaRouter = useMetaRouter();
73
- const analytics = metaRouter.analytics.getClient();
73
+ const { analytics } = useMetaRouter();
74
74
 
75
75
  const handleButtonPress = () => {
76
76
  analytics.track("Button Pressed", {
@@ -86,10 +86,10 @@ const MyComponent = () => {
86
86
  ### Direct Usage
87
87
 
88
88
  ```js
89
- import MetaRouter from "@metarouter/react-native-sdk";
89
+ import { createAnalyticsClient } from "@metarouter/react-native-sdk";
90
90
 
91
91
  // Initialize
92
- const analytics = await MetaRouter.analytics.init({
92
+ const analytics = await createAnalyticsClient({
93
93
  writeKey: "your-write-key",
94
94
  ingestionHost: "https://your-ingestion-endpoint.com/events",
95
95
  });
@@ -120,33 +120,26 @@ analytics.group("company123", {
120
120
  // Flush events immediately
121
121
  analytics.flush();
122
122
 
123
- // Cleanup when done
124
- analytics.cleanup();
125
-
126
123
  // Reset analytics (useful for testing or logout)
127
- await MetaRouter.analytics.reset();
124
+ await analytics.reset();
128
125
  ```
129
126
 
130
127
  ## API Reference
131
128
 
132
- ### MetaRouter.analytics.init(options)
129
+ ### createAnalyticsClient(options)
130
+
131
+ Initializes the analytics client and returns a promise resolving to the client instance.
133
132
 
134
- Initializes the analytics client and returns a promise that resolves to the client instance.
133
+ ⚠️ createAnalyticsClient() is asynchronous, but you do not need to await it before using analytics methods.
134
+
135
+ Calls to track, identify, etc. are queued and replayed once the client is fully initialized.
135
136
 
136
137
  **Options:**
137
138
 
138
139
  - `writeKey` (string, required): Your write key
139
140
  - `ingestionHost` (string, required): Your MetaRouter ingestor host
140
141
  - `debug` (boolean, optional): Enable debug mode
141
- - `flushInterval` (number, optional): Interval in seconds to flush events
142
-
143
- ### MetaRouter.analytics.getClient()
144
-
145
- Returns the current analytics client instance. Must be called after initialization.
146
-
147
- ### MetaRouter.analytics.reset()
148
-
149
- Resets the analytics client and clears all stored data. Returns a promise.
142
+ - `flushIntervalSeconds` (number, optional): Interval in seconds to flush events
150
143
 
151
144
  ### Analytics Interface
152
145
 
@@ -158,15 +151,17 @@ The analytics client provides the following methods:
158
151
  - `screen(name: string, properties?: Record<string, any>)`: Track screen views
159
152
  - `alias(newUserId: string)`: Alias user IDs
160
153
  - `flush()`: Flush events immediately
161
- - `cleanup()`: Clean up resources
154
+ - `reset()`: Reset analytics state and clear all stored data
155
+ - `enableDebugLogging()`: Enable debug logging
156
+ - `getDebugInfo()`: Get current debug information
162
157
 
163
158
  ### React Hooks
164
159
 
165
- - `useMetaRouter()`: Hook to access the MetaRouter instance within a `MetaRouterProvider`
160
+ - `useMetaRouter()`: Hook to access the analytics client within a `MetaRouterProvider`
166
161
 
167
162
  ### Components
168
163
 
169
- - `MetaRouterProvider`: React context provider for MetaRouter instance
164
+ - `MetaRouterProvider`: React context provider for the analytics client
170
165
 
171
166
  ## Features
172
167
 
@@ -186,7 +181,7 @@ If you're not seeing API calls being made, here are some steps to troubleshoot:
186
181
 
187
182
  ```js
188
183
  // Initialize with debug enabled
189
- const analytics = await MetaRouter.analytics.init({
184
+ const analytics = await createAnalyticsClient({
190
185
  writeKey: "your-write-key",
191
186
  ingestionHost: "https://your-ingestion-endpoint.com",
192
187
  debug: true, // This enables detailed logging
@@ -8,7 +8,6 @@ import { InitOptions } from "./types";
8
8
  */
9
9
  export declare class MetaRouterAnalyticsClient {
10
10
  private initialized;
11
- private initPromise;
12
11
  private queue;
13
12
  private flushIntervalMs;
14
13
  private flushTimer;
@@ -29,11 +28,6 @@ export declare class MetaRouterAnalyticsClient {
29
28
  * @returns A promise that resolves when the client is initialized.
30
29
  */
31
30
  private init;
32
- /**
33
- * Waits for the analytics client to be initialized.
34
- * @returns A promise that resolves when the client is initialized.
35
- */
36
- waitForInitialization(): Promise<void>;
37
31
  /**
38
32
  * Starts the flush loop.
39
33
  */
@@ -124,12 +118,12 @@ export declare class MetaRouterAnalyticsClient {
124
118
  timestamp?: string;
125
119
  }[] | undefined>;
126
120
  /**
127
- * Resets the analytics client.
121
+ * Resets the analytics client:
122
+ * - Clears identity (anonymousId, userId, groupId)
123
+ * - Clears queued events
124
+ * - Stops background flushing
125
+ * - Removes app state listeners
128
126
  */
129
127
  reset(): void;
130
- /**
131
- * Cleans up the analytics client.
132
- */
133
- cleanup(): void;
134
128
  }
135
129
  //# sourceMappingURL=MetaRouterAnalyticsClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetaRouterAnalyticsClient.d.ts","sourceRoot":"","sources":["../../src/analytics/MetaRouterAnalyticsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,SAAS,CAAC;AAQlE;;;;;;GAMG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,oBAAoB,CAAwC;IACpE,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAM;IAE5C;;;OAGG;gBACS,OAAO,EAAE,WAAW;IAiChC;;;OAGG;YACW,IAAI;IA8BlB;;;OAGG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;;OAGG;IACH,OAAO,CAAC,GAAG;IAIX;;;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
@@ -35,7 +35,7 @@ export class MetaRouterAnalyticsClient {
35
35
  this.appState = nextState;
36
36
  };
37
37
  log("Initializing analytics client", options);
38
- const { writeKey, ingestionHost, flushInterval } = options;
38
+ const { writeKey, ingestionHost, flushIntervalSeconds } = options;
39
39
  if (!writeKey || typeof writeKey !== "string" || writeKey.trim() === "") {
40
40
  throw new Error("MetaRouterAnalyticsClient initialization failed: `writeKey` is required and must be a non-empty string.");
41
41
  }
@@ -50,10 +50,12 @@ export class MetaRouterAnalyticsClient {
50
50
  }
51
51
  this.ingestionHost = ingestionHost;
52
52
  this.writeKey = writeKey;
53
- this.flushIntervalMs = flushInterval !== null && flushInterval !== void 0 ? flushInterval : 10000;
53
+ this.flushIntervalMs = flushIntervalSeconds
54
+ ? flushIntervalSeconds * 1000
55
+ : 10000;
54
56
  setDebugLogging((_a = options.debug) !== null && _a !== void 0 ? _a : false);
55
57
  this.identityManager = new IdentityManager();
56
- this.initPromise = this.init();
58
+ this.init();
57
59
  log("Analytics client constructor completed, initialization in progress...");
58
60
  }
59
61
  /**
@@ -84,13 +86,6 @@ export class MetaRouterAnalyticsClient {
84
86
  throw error;
85
87
  }
86
88
  }
87
- /**
88
- * Waits for the analytics client to be initialized.
89
- * @returns A promise that resolves when the client is initialized.
90
- */
91
- async waitForInitialization() {
92
- await this.initPromise;
93
- }
94
89
  /**
95
90
  * Starts the flush loop.
96
91
  */
@@ -265,24 +260,28 @@ export class MetaRouterAnalyticsClient {
265
260
  }
266
261
  }
267
262
  /**
268
- * Resets the analytics client.
263
+ * Resets the analytics client:
264
+ * - Clears identity (anonymousId, userId, groupId)
265
+ * - Clears queued events
266
+ * - Stops background flushing
267
+ * - Removes app state listeners
269
268
  */
270
269
  reset() {
270
+ var _a, _b;
271
+ log("Resetting analytics client");
272
+ // Identity reset
271
273
  this.identityManager.reset();
274
+ // Clear event queue
272
275
  this.queue = [];
273
- log("Analytics client reset");
274
- }
275
- /**
276
- * Cleans up the analytics client.
277
- */
278
- cleanup() {
279
- var _a, _b;
280
- log("Cleaning up analytics client");
281
- if (this.flushTimer)
276
+ // Clear flush interval
277
+ if (this.flushTimer) {
282
278
  clearInterval(this.flushTimer);
283
- this.queue = [];
284
- this.flushTimer = null;
279
+ this.flushTimer = null;
280
+ }
281
+ // Remove AppState listener
285
282
  (_b = (_a = this.appStateSubscription) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
283
+ this.appStateSubscription = null;
284
+ log("Analytics client reset complete");
286
285
  }
287
286
  }
288
287
  MetaRouterAnalyticsClient.MAX_QUEUE_SIZE = 20;
@@ -1,22 +1,9 @@
1
- import type { InitOptions, AnalyticsInterface } from './types';
1
+ import type { InitOptions, AnalyticsInterface } from "./types";
2
2
  /**
3
- * Initializes the analytics client singleton.
4
- * Waits for async setup (e.g., identity loading) before returning the interface.
5
- * Returns the same instance on subsequent calls.
6
- * @param options Analytics initialization options.
7
- * @returns The analytics interface.
3
+ * Modular factory for creating an independent analytics client.
4
+ * Binds the first created client to the proxy for queued events.
5
+ * @param options Initialization options.
6
+ * @returns A fully initialized analytics interface.
8
7
  */
9
- export declare function initAnalytics(options: InitOptions): Promise<AnalyticsInterface>;
10
- /**
11
- * Retrieves the analytics client singleton.
12
- * Returns the proxy client before initialization, and the real client after.
13
- * @returns The analytics interface.
14
- */
15
- export declare function getAnalyticsClient(): AnalyticsInterface;
16
- /**
17
- * Resets the analytics client singleton.
18
- * Cleans up the client and sets it to null.
19
- * @returns A promise that resolves when the client is reset.
20
- */
21
- export declare function resetAnalytics(): Promise<void>;
8
+ export declare function createAnalyticsClient(options: InitOptions): AnalyticsInterface;
22
9
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/analytics/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAM/D;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAuBrF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,kBAAkB,CAEvD;AAED;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAMpD"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/analytics/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK/D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GACnB,kBAAkB,CAuBpB"}
@@ -1,53 +1,31 @@
1
- import { MetaRouterAnalyticsClient } from './MetaRouterAnalyticsClient';
2
- import { proxyClient, setRealClient } from './proxy/proxyClient';
3
- let initialized = false;
4
- let client = null;
5
- let analyticsClient = null;
1
+ import { MetaRouterAnalyticsClient } from "./MetaRouterAnalyticsClient";
2
+ import { setRealClient } from "./proxy/proxyClient";
3
+ // Tracks whether a client has already been bound to the proxy
4
+ let proxyBound = false;
6
5
  /**
7
- * Initializes the analytics client singleton.
8
- * Waits for async setup (e.g., identity loading) before returning the interface.
9
- * Returns the same instance on subsequent calls.
10
- * @param options Analytics initialization options.
11
- * @returns The analytics interface.
6
+ * Modular factory for creating an independent analytics client.
7
+ * Binds the first created client to the proxy for queued events.
8
+ * @param options Initialization options.
9
+ * @returns A fully initialized analytics interface.
12
10
  */
13
- export async function initAnalytics(options) {
14
- if (initialized)
15
- return analyticsClient;
16
- client = new MetaRouterAnalyticsClient(options);
17
- // Wait for the client to fully initialize (including anonymous ID loading)
18
- await client.waitForInitialization();
19
- analyticsClient = {
20
- track: (event, props) => client.track(event, props),
21
- identify: (userId, traits) => client.identify(userId, traits),
22
- group: (groupId, traits) => client.group(groupId, traits),
23
- screen: (name, props) => client.screen(name, props),
24
- alias: (newUserId) => client.alias(newUserId),
25
- flush: () => client.flush(),
26
- cleanup: () => client.cleanup(),
27
- enableDebugLogging: () => client.enableDebugLogging(),
28
- getDebugInfo: () => client.getDebugInfo(),
11
+ export function createAnalyticsClient(options) {
12
+ const instance = new MetaRouterAnalyticsClient(options);
13
+ const analyticsInterface = {
14
+ track: (event, props) => instance.track(event, props),
15
+ identify: (userId, traits) => instance.identify(userId, traits),
16
+ group: (groupId, traits) => instance.group(groupId, traits),
17
+ screen: (name, props) => instance.screen(name, props),
18
+ page: (name, props) => instance.page(name, props),
19
+ alias: (newUserId) => instance.alias(newUserId),
20
+ flush: () => instance.flush(),
21
+ reset: () => instance.reset(),
22
+ enableDebugLogging: () => instance.enableDebugLogging(),
23
+ getDebugInfo: () => instance.getDebugInfo(),
29
24
  };
30
- initialized = true;
31
- setRealClient(analyticsClient);
32
- return analyticsClient;
33
- }
34
- /**
35
- * Retrieves the analytics client singleton.
36
- * Returns the proxy client before initialization, and the real client after.
37
- * @returns The analytics interface.
38
- */
39
- export function getAnalyticsClient() {
40
- return initialized ? analyticsClient : proxyClient;
41
- }
42
- /**
43
- * Resets the analytics client singleton.
44
- * Cleans up the client and sets it to null.
45
- * @returns A promise that resolves when the client is reset.
46
- */
47
- export async function resetAnalytics() {
48
- await (client === null || client === void 0 ? void 0 : client.cleanup());
49
- client = null;
50
- analyticsClient = null;
51
- initialized = false;
52
- setRealClient(null);
25
+ // Forward proxy calls to this instance (only once)
26
+ if (!proxyBound) {
27
+ setRealClient(analyticsInterface);
28
+ proxyBound = true;
29
+ }
30
+ return analyticsInterface;
53
31
  }
@@ -1,4 +1,4 @@
1
- import type { AnalyticsInterface } from '../types';
1
+ import type { AnalyticsInterface } from "../types";
2
2
  /**
3
3
  * proxyClient implements a proxy pattern for the AnalyticsInterface.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"proxyClient.d.ts","sourceRoot":"","sources":["../../../src/analytics/proxy/proxyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AA2BnD;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,WAAW,EAAE,kBAWzB,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,QAO9D"}
1
+ {"version":3,"file":"proxyClient.d.ts","sourceRoot":"","sources":["../../../src/analytics/proxy/proxyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AA6BnD;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,WAAW,EAAE,kBAezB,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,QAO9D"}
@@ -30,15 +30,22 @@ function handleMethodCall(methodName, ...args) {
30
30
  * - Call setRealClient(realClientInstance) once the real client is ready.
31
31
  */
32
32
  export const proxyClient = {
33
- track: (event, props) => handleMethodCall('track', event, props),
34
- identify: (userId, traits) => handleMethodCall('identify', userId, traits),
35
- group: (groupId, traits) => handleMethodCall('group', groupId, traits),
36
- screen: (name, props) => handleMethodCall('screen', name, props),
37
- alias: (newUserId) => handleMethodCall('alias', newUserId),
38
- flush: () => handleMethodCall('flush'),
39
- cleanup: () => handleMethodCall('cleanup'),
40
- enableDebugLogging: () => handleMethodCall('enableDebugLogging'),
41
- getDebugInfo: () => { var _a, _b; return (_b = (_a = realClient === null || realClient === void 0 ? void 0 : realClient.getDebugInfo) === null || _a === void 0 ? void 0 : _a.call(realClient)) !== null && _b !== void 0 ? _b : { proxy: true, pendingCalls: pendingCalls.length }; },
33
+ track: (event, props) => handleMethodCall("track", event, props),
34
+ identify: (userId, traits) => handleMethodCall("identify", userId, traits),
35
+ group: (groupId, traits) => handleMethodCall("group", groupId, traits),
36
+ screen: (name, props) => handleMethodCall("screen", name, props),
37
+ page: (name, props) => handleMethodCall("page", name, props),
38
+ alias: (newUserId) => handleMethodCall("alias", newUserId),
39
+ flush: () => handleMethodCall("flush"),
40
+ reset: () => handleMethodCall("reset"),
41
+ enableDebugLogging: () => handleMethodCall("enableDebugLogging"),
42
+ getDebugInfo: () => {
43
+ var _a, _b;
44
+ return (_b = (_a = realClient === null || realClient === void 0 ? void 0 : realClient.getDebugInfo) === null || _a === void 0 ? void 0 : _a.call(realClient)) !== null && _b !== void 0 ? _b : {
45
+ proxy: true,
46
+ pendingCalls: pendingCalls.length,
47
+ };
48
+ },
42
49
  };
43
50
  export function setRealClient(client) {
44
51
  realClient = client;
@@ -20,7 +20,7 @@ export interface EnrichedEventPayload extends EventWithIdentity {
20
20
  export interface InitOptions {
21
21
  writeKey: string;
22
22
  ingestionHost: string;
23
- flushInterval?: number;
23
+ flushIntervalSeconds?: number;
24
24
  debug?: boolean;
25
25
  }
26
26
  export interface AnalyticsInterface {
@@ -28,9 +28,10 @@ export interface AnalyticsInterface {
28
28
  identify: (userId: string, traits?: Record<string, any>) => void;
29
29
  group: (groupId: string, traits?: Record<string, any>) => void;
30
30
  screen: (name: string, props?: Record<string, any>) => void;
31
+ page: (name: string, props?: Record<string, any>) => void;
31
32
  alias: (newUserId: string) => void;
32
33
  flush: () => void;
33
- cleanup: () => void;
34
+ reset: () => void;
34
35
  enableDebugLogging?: () => void;
35
36
  getDebugInfo?: () => Record<string, any>;
36
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/analytics/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,UAAU,GACV,OAAO,GACP,QAAQ,GACR,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC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AAI,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,EAAE,EAAE;QACF,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE;QACP,IAAI,EAAE,OAAO,CAAC;KACf,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
package/lib/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { MetaRouter } from "./MetaRouter";
2
- export default MetaRouter;
3
- export { MetaRouter };
1
+ import "react-native-get-random-values";
2
+ export { createAnalyticsClient } from "./analytics/init";
4
3
  export { MetaRouterProvider } from "./react/context";
5
4
  export { useMetaRouter } from "./react/useMetaRouter";
6
5
  export type { InitOptions, AnalyticsInterface } from "./analytics/types";
7
- export type { MetaRouterInterface } from "./types";
8
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AAExC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
package/lib/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { MetaRouter } from "./MetaRouter";
2
- export default MetaRouter;
3
- export { MetaRouter };
1
+ import "react-native-get-random-values";
2
+ export { createAnalyticsClient } from "./analytics/init";
4
3
  export { MetaRouterProvider } from "./react/context";
5
4
  export { useMetaRouter } from "./react/useMetaRouter";
@@ -1,17 +1,13 @@
1
1
  import React, { ReactNode } from "react";
2
- import type { MetaRouterInterface } from "../types";
3
- /**
4
- * Context for the MetaRouter analytics client.
5
- * @param instance - The analytics client instance.
6
- */
7
- export declare const MetaRouterContext: React.Context<MetaRouterInterface | null>;
8
- /**
9
- * Provider for the MetaRouter analytics client.
10
- * @param children - The children to render.
11
- * @param instance - The analytics client instance.
12
- */
13
- export declare const MetaRouterProvider: ({ children, instance, }: {
2
+ import { AnalyticsInterface } from "../analytics/types";
3
+ export interface MetaRouterContextValue {
4
+ analytics: AnalyticsInterface;
5
+ }
6
+ export declare const MetaRouterContext: React.Context<MetaRouterContextValue | null>;
7
+ interface MetaRouterProviderProps {
14
8
  children: ReactNode;
15
- instance: MetaRouterInterface;
16
- }) => React.JSX.Element;
9
+ analyticsClient: AnalyticsInterface;
10
+ }
11
+ export declare const MetaRouterProvider: ({ children, analyticsClient, }: MetaRouterProviderProps) => React.JSX.Element;
12
+ export {};
17
13
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,2CAE7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,yBAGhC;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,mBAAmB,CAAC;CAC/B,sBAMA,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,kBAAkB,CAAC;CAC/B;AAED,eAAO,MAAM,iBAAiB,8CAE7B,CAAC;AAEF,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,kBAAkB,CAAC;CACrC;AAED,eAAO,MAAM,kBAAkB,GAAI,gCAGhC,uBAAuB,sBAUzB,CAAC"}
@@ -1,14 +1,8 @@
1
1
  import React, { createContext } from "react";
2
- /**
3
- * Context for the MetaRouter analytics client.
4
- * @param instance - The analytics client instance.
5
- */
6
2
  export const MetaRouterContext = createContext(null);
7
- /**
8
- * Provider for the MetaRouter analytics client.
9
- * @param children - The children to render.
10
- * @param instance - The analytics client instance.
11
- */
12
- export const MetaRouterProvider = ({ children, instance, }) => {
13
- return (React.createElement(MetaRouterContext.Provider, { value: instance }, children));
3
+ export const MetaRouterProvider = ({ children, analyticsClient, }) => {
4
+ const value = {
5
+ analytics: analyticsClient,
6
+ };
7
+ return (React.createElement(MetaRouterContext.Provider, { value: value }, children));
14
8
  };
@@ -1,7 +1,6 @@
1
- import type { AnalyticsInterface } from "../analytics/types";
1
+ import { AnalyticsInterface } from "../analytics/types";
2
2
  /**
3
- * Custom hook to access the MetaRouter analytics client.
4
- * @returns The analytics client instance.
3
+ * Hook to access the analytics client from MetaRouter context.
5
4
  */
6
5
  export declare const useMetaRouter: () => {
7
6
  analytics: AnalyticsInterface;
@@ -1 +1 @@
1
- {"version":3,"file":"useMetaRouter.d.ts","sourceRoot":"","sources":["../../src/react/useMetaRouter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAO;IAAE,SAAS,EAAE,kBAAkB,CAAA;CAQ7D,CAAC"}
1
+ {"version":3,"file":"useMetaRouter.d.ts","sourceRoot":"","sources":["../../src/react/useMetaRouter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO;IAAE,SAAS,EAAE,kBAAkB,CAAA;CAU/D,CAAC"}
@@ -1,14 +1,12 @@
1
1
  import { useContext } from "react";
2
2
  import { MetaRouterContext } from "./context";
3
3
  /**
4
- * Custom hook to access the MetaRouter analytics client.
5
- * @returns The analytics client instance.
4
+ * Hook to access the analytics client from MetaRouter context.
6
5
  */
7
6
  export const useMetaRouter = () => {
8
- const ctx = useContext(MetaRouterContext);
9
- if (!ctx)
10
- throw new Error("useMetaRouter must be used within MetaRouterProvider");
11
- return {
12
- analytics: ctx.analytics.getClient(),
13
- };
7
+ const context = useContext(MetaRouterContext);
8
+ if (!(context === null || context === void 0 ? void 0 : context.analytics)) {
9
+ throw new Error("useMetaRouter must be used within a <MetaRouterProvider> with an analytics client.");
10
+ }
11
+ return { analytics: context.analytics };
14
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metarouter/react-native-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "exports": {
@@ -1,15 +0,0 @@
1
- import type { MetaRouterInterface } from './types';
2
- import 'react-native-get-random-values';
3
- /**
4
- * Top-level MetaRouter SDK interface.
5
- *
6
- * Provides access to analytics methods for initialization, client retrieval, and reset.
7
- * Designed for use in React Native applications.
8
- *
9
- * Usage:
10
- * import MetaRouter from '@metarouter/react-native-sdk';
11
- * await MetaRouter.analytics.init({ ... });
12
- * MetaRouter.analytics.track(...);
13
- */
14
- export declare const MetaRouter: MetaRouterInterface;
15
- //# sourceMappingURL=MetaRouter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MetaRouter.d.ts","sourceRoot":"","sources":["../src/MetaRouter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,gCAAgC,CAAC;AAExC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,mBAMxB,CAAC"}
package/lib/MetaRouter.js DELETED
@@ -1,20 +0,0 @@
1
- import { initAnalytics, getAnalyticsClient, resetAnalytics } from './analytics/init';
2
- import 'react-native-get-random-values';
3
- /**
4
- * Top-level MetaRouter SDK interface.
5
- *
6
- * Provides access to analytics methods for initialization, client retrieval, and reset.
7
- * Designed for use in React Native applications.
8
- *
9
- * Usage:
10
- * import MetaRouter from '@metarouter/react-native-sdk';
11
- * await MetaRouter.analytics.init({ ... });
12
- * MetaRouter.analytics.track(...);
13
- */
14
- export const MetaRouter = {
15
- analytics: {
16
- init: (opts) => initAnalytics(opts),
17
- getClient: () => getAnalyticsClient(),
18
- reset: () => resetAnalytics(),
19
- },
20
- };
package/lib/types.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { InitOptions, AnalyticsInterface } from "./analytics/types";
2
- export interface MetaRouterInterface {
3
- analytics: {
4
- init: (opts: InitOptions) => Promise<AnalyticsInterface>;
5
- getClient: () => AnalyticsInterface;
6
- reset: () => Promise<void>;
7
- };
8
- }
9
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE;QACT,IAAI,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACzD,SAAS,EAAE,MAAM,kBAAkB,CAAC;QACpC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC;CACH"}
package/lib/types.js DELETED
@@ -1 +0,0 @@
1
- export {};