Skip to content
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

Modifier.sentryTag uses Modifier.Node #4029

Open
wants to merge 8 commits into
base: 7.x.x
Choose a base branch
from

Conversation

richkzad
Copy link

@richkzad richkzad commented Jan 7, 2025

📜 Description

Converts Modifier.sentryTag to be implemented with Modifier.Node.

fixes #4028

💡 Motivation and Context

Currently, Modifier.sentryTag prevents composable skipping, due to creating a lambda within a non-@Composable function.

Assuming the @Composable annotation cannot be added (might be a breaking change if other developers have used Modifier.sentryTag outside of a @Composable context), then a Modifier.Node implementation will help avoid recomposition.

💚 How did you test it?

I did build a UI test for this, but was unsure how to run it.

package io.sentry.uitest.android

import androidx.compose.foundation.layout.Box
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.sentry.compose.SentryModifier.sentryTag
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class SentryModifierTest : BaseUiTest() {

    @get:Rule
    val rule = createComposeRule()

    @Test
    fun sentryModifierAppliesTag() {
        rule.setContent {
            Box(Modifier.sentryTag(testSentryTag))
        }
        rule.onNode(
            SemanticsMatcher(testSentryTag) {
                it.config.find { (key, _) -> key.name == "sentryTag" }?.value == testSentryTag
            }
        )
            .assertExists()
    }
}

private const val testSentryTag = "TestSentryTag"

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

getsentry-bot and others added 5 commits January 2, 2025 19:36
* removed Activity callback from SentryPerformanceProvider
* moved activity lifecycle spans logic into a separate class ActivityLifecycleSpanHelper
* moved processInitSpan creation to AppStartMetrics
* ActivityLifecycleIntegration now create regular spans, and adds TimeSpans to AppStartMetrics to handle hybrid SDKs
* PerformanceAndroidEventProcessor does not add activity lifecycle spans to the transaction, as they are added by ActivityLifecycleIntegration directly
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.0.7 to 5.1.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@015f24e...7f8b4b4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@markushi
Copy link
Member

markushi commented Jan 8, 2025

Referencing richkzad#2 here as well, so we can get this ready for merging soon.

@richkzad
Copy link
Author

richkzad commented Jan 9, 2025

Thank you @markushi ! Merged in your changes.

@markushi markushi changed the base branch from main to 7.x.x January 20, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modifier.sentryTag forces recomposition.
3 participants