- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 225
Custom SessionReplay masks in MAUI Android apps #4121
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
Conversation
| /// <summary> | ||
| /// Controls the masking behaviour of the Session Replay feature. | ||
| /// </summary> | ||
| public enum SessionReplayMaskMode | 
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.
question: Is the term "mask mode" (or "masking mode") established through other SDKs, or is this enum a .NET-only concept to "type-ify" the strings?
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.
The later - I made it up to limit the number of possibilities presented by the tooling when writing XAML.
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 was wondering if we have already established prior art for the enum and it's name.
| 
 Thanks @aritchie - new code uses static handlers. To avoid capturing the  | 
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.
LGTM - ship it!
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.
can the same API work in iOS once we add there?
| 
 It depends on how masking is done in iOS. I'm not expecting it to work on iOS though. The Java implementation seems quite android specific. | 
Summary
Previously the SessionReplay options for Android supported either Masking everything or masking nothing:
sentry-dotnet/samples/Sentry.Samples.Maui/MauiProgram.cs
Lines 34 to 35 in e8a65cf
This PR adds the ability to override those "default" masking settings one or more view elements.
Overriding mask settings for specific MAUI components
SDK users would do this first by adding a reference to the Sentry namespace (which gives access to Sentry specific XAML elements):
sentry-dotnet/samples/Sentry.Samples.Maui/MainPage.xaml
Line 4 in e8a65cf
And then by specifying the
sentry:SessionReplay.Maskfor any view elements they want to explicitly mask or unmask:sentry-dotnet/samples/Sentry.Samples.Maui/MainPage.xaml
Lines 13 to 18 in d518620
Overriding mask settings for types of MAUI components
sentry-dotnet/samples/Sentry.Samples.Maui/MauiProgram.cs
Lines 36 to 38 in d518620
Tests
I added a couple of almost inconsequential unit tests. It's very difficult to test these behaviours however since ultimately we're setting properties on native (Android) view elements. Create those view elements requires an
IMauiContextwhich really needs the view element to sit in an actual MAUI application running on Android.I couldn't think of a practical way to access or leverage the MAUI context that would exist in our
Sentry.Maui.Device.TestApp.csproj(I think that's gets created magically by xharness). If anyone who's more experienced with MAUI than me has any ideas about how this could be better tested, maybe we can add better test coverage in the future.