-
-
Notifications
You must be signed in to change notification settings - Fork 226
Map iOS Native BeforeSend & OnCrashedLastEvent to SentryOptions.Native #3958
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
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a1b0cb6
Initial commit for exposing iOS native before send & crashed last run
aritchie 1a8474e
Initial feature set is working
aritchie c36be94
Format code
getsentry-bot cd074d4
Update CHANGELOG.md
aritchie 17790c7
Merge branch '2102-ios_beforesend_oncrashedlastrun' of https://github…
aritchie 70a677d
Merge signal abort code before user based BeforeSend
aritchie 4a6462c
Move native BeforeSend & OnCrashedLastRun events to SentryOptions - O…
aritchie 91145ab
Always run NativeOptions.BeforeSend so sig aborts can be filtered
aritchie fd48026
Update SentrySdk.cs
aritchie 1b3dfdd
Merge branch 'main' into 2102-ios_beforesend_oncrashedlastrun
aritchie c29a785
Update CHANGELOG.md
aritchie 50a5554
Format code
getsentry-bot 63e3f55
WIP - removing serialization mechanics as they cause a native crash d…
aritchie 5c06eb5
Transferring transformed sentryevent back to original native event in…
aritchie 18a1079
Merge branch 'main' into 2102-ios_beforesend_oncrashedlastrun
aritchie 000b324
Remove unnecessary hacks
aritchie bdfe3a9
Format code
getsentry-bot bf4d33d
Add missing bindable option for native iOS sentryoptions
aritchie 52f0699
Update SentrySdk.cs
aritchie dab118e
Update SentrySdk.cs
aritchie 1f721b8
Update CHANGELOG.md
aritchie 4830f8e
Update CHANGELOG.md
aritchie b8b08cc
Unit tests mapping checks to/from native iOS
aritchie a46bd43
Format code
getsentry-bot 5dca9e2
Update NativeSerializationTests.cs
aritchie 00cbc04
Revert "Add missing bindable option for native iOS sentryoptions"
aritchie d2776e1
Remove iOS native event suppress configuration
aritchie 5e8134a
Update CHANGELOG.md
aritchie d8ac6ea
Rename tests according to review
aritchie 63326ec
add timestamp for deserialize test
aritchie d1feffc
Account for fractions of seconds
aritchie 6c10867
Merge branch 'main' into 2102-ios_beforesend_oncrashedlastrun
aritchie ede88c1
Platforms should not change
aritchie bbf9da4
Update CocoaExtensionsTests.cs
aritchie 65534f0
Update CocoaExtensionsTests.cs
aritchie 35113e1
Update CocoaExtensionsTests.cs
aritchie 4c6d7a2
Update CocoaExtensionsTests.cs
aritchie e80ce73
Safety SentryLevel in both directions
aritchie e97bc47
Update EnumExtensions.cs
aritchie 61665c5
Format code
getsentry-bot 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
Next
Next commit
Initial commit for exposing iOS native before send & crashed last run
- Loading branch information
commit a1b0cb6acf95ffbbeabbd1f2642f14f37ee00c72
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
91 changes: 46 additions & 45 deletions
91
src/Sentry/Platforms/Cocoa/Extensions/SentryEventExtensions.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -1,45 +1,46 @@ | ||
| // using Sentry.Extensibility; | ||
| // using Sentry.Protocol.Envelopes; | ||
| // | ||
| // namespace Sentry.Cocoa.Extensions; | ||
| // | ||
| // internal static class SentryEventExtensions | ||
| // { | ||
| // /* | ||
| // * These methods map between a SentryEvent and it's Cocoa counterpart by serializing as JSON into memory on one side, | ||
| // * then deserializing back to an object on the other side. It is not expected to be performant, as this code is only | ||
| // * used when a BeforeSend option is set, and then only when an event is captured by the Cocoa SDK (which should be | ||
| // * relatively rare). | ||
| // * | ||
| // * This approach avoids having to write to/from methods for the entire object graph. However, it's also important to | ||
| // * recognize that there's not necessarily a one-to-one mapping available on all objects (even through serialization) | ||
| // * between the two SDKs, so some optional details may be lost when roundtripping. That's generally OK, as this is | ||
| // * still better than nothing. If a specific part of the object graph becomes important to roundtrip, we can consider | ||
| // * updating the objects on either side. | ||
| // */ | ||
| // | ||
| // public static SentryEvent ToSentryEvent(this CocoaSdk.SentryEvent sentryEvent, SentryCocoaSdkOptions nativeOptions) | ||
| // { | ||
| // using var stream = sentryEvent.ToJsonStream()!; | ||
| // //stream.Seek(0, SeekOrigin.Begin); ?? | ||
| // | ||
| // using var json = JsonDocument.Parse(stream); | ||
| // var exception = sentryEvent.Error == null ? null : new NSErrorException(sentryEvent.Error); | ||
| // return SentryEvent.FromJson(json.RootElement, exception); | ||
| // } | ||
| // | ||
| // public static CocoaSdk.SentryEvent ToCocoaSentryEvent(this SentryEvent sentryEvent, SentryOptions options, SentryCocoaSdkOptions nativeOptions) | ||
| // { | ||
| // var envelope = Envelope.FromEvent(sentryEvent); | ||
| // | ||
| // using var stream = new MemoryStream(); | ||
| // envelope.Serialize(stream, options.DiagnosticLogger); | ||
| // stream.Seek(0, SeekOrigin.Begin); | ||
| // | ||
| // using var data = NSData.FromStream(stream)!; | ||
| // var cocoaEnvelope = CocoaSdk.PrivateSentrySDKOnly.EnvelopeWithData(data); | ||
| // | ||
| // var cocoaEvent = (CocoaSdk.SentryEvent) cocoaEnvelope.Items[0]; | ||
| // return cocoaEvent; | ||
| // } | ||
| // } | ||
| using Sentry.Extensibility; | ||
| using Sentry.Protocol.Envelopes; | ||
|
|
||
| namespace Sentry.Cocoa.Extensions; | ||
|
|
||
| internal static class SentryEventExtensions | ||
| { | ||
| /* | ||
| * These methods map between a SentryEvent and it's Cocoa counterpart by serializing as JSON into memory on one side, | ||
| * then deserializing back to an object on the other side. It is not expected to be performant, as this code is only | ||
| * used when a BeforeSend option is set, and then only when an event is captured by the Cocoa SDK (which should be | ||
| * relatively rare). | ||
| * | ||
| * This approach avoids having to write to/from methods for the entire object graph. However, it's also important to | ||
| * recognize that there's not necessarily a one-to-one mapping available on all objects (even through serialization) | ||
| * between the two SDKs, so some optional details may be lost when roundtripping. That's generally OK, as this is | ||
| * still better than nothing. If a specific part of the object graph becomes important to roundtrip, we can consider | ||
| * updating the objects on either side. | ||
| */ | ||
|
|
||
| public static SentryEvent ToSentryEvent(this CocoaSdk.SentryEvent sentryEvent, SentryCocoaSdkOptions nativeOptions) | ||
| { | ||
| using var stream = sentryEvent.ToJsonStream()!; | ||
| //stream.Seek(0, SeekOrigin.Begin); ?? | ||
|
|
||
| using var json = JsonDocument.Parse(stream); | ||
| var exception = sentryEvent.Error == null ? null : new NSErrorException(sentryEvent.Error); | ||
| var ev = SentryEvent.FromJson(json.RootElement, exception); | ||
| return ev; | ||
| } | ||
|
|
||
| public static CocoaSdk.SentryEvent ToCocoaSentryEvent(this SentryEvent sentryEvent, SentryOptions options, SentryCocoaSdkOptions nativeOptions) | ||
| { | ||
| var envelope = Envelope.FromEvent(sentryEvent); | ||
|
|
||
| using var stream = new MemoryStream(); | ||
| envelope.Serialize(stream, options.DiagnosticLogger); | ||
| stream.Seek(0, SeekOrigin.Begin); | ||
|
|
||
| using var data = NSData.FromStream(stream)!; | ||
| var cocoaEnvelope = CocoaSdk.PrivateSentrySDKOnly.EnvelopeWithData(data); | ||
|
|
||
| var cocoaEvent = (CocoaSdk.SentryEvent) cocoaEnvelope.Items.GetItem<CocoaSdk.SentryEvent>(0); | ||
| return cocoaEvent; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.