@athena-tracker/tracker 1.0.0 → 1.0.2

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.js CHANGED
@@ -2,2871 +2,186 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var reactNative = require('react-native');
6
-
7
- /**
8
- * Auto-Detection Logic
9
- *
10
- * Automatically detects whether to use on-device or server-side inference
11
- * based on availability of onnxruntime-react-native
12
- */
13
- async function detectInferenceMode(configMode) {
14
- // Respect explicit configuration
15
- if (configMode === 'on-device') {
16
- console.log('[ATHENA] Forcing on-device inference mode');
17
- return 'on-device';
18
- }
19
- if (configMode === 'server') {
20
- console.log('[ATHENA] Forcing server-side inference mode');
21
- return 'server';
22
- }
23
- // Auto-detect based on onnxruntime-react-native availability
24
- try {
25
- // Try to dynamically import onnxruntime-react-native
26
- await import('onnxruntime-react-native');
27
- console.log('[ATHENA] On-device inference available (onnxruntime-react-native detected)');
28
- return 'on-device';
29
- } catch (error) {
30
- console.log('[ATHENA] Falling back to server-side inference (onnxruntime-react-native not found)');
31
- return 'server';
32
- }
33
- }
34
- /**
35
- * Check if running in React Native environment
36
- */
37
- function isReactNative() {
38
- return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
39
- }
40
- /**
41
- * Check if running in browser environment
42
- */
43
- function isBrowser() {
44
- return typeof window !== 'undefined' && typeof document !== 'undefined';
45
- }
46
5
  /**
47
- * Get platform identifier
6
+ * @athena-tracker/tracker
7
+ * ATHENA Analytics tracker SDK wrapper
48
8
  */
