Custom SessionReplay masks in MAUI Android apps#4121
Conversation
| /// <summary> | ||
| /// Controls the masking behaviour of the Session Replay feature. | ||
| /// </summary> | ||
| public enum SessionReplayMaskMode |
There was a problem hiding this comment.
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.
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.
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 |
bruno-garcia
left a comment
There was a problem hiding this comment.
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.