Skip to content

feat(android): Add Jetpack Compose automatic UI transaction docs #5893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 19, 2022

Conversation

markushi
Copy link
Member

@markushi markushi commented Dec 5, 2022

Add docs for automatic Jetpack Compose transactions.

Related sentry-java PR: getsentry/sentry-java#2390

TODOs

  • Await release and make sure the docs use the right min-version

@vercel
Copy link

vercel bot commented Dec 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
sentry-docs ✅ Ready (Inspect) Visit Preview Dec 19, 2022 at 7:37AM (UTC)

@@ -226,24 +226,56 @@ For more information see our [file I/O integration](/platforms/android/configura

### User Interaction Instrumentation

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 UI.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 UI.
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 the Jetpack Compose UI.

Copy link
Contributor

@imatwawana imatwawana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is still in draft, but I just made some wording and style fixes.

@romtsn
Copy link
Member

romtsn commented Dec 9, 2022

Can we also maybe update the Jetpack Compose page? (maybe we could have subsections for navigation and UI events, or just change the wording a bit)

Also, maybe we should update the Basic Options section with the new flags (enableUserInteractionBreadcrumbs and enableUserInteractionTracing), since they live in the core SentryOptions right now?

Otherwise the PR looks good 👍

<application>
<meta-data android:name="io.sentry.traces.user-interaction.enable" android:value="true" />
</application>
The SDK composes the transaction name out of the host `Activity` and the `tag` set by way of `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`).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the testTag for monitoring in production seems a bit awkward to me. Maybe we should define our own Modifier?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! @romtsn and I discussed about this as well..testTag() is used for writing Jetpack Compose UI tests to identify an element within the view hierarchy. So the use case is quite similar to ours.
I see two advantages:

  • it will work out of the box for any existing Composables
  • there's no need for an extra API
  • If we would introduce our own modifier, the users would probably end up setting the same value there as well:
Button(
    modifier = Modifier
      .testTag("button_login")
      .sentryTag("button_login") {
    ...
}

But yeah I see your point, it still could be confusing. Maybe let's wait for some user feedback and add our own API if necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep - our ultimate goal would also be to automatically generate the transaction name through SAGP (either bytecode manipulation or kotlin compiler plugin), so long-term users will only need this as a fallback in rare cases, so I think it's a good middle-ground

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using testTag as a fallback if sentryTag is not set? So if you are already using testTag you are fine, because you don't have to set it twice. If you use both, sentryTag wins. Finally, we recommend using sentryTag. I'm also fine with not adding sentryTag in the first iteration. It's always easier to add APIs than to remove them.

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 🚀 just one thing about the gradle setup. @imatwawana do you want to have another look at the updated docs please?

Copy link
Contributor

@imatwawana imatwawana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some wording tweaks and fixed some formatting stuff (adding line breaks etc).

Co-authored-by: Isabel <[email protected]>
Co-authored-by: Roman Zavarnitsyn <[email protected]>
@markushi markushi merged commit 3c4b9d8 into master Dec 19, 2022
@markushi markushi deleted the feat/compose-ui-transactions branch December 19, 2022 07:38
@github-actions github-actions bot locked and limited conversation to collaborators Jan 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants