react-native-mytatva-rn-sdk 1.2.78 → 1.2.80

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.
@@ -131,7 +131,6 @@ dependencies {
131
131
  implementation 'com.google.android.material:material:1.8.0'
132
132
  implementation 'androidx.activity:activity:1.9.3'
133
133
  implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
134
- implementation "io.sentry:sentry-android:7.11.0"
135
134
  implementation 'com.github.bumptech.glide:glide:4.15.1'
136
135
  implementation 'com.github.bumptech.glide:okhttp3-integration:4.15.1'
137
136
  implementation 'androidx.multidex:multidex:2.0.1'
@@ -29,13 +29,6 @@ import com.facebook.react.module.annotations.ReactModule
29
29
  import com.facebook.react.modules.core.DeviceEventManagerModule
30
30
  import com.google.gson.Gson
31
31
  import com.google.gson.GsonBuilder
32
- import io.sentry.IScope
33
- import io.sentry.IHub
34
- import io.sentry.android.core.SentryAndroid
35
- import io.sentry.android.core.SentryAndroidOptions
36
- import io.sentry.Hub
37
- import io.sentry.SentryLevel
38
- import io.sentry.SentryEvent
39
32
  import com.mytatvarnsdk.activity.HelpActivity
40
33
  import com.mytatvarnsdk.activity.StartCGMActivity
41
34
  import com.mytatvarnsdk.model.AllCGMLogRequest
@@ -101,156 +94,12 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
101
94
  ViewModelProvider.AndroidViewModelFactory.getInstance(reactContext.applicationContext as Application)
102
95
  mModel = ViewModelProvider(viewModelStore, factory)[MainActivityModel::class.java]
103
96
  authenticateSDKService = AuthenticateSDKService(scope = scope)
104
-
105
- initSentryIfNeeded(reactContext)
106
- }
107
-
108
- private fun initSentryIfNeeded(context: ReactApplicationContext) {
109
- // Create a separate Sentry Hub with SDK's own DSN
110
- // This ensures we don't interfere with RN app's Sentry instance
111
- // We create our own Hub WITHOUT calling SentryAndroid.init() to avoid overriding global Sentry
112
- if (sentryInitialized.compareAndSet(false, true)) {
113
- try {
114
- Log.d("Sentry", "Initializing SDK Sentry with separate Hub and DSN (not affecting global Sentry)")
115
-
116
- // Create SentryOptions with SDK's DSN
117
- // Use SentryAndroidOptions for Android-specific configuration
118
- val options = SentryAndroidOptions().apply {
119
- dsn = "https://8c1585c04b41a8bdf3271d89c7361530@o4509755819294720.ingest.us.sentry.io/4510520864735232"
120
- isDebug = true // remove or toggle for production
121
- tracesSampleRate = 1.0
122
- environment = env.ifEmpty { "development" }
123
- // Configure Android-specific options
124
- setAttachScreenshot(false)
125
- setAttachViewHierarchy(false)
126
- }
127
-
128
- // Set Android context - this is needed for Android integrations
129
- // But we DON'T call SentryAndroid.init() to avoid overriding global Sentry
130
- val androidContext = context.applicationContext
131
-
132
- // Manually configure Android-specific settings if needed
133
- // Note: Some Android integrations might not work without init(), but core functionality will
134
-
135
- // Create a separate Hub for SDK use (doesn't affect global Sentry)
136
- sdkSentryHub = Hub(options)
137
-
138
- // Capture initial message after a brief delay to ensure Sentry is ready
139
- Handler(Looper.getMainLooper()).postDelayed({
140
- try {
141
- val sentryMessage = io.sentry.protocol.Message().apply {
142
- formatted = "Goodflip SDK started"
143
- }
144
- val event = SentryEvent().apply {
145
- setMessage(sentryMessage)
146
- level = SentryLevel.INFO
147
- }
148
- sdkSentryHub?.captureEvent(event)
149
- Log.d("Sentry", "Goodflip SDK started message sent to SDK Sentry")
150
- } catch (e: Exception) {
151
- Log.e("Sentry", "Error sending initial message: ${e.message}", e)
152
- }
153
- }, 200)
154
- } catch (e: Exception) {
155
- Log.e("Sentry", "Error initializing SDK Sentry: ${e.message}", e)
156
- sentryInitialized.set(false) // Reset on error so we can try again
157
- }
158
- }
159
- }
160
-
161
- private fun captureSentryMessage(message: String, extras: Map<String, String> = emptyMap()) {
162
- try {
163
- // Always try to use Sentry - it might be initialized by RN app even if our flag is false
164
- // Ensure we're on main thread for Sentry operations
165
- if (Looper.myLooper() == Looper.getMainLooper()) {
166
- captureSentryMessageInternal(message, extras)
167
- } else {
168
- Handler(Looper.getMainLooper()).post {
169
- captureSentryMessageInternal(message, extras)
170
- }
171
- }
172
- } catch (e: Exception) {
173
- Log.e("Sentry", "Error capturing Sentry message: ${e.message}", e)
174
- }
175
- }
176
-
177
- private fun captureSentryMessageInternal(message: String, extras: Map<String, String> = emptyMap()) {
178
- try {
179
- val hub = sdkSentryHub
180
- if (hub == null) {
181
- Log.w("Sentry", "SDK Sentry Hub not initialized, skipping message: $message")
182
- return
183
- }
184
-
185
- hub.withScope { scope ->
186
- addContact(scope)
187
- extras.forEach { (key, value) ->
188
- scope.setExtra(key, value)
189
- }
190
- val msgText = message
191
- val sentryMessage = io.sentry.protocol.Message().apply {
192
- formatted = msgText
193
- }
194
- val event = SentryEvent().apply {
195
- setMessage(sentryMessage)
196
- level = SentryLevel.INFO
197
- }
198
- hub.captureEvent(event)
199
- Log.d("Sentry", "Message captured to SDK Sentry: $msgText")
200
- }
201
- } catch (e: Exception) {
202
- Log.e("Sentry", "Error in captureSentryMessageInternal: ${e.message}", e)
203
- }
204
- }
205
-
206
- private fun captureSentryException(exception: Throwable, extras: Map<String, String> = emptyMap()) {
207
- try {
208
- // Always try to use Sentry - it might be initialized by RN app even if our flag is false
209
- // Ensure we're on main thread for Sentry operations
210
- if (Looper.myLooper() == Looper.getMainLooper()) {
211
- captureSentryExceptionInternal(exception, extras)
212
- } else {
213
- Handler(Looper.getMainLooper()).post {
214
- captureSentryExceptionInternal(exception, extras)
215
- }
216
- }
217
- } catch (e: Exception) {
218
- Log.e("Sentry", "Error capturing Sentry exception: ${e.message}", e)
219
- }
220
- }
221
-
222
- private fun captureSentryExceptionInternal(exception: Throwable, extras: Map<String, String> = emptyMap()) {
223
- try {
224
- val hub = sdkSentryHub
225
- if (hub == null) {
226
- Log.w("Sentry", "SDK Sentry Hub not initialized, skipping exception: ${exception.message}")
227
- return
228
- }
229
-
230
- hub.withScope { scope ->
231
- addContact(scope)
232
- extras.forEach { (key, value) ->
233
- scope.setExtra(key, value)
234
- }
235
- val event = SentryEvent().apply {
236
- throwable = exception
237
- level = SentryLevel.ERROR
238
- }
239
- hub.captureEvent(event)
240
- Log.d("Sentry", "Exception captured to SDK Sentry: ${exception.message}")
241
- }
242
- } catch (e: Exception) {
243
- Log.e("Sentry", "Error in captureSentryExceptionInternal: ${e.message}", e)
244
- }
245
97
  }
