Skip to content

Commit 26e89f5

Browse files
authored
chore: Cleanup OptionsConfiguration template (#1972)
1 parent 18a99fd commit 26e89f5

File tree

2 files changed

+17
-111
lines changed

2 files changed

+17
-111
lines changed

samples/unity-of-bugs/Assets/Scripts/SentryOptionConfiguration.cs

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,70 +8,18 @@ public override void Configure(SentryUnityOptions options)
88
{
99
// Here you can programmatically modify the Sentry option properties used for the SDK's initialization
1010

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.");
1712

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
6714
var sceneName = SceneManager.GetActiveScene().name;
6815
if (sceneName != null && sceneName.Contains("TestScene"))
6916
{
7017
Debug.Log("Disabling the SDK while running tests.");
7118
options.Enabled = false;
7219
}
7320

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.
7523
options.SetBeforeSend((sentryEvent, _) =>
7624
{
7725
if (sentryEvent.Tags.ContainsKey("SomeTag"))
@@ -83,8 +31,19 @@ public override void Configure(SentryUnityOptions options)
8331
return sentryEvent;
8432
});
8533

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
8746

88-
Debug.Log("OptionConfigure finished.");
47+
Debug.Log("SentryOptionConfigure finished.");
8948
}
9049
}

src/Sentry.Unity/SentryOptionsConfiguration.cs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,59 +14,6 @@ public class {{ScriptName}} : SentryOptionsConfiguration
1414
public override void Configure(SentryUnityOptions options)
1515
{
1616
// Here you can programmatically modify the Sentry option properties used for the SDK's initialization
17-
18-
#if UNITY_ANDROID || UNITY_IOS
19-
// NOTE!
20-
// On Android and iOS, ALL options configured here will be "baked" into the exported project
21-
// during the build process.
22-
// Changes to the options at runtime will not affect the native SDKs (Java, C/C++, Objective-C)
23-
// and only apply to the C# layer.
24-
25-
/*
26-
* Sentry Unity SDK - Hybrid Architecture
27-
* ======================================
28-
*
29-
* Build Time Runtime
30-
* ┌─────────────────────────┐ ┌─────────────────────────┐
31-
* │ Unity Editor │ │ Game Startup │
32-
* └──────────┬──────────────┘ └───────────┬─────────────┘
33-
* │ │
34-
* ▼ ▼
35-
* ┌────────────────────────────────────────────────────────────┐
36-
* │ Options Configuration │
37-
* │ (This Method) │
38-
* └─────────────────────────────┬──────────────────────────────┘
39-
* │
40-
* ┌───────────────────────────────────┐
41-
* │ Options used for Init │
42-
* ▼ ▼
43-
* ┌──────────────────────────┐ ┌──────────────────────┐
44-
* │ Native SDK │ │ Unity C# SDK │
45-
* │ Android & iOS │ │ Initialization │
46-
* │ ┌────────────────────┐ │ └──────────────────────┘
47-
* │ │ Options "Baked in" │ │
48-
* │ └────────────────────┘ │
49-
* │ The configure call made │
50-
* │ for this part ran on │
51-
* │ your build-machine │
52-
* └──────────────────────────┘
53-
* │
54-
* ▼
55-
* ┌──────────────────────────┐
56-
* │ Native SDK │
57-
* │ Android & iOS │
58-
* └──────────────────────────┘
59-
*/
60-
61-
// Works as expected and will enable all debug logging
62-
// options.Debug = true;
63-
64-
// Will NOT work as expected.
65-
// This will run twice.
66-
// 1. Once during the build, being baked into the native SDKs
67-
// 2. And a second time every time when the game starts
68-
// options.Release = ComputeVersion();
69-
#endif
7017
}
7118
}
7219
""";

0 commit comments

Comments
 (0)