public Client(INativeClient nativeClient) { MainThread = Thread.CurrentThread; ForegroundStopwatch = new Stopwatch(); BackgroundStopwatch = new Stopwatch(); NativeClient = nativeClient; User = new User { Id = SystemInfo.deviceUniqueIdentifier }; Middleware = new List <Middleware>(); Metadata = new Metadata(nativeClient); UniqueCounter = new UniqueLogThrottle(Configuration); LogTypeCounter = new MaximumLogTypeCounter(Configuration); SessionTracking = new SessionTracker(this); UnityMetadata.InitDefaultMetadata(); Device.InitUnityVersion(); NativeClient.SetMetadata(UnityMetadataKey, UnityMetadata.ForNativeClient()); NativeClient.PopulateUser(User); SceneManager.sceneLoaded += SceneLoaded; Application.logMessageReceivedThreaded += MultiThreadedNotify; Application.logMessageReceived += Notify; User.PropertyChanged += (obj, args) => { NativeClient.SetUser(User); }; TimingTrackerObject = new GameObject("Bugsnag app lifecycle tracker"); TimingTrackerObject.AddComponent <TimingTrackerBehaviour>(); // Run initial session check in next frame to allow potential configuration // changes to be completed first. try { var asyncHandler = MainThreadDispatchBehaviour.Instance(); asyncHandler.Enqueue(RunInitialSessionCheck()); } catch (System.Exception ex) { // Async behavior is not available in a test environment } }
public Client(INativeClient nativeClient) { Stopwatch = new Stopwatch(); NativeClient = nativeClient; User = new User { Id = SystemInfo.deviceUniqueIdentifier }; Middleware = new List <Middleware>(); Metadata = new Metadata(); UniqueCounter = new UniqueLogThrottle(Configuration); LogTypeCounter = new MaximumLogTypeCounter(Configuration); SessionTracking = new SessionTracker(this); NativeClient.SetMetadata(UnityMetadataKey, UnityMetadata.ForNativeClient()); NativeClient.PopulateUser(User); SceneManager.sceneLoaded += SceneLoaded; Application.logMessageReceivedThreaded += Notify; }
void Notify(Exception[] exceptions, HandledState handledState, Middleware callback, LogType?logType) { if (!ShouldSendRequests()) { return; // Skip overhead of computing payload to to ultimately not be sent } var user = new User { Id = User.Id, Email = User.Email, Name = User.Name }; var app = new App(Configuration) { InForeground = InForeground, DurationInForeground = ForegroundStopwatch.Elapsed, }; NativeClient.PopulateApp(app); var device = new Device(); NativeClient.PopulateDevice(device); device.AddRuntimeVersions(Configuration); var metadata = new Metadata(); NativeClient.PopulateMetadata(metadata); foreach (var item in Metadata) { metadata.AddToPayload(item.Key, item.Value); } metadata.AddToPayload(UnityMetadataKey, UnityMetadata.WithLogType(logType)); var @event = new Payload.Event( Configuration.Context, metadata, app, device, user, exceptions, handledState, Breadcrumbs.Retrieve(), SessionTracking.CurrentSession); var report = new Report(Configuration, @event); lock (MiddlewareLock) { foreach (var middleware in Middleware) { try { middleware(report); } catch (System.Exception) { } } } try { callback?.Invoke(report); } catch (System.Exception) { } if (!report.Ignored) { Send(report); Breadcrumbs.Leave(Breadcrumb.FromReport(report)); SessionTracking.AddException(report); } }
void Notify(Exception[] exceptions, HandledState handledState, Middleware callback, LogType?logType) { var user = new User { Id = User.Id, Email = User.Email, Name = User.Name }; var app = new App(Configuration) { InForeground = InForeground, DurationInForeground = Stopwatch.Elapsed, }; NativeClient.PopulateApp(app); var device = new Device(); NativeClient.PopulateDevice(device); var metadata = new Metadata(); NativeClient.PopulateMetadata(metadata); foreach (var item in Metadata) { metadata.AddToPayload(item.Key, item.Value); } metadata.AddToPayload(UnityMetadataKey, UnityMetadata.WithLogType(logType)); var @event = new Payload.Event( Configuration.Context, metadata, app, device, user, exceptions, handledState, Breadcrumbs.Retrieve(), SessionTracking.CurrentSession); var report = new Report(Configuration, @event); if (report.Configuration.ReleaseStage != null && report.Configuration.NotifyReleaseStages != null && !report.Configuration.NotifyReleaseStages.Contains(report.Configuration.ReleaseStage)) { return; } lock (MiddlewareLock) { foreach (var middleware in Middleware) { try { middleware(report); } catch (System.Exception) { } } } try { callback?.Invoke(report); } catch (System.Exception) { } if (!report.Ignored) { Send(report); Breadcrumbs.Leave(Breadcrumb.FromReport(report)); SessionTracking.AddException(report); } }