246
98
 
247
-
248
99
  companion object {
249
100
  var mReactContext: ReactApplicationContext? = null
250
101
  var userToken: String = ""
251
102
  var env: String = ""
252
- private val sentryInitialized = AtomicBoolean(false)
253
- private var sdkSentryHub: IHub? = null
254
103
  }
255
104
 
256
105
  override fun getName(): String {
@@ -261,11 +110,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
261
110
  currentUserData = data
262
111
  }
263
112
 
264
- private fun addContact(scope: IScope) {
265
- val contact = currentUserData?.getString("contact_no") ?: "unknown"
266
- scope.setExtra("contact_no", contact)
267
- }
268
-
269
113
  @ReactMethod
270
114
  fun observeDeviceStatus(token: String, envType: String) {
271
115
  try {
@@ -710,15 +554,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
710
554
  try {
711
555
  // Additional safety check
712
556
  if (pocGlucose.glucoseId == null) {
713
- val timeInMillis = pocGlucose.timeInMillis?.let { it.toString() } ?: "null"
714
- captureSentryMessage(
715
- "handleGlucoseData: glucoseId null, skipping",
716
- mapOf(
717
- "envType" to envType,
718
- "glucoseId" to "null",
719
- "timeInMillis" to timeInMillis
720
- )
721
- )
722
557
  Log.w("handleGlucoseData", "Glucose ID is null, skipping processing")
723
558
  return
724
559
  }
@@ -737,16 +572,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
737
572
  val json = gson.toJson(request)
738
573
 
739
574
  Log.d("Glucose data 3 min==> ", "Glucose data 3 min==> final Json: $json")
740
- val glucoseId = pocGlucose.glucoseId?.let { it.toString() } ?: "null"
741
- val timeInMillis = pocGlucose.timeInMillis?.let { it.toString() } ?: "null"
742
- captureSentryMessage(
743
- "handleGlucoseData: single upload start",
744
- mapOf(
745
- "glucoseId" to glucoseId,
746
- "timeInMillis" to timeInMillis,
747
- "envType" to envType
748
- )
749
- )
750
575
 
751
576
  authenticateSDKService.postCGMData(
752
577
  environment = if (envType.lowercase() == "uat") TATVA_ENVIRONMENT.STAGE else TATVA_ENVIRONMENT.PROD,
@@ -754,27 +579,11 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
754
579
  token = userToken,
755
580
  responseListener = object : AuthenticateSDKService.ResponseListener {
756
581
  override fun onResponseSuccess(response: String) {
757
- val glucoseId = pocGlucose.glucoseId?.let { it.toString() } ?: "null"
758
- captureSentryMessage(
759
- "handleGlucoseData: single upload success",
760
- mapOf(
761
- "glucoseId" to glucoseId,
762
- "envType" to envType
763
- )
764
- )
765
582
  updateSyncMetadata(pocGlucose)
766
583
  Log.d("CGM Data", "Single glucose data uploaded successfully")
767
584
  }
768
585
 
769
586
  override fun onResponseFail() {
770
- val glucoseId = pocGlucose.glucoseId?.let { it.toString() } ?: "null"
771
- captureSentryMessage(
772
- "handleGlucoseData: single upload fail",
773
- mapOf(
774
- "glucoseId" to glucoseId,
775
- "envType" to envType
776
- )
777
- )
778
587
  Log.e("CGM Data", "Failed to upload single glucose data")
779
588
  }
780
589
  }
@@ -787,26 +596,10 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
787
596
  )
788
597
  } */
789
598
  } else {
790
- val glucoseId = pocGlucose.glucoseId?.let { it.toString() } ?: "null"
791
- captureSentryMessage(
792
- "handleGlucoseData: glucose error ${pocGlucose.errorCode}",
793
- mapOf(
794
- "envType" to envType,
795
- "glucoseId" to glucoseId
796
- )
797
- )
798
599
  Log.d("handleGlucoseData", "Glucose data has error: ${pocGlucose.errorCode}")
799
600
  handleGlucoseError(pocGlucose, envType)
800
601
  }
801
602
  } catch (e: Exception) {
802
- val glucoseId = pocGlucose.glucoseId?.let { it.toString() } ?: "null"
803
- captureSentryException(
804
- e,
805
- mapOf(
806
- "glucoseId" to glucoseId,
807
- "envType" to envType
808
- )
809
- )
810
603
  Log.e("handleGlucoseData", "Error handling glucose data: ${e.message}")
811
604
  e.printStackTrace()
812
605
  }
