-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Add current activity name to app context #2999
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd60464
Add current activity name to app context
markushi 09dfd0d
Add missing tests
markushi 7392211
Update Changelog
markushi 3c05fe7
Merge branch 'main' into feat/add-current-screen-to-app-context
markushi c502dbb
Merge branch 'main' into feat/add-current-screen-to-app-context
markushi 2201017
Extend (de)serialization tests
markushi 7d631f7
Merge branch 'feat/add-current-screen-to-app-context' of github.com:g…
markushi 6cd7c42
Mark screen API as internal
markushi 11559df
Fix tests
markushi 49a0e71
Fix tests
markushi 987e202
Merge branch 'main' into feat/add-current-screen-to-app-context
markushi c44b4b7
Ensure screen scope change is propagated
markushi 458d956
Merge branch 'main' into feat/add-current-screen-to-app-context
markushi 67adcc4
Merge branch 'feat/add-current-screen-to-app-context' of github.com:g…
markushi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
sentry-android-core/src/main/java/io/sentry/android/core/internal/util/ClassUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.sentry.android.core.internal.util; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@ApiStatus.Internal | ||
public class ClassUtil { | ||
Check warning on line 7 in sentry-android-core/src/main/java/io/sentry/android/core/internal/util/ClassUtil.java Codecov / codecov/patchsentry-android-core/src/main/java/io/sentry/android/core/internal/util/ClassUtil.java#L7
|
||
|
||
public static @Nullable String getClassName(final @Nullable Object object) { | ||
if (object == null) { | ||
return null; | ||
} | ||
final @Nullable String canonicalName = object.getClass().getCanonicalName(); | ||
if (canonicalName != null) { | ||
return canonicalName; | ||
} | ||
return object.getClass().getSimpleName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
sentry-android-core/src/test/java/io/sentry/android/core/internal/util/ClassUtilTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.sentry.android.core.internal.util | ||
|
||
import java.util.concurrent.Callable | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNull | ||
import kotlin.test.assertTrue | ||
|
||
class ClassUtilTest { | ||
|
||
class Outer { | ||
class Inner { | ||
val x: Callable<Boolean> = Callable<Boolean> { false } | ||
} | ||
} | ||
|
||
@Test | ||
fun `getClassName returns cannonical name by default`() { | ||
val name = ClassUtil.getClassName(Outer.Inner()) | ||
assertEquals("io.sentry.android.core.internal.util.ClassUtilTest.Outer.Inner", name) | ||
} | ||
|
||
@Test | ||
fun `getClassName falls back to simple name for anonymous classes`() { | ||
val name = ClassUtil.getClassName(Outer.Inner().x) | ||
assertTrue(name!!.contains("$")) | ||
} | ||
|
||
@Test | ||
fun `getClassName returns null when obj is null`() { | ||
val name = ClassUtil.getClassName(null) | ||
assertNull(name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m
: I'm wondering if we should stick to our approach of enriching contexts in theDefaultAndroidEventProcessor
?Probably it should live here and we also would have to check
!HintUtils.isFromHybridSdk(hint)
because hybrid SDKs will set their ownview_names
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good point, but I still think it should live on the scope because it represents a current state, which should be readable by other components.
E.g. when a span gets created (e.g. by some user interaction, a slow/frozen frame, ...) we'd need a way to get the current screen for adding it as span context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm fine with
screen
living on the scope, just meant the actual setting it to Contexts should be happening in the event processor maybeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I looked into this now, but as far as I can see EventProcessors have no direct access to the scope / a hub. But SentryClient.applyScope could be a good place for this, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh you're right. But we're anyway already doing that there
so I think it's fine to keep it as you initially implemented 👍