@umituz/react-native-firebase 1.13.5 → 1.13.7

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.
Files changed (28) hide show
  1. package/package.json +3 -5
  2. package/src/index.ts +2 -17
  3. package/src/analytics/application/ports/IAnalyticsService.ts +0 -92
  4. package/src/analytics/index.ts +0 -20
  5. package/src/analytics/infrastructure/adapters/index.ts +0 -10
  6. package/src/analytics/infrastructure/adapters/native-analytics.adapter.ts +0 -63
  7. package/src/analytics/infrastructure/adapters/web-analytics.adapter.ts +0 -63
  8. package/src/analytics/infrastructure/services/FirebaseAnalyticsService.ts +0 -165
  9. package/src/analytics/infrastructure/services/PerformanceTracker.ts +0 -49
  10. package/src/analytics/infrastructure/services/analytics-event.service.ts +0 -72
  11. package/src/analytics/infrastructure/services/analytics-initializer.service.ts +0 -141
  12. package/src/analytics/infrastructure/services/analytics-user.service.ts +0 -98
  13. package/src/analytics/infrastructure/services/index.ts +0 -12
  14. package/src/analytics/presentation/decorators/PerformanceDecorator.ts +0 -73
  15. package/src/analytics/presentation/decorators/TrackingDecorator.ts +0 -38
  16. package/src/analytics/presentation/hooks/useNavigationAnalytics.ts +0 -118
  17. package/src/analytics/presentation/hooks/useNavigationTracking.ts +0 -62
  18. package/src/analytics/presentation/hooks/useScreenTime.ts +0 -69
  19. package/src/analytics/presentation/hooks/useScreenView.ts +0 -70
  20. package/src/analytics/presentation/utils/analyticsUtils.ts +0 -78
  21. package/src/crashlytics/index.ts +0 -9
  22. package/src/crashlytics/infrastructure/adapters/index.ts +0 -8
  23. package/src/crashlytics/infrastructure/adapters/native-crashlytics.adapter.ts +0 -84
  24. package/src/crashlytics/infrastructure/services/FirebaseCrashlyticsService.ts +0 -93
  25. package/src/crashlytics/infrastructure/services/crashlytics-error.service.ts +0 -67
  26. package/src/crashlytics/infrastructure/services/crashlytics-initializer.service.ts +0 -31
  27. package/src/crashlytics/infrastructure/services/crashlytics-user.service.ts +0 -91
  28. package/src/crashlytics/infrastructure/services/index.ts +0 -11
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@umituz/react-native-firebase",
3
- "version": "1.13.5",
4
- "description": "Unified Firebase package for React Native apps - Centralized initialization and core services (Auth, Firestore, Analytics, Crashlytics).",
3
+ "version": "1.13.7",
4
+ "description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
7
7
  "scripts": {
@@ -14,14 +14,12 @@
14
14
  "keywords": [
15
15
  "react-native",
16
16
  "firebase",
17
- "firebase-core",
17
+ "firebase-js-sdk",
18
18
  "auth",
19
19
  "authentication",
20
20
  "firestore",
21
21
  "database",
22
22
  "repository",
23
- "analytics",
24
- "crashlytics",
25
23
  "ddd",
26
24
  "domain-driven-design"
27
25
  ],
package/src/index.ts CHANGED
@@ -4,16 +4,13 @@
4
4
  * Domain-Driven Design (DDD) Architecture
5
5
  *
6
6
  * This package provides Firebase App initialization and core services:
7
- * - Auth
8
- * - Firestore
9
- * - Analytics
10
- * - Crashlytics
7
+ * - Auth (Firebase JS SDK)
8
+ * - Firestore (Firebase JS SDK)
11
9
  *
12
10
  * Usage:
13
11
  * import { initializeFirebase, getFirebaseApp } from '@umituz/react-native-firebase';
14
12
  * import { useFirebaseAuth } from '@umituz/react-native-firebase';
15
13
  * import { getFirestore, BaseRepository } from '@umituz/react-native-firebase';
16
- * import { firebaseAnalyticsService } from '@umituz/react-native-firebase';
17
14
  */
18
15
 
19
16
  // =============================================================================
@@ -59,15 +56,3 @@ export * from './auth';
59
56
 
60
57
  export * from './firestore';
61
58
 
62
- // =============================================================================
63
- // ANALYTICS MODULE
64
- // =============================================================================
65
-
66
- export * from './analytics';
67
-
68
- // =============================================================================
69
- // CRASHLYTICS MODULE
70
- // =============================================================================
71
-
72
- export * from './crashlytics';
73
-
@@ -1,92 +0,0 @@
1
- /**
2
- * Analytics Service Interface
3
- *
4
- * Application Layer - Port
5
- * Defines the contract for analytics operations
6
- */
7
-
8
- export interface IAnalyticsService {
9
- /**
10
- * Initialize the analytics service
11
- * @param userId Optional user ID to associate with analytics
12
- */
13
- init(userId?: string): Promise<void>;
14
-
15
- /**
16
- * Set the current user ID
17
- * @param userId The unique user identifier
18
- */
19
- setUserId(userId: string): Promise<void>;
20
-
21
- /**
22
- * Log a custom event
23
- * @param eventName Name of the event
24
- * @param params Optional key-value pairs of parameters
25
- */
26
- logEvent(
27
- eventName: string,
28
- params?: Record<string, string | number | boolean | null>,
29
- ): Promise<void>;
30
-
31
- /**
32
- * Set a user property
33
- * @param key Property key
34
- * @param value Property value
35
- */
36
- setUserProperty(key: string, value: string): Promise<void>;
37
-
38
- /**
39
- * Set multiple user properties at once
40
- * @param properties Key-value pairs of user properties
41
- */
42
- setUserProperties(properties: Record<string, string>): Promise<void>;
43
-
44
- /**
45
- * Clear all user data and reset initialization state
46
- */
47
- clearUserData(): Promise<void>;
48
-
49
- /**
50
- * Get the current user ID if set
51
- */
52
- getCurrentUserId(): string | null;
53
-
54
- /**
55
- * Log a screen view event
56
- */
57
- logScreenView(params: { screen_name: string; screen_class?: string }): Promise<void>;
58
-
59
- /**
60
- * Log time spent on a screen
61
- */
62
- logScreenTime(params: {
63
- screen_name: string;
64
- screen_class?: string;
65
- time_spent_seconds: number;
66
- }): Promise<void>;
67
-
68
- /**
69
- * Log a navigation event between screens
70
- */
71
- logNavigation(params: {
72
- from_screen: string;
73
- to_screen: string;
74
- screen_class?: string;
75
- }): Promise<void>;
76
-
77
- /**
78
- * Log a button click event
79
- */
80
- logButtonClick(params: {
81
- button_id: string;
82
- button_name?: string;
83
- screen_name: string;
84
- screen_class?: string;
85
- }): Promise<void>;
86
-
87
- /**
88
- * Enable or disable analytics collection
89
- * @param enabled Whether collection should be enabled
90
- */
91
- setAnalyticsCollectionEnabled(enabled: boolean): Promise<void>;
92
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Firebase Analytics Module
3
- */
4
-
5
- export { firebaseAnalyticsService } from './infrastructure/services/FirebaseAnalyticsService';
6
- export type { IAnalyticsService } from './infrastructure/services/FirebaseAnalyticsService';
7
- export { analyticsInitializerService } from './infrastructure/services/analytics-initializer.service';
8
- export type { AnalyticsInstance } from './infrastructure/services/analytics-initializer.service';
9
- export { analyticsEventService } from './infrastructure/services/analytics-event.service';
10
- export { analyticsUserService } from './infrastructure/services/analytics-user.service';
11
- export { performanceTracker } from './infrastructure/services/PerformanceTracker';
12
-
13
- // Hooks
14
- export { useScreenView } from './presentation/hooks/useScreenView';
15
- export { useScreenTime } from './presentation/hooks/useScreenTime';
16
- export { useNavigationTracking } from './presentation/hooks/useNavigationTracking';
17
- export { useNavigationAnalytics } from './presentation/hooks/useNavigationAnalytics';
18
-
19
- // Utility Functions
20
- export { trackButtonClick, trackCRUDOperation } from './presentation/utils/analyticsUtils';
@@ -1,10 +0,0 @@
1
- /**
2
- * Analytics Adapters
3
- * Platform-specific implementations
4
- */
5
-
6
- export { webAnalyticsAdapter } from './web-analytics.adapter';
7
- export type { WebAnalyticsAdapter } from './web-analytics.adapter';
8
- export { nativeAnalyticsAdapter } from './native-analytics.adapter';
9
- export type { NativeAnalyticsAdapter } from './native-analytics.adapter';
10
-
@@ -1,63 +0,0 @@
1
- /**
2
- * Native Analytics Adapter
3
- * Single Responsibility: Handle Firebase Analytics native implementation
4
- * Uses React Native Firebase v23+ modular API
5
- *
6
- * NOTE: This adapter uses optional import to support Expo Go.
7
- * Native modules are only available in development builds or standalone apps.
8
- */
9
-
10
- // Optional import - will be null in Expo Go
11
- let nativeAnalytics: any = null;
12
- try {
13
- // eslint-disable-next-line @typescript-eslint/no-var-requires
14
- nativeAnalytics = require('@react-native-firebase/analytics');
15
- } catch {
16
- // Native module not available (e.g., Expo Go)
17
- // eslint-disable-next-line no-console
18
- if (__DEV__) console.warn('⚠️ Firebase Analytics: Native module not available');
19
- }
20
-
21
- export interface NativeAnalyticsAdapter {
22
- getAnalytics(): any;
23
- logEvent(analytics: any, eventName: string, params?: Record<string, any>): Promise<void>;
24
- setUserId(analytics: any, userId: string): Promise<void>;
25
- setUserProperties(analytics: any, properties: Record<string, string>): Promise<void>;
26
- resetAnalyticsData(analytics: any): Promise<void>;
27
- setAnalyticsCollectionEnabled(analytics: any, enabled: boolean): Promise<void>;
28
- }
29
-
30
- declare const __DEV__: boolean;
31
-
32
- export const nativeAnalyticsAdapter: NativeAnalyticsAdapter | null = nativeAnalytics
33
- ? {
34
- getAnalytics(): any {
35
- return nativeAnalytics.getAnalytics();
36
- },
37
- async logEvent(
38
- analytics: any,
39
- eventName: string,
40
- params?: Record<string, any>,
41
- ): Promise<void> {
42
- await nativeAnalytics.logEvent(analytics, eventName, params);
43
- },
44
- async setUserId(analytics: any, userId: string): Promise<void> {
45
- await nativeAnalytics.setUserId(analytics, userId);
46
- },
47
- async setUserProperties(
48
- analytics: any,
49
- properties: Record<string, string>,
50
- ): Promise<void> {
51
- await nativeAnalytics.setUserProperties(analytics, properties);
52
- },
53
- async resetAnalyticsData(analytics: any): Promise<void> {
54
- await nativeAnalytics.resetAnalyticsData(analytics);
55
- },
56
- async setAnalyticsCollectionEnabled(
57
- analytics: any,
58
- enabled: boolean,
59
- ): Promise<void> {
60
- await nativeAnalytics.setAnalyticsCollectionEnabled(analytics, enabled);
61
- },
62
- }
63
- : null;
@@ -1,63 +0,0 @@
1
- /**
2
- * Web Analytics Adapter
3
- * Single Responsibility: Handle Firebase Analytics web implementation
4
- */
5
-
6
- export interface WebAnalyticsAdapter {
7
- isSupported(): Promise<boolean>;
8
- getAnalytics(app: any): any;
9
- logEvent(analytics: any, eventName: string, params?: Record<string, any>): Promise<void>;
10
- setUserId(analytics: any, userId: string): Promise<void>;
11
- setUserProperties(analytics: any, properties: Record<string, string>): Promise<void>;
12
- }
13
-
14
- let webAnalyticsModule: any = null;
15
-
16
- try {
17
- // eslint-disable-next-line @typescript-eslint/no-require-imports
18
- const {
19
- getAnalytics,
20
- logEvent,
21
- setUserId,
22
- setUserProperties,
23
- isSupported,
24
- } = require('firebase/analytics');
25
- webAnalyticsModule = {
26
- getAnalytics,
27
- logEvent,
28
- setUserId,
29
- setUserProperties,
30
- isSupported,
31
- };
32
- } catch {
33
- // firebase/analytics not available
34
- }
35
-
36
- export const webAnalyticsAdapter: WebAnalyticsAdapter | null = webAnalyticsModule
37
- ? {
38
- async isSupported(): Promise<boolean> {
39
- if (!webAnalyticsModule.isSupported) return true;
40
- return webAnalyticsModule.isSupported();
41
- },
42
- getAnalytics(app: any): any {
43
- return webAnalyticsModule.getAnalytics(app);
44
- },
45
- async logEvent(
46
- analytics: any,
47
- eventName: string,
48
- params?: Record<string, any>,
49
- ): Promise<void> {
50
- await webAnalyticsModule.logEvent(analytics, eventName, params);
51
- },
52
- async setUserId(analytics: any, userId: string): Promise<void> {
53
- await webAnalyticsModule.setUserId(analytics, userId);
54
- },
55
- async setUserProperties(
56
- analytics: any,
57
- properties: Record<string, string>,
58
- ): Promise<void> {
59
- await webAnalyticsModule.setUserProperties(analytics, properties);
60
- },
61
- }
62
- : null;
63
-
@@ -1,165 +0,0 @@
1
- /**
2
- * Firebase Analytics Service
3
- * Single Responsibility: Orchestrate analytics operations
4
- * Delegates to specialized services for initialization, events, and user management
5
- */
6
-
7
- import { analyticsInitializerService } from './analytics-initializer.service';
8
- import { analyticsEventService } from './analytics-event.service';
9
- import { analyticsUserService } from './analytics-user.service';
10
- import type { AnalyticsInstance } from './analytics-initializer.service';
11
- import type { IAnalyticsService } from '../../application/ports/IAnalyticsService';
12
- import { nativeAnalyticsAdapter } from '../adapters/native-analytics.adapter';
13
-
14
- export type { IAnalyticsService };
15
-
16
- class FirebaseAnalyticsService implements IAnalyticsService {
17
- private isInitialized = false;
18
- private userId: string | null = null;
19
- private userProperties: Record<string, string> = {};
20
- private analyticsInstance: AnalyticsInstance | null = null;
21
-
22
- async init(userId?: string): Promise<void> {
23
- if (this.isInitialized) {
24
- if (userId && userId !== this.userId) {
25
- await this.setUserId(userId);
26
- }
27
- return;
28
- }
29
-
30
- try {
31
- this.analyticsInstance = await analyticsInitializerService.initialize();
32
-
33
- if (this.analyticsInstance) {
34
- if (userId) {
35
- this.userId = userId;
36
- await analyticsUserService.setUserId(this.analyticsInstance, userId);
37
- }
38
-
39
- // Explicitly enable analytics collection to ensure it's active
40
- await this.setAnalyticsCollectionEnabled(true);
41
- }
42
- } catch (_error) {
43
- // Analytics is non-critical, fail silently
44
- } finally {
45
- this.isInitialized = true;
46
- }
47
- }
48
-
49
- async setAnalyticsCollectionEnabled(enabled: boolean): Promise<void> {
50
- if (!this.analyticsInstance) {
51
- return;
52
- }
53
-
54
- try {
55
- if (this.analyticsInstance.platform === 'native' && nativeAnalyticsAdapter) {
56
- await nativeAnalyticsAdapter.setAnalyticsCollectionEnabled(
57
- this.analyticsInstance.instance,
58
- enabled,
59
- );
60
- }
61
- } catch (_error) {
62
- // Fail silently
63
- }
64
- }
65
-
66
- async setUserId(userId: string): Promise<void> {
67
- if (!this.isInitialized || !this.analyticsInstance) {
68
- // Not initialized yet, will be set during init
69
- return;
70
- }
71
-
72
- if (this.userId === userId) {
73
- // Already set to this user ID
74
- return;
75
- }
76
-
77
- try {
78
- this.userId = userId;
79
- await analyticsUserService.setUserId(this.analyticsInstance, userId);
80
- } catch (_error) {
81
- // Analytics is non-critical, fail silently
82
- }
83
- }
84
-
85
- async logEvent(
86
- eventName: string,
87
- params?: Record<string, string | number | boolean | null>,
88
- ): Promise<void> {
89
- if (!this.isInitialized) {
90
- return;
91
- }
92
- await analyticsEventService.logEvent(this.analyticsInstance, eventName, params);
93
- }
94
-
95
- async setUserProperty(key: string, value: string): Promise<void> {
96
- this.userProperties[key] = value;
97
- await analyticsUserService.setUserProperty(this.analyticsInstance, key, value);
98
- }
99
-
100
- async setUserProperties(properties: Record<string, string>): Promise<void> {
101
- await analyticsUserService.setUserProperties(this.analyticsInstance, properties);
102
- Object.assign(this.userProperties, properties);
103
- }
104
-
105
- async clearUserData(): Promise<void> {
106
- await analyticsUserService.clearUserData(this.analyticsInstance);
107
- this.userId = null;
108
- this.userProperties = {};
109
- this.isInitialized = false;
110
- }
111
-
112
- getCurrentUserId(): string | null {
113
- return this.userId;
114
- }
115
-
116
- async logScreenView(params: {
117
- screen_name: string;
118
- screen_class?: string;
119
- }): Promise<void> {
120
- await this.logEvent('screen_view', {
121
- screen_name: params.screen_name,
122
- screen_class: params.screen_class || params.screen_name,
123
- });
124
- }
125
-
126
- async logScreenTime(params: {
127
- screen_name: string;
128
- screen_class?: string;
129
- time_spent_seconds: number;
130
- }): Promise<void> {
131
- await this.logEvent('screen_time', {
132
- screen_name: params.screen_name,
133
- screen_class: params.screen_class || params.screen_name,
134
- time_spent_seconds: params.time_spent_seconds,
135
- });
136
- }
137
-
138
- async logNavigation(params: {
139
- from_screen: string;
140
- to_screen: string;
141
- screen_class?: string;
142
- }): Promise<void> {
143
- await this.logEvent('navigation', {
144
- from_screen: params.from_screen,
145
- to_screen: params.to_screen,
146
- screen_class: params.screen_class || params.to_screen,
147
- });
148
- }
149
-
150
- async logButtonClick(params: {
151
- button_id: string;
152
- button_name?: string;
153
- screen_name: string;
154
- screen_class?: string;
155
- }): Promise<void> {
156
- await this.logEvent('button_click', {
157
- button_id: params.button_id,
158
- button_name: params.button_name || params.button_id,
159
- screen_name: params.screen_name,
160
- screen_class: params.screen_class || params.screen_name,
161
- });
162
- }
163
- }
164
-
165
- export const firebaseAnalyticsService = new FirebaseAnalyticsService();
@@ -1,49 +0,0 @@
1
- /**
2
- * Performance Tracker Service
3
- *
4
- * Single Responsibility: Track performance metrics of operations
5
- */
6
-
7
- export class PerformanceTracker {
8
- private activeTracks = new Map<string, number>();
9
-
10
- /**
11
- * Start tracking an operation
12
- */
13
- start(trackingId: string): void {
14
- this.activeTracks.set(trackingId, Date.now());
15
- }
16
-
17
- /**
18
- * End tracking and return duration
19
- */
20
- async end(trackingId: string, params: Record<string, any> = {}): Promise<number> {
21
- const startTime = this.activeTracks.get(trackingId);
22
- if (!startTime) return 0;
23
-
24
- const duration = Date.now() - startTime;
25
- this.activeTracks.delete(trackingId);
26
-
27
- // In a full implementation, this could send to Firebase Performance
28
- // For now, we just log it or handle it as a custom metric
29
- if (__DEV__) {
30
- console.log(`⏱️ [Performance] ${trackingId}: ${duration}ms`, params);
31
- }
32
-
33
- return duration;
34
- }
35
-
36
- /**
37
- * Track a function execution
38
- */
39
- async track<T>(trackingId: string, fn: () => Promise<T>): Promise<T> {
40
- this.start(trackingId);
41
- try {
42
- return await fn();
43
- } finally {
44
- await this.end(trackingId);
45
- }
46
- }
47
- }
48
-
49
- export const performanceTracker = new PerformanceTracker();
@@ -1,72 +0,0 @@
1
- /**
2
- * Analytics Event Service
3
- * Single Responsibility: Handle event logging operations
4
- */
5
-
6
- import { webAnalyticsAdapter } from '../adapters/web-analytics.adapter';
7
- import { nativeAnalyticsAdapter } from '../adapters/native-analytics.adapter';
8
- import type { AnalyticsInstance } from './analytics-initializer.service';
9
-
10
- export class AnalyticsEventService {
11
- /**
12
- * Log event to analytics
13
- */
14
- async logEvent(
15
- analyticsInstance: AnalyticsInstance | null,
16
- eventName: string,
17
- params?: Record<string, string | number | boolean | null>,
18
- ): Promise<void> {
19
- if (!analyticsInstance) {
20
- /* eslint-disable-next-line no-console */
21
- if (__DEV__) {
22
- console.warn('⚠️ Firebase Analytics: Cannot log event - Analytics not initialized', {
23
- eventName,
24
- reason: 'Analytics instance is null (native module not available in Expo Go)',
25
- });
26
- }
27
- return;
28
- }
29
-
30
- try {
31
- if (analyticsInstance.platform === 'native' && nativeAnalyticsAdapter) {
32
- await nativeAnalyticsAdapter.logEvent(
33
- analyticsInstance.instance,
34
- eventName,
35
- params,
36
- );
37
- /* eslint-disable-next-line no-console */
38
- if (__DEV__) {
39
- console.log('📊 Firebase Analytics Event (native):', {
40
- eventName,
41
- params,
42
- platform: 'iOS/Android',
43
- });
44
- }
45
- } else if (analyticsInstance.platform === 'web' && webAnalyticsAdapter) {
46
- await webAnalyticsAdapter.logEvent(
47
- analyticsInstance.instance,
48
- eventName,
49
- params,
50
- );
51
- /* eslint-disable-next-line no-console */
52
- if (__DEV__) {
53
- console.log('📊 Firebase Analytics Event:', {
54
- eventName,
55
- params,
56
- });
57
- }
58
- }
59
- } catch (error) {
60
- /* eslint-disable-next-line no-console */
61
- if (__DEV__) {
62
- console.warn('⚠️ Firebase Analytics: Failed to log event', {
63
- eventName,
64
- error: error instanceof Error ? error.message : String(error),
65
- });
66
- }
67
- }
68
- }
69
- }
70
-
71
- export const analyticsEventService = new AnalyticsEventService();
72
-