@@ -867,9 +660,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
867
660
  ) {
868
661
  Log.d("function call", "observeAllGlucoseData")
869
662
 
870
- // Ensure Sentry is initialized
871
- mReactContext?.let { initSentryIfNeeded(it) }
872
-
873
663
  // Use atomic compareAndSet to prevent concurrent batch processing
874
664
  if (!isBatchProcessing.compareAndSet(false, true)) {
875
665
  Log.d("observeAllGlucoseData", "Batch processing already in progress, skipping duplicate call")
@@ -895,40 +685,15 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
895
685
  val lastSyncData = prefsHelper?.lastSyncData
896
686
 
897
687
  val lastSyncDataJson = Gson().toJson(lastSyncData).toString()
898
- captureSentryMessage(
899
- "observeAllGlucoseData method =====",
900
- mapOf("lastSyncData" to lastSyncDataJson)
901
- )
902
688
  Log.d("lastSyncData: ", lastSyncDataJson)
903
689
 
904
690
  val currentTime = System.currentTimeMillis()
905
691
  val dataAge = if (lastSyncData != null) currentTime - lastSyncData.timeInMillis else 0L
906
692
 
907
- captureSentryMessage(
908
- "observeAllGlucoseData method",
909
- mapOf(
910
- "currentTime" to currentTime.toString(),
911
- "dataAge" to dataAge.toString(),
912
- "lastSyncData" to Gson().toJson(lastSyncData).toString()
913
- )
914
- )
915
-
916
693
  if (lastSyncData != null && dataAge > 3 * 60 * 1000L) {
917
694
  val glucoseData = mModel.getGlucoseBetweenTime(lastSyncData.timeInMillis)
918
695
 
919
696
  val glucoseCount = glucoseData?.size ?: 0
920
- val lastEntry = glucoseData?.lastOrNull()
921
- val lastEntryGlucoseId = lastEntry?.glucoseId?.let { it.toString() } ?: "null"
922
- val lastEntryTimeInMillis = lastEntry?.timeInMillis?.let { it.toString() } ?: "null"
923
- captureSentryMessage(
924
- "observeAllGlucoseData batch fetch",
925
- mapOf(
926
- "glucoseCount" to glucoseCount.toString(),
927
- "lastEntry_glucoseId" to lastEntryGlucoseId,
928
- "lastEntry_timeInMillis" to lastEntryTimeInMillis
929
- )
930
- )
931
-
932
697
  Log.d("observeAllGlucoseData", "Retrieved ${glucoseCount} records from DB")
933
698
 
934
699
  // Combine database data with pending queue data
@@ -957,30 +722,12 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
957
722
  }
958
723
 
959
724
  if (sortedGlucoseData.isNotEmpty()) {
960
- captureSentryMessage(
961
- "observeAllGlucoseData: got data",
962
- mapOf(
963
- "sortedCount" to sortedGlucoseData.size.toString(),
964
- "oldestTime" to sortedGlucoseData.first().timeInMillis.toString(),
965
- "newestTime" to sortedGlucoseData.last().timeInMillis.toString()
966
- )
967
- )
968
-
969
725
  processBatchDataAndStartObserver(
970
726
  sortedGlucoseData,
971
727
  isForClear,
972
728
  envType
973
729
  )
974
730
  } else {
975
- val lastSyncTime = lastSyncData?.timeInMillis?.let { it.toString() } ?: "null"
976
- captureSentryMessage(
977
- "observeAllGlucoseData: No historical data found, starting live observation",
978
- mapOf(
979
- "pendingCount" to pendingData.size.toString(),
980
- "lastSyncTime" to lastSyncTime
981
- )
982
- )
983
-
984
731
  Log.d(
985
732
  "observeAllGlucoseData",
986
733
  "No historical data found, starting live observation"
@@ -994,18 +741,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
994
741
  } else {
995
742
  // No batch needed, but process pending data if any
996
743
  if (pendingData.isNotEmpty()) {
997
- val lastPending = pendingData.lastOrNull()
998
- val lastPendingGlucoseId = lastPending?.glucoseId?.let { it.toString() } ?: "null"
999
- val lastPendingTime = lastPending?.timeInMillis?.let { it.toString() } ?: "null"
1000
- captureSentryMessage(
1001
- "observeAllGlucoseData: no btach process, processing pending items",
1002
- mapOf(
1003
- "pendingCount" to pendingData.size.toString(),
1004
- "lastPendingGlucoseId" to lastPendingGlucoseId,
1005
- "lastPendingTime" to lastPendingTime
1006
- )
1007
- )
1008
-
1009
744
  Log.d("observeAllGlucoseData", "Processing ${pendingData.size} pending items")
1010
745
  pendingData.forEach { data ->
1011
746
  val glucoseId = data.glucoseId
@@ -1022,10 +757,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1022
757
  }
1023
758
  }
1024
759
  } catch (e: Exception) {
1025
- captureSentryException(
1026
- e,
1027
- mapOf("errorMessage" to "observeAllGlucoseData, Error in batch processing: ${e.message}")
1028
- )
1029
760
  Log.e("observeAllGlucoseData", "Error in batch processing: ${e.message}", e)
1030
761
  } finally {
1031
762
  // Always reset the flag
@@ -1051,16 +782,8 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1051
782
 
1052
783
  if (success) {
1053
784
  Log.d("processBatchDataAndStartObserver", "Batch processing completed successfully")
1054
- captureSentryMessage(
1055
- "processBatchDataAndStartObserver: batch success",
1056
- mapOf("dataListSize" to dataList.size.toString())
1057
- )
1058
785
  } else {
1059
786
  Log.w("processBatchDataAndStartObserver", "Batch processing had failures")
1060
- captureSentryMessage(
1061
- "processBatchDataAndStartObserver: batch failures",
1062
- mapOf("dataListSize" to dataList.size.toString())
1063
- )
1064
787
  }
1065
788
 
1066
789
  // Don't reset flag here - it's reset in observeAllGlucoseData's finally block
@@ -1082,10 +805,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1082
805
  }
1083
806
 
1084
807
  } catch (e: Exception) {
1085
- captureSentryException(
1086
- e,
1087
- mapOf("dataListSize" to dataList.size.toString())
1088
- )
1089
808
  Log.e("processBatchDataAndStartObserver", "Error in batch processing: ${e.message}")
1090
809
  // Start live observation even on error
1091
810
  withContext(Dispatchers.Main) {
@@ -1305,23 +1024,9 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1305
1024
  if (uploadSuccessful) {
1306
1025
  lastSyncedRecord = batch.lastOrNull()
1307
1026
  // Update sync metadata after each successful batch
1308
- captureSentryMessage(
1309
- "Batch Upload: ✅ Batch $index uploaded and synced successfully",
1310
- mapOf(
1311
- "envType" to env,
1312
- "lastSyncedRecord" to Gson().toJson(lastSyncedRecord ?: "null")
1313
- )
1314
- )
1315
1027
  updateSyncMetadata(lastSyncedRecord)
1316
1028
  Log.d("Batch Upload", "✅ Batch $index uploaded and synced successfully")
1317
1029
  } else {
1318
- captureSentryMessage(
1319
- "Batch Upload: ❌ Batch $index failed",
1320
- mapOf(
1321
- "envType" to env,
1322
- "lastSyncedRecord" to Gson().toJson(lastSyncedRecord ?: "null")
1323
- )
1324
- )
1325
1030
  allBatchesSuccessful = false
1326
1031
  Log.e("Batch Upload", "❌ Batch $index failed")
1327
1032
  // Continue with next batch instead of breaking (optional based on your needs)
@@ -1332,15 +1037,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1332
1037
  delay(500L)
1333
1038
 
1334
1039
  } catch (e: Exception) {
1335
- captureSentryException(
1336
- e,
1337
- mapOf(
1338
- "batchIndex" to index.toString(),
1339
- "batchSize" to batch.size.toString(),
1340
- "envType" to env,
1341
- "lastSyncedRecord" to Gson().toJson(lastSyncedRecord ?: "null")
1342
- )
1343
- )
1344
1040
  Log.e("Batch Upload", "❌ Batch $index exception: ${e.message}")
1345
1041
  allBatchesSuccessful = false
1346
1042
  // Continue processing other batches
@@ -1414,36 +1110,15 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1414
1110
  token = userToken,
1415
1111
  responseListener = object : AuthenticateSDKService.ResponseListener {
1416
1112
  override fun onResponseSuccess(response: String) {
1417
- captureSentryMessage(
1418
- "uploadBatchSynchronously: success",
1419
- mapOf(
1420
- "batchIndex" to batchIndex.toString(),
1421
- "envType" to envType
1422
- )
1423
- )
1424
1113
  continuation.resume(true)
1425
1114
  }
1426
1115
 
1427
1116
  override fun onResponseFail() {
1428
- captureSentryMessage(
1429
- "uploadBatchSynchronously: fail",
1430
- mapOf(
1431
- "batchIndex" to batchIndex.toString(),
1432
- "envType" to envType
1433
- )
1434
- )
1435
1117
  continuation.resume(false)
1436
1118
  }
1437
1119
  }
1438
1120
  )
1439
1121
  } catch (e: Exception) {
1440
- captureSentryException(
1441
- e,
1442
- mapOf(
1443
- "batchIndex" to batchIndex.toString(),
1444
- "envType" to envType
1445
- )
1446
- )
1447
1122
  Log.e("uploadBatchSynchronously", "Exception in batch $batchIndex: ${e.message}")
1448
1123
  continuation.resume(false)
1449
1124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.78",
3
+ "version": "1.2.80",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -182,7 +182,7 @@
182
182
  "@react-navigation/stack": "^6.3.18",
183
183
  "@reduxjs/toolkit": "^2.6.1",
184
184
  "@types/crypto-js": "^4.1.1",
185
- "axios": "1.13.4",
185
+ "axios": "1.5.0",
186
186
  "crypto-js": "^3.1.9-1",
187
187
  "moment": "^2.29.4",
188
188
  "react-native-actions-sheet": "^0.9.0-alpha.24",