private static object Merge(SentryEvent sentryEvent)
        {
            var exception = sentryEvent.Exception;
            var extra     = sentryEvent.Extra;

            if (exception == null && extra == null)
            {
                return(null);
            }

            if (extra != null && exception == null)
            {
                return(extra);
            }

            var exceptionData = new ExceptionData(exception);

            if (extra == null)
            {
                return(exceptionData);
            }

            JObject result;

            if (extra.GetType().IsArray)
            {
                result = new JObject();
                var array = JArray.FromObject(extra);

                foreach (var o in array)
                {
                    var         jo = o as JObject;
                    JProperty[] properties;

                    if (jo == null || (properties = jo.Properties().ToArray()).Length != 2 || properties[0].Name != "Key" ||
                        properties[1].Name != "Value")
                    {
                        result.Merge(o);
                        continue;
                    }

                    var key   = properties[0].Value.ToString();
                    var value = properties[1].Value;
                    result.Add(key, value);
                }
            }
            else
            {
                result = JObject.FromObject(extra);
            }

            var jExceptionData = JObject.FromObject(exceptionData);

            result.Merge(jExceptionData);

            return(result);
        }
        /// <summary>Initializes a new instance of the <see cref="ExceptionData"/> class.</summary>
        /// <param name="exception">The exception.</param>
        public ExceptionData(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }

            this.exceptionType = exception.GetType().FullName;

            foreach (var k in exception.Data.Keys)
            {
                try
                {
                    var value = exception.Data[k];
                    var key   = k as string ?? k.ToString();
                    Add(key, value);
                }
                catch (Exception e)
                {
                    Console.WriteLine("ERROR: " + e);
                }
            }

            if (exception.InnerException == null)
            {
                return;
            }

            var exceptionData = new ExceptionData(exception.InnerException);

            if (exceptionData.Count == 0)
            {
                return;
            }

            exceptionData.AddTo(this);
        }