You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/platforms/android/common/performance/instrumentation/automatic-instrumentation.mdx
+40-6Lines changed: 40 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -226,24 +226,58 @@ For more information see our [file I/O integration](/platforms/android/configura
226
226
227
227
### User Interaction Instrumentation
228
228
229
+
The UI instrumentation, once enabled, captures transactions for a set of different user interactions, which include clicks, scrolls, and swipes. User interaction instrumentation is available for both classic Android Views as well as Jetpack Compose.
230
+
231
+
This feature is disabled by default, but you can enable it by setting:
#### User Interaction Instrumentation for Classic Android View System
240
+
229
241
_(New in version 6.0.0)_
230
242
231
-
The UI instrumentation, once enabled, captures transactions for a set of different user interactions, which include clicks, scrolls and swipes. The SDK composes the transaction name out of the host `Activity` and the `id` of the view, which captured the user interaction; for example, `LoginActivity.login_button`. The transaction operation is set to `ui.action` plus the interaction type (one of `click`, `scroll` or `swipe`).
243
+
The SDK composes the transaction name out of the host `Activity` and the `id` of the view that captured the user interaction — for example, for `LoginActivity.login_button`. The transaction operation is set to `ui.action` plus the interaction type (one of `click`, `scroll`, or `swipe`).
232
244
233
245
<Note>
234
246
235
247
If the view doesn't have the `id` assigned, the transaction won't be captured because it can't be uniquely identified otherwise.
236
248
237
249
</Note>
238
250
239
-
The UI instrumentation is disabled by default, but you can enable it by setting:
251
+
#### User Interaction Instrumentation for Jetpack Compose
The SDK composes the transaction name out of the host `Activity` and the `tag` set by way of the `Modifier.testTag("<tag>")` of the `Composable` (for example, `LoginActivity.login_button`). The transaction operation is set to `ui.action` plus the interaction type (one of `click`, `scroll`, or `swipe`).
256
+
257
+
```kotlin
258
+
importandroidx.compose.ui.platform.testTag
259
+
260
+
@Composable
261
+
funLoginScreen() {
262
+
Column {
263
+
// ...
264
+
Button(
265
+
modifier =Modifier.testTag("button_login"),
266
+
onClick = { TODO() }) {
267
+
Text(text ="Login")
268
+
}
269
+
}
270
+
}
245
271
```
246
272
273
+
<Note>
274
+
275
+
If the `@Composable` doesn't have a `testTag` modifier applied, the transaction won't be captured because it can't be uniquely identified otherwise.
276
+
277
+
</Note>
278
+
279
+
#### Transaction Lifetime
280
+
247
281
The transaction finishes automatically after it reaches the specified [idleTimeout](/platforms/android/configuration/options/#idle-timeout) and all of its child spans are finished. The `idleTimeoout` defaults to `3000` milliseconds (three seconds). You can also disable the idle timeout by setting it to `null`, but the transaction must be finished manually in this case.
Copy file name to clipboardExpand all lines: src/platforms/android/configuration/integrations/jetpack-compose.mdx
+78-9Lines changed: 78 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,82 @@ categories:
8
8
- mobile
9
9
---
10
10
11
-
The `sentry-compose` library provides [Jetpack Compose](https://developer.android.com/jetpack/androidx/releases/compose) Navigation support for Sentry.
11
+
The `sentry-compose-android` library provides [Jetpack Compose](https://developer.android.com/jetpack/androidx/releases/compose) support for the following interactions:
12
+
* User interactions like clicks, swipes and scroll gestures
13
+
* Jetpack Compose navigation
12
14
13
-
On this page, we get you up and running with Sentry's Compose Navigation Integration, so that it will automatically add a breadcrumb and start a transaction for each navigation event.
15
+
## User Interactions
16
+
_(New in version 6.10.0)_
14
17
15
-
##Auto-Installation With the Sentry Android Gradle Plugin
18
+
### Installation
16
19
17
-
### Install
20
+
To add the Jetpack Compose integration, install the [Android SDK](/platforms/android/), then add the `sentry-compose-android` dependency using Gradle:
If you initialize the SDK [manually as mentioned here](/platforms/android/configuration/manual-init/), you can enable user interactions like this:
42
+
```kotlin {filename:MyApplication.kt}
43
+
SentryAndroid.init(this) { options ->
44
+
// ...
45
+
options.isEnableUserInteractionTracing =true
46
+
options.isEnableUserInteractionBreadcrumbs =true
47
+
}
48
+
```
49
+
50
+
The Sentry SDK utilizes the built-in `Modifier.testTag("<tag>")` of a Composable to determine its identifier. Here's an example:
51
+
52
+
```kotlin
53
+
importandroidx.compose.ui.platform.testTag
54
+
@Composable
55
+
funLoginScreen() {
56
+
Column {
57
+
// ...
58
+
Button(
59
+
modifier =Modifier.testTag("button_login"),
60
+
onClick = { TODO() }) {
61
+
Text(text ="Login")
62
+
}
63
+
}
64
+
}
65
+
```
66
+
67
+
<Note>
68
+
69
+
If a `@Composable` doesn't have a `testTag` modifier applied, both breadcrumbs and transactions won't be captured because they can't be uniquely identified.
70
+
71
+
</Note>
72
+
73
+
<Note>
74
+
75
+
If you want to customize the recorded breadcrumbs/transactions, you can skip to [the section below](#customize-the-recorded-breadcrumbtransaction).
76
+
77
+
</Note>
78
+
79
+
## Jetpack Compose Navigation
80
+
81
+
82
+
In this section, we get you up and running with Sentry's Compose Navigation Integration, so that it will automatically add a breadcrumb and start a transaction for each navigation event.
83
+
84
+
### Auto-Installation With the Sentry Android Gradle Plugin
85
+
86
+
#### Install
18
87
19
88
If you're using the [Sentry Android Gradle Plugin](/platforms/android/gradle/), the Jetpack Compose Navigation Integration is automatically applied, and both breadcrumbs and transactions are automatically created for every navigation event.
20
89
@@ -50,7 +119,7 @@ Learn more about the Sentry Android Gradle plugin in our [Gradle](/platforms/and
50
119
51
120
</Note>
52
121
53
-
### Disable
122
+
####Disable
54
123
55
124
If you want to disable the Jetpack Compose instrumentation feature, you can adapt your `build.gradle(.kts)` file like so:
56
125
@@ -77,9 +146,9 @@ sentry {
77
146
}
78
147
```
79
148
80
-
## Manual Installation
149
+
###Manual Installation
81
150
82
-
### Install
151
+
####Install
83
152
84
153
Sentry captures data by adding a `withSentryObservableEffect` extension function to `NavHostController`. To add the Navigation integration, install the [Android SDK](/platforms/android/), then add the `sentry-compose` dependency using Gradle:
Configuration should happen in the respective `@Composable` function, once you obtain an instance of `NavHostController`:
94
163
@@ -110,7 +179,7 @@ NavHost(
110
179
111
180
By default, the navigation transaction finishes automatically after it reaches the specified [idleTimeout](/platforms/android/configuration/options/#idle-timeout) and all of its child spans are finished. You can customize the timeout to your needs.
112
181
113
-
## Verify
182
+
###Verify
114
183
115
184
This snippet includes a sample `Activity` with a couple of navigation events between composables and captures an intentional message, so you can test that everything is working as soon as you set it up:
0 commit comments