react-native-mytatva-rn-sdk 1.2.72 → 1.2.74

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,6 +131,7 @@ 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"
134
135
  implementation 'com.github.bumptech.glide:glide:4.15.1'
135
136
  implementation 'com.github.bumptech.glide:okhttp3-integration:4.15.1'
136
137
  implementation 'androidx.multidex:multidex:2.0.1'
Binary file
@@ -359,21 +359,25 @@ public class BleGattCallback extends BluetoothGattCallback {
359
359
  if (period > 3000 || period < 800) {
360
360
  period = 800;
361
361
  }
362
+ // Capture current characteristic to avoid null races inside the async lambda
363
+ final BluetoothGattCharacteristic characteristic = mCharacteristic;
364
+
362
365
  mDisposable = Observable.intervalRange(1, count, initialDelay, period, TimeUnit.MILLISECONDS)
363
366
  .observeOn(Schedulers.io())
364
367
  .subscribe(aLong -> {
365
- if (mBluetoothGatt != null && mCharacteristic != null) {
366
- MyLog.d("intervalRange循环 发送数据 次数 " + aLong + "数据 " + HexadecimalTools.ByteArrayToStrs16(mCharacteristic.getValue()));
368
+ if (mBluetoothGatt != null && characteristic != null) {
369
+ byte[] value = characteristic.getValue();
370
+ MyLog.d("intervalRange循环 发送数据 次数 " + aLong + "数据 " + HexadecimalTools.ByteArrayToStrs16(value));
367
371
  mBluetoothGatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_BALANCED);
368
- mBluetoothGatt.writeCharacteristic(mCharacteristic);
372
+ mBluetoothGatt.writeCharacteristic(characteristic);
373
+ if (aLong >= 5 && value != null && value.length > 0 && value[0] != 0x17) {
374
+ MyLog.e("超出命令发送的最大限制 关闭连接");
375
+ closeGatt();
376
+ }
369
377
  } else {
370
378
  MyLog.w("intervalRange 循环没有数据发送 " + aLong);
371
379
  dispose();
372
380
  }
373
- if (aLong >= 5 && mCharacteristic.getValue()[0] != 0x17) {
374
- MyLog.e("超出命令发送的最大限制 关闭连接");
375
- closeGatt();
376
- }
377
381
  }, throwable -> {
378
382
  MyLog.w("intervalRange 异常 " + throwable.getMessage());
379
383
  dispose();
@@ -23,11 +23,19 @@ import com.facebook.react.bridge.Promise
23
23
  import com.facebook.react.bridge.ReactApplicationContext
24
24
  import com.facebook.react.bridge.ReactContextBaseJavaModule
25
25
  import com.facebook.react.bridge.ReactMethod
26
+ import com.facebook.react.bridge.ReadableMap
26
27
  import com.facebook.react.bridge.WritableMap
27
28
  import com.facebook.react.module.annotations.ReactModule
28
29
  import com.facebook.react.modules.core.DeviceEventManagerModule
29
30
  import com.google.gson.Gson
30
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
31
39
  import com.mytatvarnsdk.activity.HelpActivity
32
40
  import com.mytatvarnsdk.activity.StartCGMActivity
33
41
  import com.mytatvarnsdk.model.AllCGMLogRequest
@@ -83,6 +91,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
83
91
  private val pendingDataQueue = ConcurrentLinkedQueue<PocGlucose>()
84
92
  private val metadataLock = Mutex()
85
93
  private var uploadJob: Job? = null
94
+ private var currentUserData: ReadableMap? = null
86
95
 
87
96
  init {
88
97
  mReactContext = reactContext
@@ -92,6 +101,147 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
92
101
  ViewModelProvider.AndroidViewModelFactory.getInstance(reactContext.applicationContext as Application)
93
102
  mModel = ViewModelProvider(viewModelStore, factory)[MainActivityModel::class.java]
94
103
  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
+ }
95
245
  }
96
246
 
97
247
 
@@ -99,12 +249,23 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
99
249
  var mReactContext: ReactApplicationContext? = null
100
250
  var userToken: String = ""
101
251
  var env: String = ""
252
+ private val sentryInitialized = AtomicBoolean(false)
253
+ private var sdkSentryHub: IHub? = null
102
254
  }
103
255
 
104
256
  override fun getName(): String {
105
257
  return "CgmTrackyLib"
106
258
  }
107
259
 
260
+ private fun updateUserData(data: ReadableMap?) {
261
+ currentUserData = data
262
+ }
263
+
264
+ private fun addContact(scope: IScope) {
265
+ val contact = currentUserData?.getString("contact_no") ?: "unknown"
266
+ scope.setExtra("contact_no", contact)
267
+ }
268
+
108
269
  @ReactMethod
109
270
  fun observeDeviceStatus(token: String, envType: String) {
110
271
  try {
@@ -133,9 +294,11 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
133
294
  token: String,
134
295
  apiResponse: String?,
135
296
  patientId: String,
136
- envType: String
297
+ envType: String,
298
+ userData: ReadableMap? = null
137
299
  ) {
138
300
  try {
301
+ updateUserData(userData)
139
302
  if (apiResponse != null && apiResponse.isNotEmpty()) {
140
303
  env = envType
141
304
  userToken = token
@@ -360,8 +523,9 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
360
523
  }
361
524
 
362
525
  @ReactMethod
363
- fun startCgmTracky(token: String, envType: String) {
526
+ fun startCgmTracky(token: String, envType: String, userData: ReadableMap? = null) {
364
527
  try {
528
+ updateUserData(userData)
365
529
  userToken = token
366
530
  env = envType.lowercase()
367
531
  val intent = Intent(currentActivity, StartCGMActivity::class.java)
@@ -384,8 +548,9 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
384
548
  }
385
549
 
386
550
  @ReactMethod
387
- fun reconnectCgmTracky(token: String, envType: String) {
551
+ fun reconnectCgmTracky(token: String, envType: String, userData: ReadableMap? = null) {
388
552
  try {
553
+ updateUserData(userData)
389
554
  userToken = token
390
555
  env = envType.lowercase()
391
556
  currentActivity?.startActivity(
@@ -411,8 +576,14 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
411
576
 
412
577
 
413
578
  @ReactMethod
414
- fun observeGlucoseData(token: String, isForClear: Boolean = false, envType: String) {
579
+ fun observeGlucoseData(
580
+ token: String,
581
+ isForClear: Boolean = false,
582
+ envType: String,
583
+ userData: ReadableMap? = null
584
+ ) {
415
585
  try {
586
+ updateUserData(userData)
416
587
  userToken = token
417
588
  env = envType
418
589
 
@@ -539,6 +710,15 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
539
710
  try {
540
711
  // Additional safety check
541
712
  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
+ )
542
722
  Log.w("handleGlucoseData", "Glucose ID is null, skipping processing")
543
723
  return
544
724
  }
@@ -557,6 +737,16 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
557
737
  val json = gson.toJson(request)
558
738
 
559
739
  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
+ )
560
750
 
561
751
  authenticateSDKService.postCGMData(
562
752
  environment = if (envType.lowercase() == "uat") TATVA_ENVIRONMENT.STAGE else TATVA_ENVIRONMENT.PROD,
@@ -564,11 +754,27 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
564
754
  token = userToken,
565
755
  responseListener = object : AuthenticateSDKService.ResponseListener {
566
756
  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
+ )
567
765
  updateSyncMetadata(pocGlucose)
568
766
  Log.d("CGM Data", "Single glucose data uploaded successfully")
569
767
  }
570
768
 
571
769
  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
+ )
572
778
  Log.e("CGM Data", "Failed to upload single glucose data")
573
779
  }
574
780
  }
@@ -581,10 +787,26 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
581
787
  )
582
788
  } */
583
789
  } 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
+ )
584
798
  Log.d("handleGlucoseData", "Glucose data has error: ${pocGlucose.errorCode}")
585
799
  handleGlucoseError(pocGlucose, envType)
586
800
  }
587
801
  } 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
+ )
588
810
  Log.e("handleGlucoseData", "Error handling glucose data: ${e.message}")
589
811
  e.printStackTrace()
590
812
  }
