Skip to content

Fix Android ReleaseStage not being set #124

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
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
42 changes: 23 additions & 19 deletions src/BugsnagUnity/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ public abstract class AbstractConfiguration : IConfiguration

public const string DefaultSessionEndpoint = "https://sessions.bugsnag.com";

public AbstractConfiguration(string apiKey)
public AbstractConfiguration() {}

protected virtual void SetupDefaults(string apiKey)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If all the default values that would be overridden are set here, they won't need to be set in the other configurations.

{
ApiKey = apiKey;
AppVersion = Application.version;
}

public bool ReportUncaughtExceptionsAsHandled { get; set; } = true;
public virtual bool ReportUncaughtExceptionsAsHandled { get; set; } = true;

public TimeSpan MaximumLogsTimePeriod { get; set; } = TimeSpan.FromSeconds(1);
public virtual TimeSpan MaximumLogsTimePeriod { get; set; } = TimeSpan.FromSeconds(1);

public Dictionary<LogType, int> MaximumTypePerTimePeriod { get; set; } = new Dictionary<LogType, int>
public virtual Dictionary<LogType, int> MaximumTypePerTimePeriod { get; set; } = new Dictionary<LogType, int>
{
{ LogType.Assert, 5 },
{ LogType.Error, 5 },
Expand All @@ -29,35 +31,37 @@ public AbstractConfiguration(string apiKey)
{ LogType.Warning, 5 },
};

public TimeSpan UniqueLogsTimePeriod { get; set; } = TimeSpan.FromSeconds(5);
public virtual TimeSpan UniqueLogsTimePeriod { get; set; } = TimeSpan.FromSeconds(5);

public virtual string ApiKey { get; protected set; }

public string ApiKey { get; }
public virtual int MaximumBreadcrumbs { get; set; } = 25;

public int MaximumBreadcrumbs { get; set; } = 25;
public virtual string ReleaseStage { get; set; } = "production";

public string ReleaseStage { get; set; } = "production";
public virtual string[] NotifyReleaseStages { get; set; }

public string[] NotifyReleaseStages { get; set; }
public virtual string AppVersion { get; set; }

public string AppVersion { get; set; }
private string RealAppVersion { get; set; }

public Uri Endpoint { get; set; } = new Uri(DefaultEndpoint);
public virtual Uri Endpoint { get; set; } = new Uri(DefaultEndpoint);

public string PayloadVersion { get; } = "4.0";
public virtual string PayloadVersion { get; } = "4.0";

public Uri SessionEndpoint { get; set; } = new Uri(DefaultSessionEndpoint);
public virtual Uri SessionEndpoint { get; set; } = new Uri(DefaultSessionEndpoint);

public string SessionPayloadVersion { get; } = "1.0";
public virtual string SessionPayloadVersion { get; } = "1.0";

public string Context { get; set; }
public virtual string Context { get; set; }

public LogType NotifyLevel { get; set; } = LogType.Exception;
public virtual LogType NotifyLevel { get; set; } = LogType.Exception;

public bool AutoNotify { get; set; } = true;
public virtual bool AutoNotify { get; set; } = true;

public bool AutoCaptureSessions { get; set; }
public virtual bool AutoCaptureSessions { get; set; }

public LogTypeSeverityMapping LogTypeSeverityMapping { get; } = new LogTypeSeverityMapping();
public virtual LogTypeSeverityMapping LogTypeSeverityMapping { get; } = new LogTypeSeverityMapping();
}
}

