Skip to content

Commit f7c780e

Browse files
author
Paul Hunkeler
committed
Replay Quality
1 parent d807f2d commit f7c780e

File tree

9 files changed

+128
-6
lines changed

9 files changed

+128
-6
lines changed

samples/Sentry.Samples.Maui/MauiProgram.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static MauiApp CreateMauiApp()
3636
options.Native.SessionReplay.OnErrorSampleRate = 1.0f;
3737
options.Native.SessionReplay.MaskAllText = false;
3838
options.Native.SessionReplay.MaskAllImages = false;
39+
options.Native.SessionReplay.Quality = SentryReplayQuality.Low;
3940
#endif
4041
})
4142

scripts/generate-cocoa-bindings.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,12 @@ interface SentryReplayOptions //: ISentryRedactOptions
351351
[Export ("maskAllImages")]
352352
bool MaskAllImages { get; set; }
353353
354-
/*
355-
356354
// @property (nonatomic) enum SentryReplayQuality quality;
357355
[Export ("quality", ArgumentSemantic.Assign)]
358356
SentryReplayQuality Quality { get; set; }
359357
358+
/*
359+
360360
// @property (copy, nonatomic) NSArray<Class> * _Nonnull maskedViewClasses;
361361
//[Export ("maskedViewClasses", ArgumentSemantic.Copy)]
362362
//Class[] MaskedViewClasses { get; set; }

src/Sentry.Bindings.Cocoa/ApiDefinitions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,12 +2520,12 @@ interface SentryReplayOptions //: ISentryRedactOptions
25202520
[Export ("maskAllImages")]
25212521
bool MaskAllImages { get; set; }
25222522

2523-
/*
2524-
25252523
// @property (nonatomic) enum SentryReplayQuality quality;
25262524
[Export ("quality", ArgumentSemantic.Assign)]
25272525
SentryReplayQuality Quality { get; set; }
25282526

2527+
/*
2528+
25292529
// @property (copy, nonatomic) NSArray<Class> * _Nonnull maskedViewClasses;
25302530
//[Export ("maskedViewClasses", ArgumentSemantic.Copy)]
25312531
//Class[] MaskedViewClasses { get; set; }
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
namespace Sentry;
2+
3+
/// <summary>
4+
/// Native session replay options.
5+
/// </summary>
6+
public class NativeSentryReplayOptions
7+
{
8+
/// <summary>
9+
/// Gets or sets the percentage of a session
10+
/// replay to be sent. The value should be between 0.0
11+
/// and 1.0. Default is 0.
12+
/// </summary>
13+
/// <remarks>
14+
/// <see href="https://docs.sentry.io/product/explore/session-replay/mobile/">sentry.io</see>
15+
/// </remarks>
16+
public float SessionSampleRate { get; set; }
17+
18+
/// <summary>
19+
/// Gets or sets the percentage of an error
20+
/// replay to be sent. The value should be between 0.0
21+
/// and 1.0. Default is 0.
22+
/// </summary>
23+
/// <remarks>
24+
/// <see href="https://docs.sentry.io/product/explore/session-replay/mobile/">sentry.io</see>
25+
/// </remarks>
26+
public float OnErrorSampleRate { get; set; }
27+
28+
/// <summary>
29+
/// Gets or sets a value determining whether
30+
/// text should be masked during replays.
31+
/// </summary>
32+
/// <remarks>
33+
/// <see href="https://docs.sentry.io/product/explore/session-replay/mobile/">sentry.io</see>
34+
/// </remarks>
35+
public bool MaskAllText { get; set; } = true;
36+
37+
/// <summary>
38+
/// Gets or sets a value determining whether
39+
/// images should be masked during replays.
40+
/// </summary>
41+
/// <remarks>
42+
/// <see href="https://docs.sentry.io/product/explore/session-replay/mobile/">sentry.io</see>
43+
/// </remarks>
44+
public bool MaskAllImages { get; set; } = true;
45+
46+
/// <summary>
47+
/// Gets or sets the quality of session replays.
48+
/// Higher quality means finer details
49+
/// but a greater performance impact.
50+
/// Default is <see cref="SentryReplayQuality.Medium"/>.
51+
/// </summary>
52+
/// <remarks>
53+
/// <see href="https://docs.sentry.io/platforms/android/session-replay/performance-overhead/">Android</see>
54+
/// <see href="https://docs.sentry.io/platforms/apple/guides/ios/session-replay/performance-overhead/">iOS</see>
55+
/// </remarks>
56+
public SentryReplayQuality Quality { get; set; } = SentryReplayQuality.Medium;
57+
}

src/Sentry/Platforms/Android/Extensions/EnumExtensions.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,22 @@ public static JavaSdk.Protocol.TransactionNameSource ToJavaTransactionNameSource
116116
TransactionNameSource.Component => JavaSdk.Protocol.TransactionNameSource.Component,
117117
_ => throw new ArgumentOutOfRangeException(nameof(source), source, message: default)
118118
};
119+
120+
public static SentryReplayQuality ToSentryReplayQuality(this JavaSdk.SentryReplayOptions.SentryReplayQuality replayQuality) =>
121+
replayQuality.Name() switch
122+
{
123+
"LOW" => SentryReplayQuality.Low,
124+
"MEDIUM" => SentryReplayQuality.Medium,
125+
"HIGH" => SentryReplayQuality.High,
126+
_ => throw new ArgumentOutOfRangeException(nameof(replayQuality), replayQuality.Name(), message: default)
127+
};
128+
129+
public static JavaSdk.SentryReplayOptions.SentryReplayQuality ToJavaReplayQuality(this SentryReplayQuality replayQuality) =>
130+
replayQuality switch
131+
{
132+
SentryReplayQuality.Low => JavaSdk.SentryReplayOptions.SentryReplayQuality.Low,
133+
SentryReplayQuality.Medium => JavaSdk.SentryReplayOptions.SentryReplayQuality.Medium,
134+
SentryReplayQuality.High => JavaSdk.SentryReplayOptions.SentryReplayQuality.High,
135+
_ => throw new ArgumentOutOfRangeException(nameof(replayQuality), replayQuality, message: default)
136+
};
119137
}

src/Sentry/Platforms/Android/SentrySdk.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,11 @@ private static void InitSentryAndroidSdk(SentryOptions options)
134134
options.Native.InAppExcludes?.ForEach(o.AddInAppExclude);
135135
options.Native.InAppIncludes?.ForEach(o.AddInAppInclude);
136136

137-
o.SessionReplay.SessionSampleRate = (JavaDouble?)((double)options.Native.SessionReplay.SessionSampleRate);
138-
o.SessionReplay.OnErrorSampleRate = (JavaDouble?)((double)options.Native.SessionReplay.OnErrorSampleRate);
137+
o.SessionReplay.SessionSampleRate = (JavaDouble?)(double)options.Native.SessionReplay.SessionSampleRate;
138+
o.SessionReplay.OnErrorSampleRate = (JavaDouble?)(double)options.Native.SessionReplay.OnErrorSampleRate;
139139
o.SessionReplay.SetMaskAllText(options.Native.SessionReplay.MaskAllText);
140140
o.SessionReplay.SetMaskAllImages(options.Native.SessionReplay.MaskAllImages);
141+
o.SessionReplay.Quality = options.Native.SessionReplay.Quality.ToJavaReplayQuality();
141142

142143
// These options are intentionally set and not exposed for modification
143144
o.EnableExternalConfiguration = false;

src/Sentry/Platforms/Cocoa/Extensions/EnumExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,9 @@ public static TransactionNameSource ToTransactionNameSource(this CocoaSdk.Sentry
9898
(TransactionNameSource)source;
9999
public static CocoaSdk.SentryTransactionNameSource ToCocoaTransactionNameSource(this TransactionNameSource source) =>
100100
(CocoaSdk.SentryTransactionNameSource)source;
101+
102+
public static SentryReplayQuality ToSentryReplayQuality(this CocoaSdk.SentryReplayQuality replayQuality) =>
103+
(SentryReplayQuality)replayQuality;
104+
public static CocoaSdk.SentryReplayQuality ToCocoaSentryReplayQuality(this SentryReplayQuality replayQuality) =>
105+
(CocoaSdk.SentryReplayQuality)replayQuality;
101106
}

src/Sentry/Platforms/Cocoa/SentrySdk.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ private static void InitSentryCocoaSdk(SentryOptions options)
139139
nativeOptions.SessionReplay.OnErrorSampleRate = options.Native.SessionReplay.OnErrorSampleRate;
140140
nativeOptions.SessionReplay.MaskAllText = options.Native.SessionReplay.MaskAllText;
141141
nativeOptions.SessionReplay.MaskAllImages = options.Native.SessionReplay.MaskAllImages;
142+
nativeOptions.SessionReplay.Quality = options.Native.SessionReplay.Quality.ToCocoaSentryReplayQuality();
142143

143144
// StitchAsyncCode removed from Cocoa SDK in 8.6.0 with https://github.com/getsentry/sentry-cocoa/pull/2973
144145
// nativeOptions.StitchAsyncCode = options.Native.StitchAsyncCode;

src/Sentry/SentryReplayQuality.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace Sentry;
2+
3+
/// <summary>
4+
/// Session replay quality. Higher quality means finer details
5+
/// but a greater performance impact.
6+
/// </summary>
7+
/// <remarks>
8+
/// <see href="https://docs.sentry.io/platforms/android/session-replay/performance-overhead/">Android</see>
9+
/// <see href="https://docs.sentry.io/platforms/apple/guides/ios/session-replay/performance-overhead/">iOS</see>
10+
/// </remarks>
11+
public enum SentryReplayQuality
12+
{
13+
/// <summary>
14+
/// Low replay quality.
15+
/// </summary>
16+
/// <remarks>
17+
/// <see href="https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/SentryReplayOptions.java">Android</see>
18+
/// <see href="https://github.com/getsentry/sentry-cocoa/blob/main/Sources/Swift/Integrations/SessionReplay/SentryReplayOptions.swift">iOS</see>
19+
/// </remarks>
20+
Low = 0,
21+
22+
/// <summary>
23+
/// Medium replay quality.
24+
/// </summary>
25+
/// <remarks>
26+
/// <see href="https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/SentryReplayOptions.java">Android</see>
27+
/// <see href="https://github.com/getsentry/sentry-cocoa/blob/main/Sources/Swift/Integrations/SessionReplay/SentryReplayOptions.swift">iOS</see>
28+
/// </remarks>
29+
Medium = 1,
30+
31+
/// <summary>
32+
/// High replay quality.
33+
/// </summary>
34+
/// <remarks>
35+
/// <see href="https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/SentryReplayOptions.java">Android</see>
36+
/// <see href="https://github.com/getsentry/sentry-cocoa/blob/main/Sources/Swift/Integrations/SessionReplay/SentryReplayOptions.swift">iOS</see>
37+
/// </remarks>
38+
High = 2
39+
}

0 commit comments

Comments
 (0)