-
-
Notifications
You must be signed in to change notification settings - Fork 427
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 API to retrieve Android scope data #2814
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
254554a
Add MapObjectWriter to serialize protocol data to Java Map<>
markushi 8b1b62b
Move from ScopeUtil to InternalSentrySdk
markushi 6e3df8a
Fix test
markushi a461f7e
Extract device information from DefaultAndroidEventProcessor
markushi 26ab966
Fix back-fill user if not manually set on scope
markushi 74cbd44
Add missing os context
markushi e856a09
Enrich os, user and app context
markushi 09953d7
Add InternalSentrySdk.captureEnvelope
markushi 2860fa1
Address PR comments
markushi 5f44d96
Improve nullability and java docs
markushi File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.sentry; | ||
|
||
import java.io.IOException; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface ObjectWriter { | ||
ObjectWriter beginArray() throws IOException; | ||
|
||
ObjectWriter endArray() throws IOException; | ||
|
||
ObjectWriter beginObject() throws IOException; | ||
|
||
ObjectWriter endObject() throws IOException; | ||
|
||
ObjectWriter name(String name) throws IOException; | ||
markushi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ObjectWriter value(String value) throws IOException; | ||
|
||
ObjectWriter nullValue() throws IOException; | ||
|
||
ObjectWriter value(boolean value) throws IOException; | ||
|
||
ObjectWriter value(Boolean value) throws IOException; | ||
|
||
ObjectWriter value(double value) throws IOException; | ||
|
||
ObjectWriter value(long value) throws IOException; | ||
|
||
ObjectWriter value(Number value) throws IOException; | ||
|
||
ObjectWriter value(@NotNull ILogger logger, @Nullable Object object) throws IOException; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.sentry; | ||
|
||
import io.sentry.util.MapObjectWriter; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@ApiStatus.Internal | ||
public final class ScopeUtil { | ||
|
||
@NotNull | ||
public static Map<String, Object> serialize(@Nullable Scope scope) { | ||
final @NotNull Map<String, Object> data = new HashMap<>(); | ||
if (scope == null) { | ||
return data; | ||
} | ||
|
||
final @NotNull SentryOptions options = scope.getOptions(); | ||
final @NotNull ObjectWriter writer = new MapObjectWriter(data); | ||
|
||
try { | ||
serialize(writer, options, "user", scope.getUser()); | ||
serialize(writer, options, "contexts", scope.getContexts()); | ||
serialize(writer, options, "tags", scope.getTags()); | ||
serialize(writer, options, "extras", scope.getExtras()); | ||
serialize(writer, options, "fingerprint", scope.getFingerprint()); | ||
serialize(writer, options, "level", scope.getLevel()); | ||
serialize(writer, options, "breadcrumbs", scope.getBreadcrumbs()); | ||
} catch (Exception e) { | ||
options.getLogger().log(SentryLevel.ERROR, "Could not serialize scope"); | ||
markushi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return data; | ||
} | ||
|
||
private static void serialize( | ||
@NotNull ObjectWriter writer, | ||
@NotNull SentryOptions options, | ||
@NotNull String name, | ||
@Nullable Object data) | ||
throws IOException { | ||
writer.name(name); | ||
writer.value(options.getLogger(), data); | ||
} | ||
} |
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
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
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.
This class is public and not annotated as internal, technically a breaking change, was that intentional?
What's the motivation for the renaming?
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.
This is a required change in order to serialize protocol classes to either
Json
orMap<>
. IMHO it's an oversight that this class is not marked as apistatus.internal. If we consider this a breaking change we should talk to Karl/Krystof as this PR is blocking the RN profiling feature.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.
I agree its an oversight, but the class/interface was used in pretty much every class of the protocol.
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.
Broke the C# binding somehow: https://github.com/getsentry/sentry-dotnet/pull/2498/files
cc @bitsandfoxes