Skip to content

Commit ffea9cb

Browse files
author
gauffininteractive
committed
Configured reporting to https://onetrueerror.com correctly. v1.0 is closing in.
1 parent 02e928b commit ffea9cb

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

src/Server/OneTrueError.Web/Areas/Admin/Controllers/HomeController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Web.Mvc;
33
using OneTrueError.App.Configuration;
4+
using OneTrueError.Client;
45
using OneTrueError.Infrastructure;
56
using OneTrueError.Infrastructure.Configuration;
67
using OneTrueError.Web.Areas.Admin.Models;
@@ -65,6 +66,7 @@ public ActionResult Errors(ErrorTrackingViewModel model)
6566
settings.ContactEmail = model.ContactEmail;
6667
settings.InstallationId = model.InstallationId;
6768
ConfigurationStore.Instance.Store(settings);
69+
WebApiApplication.ReportToOneTrueError = model.ActivateTracking;
6870
return Redirect(Url.GetNextWizardStep());
6971
}
7072

src/Server/OneTrueError.Web/Global.asax.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Web;
45
using System.Web.Mvc;
56
using System.Web.Optimization;
67
using Griffin.Signals;
78
using log4net;
89
using log4net.Config;
10+
using OneTrueError.Client;
11+
using OneTrueError.Client.Contracts;
912
using OneTrueError.Infrastructure;
1013
using OneTrueError.SqlServer;
1114
using OneTrueError.Web.Infrastructure.Logging;
@@ -15,6 +18,7 @@ namespace OneTrueError.Web
1518
public class WebApiApplication : HttpApplication
1619
{
1720
private static readonly ILog _logger;
21+
public static bool ReportToOneTrueError;
1822

1923
static WebApiApplication()
2024
{
@@ -47,6 +51,22 @@ private void Application_Error(object sender, EventArgs e)
4751
data = reader.ReadToEnd();
4852
}
4953
_logger.Error("Request + " + Request.Url + ", data" + data, exception);
54+
55+
if (!ReportToOneTrueError)
56+
return;
57+
58+
var properties = new Dictionary<string, string>
59+
{
60+
{"Url", Request.Url.ToString()},
61+
{"HttpMethod", Request.HttpMethod}
62+
};
63+
if (Request.UrlReferrer != null)
64+
properties.Add("Referer", Request.UrlReferrer.ToString());
65+
if (data.Length < 30000)
66+
properties.Add("Body", data);
67+
properties.Add("OneTrueTags", "unhandled-exception");
68+
var collection = new ContextCollectionDTO("Request", properties);
69+
OneTrue.Report(exception, collection);
5070
}
5171

5272
private static void OnSignalRaised(object sender, SignalRaisedEventArgs e)

src/Server/OneTrueError.Web/Infrastructure/Logging/WebApiLogger.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
using System.Web.Http.ExceptionHandling;
1+
using System.Collections.Generic;
2+
using System.Web.Http.ExceptionHandling;
23
using log4net;
4+
using OneTrueError.Client;
5+
using OneTrueError.Client.Contracts;
36

47
namespace OneTrueError.Web.Infrastructure.Logging
58
{
69
internal class WebApiLogger : ExceptionLogger
710
{
811
private readonly ILog _logger = LogManager.GetLogger(typeof(WebApiLogger));
912

13+
public string ReportToOneTrueError { get; set; }
14+
1015
public override void Log(ExceptionLoggerContext context)
1116
{
1217
var data = "";
@@ -17,6 +22,21 @@ public override void Log(ExceptionLoggerContext context)
1722

1823
_logger.Error("Request + " + context.Request.RequestUri + ", data" + data, context.Exception);
1924
_logger.Error(context.Exception);
25+
26+
if (!WebApiApplication.ReportToOneTrueError)
27+
return;
28+
29+
var properties = new Dictionary<string, string>
30+
{
31+
{"Url", context.Request.RequestUri.ToString()},
32+
{"HttpMethod", context.Request.Method.Method}
33+
};
34+
if (context.Request.Headers.Referrer != null)
35+
properties.Add("Referer", context.Request.Headers.Referrer.ToString());
36+
if (data.Length < 30000)
37+
properties.Add("Body", data);
38+
var collection = new ContextCollectionDTO("Request", properties);
39+
OneTrue.Report(context.Exception, collection);
2040
base.Log(context);
2141
}
2242
}

src/Server/OneTrueError.Web/Startup.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,17 @@ private static void ConfigureErrorTracking()
109109
var errorTrackingConfig = ConfigurationStore.Instance.Load<OneTrueErrorConfigSection>();
110110
if ((errorTrackingConfig != null) && errorTrackingConfig.ActivateTracking)
111111
{
112-
var uri = new Uri("http://reporting.onetrueerror.com");
112+
var uri = new Uri("https://report.onetrueerror.com");
113113
if (!string.IsNullOrEmpty(errorTrackingConfig.ContactEmail) ||
114114
!string.IsNullOrEmpty(errorTrackingConfig.InstallationId))
115+
{
115116
OneTrue.Configuration.ContextProviders.Add(new CustomerInfoProvider(
116117
errorTrackingConfig.ContactEmail,
117118
errorTrackingConfig.InstallationId));
118-
OneTrue.Configuration.Credentials(uri, "appKey", "sharedSecret");
119+
}
120+
OneTrue.Configuration.Credentials(uri, "2b3002d3ab3e4a57ad45cff2210221ab", "f381a5c9797f49bd8a3238b892d02806");
121+
WebApiApplication.ReportToOneTrueError = true;
122+
GlobalConfiguration.Configuration.Services.Add(typeof(IExceptionLogger), new WebApiLogger());
119123
}
120124
else
121125
{

0 commit comments

Comments
 (0)