Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-dev/Plugins/iOS/SentryNativeBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ int SentryNativeBridgeStartWithOptions(const void *options)
return 1;
}

void SentryNativeBridgeSetSdkName()
{
[PrivateSentrySDKOnly performSelector:@selector(setSdkName:) withObject:@"sentry.cocoa.unity"];
}

int SentryNativeBridgeCrashedLastRun() { return [SentrySDK crashedLastRun] ? 1 : 0; }

void SentryNativeBridgeClose() { [SentrySDK close]; }
Expand Down
2 changes: 2 additions & 0 deletions package-dev/Plugins/iOS/SentryNativeBridgeNoOp.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ void SentryNativeBridgeOptionsSetString(void *options, const char *name, const c
void SentryNativeBridgeOptionsSetInt(void *options, const char *name, int32_t value) { }
int SentryNativeBridgeStartWithOptions(void *options) { return 0; }

void SentryNativeBridgeSetSdkName() { }

int SentryNativeBridgeCrashedLastRun() { return 0; }

void SentryNativeBridgeClose() { }
Expand Down
5 changes: 5 additions & 0 deletions package-dev/Plugins/macOS/SentryNativeBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ void SentryConfigureScope(void (^callback)(id))
/* - use [obj setValue:value forKey:@"prop"] instead of `obj.prop = value` */
/*******************************************************************************/

void SentryNativeBridgeSetSdkName()
{
[PrivateSentrySDKOnly performSelector:@selector(setSdkName:) withObject:@"sentry.cocoa.unity"];
}

int SentryNativeBridgeCrashedLastRun()
{
@try {
Expand Down
3 changes: 3 additions & 0 deletions src/Sentry.Unity.iOS/SentryCocoaBridgeProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public static bool Init(SentryUnityOptions options)
[DllImport("__Internal", EntryPoint = "SentryNativeBridgeStartWithOptions")]
private static extern int StartWithOptions(IntPtr options);

[DllImport("__Internal", EntryPoint = "SentryNativeBridgeSetSdkName")]
public static extern int SetSdkName();

[DllImport("__Internal", EntryPoint = "SentryNativeBridgeCrashedLastRun")]
public static extern int CrashedLastRun();

Expand Down
2 changes: 2 additions & 0 deletions src/Sentry.Unity.iOS/SentryNativeCocoa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ internal static void Configure(SentryUnityOptions options, ISentryUnityInfo sent
options.ScopeObserver = new NativeScopeObserver("macOS", options);
}

SentryCocoaBridgeProxy.SetSdkName(); // Since we're not building the SDK we have to overwrite the name here

options.NativeContextWriter = new NativeContextWriter();
options.EnableScopeSync = true;
options.CrashedLastRun = () =>
Expand Down
15 changes: 15 additions & 0 deletions test/Sentry.Unity.Editor.iOS.Tests/NativeOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ public void CreateOptionsFile_NewSentryOptions_ContainsBaseOptions()
File.Delete(testOptionsFileName);
}

[Test]
public void CreateOptionsFile_NewSentryOptions_ContainsSdkNameSetting()
{
const string testOptionsFileName = "testOptions.m";

NativeOptions.CreateFile(testOptionsFileName, new SentryUnityOptions());

Assert.IsTrue(File.Exists(testOptionsFileName)); // Sanity check

var nativeOptions = File.ReadAllText(testOptionsFileName);
StringAssert.Contains("sentry.cocoa.unity", nativeOptions);

File.Delete(testOptionsFileName);
}

[Test]
public void CreateOptionsFile_FilterBadGatewayEnabled_AddsFiltering()
{
Expand Down