@@ -637,9 +859,17 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
637
859
  }
638
860
 
639
861
  @ReactMethod
640
- fun observeAllGlucoseData(token: String, isForClear: Boolean = false, envType: String) {
862
+ fun observeAllGlucoseData(
863
+ token: String,
864
+ isForClear: Boolean = false,
865
+ envType: String,
866
+ userData: ReadableMap? = null
867
+ ) {
641
868
  Log.d("function call", "observeAllGlucoseData")
642
869
 
870
+ // Ensure Sentry is initialized
871
+ mReactContext?.let { initSentryIfNeeded(it) }
872
+
643
873
  // Use atomic compareAndSet to prevent concurrent batch processing
644
874
  if (!isBatchProcessing.compareAndSet(false, true)) {
645
875
  Log.d("observeAllGlucoseData", "Batch processing already in progress, skipping duplicate call")
@@ -647,6 +877,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
647
877
  }
648
878
 
649
879
  userToken = token
880
+ updateUserData(userData)
650
881
  env = envType
651
882
 
652
883
  CoroutineScope(Dispatchers.IO).launch {
@@ -662,15 +893,43 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
662
893
  }
663
894
 
664
895
  val lastSyncData = prefsHelper?.lastSyncData
665
- Log.d("lastSyncData: ", Gson().toJson(lastSyncData).toString())
896
+
897
+ val lastSyncDataJson = Gson().toJson(lastSyncData).toString()
898
+ captureSentryMessage(
899
+ "observeAllGlucoseData method =====",
900
+ mapOf("lastSyncData" to lastSyncDataJson)
901
+ )
902
+ Log.d("lastSyncData: ", lastSyncDataJson)
666
903
 
667
904
  val currentTime = System.currentTimeMillis()
668
905
  val dataAge = if (lastSyncData != null) currentTime - lastSyncData.timeInMillis else 0L
669
906
 
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
+
670
916
  if (lastSyncData != null && dataAge > 3 * 60 * 1000L) {
671
917
  val glucoseData = mModel.getGlucoseBetweenTime(lastSyncData.timeInMillis)
672
918
 
673
- Log.d("observeAllGlucoseData", "Retrieved ${glucoseData?.size ?: 0} records from DB")
919
+ 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
+ Log.d("observeAllGlucoseData", "Retrieved ${glucoseCount} records from DB")
674
933
 
675
934
  // Combine database data with pending queue data
676
935
  val allData = mutableListOf<PocGlucose>()
@@ -698,12 +957,30 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
698
957
  }
699
958
 
700
959
  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
+
701
969
  processBatchDataAndStartObserver(
702
970
  sortedGlucoseData,
703
971
  isForClear,
704
972
  envType
705
973
  )
706
974
  } 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
+
707
984
  Log.d(
708
985
  "observeAllGlucoseData",
709
986
  "No historical data found, starting live observation"
@@ -717,6 +994,18 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
717
994
  } else {
718
995
  // No batch needed, but process pending data if any
719
996
  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
+
720
1009
  Log.d("observeAllGlucoseData", "Processing ${pendingData.size} pending items")
721
1010
  pendingData.forEach { data ->
722
1011
  val glucoseId = data.glucoseId
@@ -733,6 +1022,10 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
733
1022
  }
734
1023
  }
735
1024
  } catch (e: Exception) {
1025
+ captureSentryException(
1026
+ e,
1027
+ mapOf("errorMessage" to "observeAllGlucoseData, Error in batch processing: ${e.message}")
1028
+ )
736
1029
  Log.e("observeAllGlucoseData", "Error in batch processing: ${e.message}", e)
737
1030
  } finally {
738
1031
  // Always reset the flag
@@ -758,8 +1051,16 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
758
1051
 
759
1052
  if (success) {
760
1053
  Log.d("processBatchDataAndStartObserver", "Batch processing completed successfully")
1054
+ captureSentryMessage(
1055
+ "processBatchDataAndStartObserver: batch success",
1056
+ mapOf("dataListSize" to dataList.size.toString())
1057
+ )
761
1058
  } else {
762
1059
  Log.w("processBatchDataAndStartObserver", "Batch processing had failures")
1060
+ captureSentryMessage(
1061
+ "processBatchDataAndStartObserver: batch failures",
1062
+ mapOf("dataListSize" to dataList.size.toString())
1063
+ )
763
1064
  }
764
1065
 
765
1066
  // Don't reset flag here - it's reset in observeAllGlucoseData's finally block
@@ -781,6 +1082,10 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
781
1082
  }
