From ece7ef9bad9dad5149a421c3a2cbaabf35e9bf28 Mon Sep 17 00:00:00 2001 From: phunkeler Date: Wed, 8 Jan 2025 23:04:10 -0500 Subject: [PATCH 1/7] [iOS] Bump Sentry Cocoa SDK from 8.39.0 to 8.43.0 + map SentryReplayOptions --- modules/sentry-cocoa.properties | 2 +- scripts/generate-cocoa-bindings.ps1 | 102 ++++++++++++++++++ src/Sentry.Bindings.Cocoa/ApiDefinitions.cs | 105 ++++++++++++++++--- src/Sentry.Bindings.Cocoa/StructsAndEnums.cs | 15 +++ 4 files changed, 211 insertions(+), 13 deletions(-) diff --git a/modules/sentry-cocoa.properties b/modules/sentry-cocoa.properties index 799f17ac06..36a3e738d5 100644 --- a/modules/sentry-cocoa.properties +++ b/modules/sentry-cocoa.properties @@ -1,2 +1,2 @@ -version = 8.39.0 +version = 8.43.0 repo = https://github.com/getsentry/sentry-cocoa diff --git a/scripts/generate-cocoa-bindings.ps1 b/scripts/generate-cocoa-bindings.ps1 index 1a9f7a6a9e..1275137786 100644 --- a/scripts/generate-cocoa-bindings.ps1 +++ b/scripts/generate-cocoa-bindings.ps1 @@ -147,8 +147,36 @@ internal enum SentryTransactionNameSource : long } '@ +# This enum resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$SentryReplayQuality = @' + +[Native] +internal enum SentryReplayQuality : long +{ + Low = 0, + Medium = 1, + High = 2 +} +'@ + +# This enum resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$SentryReplayType = @' + +[Native] +internal enum SentryReplayType : long +{ + Session = 0, + Buffer = 1 +} +'@ + $Text += "`n$SentryLevel" $Text += "`n$SentryTransactionNameSource" +$Text += "`n$SentryReplayQuality" +$Text += "`n$SentryReplayType" + # Add header and output file $Text = "$Header`n`n$Text" @@ -298,6 +326,80 @@ interface SentryId $Text += "`n$SentryId" +# This interface resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$SentryReplayOptions = @' + +// @interface SentryReplayOptions : NSObject +[BaseType (typeof(NSObject), Name = "_TtC6Sentry19SentryReplayOptions")] +[Internal] +interface SentryReplayOptions //: ISentryRedactOptions +{ + // @property (nonatomic) float sessionSampleRate; + [Export ("sessionSampleRate")] + float SessionSampleRate { get; set; } + + // @property (nonatomic) float onErrorSampleRate; + [Export ("onErrorSampleRate")] + float OnErrorSampleRate { get; set; } + + // @property (nonatomic) BOOL maskAllText; + [Export ("maskAllText")] + bool MaskAllText { get; set; } + + // @property (nonatomic) BOOL maskAllImages; + [Export ("maskAllImages")] + bool MaskAllImages { get; set; } + + // @property (nonatomic) enum SentryReplayQuality quality; + [Export ("quality", ArgumentSemantic.Assign)] + SentryReplayQuality Quality { get; set; } + + // @property (copy, nonatomic) NSArray * _Nonnull maskedViewClasses; + //[Export ("maskedViewClasses", ArgumentSemantic.Copy)] + //Class[] MaskedViewClasses { get; set; } + + // @property (copy, nonatomic) NSArray * _Nonnull unmaskedViewClasses; + //[Export ("unmaskedViewClasses", ArgumentSemantic.Copy)] + //Class[] UnmaskedViewClasses { get; set; } + + // @property (readonly, nonatomic) NSInteger replayBitRate; + [Export ("replayBitRate")] + nint ReplayBitRate { get; } + + // @property (readonly, nonatomic) float sizeScale; + [Export ("sizeScale")] + float SizeScale { get; } + + // @property (nonatomic) NSUInteger frameRate; + [Export ("frameRate")] + nuint FrameRate { get; set; } + + // @property (readonly, nonatomic) NSTimeInterval errorReplayDuration; + [Export ("errorReplayDuration")] + double ErrorReplayDuration { get; } + + // @property (readonly, nonatomic) NSTimeInterval sessionSegmentDuration; + [Export ("sessionSegmentDuration")] + double SessionSegmentDuration { get; } + + // @property (readonly, nonatomic) NSTimeInterval maximumDuration; + [Export ("maximumDuration")] + double MaximumDuration { get; } + + // -(instancetype _Nonnull)initWithSessionSampleRate:(float)sessionSampleRate onErrorSampleRate:(float)onErrorSampleRate maskAllText:(BOOL)maskAllText maskAllImages:(BOOL)maskAllImages __attribute__((objc_designated_initializer)); + [Export ("initWithSessionSampleRate:onErrorSampleRate:maskAllText:maskAllImages:")] + [DesignatedInitializer] + NativeHandle Constructor (float sessionSampleRate, float onErrorSampleRate, bool maskAllText, bool maskAllImages); + + // -(instancetype _Nonnull)initWithDictionary:(NSDictionary * _Nonnull)dictionary; + [Export ("initWithDictionary:")] + NativeHandle Constructor (NSDictionary dictionary); +} +'@ + +$Text += "`n$SentryReplayOptions" + # Add header and output file $Text = "$Header`n`n$Text" $Text | Out-File "$BindingsPath/$File" diff --git a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs index 3bbfc298dc..ecfe1fa8dc 100644 --- a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs +++ b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs @@ -59,10 +59,6 @@ namespace Sentry.CocoaSdk; [Internal] delegate void SentrySpanCallback ([NullAllowed] SentrySpan span); -// typedef BOOL (^SentryBeforeEmitMetricCallback)(NSString * _Nonnull, NSDictionary * _Nonnull); -[Internal] -delegate bool SentryBeforeEmitMetricCallback (string arg0, NSDictionary arg1); - // @interface SentryAttachment : NSObject [BaseType (typeof(NSObject))] [DisableDefaultCtor] @@ -299,7 +295,7 @@ interface SentryDebugImageProvider [Export ("getDebugImagesForThreads:")] SentryDebugMeta[] GetDebugImagesForThreads (SentryThread[] threads); - // -(NSArray * _Nonnull)getDebugImagesForThreads:(NSArray * _Nonnull)threads isCrash:(BOOL)isCrash; + // -(NSArray * _Nonnull)getDebugImagesForThreads:(NSArray * _Nonnull)threads isCrash:(BOOL)isCrash __attribute__((deprecated("This method is slow and will be removed in a future version. Use -[getDebugImagesFromCacheForThreads:] instead."))); [Export ("getDebugImagesForThreads:isCrash:")] SentryDebugMeta[] GetDebugImagesForThreads (SentryThread[] threads, bool isCrash); @@ -307,7 +303,7 @@ interface SentryDebugImageProvider [Export ("getDebugImagesForFrames:")] SentryDebugMeta[] GetDebugImagesForFrames (SentryFrame[] frames); - // -(NSArray * _Nonnull)getDebugImagesForFrames:(NSArray * _Nonnull)frames isCrash:(BOOL)isCrash; + // -(NSArray * _Nonnull)getDebugImagesForFrames:(NSArray * _Nonnull)frames isCrash:(BOOL)isCrash __attribute__((deprecated("This method is slow and will be removed in a future version. Use -[getDebugImagesFromCacheForFrames:] instead."))); [Export ("getDebugImagesForFrames:isCrash:")] SentryDebugMeta[] GetDebugImagesForFrames (SentryFrame[] frames, bool isCrash); @@ -315,7 +311,7 @@ interface SentryDebugImageProvider [Export ("getDebugImages")] SentryDebugMeta[] DebugImages { get; } - // -(NSArray * _Nonnull)getDebugImagesCrashed:(BOOL)isCrash; + // -(NSArray * _Nonnull)getDebugImagesCrashed:(BOOL)isCrash __attribute__((deprecated("This method is slow and will be removed in a future version. Use -[getDebugImagesFromCache:] instead."))); [Export ("getDebugImagesCrashed:")] SentryDebugMeta[] GetDebugImagesCrashed (bool isCrash); } @@ -1398,6 +1394,10 @@ interface SentryOptions [Export ("enablePerformanceV2")] bool EnablePerformanceV2 { get; set; } + // @property (assign, nonatomic) BOOL enablePersistingTracesWhenCrashing; + [Export ("enablePersistingTracesWhenCrashing")] + bool EnablePersistingTracesWhenCrashing { get; set; } + // @property (nonatomic) SentryScope * _Nonnull (^ _Nonnull)(SentryScope * _Nonnull) initialScope; [Export ("initialScope", ArgumentSemantic.Assign)] Func InitialScope { get; set; } @@ -1430,6 +1430,10 @@ interface SentryOptions [Export ("enablePreWarmedAppStartTracing")] bool EnablePreWarmedAppStartTracing { get; set; } + // @property (nonatomic, strong) SentryReplayOptions * _Nonnull sessionReplay; + [Export ("sessionReplay", ArgumentSemantic.Strong)] + SentryReplayOptions SessionReplay { get; set; } + // @property (assign, nonatomic) BOOL enableNetworkTracking; [Export ("enableNetworkTracking")] bool EnableNetworkTracking { get; set; } @@ -1768,11 +1772,6 @@ interface SentrySDK [Export ("captureUserFeedback:")] void CaptureUserFeedback (SentryUserFeedback userFeedback); - // +(void)showUserFeedbackForm; - [Static] - [Export ("showUserFeedbackForm")] - void ShowUserFeedbackForm (); - // +(void)addBreadcrumb:(SentryBreadcrumb * _Nonnull)crumb __attribute__((swift_name("addBreadcrumb(_:)"))); [Static] [Export ("addBreadcrumb:")] @@ -2354,6 +2353,11 @@ interface PrivateSentrySDKOnly [Export ("getSdkVersionString")] string SdkVersionString { get; } + // +(void)addSdkPackage:(NSString * _Nonnull)name version:(NSString * _Nonnull)version; + [Static] + [Export ("addSdkPackage:version:")] + void AddSdkPackage (string name, string version); + // +(NSDictionary * _Nonnull)getExtraContext; [Static] [Export ("getExtraContext")] @@ -2440,6 +2444,16 @@ interface PrivateSentrySDKOnly [Export ("addReplayRedactClasses:")] void AddReplayRedactClasses (Class[] classes); + // +(void)setIgnoreContainerClass:(Class _Nonnull)containerClass; + [Static] + [Export ("setIgnoreContainerClass:")] + void SetIgnoreContainerClass (Class containerClass); + + // +(void)setRedactContainerClass:(Class _Nonnull)containerClass; + [Static] + [Export ("setRedactContainerClass:")] + void SetRedactContainerClass (Class containerClass); + // +(NSDictionary * _Nullable)appStartMeasurementWithSpans; [Static] [NullAllowed, Export ("appStartMeasurementWithSpans")] @@ -2484,3 +2498,70 @@ interface SentryId [Export ("hash")] nuint Hash { get; } } + +// @interface SentryReplayOptions : NSObject +[BaseType (typeof(NSObject), Name = "_TtC6Sentry19SentryReplayOptions")] +[Internal] +interface SentryReplayOptions //: ISentryRedactOptions +{ + // @property (nonatomic) float sessionSampleRate; + [Export ("sessionSampleRate")] + float SessionSampleRate { get; set; } + + // @property (nonatomic) float onErrorSampleRate; + [Export ("onErrorSampleRate")] + float OnErrorSampleRate { get; set; } + + // @property (nonatomic) BOOL maskAllText; + [Export ("maskAllText")] + bool MaskAllText { get; set; } + + // @property (nonatomic) BOOL maskAllImages; + [Export ("maskAllImages")] + bool MaskAllImages { get; set; } + + // @property (nonatomic) enum SentryReplayQuality quality; + [Export ("quality", ArgumentSemantic.Assign)] + SentryReplayQuality Quality { get; set; } + + // @property (copy, nonatomic) NSArray * _Nonnull maskedViewClasses; + //[Export ("maskedViewClasses", ArgumentSemantic.Copy)] + //Class[] MaskedViewClasses { get; set; } + + // @property (copy, nonatomic) NSArray * _Nonnull unmaskedViewClasses; + //[Export ("unmaskedViewClasses", ArgumentSemantic.Copy)] + //Class[] UnmaskedViewClasses { get; set; } + + // @property (readonly, nonatomic) NSInteger replayBitRate; + [Export ("replayBitRate")] + nint ReplayBitRate { get; } + + // @property (readonly, nonatomic) float sizeScale; + [Export ("sizeScale")] + float SizeScale { get; } + + // @property (nonatomic) NSUInteger frameRate; + [Export ("frameRate")] + nuint FrameRate { get; set; } + + // @property (readonly, nonatomic) NSTimeInterval errorReplayDuration; + [Export ("errorReplayDuration")] + double ErrorReplayDuration { get; } + + // @property (readonly, nonatomic) NSTimeInterval sessionSegmentDuration; + [Export ("sessionSegmentDuration")] + double SessionSegmentDuration { get; } + + // @property (readonly, nonatomic) NSTimeInterval maximumDuration; + [Export ("maximumDuration")] + double MaximumDuration { get; } + + // -(instancetype _Nonnull)initWithSessionSampleRate:(float)sessionSampleRate onErrorSampleRate:(float)onErrorSampleRate maskAllText:(BOOL)maskAllText maskAllImages:(BOOL)maskAllImages __attribute__((objc_designated_initializer)); + [Export ("initWithSessionSampleRate:onErrorSampleRate:maskAllText:maskAllImages:")] + [DesignatedInitializer] + NativeHandle Constructor (float sessionSampleRate, float onErrorSampleRate, bool maskAllText, bool maskAllImages); + + // -(instancetype _Nonnull)initWithDictionary:(NSDictionary * _Nonnull)dictionary; + [Export ("initWithDictionary:")] + NativeHandle Constructor (NSDictionary dictionary); +} diff --git a/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs b/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs index 7fb471de9c..207d08ee95 100644 --- a/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs +++ b/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs @@ -88,3 +88,18 @@ internal enum SentryTransactionNameSource : long Component = 4, Task = 5 } + +[Native] +internal enum SentryReplayQuality : long +{ + Low = 0, + Medium = 1, + High = 2 +} + +[Native] +internal enum SentryReplayType : long +{ + Session = 0, + Buffer = 1 +} From a7bf4ef9fb80fa0cd491c88e3f6281b7fc512923 Mon Sep 17 00:00:00 2001 From: phunkeler Date: Thu, 9 Jan 2025 15:39:39 -0500 Subject: [PATCH 2/7] wire-up basic session replay options --- samples/Sentry.Samples.Maui/MauiProgram.cs | 6 ++- scripts/generate-cocoa-bindings.ps1 | 3 ++ src/Sentry.Bindings.Cocoa/ApiDefinitions.cs | 3 ++ .../Platforms/Cocoa/BindableSentryOptions.cs | 6 ++- src/Sentry/Platforms/Cocoa/SentryOptions.cs | 49 +++++++++++++++++++ src/Sentry/Platforms/Cocoa/SentrySdk.cs | 4 ++ .../iOS/BindableSentryOptionsTests.cs | 4 +- 7 files changed, 72 insertions(+), 3 deletions(-) diff --git a/samples/Sentry.Samples.Maui/MauiProgram.cs b/samples/Sentry.Samples.Maui/MauiProgram.cs index 028d98b90c..00fc1e9365 100644 --- a/samples/Sentry.Samples.Maui/MauiProgram.cs +++ b/samples/Sentry.Samples.Maui/MauiProgram.cs @@ -13,7 +13,7 @@ public static MauiApp CreateMauiApp() .UseSentry(options => { // The DSN is the only required option. - options.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537"; + options.Dsn = "https://ee8418ac652ffa7d1a7a97c7d8236175@o4507777248198656.ingest.us.sentry.io/4508439773577216"; // By default, we will send the last 100 breadcrumbs with each event. // If you want to see everything we can capture from MAUI, you may wish to use a larger value. @@ -32,6 +32,10 @@ public static MauiApp CreateMauiApp() // Return true to capture or false to prevent the capture return true; }); + +#if IOS + +#endif }) .ConfigureFonts(fonts => diff --git a/scripts/generate-cocoa-bindings.ps1 b/scripts/generate-cocoa-bindings.ps1 index 1275137786..38f3438e6c 100644 --- a/scripts/generate-cocoa-bindings.ps1 +++ b/scripts/generate-cocoa-bindings.ps1 @@ -351,6 +351,8 @@ interface SentryReplayOptions //: ISentryRedactOptions [Export ("maskAllImages")] bool MaskAllImages { get; set; } + /* + // @property (nonatomic) enum SentryReplayQuality quality; [Export ("quality", ArgumentSemantic.Assign)] SentryReplayQuality Quality { get; set; } @@ -395,6 +397,7 @@ interface SentryReplayOptions //: ISentryRedactOptions // -(instancetype _Nonnull)initWithDictionary:(NSDictionary * _Nonnull)dictionary; [Export ("initWithDictionary:")] NativeHandle Constructor (NSDictionary dictionary); + */ } '@ diff --git a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs index ecfe1fa8dc..8dc43759ee 100644 --- a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs +++ b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs @@ -2520,6 +2520,8 @@ interface SentryReplayOptions //: ISentryRedactOptions [Export ("maskAllImages")] bool MaskAllImages { get; set; } + /* + // @property (nonatomic) enum SentryReplayQuality quality; [Export ("quality", ArgumentSemantic.Assign)] SentryReplayQuality Quality { get; set; } @@ -2564,4 +2566,5 @@ interface SentryReplayOptions //: ISentryRedactOptions // -(instancetype _Nonnull)initWithDictionary:(NSDictionary * _Nonnull)dictionary; [Export ("initWithDictionary:")] NativeHandle Constructor (NSDictionary dictionary); + */ } diff --git a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs index af7b318302..c986d6cec5 100644 --- a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs @@ -1,3 +1,5 @@ +using static Sentry.SentryOptions.NativeOptions; + // ReSharper disable once CheckNamespace namespace Sentry; @@ -6,7 +8,7 @@ internal partial class BindableSentryOptions public NativeOptions Native { get; } = new NativeOptions(); /// - /// Provides additional options for the Android platform. + /// Provides additional options for the ios/maccatalyst platform. /// public class NativeOptions { @@ -25,6 +27,7 @@ public class NativeOptions public bool? EnableUIViewControllerTracing { get; set; } public bool? EnableUserInteractionTracing { get; set; } public bool? EnableTracing { get; set; } + public NativeSentryReplayOptions? SentryReplayOptions { get; set; } public void ApplyTo(SentryOptions.NativeOptions options) { @@ -45,6 +48,7 @@ public void ApplyTo(SentryOptions.NativeOptions options) options.EnableUIViewControllerTracing = EnableUIViewControllerTracing ?? options.EnableUIViewControllerTracing; options.EnableUserInteractionTracing = EnableUserInteractionTracing ?? options.EnableUserInteractionTracing; options.EnableTracing = EnableTracing ?? options.EnableTracing; + options.SentryReplayOptions = SentryReplayOptions ?? options.SentryReplayOptions; } } } diff --git a/src/Sentry/Platforms/Cocoa/SentryOptions.cs b/src/Sentry/Platforms/Cocoa/SentryOptions.cs index f72f37e08b..4174ae369c 100644 --- a/src/Sentry/Platforms/Cocoa/SentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/SentryOptions.cs @@ -180,6 +180,11 @@ internal NativeOptions(SentryOptions options) /// public NSUrlSessionDelegate? UrlSessionDelegate { get; set; } = null; + /// + /// The SessionReplay Options from the Cocoa SDK. + /// + public NativeSentryReplayOptions SentryReplayOptions { get; set; } = new(); + // ---------- Other ---------- @@ -219,6 +224,50 @@ public void AddInAppInclude(string prefix) InAppIncludes ??= new List(); InAppIncludes.Add(prefix); } + + /// + /// The SessionReplay Options from the Cocoa SDK. + /// + public class NativeSentryReplayOptions + { + /// + /// Gets or sets the percentage of a session + /// recording to be sent. Values should be between 0.0 + /// and 1.0. The default is 0. + /// + /// + /// sentry.io + /// + public float SessionSampleRate { get; set; } + + /// + /// Gets or sets the percentage of an error + /// recording to be sent. Values should be between 0.0 + /// and 1.0. The default is 0. + /// + /// + /// sentry.io + /// + public float OnErrorSampleRate { get; set; } + + /// + /// Gets or sets a value determining whether + /// text should be masked during recording. + /// + /// + /// sentry.io + /// + public bool MaskAllText { get; set; } = true; + + /// + /// Gets or sets a value determining whether + /// images should be masked during recording. + /// + /// + /// sentry.io + /// + public bool MaskAllImages { get; set; } = true; + } } // We actually add the profiling integration automatically in InitSentryCocoaSdk(). diff --git a/src/Sentry/Platforms/Cocoa/SentrySdk.cs b/src/Sentry/Platforms/Cocoa/SentrySdk.cs index c10e22938c..0b2849664a 100644 --- a/src/Sentry/Platforms/Cocoa/SentrySdk.cs +++ b/src/Sentry/Platforms/Cocoa/SentrySdk.cs @@ -134,6 +134,10 @@ private static void InitSentryCocoaSdk(SentryOptions options) nativeOptions.EnableUIViewControllerTracing = options.Native.EnableUIViewControllerTracing; nativeOptions.EnableUserInteractionTracing = options.Native.EnableUserInteractionTracing; nativeOptions.UrlSessionDelegate = options.Native.UrlSessionDelegate; + nativeOptions.SessionReplay.SessionSampleRate = options.Native.SentryReplayOptions.SessionSampleRate; + nativeOptions.SessionReplay.OnErrorSampleRate = options.Native.SentryReplayOptions.OnErrorSampleRate; + nativeOptions.SessionReplay.MaskAllText = options.Native.SentryReplayOptions.MaskAllText; + nativeOptions.SessionReplay.MaskAllImages = options.Native.SentryReplayOptions.MaskAllImages; // StitchAsyncCode removed from Cocoa SDK in 8.6.0 with https://github.com/getsentry/sentry-cocoa/pull/2973 // nativeOptions.StitchAsyncCode = options.Native.StitchAsyncCode; diff --git a/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs b/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs index bd03d2cf8c..cae749b314 100644 --- a/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs +++ b/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs @@ -6,7 +6,9 @@ namespace Sentry.Tests.Platforms.Cocoa; public class BindableSentryOptionsTests : BindableTests { public BindableSentryOptionsTests() - : base(nameof(SentryOptions.NativeOptions.UrlSessionDelegate)) + : base( + nameof(SentryOptions.NativeOptions.UrlSessionDelegate), + nameof(SentryOptions.Native.SentryReplayOptions)) { } From a283cbb5f6c00a9625891d4e5e43158146061a9a Mon Sep 17 00:00:00 2001 From: Paul Hunkeler Date: Thu, 9 Jan 2025 18:32:43 -0500 Subject: [PATCH 3/7] Renaming + comments --- samples/Sentry.Samples.Maui/MauiProgram.cs | 5 ++++- .../Platforms/Cocoa/BindableSentryOptions.cs | 4 ++-- src/Sentry/Platforms/Cocoa/SentryOptions.cs | 22 ++++++++++--------- src/Sentry/Platforms/Cocoa/SentrySdk.cs | 8 +++---- .../iOS/BindableSentryOptionsTests.cs | 2 +- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/samples/Sentry.Samples.Maui/MauiProgram.cs b/samples/Sentry.Samples.Maui/MauiProgram.cs index 00fc1e9365..45390bc92f 100644 --- a/samples/Sentry.Samples.Maui/MauiProgram.cs +++ b/samples/Sentry.Samples.Maui/MauiProgram.cs @@ -34,7 +34,10 @@ public static MauiApp CreateMauiApp() }); #if IOS - + options.Native.SessionReplay.SessionSampleRate = 1.0f; + options.Native.SessionReplay.OnErrorSampleRate = 1.0f; + options.Native.SessionReplay.MaskAllText = false; + options.Native.SessionReplay.MaskAllImages = false; #endif }) diff --git a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs index c986d6cec5..33d3e91c66 100644 --- a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs @@ -27,7 +27,7 @@ public class NativeOptions public bool? EnableUIViewControllerTracing { get; set; } public bool? EnableUserInteractionTracing { get; set; } public bool? EnableTracing { get; set; } - public NativeSentryReplayOptions? SentryReplayOptions { get; set; } + public NativeSentryReplayOptions? SessionReplay { get; set; } public void ApplyTo(SentryOptions.NativeOptions options) { @@ -48,7 +48,7 @@ public void ApplyTo(SentryOptions.NativeOptions options) options.EnableUIViewControllerTracing = EnableUIViewControllerTracing ?? options.EnableUIViewControllerTracing; options.EnableUserInteractionTracing = EnableUserInteractionTracing ?? options.EnableUserInteractionTracing; options.EnableTracing = EnableTracing ?? options.EnableTracing; - options.SentryReplayOptions = SentryReplayOptions ?? options.SentryReplayOptions; + options.SessionReplay = SessionReplay ?? options.SessionReplay; } } } diff --git a/src/Sentry/Platforms/Cocoa/SentryOptions.cs b/src/Sentry/Platforms/Cocoa/SentryOptions.cs index 4174ae369c..0ff6c2426d 100644 --- a/src/Sentry/Platforms/Cocoa/SentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/SentryOptions.cs @@ -181,10 +181,12 @@ internal NativeOptions(SentryOptions options) public NSUrlSessionDelegate? UrlSessionDelegate { get; set; } = null; /// - /// The SessionReplay Options from the Cocoa SDK. + /// Gets or sets the session replay options. /// - public NativeSentryReplayOptions SentryReplayOptions { get; set; } = new(); - + /// + /// sentry.io + /// + public NativeSentryReplayOptions SessionReplay { get; set; } = new(); // ---------- Other ---------- @@ -226,14 +228,14 @@ public void AddInAppInclude(string prefix) } /// - /// The SessionReplay Options from the Cocoa SDK. + /// Native session replay options. /// public class NativeSentryReplayOptions { /// /// Gets or sets the percentage of a session - /// recording to be sent. Values should be between 0.0 - /// and 1.0. The default is 0. + /// replay to be sent. The value should be between 0.0 + /// and 1.0. Default is 0. /// /// /// sentry.io @@ -242,8 +244,8 @@ public class NativeSentryReplayOptions /// /// Gets or sets the percentage of an error - /// recording to be sent. Values should be between 0.0 - /// and 1.0. The default is 0. + /// replay to be sent. The value should be between 0.0 + /// and 1.0. Default is 0. /// /// /// sentry.io @@ -252,7 +254,7 @@ public class NativeSentryReplayOptions /// /// Gets or sets a value determining whether - /// text should be masked during recording. + /// text should be masked during replays. /// /// /// sentry.io @@ -261,7 +263,7 @@ public class NativeSentryReplayOptions /// /// Gets or sets a value determining whether - /// images should be masked during recording. + /// images should be masked during replays. /// /// /// sentry.io diff --git a/src/Sentry/Platforms/Cocoa/SentrySdk.cs b/src/Sentry/Platforms/Cocoa/SentrySdk.cs index 0b2849664a..11d4c1fb53 100644 --- a/src/Sentry/Platforms/Cocoa/SentrySdk.cs +++ b/src/Sentry/Platforms/Cocoa/SentrySdk.cs @@ -134,10 +134,10 @@ private static void InitSentryCocoaSdk(SentryOptions options) nativeOptions.EnableUIViewControllerTracing = options.Native.EnableUIViewControllerTracing; nativeOptions.EnableUserInteractionTracing = options.Native.EnableUserInteractionTracing; nativeOptions.UrlSessionDelegate = options.Native.UrlSessionDelegate; - nativeOptions.SessionReplay.SessionSampleRate = options.Native.SentryReplayOptions.SessionSampleRate; - nativeOptions.SessionReplay.OnErrorSampleRate = options.Native.SentryReplayOptions.OnErrorSampleRate; - nativeOptions.SessionReplay.MaskAllText = options.Native.SentryReplayOptions.MaskAllText; - nativeOptions.SessionReplay.MaskAllImages = options.Native.SentryReplayOptions.MaskAllImages; + nativeOptions.SessionReplay.SessionSampleRate = options.Native.SessionReplay.SessionSampleRate; + nativeOptions.SessionReplay.OnErrorSampleRate = options.Native.SessionReplay.OnErrorSampleRate; + nativeOptions.SessionReplay.MaskAllText = options.Native.SessionReplay.MaskAllText; + nativeOptions.SessionReplay.MaskAllImages = options.Native.SessionReplay.MaskAllImages; // StitchAsyncCode removed from Cocoa SDK in 8.6.0 with https://github.com/getsentry/sentry-cocoa/pull/2973 // nativeOptions.StitchAsyncCode = options.Native.StitchAsyncCode; diff --git a/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs b/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs index cae749b314..40657758ed 100644 --- a/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs +++ b/test/Sentry.Tests/Platforms/iOS/BindableSentryOptionsTests.cs @@ -8,7 +8,7 @@ public class BindableSentryOptionsTests : BindableTests Date: Sun, 12 Jan 2025 17:45:14 -0500 Subject: [PATCH 4/7] Cherry-pick ad80795 --- samples/Sentry.Samples.Maui/MauiProgram.cs | 4 +- .../Sentry.Bindings.Android.csproj | 7 +++ .../Transforms/Metadata.xml | 4 +- src/Sentry/Platforms/Android/NativeOptions.cs | 8 ++++ src/Sentry/Platforms/Android/SentrySdk.cs | 5 ++ src/Sentry/Platforms/Cocoa/SentryOptions.cs | 48 +------------------ 6 files changed, 26 insertions(+), 50 deletions(-) diff --git a/samples/Sentry.Samples.Maui/MauiProgram.cs b/samples/Sentry.Samples.Maui/MauiProgram.cs index 45390bc92f..baf8316036 100644 --- a/samples/Sentry.Samples.Maui/MauiProgram.cs +++ b/samples/Sentry.Samples.Maui/MauiProgram.cs @@ -1,5 +1,3 @@ -using System.Diagnostics; - namespace Sentry.Samples.Maui; public static class MauiProgram @@ -33,7 +31,7 @@ public static MauiApp CreateMauiApp() return true; }); -#if IOS +#if ANDROID || IOS options.Native.SessionReplay.SessionSampleRate = 1.0f; options.Native.SessionReplay.OnErrorSampleRate = 1.0f; options.Native.SessionReplay.MaskAllText = false; diff --git a/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj b/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj index 46cc0077ab..97d2aa6c39 100644 --- a/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj +++ b/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj @@ -33,6 +33,7 @@ + @@ -53,6 +54,12 @@ Condition="!Exists('$(SentryAndroidSdkDirectory)sentry-android-ndk-$(SentryAndroidSdkVersion).aar')" Retries="3" /> + + + - > + diff --git a/src/Sentry/Platforms/Android/NativeOptions.cs b/src/Sentry/Platforms/Android/NativeOptions.cs index fdef25e518..9a0370fdde 100644 --- a/src/Sentry/Platforms/Android/NativeOptions.cs +++ b/src/Sentry/Platforms/Android/NativeOptions.cs @@ -205,6 +205,14 @@ internal NativeOptions(SentryOptions options) /// public TimeSpan ReadTimeout { get; set; } = TimeSpan.FromSeconds(5); + /// + /// Gets or sets the session replay options. + /// + /// + /// sentry.io + /// + public NativeSentryReplayOptions SessionReplay { get; set; } = new(); + // ---------- Other ---------- internal List? InAppExcludes { get; private set; } diff --git a/src/Sentry/Platforms/Android/SentrySdk.cs b/src/Sentry/Platforms/Android/SentrySdk.cs index 607f4dee59..f37e62f44e 100644 --- a/src/Sentry/Platforms/Android/SentrySdk.cs +++ b/src/Sentry/Platforms/Android/SentrySdk.cs @@ -134,6 +134,11 @@ private static void InitSentryAndroidSdk(SentryOptions options) options.Native.InAppExcludes?.ForEach(o.AddInAppExclude); options.Native.InAppIncludes?.ForEach(o.AddInAppInclude); + o.SessionReplay.SessionSampleRate = (JavaDouble?)((double)options.Native.SessionReplay.SessionSampleRate); + o.SessionReplay.OnErrorSampleRate = (JavaDouble?)((double)options.Native.SessionReplay.OnErrorSampleRate); + o.SessionReplay.SetMaskAllText(options.Native.SessionReplay.MaskAllText); + o.SessionReplay.SetMaskAllImages(options.Native.SessionReplay.MaskAllImages); + // These options are intentionally set and not exposed for modification o.EnableExternalConfiguration = false; o.EnableDeduplication = false; diff --git a/src/Sentry/Platforms/Cocoa/SentryOptions.cs b/src/Sentry/Platforms/Cocoa/SentryOptions.cs index 8cba664893..b7cbc83c84 100644 --- a/src/Sentry/Platforms/Cocoa/SentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/SentryOptions.cs @@ -198,10 +198,10 @@ internal NativeOptions(SentryOptions options) public NSUrlSessionDelegate? UrlSessionDelegate { get; set; } = null; /// - /// Gets or sets the session replay options. + /// Gets or sets the replay options. /// /// - /// sentry.io + /// sentry.io /// public NativeSentryReplayOptions SessionReplay { get; set; } = new(); @@ -243,50 +243,6 @@ public void AddInAppInclude(string prefix) InAppIncludes ??= new List(); InAppIncludes.Add(prefix); } - - /// - /// Native session replay options. - /// - public class NativeSentryReplayOptions - { - /// - /// Gets or sets the percentage of a session - /// replay to be sent. The value should be between 0.0 - /// and 1.0. Default is 0. - /// - /// - /// sentry.io - /// - public float SessionSampleRate { get; set; } - - /// - /// Gets or sets the percentage of an error - /// replay to be sent. The value should be between 0.0 - /// and 1.0. Default is 0. - /// - /// - /// sentry.io - /// - public float OnErrorSampleRate { get; set; } - - /// - /// Gets or sets a value determining whether - /// text should be masked during replays. - /// - /// - /// sentry.io - /// - public bool MaskAllText { get; set; } = true; - - /// - /// Gets or sets a value determining whether - /// images should be masked during replays. - /// - /// - /// sentry.io - /// - public bool MaskAllImages { get; set; } = true; - } } // We actually add the profiling integration automatically in InitSentryCocoaSdk(). From f7c780e28726c634f2142c19204e7879ee2d5c51 Mon Sep 17 00:00:00 2001 From: Paul Hunkeler Date: Mon, 13 Jan 2025 00:06:59 -0500 Subject: [PATCH 5/7] Replay Quality --- samples/Sentry.Samples.Maui/MauiProgram.cs | 1 + scripts/generate-cocoa-bindings.ps1 | 4 +- src/Sentry.Bindings.Cocoa/ApiDefinitions.cs | 4 +- src/Sentry/NativeSessionReplayOptions.cs | 57 +++++++++++++++++++ .../Android/Extensions/EnumExtensions.cs | 18 ++++++ src/Sentry/Platforms/Android/SentrySdk.cs | 5 +- .../Cocoa/Extensions/EnumExtensions.cs | 5 ++ src/Sentry/Platforms/Cocoa/SentrySdk.cs | 1 + src/Sentry/SentryReplayQuality.cs | 39 +++++++++++++ 9 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 src/Sentry/NativeSessionReplayOptions.cs create mode 100644 src/Sentry/SentryReplayQuality.cs diff --git a/samples/Sentry.Samples.Maui/MauiProgram.cs b/samples/Sentry.Samples.Maui/MauiProgram.cs index baf8316036..0e3aa3507b 100644 --- a/samples/Sentry.Samples.Maui/MauiProgram.cs +++ b/samples/Sentry.Samples.Maui/MauiProgram.cs @@ -36,6 +36,7 @@ public static MauiApp CreateMauiApp() options.Native.SessionReplay.OnErrorSampleRate = 1.0f; options.Native.SessionReplay.MaskAllText = false; options.Native.SessionReplay.MaskAllImages = false; + options.Native.SessionReplay.Quality = SentryReplayQuality.Low; #endif }) diff --git a/scripts/generate-cocoa-bindings.ps1 b/scripts/generate-cocoa-bindings.ps1 index 38f3438e6c..07c7b2598a 100644 --- a/scripts/generate-cocoa-bindings.ps1 +++ b/scripts/generate-cocoa-bindings.ps1 @@ -351,12 +351,12 @@ interface SentryReplayOptions //: ISentryRedactOptions [Export ("maskAllImages")] bool MaskAllImages { get; set; } - /* - // @property (nonatomic) enum SentryReplayQuality quality; [Export ("quality", ArgumentSemantic.Assign)] SentryReplayQuality Quality { get; set; } + /* + // @property (copy, nonatomic) NSArray * _Nonnull maskedViewClasses; //[Export ("maskedViewClasses", ArgumentSemantic.Copy)] //Class[] MaskedViewClasses { get; set; } diff --git a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs index 8dc43759ee..fade39b6d7 100644 --- a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs +++ b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs @@ -2520,12 +2520,12 @@ interface SentryReplayOptions //: ISentryRedactOptions [Export ("maskAllImages")] bool MaskAllImages { get; set; } - /* - // @property (nonatomic) enum SentryReplayQuality quality; [Export ("quality", ArgumentSemantic.Assign)] SentryReplayQuality Quality { get; set; } + /* + // @property (copy, nonatomic) NSArray * _Nonnull maskedViewClasses; //[Export ("maskedViewClasses", ArgumentSemantic.Copy)] //Class[] MaskedViewClasses { get; set; } diff --git a/src/Sentry/NativeSessionReplayOptions.cs b/src/Sentry/NativeSessionReplayOptions.cs new file mode 100644 index 0000000000..6492ec9b0b --- /dev/null +++ b/src/Sentry/NativeSessionReplayOptions.cs @@ -0,0 +1,57 @@ +namespace Sentry; + +/// +/// Native session replay options. +/// +public class NativeSentryReplayOptions +{ + /// + /// Gets or sets the percentage of a session + /// replay to be sent. The value should be between 0.0 + /// and 1.0. Default is 0. + /// + /// + /// sentry.io + /// + public float SessionSampleRate { get; set; } + + /// + /// Gets or sets the percentage of an error + /// replay to be sent. The value should be between 0.0 + /// and 1.0. Default is 0. + /// + /// + /// sentry.io + /// + public float OnErrorSampleRate { get; set; } + + /// + /// Gets or sets a value determining whether + /// text should be masked during replays. + /// + /// + /// sentry.io + /// + public bool MaskAllText { get; set; } = true; + + /// + /// Gets or sets a value determining whether + /// images should be masked during replays. + /// + /// + /// sentry.io + /// + public bool MaskAllImages { get; set; } = true; + + /// + /// Gets or sets the quality of session replays. + /// Higher quality means finer details + /// but a greater performance impact. + /// Default is . + /// + /// + /// Android + /// iOS + /// + public SentryReplayQuality Quality { get; set; } = SentryReplayQuality.Medium; +} diff --git a/src/Sentry/Platforms/Android/Extensions/EnumExtensions.cs b/src/Sentry/Platforms/Android/Extensions/EnumExtensions.cs index f9352f831d..3c353a5c02 100644 --- a/src/Sentry/Platforms/Android/Extensions/EnumExtensions.cs +++ b/src/Sentry/Platforms/Android/Extensions/EnumExtensions.cs @@ -116,4 +116,22 @@ public static JavaSdk.Protocol.TransactionNameSource ToJavaTransactionNameSource TransactionNameSource.Component => JavaSdk.Protocol.TransactionNameSource.Component, _ => throw new ArgumentOutOfRangeException(nameof(source), source, message: default) }; + + public static SentryReplayQuality ToSentryReplayQuality(this JavaSdk.SentryReplayOptions.SentryReplayQuality replayQuality) => + replayQuality.Name() switch + { + "LOW" => SentryReplayQuality.Low, + "MEDIUM" => SentryReplayQuality.Medium, + "HIGH" => SentryReplayQuality.High, + _ => throw new ArgumentOutOfRangeException(nameof(replayQuality), replayQuality.Name(), message: default) + }; + + public static JavaSdk.SentryReplayOptions.SentryReplayQuality ToJavaReplayQuality(this SentryReplayQuality replayQuality) => + replayQuality switch + { + SentryReplayQuality.Low => JavaSdk.SentryReplayOptions.SentryReplayQuality.Low, + SentryReplayQuality.Medium => JavaSdk.SentryReplayOptions.SentryReplayQuality.Medium, + SentryReplayQuality.High => JavaSdk.SentryReplayOptions.SentryReplayQuality.High, + _ => throw new ArgumentOutOfRangeException(nameof(replayQuality), replayQuality, message: default) + }; } diff --git a/src/Sentry/Platforms/Android/SentrySdk.cs b/src/Sentry/Platforms/Android/SentrySdk.cs index f37e62f44e..32baea7fc5 100644 --- a/src/Sentry/Platforms/Android/SentrySdk.cs +++ b/src/Sentry/Platforms/Android/SentrySdk.cs @@ -134,10 +134,11 @@ private static void InitSentryAndroidSdk(SentryOptions options) options.Native.InAppExcludes?.ForEach(o.AddInAppExclude); options.Native.InAppIncludes?.ForEach(o.AddInAppInclude); - o.SessionReplay.SessionSampleRate = (JavaDouble?)((double)options.Native.SessionReplay.SessionSampleRate); - o.SessionReplay.OnErrorSampleRate = (JavaDouble?)((double)options.Native.SessionReplay.OnErrorSampleRate); + o.SessionReplay.SessionSampleRate = (JavaDouble?)(double)options.Native.SessionReplay.SessionSampleRate; + o.SessionReplay.OnErrorSampleRate = (JavaDouble?)(double)options.Native.SessionReplay.OnErrorSampleRate; o.SessionReplay.SetMaskAllText(options.Native.SessionReplay.MaskAllText); o.SessionReplay.SetMaskAllImages(options.Native.SessionReplay.MaskAllImages); + o.SessionReplay.Quality = options.Native.SessionReplay.Quality.ToJavaReplayQuality(); // These options are intentionally set and not exposed for modification o.EnableExternalConfiguration = false; diff --git a/src/Sentry/Platforms/Cocoa/Extensions/EnumExtensions.cs b/src/Sentry/Platforms/Cocoa/Extensions/EnumExtensions.cs index 3cb7df8c99..50c918deb7 100644 --- a/src/Sentry/Platforms/Cocoa/Extensions/EnumExtensions.cs +++ b/src/Sentry/Platforms/Cocoa/Extensions/EnumExtensions.cs @@ -98,4 +98,9 @@ public static TransactionNameSource ToTransactionNameSource(this CocoaSdk.Sentry (TransactionNameSource)source; public static CocoaSdk.SentryTransactionNameSource ToCocoaTransactionNameSource(this TransactionNameSource source) => (CocoaSdk.SentryTransactionNameSource)source; + + public static SentryReplayQuality ToSentryReplayQuality(this CocoaSdk.SentryReplayQuality replayQuality) => + (SentryReplayQuality)replayQuality; + public static CocoaSdk.SentryReplayQuality ToCocoaSentryReplayQuality(this SentryReplayQuality replayQuality) => + (CocoaSdk.SentryReplayQuality)replayQuality; } diff --git a/src/Sentry/Platforms/Cocoa/SentrySdk.cs b/src/Sentry/Platforms/Cocoa/SentrySdk.cs index 39e1d3381a..04c9e09552 100644 --- a/src/Sentry/Platforms/Cocoa/SentrySdk.cs +++ b/src/Sentry/Platforms/Cocoa/SentrySdk.cs @@ -139,6 +139,7 @@ private static void InitSentryCocoaSdk(SentryOptions options) nativeOptions.SessionReplay.OnErrorSampleRate = options.Native.SessionReplay.OnErrorSampleRate; nativeOptions.SessionReplay.MaskAllText = options.Native.SessionReplay.MaskAllText; nativeOptions.SessionReplay.MaskAllImages = options.Native.SessionReplay.MaskAllImages; + nativeOptions.SessionReplay.Quality = options.Native.SessionReplay.Quality.ToCocoaSentryReplayQuality(); // StitchAsyncCode removed from Cocoa SDK in 8.6.0 with https://github.com/getsentry/sentry-cocoa/pull/2973 // nativeOptions.StitchAsyncCode = options.Native.StitchAsyncCode; diff --git a/src/Sentry/SentryReplayQuality.cs b/src/Sentry/SentryReplayQuality.cs new file mode 100644 index 0000000000..49d39eb664 --- /dev/null +++ b/src/Sentry/SentryReplayQuality.cs @@ -0,0 +1,39 @@ +namespace Sentry; + +/// +/// Session replay quality. Higher quality means finer details +/// but a greater performance impact. +/// +/// +/// Android +/// iOS +/// +public enum SentryReplayQuality +{ + /// + /// Low replay quality. + /// + /// + /// Android + /// iOS + /// + Low = 0, + + /// + /// Medium replay quality. + /// + /// + /// Android + /// iOS + /// + Medium = 1, + + /// + /// High replay quality. + /// + /// + /// Android + /// iOS + /// + High = 2 +} From c8358f6637ced929c78ae6d4d167dd3925135993 Mon Sep 17 00:00:00 2001 From: phunkeler Date: Wed, 15 Jan 2025 13:50:27 -0500 Subject: [PATCH 6/7] Wire-up basic apple breadcrumb conversion + migrate bits to Sentry.Maui project --- scripts/generate-cocoa-bindings.ps1 | 174 +++++++++++++++++- .../Sentry.Bindings.Android.csproj | 1 + src/Sentry.Bindings.Cocoa/ApiDefinitions.cs | 122 ++++++++++++ .../Sentry.Bindings.Cocoa.csproj | 1 + src/Sentry.Bindings.Cocoa/StructsAndEnums.cs | 9 + .../ReplayBreadcrumbConverter.macios.cs | 25 +++ .../Internal/SentryMauiOptionsSetup.cs | 5 + .../Internal/SentryMauiReplayIntegration.cs | 28 +++ src/Sentry.Maui/Sentry.Maui.csproj | 14 ++ .../SentryMauiAppBuilderExtensions.cs | 1 - src/Sentry.Maui/SentryMauiOptions.cs | 4 + 11 files changed, 381 insertions(+), 3 deletions(-) create mode 100644 src/Sentry.Maui/Internal/ReplayBreadcrumbConverter.macios.cs create mode 100644 src/Sentry.Maui/Internal/SentryMauiReplayIntegration.cs diff --git a/scripts/generate-cocoa-bindings.ps1 b/scripts/generate-cocoa-bindings.ps1 index 07c7b2598a..97fd5061b2 100644 --- a/scripts/generate-cocoa-bindings.ps1 +++ b/scripts/generate-cocoa-bindings.ps1 @@ -1,3 +1,5 @@ +# Reference: https://github.com/xamarin/xamarin-macios/blob/main/docs/website/binding_types_reference_guide.md + Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' @@ -172,10 +174,26 @@ internal enum SentryReplayType : long } '@ +# This enum resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$SentryRRWebEventType = @' + +[Native] +internal enum SentryRRWebEventType : long +{ + None = 0, + Touch = 3, + Meta = 4, + Custom = 5 +} +'@ + $Text += "`n$SentryLevel" $Text += "`n$SentryTransactionNameSource" $Text += "`n$SentryReplayQuality" $Text += "`n$SentryReplayType" +$Text += "`n$SentryRRWebEventType" + # Add header and output file @@ -262,7 +280,7 @@ $Text = $Text -replace '(DEPRECATED_MSG_ATTRIBUTE\()\n\s*', '$1' # Remove default IsEqual implementation (already implemented by NSObject) $Text = $Text -replace '(?ms)\n?^ *// [^\n]*isEqual:.*?$.*?;\n', '' -# Replace obsolete platform avaialbility attributes +# Replace obsolete platform availability attributes $Text = $Text -replace '([\[,] )MacCatalyst \(', '$1Introduced (PlatformName.MacCatalyst, ' $Text = $Text -replace '([\[,] )Mac \(', '$1Introduced (PlatformName.MacOSX, ' $Text = $Text -replace '([\[,] )iOS \(', '$1Introduced (PlatformName.iOS, ' @@ -275,7 +293,7 @@ $Text = $Text -replace '(?m)(^\s*\/\/[^\r\n]*$\s*\[Export \("serialize"\)\]$\s*) $Text = $Text -replace '.*SentryEnvelope .*?[\s\S]*?\n\n', '' $Text = $Text -replace '.*typedef.*SentryOnAppStartMeasurementAvailable.*?[\s\S]*?\n\n', '' -$Text = $Text -replace '\n.*SentryReplayBreadcrumbConverter.*?[\s\S]*?\);\n', '' +#$Text = $Text -replace '\n.*SentryReplayBreadcrumbConverter.*?[\s\S]*?\);\n', '' $propertiesToRemove = @( 'SentryAppStartMeasurement', @@ -403,6 +421,158 @@ interface SentryReplayOptions //: ISentryRedactOptions $Text += "`n$SentryReplayOptions" +# This interface resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$SentryRRWebEvent = @' + +// @interface SentryRRWebEvent : NSObject +[BaseType (typeof(NSObject), Name = "_TtC6Sentry16SentryRRWebEvent")] +[Protocol] +[Model] +[DisableDefaultCtor] +[Internal] +interface SentryRRWebEvent : SentrySerializable +{ + // @property (readonly, nonatomic) enum SentryRRWebEventType type; + [Export ("type")] + SentryRRWebEventType Type { get; } + + // @property (readonly, copy, nonatomic) NSDate * _Nonnull timestamp; + [Export ("timestamp", ArgumentSemantic.Copy)] + NSDate Timestamp { get; } + + // @property (readonly, copy, nonatomic) NSDictionary * _Nullable data; + [NullAllowed, Export ("data", ArgumentSemantic.Copy)] + NSDictionary Data { get; } + + // -(instancetype _Nonnull)initWithType:(enum SentryRRWebEventType)type timestamp:(NSDate * _Nonnull)timestamp data:(NSDictionary * _Nullable)data __attribute__((objc_designated_initializer)); + [Export ("initWithType:timestamp:data:")] + [DesignatedInitializer] + NativeHandle Constructor (SentryRRWebEventType type, NSDate timestamp, [NullAllowed] NSDictionary data); + + // -(NSDictionary * _Nonnull)serialize __attribute__((warn_unused_result(""))); + [Export ("serialize")] + new NSDictionary Serialize(); +} +'@ + +$Text += "`n$SentryRRWebEvent" + +# This interface resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$SentryReplayBreadcrumbConverter = @' + +// @protocol SentryReplayBreadcrumbConverter +[Protocol (Name = "_TtP6Sentry31SentryReplayBreadcrumbConverter_")] +[BaseType (typeof(NSObject), Name = "_TtP6Sentry31SentryReplayBreadcrumbConverter_")] +[Model] +[Internal] +interface SentryReplayBreadcrumbConverter +{ + // @required -(id _Nullable)convertFrom:(SentryBreadcrumb * _Nonnull)breadcrumb __attribute__((warn_unused_result(""))); + [Abstract] + [Export ("convertFrom:")] + [return: NullAllowed] + SentryRRWebEvent ConvertFrom (SentryBreadcrumb breadcrumb); +} +'@ + +$Text += "`n$SentryReplayBreadcrumbConverter" + +# This interface resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$SentryViewScreenshotProvider = @' + +// @protocol SentryViewScreenshotProvider +[Protocol (Name = "_TtP6Sentry28SentryViewScreenshotProvider_")] +[Model] +[BaseType (typeof(NSObject), Name = "_TtP6Sentry28SentryViewScreenshotProvider_")] +[Internal] +interface SentryViewScreenshotProvider +{ + // @required -(void)imageWithView:(UIView * _Nonnull)view onComplete:(void (^ _Nonnull)(UIImage * _Nonnull))onComplete; + [Abstract] + [Export ("imageWithView:onComplete:")] + void OnComplete (UIView view, Action onComplete); +} +'@ + +$Text += "`n$SentryViewScreenshotProvider" + +# This interface resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$defaultReplayBreadcrumbConverter = @' + +// @interface SentrySRDefaultBreadcrumbConverter : NSObject +[BaseType (typeof(NSObject), Name = "_TtC6Sentry34SentrySRDefaultBreadcrumbConverter")] +[Internal] +interface SentrySRDefaultBreadcrumbConverter +{ + // -(id _Nullable)convertFrom:(SentryBreadcrumb * _Nonnull)breadcrumb __attribute__((warn_unused_result(""))); + [Export ("convertFrom:")] + [return: NullAllowed] + SentryRRWebEvent ConvertFrom (SentryBreadcrumb breadcrumb); +} +'@ + +$Text += "`n$defaultReplayBreadcrumbConverter" + +# This interface resides in the Sentry-Swift.h +# Appending it here so we don't need to import and create bindings for the entire header +$sentrySessionReplayIntegration = @' + +// @interface SentrySessionReplayIntegration : SentryBaseIntegration +[BaseType (typeof(NSObject))] +[Internal] +interface SentrySessionReplayIntegration +{ + // -(instancetype _Nonnull)initForManualUse:(SentryOptions * _Nonnull)options; + [Export ("initForManualUse:")] + NativeHandle Constructor (SentryOptions options); + + // -(BOOL)captureReplay; + [Export ("captureReplay")] + bool CaptureReplay(); + + // -(void)configureReplayWith:(id _Nullable)breadcrumbConverter screenshotProvider:(id _Nullable)screenshotProvider; + [Export ("configureReplayWith:screenshotProvider:")] + void ConfigureReplayWith ([NullAllowed] SentryReplayBreadcrumbConverter breadcrumbConverter, [NullAllowed] SentryViewScreenshotProvider screenshotProvider); + + // -(void)pause; + [Export ("pause")] + void Pause (); + + // -(void)resume; + [Export ("resume")] + void Resume (); + + // -(void)stop; + [Export ("stop")] + void Stop (); + + // -(void)start; + [Export ("start")] + void Start (); + + // +(id _Nonnull)createBreadcrumbwithTimestamp:(NSDate * _Nonnull)timestamp category:(NSString * _Nonnull)category message:(NSString * _Nullable)message level:(enum SentryLevel)level data:(NSDictionary * _Nullable)data; + [Static] + [Export ("createBreadcrumbwithTimestamp:category:message:level:data:")] + SentryRRWebEvent CreateBreadcrumbwithTimestamp (NSDate timestamp, string category, [NullAllowed] string message, SentryLevel level, [NullAllowed] NSDictionary data); + + // +(id _Nonnull)createNetworkBreadcrumbWithTimestamp:(NSDate * _Nonnull)timestamp endTimestamp:(NSDate * _Nonnull)endTimestamp operation:(NSString * _Nonnull)operation description:(NSString * _Nonnull)description data:(NSDictionary * _Nonnull)data; + [Static] + [Export ("createNetworkBreadcrumbWithTimestamp:endTimestamp:operation:description:data:")] + SentryRRWebEvent CreateNetworkBreadcrumbWithTimestamp (NSDate timestamp, NSDate endTimestamp, string operation, string description, NSDictionary data); + + // +(id _Nonnull)createDefaultBreadcrumbConverter; + [Static] + [Export ("createDefaultBreadcrumbConverter")] + SentryReplayBreadcrumbConverter CreateDefaultBreadcrumbConverter(); +} +'@ + +$Text += "`n$sentrySessionReplayIntegration" + # Add header and output file $Text = "$Header`n`n$Text" $Text | Out-File "$BindingsPath/$File" diff --git a/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj b/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj index 97d2aa6c39..f98093f48e 100644 --- a/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj +++ b/src/Sentry.Bindings.Android/Sentry.Bindings.Android.csproj @@ -26,6 +26,7 @@ + diff --git a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs index fade39b6d7..976ecce54f 100644 --- a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs +++ b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs @@ -2424,6 +2424,11 @@ interface PrivateSentrySDKOnly [Export ("setCurrentScreen:")] void SetCurrentScreen (string screenName); + // +(void)configureSessionReplayWith:(id _Nullable)breadcrumbConverter screenshotProvider:(id _Nullable)screenshotProvider; + [Static] + [Export ("configureSessionReplayWith:screenshotProvider:")] + void ConfigureSessionReplayWith ([NullAllowed] SentryReplayBreadcrumbConverter breadcrumbConverter, [NullAllowed] SentryViewScreenshotProvider screenshotProvider); + // +(void)captureReplay; [Static] [Export ("captureReplay")] @@ -2568,3 +2573,120 @@ interface SentryReplayOptions //: ISentryRedactOptions NativeHandle Constructor (NSDictionary dictionary); */ } + +// @interface SentryRRWebEvent : NSObject +[BaseType (typeof(NSObject), Name = "_TtC6Sentry16SentryRRWebEvent")] +[Protocol] +[Model] +[DisableDefaultCtor] +[Internal] +interface SentryRRWebEvent : SentrySerializable +{ + // @property (readonly, nonatomic) enum SentryRRWebEventType type; + [Export ("type")] + SentryRRWebEventType Type { get; } + + // @property (readonly, copy, nonatomic) NSDate * _Nonnull timestamp; + [Export ("timestamp", ArgumentSemantic.Copy)] + NSDate Timestamp { get; } + + // @property (readonly, copy, nonatomic) NSDictionary * _Nullable data; + [NullAllowed, Export ("data", ArgumentSemantic.Copy)] + NSDictionary Data { get; } + + // -(instancetype _Nonnull)initWithType:(enum SentryRRWebEventType)type timestamp:(NSDate * _Nonnull)timestamp data:(NSDictionary * _Nullable)data __attribute__((objc_designated_initializer)); + [Export ("initWithType:timestamp:data:")] + [DesignatedInitializer] + NativeHandle Constructor (SentryRRWebEventType type, NSDate timestamp, [NullAllowed] NSDictionary data); + + // -(NSDictionary * _Nonnull)serialize __attribute__((warn_unused_result(""))); + [Export ("serialize")] + new NSDictionary Serialize(); +} + +// @protocol SentryReplayBreadcrumbConverter +[Protocol (Name = "_TtP6Sentry31SentryReplayBreadcrumbConverter_")] +[BaseType (typeof(NSObject), Name = "_TtP6Sentry31SentryReplayBreadcrumbConverter_")] +[Model] +[Internal] +interface SentryReplayBreadcrumbConverter +{ + // @required -(id _Nullable)convertFrom:(SentryBreadcrumb * _Nonnull)breadcrumb __attribute__((warn_unused_result(""))); + [Abstract] + [Export ("convertFrom:")] + [return: NullAllowed] + SentryRRWebEvent ConvertFrom (SentryBreadcrumb breadcrumb); +} + +// @protocol SentryViewScreenshotProvider +[Protocol (Name = "_TtP6Sentry28SentryViewScreenshotProvider_")] +[Model] +[BaseType (typeof(NSObject), Name = "_TtP6Sentry28SentryViewScreenshotProvider_")] +[Internal] +interface SentryViewScreenshotProvider +{ + // @required -(void)imageWithView:(UIView * _Nonnull)view onComplete:(void (^ _Nonnull)(UIImage * _Nonnull))onComplete; + [Abstract] + [Export ("imageWithView:onComplete:")] + void OnComplete (UIView view, Action onComplete); +} + +// @interface SentrySRDefaultBreadcrumbConverter : NSObject +[BaseType (typeof(NSObject), Name = "_TtC6Sentry34SentrySRDefaultBreadcrumbConverter")] +[Internal] +interface SentrySRDefaultBreadcrumbConverter +{ + // -(id _Nullable)convertFrom:(SentryBreadcrumb * _Nonnull)breadcrumb __attribute__((warn_unused_result(""))); + [Export ("convertFrom:")] + [return: NullAllowed] + SentryRRWebEvent ConvertFrom (SentryBreadcrumb breadcrumb); +} + +// @interface SentrySessionReplayIntegration : SentryBaseIntegration +[BaseType (typeof(NSObject))] +[Internal] +interface SentrySessionReplayIntegration +{ + // -(instancetype _Nonnull)initForManualUse:(SentryOptions * _Nonnull)options; + [Export ("initForManualUse:")] + NativeHandle Constructor (SentryOptions options); + + // -(BOOL)captureReplay; + [Export ("captureReplay")] + bool CaptureReplay(); + + // -(void)configureReplayWith:(id _Nullable)breadcrumbConverter screenshotProvider:(id _Nullable)screenshotProvider; + [Export ("configureReplayWith:screenshotProvider:")] + void ConfigureReplayWith ([NullAllowed] SentryReplayBreadcrumbConverter breadcrumbConverter, [NullAllowed] SentryViewScreenshotProvider screenshotProvider); + + // -(void)pause; + [Export ("pause")] + void Pause (); + + // -(void)resume; + [Export ("resume")] + void Resume (); + + // -(void)stop; + [Export ("stop")] + void Stop (); + + // -(void)start; + [Export ("start")] + void Start (); + + // +(id _Nonnull)createBreadcrumbwithTimestamp:(NSDate * _Nonnull)timestamp category:(NSString * _Nonnull)category message:(NSString * _Nullable)message level:(enum SentryLevel)level data:(NSDictionary * _Nullable)data; + [Static] + [Export ("createBreadcrumbwithTimestamp:category:message:level:data:")] + SentryRRWebEvent CreateBreadcrumbwithTimestamp (NSDate timestamp, string category, [NullAllowed] string message, SentryLevel level, [NullAllowed] NSDictionary data); + + // +(id _Nonnull)createNetworkBreadcrumbWithTimestamp:(NSDate * _Nonnull)timestamp endTimestamp:(NSDate * _Nonnull)endTimestamp operation:(NSString * _Nonnull)operation description:(NSString * _Nonnull)description data:(NSDictionary * _Nonnull)data; + [Static] + [Export ("createNetworkBreadcrumbWithTimestamp:endTimestamp:operation:description:data:")] + SentryRRWebEvent CreateNetworkBreadcrumbWithTimestamp (NSDate timestamp, NSDate endTimestamp, string operation, string description, NSDictionary data); + + // +(id _Nonnull)createDefaultBreadcrumbConverter; + [Static] + [Export ("createDefaultBreadcrumbConverter")] + SentryReplayBreadcrumbConverter CreateDefaultBreadcrumbConverter(); +} diff --git a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj index 60364aae34..1ba692b3f6 100644 --- a/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj +++ b/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj @@ -23,6 +23,7 @@ + diff --git a/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs b/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs index 207d08ee95..7fbf447fd3 100644 --- a/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs +++ b/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs @@ -103,3 +103,12 @@ internal enum SentryReplayType : long Session = 0, Buffer = 1 } + +[Native] +internal enum SentryRRWebEventType : long +{ + None = 0, + Touch = 3, + Meta = 4, + Custom = 5 +} diff --git a/src/Sentry.Maui/Internal/ReplayBreadcrumbConverter.macios.cs b/src/Sentry.Maui/Internal/ReplayBreadcrumbConverter.macios.cs new file mode 100644 index 0000000000..59b36c421b --- /dev/null +++ b/src/Sentry.Maui/Internal/ReplayBreadcrumbConverter.macios.cs @@ -0,0 +1,25 @@ +namespace Sentry; + +internal class ReplayBreadcrumbConverter : Sentry.CocoaSdk.SentryReplayBreadcrumbConverter +{ + public override Sentry.CocoaSdk.SentryRRWebEvent? ConvertFrom(Sentry.CocoaSdk.SentryBreadcrumb breadcrumb) + { + if (breadcrumb.Timestamp is null) + { + return null; + } + + if (string.Equals(breadcrumb.Category, "touch", StringComparison.OrdinalIgnoreCase)) + { + return Sentry.CocoaSdk.SentrySessionReplayIntegration.CreateBreadcrumbwithTimestamp( + breadcrumb.Timestamp, + breadcrumb.Category, + breadcrumb.Message, + breadcrumb.Level, + breadcrumb.Data + ); + } + + return null; + } +} \ No newline at end of file diff --git a/src/Sentry.Maui/Internal/SentryMauiOptionsSetup.cs b/src/Sentry.Maui/Internal/SentryMauiOptionsSetup.cs index d13b9731d8..b1815af80d 100644 --- a/src/Sentry.Maui/Internal/SentryMauiOptionsSetup.cs +++ b/src/Sentry.Maui/Internal/SentryMauiOptionsSetup.cs @@ -57,5 +57,10 @@ public void Configure(SentryMauiOptions options) // We can use MAUI's network connectivity information to inform the CachingTransport when we're offline. options.NetworkStatusListener = new MauiNetworkStatusListener(Connectivity.Current, options); #endif + +// TODO: Investigate why this is being called twice on iOS Simulator, resulting in 2 copies added to integrations list... +#if ANDROID || IOS || MACCATALYST + options.AddIntegration(new SentryMauiReplayIntegration(options)); +#endif } } diff --git a/src/Sentry.Maui/Internal/SentryMauiReplayIntegration.cs b/src/Sentry.Maui/Internal/SentryMauiReplayIntegration.cs new file mode 100644 index 0000000000..801b9d5479 --- /dev/null +++ b/src/Sentry.Maui/Internal/SentryMauiReplayIntegration.cs @@ -0,0 +1,28 @@ +using Sentry.Integrations; + +namespace Sentry.Maui.Internal; + +internal class SentryMauiReplayIntegration : ISdkIntegration +{ + private readonly SentryMauiOptions _sentryMauiOptions; + + public SentryMauiReplayIntegration(SentryMauiOptions sentryMauiOptions) + { + ArgumentNullException.ThrowIfNull(sentryMauiOptions); + + _sentryMauiOptions = sentryMauiOptions; + } + + public void Register(IHub hub, SentryOptions options) + { +#if IOS || MACCATALYST + if (_sentryMauiOptions.SessionReplayEnabled) + { + var breadcrumbConverter = new ReplayBreadcrumbConverter(); + Sentry.CocoaSdk.PrivateSentrySDKOnly.ConfigureSessionReplayWith(breadcrumbConverter, null); + } +#elif ANDROID + +#endif + } +} diff --git a/src/Sentry.Maui/Sentry.Maui.csproj b/src/Sentry.Maui/Sentry.Maui.csproj index ae2906bf64..91ffc033b3 100644 --- a/src/Sentry.Maui/Sentry.Maui.csproj +++ b/src/Sentry.Maui/Sentry.Maui.csproj @@ -46,4 +46,18 @@ + + + + + + + + + + + + + + diff --git a/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs b/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs index da2a569926..ad9b05ba27 100644 --- a/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs +++ b/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs @@ -55,7 +55,6 @@ public static MauiAppBuilder UseSentry(this MauiAppBuilder builder, services.AddLogging(); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton, SentryMauiOptionsSetup>(); services.AddSingleton(); services.TryAddSingleton(); diff --git a/src/Sentry.Maui/SentryMauiOptions.cs b/src/Sentry.Maui/SentryMauiOptions.cs index 51f901653c..c0ef0b242a 100644 --- a/src/Sentry.Maui/SentryMauiOptions.cs +++ b/src/Sentry.Maui/SentryMauiOptions.cs @@ -93,4 +93,8 @@ public void SetBeforeScreenshotCapture(Func befor { _beforeCapture = beforeCapture; } + +#if ANDROID || IOS || MACCATALYST + internal bool SessionReplayEnabled => Native.SessionReplay.SessionSampleRate > 0.0f || Native.SessionReplay.OnErrorSampleRate > 0.0f; +#endif } From 1356ee3f84c0133bc26dc9f93dfc8e331fbe8558 Mon Sep 17 00:00:00 2001 From: phunkeler Date: Tue, 4 Feb 2025 20:24:00 -0500 Subject: [PATCH 7/7] bump cocoasdk to 8.44.0 + fix btouch warnings --- modules/sentry-cocoa.properties | 2 +- scripts/generate-cocoa-bindings.ps1 | 20 +------------- src/Sentry.Bindings.Cocoa/ApiDefinitions.cs | 27 +++++-------------- .../Platforms/Cocoa/BindableSentryOptions.cs | 1 - 4 files changed, 9 insertions(+), 41 deletions(-) diff --git a/modules/sentry-cocoa.properties b/modules/sentry-cocoa.properties index 36a3e738d5..d352a84797 100644 --- a/modules/sentry-cocoa.properties +++ b/modules/sentry-cocoa.properties @@ -1,2 +1,2 @@ -version = 8.43.0 +version = 8.44.0 repo = https://github.com/getsentry/sentry-cocoa diff --git a/scripts/generate-cocoa-bindings.ps1 b/scripts/generate-cocoa-bindings.ps1 index 97fd5061b2..40022681fd 100644 --- a/scripts/generate-cocoa-bindings.ps1 +++ b/scripts/generate-cocoa-bindings.ps1 @@ -267,7 +267,7 @@ $Text = $Text -replace '\[Static\]\s*\[Internal\]\s*partial\s+interface\s+Consta # Update MethodToProperty translations $Text = $Text -replace '(Export \("get\w+"\)\]\n)\s*\[Verify \(MethodToProperty\)\]\n(.+ \{ get; \})', '$1$2' -$Text = $Text -replace '\[Verify \(MethodToProperty\)\]\n\s*(.+ (?:Hash|Value|DefaultIntegrations) \{ get; \})', '$1' +$Text = $Text -replace '\[Verify \(MethodToProperty\)\]\n\s*(.+ (?:Hash|Value|DefaultIntegrations|AppStartMeasurementWithSpans|BaggageHttpHeader) \{ get; \})', '$1' $Text = $Text -replace '\[Verify \(MethodToProperty\)\]\n\s*(.+) \{ get; \}', '$1();' # Allow weakly typed NSArray @@ -499,24 +499,6 @@ interface SentryViewScreenshotProvider $Text += "`n$SentryViewScreenshotProvider" -# This interface resides in the Sentry-Swift.h -# Appending it here so we don't need to import and create bindings for the entire header -$defaultReplayBreadcrumbConverter = @' - -// @interface SentrySRDefaultBreadcrumbConverter : NSObject -[BaseType (typeof(NSObject), Name = "_TtC6Sentry34SentrySRDefaultBreadcrumbConverter")] -[Internal] -interface SentrySRDefaultBreadcrumbConverter -{ - // -(id _Nullable)convertFrom:(SentryBreadcrumb * _Nonnull)breadcrumb __attribute__((warn_unused_result(""))); - [Export ("convertFrom:")] - [return: NullAllowed] - SentryRRWebEvent ConvertFrom (SentryBreadcrumb breadcrumb); -} -'@ - -$Text += "`n$defaultReplayBreadcrumbConverter" - # This interface resides in the Sentry-Swift.h # Appending it here so we don't need to import and create bindings for the entire header $sentrySessionReplayIntegration = @' diff --git a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs index 976ecce54f..6d6a08a8e6 100644 --- a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs +++ b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs @@ -279,13 +279,6 @@ interface SentryClient void Close (); } -// @interface SentryCrashExceptionApplication : NSObject -[BaseType (typeof(NSObject))] -[Internal] -interface SentryCrashExceptionApplication -{ -} - // @interface SentryDebugImageProvider : NSObject [BaseType (typeof(NSObject))] [Internal] @@ -870,7 +863,7 @@ interface SentrySpan : SentrySerializable // @required -(NSString * _Nullable)baggageHttpHeader; [Abstract] [NullAllowed, Export ("baggageHttpHeader")] - string BaggageHttpHeader(); + string BaggageHttpHeader { get; } } // @interface SentryHub : NSObject @@ -2459,10 +2452,15 @@ interface PrivateSentrySDKOnly [Export ("setRedactContainerClass:")] void SetRedactContainerClass (Class containerClass); + // +(void)setReplayTags:(NSDictionary * _Nonnull)tags; + [Static] + [Export ("setReplayTags:")] + void SetReplayTags (NSDictionary tags); + // +(NSDictionary * _Nullable)appStartMeasurementWithSpans; [Static] [NullAllowed, Export ("appStartMeasurementWithSpans")] - NSDictionary AppStartMeasurementWithSpans(); + NSDictionary AppStartMeasurementWithSpans { get; } // +(SentryUser * _Nonnull)userWithDictionary:(NSDictionary * _Nonnull)dictionary; [Static] @@ -2631,17 +2629,6 @@ interface SentryViewScreenshotProvider void OnComplete (UIView view, Action onComplete); } -// @interface SentrySRDefaultBreadcrumbConverter : NSObject -[BaseType (typeof(NSObject), Name = "_TtC6Sentry34SentrySRDefaultBreadcrumbConverter")] -[Internal] -interface SentrySRDefaultBreadcrumbConverter -{ - // -(id _Nullable)convertFrom:(SentryBreadcrumb * _Nonnull)breadcrumb __attribute__((warn_unused_result(""))); - [Export ("convertFrom:")] - [return: NullAllowed] - SentryRRWebEvent ConvertFrom (SentryBreadcrumb breadcrumb); -} - // @interface SentrySessionReplayIntegration : SentryBaseIntegration [BaseType (typeof(NSObject))] [Internal] diff --git a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs index e9d5ca14f1..38916418ea 100644 --- a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs @@ -50,7 +50,6 @@ public void ApplyTo(SentryOptions.NativeOptions options) options.EnableUIViewControllerTracing = EnableUIViewControllerTracing ?? options.EnableUIViewControllerTracing; options.EnableUserInteractionTracing = EnableUserInteractionTracing ?? options.EnableUserInteractionTracing; options.EnableTracing = EnableTracing ?? options.EnableTracing; - options.SessionReplay = SessionReplay ?? options.SessionReplay; } } }