@umituz/react-native-firebase 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-firebase",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "Unified Firebase package for React Native apps - Centralized initialization and core services (Analytics, Crashlytics).",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
* Native Analytics Adapter
|
|
3
3
|
* Single Responsibility: Handle Firebase Analytics native implementation
|
|
4
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.
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
}
|
|
15
20
|
|
|
16
21
|
export interface NativeAnalyticsAdapter {
|
|
17
22
|
getAnalytics(): any;
|
|
@@ -22,33 +27,37 @@ export interface NativeAnalyticsAdapter {
|
|
|
22
27
|
setAnalyticsCollectionEnabled(analytics: any, enabled: boolean): Promise<void>;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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;
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
* Native Crashlytics Adapter
|
|
3
3
|
* Single Responsibility: Handle Firebase Crashlytics native implementation
|
|
4
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.
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
// Optional import - will be null in Expo Go
|
|
11
|
+
let nativeCrashlytics: any = null;
|
|
12
|
+
try {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
+
nativeCrashlytics = require('@react-native-firebase/crashlytics');
|
|
15
|
+
} catch {
|
|
16
|
+
// Native module not available (e.g., Expo Go)
|
|
17
|
+
// Silent fail - crashlytics is optional
|
|
18
|
+
}
|
|
15
19
|
|
|
16
|
-
export type CrashlyticsInstance =
|
|
20
|
+
export type CrashlyticsInstance = any;
|
|
17
21
|
|
|
18
22
|
export interface NativeCrashlyticsAdapter {
|
|
19
23
|
getCrashlytics(): CrashlyticsInstance;
|
|
@@ -23,54 +27,58 @@ export interface NativeCrashlyticsAdapter {
|
|
|
23
27
|
log(crashlytics: CrashlyticsInstance, message: string): Promise<void>;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
30
|
+
declare const __DEV__: boolean;
|
|
31
|
+
|
|
32
|
+
export const nativeCrashlyticsAdapter: NativeCrashlyticsAdapter | null = nativeCrashlytics
|
|
33
|
+
? {
|
|
34
|
+
getCrashlytics(): CrashlyticsInstance {
|
|
35
|
+
return nativeCrashlytics.getCrashlytics();
|
|
36
|
+
},
|
|
37
|
+
async setUserId(crashlytics: CrashlyticsInstance, userId: string): Promise<void> {
|
|
38
|
+
try {
|
|
39
|
+
await nativeCrashlytics.setUserId(crashlytics, userId);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
/* eslint-disable-next-line no-console */
|
|
42
|
+
if (__DEV__) {
|
|
43
|
+
console.warn('[Crashlytics] Failed to set user ID:', error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
async setAttributes(
|
|
48
|
+
crashlytics: CrashlyticsInstance,
|
|
49
|
+
attributes: Record<string, string>,
|
|
50
|
+
): Promise<void> {
|
|
51
|
+
try {
|
|
52
|
+
// Set each attribute individually using the modular API
|
|
53
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
54
|
+
await nativeCrashlytics.setAttribute(crashlytics, key, value);
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
/* eslint-disable-next-line no-console */
|
|
58
|
+
if (__DEV__) {
|
|
59
|
+
console.warn('[Crashlytics] Failed to set attributes:', error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
async recordError(crashlytics: CrashlyticsInstance, error: Error): Promise<void> {
|
|
64
|
+
try {
|
|
65
|
+
await nativeCrashlytics.recordError(crashlytics, error);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
/* eslint-disable-next-line no-console */
|
|
68
|
+
if (__DEV__) {
|
|
69
|
+
console.warn('[Crashlytics] Failed to record error:', err);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
async log(crashlytics: CrashlyticsInstance, message: string): Promise<void> {
|
|
74
|
+
try {
|
|
75
|
+
await nativeCrashlytics.log(crashlytics, message);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
/* eslint-disable-next-line no-console */
|
|
78
|
+
if (__DEV__) {
|
|
79
|
+
console.warn('[Crashlytics] Failed to log message:', error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
74
83
|
}
|
|
75
|
-
|
|
76
|
-
};
|
|
84
|
+
: null;
|