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
83 changes: 53 additions & 30 deletions CHANGELOG.md

Large diffs are not rendered by default.

111 changes: 63 additions & 48 deletions README.md

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions Runtime/BacktraceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using UnityEngine;

Expand All @@ -21,7 +22,7 @@ public class BacktraceClient : MonoBehaviour, IBacktraceClient
{
public BacktraceConfiguration Configuration;

public const string VERSION = "3.4.0-rc1";
public const string VERSION = "3.4.0-rc2";
public bool Enabled { get; private set; }

/// <summary>
Expand Down Expand Up @@ -676,7 +677,7 @@ record = Database.Add(data);

if (data.Deduplication != 0)
{
queryAttributes["_mod_duplicate"] = data.Deduplication.ToString();
queryAttributes["_mod_duplicate"] = data.Deduplication.ToString(CultureInfo.InvariantCulture);
}

StartCoroutine(BacktraceApi.Send(json, data.Attachments, queryAttributes, (BacktraceResult result) =>
Expand Down Expand Up @@ -916,7 +917,7 @@ private bool ShouldSendReport(Exception exception, List<string> attachmentPaths,
}

//check rate limiting
bool shouldProcess = _reportLimitWatcher.WatchReport(new DateTime().Timestamp());
bool shouldProcess = _reportLimitWatcher.WatchReport(DateTimeHelper.Timestamp());
if (shouldProcess)
{
// This condition checks if we should send exception from current thread
Expand All @@ -926,7 +927,7 @@ private bool ShouldSendReport(Exception exception, List<string> attachmentPaths,
if (Thread.CurrentThread.ManagedThreadId != _current.ManagedThreadId)
{
var report = new BacktraceReport(exception, attributes, attachmentPaths);
report.Attributes["exception.thread"] = Thread.CurrentThread.ManagedThreadId.ToString();
report.Attributes["exception.thread"] = Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture);
BackgroundExceptions.Push(report);
return false;
}
Expand All @@ -951,7 +952,7 @@ private bool ShouldSendReport(string message, List<string> attachmentPaths, Dict
}

//check rate limiting
bool shouldProcess = _reportLimitWatcher.WatchReport(new DateTime().Timestamp());
bool shouldProcess = _reportLimitWatcher.WatchReport(DateTimeHelper.Timestamp());
if (shouldProcess)
{
// This condition checks if we should send exception from current thread
Expand All @@ -961,7 +962,7 @@ private bool ShouldSendReport(string message, List<string> attachmentPaths, Dict
if (Thread.CurrentThread.ManagedThreadId != _current.ManagedThreadId)
{
var report = new BacktraceReport(message, attributes, attachmentPaths);
report.Attributes["exception.thread"] = Thread.CurrentThread.ManagedThreadId.ToString();
report.Attributes["exception.thread"] = Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture);
BackgroundExceptions.Push(report);
return false;
}
Expand Down Expand Up @@ -990,7 +991,7 @@ private bool ShouldSendReport(BacktraceReport report)
return false;
}
//check rate limiting
bool shouldProcess = _reportLimitWatcher.WatchReport(new DateTime().Timestamp());
bool shouldProcess = _reportLimitWatcher.WatchReport(DateTimeHelper.Timestamp());
if (shouldProcess)
{
// This condition checks if we should send exception from current thread
Expand All @@ -999,7 +1000,7 @@ private bool ShouldSendReport(BacktraceReport report)
// and let update method send data to Backtrace.
if (Thread.CurrentThread.ManagedThreadId != _current.ManagedThreadId)
{
report.Attributes["exception.thread"] = Thread.CurrentThread.ManagedThreadId.ToString();
report.Attributes["exception.thread"] = Thread.CurrentThread.ManagedThreadId.ToString(CultureInfo.InvariantCulture);
BackgroundExceptions.Push(report);
return false;
}
Expand Down
7 changes: 4 additions & 3 deletions Runtime/BacktraceDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Backtrace.Unity.Types;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using UnityEngine;

Expand Down Expand Up @@ -372,7 +373,7 @@ private void FlushRecord(BacktraceDatabaseRecord record)
return;
}

queryAttributes["_mod_duplicate"] = record.Count.ToString();
queryAttributes["_mod_duplicate"] = record.Count.ToString(CultureInfo.InvariantCulture);

StartCoroutine(
BacktraceApi.Send(backtraceData, record.Attachments, queryAttributes, (BacktraceResult result) =>
Expand Down Expand Up @@ -403,7 +404,7 @@ private void SendData(BacktraceDatabaseRecord record)
stopWatch.Stop();
queryAttributes["performance.database.send"] = stopWatch.GetMicroseconds();
}
queryAttributes["_mod_duplicate"] = record.Count.ToString();
queryAttributes["_mod_duplicate"] = record.Count.ToString(CultureInfo.InvariantCulture);

StartCoroutine(
BacktraceApi.Send(backtraceData, record.Attachments, queryAttributes, (BacktraceResult sendResult) =>
Expand All @@ -418,7 +419,7 @@ private void SendData(BacktraceDatabaseRecord record)
BacktraceDatabaseContext.IncrementBatchRetry();
return;
}
bool shouldProcess = _reportLimitWatcher.WatchReport(new DateTime().Timestamp());
bool shouldProcess = _reportLimitWatcher.WatchReport(DateTimeHelper.Timestamp());
if (!shouldProcess)
{
return;
Expand Down
16 changes: 16 additions & 0 deletions Runtime/Common/DateTimeHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Backtrace.Unity.Common
{
internal static class DateTimeHelper
{
public static int Timestamp()
{
return (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions Runtime/Extensions/DateTimeExtensions.cs

This file was deleted.

5 changes: 3 additions & 2 deletions Runtime/Extensions/ThreadExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading;
using System.Globalization;
using System.Threading;

namespace Backtrace.Unity.Extensions
{
Expand All @@ -18,7 +19,7 @@ public static string GenerateValidThreadName(this Thread thread)
//in worst scenario thread name should be managedThreadId
var threadName = thread.Name;
threadName = string.IsNullOrEmpty(threadName)
? thread.ManagedThreadId.ToString()
? thread.ManagedThreadId.ToString(CultureInfo.InvariantCulture)
: threadName;

return threadName;
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Json/BacktraceJObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BacktraceJObject(Dictionary<string, string> source)
/// <param name="value">value</param>
public void Add(string key, bool value)
{
PrimitiveValues.Add(key, value.ToString().ToLower());
PrimitiveValues.Add(key, value.ToString(CultureInfo.InvariantCulture).ToLower());
}


Expand Down Expand Up @@ -100,7 +100,7 @@ public void Add(string key, string value)
/// <param name="value">value</param>
public void Add(string key, long value)
{
PrimitiveValues.Add(key, value.ToString());
PrimitiveValues.Add(key, value.ToString(CultureInfo.InvariantCulture));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Model/BacktraceReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class BacktraceReport
/// <summary>
/// UTC timestamp in seconds
/// </summary>
public readonly long Timestamp = new DateTime().Timestamp();
public readonly long Timestamp = DateTimeHelper.Timestamp();

/// <summary>
/// Get information aboout report type. If value is true the BacktraceReport has an error information
Expand Down
5 changes: 3 additions & 2 deletions Runtime/Model/BacktraceStackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;

Expand Down Expand Up @@ -165,7 +166,7 @@ public BacktraceStackFrame(StackFrame frame, bool generatedByException)
Column = frame.GetFileColumnNumber();
try
{
MemberInfo = method.MetadataToken.ToString();
MemberInfo = method.MetadataToken.ToString(CultureInfo.InvariantCulture);
}
catch (InvalidOperationException)
{
Expand Down Expand Up @@ -277,7 +278,7 @@ private string GetFileNameFromFunctionName()

public override string ToString()
{
return string.Format("{0} (at {1}:{2})", FunctionName, Library, Line.ToString());
return string.Format("{0} (at {1}:{2})", FunctionName, Library, Line.ToString(CultureInfo.InvariantCulture));
}
}
}
3 changes: 2 additions & 1 deletion Runtime/Model/BacktraceUnityMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.Text;
using UnityEngine;

Expand Down Expand Up @@ -48,7 +49,7 @@ private string GetFormattedMessage(bool backtraceFrame)
var stringBuilder = new StringBuilder();
stringBuilder.AppendFormat(
"[{0}] {1}<{2}>: {3}", new object[4] {
DateTime.Now.ToUniversalTime().ToString(),
DateTime.Now.ToUniversalTime().ToString(CultureInfo.InvariantCulture),
backtraceFrame ? "(Backtrace)" : string.Empty,
Enum.GetName(typeof(LogType), Type),
Message}
Expand Down
6 changes: 3 additions & 3 deletions Runtime/Model/JsonData/Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ private BacktraceJObject GetJObject(GameObject gameObject, string parentName = "
return new BacktraceJObject(new Dictionary<string, string>()
{
{ "name", gameObject.name},
{"isStatic", gameObject.isStatic.ToString().ToLower() },
{"isStatic", gameObject.isStatic.ToString(CultureInfo.InvariantCulture).ToLower() },
{"layer", gameObject.layer.ToString(CultureInfo.InvariantCulture) },
{"transform.position", gameObject.transform.position.ToString()},
{"transform.rotation", gameObject.transform.rotation.ToString()},
{"tag",gameObject.tag},
{"activeInHierarchy", gameObject.activeInHierarchy.ToString().ToLower()},
{"activeSelf", gameObject.activeSelf.ToString().ToLower() },
{"activeInHierarchy", gameObject.activeInHierarchy.ToString(CultureInfo.InvariantCulture).ToLower()},
{"activeSelf", gameObject.activeSelf.ToString(CultureInfo.InvariantCulture).ToLower() },
{"instanceId", gameObject.GetInstanceID().ToString(CultureInfo.InvariantCulture) },
{ "parnetName", string.IsNullOrEmpty(parentName) ? "root object" : parentName }
});
Expand Down
Loading