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 3 commits into
base: main
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

@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.

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.
2 participants