@bigcrunch/react-native-ads 0.6.0 → 0.7.0

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.
@@ -308,6 +308,7 @@ object BigCrunchAds {
308
308
  return SessionInfo(
309
309
  sessionId = SessionManager.getSessionId(),
310
310
  startTime = SessionManager.getSessionStartTime(),
311
+ sessionDepth = SessionManager.getSessionDepth(),
311
312
  screenViewCount = SessionManager.getScreenViewCount(),
312
313
  adRequestCount = SessionManager.getAdRequestCount(),
313
314
  adImpressionCount = SessionManager.getAdImpressionCount(),
@@ -157,7 +157,8 @@ internal class ConfigManager(
157
157
  if (config != null) {
158
158
  cachedConfig = config
159
159
  saveToStorage(json)
160
- BCLogger.i("ConfigManager", "Config loaded successfully from network (${config.placements.size} placements)")
160
+ val placementIds = config.placements.map { it.placementId }
161
+ BCLogger.i("ConfigManager", "Config loaded successfully from network (${config.placements.size} placements): $placementIds")
161
162
  Result.success(config)
162
163
  } else {
163
164
  BCLogger.e("ConfigManager", "Invalid config JSON")
@@ -166,7 +167,8 @@ internal class ConfigManager(
166
167
  }
167
168
  storedConfig != null -> {
168
169
  // Network failed but we have cached version
169
- BCLogger.w("ConfigManager", "Using cached config, network fetch failed: ${result.exceptionOrNull()?.message}")
170
+ val cachedIds = storedConfig.placements.map { it.placementId }
171
+ BCLogger.w("ConfigManager", "Using cached config, network fetch failed: ${result.exceptionOrNull()?.message} (cached placements: $cachedIds)")
170
172
  Result.success(storedConfig)
171
173
  }
172
174
  else -> {
@@ -28,7 +28,7 @@ internal class DeviceContext private constructor(context: Context) {
28
28
 
29
29
  companion object {
30
30
  private const val TAG = "DeviceContext"
31
- internal const val SDK_VERSION = "0.6.0"
31
+ internal const val SDK_VERSION = "0.7.0"
32
32
 
33
33
  @Volatile
34
34
  private var instance: DeviceContext? = null
@@ -71,6 +71,7 @@ internal class SessionManager private constructor(private val storage: KeyValueS
71
71
  // Static accessors for tracking counters
72
72
  fun getSessionId(): String = getInstance().sessionId
73
73
  fun getSessionStartTime(): String = getInstance().sessionStartTime
74
+ fun getSessionDepth(): Int = getInstance().sessionDepth
74
75
  fun getScreenViewCount(): Int = getInstance().screenViewCounter.get()
75
76
  fun getAdRequestCount(): Int = getInstance().adRequestCounter.get()
76
77
  fun getAdImpressionCount(): Int = getInstance().adImpressionCounter.get()
@@ -14,6 +14,7 @@ package com.bigcrunch.ads.models
14
14
  data class SessionInfo(
15
15
  val sessionId: String,
16
16
  val startTime: String,
17
+ val sessionDepth: Int,
17
18
  val screenViewCount: Int,
18
19
  val adRequestCount: Int,
19
20
  val adImpressionCount: Int,
@@ -39,6 +39,8 @@ class BigCrunchAdsModule(reactContext: ReactApplicationContext) :
39
39
 
40
40
  scope.launch {
41
41
  try {
42
+ android.util.Log.d("BigCrunchRNBridge", "initialize() called: propertyId=$propertyId env=$environment mock=${environment == "sandbox"}")
43
+
42
44
  BigCrunchAds.initialize(
43
45
  context = context,
44
46
  propertyId = propertyId,
@@ -50,18 +52,25 @@ class BigCrunchAdsModule(reactContext: ReactApplicationContext) :
50
52
  useMockConfig = environment == "sandbox"
51
53
  )
52
54
 
55
+ android.util.Log.d("BigCrunchRNBridge", "native initialize() returned, isInitialized=${BigCrunchAds.isInitialized()}")
56
+
53
57
  if (debug) {
54
58
  BigCrunchAds.setDebugMode(true)
55
59
  }
56
60
 
57
61
  // Wait for config to be loaded before resolving the promise
58
62
  // This ensures placements are available when the app starts loading ads
63
+ android.util.Log.d("BigCrunchRNBridge", "waiting for config...")
59
64
  val configLoaded = BigCrunchAds.waitForConfig()
65
+ android.util.Log.d("BigCrunchRNBridge", "waitForConfig returned: $configLoaded, isConfigReady=${BigCrunchAds.isConfigReady()}")
66
+
60
67
  if (!configLoaded) {
68
+ android.util.Log.e("BigCrunchRNBridge", "config failed to load, rejecting promise")
61
69
  promise.reject("INIT_ERROR", "Failed to load configuration", null)
62
70
  return@launch
63
71
  }
64
72
 
73
+ android.util.Log.d("BigCrunchRNBridge", "init complete, resolving promise")
65
74
  promise.resolve(null)
66
75
  } catch (e: Exception) {
67
76
  promise.reject("INIT_ERROR", "Failed to initialize SDK: ${e.message}", e)
@@ -618,6 +627,7 @@ class BigCrunchAdsModule(reactContext: ReactApplicationContext) :
618
627
  val map = Arguments.createMap()
619
628
  map.putString("sessionId", info.sessionId)
620
629
  map.putString("startTime", info.startTime) // Changed from toDouble() - now ISO 8601 string
630
+ map.putInt("sessionDepth", info.sessionDepth)
621
631
  map.putInt("screenViewCount", info.screenViewCount)
622
632
  map.putInt("adRequestCount", info.adRequestCount)
623
633
  map.putInt("adImpressionCount", info.adImpressionCount)
@@ -202,6 +202,7 @@ public final class BigCrunchAds {
202
202
  sessionId: sm.sessionId,
203
203
  userId: sm.userId,
204
204
  startTime: sm.sessionStartTime,
205
+ sessionDepth: sm.sessionDepth,
205
206
  screenViewCount: sm.sessionDepth,
206
207
  adRequestCount: sm.adRequestCount,
207
208
  adImpressionCount: sm.adImpressionCount,
@@ -147,7 +147,8 @@ internal class ConfigManager {
147
147
  let config = try JSONDecoder().decode(AppConfig.self, from: data)
148
148
  cachedConfig = config
149
149
  saveToStorage(json)
150
- BCLogger.info("Config loaded successfully from network (\(config.placements.count) placements)")
150
+ let placementIds = config.placements.map { $0.placementId }
151
+ BCLogger.info("Config loaded successfully from network (\(config.placements.count) placements): \(placementIds)")
151
152
  return .success(config)
152
153
  } catch {
153
154
  BCLogger.error("Failed to parse config JSON: \(error)")
@@ -157,7 +158,8 @@ internal class ConfigManager {
157
158
  case .failure(let error):
158
159
  // Network failed, check for cached version
159
160
  if let cached = cachedConfig {
160
- BCLogger.warning("Using cached config, network fetch failed: \(error)")
161
+ let cachedIds = cached.placements.map { $0.placementId }
162
+ BCLogger.warning("Using cached config, network fetch failed: \(error) (cached placements: \(cachedIds))")
161
163
  return .success(cached)
162
164
  } else {
163
165
  BCLogger.error("Config load failed and no cache available")
@@ -74,7 +74,7 @@ internal final class DeviceContext {
74
74
  // MARK: - SDK Properties
75
75
 
76
76
  /// SDK version
77
- static let SDK_VERSION = "0.6.0"
77
+ static let SDK_VERSION = "0.7.0"
78
78
  let sdkVersion: String = SDK_VERSION
79
79
 
80
80
  /// SDK platform (always "ios")
@@ -39,6 +39,18 @@ public struct AppConfig: Codable {
39
39
  self.placements = placements
40
40
  }
41
41
 
42
+ public init(from decoder: Decoder) throws {
43
+ let container = try decoder.container(keyedBy: CodingKeys.self)
44
+ propertyId = try container.decode(String.self, forKey: .propertyId)
45
+ appName = try container.decode(String.self, forKey: .appName)
46
+ gamNetworkCode = try container.decode(String.self, forKey: .gamNetworkCode)
47
+ s2s = try container.decode(S2SConfig.self, forKey: .s2s)
48
+ bidders = try container.decodeIfPresent([String: BidderEntry].self, forKey: .bidders)
49
+ amazonAps = try container.decodeIfPresent(GlobalAmazonConfig.self, forKey: .amazonAps)
50
+ useTestAds = try container.decodeIfPresent(Bool.self, forKey: .useTestAds) ?? false
51
+ refresh = try container.decodeIfPresent(RefreshConfig.self, forKey: .refresh)
52
+ placements = try container.decode([PlacementConfig].self, forKey: .placements)
53
+ }
42
54
  }
43
55
 
44
56
  /**
@@ -16,6 +16,9 @@ public struct SessionInfo {
16
16
  /// ISO 8601 timestamp when the session started
17
17
  public let startTime: String
18
18
 
19
+ /// Number of page views in current session (same as screenViewCount)
20
+ public let sessionDepth: Int
21
+
19
22
  /// Number of screen views in this session
20
23
  public let screenViewCount: Int
21
24
 
@@ -32,6 +35,7 @@ public struct SessionInfo {
32
35
  sessionId: String,
33
36
  userId: String,
34
37
  startTime: String,
38
+ sessionDepth: Int,
35
39
  screenViewCount: Int,
36
40
  adRequestCount: Int,
37
41
  adImpressionCount: Int,
@@ -40,6 +44,7 @@ public struct SessionInfo {
40
44
  self.sessionId = sessionId
41
45
  self.userId = userId
42
46
  self.startTime = startTime
47
+ self.sessionDepth = sessionDepth
43
48
  self.screenViewCount = screenViewCount
44
49
  self.adRequestCount = adRequestCount
45
50
  self.adImpressionCount = adImpressionCount
@@ -132,10 +132,12 @@ class InitCallbackBridge: NSObject, BigCrunchInitializationCallback {
132
132
  }
133
133
 
134
134
  func onInitialized() {
135
+ NSLog("[BigCrunchRNBridge] callback onInitialized fired, resolving promise")
135
136
  onSuccess()
136
137
  }
137
138
 
138
139
  func onInitializationFailed(error: String) {
140
+ NSLog("[BigCrunchRNBridge] callback onInitializationFailed: %@", error)
139
141
  onFailure(error)
140
142
  }
141
143
  }
@@ -229,14 +231,18 @@ class BigCrunchAdsModule: RCTEventEmitter {
229
231
  // Map environment strings to SDK enum - "sandbox" maps to .staging
230
232
  let env: BigCrunchEnv = environment == "sandbox" ? .staging : .prod
231
233
 
234
+ NSLog("[BigCrunchRNBridge] initialize() called: propertyId=%@ env=%@ mock=%d", propertyId, environment, useMockConfig ? 1 : 0)
235
+
232
236
  // Use callback to wait for config to load before resolving the promise
233
237
  // This ensures placements are available when the app starts loading ads
234
238
  let callbackBridge = InitCallbackBridge(
235
239
  onSuccess: {
240
+ NSLog("[BigCrunchRNBridge] init complete, setting isSDKInitialized=true, resolving promise")
236
241
  BigCrunchAdsModule.isSDKInitialized = true
237
242
  resolver(nil)
238
243
  },
239
244
  onFailure: { error in
245
+ NSLog("[BigCrunchRNBridge] init failed: %@, rejecting promise", error)
240
246
  rejecter("INIT_ERROR", "Failed to load configuration: \(error)", nil)
241
247
  }
242
248
  )
@@ -249,6 +255,7 @@ class BigCrunchAdsModule: RCTEventEmitter {
249
255
  useMockConfig: useMockConfig,
250
256
  callback: callbackBridge
251
257
  )
258
+ NSLog("[BigCrunchRNBridge] native initialize() returned, waiting for callback...")
252
259
  }
253
260
  }
254
261
 
@@ -510,6 +517,7 @@ class BigCrunchAdsModule: RCTEventEmitter {
510
517
  "sessionId": info.sessionId,
511
518
  "userId": info.userId,
512
519
  "startTime": info.startTime,
520
+ "sessionDepth": info.sessionDepth,
513
521
  "screenViewCount": info.screenViewCount,
514
522
  "adRequestCount": info.adRequestCount,
515
523
  "adImpressionCount": info.adImpressionCount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcrunch/react-native-ads",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "BigCrunch Mobile Ads SDK for React Native - Simplified in-app advertising with S2S demand and Google Ad Manager",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",