@@ -8,70 +8,18 @@ public override void Configure(SentryUnityOptions options)
8
8
{
9
9
// Here you can programmatically modify the Sentry option properties used for the SDK's initialization
10
10
11
- #if UNITY_ANDROID || UNITY_IOS
12
- // NOTE!
13
- // On Android and iOS, ALL options configured here will be "baked" into the exported project
14
- // during the build process.
15
- // Changes to the options at runtime will not affect the native SDKs (Java, C/C++, Objective-C)
16
- // and only apply to the C# layer.
11
+ Debug . Log ( "SentryOptionConfigure started." ) ;
17
12
18
- /*
19
- * Sentry Unity SDK - Hybrid Architecture
20
- * ======================================
21
- *
22
- * Build Time Runtime
23
- * ┌─────────────────────────┐ ┌─────────────────────────┐
24
- * │ Unity Editor │ │ Game Startup │
25
- * └──────────┬──────────────┘ └───────────┬─────────────┘
26
- * │ │
27
- * ▼ ▼
28
- * ┌────────────────────────────────────────────────────────────┐
29
- * │ Options Configuration │
30
- * │ (This Method) │
31
- * └─────────────────────────────┬──────────────────────────────┘
32
- * │
33
- * ┌───────────────────────────────────┐
34
- * │ Options used for Init │
35
- * ▼ ▼
36
- * ┌──────────────────────────┐ ┌──────────────────────┐
37
- * │ Native SDK │ │ Unity C# SDK │
38
- * │ Android & iOS │ │ Initialization │
39
- * │ ┌────────────────────┐ │ └──────────────────────┘
40
- * │ │ Options "Baked in" │ │
41
- * │ └────────────────────┘ │
42
- * │ The configure call made │
43
- * │ for this part ran on │
44
- * │ your build-machine │
45
- * └──────────────────────────┘
46
- * │
47
- * ▼
48
- * ┌──────────────────────────┐
49
- * │ Native SDK │
50
- * │ Android & iOS │
51
- * └──────────────────────────┘
52
- */
53
-
54
- // Works as expected and will enable all debug logging
55
- // options.Debug = true;
56
-
57
- // Will NOT work as expected.
58
- // This will run twice.
59
- // 1. Once during the build, being baked into the native SDKs
60
- // 2. And a second time every time when the game starts
61
- // options.Release = ComputeVersion();
62
- #endif
63
-
64
- Debug . Log ( "OptionConfigure started." ) ;
65
-
66
- // Making sure the SDK is not already initialized during tests
13
+ // This is making sure the SDK is not already initialized during tests for local development
67
14
var sceneName = SceneManager . GetActiveScene ( ) . name ;
68
15
if ( sceneName != null && sceneName . Contains ( "TestScene" ) )
69
16
{
70
17
Debug . Log ( "Disabling the SDK while running tests." ) ;
71
18
options . Enabled = false ;
72
19
}
73
20
74
- // BeforeSend is only relevant at runtime. It wouldn't hurt to be set at build time, just wouldn't do anything.
21
+ // BeforeSend is currently limited to C# code. Native errors - such as crashes in C/C++ code - are getting
22
+ // captured by the native SDKs, but the native SDKs won't invoke this callback.
75
23
options . SetBeforeSend ( ( sentryEvent , _ ) =>
76
24
{
77
25
if ( sentryEvent . Tags . ContainsKey ( "SomeTag" ) )
@@ -83,8 +31,19 @@ public override void Configure(SentryUnityOptions options)
83
31
return sentryEvent ;
84
32
} ) ;
85
33
86
- options . IosNativeInitializationType = NativeInitializationType . BuildTime ;
34
+ // Native SDK initialization timing options:
35
+ // Build-time initialization:
36
+ // + Can capture Unity engine errors
37
+ // - Options are fixed at build time
38
+ // Runtime initialization:
39
+ // + Allows dynamic configuration
40
+ // - May miss some early errors
41
+ #if UNITY_ANDROID
42
+ options . AndroidNativeInitializationType = NativeInitializationType . Runtime ;
43
+ #elif UNITY_IOS
44
+ options . IosNativeInitializationType = NativeInitializationType . Runtime ;
45
+ #endif
87
46
88
- Debug . Log ( "OptionConfigure finished." ) ;
47
+ Debug . Log ( "SentryOptionConfigure finished." ) ;
89
48
}
90
49
}
0 commit comments