782
1083
 
783
1084
  } catch (e: Exception) {
1085
+ captureSentryException(
1086
+ e,
1087
+ mapOf("dataListSize" to dataList.size.toString())
1088
+ )
784
1089
  Log.e("processBatchDataAndStartObserver", "Error in batch processing: ${e.message}")
785
1090
  // Start live observation even on error
786
1091
  withContext(Dispatchers.Main) {
@@ -1000,9 +1305,23 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1000
1305
  if (uploadSuccessful) {
1001
1306
  lastSyncedRecord = batch.lastOrNull()
1002
1307
  // 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
+ )
1003
1315
  updateSyncMetadata(lastSyncedRecord)
1004
1316
  Log.d("Batch Upload", "✅ Batch $index uploaded and synced successfully")
1005
1317
  } else {
1318
+ captureSentryMessage(
1319
+ "Batch Upload: ❌ Batch $index failed",
1320
+ mapOf(
1321
+ "envType" to env,
1322
+ "lastSyncedRecord" to Gson().toJson(lastSyncedRecord ?: "null")
1323
+ )
1324
+ )
1006
1325
  allBatchesSuccessful = false
1007
1326
  Log.e("Batch Upload", "❌ Batch $index failed")
1008
1327
  // Continue with next batch instead of breaking (optional based on your needs)
@@ -1013,6 +1332,15 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1013
1332
  delay(500L)
1014
1333
 
1015
1334
  } 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
+ )
1016
1344
  Log.e("Batch Upload", "❌ Batch $index exception: ${e.message}")
1017
1345
  allBatchesSuccessful = false
1018
1346
  // Continue processing other batches
@@ -1086,15 +1414,36 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
1086
1414
  token = userToken,
1087
1415
  responseListener = object : AuthenticateSDKService.ResponseListener {
1088
1416
  override fun onResponseSuccess(response: String) {
1417
+ captureSentryMessage(
1418
+ "uploadBatchSynchronously: success",
1419
+ mapOf(
1420
+ "batchIndex" to batchIndex.toString(),
1421
+ "envType" to envType
1422
+ )
1423
+ )
1089
1424
  continuation.resume(true)
1090
1425
  }
1091
1426
 
1092
1427
  override fun onResponseFail() {
1428
+ captureSentryMessage(
1429
+ "uploadBatchSynchronously: fail",
1430
+ mapOf(
1431
+ "batchIndex" to batchIndex.toString(),
1432
+ "envType" to envType
1433
+ )
1434
+ )
1093
1435
  continuation.resume(false)
1094
1436
  }
1095
1437
  }
1096
1438
  )
1097
1439
  } catch (e: Exception) {
1440
+ captureSentryException(
1441
+ e,
1442
+ mapOf(
1443
+ "batchIndex" to batchIndex.toString(),
1444
+ "envType" to envType
1445
+ )
1446
+ )
1098
1447
  Log.e("uploadBatchSynchronously", "Exception in batch $batchIndex: ${e.message}")
1099
1448
  continuation.resume(false)
1100
1449
  }
@@ -31,9 +31,23 @@
31
31
  + (KLTDatabaseHandler *)shared {
32
32
  static KLTDatabaseHandler *handler;
33
33
  static dispatch_once_t onceToken;
34
- dispatch_once(&onceToken, ^{
35
- handler = [[self alloc] init];
36
- });
34
+
35
+ // IMPORTANT:
36
+ // CoreData context in this SDK is NSMainQueueConcurrencyType.
37
+ // If `shared` is first initialized from a background queue, CoreBluetooth can later call
38
+ // `willRestoreState` on the main queue and block waiting on dispatch_once, producing an ANR.
39
+ // Force initialization to happen on the main thread to avoid dispatch_once contention/deadlock.
40
+ if ([NSThread isMainThread]) {
41
+ dispatch_once(&onceToken, ^{
42
+ handler = [[self alloc] init];
43
+ });
44
+ } else {
45
+ dispatch_sync(dispatch_get_main_queue(), ^{
46
+ dispatch_once(&onceToken, ^{
47
+ handler = [[self alloc] init];
48
+ });
49
+ });
50
+ }
37
51
  return handler;
38
52
  }
39
53
 
@@ -69,7 +69,6 @@ class AttachTransmitterViewController: UIViewController {
69
69
 
70
70
 
71
71
  let data = KLTDatabaseHandler.shared().queryAllReceiveData() as! [ReceiveData]
72
- print(data)
73
72
  print("===> all data count: ", data.count)
74
73
  // KLTDatabaseHandler.shared().reloadQueryHistoryData()
75
74
 
@@ -485,8 +485,6 @@ class FinalViewModel: NSObject {
485
485
  print("⚠️ Failed to cast queryAllReceiveData() to [ReceiveData]")
486
486
  return
487
487
  }
488
-
489
- print(data)
490
488
  print("===> all data count: \(data.count)")
491
489
 
492
490
  // Ensure device exists
@@ -54,31 +54,31 @@ function removeCGMEventListener() {
54
54
  eventSubscription = null;
55
55
  }
56
56
  }
