1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-28 19:05:55 +00:00
Radarr/NzbDrone.Core/Providers/AnalyticsProvider.cs

54 lines
1.3 KiB
C#

using System;
using System.Linq;
using DeskMetrics;
using NLog;
using Ninject;
using NzbDrone.Common;
namespace NzbDrone.Core.Providers
{
public class AnalyticsProvider
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly IDeskMetricsClient _deskMetricsClient;
public const string DESKMETRICS_TEST_ID = "4ea8d347a14ad71442000002";
public const string DESKMETRICS_PRODUCTION_ID = "4f20b01ea14ad729b2000000";
[Inject]
public AnalyticsProvider(IDeskMetricsClient deskMetricsClient)
{
_deskMetricsClient = deskMetricsClient;
}
public AnalyticsProvider()
{
}
public virtual void Checkpoint()
{
try
{
if (EnviromentProvider.IsNewInstall)
{
_deskMetricsClient.RegisterInstall();
}
if (_deskMetricsClient.Started)
{
_deskMetricsClient.Stop();
}
_deskMetricsClient.Start();
}
catch (Exception e)
{
if (!EnviromentProvider.IsProduction)
throw;
logger.WarnException("Error while sending analytics data.", e);
}
}
}
}