49
- function getPlatform() {
50
- if (isReactNative()) {
51
- return 'react-native';
52
- } else if (isBrowser()) {
53
- return 'web';
54
- }
55
- return 'unknown';
56
- }
57
-
58
- /**
59
- * On-Device Inference Module
60
- *
61
- * Uses onnxruntime-react-native for local ML inference
62
- * Target latency: <10ms P95
63
- */
64
- let InferenceSession;
65
- let Tensor;
66
- // Dynamically import ONNX Runtime (only available in React Native)
67
- async function loadOnnxRuntime() {
68
- try {
69
- const onnx = await import('onnxruntime-react-native');
70
- InferenceSession = onnx.InferenceSession;
71
- Tensor = onnx.Tensor;
72
- return true;
73
- } catch (error) {
74
- console.error('[ATHENA] Failed to load onnxruntime-react-native:', error);
75
- return false;
76
- }
77
- }
78
- class OnDeviceInference {
79
- constructor() {
80
- this.session = null;
81
- this.modelLoaded = false;
82
- }
83
- /**
84
- * Initialize ONNX session with model file
85
- */
86
- async initialize(modelPath) {
87
- console.log('[ATHENA] Loading ONNX model for on-device inference...');
88
- // Load ONNX Runtime
89
- const loaded = await loadOnnxRuntime();
90
- if (!loaded) {
91
- throw new Error('onnxruntime-react-native not available');
92
- }
93
- try {
94
- const startTime = performance.now();
95
- this.session = await InferenceSession.create(modelPath);
96
- const loadTime = performance.now() - startTime;
97
- this.modelLoaded = true;
98
- console.log(`[ATHENA] ONNX model loaded successfully (${loadTime.toFixed(0)}ms)`);
99
- } catch (error) {
100
- console.error('[ATHENA] Failed to load ONNX model:', error);
101
- throw new Error(`Model loading failed: ${error}`);
102
- }
103
- }
104
- /**
105
- * Run inference on feature vector
106
- */
107
- async predict(features) {
108
- if (!this.modelLoaded || !this.session) {
109
- throw new Error('ONNX model not initialized. Call initialize() first.');
110
- }
111
- const startTime = performance.now();
112
- try {
113
- // Create input tensor
114
- const inputTensor = new Tensor('float32', features, [1, features.length]);
115
- const feeds = {
116
- input: inputTensor
117
- };
118
- // Run inference
119
- const results = await this.session.run(feeds);
120
- const inferenceTime = performance.now() - startTime;
121
- // Parse output
122
- const prediction = this.parseOutput(results.output);
123
- console.log(`[ATHENA] On-device inference complete: ${inferenceTime.toFixed(2)}ms ` + `(class: ${prediction.predicted_class}, confidence: ${prediction.confidence.toFixed(2)})`);
124
- return {
125
- ...prediction,
126
- inference_time_ms: Math.round(inferenceTime * 100) / 100,
127
- inference_location: 'on-device',
128
- timestamp: new Date().toISOString()
129
- };
130
- } catch (error) {
131
- console.error('[ATHENA] On-device inference failed:', error);
132
- throw new Error(`Inference failed: ${error}`);
133
- }
134
- }
135
- /**
136
- * Parse ONNX output tensor to prediction result
137
- */
138
- parseOutput(outputTensor) {
139
- const data = outputTensor.data;
140
- // Extract predictions from model output
141
- // Model outputs: [predicted_class_idx, confidence, purchase_intent, cart_abandon_risk, checkout_abandon_risk]
142
- const predictedClassIdx = data[0];
143
- const confidence = data[1];
144
- const purchaseIntent = data[2];
145
- const cartAbandonRisk = data[3] || 0;
146
- const checkoutAbandonRisk = data[4] || 0;
147
- // Map class index to label
148
- const classLabels = ['engaged_explorer', 'high_intent_buyer', 'cart_abandoner', 'checkout_abandoner', 'bounce_risk'];
149
- const predictedClass = classLabels[predictedClassIdx] || 'unknown';
150
- // Determine archetype based on purchase intent
151
- let archetype;
152
- if (purchaseIntent >= 0.85) {
153
- archetype = 'fast_mover';
154
- } else if (purchaseIntent >= 0.60) {
155
- archetype = 'on_track';
156
- } else if (purchaseIntent >= 0.40) {
157
- archetype = 'slow_adopter';
158
- } else if (purchaseIntent >= 0.20) {
159
- archetype = 'at_risk';
160
- } else {
161
- archetype = 'different_path';
9
+ class AthenaTrackerSDK {
10
+ constructor(config) {
11
+ this.scriptLoaded = false;
12
+ this.loadPromise = null;
13
+ this.config = {
14
+ apiUrl: 'https://tracker.pascal.cx',
15
+ sampleRate: 1.0,
16
+ ...config,
17
+ };
18
+ }
19
+ /**
20
+ * Load the ATHENA tracker script dynamically
21
+ */
22
+ async load() {
23
+ if (this.scriptLoaded)
24
+ return;
25
+ if (this.loadPromise)
26
+ return this.loadPromise;
27
+ this.loadPromise = new Promise((resolve, reject) => {
28
+ const script = document.createElement('script');
29
+ script.src = `${this.config.apiUrl}/v1/tracker.min.js`;
30
+ script.async = true;
31
+ script.onload = () => {
32
+ this.scriptLoaded = true;
33
+ this.initialize();
34
+ resolve();
35
+ };
36
+ script.onerror = () => {
37
+ reject(new Error('Failed to load ATHENA tracker script'));
38
+ };
39
+ document.head.appendChild(script);
40
+ });
41
+ return this.loadPromise;
42
+ }
43
+ /**
44
+ * Initialize the tracker with configuration
45
+ */
46
+ initialize() {
47
+ if (typeof window !== 'undefined' && window.PascalTracker) {
48
+ window.athenaTracker = new window.PascalTracker(this.config);
49
+ }
162
50
  }
163
- // Generate recommendations
164
- const recommendation = this.generateRecommendation(predictedClass, purchaseIntent, cartAbandonRisk, checkoutAbandonRisk);
165
- return {
166
- predicted_class: predictedClass,
167
- confidence,
168
- archetype,
169
- purchase_intent: purchaseIntent,
170
- cart_abandonment_risk: cartAbandonRisk,
171
- checkout_abandonment_risk: checkoutAbandonRisk,
172
- ...recommendation
173
- };
174
- }
175
- /**
176
- * Generate action recommendations based on prediction
177
- */
178
- generateRecommendation(predictedClass, purchaseIntent, cartAbandonRisk, checkoutAbandonRisk) {
179
- // High cart abandonment risk
180
- if (cartAbandonRisk > 0.7) {
181
- return {
182
- recommended_action: 'Show cart abandonment discount (10-15% off)',
183
- urgency: 'high',
184
- trigger_reason: `High cart abandonment risk (${(cartAbandonRisk * 100).toFixed(0)}%)`
185
- };
51
+ /**
52
+ * Get the underlying tracker instance
53
+ */
54
+ getTracker() {
55
+ if (typeof window === 'undefined') {
56
+ console.warn('ATHENA Tracker: window is not defined (SSR environment)');
57
+ return null;
58
+ }
59
+ if (!window.athenaTracker) {
60
+ console.warn('ATHENA Tracker: not initialized. Call load() first.');
61
+ return null;
62
+ }
63
+ return window.athenaTracker;
64
+ }
65
+ /**
66
+ * Identify a user
67
+ */
68
+ identify(userId, properties) {
69
+ const tracker = this.getTracker();
70
+ if (tracker && tracker.identify) {
71
+ tracker.identify({
72
+ userId,
73
+ ...properties,
74
+ });
75
+ }
186
76
  }
187
- // High checkout abandonment risk
188
- if (checkoutAbandonRisk > 0.7) {
189
- return {
190
- recommended_action: 'Simplify checkout flow or offer free shipping',
191
- urgency: 'critical',
192
- trigger_reason: `High checkout abandonment risk (${(checkoutAbandonRisk * 100).toFixed(0)}%)`
193
- };
77
+ /**
78
+ * Track a custom event
79
+ */
80
+ track(eventName, properties) {
81
+ const tracker = this.getTracker();
82
+ if (tracker && tracker.track) {
83
+ tracker.track(eventName, properties);
84
+ }
194
85
  }
195
- // High purchase intent
196
- if (purchaseIntent > 0.8) {
197
- return {
198
- recommended_action: 'Show product recommendations or upsell',
199
- urgency: 'medium',
200
- trigger_reason: `High purchase intent (${(purchaseIntent * 100).toFixed(0)}%)`
201
- };
86
+ /**
87
+ * Track a page view
88
+ */
89
+ page(pageName, properties) {
90
+ const tracker = this.getTracker();
91
+ if (tracker && tracker.page) {
92
+ tracker.page(pageName, properties);
93
+ }
202
94
  }
203
- // Low purchase intent
204
- if (purchaseIntent < 0.3) {
205
- return {
206
- recommended_action: 'Show value proposition or testimonials',
207
- urgency: 'low',
208
- trigger_reason: `Low purchase intent (${(purchaseIntent * 100).toFixed(0)}%)`
209
- };
95
+ /**
96
+ * Reset user identity (logout)
97
+ */
98
+ reset() {
99
+ const tracker = this.getTracker();
100
+ if (tracker && tracker.reset) {
101
+ tracker.reset();
102
+ }
210
103
  }
211
- return {
212
- recommended_action: 'Continue monitoring',
213
- urgency: 'low'
214
- };
215
- }
216
- /**
217
- * Check if model is loaded
218
- */
219
- isReady() {
220
- return this.modelLoaded;
221
- }
222
- /**
223
- * Cleanup resources
224
- */
225
- async dispose() {
226
- if (this.session) {
227
- try {
228
- // ONNX Runtime sessions should be disposed
229
- await this.session.release?.();
230
- console.log('[ATHENA] On-device inference session disposed');
231
- } catch (error) {
232
- console.warn('[ATHENA] Failed to dispose session:', error);
233
- }
234
- this.session = null;
235
- this.modelLoaded = false;
104
+ /**
105
+ * Get current session ID
106
+ */
107
+ getSessionId() {
108
+ const tracker = this.getTracker();
109
+ if (tracker && tracker.getSessionId) {
110
+ return tracker.getSessionId();
111
+ }
112
+ return null;
113
+ }
114
+ /**
115
+ * Get current user ID
116
+ */
117
+ getUserId() {
118
+ const tracker = this.getTracker();
119
+ if (tracker && tracker.getUserId) {
120
+ return tracker.getUserId();
121
+ }
122
+ return null;
236
123
  }
237
- }
238
124
  }
239
-
125
+ // Singleton instance
126
+ let trackerInstance = null;
240
127
  /**
241
- * Server-Side Inference Module
242
- *
243
- * Fallback inference via HTTP API when on-device inference is not available
244
- * Target latency: <100ms P95
128
+ * Initialize ATHENA tracker
245
129
  */
246
- class ServerInference {
247
- constructor(apiUrl, appToken, timeout = 5000) {
248
- this.apiUrl = apiUrl;
249
- this.appToken = appToken;
250
- this.timeout = timeout;
251
- }
252
- /**
253
- * Make prediction request to server
254
- */
255
- async predict(events, sessionId, userId) {
256
- const startTime = Date.now();
257
- try {
258
- const requestBody = {
259
- app_token: this.appToken,
260
- events,
261
- session_id: sessionId,
262
- user_id: userId
263
- };
264
- console.log(`[ATHENA] Sending ${events.length} events to server for inference...`);
265
- const response = await this.fetchWithTimeout(`${this.apiUrl}/v1/predict`, {
266
- method: 'POST',
267
- headers: {
268
- 'Content-Type': 'application/json',
269
- 'X-App-Token': this.appToken
270
- },
271
- body: JSON.stringify(requestBody)
272
- }, this.timeout);
273
- if (!response.ok) {
274
- const errorText = await response.text();
275
- throw new Error(`Server inference failed: ${response.status} ${errorText}`);
276
- }
277
- const result = await response.json();
278
- const latency = Date.now() - startTime;
279
- console.log(`[ATHENA] Server-side inference complete: ${latency}ms ` + `(class: ${result.predicted_class}, confidence: ${result.confidence.toFixed(2)})`);
280
- return {
281
- ...result,
282
- inference_time_ms: latency,
283
- inference_location: 'server',
284
- timestamp: result.timestamp || new Date().toISOString()
285
- };
286
- } catch (error) {
287
- const latency = Date.now() - startTime;
288
- console.error(`[ATHENA] Server inference failed after ${latency}ms:`, error.message);
289
- throw new Error(`Server inference failed: ${error.message}`);
290
- }
291
- }
292
- /**
293
- * Fetch with timeout
294
- */
295
- async fetchWithTimeout(url, options, timeout) {
296
- const controller = new AbortController();
297
- const timeoutId = setTimeout(() => controller.abort(), timeout);
298
- try {
299
- const response = await fetch(url, {
300
- ...options,
301
- signal: controller.signal
302
- });
303
- clearTimeout(timeoutId);
304
- return response;
305
- } catch (error) {
306
- clearTimeout(timeoutId);
307
- if (error.name === 'AbortError') {
308
- throw new Error(`Request timeout after ${timeout}ms`);
309
- }
310
- throw error;
311
- }
312
- }
313
- /**
314
- * Test server connectivity
315
- */
316
- async testConnection() {
317
- try {
318
- const response = await this.fetchWithTimeout(`${this.apiUrl}/health`, {
319
- method: 'GET'
320
- }, 3000);
321
- return response.ok;
322
- } catch (error) {
323
- console.warn('[ATHENA] Server connectivity test failed:', error);
324
- return false;
130
+ function initTracker(config) {
131
+ if (!trackerInstance) {
132
+ trackerInstance = new AthenaTrackerSDK(config);
325
133
  }
326
- }
327
- /**
328
- * Update configuration
329
- */
330
- updateConfig(apiUrl, appToken, timeout) {
331
- if (apiUrl) this.apiUrl = apiUrl;
332
- if (appToken) this.appToken = appToken;
333
- if (timeout) this.timeout = timeout;
334
- }
134
+ return trackerInstance;
335
135
  }
336
-
337
136
  /**
338
- * ATHENA Tracker - Main Class
339
- *
340
- * Unified interface for behavioral tracking with dual-mode ML inference
137
+ * Get the tracker instance
341
138
  */
342
- const DEFAULT_API_URL = 'https://tracker.pascal.cx';
343
- const DEFAULT_MODEL_PATH = 'https://tracker.pascal.cx/models/base_model_int8.onnx';
344
- const DEFAULT_BATCH_SIZE = 10;
345
- const DEFAULT_BATCH_INTERVAL_MS = 10000; // 10 seconds
346
- class AthenaTracker {
347
- constructor() {
348
- this.config = null;
349
- this.state = {
350
- initialized: false,
351
- inferenceMode: null,
352
- sessionId: null,
353
- userId: null,
354
- events: []
355
- };
356
- this.onDeviceInference = null;
357
- this.serverInference = null;
358
- this.batchIntervalId = null;
359
- // Private constructor for singleton
360
- }
361
- /**
362
- * Get singleton instance
363
- */
364
- static getInstance() {
365
- if (!AthenaTracker.instance) {
366
- AthenaTracker.instance = new AthenaTracker();
367
- }
368
- return AthenaTracker.instance;
369
- }
370
- /**
371
- * Initialize tracker
372
- */
373
- static async init(config) {
374
- const instance = AthenaTracker.getInstance();
375
- if (instance.state.initialized) {
376
- console.warn('[ATHENA] Already initialized');
377
- return;
139
+ function getTracker() {
140
+ if (!trackerInstance) {
141
+ console.warn('ATHENA Tracker: not initialized. Call initTracker() first.');
378
142
  }
379
- console.log('[ATHENA] Initializing tracker...');
380
- instance.config = {
381
- ...config,
382
- apiUrl: config.apiUrl || DEFAULT_API_URL,
383
- modelPath: config.modelPath || DEFAULT_MODEL_PATH,
384
- serverInferenceUrl: config.serverInferenceUrl || `${config.apiUrl || DEFAULT_API_URL}/v1/predict`,
385
- batching: {
386
- size: config.batching?.size || DEFAULT_BATCH_SIZE,
387
- intervalMs: config.batching?.intervalMs || DEFAULT_BATCH_INTERVAL_MS
388
- }
389
- };
390
- // Detect inference mode
391
- const detectedMode = await detectInferenceMode(config.inferenceMode);
392
- instance.state.inferenceMode = detectedMode;
393
- // Initialize appropriate inference engine
394
- if (detectedMode === 'on-device') {
395
- await instance.initializeOnDevice();
396
- } else {
397
- await instance.initializeServer();
398
- }
399
- // Generate session ID
400
- instance.state.sessionId = instance.generateSessionId();
401
- // Start event batching
402
- instance.startBatching();
403
- instance.state.initialized = true;
404
- console.log(`[ATHENA] Tracker initialized successfully (mode: ${detectedMode}, platform: ${getPlatform()})`);
405
- }
406
- /**
407
- * Initialize on-device inference
408
- */
409
- async initializeOnDevice() {
410
- try {
411
- this.onDeviceInference = new OnDeviceInference();
412
- await this.onDeviceInference.initialize(this.config.modelPath);
413
- console.log('[ATHENA] On-device inference ready');
414
- } catch (error) {
415
- console.error('[ATHENA] On-device inference initialization failed:', error);
416
- console.log('[ATHENA] Falling back to server-side inference');
417
- this.state.inferenceMode = 'server';
418
- await this.initializeServer();
419
- }
420
- }
421
- /**
422
- * Initialize server-side inference
423
- */
424
- async initializeServer() {
425
- this.serverInference = new ServerInference(this.config.serverInferenceUrl, this.config.appToken);
426
- // Test connectivity
427
- const connected = await this.serverInference.testConnection();
428
- if (!connected) {
429
- console.warn('[ATHENA] Server connectivity test failed - predictions may fail');
430
- } else {
431
- console.log('[ATHENA] Server-side inference ready');
432
- }
433
- }
434
- /**
435
- * Identify a user
436
- */
437
- static identify(userId, traits) {
438
- const instance = AthenaTracker.getInstance();
439
- instance.state.userId = userId;
440
- instance.track('identify', {
441
- user_id: userId,
442
- ...traits
443
- });
444
- console.log(`[ATHENA] User identified: ${userId}`);
445
- }
446
- /**
447
- * Track an event
448
- */
449
- static track(eventType, properties) {
450
- const instance = AthenaTracker.getInstance();
451
- if (!instance.state.initialized) {
452
- console.warn('[ATHENA] Tracker not initialized. Call init() first.');
453
- return;
454
- }
455
- const event = {
456
- event_type: eventType,
457
- timestamp: Date.now(),
458
- properties: properties || {},
459
- session_id: instance.state.sessionId || undefined,
460
- user_id: instance.state.userId || undefined
461
- };
462
- instance.state.events.push(event);
463
- if (instance.config?.debug) {
464
- console.log('[ATHENA] Event tracked:', event);
465
- }
466
- // Trigger immediate inference if batch size reached
467
- if (instance.state.events.length >= instance.config.batching.size) {
468
- instance.processBatch();
469
- }
470
- }
471
- /**
472
- * Process event batch and run inference
473
- */
474
- async processBatch() {
475
- if (this.state.events.length === 0) return;
476
- const events = [...this.state.events];
477
- this.state.events = [];
478
- try {
479
- const prediction = await this.runInference(events);
480
- if (this.config?.webhook?.enabled && this.config.webhook.url) {
481
- await this.sendWebhook(prediction);
482
- }
483
- if (this.config?.debug) {
484
- console.log('[ATHENA] Prediction:', prediction);
485
- }
486
- } catch (error) {
487
- console.error('[ATHENA] Failed to process batch:', error);
488
- // Re-queue events on failure
489
- this.state.events.unshift(...events);
490
- }
491
- }
492
- /**
493
- * Run inference (delegates to on-device or server)
494
- */
495
- async runInference(events) {
496
- if (this.state.inferenceMode === 'on-device' && this.onDeviceInference) {
497
- // Extract features from events (simplified - would need proper feature extraction)
498
- const features = this.extractFeatures(events);
499
- return await this.onDeviceInference.predict(features);
500
- } else if (this.state.inferenceMode === 'server' && this.serverInference) {
501
- return await this.serverInference.predict(events, this.state.sessionId || undefined, this.state.userId || undefined);
502
- } else {
503
- throw new Error('No inference engine available');
504
- }
505
- }
506
- /**
507
- * Extract features from events (placeholder)
508
- * In production, this would use proper feature engineering
509
- */
510
- extractFeatures(events) {
511
- // Simplified feature extraction - 20 features
512
- const features = new Float32Array(20);
513
- // Event count
514
- features[0] = events.length;
515
- // Unique event types
516
- const uniqueTypes = new Set(events.map(e => e.event_type));
517
- features[1] = uniqueTypes.size;
518
- // Time span
519
- if (events.length > 1) {
520
- const timeSpan = events[events.length - 1].timestamp - events[0].timestamp;
521
- features[2] = timeSpan / 1000; // seconds
522
- }
523
- // Fill remaining features with event type frequencies
524
- const typeCounts = new Map();
525
- events.forEach(e => {
526
- typeCounts.set(e.event_type, (typeCounts.get(e.event_type) || 0) + 1);
527
- });
528
- let idx = 3;
529
- ['click', 'scroll', 'page_view', 'cart_add', 'checkout_start'].forEach(type => {
530
- features[idx++] = typeCounts.get(type) || 0;
531
- });
532
- return features;
533
- }
534
- /**
535
- * Send prediction to webhook
536
- */
537
- async sendWebhook(prediction) {
538
- if (!this.config?.webhook?.url) return;
539
- const maxAttempts = this.config.webhook.retry?.maxAttempts || 3;
540
- const backoffMs = this.config.webhook.retry?.backoffMs || 1000;
541
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
542
- try {
543
- const response = await fetch(this.config.webhook.url, {
544
- method: 'POST',
545
- headers: {
546
- 'Content-Type': 'application/json',
547
- 'X-App-Token': this.config.appToken
548
- },
549
- body: JSON.stringify({
550
- ...prediction,
551
- session_id: this.state.sessionId,
552
- user_id: this.state.userId
553
- })
554
- });
555
- if (response.ok) {
556
- if (this.config.debug) {
557
- console.log('[ATHENA] Webhook delivered successfully');
558
- }
559
- return;
560
- }
561
- throw new Error(`Webhook failed: ${response.status}`);
562
- } catch (error) {
563
- console.warn(`[ATHENA] Webhook attempt ${attempt}/${maxAttempts} failed:`, error);
564
- if (attempt < maxAttempts) {
565
- await this.sleep(backoffMs * Math.pow(2, attempt - 1));
566
- }
567
- }
568
- }
569
- console.error('[ATHENA] Webhook delivery failed after all retries');
570
- }
571
- /**
572
- * Start event batching interval
573
- */
574
- startBatching() {
575
- this.batchIntervalId = setInterval(() => {
576
- this.processBatch();
577
- }, this.config.batching.intervalMs);
578
- }
579
- /**
580
- * Get inference mode
581
- */
582
- static getInferenceMode() {
583
- return AthenaTracker.getInstance().state.inferenceMode;
584
- }
585
- /**
586
- * Get session ID
587
- */
588
- static getSessionId() {
589
- return AthenaTracker.getInstance().state.sessionId;
590
- }
591
- /**
592
- * Cleanup resources
593
- */
594
- static async dispose() {
595
- const instance = AthenaTracker.getInstance();
596
- if (instance.batchIntervalId) {
597
- clearInterval(instance.batchIntervalId);
598
- }
599
- if (instance.onDeviceInference) {
600
- await instance.onDeviceInference.dispose();
601
- }
602
- instance.state.initialized = false;
603
- console.log('[ATHENA] Tracker disposed');
604
- }
605
- /**
606
- * Generate session ID
607
- */
608
- generateSessionId() {
609
- return `sess_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
610
- }
611
- /**
612
- * Sleep utility
613
- */
614
- sleep(ms) {
615
- return new Promise(resolve => setTimeout(resolve, ms));
616
- }
617
- }
618
- AthenaTracker.instance = null;
619
-
620
- function getDefaultExportFromCjs (x) {
621
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
143
+ return trackerInstance;
622
144
  }
623
-
624
- var react = {exports: {}};
625
-
626
- var react_production = {};
627
-
628
145
  /**
629
- * @license React
630
- * react.production.js
631
- *
632
- * Copyright (c) Meta Platforms, Inc. and affiliates.
633
- *
634
- * This source code is licensed under the MIT license found in the
635
- * LICENSE file in the root directory of this source tree.
146
+ * Convenience methods (use singleton instance)
636
147
  */
637
-
638
- var hasRequiredReact_production;
639
-
640
- function requireReact_production () {
641
- if (hasRequiredReact_production) return react_production;
642
- hasRequiredReact_production = 1;
643
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
644
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
645
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
646
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
647
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
648
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
649
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
650
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
651
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
652
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
653
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
654
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
655
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
656
- function getIteratorFn(maybeIterable) {
657
- if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
658
- maybeIterable =
659
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
660
- maybeIterable["@@iterator"];
661
- return "function" === typeof maybeIterable ? maybeIterable : null;
662
- }
663
- var ReactNoopUpdateQueue = {
664
- isMounted: function () {
665
- return false;
666
- },
667
- enqueueForceUpdate: function () {},
668
- enqueueReplaceState: function () {},
669
- enqueueSetState: function () {}
670
- },
671
- assign = Object.assign,
672
- emptyObject = {};
673
- function Component(props, context, updater) {
674
- this.props = props;
675
- this.context = context;
676
- this.refs = emptyObject;
677
- this.updater = updater || ReactNoopUpdateQueue;
678
- }
679
- Component.prototype.isReactComponent = {};
680
- Component.prototype.setState = function (partialState, callback) {
681
- if (
682
- "object" !== typeof partialState &&
683
- "function" !== typeof partialState &&
684
- null != partialState
685
- )
686
- throw Error(
687
- "takes an object of state variables to update or a function which returns an object of state variables."
688
- );
689
- this.updater.enqueueSetState(this, partialState, callback, "setState");
690
- };
691
- Component.prototype.forceUpdate = function (callback) {
692
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
693
- };
694
- function ComponentDummy() {}
695
- ComponentDummy.prototype = Component.prototype;
696
- function PureComponent(props, context, updater) {
697
- this.props = props;
698
- this.context = context;
699
- this.refs = emptyObject;
700
- this.updater = updater || ReactNoopUpdateQueue;
701
- }
702
- var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
703
- pureComponentPrototype.constructor = PureComponent;
704
- assign(pureComponentPrototype, Component.prototype);
705
- pureComponentPrototype.isPureReactComponent = true;
706
- var isArrayImpl = Array.isArray;
707
- function noop() {}
708
- var ReactSharedInternals = { H: null, A: null, T: null, S: null },
709
- hasOwnProperty = Object.prototype.hasOwnProperty;
710
- function ReactElement(type, key, props) {
711
- var refProp = props.ref;
712
- return {
713
- $$typeof: REACT_ELEMENT_TYPE,
714
- type: type,
715
- key: key,
716
- ref: void 0 !== refProp ? refProp : null,
717
- props: props
718
- };
719
- }
720
- function cloneAndReplaceKey(oldElement, newKey) {
721
- return ReactElement(oldElement.type, newKey, oldElement.props);
722
- }
723
- function isValidElement(object) {
724
- return (
725
- "object" === typeof object &&
726
- null !== object &&
727
- object.$$typeof === REACT_ELEMENT_TYPE
728
- );
729
- }
730
- function escape(key) {
731
- var escaperLookup = { "=": "=0", ":": "=2" };
732
- return (
733
- "$" +
734
- key.replace(/[=:]/g, function (match) {
735
- return escaperLookup[match];
736
- })
737
- );
738
- }
739
- var userProvidedKeyEscapeRegex = /\/+/g;
740
- function getElementKey(element, index) {
741
- return "object" === typeof element && null !== element && null != element.key
742
- ? escape("" + element.key)
743
- : index.toString(36);
744
- }
745
- function resolveThenable(thenable) {
746
- switch (thenable.status) {
747
- case "fulfilled":
748
- return thenable.value;
749
- case "rejected":
750
- throw thenable.reason;
751
- default:
752
- switch (
753
- ("string" === typeof thenable.status
754
- ? thenable.then(noop, noop)
755
- : ((thenable.status = "pending"),
756
- thenable.then(
757
- function (fulfilledValue) {
758
- "pending" === thenable.status &&
759
- ((thenable.status = "fulfilled"),
760
- (thenable.value = fulfilledValue));
761
- },
762
- function (error) {
763
- "pending" === thenable.status &&
764
- ((thenable.status = "rejected"), (thenable.reason = error));
765
- }
766
- )),
767
- thenable.status)
768
- ) {
769
- case "fulfilled":
770
- return thenable.value;
771
- case "rejected":
772
- throw thenable.reason;
773
- }
774
- }
775
- throw thenable;
776
- }
777
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
778
- var type = typeof children;
779
- if ("undefined" === type || "boolean" === type) children = null;
780
- var invokeCallback = false;
781
- if (null === children) invokeCallback = true;
782
- else
783
- switch (type) {
784
- case "bigint":
785
- case "string":
786
- case "number":
787
- invokeCallback = true;
788
- break;
789
- case "object":
790
- switch (children.$$typeof) {
791
- case REACT_ELEMENT_TYPE:
792
- case REACT_PORTAL_TYPE:
793
- invokeCallback = true;
794
- break;
795
- case REACT_LAZY_TYPE:
796
- return (
797
- (invokeCallback = children._init),
798
- mapIntoArray(
799
- invokeCallback(children._payload),
800
- array,
801
- escapedPrefix,
802
- nameSoFar,
803
- callback
804
- )
805
- );
806
- }
807
- }
808
- if (invokeCallback)
809
- return (
810
- (callback = callback(children)),
811
- (invokeCallback =
812
- "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
813
- isArrayImpl(callback)
814
- ? ((escapedPrefix = ""),
815
- null != invokeCallback &&
816
- (escapedPrefix =
817
- invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
818
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
819
- return c;
820
- }))
821
- : null != callback &&
822
- (isValidElement(callback) &&
823
- (callback = cloneAndReplaceKey(
824
- callback,
825
- escapedPrefix +
826
- (null == callback.key ||
827
- (children && children.key === callback.key)
828
- ? ""
829
- : ("" + callback.key).replace(
830
- userProvidedKeyEscapeRegex,
831
- "$&/"
832
- ) + "/") +
833
- invokeCallback
834
- )),
835
- array.push(callback)),
836
- 1
837
- );
838
- invokeCallback = 0;
839
- var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
840
- if (isArrayImpl(children))
841
- for (var i = 0; i < children.length; i++)
842
- (nameSoFar = children[i]),
843
- (type = nextNamePrefix + getElementKey(nameSoFar, i)),
844
- (invokeCallback += mapIntoArray(
845
- nameSoFar,
846
- array,
847
- escapedPrefix,
848
- type,
849
- callback
850
- ));
851
- else if (((i = getIteratorFn(children)), "function" === typeof i))
852
- for (
853
- children = i.call(children), i = 0;
854
- !(nameSoFar = children.next()).done;
855
-
856
- )
857
- (nameSoFar = nameSoFar.value),
858
- (type = nextNamePrefix + getElementKey(nameSoFar, i++)),
859
- (invokeCallback += mapIntoArray(
860
- nameSoFar,
861
- array,
862
- escapedPrefix,
863
- type,
864
- callback
865
- ));
866
- else if ("object" === type) {
867
- if ("function" === typeof children.then)
868
- return mapIntoArray(
869
- resolveThenable(children),
870
- array,
871
- escapedPrefix,
872
- nameSoFar,
873
- callback
874
- );
875
- array = String(children);
876
- throw Error(
877
- "Objects are not valid as a React child (found: " +
878
- ("[object Object]" === array
879
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
880
- : array) +
881
- "). If you meant to render a collection of children, use an array instead."
882
- );
883
- }
884
- return invokeCallback;
885
- }
886
- function mapChildren(children, func, context) {
887
- if (null == children) return children;
888
- var result = [],
889
- count = 0;
890
- mapIntoArray(children, result, "", "", function (child) {
891
- return func.call(context, child, count++);
892
- });
893
- return result;
894
- }
895
- function lazyInitializer(payload) {
896
- if (-1 === payload._status) {
897
- var ctor = payload._result;
898
- ctor = ctor();
899
- ctor.then(
900
- function (moduleObject) {
901
- if (0 === payload._status || -1 === payload._status)
902
- (payload._status = 1), (payload._result = moduleObject);
903
- },
904
- function (error) {
905
- if (0 === payload._status || -1 === payload._status)
906
- (payload._status = 2), (payload._result = error);
907
- }
908
- );
909
- -1 === payload._status && ((payload._status = 0), (payload._result = ctor));
910
- }
911
- if (1 === payload._status) return payload._result.default;
912
- throw payload._result;
913
- }
914
- var reportGlobalError =
915
- "function" === typeof reportError
916
- ? reportError
917
- : function (error) {
918
- if (
919
- "object" === typeof window &&
920
- "function" === typeof window.ErrorEvent
921
- ) {
922
- var event = new window.ErrorEvent("error", {
923
- bubbles: true,
924
- cancelable: true,
925
- message:
926
- "object" === typeof error &&
927
- null !== error &&
928
- "string" === typeof error.message
929
- ? String(error.message)
930
- : String(error),
931
- error: error
932
- });
933
- if (!window.dispatchEvent(event)) return;
934
- } else if (
935
- "object" === typeof process &&
936
- "function" === typeof process.emit
937
- ) {
938
- process.emit("uncaughtException", error);
939
- return;
940
- }
941
- console.error(error);
942
- },
943
- Children = {
944
- map: mapChildren,
945
- forEach: function (children, forEachFunc, forEachContext) {
946
- mapChildren(
947
- children,
948
- function () {
949
- forEachFunc.apply(this, arguments);
950
- },
951
- forEachContext
952
- );
953
- },
954
- count: function (children) {
955
- var n = 0;
956
- mapChildren(children, function () {
957
- n++;
958
- });
959
- return n;
960
- },
961
- toArray: function (children) {
962
- return (
963
- mapChildren(children, function (child) {
964
- return child;
965
- }) || []
966
- );
967
- },
968
- only: function (children) {
969
- if (!isValidElement(children))
970
- throw Error(
971
- "React.Children.only expected to receive a single React element child."
972
- );
973
- return children;
974
- }
975
- };
976
- react_production.Activity = REACT_ACTIVITY_TYPE;
977
- react_production.Children = Children;
978
- react_production.Component = Component;
979
- react_production.Fragment = REACT_FRAGMENT_TYPE;
980
- react_production.Profiler = REACT_PROFILER_TYPE;
981
- react_production.PureComponent = PureComponent;
982
- react_production.StrictMode = REACT_STRICT_MODE_TYPE;
983
- react_production.Suspense = REACT_SUSPENSE_TYPE;
984
- react_production.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
985
- ReactSharedInternals;
986
- react_production.__COMPILER_RUNTIME = {
987
- __proto__: null,
988
- c: function (size) {
989
- return ReactSharedInternals.H.useMemoCache(size);
990
- }
991
- };
992
- react_production.cache = function (fn) {
993
- return function () {
994
- return fn.apply(null, arguments);
995
- };
996
- };
997
- react_production.cacheSignal = function () {
998
- return null;
999
- };
1000
- react_production.cloneElement = function (element, config, children) {
1001
- if (null === element || void 0 === element)
1002
- throw Error(
1003
- "The argument must be a React element, but you passed " + element + "."
1004
- );
1005
- var props = assign({}, element.props),
1006
- key = element.key;
1007
- if (null != config)
1008
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
1009
- !hasOwnProperty.call(config, propName) ||
1010
- "key" === propName ||
1011
- "__self" === propName ||
1012
- "__source" === propName ||
1013
- ("ref" === propName && void 0 === config.ref) ||
1014
- (props[propName] = config[propName]);
1015
- var propName = arguments.length - 2;
1016
- if (1 === propName) props.children = children;
1017
- else if (1 < propName) {
1018
- for (var childArray = Array(propName), i = 0; i < propName; i++)
1019
- childArray[i] = arguments[i + 2];
1020
- props.children = childArray;
1021
- }
1022
- return ReactElement(element.type, key, props);
1023
- };
1024
- react_production.createContext = function (defaultValue) {
1025
- defaultValue = {
1026
- $$typeof: REACT_CONTEXT_TYPE,
1027
- _currentValue: defaultValue,
1028
- _currentValue2: defaultValue,
1029
- _threadCount: 0,
1030
- Provider: null,
1031
- Consumer: null
1032
- };
1033
- defaultValue.Provider = defaultValue;
1034
- defaultValue.Consumer = {
1035
- $$typeof: REACT_CONSUMER_TYPE,
1036
- _context: defaultValue
1037
- };
1038
- return defaultValue;
1039
- };
1040
- react_production.createElement = function (type, config, children) {
1041
- var propName,
1042
- props = {},
1043
- key = null;
1044
- if (null != config)
1045
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
1046
- hasOwnProperty.call(config, propName) &&
1047
- "key" !== propName &&
1048
- "__self" !== propName &&
1049
- "__source" !== propName &&
1050
- (props[propName] = config[propName]);
1051
- var childrenLength = arguments.length - 2;
1052
- if (1 === childrenLength) props.children = children;
1053
- else if (1 < childrenLength) {
1054
- for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
1055
- childArray[i] = arguments[i + 2];
1056
- props.children = childArray;
1057
- }
1058
- if (type && type.defaultProps)
1059
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
1060
- void 0 === props[propName] &&
1061
- (props[propName] = childrenLength[propName]);
1062
- return ReactElement(type, key, props);
1063
- };
1064
- react_production.createRef = function () {
1065
- return { current: null };
1066
- };
1067
- react_production.forwardRef = function (render) {
1068
- return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
1069
- };
1070
- react_production.isValidElement = isValidElement;
1071
- react_production.lazy = function (ctor) {
1072
- return {
1073
- $$typeof: REACT_LAZY_TYPE,
1074
- _payload: { _status: -1, _result: ctor },
1075
- _init: lazyInitializer
1076
- };
1077
- };
1078
- react_production.memo = function (type, compare) {
1079
- return {
1080
- $$typeof: REACT_MEMO_TYPE,
1081
- type: type,
1082
- compare: void 0 === compare ? null : compare
1083
- };
1084
- };
1085
- react_production.startTransition = function (scope) {
1086
- var prevTransition = ReactSharedInternals.T,
1087
- currentTransition = {};
1088
- ReactSharedInternals.T = currentTransition;
1089
- try {
1090
- var returnValue = scope(),
1091
- onStartTransitionFinish = ReactSharedInternals.S;
1092
- null !== onStartTransitionFinish &&
1093
- onStartTransitionFinish(currentTransition, returnValue);
1094
- "object" === typeof returnValue &&
1095
- null !== returnValue &&
1096
- "function" === typeof returnValue.then &&
1097
- returnValue.then(noop, reportGlobalError);
1098
- } catch (error) {
1099
- reportGlobalError(error);
1100
- } finally {
1101
- null !== prevTransition &&
1102
- null !== currentTransition.types &&
1103
- (prevTransition.types = currentTransition.types),
1104
- (ReactSharedInternals.T = prevTransition);
1105
- }
1106
- };
1107
- react_production.unstable_useCacheRefresh = function () {
1108
- return ReactSharedInternals.H.useCacheRefresh();
1109
- };
1110
- react_production.use = function (usable) {
1111
- return ReactSharedInternals.H.use(usable);
1112
- };
1113
- react_production.useActionState = function (action, initialState, permalink) {
1114
- return ReactSharedInternals.H.useActionState(action, initialState, permalink);
1115
- };
1116
- react_production.useCallback = function (callback, deps) {
1117
- return ReactSharedInternals.H.useCallback(callback, deps);
1118
- };
1119
- react_production.useContext = function (Context) {
1120
- return ReactSharedInternals.H.useContext(Context);
1121
- };
1122
- react_production.useDebugValue = function () {};
1123
- react_production.useDeferredValue = function (value, initialValue) {
1124
- return ReactSharedInternals.H.useDeferredValue(value, initialValue);
1125
- };
1126
- react_production.useEffect = function (create, deps) {
1127
- return ReactSharedInternals.H.useEffect(create, deps);
1128
- };
1129
- react_production.useEffectEvent = function (callback) {
1130
- return ReactSharedInternals.H.useEffectEvent(callback);
1131
- };
1132
- react_production.useId = function () {
1133
- return ReactSharedInternals.H.useId();
1134
- };
1135
- react_production.useImperativeHandle = function (ref, create, deps) {
1136
- return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
1137
- };
1138
- react_production.useInsertionEffect = function (create, deps) {
1139
- return ReactSharedInternals.H.useInsertionEffect(create, deps);
1140
- };
1141
- react_production.useLayoutEffect = function (create, deps) {
1142
- return ReactSharedInternals.H.useLayoutEffect(create, deps);
1143
- };
1144
- react_production.useMemo = function (create, deps) {
1145
- return ReactSharedInternals.H.useMemo(create, deps);
1146
- };
1147
- react_production.useOptimistic = function (passthrough, reducer) {
1148
- return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
1149
- };
1150
- react_production.useReducer = function (reducer, initialArg, init) {
1151
- return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
1152
- };
1153
- react_production.useRef = function (initialValue) {
1154
- return ReactSharedInternals.H.useRef(initialValue);
1155
- };
1156
- react_production.useState = function (initialState) {
1157
- return ReactSharedInternals.H.useState(initialState);
1158
- };
1159
- react_production.useSyncExternalStore = function (
1160
- subscribe,
1161
- getSnapshot,
1162
- getServerSnapshot
1163
- ) {
1164
- return ReactSharedInternals.H.useSyncExternalStore(
1165
- subscribe,
1166
- getSnapshot,
1167
- getServerSnapshot
1168
- );
1169
- };
1170
- react_production.useTransition = function () {
1171
- return ReactSharedInternals.H.useTransition();
1172
- };
1173
- react_production.version = "19.2.4";
1174
- return react_production;
148
+ function identify(userId, properties) {
149
+ trackerInstance?.identify(userId, properties);
1175
150
  }
1176
-
1177
- var react_development = {exports: {}};
1178
-
1179
- /**
1180
- * @license React
1181
- * react.development.js
1182
- *
1183
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1184
- *
1185
- * This source code is licensed under the MIT license found in the
1186
- * LICENSE file in the root directory of this source tree.
1187
- */
1188
- react_development.exports;
1189
-
1190
- var hasRequiredReact_development;
1191
-
1192
- function requireReact_development () {
1193
- if (hasRequiredReact_development) return react_development.exports;
1194
- hasRequiredReact_development = 1;
1195
- (function (module, exports$1) {
1196
- "production" !== process.env.NODE_ENV &&
1197
- (function () {
1198
- function defineDeprecationWarning(methodName, info) {
1199
- Object.defineProperty(Component.prototype, methodName, {
1200
- get: function () {
1201
- console.warn(
1202
- "%s(...) is deprecated in plain JavaScript React classes. %s",
1203
- info[0],
1204
- info[1]
1205
- );
1206
- }
1207
- });
1208
- }
1209
- function getIteratorFn(maybeIterable) {
1210
- if (null === maybeIterable || "object" !== typeof maybeIterable)
1211
- return null;
1212
- maybeIterable =
1213
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
1214
- maybeIterable["@@iterator"];
1215
- return "function" === typeof maybeIterable ? maybeIterable : null;
1216
- }
1217
- function warnNoop(publicInstance, callerName) {
1218
- publicInstance =
1219
- ((publicInstance = publicInstance.constructor) &&
1220
- (publicInstance.displayName || publicInstance.name)) ||
1221
- "ReactClass";
1222
- var warningKey = publicInstance + "." + callerName;
1223
- didWarnStateUpdateForUnmountedComponent[warningKey] ||
1224
- (console.error(
1225
- "Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
1226
- callerName,
1227
- publicInstance
1228
- ),
1229
- (didWarnStateUpdateForUnmountedComponent[warningKey] = true));
1230
- }
1231
- function Component(props, context, updater) {
1232
- this.props = props;
1233
- this.context = context;
1234
- this.refs = emptyObject;
1235
- this.updater = updater || ReactNoopUpdateQueue;
1236
- }
1237
- function ComponentDummy() {}
1238
- function PureComponent(props, context, updater) {
1239
- this.props = props;
1240
- this.context = context;
1241
- this.refs = emptyObject;
1242
- this.updater = updater || ReactNoopUpdateQueue;
1243
- }
1244
- function noop() {}
1245
- function testStringCoercion(value) {
1246
- return "" + value;
1247
- }
1248
- function checkKeyStringCoercion(value) {
1249
- try {
1250
- testStringCoercion(value);
1251
- var JSCompiler_inline_result = !1;
1252
- } catch (e) {
1253
- JSCompiler_inline_result = true;
1254
- }
1255
- if (JSCompiler_inline_result) {
1256
- JSCompiler_inline_result = console;
1257
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
1258
- var JSCompiler_inline_result$jscomp$0 =
1259
- ("function" === typeof Symbol &&
1260
- Symbol.toStringTag &&
1261
- value[Symbol.toStringTag]) ||
1262
- value.constructor.name ||
1263
- "Object";
1264
- JSCompiler_temp_const.call(
1265
- JSCompiler_inline_result,
1266
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
1267
- JSCompiler_inline_result$jscomp$0
1268
- );
1269
- return testStringCoercion(value);
1270
- }
1271
- }
1272
- function getComponentNameFromType(type) {
1273
- if (null == type) return null;
1274
- if ("function" === typeof type)
1275
- return type.$$typeof === REACT_CLIENT_REFERENCE
1276
- ? null
1277
- : type.displayName || type.name || null;
1278
- if ("string" === typeof type) return type;
1279
- switch (type) {
1280
- case REACT_FRAGMENT_TYPE:
1281
- return "Fragment";
1282
- case REACT_PROFILER_TYPE:
1283
- return "Profiler";
1284
- case REACT_STRICT_MODE_TYPE:
1285
- return "StrictMode";
1286
- case REACT_SUSPENSE_TYPE:
1287
- return "Suspense";
1288
- case REACT_SUSPENSE_LIST_TYPE:
1289
- return "SuspenseList";
1290
- case REACT_ACTIVITY_TYPE:
1291
- return "Activity";
1292
- }
1293
- if ("object" === typeof type)
1294
- switch (
1295
- ("number" === typeof type.tag &&
1296
- console.error(
1297
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
1298
- ),
1299
- type.$$typeof)
1300
- ) {
1301
- case REACT_PORTAL_TYPE:
1302
- return "Portal";
1303
- case REACT_CONTEXT_TYPE:
1304
- return type.displayName || "Context";
1305
- case REACT_CONSUMER_TYPE:
1306
- return (type._context.displayName || "Context") + ".Consumer";
1307
- case REACT_FORWARD_REF_TYPE:
1308
- var innerType = type.render;
1309
- type = type.displayName;
1310
- type ||
1311
- ((type = innerType.displayName || innerType.name || ""),
1312
- (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
1313
- return type;
1314
- case REACT_MEMO_TYPE:
1315
- return (
1316
- (innerType = type.displayName || null),
1317
- null !== innerType
1318
- ? innerType
1319
- : getComponentNameFromType(type.type) || "Memo"
1320
- );
1321
- case REACT_LAZY_TYPE:
1322
- innerType = type._payload;
1323
- type = type._init;
1324
- try {
1325
- return getComponentNameFromType(type(innerType));
1326
- } catch (x) {}
1327
- }
1328
- return null;
1329
- }
1330
- function getTaskName(type) {
1331
- if (type === REACT_FRAGMENT_TYPE) return "<>";
1332
- if (
1333
- "object" === typeof type &&
1334
- null !== type &&
1335
- type.$$typeof === REACT_LAZY_TYPE
1336
- )
1337
- return "<...>";
1338
- try {
1339
- var name = getComponentNameFromType(type);
1340
- return name ? "<" + name + ">" : "<...>";
1341
- } catch (x) {
1342
- return "<...>";
1343
- }
1344
- }
1345
- function getOwner() {
1346
- var dispatcher = ReactSharedInternals.A;
1347
- return null === dispatcher ? null : dispatcher.getOwner();
1348
- }
1349
- function UnknownOwner() {
1350
- return Error("react-stack-top-frame");
1351
- }
1352
- function hasValidKey(config) {
1353
- if (hasOwnProperty.call(config, "key")) {
1354
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
1355
- if (getter && getter.isReactWarning) return false;
1356
- }
1357
- return void 0 !== config.key;
1358
- }
1359
- function defineKeyPropWarningGetter(props, displayName) {
1360
- function warnAboutAccessingKey() {
1361
- specialPropKeyWarningShown ||
1362
- ((specialPropKeyWarningShown = true),
1363
- console.error(
1364
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
1365
- displayName
1366
- ));
1367
- }
1368
- warnAboutAccessingKey.isReactWarning = true;
1369
- Object.defineProperty(props, "key", {
1370
- get: warnAboutAccessingKey,
1371
- configurable: true
1372
- });
1373
- }
1374
- function elementRefGetterWithDeprecationWarning() {
1375
- var componentName = getComponentNameFromType(this.type);
1376
- didWarnAboutElementRef[componentName] ||
1377
- ((didWarnAboutElementRef[componentName] = true),
1378
- console.error(
1379
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
1380
- ));
1381
- componentName = this.props.ref;
1382
- return void 0 !== componentName ? componentName : null;
1383
- }
1384
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
1385
- var refProp = props.ref;
1386
- type = {
1387
- $$typeof: REACT_ELEMENT_TYPE,
1388
- type: type,
1389
- key: key,
1390
- props: props,
1391
- _owner: owner
1392
- };
1393
- null !== (void 0 !== refProp ? refProp : null)
1394
- ? Object.defineProperty(type, "ref", {
1395
- enumerable: false,
1396
- get: elementRefGetterWithDeprecationWarning
1397
- })
1398
- : Object.defineProperty(type, "ref", { enumerable: false, value: null });
1399
- type._store = {};
1400
- Object.defineProperty(type._store, "validated", {
1401
- configurable: false,
1402
- enumerable: false,
1403
- writable: true,
1404
- value: 0
1405
- });
1406
- Object.defineProperty(type, "_debugInfo", {
1407
- configurable: false,
1408
- enumerable: false,
1409
- writable: true,
1410
- value: null
1411
- });
1412
- Object.defineProperty(type, "_debugStack", {
1413
- configurable: false,
1414
- enumerable: false,
1415
- writable: true,
1416
- value: debugStack
1417
- });
1418
- Object.defineProperty(type, "_debugTask", {
1419
- configurable: false,
1420
- enumerable: false,
1421
- writable: true,
1422
- value: debugTask
1423
- });
1424
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
1425
- return type;
1426
- }
1427
- function cloneAndReplaceKey(oldElement, newKey) {
1428
- newKey = ReactElement(
1429
- oldElement.type,
1430
- newKey,
1431
- oldElement.props,
1432
- oldElement._owner,
1433
- oldElement._debugStack,
1434
- oldElement._debugTask
1435
- );
1436
- oldElement._store &&
1437
- (newKey._store.validated = oldElement._store.validated);
1438
- return newKey;
1439
- }
1440
- function validateChildKeys(node) {
1441
- isValidElement(node)
1442
- ? node._store && (node._store.validated = 1)
1443
- : "object" === typeof node &&
1444
- null !== node &&
1445
- node.$$typeof === REACT_LAZY_TYPE &&
1446
- ("fulfilled" === node._payload.status
1447
- ? isValidElement(node._payload.value) &&
1448
- node._payload.value._store &&
1449
- (node._payload.value._store.validated = 1)
1450
- : node._store && (node._store.validated = 1));
1451
- }
1452
- function isValidElement(object) {
1453
- return (
1454
- "object" === typeof object &&
1455
- null !== object &&
1456
- object.$$typeof === REACT_ELEMENT_TYPE
1457
- );
1458
- }
1459
- function escape(key) {
1460
- var escaperLookup = { "=": "=0", ":": "=2" };
1461
- return (
1462
- "$" +
1463
- key.replace(/[=:]/g, function (match) {
1464
- return escaperLookup[match];
1465
- })
1466
- );
1467
- }
1468
- function getElementKey(element, index) {
1469
- return "object" === typeof element &&
1470
- null !== element &&
1471
- null != element.key
1472
- ? (checkKeyStringCoercion(element.key), escape("" + element.key))
1473
- : index.toString(36);
1474
- }
1475
- function resolveThenable(thenable) {
1476
- switch (thenable.status) {
1477
- case "fulfilled":
1478
- return thenable.value;
1479
- case "rejected":
1480
- throw thenable.reason;
1481
- default:
1482
- switch (
1483
- ("string" === typeof thenable.status
1484
- ? thenable.then(noop, noop)
1485
- : ((thenable.status = "pending"),
1486
- thenable.then(
1487
- function (fulfilledValue) {
1488
- "pending" === thenable.status &&
1489
- ((thenable.status = "fulfilled"),
1490
- (thenable.value = fulfilledValue));
1491
- },
1492
- function (error) {
1493
- "pending" === thenable.status &&
1494
- ((thenable.status = "rejected"),
1495
- (thenable.reason = error));
1496
- }
1497
- )),
1498
- thenable.status)
1499
- ) {
1500
- case "fulfilled":
1501
- return thenable.value;
1502
- case "rejected":
1503
- throw thenable.reason;
1504
- }
1505
- }
1506
- throw thenable;
1507
- }
1508
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1509
- var type = typeof children;
1510
- if ("undefined" === type || "boolean" === type) children = null;
1511
- var invokeCallback = false;
1512
- if (null === children) invokeCallback = true;
1513
- else
1514
- switch (type) {
1515
- case "bigint":
1516
- case "string":
1517
- case "number":
1518
- invokeCallback = true;
1519
- break;
1520
- case "object":
1521
- switch (children.$$typeof) {
1522
- case REACT_ELEMENT_TYPE:
1523
- case REACT_PORTAL_TYPE:
1524
- invokeCallback = true;
1525
- break;
1526
- case REACT_LAZY_TYPE:
1527
- return (
1528
- (invokeCallback = children._init),
1529
- mapIntoArray(
1530
- invokeCallback(children._payload),
1531
- array,
1532
- escapedPrefix,
1533
- nameSoFar,
1534
- callback
1535
- )
1536
- );
1537
- }
1538
- }
1539
- if (invokeCallback) {
1540
- invokeCallback = children;
1541
- callback = callback(invokeCallback);
1542
- var childKey =
1543
- "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
1544
- isArrayImpl(callback)
1545
- ? ((escapedPrefix = ""),
1546
- null != childKey &&
1547
- (escapedPrefix =
1548
- childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
1549
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
1550
- return c;
1551
- }))
1552
- : null != callback &&
1553
- (isValidElement(callback) &&
1554
- (null != callback.key &&
1555
- ((invokeCallback && invokeCallback.key === callback.key) ||
1556
- checkKeyStringCoercion(callback.key)),
1557
- (escapedPrefix = cloneAndReplaceKey(
1558
- callback,
1559
- escapedPrefix +
1560
- (null == callback.key ||
1561
- (invokeCallback && invokeCallback.key === callback.key)
1562
- ? ""
1563
- : ("" + callback.key).replace(
1564
- userProvidedKeyEscapeRegex,
1565
- "$&/"
1566
- ) + "/") +
1567
- childKey
1568
- )),
1569
- "" !== nameSoFar &&
1570
- null != invokeCallback &&
1571
- isValidElement(invokeCallback) &&
1572
- null == invokeCallback.key &&
1573
- invokeCallback._store &&
1574
- !invokeCallback._store.validated &&
1575
- (escapedPrefix._store.validated = 2),
1576
- (callback = escapedPrefix)),
1577
- array.push(callback));
1578
- return 1;
1579
- }
1580
- invokeCallback = 0;
1581
- childKey = "" === nameSoFar ? "." : nameSoFar + ":";
1582
- if (isArrayImpl(children))
1583
- for (var i = 0; i < children.length; i++)
1584
- (nameSoFar = children[i]),
1585
- (type = childKey + getElementKey(nameSoFar, i)),
1586
- (invokeCallback += mapIntoArray(
1587
- nameSoFar,
1588
- array,
1589
- escapedPrefix,
1590
- type,
1591
- callback
1592
- ));
1593
- else if (((i = getIteratorFn(children)), "function" === typeof i))
1594
- for (
1595
- i === children.entries &&
1596
- (didWarnAboutMaps ||
1597
- console.warn(
1598
- "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
1599
- ),
1600
- (didWarnAboutMaps = true)),
1601
- children = i.call(children),
1602
- i = 0;
1603
- !(nameSoFar = children.next()).done;
1604
-
1605
- )
1606
- (nameSoFar = nameSoFar.value),
1607
- (type = childKey + getElementKey(nameSoFar, i++)),
1608
- (invokeCallback += mapIntoArray(
1609
- nameSoFar,
1610
- array,
1611
- escapedPrefix,
1612
- type,
1613
- callback
1614
- ));
1615
- else if ("object" === type) {
1616
- if ("function" === typeof children.then)
1617
- return mapIntoArray(
1618
- resolveThenable(children),
1619
- array,
1620
- escapedPrefix,
1621
- nameSoFar,
1622
- callback
1623
- );
1624
- array = String(children);
1625
- throw Error(
1626
- "Objects are not valid as a React child (found: " +
1627
- ("[object Object]" === array
1628
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
1629
- : array) +
1630
- "). If you meant to render a collection of children, use an array instead."
1631
- );
1632
- }
1633
- return invokeCallback;
1634
- }
1635
- function mapChildren(children, func, context) {
1636
- if (null == children) return children;
1637
- var result = [],
1638
- count = 0;
1639
- mapIntoArray(children, result, "", "", function (child) {
1640
- return func.call(context, child, count++);
1641
- });
1642
- return result;
1643
- }
1644
- function lazyInitializer(payload) {
1645
- if (-1 === payload._status) {
1646
- var ioInfo = payload._ioInfo;
1647
- null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
1648
- ioInfo = payload._result;
1649
- var thenable = ioInfo();
1650
- thenable.then(
1651
- function (moduleObject) {
1652
- if (0 === payload._status || -1 === payload._status) {
1653
- payload._status = 1;
1654
- payload._result = moduleObject;
1655
- var _ioInfo = payload._ioInfo;
1656
- null != _ioInfo && (_ioInfo.end = performance.now());
1657
- void 0 === thenable.status &&
1658
- ((thenable.status = "fulfilled"),
1659
- (thenable.value = moduleObject));
1660
- }
1661
- },
1662
- function (error) {
1663
- if (0 === payload._status || -1 === payload._status) {
1664
- payload._status = 2;
1665
- payload._result = error;
1666
- var _ioInfo2 = payload._ioInfo;
1667
- null != _ioInfo2 && (_ioInfo2.end = performance.now());
1668
- void 0 === thenable.status &&
1669
- ((thenable.status = "rejected"), (thenable.reason = error));
1670
- }
1671
- }
1672
- );
1673
- ioInfo = payload._ioInfo;
1674
- if (null != ioInfo) {
1675
- ioInfo.value = thenable;
1676
- var displayName = thenable.displayName;
1677
- "string" === typeof displayName && (ioInfo.name = displayName);
1678
- }
1679
- -1 === payload._status &&
1680
- ((payload._status = 0), (payload._result = thenable));
1681
- }
1682
- if (1 === payload._status)
1683
- return (
1684
- (ioInfo = payload._result),
1685
- void 0 === ioInfo &&
1686
- console.error(
1687
- "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
1688
- ioInfo
1689
- ),
1690
- "default" in ioInfo ||
1691
- console.error(
1692
- "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
1693
- ioInfo
1694
- ),
1695
- ioInfo.default
1696
- );
1697
- throw payload._result;
1698
- }
1699
- function resolveDispatcher() {
1700
- var dispatcher = ReactSharedInternals.H;
1701
- null === dispatcher &&
1702
- console.error(
1703
- "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
1704
- );
1705
- return dispatcher;
1706
- }
1707
- function releaseAsyncTransition() {
1708
- ReactSharedInternals.asyncTransitions--;
1709
- }
1710
- function enqueueTask(task) {
1711
- if (null === enqueueTaskImpl)
1712
- try {
1713
- var requireString = ("require" + Math.random()).slice(0, 7);
1714
- enqueueTaskImpl = (module && module[requireString]).call(
1715
- module,
1716
- "timers"
1717
- ).setImmediate;
1718
- } catch (_err) {
1719
- enqueueTaskImpl = function (callback) {
1720
- false === didWarnAboutMessageChannel &&
1721
- ((didWarnAboutMessageChannel = true),
1722
- "undefined" === typeof MessageChannel &&
1723
- console.error(
1724
- "This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
1725
- ));
1726
- var channel = new MessageChannel();
1727
- channel.port1.onmessage = callback;
1728
- channel.port2.postMessage(void 0);
1729
- };
1730
- }
1731
- return enqueueTaskImpl(task);
1732
- }
1733
- function aggregateErrors(errors) {
1734
- return 1 < errors.length && "function" === typeof AggregateError
1735
- ? new AggregateError(errors)
1736
- : errors[0];
1737
- }
1738
- function popActScope(prevActQueue, prevActScopeDepth) {
1739
- prevActScopeDepth !== actScopeDepth - 1 &&
1740
- console.error(
1741
- "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
1742
- );
1743
- actScopeDepth = prevActScopeDepth;
1744
- }
1745
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
1746
- var queue = ReactSharedInternals.actQueue;
1747
- if (null !== queue)
1748
- if (0 !== queue.length)
1749
- try {
1750
- flushActQueue(queue);
1751
- enqueueTask(function () {
1752
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
1753
- });
1754
- return;
1755
- } catch (error) {
1756
- ReactSharedInternals.thrownErrors.push(error);
1757
- }
1758
- else ReactSharedInternals.actQueue = null;
1759
- 0 < ReactSharedInternals.thrownErrors.length
1760
- ? ((queue = aggregateErrors(ReactSharedInternals.thrownErrors)),
1761
- (ReactSharedInternals.thrownErrors.length = 0),
1762
- reject(queue))
1763
- : resolve(returnValue);
1764
- }
1765
- function flushActQueue(queue) {
1766
- if (!isFlushing) {
1767
- isFlushing = true;
1768
- var i = 0;
1769
- try {
1770
- for (; i < queue.length; i++) {
1771
- var callback = queue[i];
1772
- do {
1773
- ReactSharedInternals.didUsePromise = !1;
1774
- var continuation = callback(!1);
1775
- if (null !== continuation) {
1776
- if (ReactSharedInternals.didUsePromise) {
1777
- queue[i] = callback;
1778
- queue.splice(0, i);
1779
- return;
1780
- }
1781
- callback = continuation;
1782
- } else break;
1783
- } while (1);
1784
- }
1785
- queue.length = 0;
1786
- } catch (error) {
1787
- queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
1788
- } finally {
1789
- isFlushing = false;
1790
- }
1791
- }
1792
- }
1793
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1794
- "function" ===
1795
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
1796
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1797
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
1798
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
1799
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1800
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
1801
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
1802
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
1803
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
1804
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
1805
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
1806
- REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
1807
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
1808
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
1809
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
1810
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
1811
- didWarnStateUpdateForUnmountedComponent = {},
1812
- ReactNoopUpdateQueue = {
1813
- isMounted: function () {
1814
- return false;
1815
- },
1816
- enqueueForceUpdate: function (publicInstance) {
1817
- warnNoop(publicInstance, "forceUpdate");
1818
- },
1819
- enqueueReplaceState: function (publicInstance) {
1820
- warnNoop(publicInstance, "replaceState");
1821
- },
1822
- enqueueSetState: function (publicInstance) {
1823
- warnNoop(publicInstance, "setState");
1824
- }
1825
- },
1826
- assign = Object.assign,
1827
- emptyObject = {};
1828
- Object.freeze(emptyObject);
1829
- Component.prototype.isReactComponent = {};
1830
- Component.prototype.setState = function (partialState, callback) {
1831
- if (
1832
- "object" !== typeof partialState &&
1833
- "function" !== typeof partialState &&
1834
- null != partialState
1835
- )
1836
- throw Error(
1837
- "takes an object of state variables to update or a function which returns an object of state variables."
1838
- );
1839
- this.updater.enqueueSetState(this, partialState, callback, "setState");
1840
- };
1841
- Component.prototype.forceUpdate = function (callback) {
1842
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
1843
- };
1844
- var deprecatedAPIs = {
1845
- isMounted: [
1846
- "isMounted",
1847
- "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
1848
- ],
1849
- replaceState: [
1850
- "replaceState",
1851
- "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
1852
- ]
1853
- };
1854
- for (fnName in deprecatedAPIs)
1855
- deprecatedAPIs.hasOwnProperty(fnName) &&
1856
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
1857
- ComponentDummy.prototype = Component.prototype;
1858
- deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
1859
- deprecatedAPIs.constructor = PureComponent;
1860
- assign(deprecatedAPIs, Component.prototype);
1861
- deprecatedAPIs.isPureReactComponent = true;
1862
- var isArrayImpl = Array.isArray,
1863
- REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
1864
- ReactSharedInternals = {
1865
- H: null,
1866
- A: null,
1867
- T: null,
1868
- S: null,
1869
- actQueue: null,
1870
- asyncTransitions: 0,
1871
- isBatchingLegacy: false,
1872
- didScheduleLegacyUpdate: false,
1873
- didUsePromise: false,
1874
- thrownErrors: [],
1875
- getCurrentStack: null,
1876
- recentlyCreatedOwnerStacks: 0
1877
- },
1878
- hasOwnProperty = Object.prototype.hasOwnProperty,
1879
- createTask = console.createTask
1880
- ? console.createTask
1881
- : function () {
1882
- return null;
1883
- };
1884
- deprecatedAPIs = {
1885
- react_stack_bottom_frame: function (callStackForError) {
1886
- return callStackForError();
1887
- }
1888
- };
1889
- var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
1890
- var didWarnAboutElementRef = {};
1891
- var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
1892
- deprecatedAPIs,
1893
- UnknownOwner
1894
- )();
1895
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1896
- var didWarnAboutMaps = false,
1897
- userProvidedKeyEscapeRegex = /\/+/g,
1898
- reportGlobalError =
1899
- "function" === typeof reportError
1900
- ? reportError
1901
- : function (error) {
1902
- if (
1903
- "object" === typeof window &&
1904
- "function" === typeof window.ErrorEvent
1905
- ) {
1906
- var event = new window.ErrorEvent("error", {
1907
- bubbles: true,
1908
- cancelable: true,
1909
- message:
1910
- "object" === typeof error &&
1911
- null !== error &&
1912
- "string" === typeof error.message
1913
- ? String(error.message)
1914
- : String(error),
1915
- error: error
1916
- });
1917
- if (!window.dispatchEvent(event)) return;
1918
- } else if (
1919
- "object" === typeof process &&
1920
- "function" === typeof process.emit
1921
- ) {
1922
- process.emit("uncaughtException", error);
1923
- return;
1924
- }
1925
- console.error(error);
1926
- },
1927
- didWarnAboutMessageChannel = false,
1928
- enqueueTaskImpl = null,
1929
- actScopeDepth = 0,
1930
- didWarnNoAwaitAct = false,
1931
- isFlushing = false,
1932
- queueSeveralMicrotasks =
1933
- "function" === typeof queueMicrotask
1934
- ? function (callback) {
1935
- queueMicrotask(function () {
1936
- return queueMicrotask(callback);
1937
- });
1938
- }
1939
- : enqueueTask;
1940
- deprecatedAPIs = Object.freeze({
1941
- __proto__: null,
1942
- c: function (size) {
1943
- return resolveDispatcher().useMemoCache(size);
1944
- }
1945
- });
1946
- var fnName = {
1947
- map: mapChildren,
1948
- forEach: function (children, forEachFunc, forEachContext) {
1949
- mapChildren(
1950
- children,
1951
- function () {
1952
- forEachFunc.apply(this, arguments);
1953
- },
1954
- forEachContext
1955
- );
1956
- },
1957
- count: function (children) {
1958
- var n = 0;
1959
- mapChildren(children, function () {
1960
- n++;
1961
- });
1962
- return n;
1963
- },
1964
- toArray: function (children) {
1965
- return (
1966
- mapChildren(children, function (child) {
1967
- return child;
1968
- }) || []
1969
- );
1970
- },
1971
- only: function (children) {
1972
- if (!isValidElement(children))
1973
- throw Error(
1974
- "React.Children.only expected to receive a single React element child."
1975
- );
1976
- return children;
1977
- }
1978
- };
1979
- exports$1.Activity = REACT_ACTIVITY_TYPE;
1980
- exports$1.Children = fnName;
1981
- exports$1.Component = Component;
1982
- exports$1.Fragment = REACT_FRAGMENT_TYPE;
1983
- exports$1.Profiler = REACT_PROFILER_TYPE;
1984
- exports$1.PureComponent = PureComponent;
1985
- exports$1.StrictMode = REACT_STRICT_MODE_TYPE;
1986
- exports$1.Suspense = REACT_SUSPENSE_TYPE;
1987
- exports$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
1988
- ReactSharedInternals;
1989
- exports$1.__COMPILER_RUNTIME = deprecatedAPIs;
1990
- exports$1.act = function (callback) {
1991
- var prevActQueue = ReactSharedInternals.actQueue,
1992
- prevActScopeDepth = actScopeDepth;
1993
- actScopeDepth++;
1994
- var queue = (ReactSharedInternals.actQueue =
1995
- null !== prevActQueue ? prevActQueue : []),
1996
- didAwaitActCall = false;
1997
- try {
1998
- var result = callback();
1999
- } catch (error) {
2000
- ReactSharedInternals.thrownErrors.push(error);
2001
- }
2002
- if (0 < ReactSharedInternals.thrownErrors.length)
2003
- throw (
2004
- (popActScope(prevActQueue, prevActScopeDepth),
2005
- (callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
2006
- (ReactSharedInternals.thrownErrors.length = 0),
2007
- callback)
2008
- );
2009
- if (
2010
- null !== result &&
2011
- "object" === typeof result &&
2012
- "function" === typeof result.then
2013
- ) {
2014
- var thenable = result;
2015
- queueSeveralMicrotasks(function () {
2016
- didAwaitActCall ||
2017
- didWarnNoAwaitAct ||
2018
- ((didWarnNoAwaitAct = true),
2019
- console.error(
2020
- "You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
2021
- ));
2022
- });
2023
- return {
2024
- then: function (resolve, reject) {
2025
- didAwaitActCall = true;
2026
- thenable.then(
2027
- function (returnValue) {
2028
- popActScope(prevActQueue, prevActScopeDepth);
2029
- if (0 === prevActScopeDepth) {
2030
- try {
2031
- flushActQueue(queue),
2032
- enqueueTask(function () {
2033
- return recursivelyFlushAsyncActWork(
2034
- returnValue,
2035
- resolve,
2036
- reject
2037
- );
2038
- });
2039
- } catch (error$0) {
2040
- ReactSharedInternals.thrownErrors.push(error$0);
2041
- }
2042
- if (0 < ReactSharedInternals.thrownErrors.length) {
2043
- var _thrownError = aggregateErrors(
2044
- ReactSharedInternals.thrownErrors
2045
- );
2046
- ReactSharedInternals.thrownErrors.length = 0;
2047
- reject(_thrownError);
2048
- }
2049
- } else resolve(returnValue);
2050
- },
2051
- function (error) {
2052
- popActScope(prevActQueue, prevActScopeDepth);
2053
- 0 < ReactSharedInternals.thrownErrors.length
2054
- ? ((error = aggregateErrors(
2055
- ReactSharedInternals.thrownErrors
2056
- )),
2057
- (ReactSharedInternals.thrownErrors.length = 0),
2058
- reject(error))
2059
- : reject(error);
2060
- }
2061
- );
2062
- }
2063
- };
2064
- }
2065
- var returnValue$jscomp$0 = result;
2066
- popActScope(prevActQueue, prevActScopeDepth);
2067
- 0 === prevActScopeDepth &&
2068
- (flushActQueue(queue),
2069
- 0 !== queue.length &&
2070
- queueSeveralMicrotasks(function () {
2071
- didAwaitActCall ||
2072
- didWarnNoAwaitAct ||
2073
- ((didWarnNoAwaitAct = true),
2074
- console.error(
2075
- "A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
2076
- ));
2077
- }),
2078
- (ReactSharedInternals.actQueue = null));
2079
- if (0 < ReactSharedInternals.thrownErrors.length)
2080
- throw (
2081
- ((callback = aggregateErrors(ReactSharedInternals.thrownErrors)),
2082
- (ReactSharedInternals.thrownErrors.length = 0),
2083
- callback)
2084
- );
2085
- return {
2086
- then: function (resolve, reject) {
2087
- didAwaitActCall = true;
2088
- 0 === prevActScopeDepth
2089
- ? ((ReactSharedInternals.actQueue = queue),
2090
- enqueueTask(function () {
2091
- return recursivelyFlushAsyncActWork(
2092
- returnValue$jscomp$0,
2093
- resolve,
2094
- reject
2095
- );
2096
- }))
2097
- : resolve(returnValue$jscomp$0);
2098
- }
2099
- };
2100
- };
2101
- exports$1.cache = function (fn) {
2102
- return function () {
2103
- return fn.apply(null, arguments);
2104
- };
2105
- };
2106
- exports$1.cacheSignal = function () {
2107
- return null;
2108
- };
2109
- exports$1.captureOwnerStack = function () {
2110
- var getCurrentStack = ReactSharedInternals.getCurrentStack;
2111
- return null === getCurrentStack ? null : getCurrentStack();
2112
- };
2113
- exports$1.cloneElement = function (element, config, children) {
2114
- if (null === element || void 0 === element)
2115
- throw Error(
2116
- "The argument must be a React element, but you passed " +
2117
- element +
2118
- "."
2119
- );
2120
- var props = assign({}, element.props),
2121
- key = element.key,
2122
- owner = element._owner;
2123
- if (null != config) {
2124
- var JSCompiler_inline_result;
2125
- a: {
2126
- if (
2127
- hasOwnProperty.call(config, "ref") &&
2128
- (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
2129
- config,
2130
- "ref"
2131
- ).get) &&
2132
- JSCompiler_inline_result.isReactWarning
2133
- ) {
2134
- JSCompiler_inline_result = false;
2135
- break a;
2136
- }
2137
- JSCompiler_inline_result = void 0 !== config.ref;
2138
- }
2139
- JSCompiler_inline_result && (owner = getOwner());
2140
- hasValidKey(config) &&
2141
- (checkKeyStringCoercion(config.key), (key = "" + config.key));
2142
- for (propName in config)
2143
- !hasOwnProperty.call(config, propName) ||
2144
- "key" === propName ||
2145
- "__self" === propName ||
2146
- "__source" === propName ||
2147
- ("ref" === propName && void 0 === config.ref) ||
2148
- (props[propName] = config[propName]);
2149
- }
2150
- var propName = arguments.length - 2;
2151
- if (1 === propName) props.children = children;
2152
- else if (1 < propName) {
2153
- JSCompiler_inline_result = Array(propName);
2154
- for (var i = 0; i < propName; i++)
2155
- JSCompiler_inline_result[i] = arguments[i + 2];
2156
- props.children = JSCompiler_inline_result;
2157
- }
2158
- props = ReactElement(
2159
- element.type,
2160
- key,
2161
- props,
2162
- owner,
2163
- element._debugStack,
2164
- element._debugTask
2165
- );
2166
- for (key = 2; key < arguments.length; key++)
2167
- validateChildKeys(arguments[key]);
2168
- return props;
2169
- };
2170
- exports$1.createContext = function (defaultValue) {
2171
- defaultValue = {
2172
- $$typeof: REACT_CONTEXT_TYPE,
2173
- _currentValue: defaultValue,
2174
- _currentValue2: defaultValue,
2175
- _threadCount: 0,
2176
- Provider: null,
2177
- Consumer: null
2178
- };
2179
- defaultValue.Provider = defaultValue;
2180
- defaultValue.Consumer = {
2181
- $$typeof: REACT_CONSUMER_TYPE,
2182
- _context: defaultValue
2183
- };
2184
- defaultValue._currentRenderer = null;
2185
- defaultValue._currentRenderer2 = null;
2186
- return defaultValue;
2187
- };
2188
- exports$1.createElement = function (type, config, children) {
2189
- for (var i = 2; i < arguments.length; i++)
2190
- validateChildKeys(arguments[i]);
2191
- i = {};
2192
- var key = null;
2193
- if (null != config)
2194
- for (propName in (didWarnAboutOldJSXRuntime ||
2195
- !("__self" in config) ||
2196
- "key" in config ||
2197
- ((didWarnAboutOldJSXRuntime = true),
2198
- console.warn(
2199
- "Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
2200
- )),
2201
- hasValidKey(config) &&
2202
- (checkKeyStringCoercion(config.key), (key = "" + config.key)),
2203
- config))
2204
- hasOwnProperty.call(config, propName) &&
2205
- "key" !== propName &&
2206
- "__self" !== propName &&
2207
- "__source" !== propName &&
2208
- (i[propName] = config[propName]);
2209
- var childrenLength = arguments.length - 2;
2210
- if (1 === childrenLength) i.children = children;
2211
- else if (1 < childrenLength) {
2212
- for (
2213
- var childArray = Array(childrenLength), _i = 0;
2214
- _i < childrenLength;
2215
- _i++
2216
- )
2217
- childArray[_i] = arguments[_i + 2];
2218
- Object.freeze && Object.freeze(childArray);
2219
- i.children = childArray;
2220
- }
2221
- if (type && type.defaultProps)
2222
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
2223
- void 0 === i[propName] && (i[propName] = childrenLength[propName]);
2224
- key &&
2225
- defineKeyPropWarningGetter(
2226
- i,
2227
- "function" === typeof type
2228
- ? type.displayName || type.name || "Unknown"
2229
- : type
2230
- );
2231
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
2232
- return ReactElement(
2233
- type,
2234
- key,
2235
- i,
2236
- getOwner(),
2237
- propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
2238
- propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
2239
- );
2240
- };
2241
- exports$1.createRef = function () {
2242
- var refObject = { current: null };
2243
- Object.seal(refObject);
2244
- return refObject;
2245
- };
2246
- exports$1.forwardRef = function (render) {
2247
- null != render && render.$$typeof === REACT_MEMO_TYPE
2248
- ? console.error(
2249
- "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
2250
- )
2251
- : "function" !== typeof render
2252
- ? console.error(
2253
- "forwardRef requires a render function but was given %s.",
2254
- null === render ? "null" : typeof render
2255
- )
2256
- : 0 !== render.length &&
2257
- 2 !== render.length &&
2258
- console.error(
2259
- "forwardRef render functions accept exactly two parameters: props and ref. %s",
2260
- 1 === render.length
2261
- ? "Did you forget to use the ref parameter?"
2262
- : "Any additional parameter will be undefined."
2263
- );
2264
- null != render &&
2265
- null != render.defaultProps &&
2266
- console.error(
2267
- "forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
2268
- );
2269
- var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render: render },
2270
- ownName;
2271
- Object.defineProperty(elementType, "displayName", {
2272
- enumerable: false,
2273
- configurable: true,
2274
- get: function () {
2275
- return ownName;
2276
- },
2277
- set: function (name) {
2278
- ownName = name;
2279
- render.name ||
2280
- render.displayName ||
2281
- (Object.defineProperty(render, "name", { value: name }),
2282
- (render.displayName = name));
2283
- }
2284
- });
2285
- return elementType;
2286
- };
2287
- exports$1.isValidElement = isValidElement;
2288
- exports$1.lazy = function (ctor) {
2289
- ctor = { _status: -1, _result: ctor };
2290
- var lazyType = {
2291
- $$typeof: REACT_LAZY_TYPE,
2292
- _payload: ctor,
2293
- _init: lazyInitializer
2294
- },
2295
- ioInfo = {
2296
- name: "lazy",
2297
- start: -1,
2298
- end: -1,
2299
- value: null,
2300
- owner: null,
2301
- debugStack: Error("react-stack-top-frame"),
2302
- debugTask: console.createTask ? console.createTask("lazy()") : null
2303
- };
2304
- ctor._ioInfo = ioInfo;
2305
- lazyType._debugInfo = [{ awaited: ioInfo }];
2306
- return lazyType;
2307
- };
2308
- exports$1.memo = function (type, compare) {
2309
- null == type &&
2310
- console.error(
2311
- "memo: The first argument must be a component. Instead received: %s",
2312
- null === type ? "null" : typeof type
2313
- );
2314
- compare = {
2315
- $$typeof: REACT_MEMO_TYPE,
2316
- type: type,
2317
- compare: void 0 === compare ? null : compare
2318
- };
2319
- var ownName;
2320
- Object.defineProperty(compare, "displayName", {
2321
- enumerable: false,
2322
- configurable: true,
2323
- get: function () {
2324
- return ownName;
2325
- },
2326
- set: function (name) {
2327
- ownName = name;
2328
- type.name ||
2329
- type.displayName ||
2330
- (Object.defineProperty(type, "name", { value: name }),
2331
- (type.displayName = name));
2332
- }
2333
- });
2334
- return compare;
2335
- };
2336
- exports$1.startTransition = function (scope) {
2337
- var prevTransition = ReactSharedInternals.T,
2338
- currentTransition = {};
2339
- currentTransition._updatedFibers = new Set();
2340
- ReactSharedInternals.T = currentTransition;
2341
- try {
2342
- var returnValue = scope(),
2343
- onStartTransitionFinish = ReactSharedInternals.S;
2344
- null !== onStartTransitionFinish &&
2345
- onStartTransitionFinish(currentTransition, returnValue);
2346
- "object" === typeof returnValue &&
2347
- null !== returnValue &&
2348
- "function" === typeof returnValue.then &&
2349
- (ReactSharedInternals.asyncTransitions++,
2350
- returnValue.then(releaseAsyncTransition, releaseAsyncTransition),
2351
- returnValue.then(noop, reportGlobalError));
2352
- } catch (error) {
2353
- reportGlobalError(error);
2354
- } finally {
2355
- null === prevTransition &&
2356
- currentTransition._updatedFibers &&
2357
- ((scope = currentTransition._updatedFibers.size),
2358
- currentTransition._updatedFibers.clear(),
2359
- 10 < scope &&
2360
- console.warn(
2361
- "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
2362
- )),
2363
- null !== prevTransition &&
2364
- null !== currentTransition.types &&
2365
- (null !== prevTransition.types &&
2366
- prevTransition.types !== currentTransition.types &&
2367
- console.error(
2368
- "We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
2369
- ),
2370
- (prevTransition.types = currentTransition.types)),
2371
- (ReactSharedInternals.T = prevTransition);
2372
- }
2373
- };
2374
- exports$1.unstable_useCacheRefresh = function () {
2375
- return resolveDispatcher().useCacheRefresh();
2376
- };
2377
- exports$1.use = function (usable) {
2378
- return resolveDispatcher().use(usable);
2379
- };
2380
- exports$1.useActionState = function (action, initialState, permalink) {
2381
- return resolveDispatcher().useActionState(
2382
- action,
2383
- initialState,
2384
- permalink
2385
- );
2386
- };
2387
- exports$1.useCallback = function (callback, deps) {
2388
- return resolveDispatcher().useCallback(callback, deps);
2389
- };
2390
- exports$1.useContext = function (Context) {
2391
- var dispatcher = resolveDispatcher();
2392
- Context.$$typeof === REACT_CONSUMER_TYPE &&
2393
- console.error(
2394
- "Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
2395
- );
2396
- return dispatcher.useContext(Context);
2397
- };
2398
- exports$1.useDebugValue = function (value, formatterFn) {
2399
- return resolveDispatcher().useDebugValue(value, formatterFn);
2400
- };
2401
- exports$1.useDeferredValue = function (value, initialValue) {
2402
- return resolveDispatcher().useDeferredValue(value, initialValue);
2403
- };
2404
- exports$1.useEffect = function (create, deps) {
2405
- null == create &&
2406
- console.warn(
2407
- "React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2408
- );
2409
- return resolveDispatcher().useEffect(create, deps);
2410
- };
2411
- exports$1.useEffectEvent = function (callback) {
2412
- return resolveDispatcher().useEffectEvent(callback);
2413
- };
2414
- exports$1.useId = function () {
2415
- return resolveDispatcher().useId();
2416
- };
2417
- exports$1.useImperativeHandle = function (ref, create, deps) {
2418
- return resolveDispatcher().useImperativeHandle(ref, create, deps);
2419
- };
2420
- exports$1.useInsertionEffect = function (create, deps) {
2421
- null == create &&
2422
- console.warn(
2423
- "React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2424
- );
2425
- return resolveDispatcher().useInsertionEffect(create, deps);
2426
- };
2427
- exports$1.useLayoutEffect = function (create, deps) {
2428
- null == create &&
2429
- console.warn(
2430
- "React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
2431
- );
2432
- return resolveDispatcher().useLayoutEffect(create, deps);
2433
- };
2434
- exports$1.useMemo = function (create, deps) {
2435
- return resolveDispatcher().useMemo(create, deps);
2436
- };
2437
- exports$1.useOptimistic = function (passthrough, reducer) {
2438
- return resolveDispatcher().useOptimistic(passthrough, reducer);
2439
- };
2440
- exports$1.useReducer = function (reducer, initialArg, init) {
2441
- return resolveDispatcher().useReducer(reducer, initialArg, init);
2442
- };
2443
- exports$1.useRef = function (initialValue) {
2444
- return resolveDispatcher().useRef(initialValue);
2445
- };
2446
- exports$1.useState = function (initialState) {
2447
- return resolveDispatcher().useState(initialState);
2448
- };
2449
- exports$1.useSyncExternalStore = function (
2450
- subscribe,
2451
- getSnapshot,
2452
- getServerSnapshot
2453
- ) {
2454
- return resolveDispatcher().useSyncExternalStore(
2455
- subscribe,
2456
- getSnapshot,
2457
- getServerSnapshot
2458
- );
2459
- };
2460
- exports$1.useTransition = function () {
2461
- return resolveDispatcher().useTransition();
2462
- };
2463
- exports$1.version = "19.2.4";
2464
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2465
- "function" ===
2466
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
2467
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
2468
- })();
2469
- } (react_development, react_development.exports));
2470
- return react_development.exports;
151
+ function track(eventName, properties) {
152
+ trackerInstance?.track(eventName, properties);
2471
153
  }
2472
-
2473
- if (process.env.NODE_ENV === 'production') {
2474
- react.exports = requireReact_production();
2475
- } else {
2476
- react.exports = requireReact_development();
154
+ function page(pageName, properties) {
155
+ trackerInstance?.page(pageName, properties);
2477
156
  }
2478
-
2479
- var reactExports = react.exports;
2480
- var React = /*@__PURE__*/getDefaultExportFromCjs(reactExports);
2481
-
2482
- /**
2483
- * ATHENA OTA Wrapper
2484
- *
2485
- * Wraps the React Native app and forces a reload on first launch after OTA update
2486
- * This ensures the ATHENA tracker is loaded fresh after deployment
2487
- *
2488
- * Usage:
2489
- * import { AthenaOTAWrapper } from '@athena/tracker';
2490
- *
2491
- * export default function App() {
2492
- * return (
2493
- * <AthenaOTAWrapper>
2494
- * <YourAppContent />
2495
- * </AthenaOTAWrapper>
2496
- * );
2497
- * }
2498
- */
2499
- // Dynamic import of expo-updates (optional peer dependency)
2500
- let Updates = null;
2501
- async function loadExpoUpdates() {
2502
- try {
2503
- Updates = await import('expo-updates');
2504
- return true;
2505
- } catch (error) {
2506
- console.warn('[ATHENA] expo-updates not available - OTA updates disabled');
2507
- return false;
2508
- }
157
+ function reset() {
158
+ trackerInstance?.reset();
2509
159
  }
2510
- function AthenaOTAWrapper({
2511
- children,
2512
- loadingMessage = 'Loading...',
2513
- updateMessage = 'Updating...'
2514
- }) {
2515
- const [isCheckingUpdate, setIsCheckingUpdate] = reactExports.useState(true);
2516
- const [updateAvailable, setUpdateAvailable] = reactExports.useState(false);
2517
- const [error, setError] = reactExports.useState(null);
2518
- reactExports.useEffect(() => {
2519
- checkForUpdates();
2520
- }, []);
2521
- async function checkForUpdates() {
2522
- try {
2523
- // Load expo-updates module
2524
- const hasUpdates = await loadExpoUpdates();
2525
- if (!hasUpdates) {
2526
- // expo-updates not available, continue without OTA check
2527
- setIsCheckingUpdate(false);
2528
- return;
2529
- }
2530
- // Check if running in development mode (skip update check)
2531
- if (__DEV__) {
2532
- console.log('[ATHENA] Development mode - skipping OTA update check');
2533
- setIsCheckingUpdate(false);
2534
- return;
2535
- }
2536
- console.log('[ATHENA] Checking for OTA updates...');
2537
- // Check for available updates
2538
- const update = await Updates.checkForUpdateAsync();
2539
- if (update.isAvailable) {
2540
- console.log('[ATHENA] Update available - fetching...');
2541
- setUpdateAvailable(true);
2542
- // Fetch the new update
2543
- await Updates.fetchUpdateAsync();
2544
- console.log('[ATHENA] Update fetched - reloading app...');
2545
- // Force reload to apply update
2546
- await Updates.reloadAsync();
2547
- // If reloadAsync fails, we'll never reach here
2548
- } else {
2549
- console.log('[ATHENA] No updates available - continuing with current version');
2550
- setIsCheckingUpdate(false);
2551
- }
2552
- } catch (error) {
2553
- // Don't block app if update check fails
2554
- console.warn('[ATHENA] Update check failed:', error.message);
2555
- setError(error.message);
2556
- setIsCheckingUpdate(false);
2557
- }
2558
- }
2559
- // Show loading screen while checking for updates
2560
- if (isCheckingUpdate || updateAvailable) {
2561
- return React.createElement(reactNative.View, {
2562
- style: styles.container
2563
- }, React.createElement(reactNative.ActivityIndicator, {
2564
- size: "large",
2565
- color: "#007AFF"
2566
- }), React.createElement(reactNative.Text, {
2567
- style: styles.text
2568
- }, updateAvailable ? updateMessage : loadingMessage), error && React.createElement(reactNative.Text, {
2569
- style: styles.errorText
2570
- }, "Update check failed: ", error));
2571
- }
2572
- // Render app content once update check is complete
2573
- return React.createElement(React.Fragment, null, children);
160
+ function getSessionId() {
161
+ return trackerInstance?.getSessionId() || null;
2574
162
  }
2575
- const styles = reactNative.StyleSheet.create({
2576
- container: {
2577
- flex: 1,
2578
- justifyContent: 'center',
2579
- alignItems: 'center',
2580
- backgroundColor: '#FFFFFF'
2581
- },
2582
- text: {
2583
- marginTop: 16,
2584
- color: '#666666',
2585
- fontSize: 14,
2586
- fontWeight: '500'
2587
- },
2588
- errorText: {
2589
- marginTop: 8,
2590
- color: '#FF3B30',
2591
- fontSize: 12,
2592
- textAlign: 'center',
2593
- paddingHorizontal: 32
2594
- }
2595
- });
2596
-
2597
- /**
2598
- * React Native Event Capture
2599
- *
2600
- * Captures behavioral events from React Native apps
2601
- * - Touch events (Tap, Swipe, LongPress)
2602
- * - Navigation events (Screen changes)
2603
- * - App lifecycle events (Open, Background, Foreground, Close)
2604
- * - Form interactions
2605
- * - Network errors
2606
- */
2607
- class ReactNativeEventCapture {
2608
- constructor(config = {}) {
2609
- this.events = [];
2610
- this.appStateSubscription = null;
2611
- this.panResponder = null;
2612
- this.batchTimer = null;
2613
- this.currentScreen = 'Unknown';
2614
- this.sessionStartTime = Date.now();
2615
- this.config = {
2616
- captureTouch: config.captureTouch !== false,
2617
- captureNavigation: config.captureNavigation !== false,
2618
- captureLifecycle: config.captureLifecycle !== false,
2619
- captureNetworkErrors: config.captureNetworkErrors !== false,
2620
- batchSize: config.batchSize || 10,
2621
- batchIntervalMs: config.batchIntervalMs || 10000
2622
- };
2623
- }
2624
- /**
2625
- * Start capturing events
2626
- */
2627
- start() {
2628
- console.log('[ATHENA] Starting React Native event capture');
2629
- if (this.config.captureLifecycle) {
2630
- this.setupLifecycleTracking();
2631
- }
2632
- if (this.config.captureTouch) {
2633
- this.setupTouchTracking();
2634
- }
2635
- if (this.config.captureNetworkErrors) {
2636
- this.setupNetworkErrorTracking();
2637
- }
2638
- // Start batch timer
2639
- this.batchTimer = setInterval(() => {
2640
- this.flushEvents();
2641
- }, this.config.batchIntervalMs);
2642
- // Capture initial AppOpen event
2643
- this.captureEvent({
2644
- event_type: 'AppOpen',
2645
- timestamp: Date.now(),
2646
- properties: {
2647
- screen: this.currentScreen,
2648
- session_start: true
2649
- }
2650
- });
2651
- }
2652
- /**
2653
- * Stop capturing events
2654
- */
2655
- stop() {
2656
- console.log('[ATHENA] Stopping React Native event capture');
2657
- if (this.appStateSubscription) {
2658
- this.appStateSubscription.remove();
2659
- }
2660
- if (this.batchTimer) {
2661
- clearInterval(this.batchTimer);
2662
- }
2663
- // Flush any remaining events
2664
- this.flushEvents();
2665
- }
2666
- /**
2667
- * Setup app lifecycle tracking (Open, Background, Foreground, Close)
2668
- */
2669
- setupLifecycleTracking() {
2670
- this.appStateSubscription = reactNative.AppState.addEventListener('change', nextAppState => {
2671
- if (nextAppState === 'active') {
2672
- this.captureEvent({
2673
- event_type: 'AppForeground',
2674
- timestamp: Date.now(),
2675
- properties: {
2676
- screen: this.currentScreen
2677
- }
2678
- });
2679
- } else if (nextAppState === 'background') {
2680
- this.captureEvent({
2681
- event_type: 'AppBackground',
2682
- timestamp: Date.now(),
2683
- properties: {
2684
- screen: this.currentScreen,
2685
- session_duration: Date.now() - this.sessionStartTime
2686
- }
2687
- });
2688
- } else if (nextAppState === 'inactive') {
2689
- this.captureEvent({
2690
- event_type: 'AppInactive',
2691
- timestamp: Date.now(),
2692
- properties: {
2693
- screen: this.currentScreen
2694
- }
2695
- });
2696
- }
2697
- });
2698
- }
2699
- /**
2700
- * Setup touch event tracking
2701
- */
2702
- setupTouchTracking() {
2703
- let touchStartTime = 0;
2704
- this.panResponder = reactNative.PanResponder.create({
2705
- onStartShouldSetPanResponder: () => true,
2706
- onMoveShouldSetPanResponder: () => true,
2707
- onPanResponderGrant: (evt, gestureState) => {
2708
- touchStartTime = Date.now();
2709
- evt.nativeEvent.pageX;
2710
- evt.nativeEvent.pageY;
2711
- },
2712
- onPanResponderRelease: (evt, gestureState) => {
2713
- const touchDuration = Date.now() - touchStartTime;
2714
- const deltaX = Math.abs(gestureState.dx);
2715
- const deltaY = Math.abs(gestureState.dy);
2716
- // Detect gesture type
2717
- if (touchDuration > 500 && deltaX < 10 && deltaY < 10) {
2718
- // Long press
2719
- this.captureEvent({
2720
- event_type: 'LongPress',
2721
- timestamp: Date.now(),
2722
- properties: {
2723
- screen: this.currentScreen,
2724
- x: evt.nativeEvent.pageX,
2725
- y: evt.nativeEvent.pageY,
2726
- duration: touchDuration
2727
- }
2728
- });
2729
- } else if (deltaX > 50 || deltaY > 50) {
2730
- // Swipe
2731
- const direction = deltaX > deltaY ? gestureState.dx > 0 ? 'right' : 'left' : gestureState.dy > 0 ? 'down' : 'up';
2732
- this.captureEvent({
2733
- event_type: 'Swipe',
2734
- timestamp: Date.now(),
2735
- properties: {
2736
- screen: this.currentScreen,
2737
- direction,
2738
- distance: Math.sqrt(deltaX * deltaX + deltaY * deltaY)
2739
- }
2740
- });
2741
- } else {
2742
- // Tap
2743
- this.captureEvent({
2744
- event_type: 'Tap',
2745
- timestamp: Date.now(),
2746
- properties: {
2747
- screen: this.currentScreen,
2748
- x: evt.nativeEvent.pageX,
2749
- y: evt.nativeEvent.pageY,
2750
- duration: touchDuration
2751
- }
2752
- });
2753
- }
2754
- }
2755
- });
2756
- }
2757
- /**
2758
- * Setup network error tracking
2759
- */
2760
- setupNetworkErrorTracking() {
2761
- // Monkey-patch fetch to track network errors
2762
- const originalFetch = global.fetch;
2763
- global.fetch = async (...args) => {
2764
- const startTime = Date.now();
2765
- const url = typeof args[0] === 'string' ? args[0] : args[0].url;
2766
- try {
2767
- const response = await originalFetch(...args);
2768
- if (!response.ok) {
2769
- this.captureEvent({
2770
- event_type: 'NetworkError',
2771
- timestamp: Date.now(),
2772
- properties: {
2773
- screen: this.currentScreen,
2774
- url,
2775
- status: response.status,
2776
- statusText: response.statusText,
2777
- duration: Date.now() - startTime
2778
- }
2779
- });
2780
- }
2781
- return response;
2782
- } catch (error) {
2783
- this.captureEvent({
2784
- event_type: 'NetworkError',
2785
- timestamp: Date.now(),
2786
- properties: {
2787
- screen: this.currentScreen,
2788
- url,
2789
- error: error.message,
2790
- duration: Date.now() - startTime
2791
- }
2792
- });
2793
- throw error;
2794
- }
2795
- };
2796
- }
2797
- /**
2798
- * Manually track screen navigation
2799
- * Should be called by navigation library (React Navigation, etc.)
2800
- */
2801
- trackScreenView(screenName, params) {
2802
- this.currentScreen = screenName;
2803
- this.captureEvent({
2804
- event_type: 'ScreenView',
2805
- timestamp: Date.now(),
2806
- properties: {
2807
- screen: screenName,
2808
- params: params || {},
2809
- previous_screen: this.currentScreen
2810
- }
2811
- });
2812
- }
2813
- /**
2814
- * Manually track custom event
2815
- */
2816
- track(eventType, properties) {
2817
- this.captureEvent({
2818
- event_type: eventType,
2819
- timestamp: Date.now(),
2820
- properties: {
2821
- ...properties,
2822
- screen: this.currentScreen
2823
- }
2824
- });
2825
- }
2826
- /**
2827
- * Capture an event and add to batch
2828
- */
2829
- captureEvent(event) {
2830
- this.events.push(event);
2831
- // Flush immediately if batch size reached
2832
- if (this.events.length >= this.config.batchSize) {
2833
- this.flushEvents();
2834
- }
2835
- }
2836
- /**
2837
- * Flush accumulated events (to be sent to server)
2838
- */
2839
- flushEvents() {
2840
- if (this.events.length === 0) return;
2841
- const batch = [...this.events];
2842
- this.events = [];
2843
- // Emit events for tracker to send
2844
- this.onEventBatch?.(batch);
2845
- }
2846
- /**
2847
- * Get PanResponder for manual integration
2848
- * Usage: <View {...capture.getPanResponderProps()}>
2849
- */
2850
- getPanResponderProps() {
2851
- return this.panResponder?.panHandlers || {};
2852
- }
163
+ function getUserId() {
164
+ return trackerInstance?.getUserId() || null;
2853
165
  }
2854
-
2855
- /**
2856
- * @athena/tracker
2857
- *
2858
- * Behavioral analytics tracker with edge AI
2859
- */
2860
- // Version
2861
- const VERSION = '1.0.0';
2862
-
2863
- exports.AthenaOTAWrapper = AthenaOTAWrapper;
2864
- exports.AthenaTracker = AthenaTracker;
2865
- exports.ReactNativeEventCapture = ReactNativeEventCapture;
2866
- exports.VERSION = VERSION;
2867
- exports.default = AthenaTracker;
2868
- exports.detectInferenceMode = detectInferenceMode;
2869
- exports.getPlatform = getPlatform;
2870
- exports.isBrowser = isBrowser;
2871
- exports.isReactNative = isReactNative;
166
+ // Default export
167
+ var index = {
168
+ initTracker,
169
+ getTracker,
170
+ identify,
171
+ track,
172
+ page,
173
+ reset,
174
+ getSessionId,
175
+ getUserId,
176
+ };
177
+
178
+ exports.default = index;
179
+ exports.getSessionId = getSessionId;
180
+ exports.getTracker = getTracker;
181
+ exports.getUserId = getUserId;
182
+ exports.identify = identify;
183
+ exports.initTracker = initTracker;
184
+ exports.page = page;
185
+ exports.reset = reset;
186
+ exports.track = track;
2872
187
  //# sourceMappingURL=index.js.map