-
-
Notifications
You must be signed in to change notification settings - Fork 225
fix: ExtraData not captured for Breadcrumbs in MauiEventsBinder #4254
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 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
94ee8f6
fix: ExtraData not captured for Breadcrumbs in MauiEventsBinder
jamescrosswell 97cf6bb
Update CHANGELOG.md
jamescrosswell ddfcd8b
Add constructor overload to BreadcrumbEvent for backward compatibility
jamescrosswell 5a38114
Create BreadcrumbEventTests.cs
jamescrosswell 0258492
Changed from record to class
jamescrosswell ad5a8d5
Refactored custom event binders into separate test classes
jamescrosswell c79fa03
Update CHANGELOG.md
jamescrosswell f5f0ad2
Merge branch 'main' into breadcrumbevent-extradata
jamescrosswell f4f14f9
Update MauiEventsBinderFixture.cs
jamescrosswell 89e72e8
Update CHANGELOG.md
jamescrosswell a264395
Changed ExtraData from an Array to an IEnumerable
jamescrosswell dbf9985
Merge branch 'main' into breadcrumbevent-extradata
jamescrosswell 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| namespace Sentry.Maui; | ||
|
|
||
| /// <summary> | ||
| /// Argument to the OnBreadcrumbCreateCallback | ||
| /// </summary> | ||
| public sealed class BreadcrumbEvent | ||
| { | ||
| /// <summary> | ||
| /// The sender of the event, usually the control that triggered it. | ||
| /// </summary> | ||
| public object? Sender { get; } | ||
|
|
||
| /// <summary> | ||
| /// The event name (e.g. "Tapped", "Swiped", etc.) | ||
| /// </summary> | ||
| public string EventName { get; } | ||
|
|
||
| /// <summary> | ||
| /// Any extra data to be included in the breadcrumb. This would typically be event specific information (for example | ||
| /// it could include the X, Y coordinates of a tap event). | ||
| /// </summary> | ||
| public (string Key, string Value)[] ExtraData { get; } | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Creates a new BreadcrumbEvent | ||
| /// </summary> | ||
| public BreadcrumbEvent( | ||
| object? sender, | ||
| string eventName, | ||
| params (string Key, string Value)[] extraData) | ||
| { | ||
| Sender = sender; | ||
| EventName = eventName; | ||
| ExtraData = extraData; | ||
Flash0ver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// This constructor remains for backward compatibility. | ||
| /// </summary> | ||
| /// <param name="sender"></param> | ||
| /// <param name="eventName"></param> | ||
| /// <param name="extraData"></param> | ||
| [Obsolete("Use the simpler constructor with params (string Key, string Value)[] extraData instead.")] | ||
| public BreadcrumbEvent( | ||
| object? sender, | ||
| string eventName, | ||
| IEnumerable<(string Key, string Value)>[] extraData) : this(sender, eventName, extraData.SelectMany(e => e).ToArray()) | ||
| { | ||
| } | ||
| } | ||
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
Flash0ver marked this conversation as resolved.
Show resolved
Hide resolved
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using System.Collections.Generic; | ||
| using FluentAssertions; | ||
| using Xunit; | ||
|
|
||
| namespace Sentry.Maui.Tests; | ||
|
|
||
| public class BreadcrumbEventTests | ||
| { | ||
| [Fact] | ||
| public void BreadcrumbEvent_OldConstructor_EquivalentToNewConstructor() | ||
| { | ||
| // Arrange | ||
| var sender = new object(); | ||
| var eventName = "TestEvent"; | ||
|
|
||
| // Act | ||
| IEnumerable<(string Key, string Value)>[] extraData = [[("key1", "value1")], [("key2", "value2")]]; | ||
| #pragma warning disable CS0618 // Type or member is obsolete | ||
| var oldEvent = new BreadcrumbEvent(sender, eventName, extraData); | ||
| #pragma warning restore CS0618 // Type or member is obsolete | ||
| var newEvent = new BreadcrumbEvent(sender, eventName, ("key1", "value1"), ("key2", "value2")); | ||
|
|
||
| // Assert | ||
| oldEvent.Sender.Should().Be(newEvent.Sender); | ||
| oldEvent.EventName.Should().Be(newEvent.EventName); | ||
| oldEvent.ExtraData.Should().BeEquivalentTo(newEvent.ExtraData); | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| using Sentry.Maui.Internal; | ||
|
|
||
| namespace Sentry.Maui.Tests; | ||
|
|
||
| internal class MauiEventsBinderFixture | ||
| { | ||
| public IHub Hub { get; } | ||
|
|
||
| public MauiEventsBinder Binder { get; } | ||
|
|
||
| public Scope Scope { get; } = new(); | ||
|
|
||
| public SentryMauiOptions Options { get; } = new(); | ||
|
|
||
| public MauiEventsBinderFixture(params IEnumerable<IMauiElementEventBinder> elementEventBinders) | ||
| { | ||
| Hub = Substitute.For<IHub>(); | ||
| Hub.When(h => h.ConfigureScope(Arg.Any<Action<Scope>>())) | ||
| .Do(c => | ||
| { | ||
| c.Arg<Action<Scope>>()(Scope); | ||
| }); | ||
|
|
||
| Scope.Transaction = Substitute.For<ITransactionTracer>(); | ||
|
|
||
| Options.Debug = true; | ||
| var logger = Substitute.For<IDiagnosticLogger>(); | ||
| logger.IsEnabled(Arg.Any<SentryLevel>()).Returns(true); | ||
| Options.DiagnosticLogger = logger; | ||
| var options = Microsoft.Extensions.Options.Options.Create(Options); | ||
| Binder = new MauiEventsBinder( | ||
| Hub, | ||
| options, | ||
| elementEventBinders | ||
| ); | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.