Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }