@umituz/react-native-subscription 2.14.20 → 2.14.22

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-subscription",
3
- "version": "2.14.20",
3
+ "version": "2.14.22",
4
4
  "description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -3,7 +3,7 @@
3
3
  * Handles SDK initialization logic
4
4
  */
5
5
 
6
- import Purchases from "react-native-purchases";
6
+ import Purchases, { LOG_LEVEL } from "react-native-purchases";
7
7
  import type { InitializeResult } from '../../application/ports/IRevenueCatService';
8
8
  import type { RevenueCatConfig } from '../../domain/value-objects/RevenueCatConfig';
9
9
  import { getErrorMessage } from '../../domain/types/RevenueCatTypes';
@@ -24,6 +24,50 @@ export interface InitializerDeps {
24
24
 
25
25
  // Track if Purchases.configure has been called globally
26
26
  let isPurchasesConfigured = false;
27
+ let isLogHandlerConfigured = false;
28
+
29
+ /**
30
+ * Configures custom log handler to filter StoreKit 2 internal errors
31
+ * These errors occur on simulator when no prior purchases exist
32
+ */
33
+ function configureLogHandler(): void {
34
+ if (isLogHandlerConfigured) return;
35
+
36
+ Purchases.setLogHandler((logLevel, message) => {
37
+ // Filter out StoreKit 2 AppTransaction errors (normal on simulator)
38
+ const isAppTransactionError =
39
+ message.includes("Purchase was cancelled") ||
40
+ message.includes("AppTransaction") ||
41
+ message.includes("Couldn't find previous transactions");
42
+
43
+ if (isAppTransactionError) {
44
+ // Downgrade to debug level - only show in __DEV__
45
+ if (__DEV__) {
46
+ console.debug("[RevenueCat] (filtered)", message);
47
+ }
48
+ return;
49
+ }
50
+
51
+ // Normal logging for other messages
52
+ switch (logLevel) {
53
+ case LOG_LEVEL.VERBOSE:
54
+ case LOG_LEVEL.DEBUG:
55
+ if (__DEV__) console.debug("[RevenueCat]", message);
56
+ break;
57
+ case LOG_LEVEL.INFO:
58
+ if (__DEV__) console.info("[RevenueCat]", message);
59
+ break;
60
+ case LOG_LEVEL.WARN:
61
+ if (__DEV__) console.warn("[RevenueCat]", message);
62
+ break;
63
+ case LOG_LEVEL.ERROR:
64
+ console.error("[RevenueCat]", message);
65
+ break;
66
+ }
67
+ });
68
+
69
+ isLogHandlerConfigured = true;
70
+ }
27
71
 
28
72
  export async function initializeSDK(
29
73
  deps: InitializerDeps,
@@ -116,6 +160,9 @@ export async function initializeSDK(
116
160
  }
117
161
 
118
162
  try {
163
+ // Configure log handler before SDK initialization
164
+ configureLogHandler();
165
+
119
166
  if (__DEV__) {
120
167
  console.log('[DEBUG RevenueCatInitializer] Calling Purchases.configure', {
121
168
  apiKey: key.substring(0, 10) + '...',