expo-observe 58.0.19 → 58.1.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.
Files changed (111) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +11 -0
  3. package/android/build.gradle +1 -0
  4. package/android/src/main/java/expo/modules/observe/Constants.kt +3 -0
  5. package/android/src/main/java/expo/modules/observe/EventDispatcher.kt +7 -0
  6. package/android/src/main/java/expo/modules/observe/ObservabilityBackgroundWorker.kt +10 -1
  7. package/android/src/main/java/expo/modules/observe/ObservabilityManager.kt +32 -6
  8. package/android/src/main/java/expo/modules/observe/ObserveModule.kt +80 -1
  9. package/android/src/main/java/expo/modules/observe/ObservePreferences.kt +18 -24
  10. package/android/src/main/java/expo/modules/observe/OpenTelemetry.kt +15 -6
  11. package/app.plugin.js +1 -0
  12. package/build/index.d.ts +1 -1
  13. package/build/index.js.map +1 -1
  14. package/build/integrations/expo-router/init.js +22 -4
  15. package/build/integrations/expo-router/init.js.map +1 -1
  16. package/build/integrations/navigationConfig.d.ts +1 -0
  17. package/build/integrations/navigationConfig.js +3 -0
  18. package/build/integrations/navigationConfig.js.map +1 -1
  19. package/build/integrations/react-navigation/ObserveNavigationProvider.js +8 -3
  20. package/build/integrations/react-navigation/ObserveNavigationProvider.js.map +1 -1
  21. package/build/integrations/react-navigation/actionListener.d.ts +2 -1
  22. package/build/integrations/react-navigation/actionListener.js +5 -2
  23. package/build/integrations/react-navigation/actionListener.js.map +1 -1
  24. package/build/integrations/react-navigation/handleStateChange.d.ts +2 -1
  25. package/build/integrations/react-navigation/handleStateChange.js +14 -1
  26. package/build/integrations/react-navigation/handleStateChange.js.map +1 -1
  27. package/build/integrations/shared/navigation/blockingTime.d.ts +9 -0
  28. package/build/integrations/shared/navigation/blockingTime.js +76 -0
  29. package/build/integrations/shared/navigation/blockingTime.js.map +1 -0
  30. package/build/module.js +14 -0
  31. package/build/module.js.map +1 -1
  32. package/build/module.web.d.ts +3 -1
  33. package/build/module.web.js +5 -0
  34. package/build/module.web.js.map +1 -1
  35. package/build/privacyManifestWarning.d.ts +2 -0
  36. package/build/privacyManifestWarning.ios.d.ts +2 -0
  37. package/build/privacyManifestWarning.ios.js +13 -0
  38. package/build/privacyManifestWarning.ios.js.map +1 -0
  39. package/build/privacyManifestWarning.js +4 -0
  40. package/build/privacyManifestWarning.js.map +1 -0
  41. package/build/reportFeedback.d.ts +6 -0
  42. package/build/reportFeedback.js +78 -0
  43. package/build/reportFeedback.js.map +1 -0
  44. package/build/types.d.ts +133 -4
  45. package/build/types.js.map +1 -1
  46. package/ios/DispatchUtils.swift +6 -0
  47. package/ios/Observability.swift +49 -10
  48. package/ios/ObserveModule.swift +52 -1
  49. package/ios/ObserveUserDefaults.swift +14 -5
  50. package/ios/OpenTelemetry.swift +20 -6
  51. package/ios/Tests/DispatchLoopTests.swift +84 -0
  52. package/ios/Tests/ObservabilityTests.swift +94 -2
  53. package/ios/Tests/ObserveUserDefaultsTests.swift +64 -0
  54. package/ios/Tests/OpenTelemetryTests.swift +62 -0
  55. package/ios/Tests/PrivacyManifestTests.swift +36 -0
  56. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0-sources.jar +0 -0
  57. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0-sources.jar.md5 +1 -0
  58. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0-sources.jar.sha1 +1 -0
  59. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0-sources.jar.sha256 +1 -0
  60. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0-sources.jar.sha512 +1 -0
  61. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.aar +0 -0
  62. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.aar.md5 +1 -0
  63. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.aar.sha1 +1 -0
  64. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.aar.sha256 +1 -0
  65. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.aar.sha512 +1 -0
  66. package/local-maven-repo/expo/modules/observe/expo.modules.observe/{58.0.19/expo.modules.observe-58.0.19.module → 58.1.0/expo.modules.observe-58.1.0.module} +23 -23
  67. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.module.md5 +1 -0
  68. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.module.sha1 +1 -0
  69. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.module.sha256 +1 -0
  70. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.module.sha512 +1 -0
  71. package/local-maven-repo/expo/modules/observe/expo.modules.observe/{58.0.19/expo.modules.observe-58.0.19.pom → 58.1.0/expo.modules.observe-58.1.0.pom} +2 -2
  72. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.pom.md5 +1 -0
  73. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.pom.sha1 +1 -0
  74. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.pom.sha256 +1 -0
  75. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.1.0/expo.modules.observe-58.1.0.pom.sha512 +1 -0
  76. package/package.json +8 -5
  77. package/plugin/build/withObserve.d.ts +11 -0
  78. package/plugin/build/withObserve.js +45 -0
  79. package/plugin/build/withObserve.js.map +1 -0
  80. package/plugin/src/withObserve.ts +50 -0
  81. package/src/index.ts +4 -0
  82. package/src/integrations/expo-router/init.ts +27 -8
  83. package/src/integrations/navigationConfig.ts +4 -0
  84. package/src/integrations/react-navigation/ObserveNavigationProvider.tsx +15 -3
  85. package/src/integrations/react-navigation/actionListener.ts +7 -5
  86. package/src/integrations/react-navigation/handleStateChange.ts +19 -2
  87. package/src/integrations/shared/navigation/blockingTime.ts +101 -0
  88. package/src/module.ts +23 -1
  89. package/src/module.web.ts +7 -0
  90. package/src/privacyManifestWarning.ios.ts +19 -0
  91. package/src/privacyManifestWarning.ts +4 -0
  92. package/src/reportFeedback.ts +75 -0
  93. package/src/types.ts +150 -4
  94. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19-sources.jar +0 -0
  95. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19-sources.jar.md5 +0 -1
  96. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19-sources.jar.sha1 +0 -1
  97. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19-sources.jar.sha256 +0 -1
  98. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19-sources.jar.sha512 +0 -1
  99. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.aar +0 -0
  100. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.aar.md5 +0 -1
  101. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.aar.sha1 +0 -1
  102. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.aar.sha256 +0 -1
  103. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.aar.sha512 +0 -1
  104. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.module.md5 +0 -1
  105. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.module.sha1 +0 -1
  106. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.module.sha256 +0 -1
  107. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.module.sha512 +0 -1
  108. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.pom.md5 +0 -1
  109. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.pom.sha1 +0 -1
  110. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.pom.sha256 +0 -1
  111. package/local-maven-repo/expo/modules/observe/expo.modules.observe/58.0.19/expo.modules.observe-58.0.19.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Keep Observe inactive when the config plugin sets the `consent` option to `'not-granted'`. Observe then sends no data. ([#53709](https://github.com/expo/expo/pull/53709) by [@Ubax](https://github.com/Ubax))
8
+ - Add a config plugin with a `consent` option. Prebuild writes the consent value to `AndroidManifest.xml` and `Info.plist`. ([#53878](https://github.com/expo/expo/pull/53878) by [@Ubax](https://github.com/Ubax))
9
+ - Add `Observe.reportFeedback` to send user feedback. ([#53261](https://github.com/expo/expo/pull/53261) by [@Ubax](https://github.com/Ubax))
10
+ - Add `Observe.setConsent` to change the consent value at runtime. A grant starts collection, and a revoke stops collection and deletes the Observe data stored on the device. ([#53710](https://github.com/expo/expo/pull/53710) by [@Ubax](https://github.com/Ubax))
11
+
12
+ ### Patch Changes
13
+
14
+ - Add experimental navigation total blocking time (`tbt`) metric, enabled with `experimental_totalBlockingTime`. ([#51505](https://github.com/expo/expo/pull/51505) by [@Ubax](https://github.com/Ubax))
15
+ - Warn in development on iOS when the app privacy manifest has no user content entry for `Observe.reportFeedback`. ([#53284](https://github.com/expo/expo/pull/53284) by [@Ubax](https://github.com/Ubax))
16
+ - Add `ignoredMetrics` and `ignoredEvents` configure options to skip selected metrics and events during dispatch. ([#52524](https://github.com/expo/expo/pull/52524) by [@Ubax](https://github.com/Ubax))
17
+ - Send at most 128 attributes for each log event, and keep the `expo.*` attributes first, so the server does not drop them. ([#53615](https://github.com/expo/expo/pull/53615) by [@Ubax](https://github.com/Ubax))
18
+ - Updated dependencies. ([#51003](https://github.com/expo/expo/pull/51003), [#53973](https://github.com/expo/expo/pull/53973), [#54066](https://github.com/expo/expo/pull/54066), [#53709](https://github.com/expo/expo/pull/53709), [#53710](https://github.com/expo/expo/pull/53710), [#53688](https://github.com/expo/expo/pull/53688), [#53261](https://github.com/expo/expo/pull/53261))
19
+ - expo-app-metrics@58.1.0
20
+
3
21
  ## 58.0.19
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -120,6 +120,17 @@ See [Custom endpoint](https://docs.expo.dev/eas/observe/configuration/#custom-en
120
120
 
121
121
  `Observe.configure()` sets the environment label, the sampling rate, dispatching behavior and integrations at runtime. `Observe.dispatchEvents()` flushes pending events manually.
122
122
 
123
+ Use `ignoredMetrics` to skip exported metric names and `ignoredEvents` to skip event names, including custom names passed to `Observe.logEvent`:
124
+
125
+ ```ts
126
+ Observe.configure({
127
+ ignoredMetrics: ['expo.app_startup.tti'],
128
+ ignoredEvents: ['reanimated.warning', 'checkout.completed'],
129
+ });
130
+ ```
131
+
132
+ The lists apply at dispatch time. They do nothing on web and do not affect network traces.
133
+
123
134
  See [Configuration](https://docs.expo.dev/eas/observe/configuration/).
124
135
 
125
136
  ## Command line and agents
@@ -57,4 +57,5 @@ dependencies {
57
57
  testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.2'
58
58
  testImplementation 'io.mockk:mockk:1.13.8'
59
59
  testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'
60
+ testImplementation 'androidx.work:work-testing:2.10.5'
60
61
  }
@@ -8,5 +8,8 @@ internal const val OBSERVE_DEFAULT_BASE_URL = "https://o.expo.dev/"
8
8
 
9
9
  internal const val DISPATCH_CHUNK_SIZE = 200
10
10
 
11
+ // The database of the telemetry queues that app metrics storage replaced.
12
+ internal const val LEGACY_DATABASE_NAME = "eas_observe"
13
+
11
14
  // Log names that `errorSampleRate` applies to.
12
15
  internal val ERROR_LOG_NAMES = setOf(JS_EXCEPTION_LOG_NAME, NATIVE_EXCEPTION_LOG_NAME)
@@ -2,6 +2,7 @@ package expo.modules.observe
2
2
 
3
3
  import android.content.Context
4
4
  import android.util.Log
5
+ import expo.modules.appmetrics.ObserveConsent
5
6
  import expo.modules.easclient.EASClientID
6
7
  import kotlinx.coroutines.suspendCancellableCoroutine
7
8
  import okhttp3.MediaType.Companion.toMediaType
@@ -132,6 +133,12 @@ class EventDispatcher(
132
133
  call.cancel()
133
134
  }
134
135
 
136
+ // Checked right before the request starts, so a revoke during the preparation stops it. The
137
+ // retryable result ends the dispatch loop without moving the cursors.
138
+ if (!ObserveConsent.isGranted) {
139
+ continuation.resume(DispatchResult.RetryableFailure(retryAfterMs = null))
140
+ return
141
+ }
135
142
  val response = try {
136
143
  call.execute()
137
144
  } catch (e: Exception) {
@@ -14,7 +14,9 @@ import androidx.work.NetworkType
14
14
  import androidx.work.OneTimeWorkRequestBuilder
15
15
  import androidx.work.WorkManager
16
16
  import androidx.work.WorkerParameters
17
+ import androidx.work.await
17
18
  import androidx.work.workDataOf
19
+ import expo.modules.appmetrics.ObserveConsent
18
20
  import expo.modules.appmetrics.storage.SessionManager
19
21
 
20
22
  /**
@@ -61,6 +63,9 @@ class ObservabilityBackgroundWorker(
61
63
  }
62
64
 
63
65
  override suspend fun doWork(): Result {
66
+ if (!ObserveConsent.isGranted) {
67
+ return Result.success()
68
+ }
64
69
  return try {
65
70
  if (observabilityManager == null) {
66
71
  Log.e(OBSERVE_TAG, "ObservabilityManager is null - missing projectId or baseUrl")
@@ -83,7 +88,11 @@ class ObservabilityBackgroundWorker(
83
88
  }
84
89
 
85
90
  companion object {
86
- private const val WORK_NAME = "eas-observe-dispatch"
91
+ internal const val WORK_NAME = "eas-observe-dispatch"
92
+
93
+ suspend fun cancelBackgroundDispatch(context: Context) {
94
+ WorkManager.getInstance(context).cancelUniqueWork(WORK_NAME).await()
95
+ }
87
96
 
88
97
  fun scheduleBackgroundDispatch(
89
98
  context: Context,
@@ -2,7 +2,9 @@ package expo.modules.observe
2
2
 
3
3
  import android.content.Context
4
4
  import android.util.Log
5
+ import expo.modules.appmetrics.ObserveConsent
5
6
  import expo.modules.easclient.EASClientID
7
+ import expo.modules.appmetrics.logevents.FEEDBACK_LOG_NAME
6
8
  import expo.modules.appmetrics.storage.SessionManager
7
9
  import expo.modules.appmetrics.storage.Span
8
10
  import expo.modules.appmetrics.utils.TimeUtils
@@ -55,6 +57,9 @@ class ObservabilityManager(
55
57
  }
56
58
 
57
59
  fun scheduleBackgroundDispatch() {
60
+ if (!ObserveConsent.isGranted) {
61
+ return
62
+ }
58
63
  ObservabilityBackgroundWorker.scheduleBackgroundDispatch(
59
64
  context = context,
60
65
  projectId = baseManager.projectId,
@@ -130,12 +135,16 @@ class BaseObservabilityManager(
130
135
  )
131
136
 
132
137
  suspend fun dispatchUnsentMetrics(): Unit = metricsDispatchMutex.withLock {
138
+ if (!ObserveConsent.isGranted) {
139
+ return
140
+ }
133
141
  if (retryGateBlocks(metricsRetryGate, "metrics")) {
134
142
  return
135
143
  }
136
144
 
137
145
  repairMetricCursorIfStale(context, sessionManager)
138
146
  val config = ObservePreferences.getConfig(context)
147
+ val ignoredMetrics = config?.ignoredMetrics?.toSet() ?: emptySet()
139
148
  if (!shouldDispatch(config, config?.sampleRate)) {
140
149
  val maxId = sessionManager.getMaxMetricId() ?: -1
141
150
  if (ObservePreferences.getLastDispatchedMetricId(context) != maxId) {
@@ -154,7 +163,9 @@ class BaseObservabilityManager(
154
163
  }
155
164
 
156
165
  val highestId = metrics.last().id
157
- val metricsBySessionId = metrics.groupBy { it.sessionId }
166
+ val metricsBySessionId = metrics
167
+ .filterNot { exportedMetricName(it.category, it.name) in ignoredMetrics }
168
+ .groupBy { it.sessionId }
158
169
  val sessions = sessionManager.getSessions(metricsBySessionId.keys).associateBy { it.id }
159
170
  val events = metricsBySessionId.mapNotNull { (sessionId, sessionMetrics) ->
160
171
  sessions[sessionId]?.let { session ->
@@ -210,16 +221,22 @@ class BaseObservabilityManager(
210
221
  * a logs failure doesn't affect the metrics cursor and vice versa.
211
222
  */
212
223
  suspend fun dispatchUnsentLogs(): Unit = logsDispatchMutex.withLock {
224
+ if (!ObserveConsent.isGranted) {
225
+ return
226
+ }
213
227
  if (retryGateBlocks(logsRetryGate, "logs")) {
214
228
  return
215
229
  }
216
230
 
217
231
  repairLogCursorIfStale(context, sessionManager)
218
232
  val config = ObservePreferences.getConfig(context)
233
+ val ignoredEvents = config?.ignoredEvents?.toSet() ?: emptySet()
219
234
  // Installations in-sample for `sampleRate` send all logs. Errors use the higher of the two rates.
235
+ // Feedback uses no rate, so it is sent whenever this installation can send any logs.
220
236
  val dispatchLogsAndErrors = shouldDispatch(config, config?.sampleRate)
221
237
  val dispatchErrors = shouldDispatch(config, config?.errorSampleRate ?: config?.sampleRate)
222
- if (!dispatchLogsAndErrors && !dispatchErrors) {
238
+ val dispatchAnyLogs = shouldDispatch(config, null)
239
+ if (!dispatchAnyLogs) {
223
240
  val maxId = sessionManager.getMaxLogId() ?: -1
224
241
  if (ObservePreferences.getLastDispatchedLogId(context) != maxId) {
225
242
  ObservePreferences.setLastDispatchedLogId(context, maxId)
@@ -240,8 +257,15 @@ class BaseObservabilityManager(
240
257
  val sampledLogs = if (dispatchLogsAndErrors) {
241
258
  logs
242
259
  } else {
243
- logs.filter { it.name in ERROR_LOG_NAMES }
244
- }
260
+ val supportedLogNames = (
261
+ if (dispatchErrors) {
262
+ ERROR_LOG_NAMES
263
+ } else {
264
+ emptySet()
265
+ }
266
+ ) + FEEDBACK_LOG_NAME
267
+ logs.filter { it.name in supportedLogNames }
268
+ }.filterNot { it.name in ignoredEvents }
245
269
  val logsBySessionId = sampledLogs.groupBy { it.sessionId }
246
270
  val sessions = sessionManager.getSessions(logsBySessionId.keys).associateBy { it.id }
247
271
  val events = logsBySessionId.mapNotNull { (sessionId, sessionLogs) ->
@@ -303,6 +327,9 @@ class BaseObservabilityManager(
303
327
  * server's per-request span limit.
304
328
  */
305
329
  suspend fun dispatchUnsentSpans(): Unit = spansDispatchMutex.withLock {
330
+ if (!ObserveConsent.isGranted) {
331
+ return
332
+ }
306
333
  if (retryGateBlocks(spansRetryGate, "spans")) {
307
334
  return
308
335
  }
@@ -399,8 +426,7 @@ class BaseObservabilityManager(
399
426
  suspend fun cleanup() {
400
427
  // TODO(@ubax): Move sessionManager.cleanupOldSessions out of eas observe
401
428
  sessionManager.cleanupOldSessions()
402
- // Remove the database used by the old pending telemetry queues.
403
- context.deleteDatabase("eas_observe")
429
+ context.deleteDatabase(LEGACY_DATABASE_NAME)
404
430
  sessionManager.cleanupOldLogs()
405
431
  }
406
432
 
@@ -3,6 +3,7 @@ package expo.modules.observe
3
3
  import android.content.Context
4
4
  import android.util.Log
5
5
  import expo.modules.appmetrics.AppMetricsModule
6
+ import expo.modules.appmetrics.ObserveConsent
6
7
  import expo.modules.easclient.EASClientID
7
8
  import expo.modules.interfaces.constants.ConstantsInterface
8
9
  import expo.modules.kotlin.exception.Exceptions
@@ -11,7 +12,9 @@ import expo.modules.kotlin.modules.Module
11
12
  import expo.modules.kotlin.modules.ModuleDefinition
12
13
  import expo.modules.kotlin.records.Field
13
14
  import expo.modules.kotlin.records.Record
15
+ import expo.modules.kotlin.types.Enumerable
14
16
  import expo.modules.kotlin.types.OptimizedRecord
17
+ import kotlinx.coroutines.CancellationException
15
18
 
16
19
  @OptimizedRecord
17
20
  class Config(
@@ -20,6 +23,8 @@ class Config(
20
23
  @Field val dispatchInDebug: Boolean? = null,
21
24
  @Field val sampleRate: Double? = null,
22
25
  @Field val errorSampleRate: Double? = null,
26
+ @Field val ignoredMetrics: List<String> = emptyList(),
27
+ @Field val ignoredEvents: List<String> = emptyList(),
23
28
  @Field val integrations: Map<String, Any?>? = null
24
29
  ) : Record
25
30
 
@@ -29,6 +34,11 @@ class BundleDefaults(
29
34
  @Field val isJsDev: Boolean = false
30
35
  ) : Record
31
36
 
37
+ internal enum class ConsentValue(val value: String) : Enumerable {
38
+ GRANTED("granted"),
39
+ NOT_GRANTED("not-granted")
40
+ }
41
+
32
42
  class ObserveModule : Module() {
33
43
  private val context: Context
34
44
  get() = appContext.reactContext ?: throw Exceptions.ReactContextLost()
@@ -45,6 +55,12 @@ class ObserveModule : Module() {
45
55
  Events("configure")
46
56
 
47
57
  OnCreate {
58
+ // Deletes what a build with consent stored. Module start is late enough, because nothing is
59
+ // sent without consent.
60
+ if (!ObserveConsent.isGranted) {
61
+ context.deleteDatabase(LEGACY_DATABASE_NAME)
62
+ ObservePreferences.deleteStoredSettings(context)
63
+ }
48
64
  appMetricsModule = checkNotNull(appContext.registry.getModule<AppMetricsModule>()) {
49
65
  "AppMetricsModule is required by ObserveModule. Make sure expo-app-metrics is installed."
50
66
  }
@@ -64,6 +80,10 @@ class ObserveModule : Module() {
64
80
  EASClientID(context).uuid.toString().lowercase()
65
81
  }
66
82
 
83
+ AsyncFunction("setConsent") Coroutine { consent: ConsentValue ->
84
+ applyConsent(context, consent, appMetricsModule::setConsent)
85
+ }
86
+
67
87
  AsyncFunction("dispatchEvents") Coroutine { ->
68
88
  observabilityManager.dispatchUnsentMetrics()
69
89
  observabilityManager.dispatchUnsentLogs()
@@ -77,7 +97,9 @@ class ObserveModule : Module() {
77
97
  dispatchingEnabled = config.dispatchingEnabled,
78
98
  dispatchInDebug = config.dispatchInDebug,
79
99
  sampleRate = config.sampleRate,
80
- errorSampleRate = config.errorSampleRate
100
+ errorSampleRate = config.errorSampleRate,
101
+ ignoredMetrics = config.ignoredMetrics,
102
+ ignoredEvents = config.ignoredEvents
81
103
  )
82
104
  )
83
105
  // Environment falls back to the bundle default (set on JS package import) so an
@@ -115,3 +137,60 @@ class ObserveModule : Module() {
115
137
  }
116
138
  }
117
139
  }
140
+
141
+ /**
142
+ * Applies `Observe.setConsent`. A revoke deletes the Observe data under the app metrics consent
143
+ * lock, after the gate closes, also when the consent save failed. A failed consent save is reported
144
+ * before a failed delete.
145
+ */
146
+ internal suspend fun applyConsent(
147
+ context: Context,
148
+ consent: ConsentValue,
149
+ setAppMetricsConsent: suspend (Boolean, suspend () -> Unit) -> Unit
150
+ ) {
151
+ var deleteError: Exception? = null
152
+ try {
153
+ setAppMetricsConsent(consent == ConsentValue.GRANTED) {
154
+ try {
155
+ deleteObserveData(context)
156
+ } catch (e: CancellationException) {
157
+ throw e
158
+ } catch (e: Exception) {
159
+ deleteError = e
160
+ }
161
+ }
162
+ } catch (e: CancellationException) {
163
+ throw e
164
+ } catch (e: Exception) {
165
+ deleteError?.let(e::addSuppressed)
166
+ throw e
167
+ }
168
+ deleteError?.let { throw it }
169
+ }
170
+
171
+ /**
172
+ * Deletes the Observe settings, the dispatch cursors among them, and the scheduled dispatch. Each
173
+ * step runs also when an earlier step fails. The first error is thrown, with the others attached.
174
+ */
175
+ internal suspend fun deleteObserveData(context: Context) {
176
+ var error: Exception? = null
177
+ // The local deletes first, because they do not suspend. So a canceled dispatch cancel cannot
178
+ // skip them.
179
+ val localDeletes = listOf({ context.deleteDatabase(LEGACY_DATABASE_NAME) }, { ObservePreferences.deleteStoredSettings(context) })
180
+ for (delete in localDeletes) {
181
+ try {
182
+ delete()
183
+ } catch (e: Exception) {
184
+ error?.addSuppressed(e) ?: run { error = e }
185
+ }
186
+ }
187
+ try {
188
+ ObservabilityBackgroundWorker.cancelBackgroundDispatch(context)
189
+ } catch (e: CancellationException) {
190
+ error?.let(e::addSuppressed)
191
+ throw e
192
+ } catch (e: Exception) {
193
+ error?.addSuppressed(e) ?: run { error = e }
194
+ }
195
+ error?.let { throw it }
196
+ }
@@ -1,7 +1,7 @@
1
1
  package expo.modules.observe
2
2
 
3
3
  import android.content.Context
4
- import androidx.core.content.edit
4
+ import expo.modules.appmetrics.ConsentGatedPreferences
5
5
  import kotlinx.serialization.Serializable
6
6
  import kotlinx.serialization.json.Json
7
7
 
@@ -19,7 +19,9 @@ data class PersistedConfig(
19
19
  val dispatchingEnabled: Boolean? = null,
20
20
  val dispatchInDebug: Boolean? = null,
21
21
  val sampleRate: Double? = null,
22
- val errorSampleRate: Double? = null
22
+ val errorSampleRate: Double? = null,
23
+ val ignoredMetrics: List<String> = emptyList(),
24
+ val ignoredEvents: List<String> = emptyList()
23
25
  )
24
26
 
25
27
  /**
@@ -32,49 +34,41 @@ data class PersistedBundleDefaults(
32
34
  )
33
35
 
34
36
  object ObservePreferences {
37
+ private val preferences = ConsentGatedPreferences(PREFS_NAME)
38
+
35
39
  fun getConfig(context: Context): PersistedConfig? {
36
- val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
37
- val json = prefs.getString(KEY_CONFIG, null) ?: return null
40
+ val json = preferences.getString(context, KEY_CONFIG) ?: return null
38
41
  return runCatching { Json.decodeFromString<PersistedConfig>(json) }.getOrNull()
39
42
  }
40
43
 
41
44
  fun setConfig(context: Context, config: PersistedConfig) {
42
- val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
43
- prefs.edit(commit = true) {
44
- putString(KEY_CONFIG, Json.encodeToString(config))
45
- }
45
+ preferences.putString(context, KEY_CONFIG, Json.encodeToString(config))
46
46
  }
47
47
 
48
48
  fun getBundleDefaults(context: Context): PersistedBundleDefaults? {
49
- val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
50
- val json = prefs.getString(KEY_BUNDLE_DEFAULTS, null) ?: return null
49
+ val json = preferences.getString(context, KEY_BUNDLE_DEFAULTS) ?: return null
51
50
  return runCatching { Json.decodeFromString<PersistedBundleDefaults>(json) }.getOrNull()
52
51
  }
53
52
 
54
53
  fun setBundleDefaults(context: Context, defaults: PersistedBundleDefaults) {
55
- val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
56
- prefs.edit {
57
- putString(KEY_BUNDLE_DEFAULTS, Json.encodeToString(defaults))
58
- }
54
+ preferences.putString(context, KEY_BUNDLE_DEFAULTS, Json.encodeToString(defaults), commit = false)
59
55
  }
60
56
 
61
57
  fun getLastDispatchedMetricId(context: Context): Long =
62
- context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
63
- .getLong(KEY_LAST_DISPATCHED_METRIC_ID, -1)
58
+ preferences.getLong(context, KEY_LAST_DISPATCHED_METRIC_ID, -1)
64
59
 
65
60
  fun setLastDispatchedMetricId(context: Context, id: Long) {
66
- context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit(commit = true) {
67
- putLong(KEY_LAST_DISPATCHED_METRIC_ID, id)
68
- }
61
+ preferences.putLong(context, KEY_LAST_DISPATCHED_METRIC_ID, id)
69
62
  }
70
63
 
71
64
  fun getLastDispatchedLogId(context: Context): Long =
72
- context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
73
- .getLong(KEY_LAST_DISPATCHED_LOG_ID, -1)
65
+ preferences.getLong(context, KEY_LAST_DISPATCHED_LOG_ID, -1)
74
66
 
75
67
  fun setLastDispatchedLogId(context: Context, id: Long) {
76
- context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit(commit = true) {
77
- putLong(KEY_LAST_DISPATCHED_LOG_ID, id)
78
- }
68
+ preferences.putLong(context, KEY_LAST_DISPATCHED_LOG_ID, id)
69
+ }
70
+
71
+ internal fun deleteStoredSettings(context: Context) {
72
+ preferences.delete(context)
79
73
  }
80
74
  }
@@ -258,7 +258,7 @@ data class OTServiceResponse(
258
258
  */
259
259
  internal const val SEMCONV_SCHEMA_URL = "https://opentelemetry.io/schemas/1.27.0"
260
260
 
261
- // This must be kept in sync with the INTERNAL_TO_OTEL map in universe
261
+ // Keep in sync with INTERNAL_TO_OTEL in universe and `ObserveMetricName` in `src/types.ts`:
262
262
  // https://github.com/expo/universe/blob/main/server/www/src/middleware/easObserveRoutes.ts#L209
263
263
  private val metricNameMap = mapOf(
264
264
  // App startup
@@ -279,9 +279,13 @@ private val metricNameMap = mapOf(
279
279
  // Navigation
280
280
  (MetricCategory.Navigation.categoryName to "cold_ttr") to "expo.navigation.cold_ttr",
281
281
  (MetricCategory.Navigation.categoryName to "warm_ttr") to "expo.navigation.warm_ttr",
282
- (MetricCategory.Navigation.categoryName to "tti") to "expo.navigation.tti"
282
+ (MetricCategory.Navigation.categoryName to "tti") to "expo.navigation.tti",
283
+ (MetricCategory.Navigation.categoryName to "tbt") to "expo.navigation.tbt"
283
284
  )
284
285
 
286
+ internal fun exportedMetricName(category: String, name: String): String =
287
+ metricNameMap[category to name] ?: "expo.unknown.$name"
288
+
285
289
  fun EASMetric.toOTMetric(): OTMetric {
286
290
  val attributes = mutableListOf(
287
291
  OTAttribute.of(key = "session.id", rawValue = sessionId)
@@ -298,7 +302,7 @@ fun EASMetric.toOTMetric(): OTMetric {
298
302
 
299
303
  return OTMetric(
300
304
  unit = "s",
301
- name = metricNameMap[category to name] ?: "expo.unknown.$name",
305
+ name = exportedMetricName(category, name),
302
306
  gauge = OTGauge(
303
307
  dataPoints = listOf(
304
308
  OTDataPoint(
@@ -422,11 +426,13 @@ fun LogEvent.toOTLogRecord(): OTLogRecord {
422
426
  var encodeTimeDrops = 0
423
427
  this.attributes?.let { attrs ->
424
428
  val (typed, dropped) = otAttributesFromJsonObject(attrs)
425
- attributes.addAll(typed)
429
+ // The ingest keeps only the first `MAX_LOG_ATTRIBUTE_COUNT` attributes, so SDK `expo.*` keys go first.
430
+ attributes.addAll(typed.sortedWith(compareBy({ !it.key.startsWith("expo.") }, { it.key })))
426
431
  encodeTimeDrops = dropped
427
432
  }
433
+ val limitDrops = maxOf(attributes.size - MAX_LOG_ATTRIBUTE_COUNT, 0)
428
434
 
429
- val totalDrops = droppedAttributesCount + encodeTimeDrops
435
+ val totalDrops = droppedAttributesCount + encodeTimeDrops + limitDrops
430
436
  val timeNs = timestampToDateNS(timestamp)
431
437
  // Both `severityNumber` and `severityText` come off the same enum case so
432
438
  // they can't disagree. Unknown raw values (e.g. a future case shipped on JS
@@ -439,7 +445,7 @@ fun LogEvent.toOTLogRecord(): OTLogRecord {
439
445
  severityNumber = resolvedSeverity.severityNumber,
440
446
  severityText = resolvedSeverity.severityText,
441
447
  body = OTStringValue(stringValue = body ?: ""),
442
- attributes = attributes,
448
+ attributes = attributes.take(MAX_LOG_ATTRIBUTE_COUNT),
443
449
  droppedAttributesCount = if (totalDrops > 0) {
444
450
  totalDrops
445
451
  } else {
@@ -486,6 +492,9 @@ fun Event.toOTResourceSpans(easClientId: String, spans: List<OTSpan>): OTResourc
486
492
  */
487
493
  private const val MAX_SPAN_EVENT_COUNT = 32
488
494
 
495
+ // Maximum attributes the ingestion endpoint keeps per log record.
496
+ private const val MAX_LOG_ATTRIBUTE_COUNT = 128
497
+
489
498
  /**
490
499
  * Converts a persisted unix-epoch millisecond timestamp to nanoseconds, saturating instead of
491
500
  * overflowing: a corrupt row or a device clock set far into the future must never wrap into a
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build/withObserve');
package/build/index.d.ts CHANGED
@@ -12,5 +12,5 @@ export { ObserveRoot } from './ObserveRoot';
12
12
  export { Observe };
13
13
  /** @deprecated Import the named `Observe` export instead. */
14
14
  export default Observe;
15
- export type { ObserveAttribute, ObserveAttributes, ObserveConfig, ObserveIntegrationsConfig, ObserveModule, ObserveModuleEvents, ObserveNavigationIntegrationConfig, ObserveNetworkTracesConfig, ObserveReanimatedIntegrationConfig, } from './types';
15
+ export type { ObserveAttribute, ObserveAttributes, ObserveConfig, ObserveConsent, ObserveEventName, ObserveFeedback, ObserveIntegrationsConfig, ObserveModule, ObserveModuleEvents, ObserveMetricName, ObserveNavigationIntegrationConfig, ObserveNetworkTracesConfig, ObserveReanimatedIntegrationConfig, } from './types';
16
16
  export { useObserve } from './useObserve';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":[null],"names":["Observe","default","AppMetrics","ObserveErrorBoundary","ObserveInteractiveMarker","ObserveRoot","setBundleDefaults","environment","process","env","NODE_ENV","isJsDev","__DEV__","useObserve"],"mappings":"AAAA,OAAOA,aAAa,WAAW;AAE/B;;CAEC,GACD,SAASC,WAAWC,UAAU,QAAQ,mBAAmB;AAiBzD,SAASC,oBAAoB,QAAQ,yBAAyB;AAK9D,SAASC,wBAAwB,QAAQ,6BAA6B;AAEtE,SAASC,WAAW,QAAQ,gBAAgB;AAE5CL,QAAQM,iBAAiB,CAAC;IACxBC,aAAaC,QAAQC,GAAG,CAACC,QAAQ,IAAI;IACrCC,SAAS,CAAC,CAACC;AACb;AAEA,SAASZ,OAAO,GAAG;AAEnB,2DAA2D,GAC3D,eAAeA,QAAQ;AAavB,SAASa,UAAU,QAAQ,eAAe"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":[null],"names":["Observe","default","AppMetrics","ObserveErrorBoundary","ObserveInteractiveMarker","ObserveRoot","setBundleDefaults","environment","process","env","NODE_ENV","isJsDev","__DEV__","useObserve"],"mappings":"AAAA,OAAOA,aAAa,WAAW;AAE/B;;CAEC,GACD,SAASC,WAAWC,UAAU,QAAQ,mBAAmB;AAiBzD,SAASC,oBAAoB,QAAQ,yBAAyB;AAK9D,SAASC,wBAAwB,QAAQ,6BAA6B;AAEtE,SAASC,WAAW,QAAQ,gBAAgB;AAE5CL,QAAQM,iBAAiB,CAAC;IACxBC,aAAaC,QAAQC,GAAG,CAACC,QAAQ,IAAI;IACrCC,SAAS,CAAC,CAACC;AACb;AAEA,SAASZ,OAAO,GAAG;AAEnB,2DAA2D,GAC3D,eAAeA,QAAQ;AAiBvB,SAASa,UAAU,QAAQ,eAAe"}
@@ -1,5 +1,6 @@
1
1
  import AppMetrics from 'expo-app-metrics';
2
- import { getNavigationMetricParams } from '../navigationConfig';
2
+ import { getNavigationMetricParams, isTotalBlockingTimeEnabled } from '../navigationConfig';
3
+ import { createNavigationBlockingTime } from '../shared/navigation/blockingTime';
3
4
  import { emitTTI } from './emitTTI';
4
5
  import { buildRoutePattern } from './routeName';
5
6
  import { optionalRouter } from './router';
@@ -19,6 +20,7 @@ export function initRouterIntegration(config) {
19
20
  }
20
21
  export function initListeners(storage, PerformanceObserver) {
21
22
  const appLaunchTime = performance.now();
23
+ const blockingTime = isTotalBlockingTimeEnabled(routerIntegrationConfig) ? createNavigationBlockingTime((metric)=>AppMetrics.getMainSession().addMetric(metric)) : undefined;
22
24
  const observer = new PerformanceObserver((list)=>{
23
25
  for (const performanceEntry of list.getEntries()){
24
26
  // Marks with the names handled below always have the matching `detail`.
@@ -40,10 +42,13 @@ export function initListeners(storage, PerformanceObserver) {
40
42
  // PRELOAD comes from router.prefetch() — a route warm-up, not a user
41
43
  // navigation — so it must not become a TTR start.
42
44
  if (entry.detail.actionType === 'PRELOAD') break;
45
+ const startTime = enqueueTime ?? entry.startTime;
43
46
  storage.pendingActions.push({
44
47
  actionType: entry.detail.actionType,
45
- startTime: enqueueTime ?? entry.startTime
48
+ startTime
46
49
  });
50
+ // Navigations before the first screen is focused are part of app launch.
51
+ if (storage.hasRecordedInitialTtr) blockingTime?.start(startTime);
47
52
  break;
48
53
  }
49
54
  case 'expo-router:page-preloaded':
@@ -68,7 +73,8 @@ export function initListeners(storage, PerformanceObserver) {
68
73
  // sees the pre-focus state of this screen. A pending interactive means
69
74
  // `markInteractive` ran before this focus landed.
70
75
  const existingFocusedScreenTimes = storage.screenTimes[e.screenId];
71
- const hasPendingInteractive = existingFocusedScreenTimes?.lastInteractiveCall != null && existingFocusedScreenTimes?.dispatchTime == null;
76
+ const isFirstFocus = existingFocusedScreenTimes?.dispatchTime == null;
77
+ const hasPendingInteractive = isFirstFocus && existingFocusedScreenTimes?.lastInteractiveCall != null;
72
78
  const isInitial = !storage.renderedScreensIds.has(e.screenId);
73
79
  storage.renderedScreensIds.add(e.screenId);
74
80
  const name = isInitial ? 'cold_ttr' : 'warm_ttr';
@@ -119,6 +125,15 @@ export function initListeners(storage, PerformanceObserver) {
119
125
  ...navigationParams
120
126
  }
121
127
  });
128
+ if (!isAppLaunch && isFirstFocus) {
129
+ blockingTime?.setMetric({
130
+ timestamp,
131
+ category: 'navigation',
132
+ name: 'tbt',
133
+ routeName: routePattern,
134
+ params: navigationParams
135
+ }, now);
136
+ }
122
137
  if (hasPendingInteractive) {
123
138
  await emitTTI({
124
139
  session: mainSession,
@@ -132,7 +147,10 @@ export function initListeners(storage, PerformanceObserver) {
132
147
  });
133
148
  }
134
149
  }
135
- return ()=>observer.disconnect();
150
+ return ()=>{
151
+ observer.disconnect();
152
+ blockingTime?.dispose();
153
+ };
136
154
  }
137
155
 
138
156
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["integrations/expo-router/init.ts"],"sourcesContent":[null],"names":["AppMetrics","getNavigationMetricParams","emitTTI","buildRoutePattern","optionalRouter","MAX_ENQUEUE_TIMES","initialized","routerIntegrationConfig","isInitialized","getRouterIntegrationConfig","initRouterIntegration","config","unstable_enablePerformanceIntegration","initListeners","storage","PerformanceObserver","appLaunchTime","performance","now","observer","list","performanceEntry","getEntries","entry","name","enqueueTimes","set","detail","actionId","startTime","size","delete","keys","next","value","enqueueTime","undefined","get","actionType","pendingActions","push","renderedScreensIds","add","screenId","onPageFocused","observe","type","e","timestamp","Date","toISOString","existingFocusedScreenTimes","screenTimes","hasPendingInteractive","lastInteractiveCall","dispatchTime","isInitial","has","routePattern","segments","isAppLaunch","hasRecordedInitialTtr","last","length","ttrSeconds","interactiveScreensIds","mainSession","getMainSession","navigationParams","params","pathname","addMetric","category","routeName","session","routeParams","url","disconnect"],"mappings":"AAAA,OAAOA,gBAAgB,mBAAmB;AAG1C,SAASC,yBAAyB,QAAQ,sBAAsB;AAChE,SAASC,OAAO,QAAQ,YAAY;AACpC,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,MAAMqC,YAAW,IAAK;QAE1C,qEAAqE;QACrE,qEAAqE;QACrE,mDAAmD;QACnDzC,QAAQsC,WAAW,CAACL,EAAEJ,QAAQ,CAAC,GAAG;YAChC,GAAG7B,QAAQsC,WAAW,CAACL,EAAEJ,QAAQ,CAAC;YAClCY;YACAK;YACA,GAAIP,wBAAwB;gBAAEC,qBAAqBpC;YAAI,IAAI,CAAC,CAAC;QAC/D;QACA,IAAImC,uBAAuB;YACzB,mEAAmE;YACnE,6DAA6D;YAC7DvC,QAAQmD,qBAAqB,CAACvB,GAAG,CAACK,EAAEJ,QAAQ;QAC9C;QAEA,MAAMuB,cAAclE,WAAWmE,cAAc;QAC7C,MAAMC,mBAAmBnE,0BACvBM,yBACAwC,EAAEsB,MAAM,EACRtB,EAAEuB,QAAQ;QAGZJ,YAAYK,SAAS,CAAC;YACpBvB;YACAwB,UAAU;YACVhD;YACAiD,WAAWf;YACXxB,OAAO8B;YACPK,QAAQ;gBAAET;gBAAa,GAAGQ,gBAAgB;YAAC;QAC7C;QACA,IAAIf,uBAAuB;YACzB,MAAMnD,QAAQ;gBACZwE,SAASR;gBACTlB;gBACAyB,WAAWf;gBACXxB,OAAO8B;gBACPJ;gBACAe,aAAa5B,EAAEsB,MAAM;gBACrBO,KAAK7B,EAAEuB,QAAQ;gBACf3D,QAAQJ;YACV;QACF;IACF;IAEA,OAAO,IAAMY,SAAS0D,UAAU;AAClC"}
1
+ {"version":3,"sources":["integrations/expo-router/init.ts"],"sourcesContent":[null],"names":["AppMetrics","getNavigationMetricParams","isTotalBlockingTimeEnabled","createNavigationBlockingTime","emitTTI","buildRoutePattern","optionalRouter","MAX_ENQUEUE_TIMES","initialized","routerIntegrationConfig","isInitialized","getRouterIntegrationConfig","initRouterIntegration","config","unstable_enablePerformanceIntegration","initListeners","storage","PerformanceObserver","appLaunchTime","performance","now","blockingTime","metric","getMainSession","addMetric","undefined","observer","list","performanceEntry","getEntries","entry","name","enqueueTimes","set","detail","actionId","startTime","size","delete","keys","next","value","enqueueTime","get","actionType","pendingActions","push","hasRecordedInitialTtr","start","renderedScreensIds","add","screenId","onPageFocused","observe","type","e","timestamp","Date","toISOString","existingFocusedScreenTimes","screenTimes","isFirstFocus","dispatchTime","hasPendingInteractive","lastInteractiveCall","isInitial","has","routePattern","segments","isAppLaunch","last","length","ttrSeconds","interactiveScreensIds","mainSession","navigationParams","params","pathname","category","routeName","setMetric","session","routeParams","url","disconnect","dispose"],"mappings":"AAAA,OAAOA,gBAAgB,mBAAmB;AAG1C,SAASC,yBAAyB,EAAEC,0BAA0B,QAAQ,sBAAsB;AAC5F,SAASC,4BAA4B,QAAQ,oCAAoC;AACjF,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SACEC,cAAc,QAIT,WAAW;AAGlB,+EAA+E;AAC/E,8EAA8E;AAC9E,0EAA0E;AAC1E,gEAAgE;AAEhE,MAAMC,oBAAoB;AAE1B,IAAIC,cAAc;AAClB,IAAIC;AAEJ,OAAO,MAAMC,gBAAgB,IAAMF,YAAY;AAC/C,OAAO,MAAMG,6BAA6B,IAAMF,wBAAwB;AAExE,OAAO,SAASG,sBAAsBC,MAAiD;IACrFL,cAAc;IACdC,0BAA0BI;IAC1BP,gBAAgBQ;AAClB;AAEA,OAAO,SAASC,cACdC,OAAiC,EACjCC,mBAA8C;IAE9C,MAAMC,gBAAgBC,YAAYC,GAAG;IACrC,MAAMC,eAAenB,2BAA2BO,2BAC5CN,6BAA6B,CAACmB,SAAWtB,WAAWuB,cAAc,GAAGC,SAAS,CAACF,WAC/EG;IAEJ,MAAMC,WAAW,IAAIT,oBAAoB,CAACU;QACxC,KAAK,MAAMC,oBAAoBD,KAAKE,UAAU,GAAI;YAChD,wEAAwE;YACxE,MAAMC,QAAQF;YACd,OAAQE,MAAMC,IAAI;gBAChB,KAAK;oBACHf,QAAQgB,YAAY,CAACC,GAAG,CAACH,MAAMI,MAAM,CAACC,QAAQ,EAAEL,MAAMM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YACAgD,WAAWZ;YACX1B,OAAO+B;YACPI,QAAQ;gBAAEP;gBAAa,GAAGM,gBAAgB;YAAC;QAC7C;QACA,IAAI,CAACN,eAAeR,cAAc;YAChCxC,cAAc2D,UACZ;gBACExB;gBACAsB,UAAU;gBACV/C,MAAM;gBACNgD,WAAWZ;gBACXS,QAAQD;YACV,GACAvD;QAEJ;QACA,IAAI2C,uBAAuB;YACzB,MAAM3D,QAAQ;gBACZ6E,SAASP;gBACTlB;gBACAuB,WAAWZ;gBACX1B,OAAO+B;gBACPH;gBACAa,aAAa3B,EAAEqB,MAAM;gBACrBO,KAAK5B,EAAEsB,QAAQ;gBACfhE,QAAQJ;YACV;QACF;IACF;IAEA,OAAO;QACLiB,SAAS0D,UAAU;QACnB/D,cAAcgE;IAChB;AACF"}
@@ -13,6 +13,7 @@ type NavigationRouteParams = {
13
13
  routeParams: Record<string, unknown>;
14
14
  urlHidden?: true;
15
15
  };
16
+ export declare function isTotalBlockingTimeEnabled(config: NavigationIntegrationConfig): boolean;
16
17
  export declare function getNavigationRouteParams(config: NavigationIntegrationConfig, params: object | undefined): NavigationRouteParams;
17
18
  export declare function getNavigationMetricParams(config: NavigationIntegrationConfig, routeParams: object | undefined, url: string | undefined): NavigationMetricParams;
18
19
  export {};
@@ -4,6 +4,9 @@ function getFilteredParamKeys(config) {
4
4
  const keys = new Set(filteredParams.filter((key)=>typeof key === 'string'));
5
5
  return keys.size > 0 ? keys : null;
6
6
  }
7
+ export function isTotalBlockingTimeEnabled(config) {
8
+ return !!config && typeof config === 'object' && config.experimental_totalBlockingTime === true;
9
+ }
7
10
  function prepareNavigationRouteParams(config, params) {
8
11
  const filteredKeys = getFilteredParamKeys(config);
9
12
  let urlHidden = false;