updated analytics
This commit is contained in:
parent
2deb6822b0
commit
5c03c873b2
|
@ -43,7 +43,7 @@ namespace NzbDrone.Common
|
||||||
public static Guid UGuid { get; set; }
|
public static Guid UGuid { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public static bool IsNewInstall { get; set; }
|
public static bool RegisterNewInstall { get; set; }
|
||||||
|
|
||||||
public virtual bool IsUserInteractive
|
public virtual bool IsUserInteractive
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Security.Principal;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test
|
||||||
public void app_should_be_marked_as_new_install_if_db_is_initilized_for_the_first_time()
|
public void app_should_be_marked_as_new_install_if_db_is_initilized_for_the_first_time()
|
||||||
{
|
{
|
||||||
WithRealDb();
|
WithRealDb();
|
||||||
EnviromentProvider.IsNewInstall.Should().Be(true);
|
EnviromentProvider.RegisterNewInstall.Should().Be(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using DeskMetrics;
|
using DeskMetrics;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -19,6 +20,12 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns(UpdateProvider.DEFAULT_UPDATE_URL);
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns(UpdateProvider.DEFAULT_UPDATE_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void WithStageClient()
|
||||||
|
{
|
||||||
|
Mocker.SetConstant(new DeskMetricsClient(Guid.NewGuid().ToString(), AnalyticsProvider.DESKMETRICS_TEST_ID, new Version(9, 9, 9)));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void checkpoint_should_stop_existing_start_then_start_again()
|
public void checkpoint_should_stop_existing_start_then_start_again()
|
||||||
{
|
{
|
||||||
|
@ -46,7 +53,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void new_install_should_be_registered()
|
public void new_install_should_be_registered()
|
||||||
{
|
{
|
||||||
EnviromentProvider.IsNewInstall = true;
|
EnviromentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
var provider = Mocker.Resolve<AnalyticsProvider>();
|
var provider = Mocker.Resolve<AnalyticsProvider>();
|
||||||
|
|
||||||
|
@ -55,10 +62,24 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.RegisterInstall(), Times.Once());
|
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.RegisterInstall(), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void new_install_should_only_be_registered_on_first_call()
|
||||||
|
{
|
||||||
|
EnviromentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
|
var provider = Mocker.Resolve<AnalyticsProvider>();
|
||||||
|
|
||||||
|
provider.Checkpoint();
|
||||||
|
provider.Checkpoint();
|
||||||
|
provider.Checkpoint();
|
||||||
|
|
||||||
|
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.RegisterInstall(), Times.Once());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void upgrade_should_not_register_install()
|
public void upgrade_should_not_register_install()
|
||||||
{
|
{
|
||||||
EnviromentProvider.IsNewInstall = false;
|
EnviromentProvider.RegisterNewInstall = false;
|
||||||
|
|
||||||
var provider = Mocker.Resolve<AnalyticsProvider>();
|
var provider = Mocker.Resolve<AnalyticsProvider>();
|
||||||
|
|
||||||
|
@ -71,7 +92,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void shouldnt_register_anything_if_not_on_master_branch()
|
public void shouldnt_register_anything_if_not_on_master_branch()
|
||||||
{
|
{
|
||||||
EnviromentProvider.IsNewInstall = false;
|
EnviromentProvider.RegisterNewInstall = false;
|
||||||
|
|
||||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
||||||
|
|
||||||
|
@ -83,7 +104,7 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
[Test]
|
[Test]
|
||||||
public void new_install_shouldnt_register_anything_if_not_on_master_branch()
|
public void new_install_shouldnt_register_anything_if_not_on_master_branch()
|
||||||
{
|
{
|
||||||
EnviromentProvider.IsNewInstall = true;
|
EnviromentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
|
||||||
|
|
||||||
|
@ -92,6 +113,16 @@ namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
|
||||||
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
|
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_call_deskmetrics_using_test_appid()
|
||||||
|
{
|
||||||
|
EnviromentProvider.RegisterNewInstall = true;
|
||||||
|
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//")]
|
||||||
|
|
|
@ -71,11 +71,8 @@ namespace NzbDrone.Core
|
||||||
var deskMetricsClient = new DeskMetricsClient(Kernel.Get<ConfigProvider>().UGuid.ToString(), appId, _enviromentProvider.Version);
|
var deskMetricsClient = new DeskMetricsClient(Kernel.Get<ConfigProvider>().UGuid.ToString(), appId, _enviromentProvider.Version);
|
||||||
Kernel.Bind<IDeskMetricsClient>().ToConstant(deskMetricsClient);
|
Kernel.Bind<IDeskMetricsClient>().ToConstant(deskMetricsClient);
|
||||||
|
|
||||||
if (EnviromentProvider.IsProduction)
|
|
||||||
{
|
|
||||||
Kernel.Get<AnalyticsProvider>().Checkpoint();
|
Kernel.Get<AnalyticsProvider>().Checkpoint();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void InitQuality()
|
private void InitQuality()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
||||||
protected override void MainDbUpgrade()
|
protected override void MainDbUpgrade()
|
||||||
{
|
{
|
||||||
//This should not run unless for a clean install
|
//This should not run unless for a clean install
|
||||||
EnviromentProvider.IsNewInstall = true;
|
EnviromentProvider.RegisterNewInstall = true;
|
||||||
|
|
||||||
Database.AddTable("Series", new[]
|
Database.AddTable("Series", new[]
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,11 +33,8 @@ namespace NzbDrone.Core.Jobs
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
||||||
{
|
|
||||||
if(EnviromentProvider.IsProduction)
|
|
||||||
{
|
{
|
||||||
_analyticsProvider.Checkpoint();
|
_analyticsProvider.Checkpoint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
Loading…
Reference in New Issue