Skip to content

task(config): new configuration option PersistUser #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 19, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Enhancements

* Add `PersistUser ` config option to set the [native Android option](https://docs.bugsnag.com/platforms/android/configuration-options/#persistuser) and the [native Cocoa option](https://docs.bugsnag.com/platforms/ios/configuration-options/#persistuser) [#372](https://github.com/bugsnag/bugsnag-unity/pull/372)

* Add `MaxPersistedEvents ` config option to set the [native Android option](https://docs.bugsnag.com/platforms/android/configuration-options/#maxpersistedevents) and the [native Cocoa option](https://docs.bugsnag.com/platforms/ios/configuration-options/#maxpersistedevents) [#371](https://github.com/bugsnag/bugsnag-unity/pull/371)

* Add `RedactedKeys` configuration option to enable redacting specific keys in metadata [#367](https://github.com/bugsnag/bugsnag-unity/pull/367)
Expand Down
6 changes: 6 additions & 0 deletions src/BugsnagUnity.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

void bugsnag_setAppVersion(const void *configuration, char *appVersion);

void bugsnag_setPersistUser(const void *configuration, bool persistUser);

void bugsnag_setAutoNotifyConfig(const void *configuration, bool autoNotify);

void bugsnag_setAutoNotify(bool autoNotify);
Expand Down Expand Up @@ -252,6 +254,10 @@ void bugsnag_setAutoNotifyConfig(const void *configuration, bool autoNotify) {
((__bridge BugsnagConfiguration *)configuration).autoDetectErrors = autoNotify;
}

void bugsnag_setPersistUser(const void *configuration, bool persistUser) {
((__bridge BugsnagConfiguration *)configuration).persistUser = persistUser;
}

void bugsnag_setAutoNotify(bool autoNotify) {
Bugsnag.client.autoNotify = autoNotify;
}
Expand Down
2 changes: 2 additions & 0 deletions src/BugsnagUnity/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class Configuration : IConfiguration

public string[] RedactedKeys { get; set; } = new string[] { "password" };

public bool PersistUser { get; set; }

public bool KeyIsRedacted(string key)
{
if (RedactedKeys == null || RedactedKeys.Length == 0)
Expand Down
2 changes: 2 additions & 0 deletions src/BugsnagUnity/IConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public interface IConfiguration

string[] RedactedKeys { get; set; }

bool PersistUser { get; set; }

int MaxPersistedEvents { get; set; }

bool KeyIsRedacted(string key);
Expand Down
5 changes: 2 additions & 3 deletions src/BugsnagUnity/Native/Android/NativeInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,12 @@ AndroidJavaObject CreateNativeConfig(IConfiguration config)
obj.Call("setEndpoints", endpointConfig);
}

// set version/context/maxbreadcrumbs/AppType/maxPersistedEvents/maxPersistedSessions
// set version/context/maxbreadcrumbs/AppType/maxPersistedEvents/PersistUser
obj.Call("setAppVersion", config.AppVersion);
obj.Call("setContext", config.Context);
obj.Call("setMaxBreadcrumbs", config.MaximumBreadcrumbs);
obj.Call("setMaxPersistedEvents", config.MaxPersistedEvents);


obj.Call("setPersistUser",config.PersistUser);

//Null or empty check necessary because android will set the app.type to empty if that or null is passed as default
if (!string.IsNullOrEmpty(config.AppType))
Expand Down
2 changes: 2 additions & 0 deletions src/BugsnagUnity/Native/Cocoa/NativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ IntPtr CreateNativeConfig(IConfiguration config)
NativeCode.bugsnag_setMaxBreadcrumbs(obj, config.MaximumBreadcrumbs);
NativeCode.bugsnag_setBundleVersion(obj, config.BundleVersion);
NativeCode.bugsnag_setAppType(obj, config.AppType);
NativeCode.bugsnag_setPersistUser(obj,config.PersistUser);
NativeCode.bugsnag_setMaxPersistedEvents(obj, config.MaxPersistedEvents);

if (config.DiscardClasses != null && config.DiscardClasses.Length > 0)
{
NativeCode.bugsnag_setDiscardClasses(obj, config.DiscardClasses, config.DiscardClasses.Length);
Expand Down
5 changes: 4 additions & 1 deletion src/BugsnagUnity/Native/Cocoa/NativeCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ partial class NativeCode
internal static extern void bugsnag_setAutoNotify(bool autoNotify);

[DllImport(Import)]
internal static extern void bugsnag_setAutoNotifyConfig(IntPtr configuration, bool autoNotify);
internal static extern void bugsnag_setAutoNotifyConfig(IntPtr configuration, bool autoNotify);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't see what's changed here 😅


[DllImport(Import)]
internal static extern void bugsnag_setPersistUser(IntPtr configuration, bool persistUser);

[DllImport(Import)]
internal static extern void bugsnag_setContext(IntPtr configuration, string context);
Expand Down