analytics will not leak exceptions while in production.

This commit is contained in:
kay.one 2012-01-26 22:10:15 -08:00
parent 14ed804025
commit b58fe89ce4
1 changed files with 23 additions and 9 deletions

View File

@ -1,5 +1,7 @@
using System.Linq; using System;
using System.Linq;
using DeskMetrics; using DeskMetrics;
using NLog;
using Ninject; using Ninject;
using NzbDrone.Common; using NzbDrone.Common;
@ -7,6 +9,8 @@ namespace NzbDrone.Core.Providers
{ {
public class AnalyticsProvider public class AnalyticsProvider
{ {
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly IDeskMetricsClient _deskMetricsClient; private readonly IDeskMetricsClient _deskMetricsClient;
public const string DESKMETRICS_TEST_ID = "4ea8d347a14ad71442000002"; public const string DESKMETRICS_TEST_ID = "4ea8d347a14ad71442000002";
public const string DESKMETRICS_PRODUCTION_ID = "4f20b01ea14ad729b2000000"; public const string DESKMETRICS_PRODUCTION_ID = "4f20b01ea14ad729b2000000";
@ -23,6 +27,8 @@ namespace NzbDrone.Core.Providers
} }
public virtual void Checkpoint() public virtual void Checkpoint()
{
try
{ {
if (EnviromentProvider.IsNewInstall) if (EnviromentProvider.IsNewInstall)
{ {
@ -36,5 +42,13 @@ namespace NzbDrone.Core.Providers
_deskMetricsClient.Start(); _deskMetricsClient.Start();
} }
catch (Exception e)
{
if (!EnviromentProvider.IsProduction)
throw;
logger.WarnException("Error while sending analytics data.", e);
}
}
} }
} }