Skip to content

Commit

Permalink
Merge pull request #839 from bugsnag/next
Browse files Browse the repository at this point in the history
Release v8.2.0
  • Loading branch information
richardelms authored Sep 23, 2024
2 parents 50c139e + 6c118ba commit ff6bdff
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ features/fixtures/minimalapp/Assets/Bugsnag
features/fixtures/minimalapp/minimal_with_xcode
features/fixtures/minimalapp/minimal_without_xcode
features/fixtures/minimalapp/Packages
Gemfile.lock
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 8.2.0 (2024-09-23)

### Enhancements

- Allow for error correlation with Bugsnag Unity Performance. [#806](https://github.com/bugsnag/bugsnag-unity/pull/806)

## 8.1.0 (2024-08-12)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gem 'xcpretty'
gem 'xcodeproj'
gem 'cocoapods'
gem 'rake'
gem 'danger'

unless Gem.win_platform?
# Use official Maze Runner release
Expand Down
115 changes: 0 additions & 115 deletions Gemfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Define default arguments.
CONFIGURATION="Release"
SOLUTION="./BugsnagUnity.sln"
VERSION="8.1.0"
VERSION="8.2.0"

# Parse arguments.
for i in "$@"; do
Expand Down
2 changes: 2 additions & 0 deletions features/scripts/do_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package_path=Bugsnag.unitypackage

imported_sdk_path="$project_path/Assets/Bugsnag"

bundle install

rm -rf "$project_path/Assets/Bugsnag"

echo "building android without bugsnag"
Expand Down
15 changes: 8 additions & 7 deletions src/BugsnagUnity/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UnityEngine.SceneManagement;
using System;
using System.Collections;
using System.Reflection;
using BugsnagNetworking;
using UnityEngine.Networking;

Expand Down Expand Up @@ -375,13 +376,13 @@ private void Notify(Error[] exceptions, HandledState handledState, Func<IEvent,
return;
}


var correlation = PerformanceHelper.GetCurrentPerformanceSpanContext();
if (!ReferenceEquals(Thread.CurrentThread, MainThread))
{
try
{
var asyncHandler = MainThreadDispatchBehaviour.Instance();
asyncHandler.Enqueue(() => { NotifyOnMainThread(exceptions, handledState, callback, logType); });
asyncHandler.Enqueue(() => { NotifyOnMainThread(exceptions, handledState, callback,logType, correlation); });
}
catch
{
Expand All @@ -390,12 +391,11 @@ private void Notify(Error[] exceptions, HandledState handledState, Func<IEvent,
}
else
{
NotifyOnMainThread(exceptions, handledState, callback, logType);
}

NotifyOnMainThread(exceptions, handledState, callback, logType, correlation);
}
}

private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, Func<IEvent, bool> callback, LogType? logType)
private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, Func<IEvent, bool> callback, LogType? logType, Correlation correlation)
{
if (!ShouldSendRequests() || EventContainsDiscardedClass(exceptions) || !Configuration.Endpoints.IsValid)
{
Expand Down Expand Up @@ -447,7 +447,8 @@ private void NotifyOnMainThread(Error[] exceptions, HandledState handledState, F
Breadcrumbs.Retrieve(),
SessionTracking.CurrentSession,
Configuration.ApiKey,
featureFlags);
featureFlags,
correlation);

//Check for adding project packages to an android java error event
if (ShouldAddProjectPackagesToEvent(@event))
Expand Down
53 changes: 53 additions & 0 deletions src/BugsnagUnity/Payload/Correlation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine.Events;
#nullable enable

namespace BugsnagUnity.Payload
{
public class Correlation : PayloadContainer
{

private const string TRACE_ID_KEY = "traceId";
private const string SPAN_ID_KEY = "spanId";

internal Correlation(string traceId, string spanId)
{
TraceId = traceId;
SpanId = spanId;
}

public string TraceId
{
get {
var @object = Get(TRACE_ID_KEY);
if (@object == null)
{
return string.Empty;
}
return (string)@object;
}
set
{
Add(TRACE_ID_KEY, value);
}
}

public string SpanId
{
get
{
var @object = Get(SPAN_ID_KEY);
if (@object == null)
{
return string.Empty;
}
return (string)@object;
}
set
{
Add(SPAN_ID_KEY, value);
}
}
}
}
9 changes: 8 additions & 1 deletion src/BugsnagUnity/Payload/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BugsnagUnity.Payload
public class Event : PayloadContainer, IEvent
{

internal Event(string context, Metadata metadata, AppWithState app, DeviceWithState device, User user, Error[] errors, HandledState handledState, List<Breadcrumb> breadcrumbs, Session session, string apiKey, OrderedDictionary featureFlags, LogType? logType = null)
internal Event(string context, Metadata metadata, AppWithState app, DeviceWithState device, User user, Error[] errors, HandledState handledState, List<Breadcrumb> breadcrumbs, Session session, string apiKey, OrderedDictionary featureFlags, Correlation correlation, LogType? logType = null)
{
ApiKey = apiKey;
OriginalSeverity = handledState;
Expand All @@ -23,6 +23,7 @@ internal Event(string context, Metadata metadata, AppWithState app, DeviceWithSt
_user = user;
_errors = errors.ToList();
Errors = new List<IError>();
Correlation = correlation;
foreach (var error in _errors)
{
Errors.Add(error);
Expand Down Expand Up @@ -187,6 +188,8 @@ internal void AddAndroidProjectPackagesToEvent(string[] packages)

public string ApiKey { get; set; }

public Correlation Correlation;

private List<Breadcrumb> _breadcrumbs;

public ReadOnlyCollection<IBreadcrumb> Breadcrumbs { get; }
Expand Down Expand Up @@ -314,6 +317,10 @@ internal Dictionary<string, object> GetEventPayload()
Add("groupingHash", GroupingHash);
Add("payloadVersion", PayloadVersion);
Add("exceptions", _errors);
if(Correlation != null)
{
Add("correlation", Correlation.Payload);
}
if (_androidProjectPackages != null)
{
Add("projectPackages", _androidProjectPackages);
Expand Down
Loading

0 comments on commit ff6bdff

Please sign in to comment.