mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-10 23:29:53 +02:00
Deskmetrics will not report any data unless using the master branch.
This commit is contained in:
parent
7482a4c935
commit
44d6d20bd6
@ -4,6 +4,7 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||
@ -11,6 +12,13 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class AnalyticsProviderFixture : CoreTest
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns(UpdateProvider.DEFAULT_UPDATE_URL);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void checkpoint_should_stop_existing_start_then_start_again()
|
||||
{
|
||||
@ -60,5 +68,48 @@ public void upgrade_should_not_register_install()
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void shouldnt_register_anything_if_not_on_master_branch()
|
||||
{
|
||||
EnviromentProvider.IsNewInstall = false;
|
||||
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
||||
|
||||
Mocker.GetMock<IDeskMetricsClient>(MockBehavior.Strict);
|
||||
|
||||
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void new_install_shouldnt_register_anything_if_not_on_master_branch()
|
||||
{
|
||||
EnviromentProvider.IsNewInstall = true;
|
||||
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
||||
|
||||
Mocker.GetMock<IDeskMetricsClient>(MockBehavior.Strict);
|
||||
|
||||
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
|
||||
}
|
||||
|
||||
|
||||
[TestCase("http://update.nzbdrone.com/master/")]
|
||||
[TestCase("http://update.nzbdrone.com/master//")]
|
||||
[TestCase("http://update.nzbdrone.com/master")]
|
||||
[TestCase("http://update.nzbdrone.com/master ")]
|
||||
[TestCase("http://update.nzbdrone.com/master/ ")]
|
||||
[TestCase("http://UPDATE.nzbdrone.COM/master/ ")]
|
||||
public void should_still_work_if_url_is_slightly_diffrent(string url)
|
||||
{
|
||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns(url);
|
||||
|
||||
var provider = Mocker.Resolve<AnalyticsProvider>();
|
||||
|
||||
provider.Checkpoint();
|
||||
|
||||
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.Start(), Times.Once());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
@ -12,13 +13,15 @@ public class AnalyticsProvider
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly IDeskMetricsClient _deskMetricsClient;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
public const string DESKMETRICS_TEST_ID = "4ea8d347a14ad71442000002";
|
||||
public const string DESKMETRICS_PRODUCTION_ID = "4f20b01ea14ad729b2000000";
|
||||
|
||||
[Inject]
|
||||
public AnalyticsProvider(IDeskMetricsClient deskMetricsClient)
|
||||
public AnalyticsProvider(IDeskMetricsClient deskMetricsClient, ConfigProvider configProvider)
|
||||
{
|
||||
_deskMetricsClient = deskMetricsClient;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public AnalyticsProvider()
|
||||
@ -30,6 +33,10 @@ public virtual void Checkpoint()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Don't report anything unless working from master branch.
|
||||
if (!IsOnMasterBranch())
|
||||
return;
|
||||
|
||||
if (EnviromentProvider.IsNewInstall)
|
||||
{
|
||||
_deskMetricsClient.RegisterInstall();
|
||||
@ -50,5 +57,14 @@ public virtual void Checkpoint()
|
||||
logger.WarnException("Error while sending analytics data.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool IsOnMasterBranch()
|
||||
{
|
||||
var defaultUpdateUrl = UpdateProvider.DEFAULT_UPDATE_URL.Trim().Trim('/');
|
||||
var currentUpdateUrl = _configProvider.UpdateUrl.Trim().Trim('/');
|
||||
|
||||
return String.Equals(defaultUpdateUrl, currentUpdateUrl, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ public virtual string XbmcPassword
|
||||
|
||||
public virtual string UpdateUrl
|
||||
{
|
||||
get { return GetValue("UpdateUrl", @"http://update.nzbdrone.com/master/"); }
|
||||
get { return GetValue("UpdateUrl", UpdateProvider.DEFAULT_UPDATE_URL); }
|
||||
set { SetValue("UpdateUrl", value); }
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class UpdateProvider
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private static readonly Regex parseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
|
||||
|
||||
public const string DEFAULT_UPDATE_URL = @"http://update.nzbdrone.com/master/";
|
||||
|
||||
|
||||
[Inject]
|
||||
|
Loading…
Reference in New Issue
Block a user