@umituz/react-native-firebase 1.13.7 → 1.13.9

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.7",
3
+ "version": "1.13.9",
4
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",
@@ -30,6 +30,7 @@
30
30
  "url": "https://github.com/umituz/react-native-firebase"
31
31
  },
32
32
  "peerDependencies": {
33
+ "@umituz/react-native-sentry": "latest",
33
34
  "expo-apple-authentication": ">=6.0.0",
34
35
  "firebase": ">=10.0.0",
35
36
  "react": ">=18.2.0",
@@ -6,6 +6,10 @@
6
6
  import { signInAnonymously, type Auth, type User } from "firebase/auth";
7
7
  import { toAnonymousUser, type AnonymousUser } from "../../domain/entities/AnonymousUser";
8
8
  import { checkAuthState } from "./auth-utils.service";
9
+ import {
10
+ trackPackageError,
11
+ addPackageBreadcrumb,
12
+ } from "@umituz/react-native-sentry";
9
13
 
10
14
  declare const __DEV__: boolean;
11
15
 
@@ -66,6 +70,8 @@ export class AnonymousAuthService implements AnonymousAuthServiceInterface {
66
70
  }
67
71
 
68
72
  // No user exists, sign in anonymously
73
+ addPackageBreadcrumb("firebase-auth", "Starting anonymous sign-in");
74
+
69
75
  try {
70
76
  const userCredential = await signInAnonymously(auth);
71
77
  const anonymousUser = toAnonymousUser(userCredential.user);
@@ -75,6 +81,10 @@ export class AnonymousAuthService implements AnonymousAuthServiceInterface {
75
81
  console.log("[AnonymousAuthService] Successfully signed in anonymously", { uid: anonymousUser.uid });
76
82
  }
77
83
 
84
+ addPackageBreadcrumb("firebase-auth", "Anonymous sign-in successful", {
85
+ userId: anonymousUser.uid,
86
+ });
87
+
78
88
  return {
79
89
  user: userCredential.user,
80
90
  anonymousUser,
@@ -85,6 +95,15 @@ export class AnonymousAuthService implements AnonymousAuthServiceInterface {
85
95
  // eslint-disable-next-line no-console
86
96
  console.error("[AnonymousAuthService] Failed to sign in anonymously", error);
87
97
  }
98
+
99
+ trackPackageError(
100
+ error instanceof Error ? error : new Error("Anonymous sign-in failed"),
101
+ {
102
+ packageName: "firebase-auth",
103
+ operation: "anonymous-sign-in",
104
+ }
105
+ );
106
+
88
107
  throw error;
89
108
  }
90
109
  }
@@ -13,6 +13,10 @@ import {
13
13
  import * as AppleAuthentication from "expo-apple-authentication";
14
14
  import * as Crypto from "expo-crypto";
15
15
  import { Platform } from "react-native";
16
+ import {
17
+ trackPackageError,
18
+ addPackageBreadcrumb,
19
+ } from "@umituz/react-native-sentry";
16
20
 
17
21
  /**
18
22
  * Apple Auth result
@@ -50,10 +54,15 @@ export class AppleAuthService {
50
54
  * Handles the complete Apple Sign-In flow
51
55
  */
52
56
  async signIn(auth: Auth): Promise<AppleAuthResult> {
57
+ addPackageBreadcrumb("firebase-auth", "Apple Sign-In started");
58
+
53
59
  try {
54
60
  // Check availability
55
61
  const isAvailable = await this.isAvailable();
56
62
  if (!isAvailable) {
63
+ addPackageBreadcrumb("firebase-auth", "Apple Sign-In not available", {
64
+ platform: Platform.OS,
65
+ });
57
66
  return {
58
67
  success: false,
59
68
  error: "Apple Sign-In is not available on this device",
@@ -67,6 +76,8 @@ export class AppleAuthService {
67
76
  nonce,
68
77
  );
69
78
 
79
+ addPackageBreadcrumb("firebase-auth", "Requesting Apple credentials");
80
+
70
81
  // Request Apple Sign-In
71
82
  const appleCredential = await AppleAuthentication.signInAsync({
72
83
  requestedScopes: [
@@ -78,12 +89,19 @@ export class AppleAuthService {
78
89
 
79
90
  // Check for identity token
80
91
  if (!appleCredential.identityToken) {
92
+ const error = new Error("No identity token received from Apple");
93
+ trackPackageError(error, {
94
+ packageName: "firebase-auth",
95
+ operation: "apple-sign-in",
96
+ });
81
97
  return {
82
98
  success: false,
83
99
  error: "No identity token received from Apple",
84
100
  };
85
101
  }
86
102
 
103
+ addPackageBreadcrumb("firebase-auth", "Creating Firebase credential");
104
+
87
105
  // Create Firebase credential
88
106
  const provider = new OAuthProvider("apple.com");
89
107
  const credential = provider.credential({
@@ -99,6 +117,11 @@ export class AppleAuthService {
99
117
  userCredential.user.metadata.creationTime ===
100
118
  userCredential.user.metadata.lastSignInTime;
101
119
 
120
+ addPackageBreadcrumb("firebase-auth", "Apple Sign-In successful", {
121
+ isNewUser,
122
+ userId: userCredential.user.uid,
123
+ });
124
+
102
125
  return {
103
126
  success: true,
104
127
  userCredential,
@@ -110,12 +133,23 @@ export class AppleAuthService {
110
133
  error instanceof Error &&
111
134
  error.message.includes("ERR_CANCELED")
112
135
  ) {
136
+ addPackageBreadcrumb("firebase-auth", "Apple Sign-In cancelled by user");
113
137
  return {
114
138
  success: false,
115
139
  error: "Apple Sign-In was cancelled",
116
140
  };
117
141
  }
118
142
 
143
+ // Track error in Sentry
144
+ trackPackageError(
145
+ error instanceof Error ? error : new Error("Apple sign-in failed"),
146
+ {
147
+ packageName: "firebase-auth",
148
+ operation: "apple-sign-in",
149
+ platform: Platform.OS,
150
+ }
151
+ );
152
+
119
153
  return {
120
154
  success: false,
121
155
  error: error instanceof Error ? error.message : "Apple sign-in failed",
@@ -10,6 +10,10 @@ import {
10
10
  type Auth,
11
11
  type UserCredential,
12
12
  } from "firebase/auth";
13
+ import {
14
+ trackPackageError,
15
+ addPackageBreadcrumb,
16
+ } from "@umituz/react-native-sentry";
13
17
 
14
18
  /**
15
19
  * Google Auth configuration
@@ -71,6 +75,8 @@ export class GoogleAuthService {
71
75
  auth: Auth,
72
76
  idToken: string,
73
77
  ): Promise<GoogleAuthResult> {
78
+ addPackageBreadcrumb("firebase-auth", "Google Sign-In with ID token");
79
+
74
80
  try {
75
81
  const credential = GoogleAuthProvider.credential(idToken);
76
82
  const userCredential = await signInWithCredential(auth, credential);
@@ -80,12 +86,25 @@ export class GoogleAuthService {
80
86
  userCredential.user.metadata.creationTime ===
81
87
  userCredential.user.metadata.lastSignInTime;
82
88
 
89
+ addPackageBreadcrumb("firebase-auth", "Google Sign-In successful", {
90
+ isNewUser,
91
+ userId: userCredential.user.uid,
92
+ });
93
+
83
94
  return {
84
95
  success: true,
85
96
  userCredential,
86
97
  isNewUser,
87
98
  };
88
99
  } catch (error) {
100
+ trackPackageError(
101
+ error instanceof Error ? error : new Error("Google sign-in failed"),
102
+ {
103
+ packageName: "firebase-auth",
104
+ operation: "google-sign-in",
105
+ }
106
+ );
107
+
89
108
  return {
90
109
  success: false,
91
110
  error: error instanceof Error ? error.message : "Google sign-in failed",
@@ -38,8 +38,6 @@ declare const __DEV__: boolean;
38
38
  export interface ServiceInitializationResult {
39
39
  app: FirebaseApp | null;
40
40
  auth: unknown;
41
- analytics: unknown;
42
- crashlytics: unknown;
43
41
  }
44
42
 
45
43
  /**
@@ -111,7 +109,7 @@ export function autoInitializeFirebase(): FirebaseApp | null {
111
109
  }
112
110
 
113
111
  /**
114
- * Initialize all Firebase services (App, Auth, Analytics, Crashlytics)
112
+ * Initialize all Firebase services (App and Auth)
115
113
  * This is the main entry point for applications - call this once at app startup
116
114
  *
117
115
  * IMPORTANT: Auth initialization is handled via callback to avoid require() issues.
@@ -141,36 +139,21 @@ export async function initializeAllFirebaseServices(
141
139
  return {
142
140
  app: null,
143
141
  auth: null,
144
- analytics: null,
145
- crashlytics: null,
146
142
  };
147
143
  }
148
144
 
149
- const { auth, analytics, crashlytics } =
150
- await FirebaseServiceInitializer.initializeServices(options);
151
-
152
- if (analytics && typeof (analytics as { init?: () => Promise<void> }).init === 'function') {
153
- await (analytics as { init: () => Promise<void> }).init();
154
- }
155
-
156
- if (crashlytics && typeof (crashlytics as { init?: () => Promise<void> }).init === 'function') {
157
- await (crashlytics as { init: () => Promise<void> }).init();
158
- }
145
+ const { auth } = await FirebaseServiceInitializer.initializeServices(options);
159
146
 
160
147
  if (__DEV__) {
161
148
  console.log('[Firebase] All services initialized:', {
162
149
  app: !!app,
163
150
  auth: !!auth,
164
- analytics: !!analytics,
165
- crashlytics: !!crashlytics,
166
151
  });
167
152
  }
168
153
 
169
154
  return {
170
155
  app,
171
156
  auth,
172
- analytics,
173
- crashlytics,
174
157
  };
175
158
  }
176
159
 
@@ -1,16 +1,13 @@
1
1
  /**
2
2
  * Firebase Service Initializer
3
- * Handles initialization of Firebase services (Analytics, Crashlytics)
3
+ * Handles initialization of Firebase Auth service
4
4
  *
5
5
  * NOTE: Auth initialization is handled by the main app via callback.
6
6
  * This removes the need for dynamic require() which causes issues in production.
7
7
  *
8
- * Single Responsibility: Only initializes Firebase services
8
+ * Single Responsibility: Only initializes Firebase Auth service
9
9
  */
10
10
 
11
- import { firebaseAnalyticsService } from '../../../analytics';
12
- import { firebaseCrashlyticsService } from '../../../crashlytics';
13
-
14
11
  declare const __DEV__: boolean;
15
12
 
16
13
  export type AuthInitializer = () => unknown;
@@ -21,8 +18,6 @@ export interface ServiceInitializationOptions {
21
18
 
22
19
  export interface ServiceInitializationResult {
23
20
  auth: unknown;
24
- analytics: typeof firebaseAnalyticsService;
25
- crashlytics: typeof firebaseCrashlyticsService;
26
21
  }
27
22
 
28
23
  export class FirebaseServiceInitializer {
@@ -30,7 +25,7 @@ export class FirebaseServiceInitializer {
30
25
  options?: ServiceInitializationOptions
31
26
  ): Promise<ServiceInitializationResult> {
32
27
  if (__DEV__) {
33
- console.log('[Firebase] Initializing services...');
28
+ console.log('[Firebase] Initializing auth service...');
34
29
  }
35
30
 
36
31
  let auth: unknown = null;
@@ -50,20 +45,10 @@ export class FirebaseServiceInitializer {
50
45
  }
51
46
  }
52
47
 
53
- const analytics = firebaseAnalyticsService;
54
- const crashlytics = firebaseCrashlyticsService;
55
-
56
48
  if (__DEV__) {
57
- console.log(
58
- '[Firebase] Services initialized - Auth:',
59
- !!auth,
60
- 'Analytics:',
61
- !!analytics,
62
- 'Crashlytics:',
63
- !!crashlytics
64
- );
49
+ console.log('[Firebase] Auth service initialized:', !!auth);
65
50
  }
66
51
 
67
- return { auth, analytics, crashlytics };
52
+ return { auth };
68
53
  }
69
54
  }