Skip to content

Commit b0cb809

Browse files
author
Aleix Ventayol
committed
Add configuration options for Bugfender initialization and create metadata file
1 parent 6af37f6 commit b0cb809

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

Runtime/Bugfender.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using UnityEngine;
1+
using UnityEngine;
22
using System.Runtime.InteropServices;
33
using UnityEngine.Diagnostics;
44

@@ -69,6 +69,18 @@ public enum LogLevel { Debug, Warning, Error, Trace, Info, Fatal };
6969
// Automatically called when scene starts
7070
void Start()
7171
{
72+
// Optional override from Resources/bugfender_app_key.txt (e.g. for CI or per-build config)
73+
var keyAsset = Resources.Load<TextAsset>("bugfender_app_key");
74+
if (keyAsset != null && !string.IsNullOrWhiteSpace(keyAsset.text))
75+
{
76+
APP_KEY = keyAsset.text.Trim();
77+
}
78+
// Optional: set Resources/bugfender_print_to_console.txt to "true" to mirror logs to logcat (Android) / Xcode console (iOS)
79+
var printAsset = Resources.Load<TextAsset>("bugfender_print_to_console");
80+
if (printAsset != null && string.Equals(printAsset.text.Trim(), "true", System.StringComparison.OrdinalIgnoreCase))
81+
{
82+
PRINT_TO_CONSOLE = true;
83+
}
7284
Debug.Log("[BF] *** INITIALIZING BUGFENDER ***");
7385
#if UNITY_ANDROID && !UNITY_EDITOR
7486
if (bugfender == null) {
@@ -99,6 +111,11 @@ void Start()
99111
if (ENABLE_CRASH_REPORTING) {
100112
bugfender.CallStatic ("enableCrashReporting");
101113
}
114+
// Optional: set Resources/bugfender_debug.txt to "true" to enable native SDK debug logs (tag BF/DEBUG in logcat)
115+
var debugAsset = Resources.Load<TextAsset>("bugfender_debug");
116+
if (debugAsset != null && string.Equals(debugAsset.text.Trim(), "true", System.StringComparison.OrdinalIgnoreCase)) {
117+
try { bugfender.CallStatic("setDebugMode", true); } catch (AndroidJavaException) { /* ignore if not available */ }
118+
}
102119
//bugfender.CallStatic ("enableLogcatLogging"); // optional, uncomment if you want it (Android only)
103120
}
104121

Runtime/Plugins/iOS/BugfenderBridge.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
void BugfenderSetSDKType(const char* sdkType, int version) {
2727
SEL selector = NSSelectorFromString(@"setSDKType:version:");
2828
if ([Bugfender respondsToSelector:selector]) {
29-
typedef void (*SetSDKTypeMethod)(id, SEL, NSString*, int);
30-
SetSDKTypeMethod method = (SetSDKTypeMethod)[Bugfender methodForSelector:selector];
31-
method(Bugfender, selector, convertCStringToNSString(sdkType), version);
29+
typedef void (*SetSDKTypeFunc)(id, SEL, NSString*, int);
30+
SetSDKTypeFunc invoke = (SetSDKTypeFunc)[Bugfender methodForSelector:selector];
31+
invoke((id)[Bugfender class], selector, convertCStringToNSString(sdkType), version);
3232
}
3333
}
3434

TESTING.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)