23 changes: 16 additions & 7 deletions src/BugsnagUnity/Native/Android/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Configuration : AbstractConfiguration
{
internal NativeInterface NativeInterface { get; }

internal Configuration(string apiKey) : base(apiKey)
internal Configuration(string apiKey) : base()
{
var JavaObject = new AndroidJavaObject("com.bugsnag.android.Configuration", apiKey);
// the bugsnag-unity notifier will handle session tracking
Expand All @@ -18,9 +18,18 @@ internal Configuration(string apiKey) : base(apiKey)
JavaObject.Call("setReleaseStage", "production");
JavaObject.Call("setAppVersion", Application.version);
NativeInterface = new NativeInterface(JavaObject);
SetupDefaults(apiKey);
}

public new string ReleaseStage
protected override void SetupDefaults(string apiKey)
{
base.SetupDefaults(apiKey);
ReleaseStage = "production";
Endpoint = new Uri(DefaultEndpoint);
SessionEndpoint = new Uri(DefaultSessionEndpoint);
}

public override string ReleaseStage
{
set
{
Expand All @@ -32,7 +41,7 @@ internal Configuration(string apiKey) : base(apiKey)
}
}

public new string[] NotifyReleaseStages
public override string[] NotifyReleaseStages
{
set
{
Expand All @@ -44,7 +53,7 @@ internal Configuration(string apiKey) : base(apiKey)
}
}

public new string AppVersion
public override string AppVersion
{
set
{
Expand All @@ -56,7 +65,7 @@ internal Configuration(string apiKey) : base(apiKey)
}
}

public new Uri Endpoint
public override Uri Endpoint
{
set
{
Expand All @@ -68,7 +77,7 @@ internal Configuration(string apiKey) : base(apiKey)
}
}

public new Uri SessionEndpoint
public override Uri SessionEndpoint
{
set
{
Expand All @@ -80,7 +89,7 @@ internal Configuration(string apiKey) : base(apiKey)
}
}

public new string Context
public override string Context
{
set
{
Expand Down
26 changes: 19 additions & 7 deletions src/BugsnagUnity/Native/Cocoa/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,32 @@ class Configuration : AbstractConfiguration
{
internal IntPtr NativeConfiguration { get; }

internal Configuration(string apiKey) : base(apiKey)
internal Configuration(string apiKey) : base()
{
NativeConfiguration = NativeCode.bugsnag_createConfiguration(apiKey);
SetupDefaults(apiKey);
}

public new string ApiKey => Marshal.PtrToStringAuto(NativeCode.bugsnag_getApiKey(NativeConfiguration));
protected override void SetupDefaults(string apiKey)
{
base.SetupDefaults(apiKey);
ReleaseStage = "production";
Endpoint = new Uri(DefaultEndpoint);
}

public override string ApiKey
{
get => Marshal.PtrToStringAuto(NativeCode.bugsnag_getApiKey(NativeConfiguration));
protected set {}
}

public new string ReleaseStage
public override string ReleaseStage
{
get => Marshal.PtrToStringAuto(NativeCode.bugsnag_getReleaseStage(NativeConfiguration));
set => NativeCode.bugsnag_setReleaseStage(NativeConfiguration, value);
}

public new string[] NotifyReleaseStages
public override string[] NotifyReleaseStages
{
get
{
Expand Down Expand Up @@ -59,19 +71,19 @@ static void PopulateReleaseStages(IntPtr instance, string[] releaseStages, long
}
}

public new string AppVersion
public override string AppVersion
{
get => Marshal.PtrToStringAuto(NativeCode.bugsnag_getAppVersion(NativeConfiguration));
set => NativeCode.bugsnag_setAppVersion(NativeConfiguration, value);
}

public new Uri Endpoint
public override Uri Endpoint
{
get => new Uri(Marshal.PtrToStringAuto(NativeCode.bugsnag_getNotifyUrl(NativeConfiguration)));
set => NativeCode.bugsnag_setNotifyUrl(NativeConfiguration, value.ToString());
}

public new string Context
public override string Context
{
get => Marshal.PtrToStringAuto(NativeCode.bugsnag_getContext(NativeConfiguration));
set => NativeCode.bugsnag_setContext(NativeConfiguration, value);
Expand Down
4 changes: 3 additions & 1 deletion src/BugsnagUnity/Native/Fallback/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace BugsnagUnity
{
class Configuration : AbstractConfiguration
{
internal Configuration(string apiKey) : base(apiKey) {}
internal Configuration(string apiKey) : base() {
SetupDefaults(apiKey);
}
}
}
4 changes: 3 additions & 1 deletion tests/BugsnagUnity.Tests/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace BugsnagUnity.Payload.Tests
{
class TestConfig : AbstractConfiguration
{
internal TestConfig(string apiKey) : base(apiKey) {}
internal TestConfig(string apiKey) : base() {
SetupDefaults(apiKey);
}
}

[TestFixture]
Expand Down
4 changes: 3 additions & 1 deletion tests/BugsnagUnity.Tests/TestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace BugsnagUnity.Tests
{
public class TestConfiguration : AbstractConfiguration
{
internal TestConfiguration(string apiKey) : base(apiKey) {}
internal TestConfiguration(string apiKey) : base() {
SetupDefaults(apiKey);
}
}
}