57
- const startCGM = async (token, envType) => {
57
+ const startCGM = async (token, envType, userData) => {
58
58
  console.log('startCGM===');
59
59
  try {
60
- const result = await cgmLib.startCgmTracky(token, envType);
60
+ const result = _reactNative.Platform.OS === 'android' ? await cgmLib.startCgmTracky(token, envType, userData) : await cgmLib.startCgmTracky(token, envType);
61
61
  console.log(result);
62
62
  } catch (error) {
63
63
  console.error(error);
64
64
  }
65
65
  };
66
66
  exports.startCGM = startCGM;
67
- const reconnectCGM = async (token, envType) => {
67
+ const reconnectCGM = async (token, envType, userData) => {
68
68
  console.log('reconnectCGM====');
69
69
  try {
70
- const result = await cgmLib.reconnectCgmTracky(token, envType);
70
+ const result = _reactNative.Platform.OS === 'android' ? await cgmLib.reconnectCgmTracky(token, envType, userData) : await cgmLib.reconnectCgmTracky(token, envType);
71
71
  console.log(result);
72
72
  } catch (error) {
73
73
  console.error(error);
74
74
  }
75
75
  };
76
76
  exports.reconnectCGM = reconnectCGM;
77
- const observeAllGlucoseDataHandler = async (token, isCleanData, envType) => {
77
+ const observeAllGlucoseDataHandler = async (token, isCleanData, envType, userData) => {
78
78
  console.log('observeAllGlucoseDataHandler====');
79
79
  try {
80
80
  if (_reactNative.Platform.OS === 'android') {
81
- const result = await cgmLib.observeAllGlucoseData(token, isCleanData, envType);
81
+ const result = await cgmLib.observeAllGlucoseData(token, isCleanData, envType, userData);
82
82
  const deviceStatus = await cgmLib.observeDeviceStatus(token, envType);
83
83
  console.log(result);
84
84
  console.log(deviceStatus);
@@ -102,10 +102,10 @@ const helpCGM = async (token, envType) => {
102
102
  }
103
103
  };
104
104
  exports.helpCGM = helpCGM;
105
- const observeTransmitterUnbindStatusHandler = async (token, apiResponse, patientId, envType) => {
105
+ const observeTransmitterUnbindStatusHandler = async (token, apiResponse, patientId, envType, userData) => {
106
106
  console.log('observeTransmitterUnbindStatusHandler====');
107
107
  try {
108
- const result = await cgmLib.observeTransmitterUnbindStatus(token, apiResponse, patientId, envType);
108
+ const result = _reactNative.Platform.OS === 'android' ? await cgmLib.observeTransmitterUnbindStatus(token, apiResponse, patientId, envType, userData) : await cgmLib.observeTransmitterUnbindStatus(token, apiResponse, patientId, envType);
109
109
  console.log(result);
110
110
  } catch (error) {
111
111
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","eventSubscription","LINKING_ERROR","Platform","select","ios","default","cgmLib","NativeModules","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","NativeEventEmitter","remove","OS","DeviceEventEmitter","addListener","eventData","status","removeCGMEventListener","startCGM","token","envType","console","log","result","startCgmTracky","error","exports","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","isCleanData","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","apiResponse","patientId","observeTransmitterUnbindStatus","observeResetLogoutHandler","resetCgmState","getSqliteDBPath","getTrackLibDbPath","stopCGM","getCgmLogFilePaths","getCgmLogFiles","length"],"sources":["CGMConnect.ts"],"sourcesContent":["import {\n DeviceEventEmitter,\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nfunction initializeCGMEventListener(callback: (eventData: any) => void) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\nconst startCGM = async (token: string, envType: string) => {\n console.log('startCGM===');\n try {\n const result = await cgmLib.startCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst reconnectCGM = async (token: string, envType: string) => {\n console.log('reconnectCGM====');\n try {\n const result = await cgmLib.reconnectCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeAllGlucoseDataHandler = async (\n token: string,\n isCleanData: boolean,\n envType: string\n) => {\n console.log('observeAllGlucoseDataHandler====');\n try {\n if (Platform.OS === 'android') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType\n );\n const deviceStatus = await cgmLib.observeDeviceStatus(token, envType);\n console.log(result);\n console.log(deviceStatus);\n } else if (Platform.OS === 'ios') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType\n );\n console.log(result);\n }\n } catch (error) {\n console.log('error====', error);\n console.error(error);\n }\n};\n\nconst helpCGM = async (token: string, envType: string) => {\n console.log('helpCGM====');\n try {\n const result = await cgmLib.openHelpSupport();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeTransmitterUnbindStatusHandler = async (\n token: string,\n apiResponse: string,\n patientId: string,\n envType: string\n) => {\n console.log('observeTransmitterUnbindStatusHandler====');\n try {\n const result = await cgmLib.observeTransmitterUnbindStatus(\n token,\n apiResponse,\n patientId,\n envType\n );\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeResetLogoutHandler = async () => {\n console.log('observeResetLogoutHandler====');\n try {\n const result = await cgmLib.resetCgmState();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst getSqliteDBPath = async (): Promise<string> => {\n const result = await cgmLib.getTrackLibDbPath();\n return result;\n};\n\nconst stopCGM = async () => {\n // Implementation\n};\n\n/**\n * Get all CGM log file paths\n * Returns array of absolute file paths to CGM log files (CSV format)\n * Use react-native-fs or similar in your main app to read these files\n *\n * @returns Promise<string[]> - Array of absolute file paths\n *\n * @example\n * const logPaths = await getCgmLogFilePaths();\n * // Android: ['/storage/emulated/0/Android/data/.../Documents/12345_POCTech.csv']\n * // iOS: ['/var/mobile/Containers/Data/Application/.../Documents/runLog/1_SensorID.csv']\n */\nconst getCgmLogFilePaths = async (): Promise<string[]> => {\n try {\n const result = await cgmLib.getCgmLogFiles();\n console.log(`CGM Log Files: ${result.length} files found`);\n return result;\n } catch (error) {\n console.error('Error getting CGM log file paths:', error);\n throw error;\n }\n};\n\nexport {\n startCGM,\n stopCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths,\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAIC,iBAA6C,GAAG,IAAI;AAExD,MAAMC,aAAa,GACjB,sFAAsF,GACtFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,MAAM,GAAGC,0BAAa,CAACC,YAAY,GACrCD,0BAAa,CAACC,YAAY,GAC1B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,SAASW,0BAA0BA,CAACC,QAAkC,EAAE;EACtE,MAAMC,eAAe,GAAG,IAAIC,+BAAkB,CAACT,MAAM,CAAC;EACtD,IAAIN,iBAAiB,EAAE;IACrBA,iBAAiB,CAACgB,MAAM,CAAC,CAAC;EAC5B;EAEA,IAAId,qBAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BjB,iBAAiB,GAAGkB,+BAAkB,CAACC,WAAW,CAChD,gBAAgB,EACfC,SAAc,IAAK;MAClB,MAAM;QAAEC;MAAO,CAAC,GAAGD,SAAS;MAC5B,IAAIC,MAAM,KAAK,qBAAqB,EAAE;QACpCR,QAAQ,CAACO,SAAS,CAAC;MACrB,CAAC,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AA,CAAAkB,OAAA,GAAAA,OAAA;AAYA,MAAMC,kBAAkB,GAAG,MAAAA,CAAA,KAA+B;EACxD,IAAI;IACF,MAAMtB,MAAM,GAAG,MAAMtB,MAAM,CAAC6C,cAAc,CAAC,CAAC;IAC5CzB,OAAO,CAACC,GAAG,CAAC,kBAAkBC,MAAM,CAACwB,MAAM,cAAc,CAAC;IAC1D,OAAOxB,MAAM;EACf,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdJ,OAAO,CAACI,KAAK,CAAC,mCAAmC,EAAEA,KAAK,CAAC;IACzD,MAAMA,KAAK;EACb;AACF,CAAC;AAACC,OAAA,CAAAmB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","eventSubscription","LINKING_ERROR","Platform","select","ios","default","cgmLib","NativeModules","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","NativeEventEmitter","remove","OS","DeviceEventEmitter","addListener","eventData","status","removeCGMEventListener","startCGM","token","envType","userData","console","log","result","startCgmTracky","error","exports","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","isCleanData","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","apiResponse","patientId","observeTransmitterUnbindStatus","observeResetLogoutHandler","resetCgmState","getSqliteDBPath","getTrackLibDbPath","stopCGM","getCgmLogFilePaths","getCgmLogFiles","length"],"sources":["CGMConnect.ts"],"sourcesContent":["import {\n DeviceEventEmitter,\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nfunction initializeCGMEventListener(callback: (eventData: any) => void) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\nconst startCGM = async (token: string, envType: string, userData: any) => {\n console.log('startCGM===');\n try {\n const result =\n Platform.OS === 'android'\n ? await cgmLib.startCgmTracky(token, envType, userData)\n : await cgmLib.startCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst reconnectCGM = async (token: string, envType: string, userData: any) => {\n console.log('reconnectCGM====');\n try {\n const result =\n Platform.OS === 'android'\n ? await cgmLib.reconnectCgmTracky(token, envType, userData)\n : await cgmLib.reconnectCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeAllGlucoseDataHandler = async (\n token: string,\n isCleanData: boolean,\n envType: string,\n userData: any\n) => {\n console.log('observeAllGlucoseDataHandler====');\n try {\n if (Platform.OS === 'android') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType,\n userData\n );\n const deviceStatus = await cgmLib.observeDeviceStatus(token, envType);\n console.log(result);\n console.log(deviceStatus);\n } else if (Platform.OS === 'ios') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType\n );\n console.log(result);\n }\n } catch (error) {\n console.log('error====', error);\n console.error(error);\n }\n};\n\nconst helpCGM = async (token: string, envType: string) => {\n console.log('helpCGM====');\n try {\n const result = await cgmLib.openHelpSupport();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeTransmitterUnbindStatusHandler = async (\n token: string,\n apiResponse: string,\n patientId: string,\n envType: string,\n userData: any\n) => {\n console.log('observeTransmitterUnbindStatusHandler====');\n try {\n const result =\n Platform.OS === 'android'\n ? await cgmLib.observeTransmitterUnbindStatus(\n token,\n apiResponse,\n patientId,\n envType,\n userData\n )\n : await cgmLib.observeTransmitterUnbindStatus(\n token,\n apiResponse,\n patientId,\n envType\n );\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeResetLogoutHandler = async () => {\n console.log('observeResetLogoutHandler====');\n try {\n const result = await cgmLib.resetCgmState();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst getSqliteDBPath = async (): Promise<string> => {\n const result = await cgmLib.getTrackLibDbPath();\n return result;\n};\n\nconst stopCGM = async () => {\n // Implementation\n};\n\n/**\n * Get all CGM log file paths\n * Returns array of absolute file paths to CGM log files (CSV format)\n * Use react-native-fs or similar in your main app to read these files\n *\n * @returns Promise<string[]> - Array of absolute file paths\n *\n * @example\n * const logPaths = await getCgmLogFilePaths();\n * // Android: ['/storage/emulated/0/Android/data/.../Documents/12345_POCTech.csv']\n * // iOS: ['/var/mobile/Containers/Data/Application/.../Documents/runLog/1_SensorID.csv']\n */\nconst getCgmLogFilePaths = async (): Promise<string[]> => {\n try {\n const result = await cgmLib.getCgmLogFiles();\n console.log(`CGM Log Files: ${result.length} files found`);\n return result;\n } catch (error) {\n console.error('Error getting CGM log file paths:', error);\n throw error;\n }\n};\n\nexport {\n startCGM,\n stopCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n help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;AACf,CAAC;AAACG,OAAA,CAAAgB,eAAA,GAAAA,eAAA;AAEF,MAAME,OAAO,GAAG,MAAAA,CAAA,KAAY;EAC1B;AAAA,CACD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXAlB,OAAA,CAAAkB,OAAA,GAAAA,OAAA;AAYA,MAAMC,kBAAkB,GAAG,MAAAA,CAAA,KAA+B;EACxD,IAAI;IACF,MAAMtB,MAAM,GAAG,MAAMvB,MAAM,CAAC8C,cAAc,CAAC,CAAC;IAC5CzB,OAAO,CAACC,GAAG,CAAC,kBAAkBC,MAAM,CAACwB,MAAM,cAAc,CAAC;IAC1D,OAAOxB,MAAM;EACf,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdJ,OAAO,CAACI,KAAK,CAAC,mCAAmC,EAAEA,KAAK,CAAC;IACzD,MAAMA,KAAK;EACb;AACF,CAAC;AAACC,OAAA,CAAAmB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -44,29 +44,29 @@ function removeCGMEventListener() {
44
44
  eventSubscription = null;
45
45
  }
46
46
  }
47
- const startCGM = async (token, envType) => {
47
+ const startCGM = async (token, envType, userData) => {
48
48
  console.log('startCGM===');
49
49
  try {
50
- const result = await cgmLib.startCgmTracky(token, envType);
50
+ const result = Platform.OS === 'android' ? await cgmLib.startCgmTracky(token, envType, userData) : await cgmLib.startCgmTracky(token, envType);
51
51
  console.log(result);
52
52
  } catch (error) {
53
53
  console.error(error);
54
54
  }
55
55
  };
56
- const reconnectCGM = async (token, envType) => {
56
+ const reconnectCGM = async (token, envType, userData) => {
57
57
  console.log('reconnectCGM====');
58
58
  try {
59
- const result = await cgmLib.reconnectCgmTracky(token, envType);
59
+ const result = Platform.OS === 'android' ? await cgmLib.reconnectCgmTracky(token, envType, userData) : await cgmLib.reconnectCgmTracky(token, envType);
60
60
  console.log(result);
61
61
  } catch (error) {
62
62
  console.error(error);
63
63
  }
64
64
  };
65
- const observeAllGlucoseDataHandler = async (token, isCleanData, envType) => {
65
+ const observeAllGlucoseDataHandler = async (token, isCleanData, envType, userData) => {
66
66
  console.log('observeAllGlucoseDataHandler====');
67
67
  try {
68
68
  if (Platform.OS === 'android') {
69
- const result = await cgmLib.observeAllGlucoseData(token, isCleanData, envType);
69
+ const result = await cgmLib.observeAllGlucoseData(token, isCleanData, envType, userData);
70
70
  const deviceStatus = await cgmLib.observeDeviceStatus(token, envType);
71
71
  console.log(result);
72
72
  console.log(deviceStatus);
@@ -88,10 +88,10 @@ const helpCGM = async (token, envType) => {
88
88
  console.error(error);
89
89
  }
90
90
  };
91
- const observeTransmitterUnbindStatusHandler = async (token, apiResponse, patientId, envType) => {
91
+ const observeTransmitterUnbindStatusHandler = async (token, apiResponse, patientId, envType, userData) => {
92
92
  console.log('observeTransmitterUnbindStatusHandler====');
93
93
  try {
94
- const result = await cgmLib.observeTransmitterUnbindStatus(token, apiResponse, patientId, envType);
94
+ const result = Platform.OS === 'android' ? await cgmLib.observeTransmitterUnbindStatus(token, apiResponse, patientId, envType, userData) : await cgmLib.observeTransmitterUnbindStatus(token, apiResponse, patientId, envType);
95
95
  console.log(result);
96
96
  } catch (error) {
97
97
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"names":["DeviceEventEmitter","NativeEventEmitter","NativeModules","Platform","eventSubscription","LINKING_ERROR","select","ios","default","cgmLib","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","remove","OS","addListener","eventData","status","removeCGMEventListener","startCGM","token","envType","console","log","result","startCgmTracky","error","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","isCleanData","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","apiResponse","patientId","observeTransmitterUnbindStatus","observeResetLogoutHandler","resetCgmState","getSqliteDBPath","getTrackLibDbPath","stopCGM","getCgmLogFilePaths","getCgmLogFiles","length"],"sources":["CGMConnect.ts"],"sourcesContent":["import {\n DeviceEventEmitter,\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nfunction initializeCGMEventListener(callback: (eventData: any) => void) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\nconst startCGM = async (token: string, envType: string) => {\n console.log('startCGM===');\n try {\n const result = await cgmLib.startCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst reconnectCGM = async (token: string, envType: string) => {\n console.log('reconnectCGM====');\n try {\n const result = await cgmLib.reconnectCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeAllGlucoseDataHandler = async (\n token: string,\n isCleanData: boolean,\n envType: string\n) => {\n console.log('observeAllGlucoseDataHandler====');\n try {\n if (Platform.OS === 'android') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType\n );\n const deviceStatus = await cgmLib.observeDeviceStatus(token, envType);\n console.log(result);\n console.log(deviceStatus);\n } else if (Platform.OS === 'ios') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType\n );\n console.log(result);\n }\n } catch (error) {\n console.log('error====', error);\n console.error(error);\n }\n};\n\nconst helpCGM = async (token: string, envType: string) => {\n console.log('helpCGM====');\n try {\n const result = await cgmLib.openHelpSupport();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeTransmitterUnbindStatusHandler = async (\n token: string,\n apiResponse: string,\n patientId: string,\n envType: string\n) => {\n console.log('observeTransmitterUnbindStatusHandler====');\n try {\n const result = await cgmLib.observeTransmitterUnbindStatus(\n token,\n apiResponse,\n patientId,\n envType\n );\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeResetLogoutHandler = async () => {\n console.log('observeResetLogoutHandler====');\n try {\n const result = await cgmLib.resetCgmState();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst getSqliteDBPath = async (): Promise<string> => {\n const result = await cgmLib.getTrackLibDbPath();\n return result;\n};\n\nconst stopCGM = async () => {\n // Implementation\n};\n\n/**\n * Get all CGM log file paths\n * Returns array of absolute file paths to CGM log files (CSV format)\n * Use react-native-fs or similar in your main app to read these files\n *\n * @returns Promise<string[]> - Array of absolute file paths\n *\n * @example\n * const logPaths = await getCgmLogFilePaths();\n * // Android: ['/storage/emulated/0/Android/data/.../Documents/12345_POCTech.csv']\n * // iOS: ['/var/mobile/Containers/Data/Application/.../Documents/runLog/1_SensorID.csv']\n */\nconst getCgmLogFilePaths = async (): Promise<string[]> => {\n try {\n const result = await cgmLib.getCgmLogFiles();\n console.log(`CGM Log Files: ${result.length} files found`);\n return result;\n } catch (error) {\n console.error('Error getting CGM log file paths:', error);\n throw error;\n }\n};\n\nexport {\n startCGM,\n stopCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths,\n};\n"],"mappings":"AAAA,SACEA,kBAAkB,EAElBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AAErB,IAAIC,iBAA6C,GAAG,IAAI;AAExD,MAAMC,aAAa,GACjB,sFAAsF,GACtFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,MAAM,GAAGP,aAAa,CAACQ,YAAY,GACrCR,aAAa,CAACQ,YAAY,GAC1B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,SAASS,0BAA0BA,CAACC,QAAkC,EAAE;EACtE,MAAMC,eAAe,GAAG,IAAIf,kBAAkB,CAACQ,MAAM,CAAC;EACtD,IAAIL,iBAAiB,EAAE;IACrBA,iBAAiB,CAACa,MAAM,CAAC,CAAC;EAC5B;EAEA,IAAId,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7Bd,iBAAiB,GAAGJ,kBAAkB,CAACmB,WAAW,CAChD,gBAAgB,EACfC,SAAc,IAAK;MAClB,MAAM;QAAEC;MAAO,CAAC,GAAGD,SAAS;MAC5B,IAAIC,MAAM,KAAK,qBAAqB,EAAE;QACpCN,QAAQ,CAACK,SAAS,CAAC;MACrB,CAAC,MAAM;QACLL,QAAQ,CAACK,SAAS,CAAC;MACrB;IACF,CACF,CAAC;EACH,CAAC,MAAM,IAAIjB,QAAQ,CAACe,EAAE,KAAK,KAAK,IAAIF,eAAe,EAAE;IACnDZ,iBAAiB,GAAG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,OAAO,EACPE,qCAAqC,EACrCI,yBAAyB,EACzBE,eAAe,EACfG,kBAAkB","ignoreList":[]}
1
+ {"version":3,"names":["DeviceEventEmitter","NativeEventEmitter","NativeModules","Platform","eventSubscription","LINKING_ERROR","select","ios","default","cgmLib","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","remove","OS","addListener","eventData","status","removeCGMEventListener","startCGM","token","envType","userData","console","log","result","startCgmTracky","error","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","isCleanData","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","apiResponse","patientId","observeTransmitterUnbindStatus","observeResetLogoutHandler","resetCgmState","getSqliteDBPath","getTrackLibDbPath","stopCGM","getCgmLogFilePaths","getCgmLogFiles","length"],"sources":["CGMConnect.ts"],"sourcesContent":["import {\n DeviceEventEmitter,\n EmitterSubscription,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nfunction initializeCGMEventListener(callback: (eventData: any) => void) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\nconst startCGM = async (token: string, envType: string, userData: any) => {\n console.log('startCGM===');\n try {\n const result =\n Platform.OS === 'android'\n ? await cgmLib.startCgmTracky(token, envType, userData)\n : await cgmLib.startCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst reconnectCGM = async (token: string, envType: string, userData: any) => {\n console.log('reconnectCGM====');\n try {\n const result =\n Platform.OS === 'android'\n ? await cgmLib.reconnectCgmTracky(token, envType, userData)\n : await cgmLib.reconnectCgmTracky(token, envType);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeAllGlucoseDataHandler = async (\n token: string,\n isCleanData: boolean,\n envType: string,\n userData: any\n) => {\n console.log('observeAllGlucoseDataHandler====');\n try {\n if (Platform.OS === 'android') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType,\n userData\n );\n const deviceStatus = await cgmLib.observeDeviceStatus(token, envType);\n console.log(result);\n console.log(deviceStatus);\n } else if (Platform.OS === 'ios') {\n const result = await cgmLib.observeAllGlucoseData(\n token,\n isCleanData,\n envType\n );\n console.log(result);\n }\n } catch (error) {\n console.log('error====', error);\n console.error(error);\n }\n};\n\nconst helpCGM = async (token: string, envType: string) => {\n console.log('helpCGM====');\n try {\n const result = await cgmLib.openHelpSupport();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeTransmitterUnbindStatusHandler = async (\n token: string,\n apiResponse: string,\n patientId: string,\n envType: string,\n userData: any\n) => {\n console.log('observeTransmitterUnbindStatusHandler====');\n try {\n const result =\n Platform.OS === 'android'\n ? await cgmLib.observeTransmitterUnbindStatus(\n token,\n apiResponse,\n patientId,\n envType,\n userData\n )\n : await cgmLib.observeTransmitterUnbindStatus(\n token,\n apiResponse,\n patientId,\n envType\n );\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeResetLogoutHandler = async () => {\n console.log('observeResetLogoutHandler====');\n try {\n const result = await cgmLib.resetCgmState();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst getSqliteDBPath = async (): Promise<string> => {\n const result = await cgmLib.getTrackLibDbPath();\n return result;\n};\n\nconst stopCGM = async () => {\n // Implementation\n};\n\n/**\n * Get all CGM log file paths\n * Returns array of absolute file paths to CGM log files (CSV format)\n * Use react-native-fs or similar in your main app to read these files\n *\n * @returns Promise<string[]> - Array of absolute file paths\n *\n * @example\n * const logPaths = await getCgmLogFilePaths();\n * // Android: ['/storage/emulated/0/Android/data/.../Documents/12345_POCTech.csv']\n * // iOS: ['/var/mobile/Containers/Data/Application/.../Documents/runLog/1_SensorID.csv']\n */\nconst getCgmLogFilePaths = async (): Promise<string[]> => {\n try {\n const result = await cgmLib.getCgmLogFiles();\n console.log(`CGM Log Files: ${result.length} files found`);\n return result;\n } catch (error) {\n console.error('Error getting CGM log file paths:', error);\n throw error;\n }\n};\n\nexport {\n startCGM,\n stopCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths,\n};\n"],"mappings":"AAAA,SACEA,kBAAkB,EAElBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AAErB,IAAIC,iBAA6C,GAAG,IAAI;AAExD,MAAMC,aAAa,GACjB,sFAAsF,GACtFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,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E,qCAAqC,EACrCI,yBAAyB,EACzBE,eAAe,EACfG,kBAAkB","ignoreList":[]}
@@ -1,10 +1,10 @@
1
1
  declare function initializeCGMEventListener(callback: (eventData: any) => void): void;
2
2
  declare function removeCGMEventListener(): void;
3
- declare const startCGM: (token: string, envType: string) => Promise<void>;
4
- declare const reconnectCGM: (token: string, envType: string) => Promise<void>;
5
- declare const observeAllGlucoseDataHandler: (token: string, isCleanData: boolean, envType: string) => Promise<void>;
3
+ declare const startCGM: (token: string, envType: string, userData: any) => Promise<void>;
4
+ declare const reconnectCGM: (token: string, envType: string, userData: any) => Promise<void>;
5
+ declare const observeAllGlucoseDataHandler: (token: string, isCleanData: boolean, envType: string, userData: any) => Promise<void>;
6
6
  declare const helpCGM: (token: string, envType: string) => Promise<void>;
7
- declare const observeTransmitterUnbindStatusHandler: (token: string, apiResponse: string, patientId: string, envType: string) => Promise<void>;
7
+ declare const observeTransmitterUnbindStatusHandler: (token: string, apiResponse: string, patientId: string, envType: string, userData: any) => Promise<void>;
8
8
  declare const observeResetLogoutHandler: () => Promise<void>;
9
9
  declare const getSqliteDBPath: () => Promise<string>;
10
10
  declare const stopCGM: () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.72",
3
+ "version": "1.2.74",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/CGMConnect.ts CHANGED
@@ -65,20 +65,26 @@ function removeCGMEventListener() {
65
65
  }
66
66
  }
67
67
 
68
- const startCGM = async (token: string, envType: string) => {
68
+ const startCGM = async (token: string, envType: string, userData: any) => {
69
69
  console.log('startCGM===');
70
70
  try {
71
- const result = await cgmLib.startCgmTracky(token, envType);
71
+ const result =
72
+ Platform.OS === 'android'
73
+ ? await cgmLib.startCgmTracky(token, envType, userData)
74
+ : await cgmLib.startCgmTracky(token, envType);
72
75
  console.log(result);
73
76
  } catch (error) {
74
77
  console.error(error);
75
78
  }
76
79
  };
77
80
 
78
- const reconnectCGM = async (token: string, envType: string) => {
81
+ const reconnectCGM = async (token: string, envType: string, userData: any) => {
79
82
  console.log('reconnectCGM====');
80
83
  try {
81
- const result = await cgmLib.reconnectCgmTracky(token, envType);
84
+ const result =
85
+ Platform.OS === 'android'
86
+ ? await cgmLib.reconnectCgmTracky(token, envType, userData)
87
+ : await cgmLib.reconnectCgmTracky(token, envType);
82
88
  console.log(result);
83
89
  } catch (error) {
84
90
  console.error(error);
@@ -88,7 +94,8 @@ const reconnectCGM = async (token: string, envType: string) => {
88
94
  const observeAllGlucoseDataHandler = async (
89
95
  token: string,
90
96
  isCleanData: boolean,
91
- envType: string
97
+ envType: string,
98
+ userData: any
92
99
  ) => {
93
100
  console.log('observeAllGlucoseDataHandler====');
94
101
  try {
@@ -96,7 +103,8 @@ const observeAllGlucoseDataHandler = async (
96
103
  const result = await cgmLib.observeAllGlucoseData(
97
104
  token,
98
105
  isCleanData,
99
- envType
106
+ envType,
107
+ userData
100
108
  );
101
109
  const deviceStatus = await cgmLib.observeDeviceStatus(token, envType);
102
110
  console.log(result);
@@ -129,16 +137,26 @@ const observeTransmitterUnbindStatusHandler = async (
129
137
  token: string,
130
138
  apiResponse: string,
131
139
  patientId: string,
132
- envType: string
140
+ envType: string,
141
+ userData: any
133
142
  ) => {
134
143
  console.log('observeTransmitterUnbindStatusHandler====');
135
144
  try {
136
- const result = await cgmLib.observeTransmitterUnbindStatus(
137
- token,
138
- apiResponse,
139
- patientId,
140
- envType
141
- );
145
+ const result =
146
+ Platform.OS === 'android'
147
+ ? await cgmLib.observeTransmitterUnbindStatus(
148
+ token,
149
+ apiResponse,
150
+ patientId,
151
+ envType,
152
+ userData
153
+ )
154
+ : await cgmLib.observeTransmitterUnbindStatus(
155
+ token,
156
+ apiResponse,
157
+ patientId,
158
+ envType
159
+ );
142
160
  console.log(result);
143
161
  } catch (error) {
144
162
  console.error(error);