disable analytics in dev
This commit is contained in:
parent
f716903a30
commit
c4b210c053
|
@ -6,6 +6,7 @@ using Nancy;
|
|||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Analytics;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
@ -14,6 +15,7 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||
{
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly IAnalyticsService _analyticsService;
|
||||
private readonly Func<ICacheBreakerProvider> _cacheBreakProviderFactory;
|
||||
private readonly string _indexPath;
|
||||
private static readonly Regex ReplaceRegex = new Regex("(?<=(?:href|src|data-main)=\").*?(?=\")", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
@ -26,12 +28,14 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||
public IndexHtmlMapper(IAppFolderInfo appFolderInfo,
|
||||
IDiskProvider diskProvider,
|
||||
IConfigFileProvider configFileProvider,
|
||||
IAnalyticsService analyticsService,
|
||||
Func<ICacheBreakerProvider> cacheBreakProviderFactory,
|
||||
Logger logger)
|
||||
: base(diskProvider, logger)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_configFileProvider = configFileProvider;
|
||||
_analyticsService = analyticsService;
|
||||
_cacheBreakProviderFactory = cacheBreakProviderFactory;
|
||||
_indexPath = Path.Combine(appFolderInfo.StartUpFolder, "UI", "index.html");
|
||||
|
||||
|
@ -89,7 +93,8 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||
text = text.Replace("API_ROOT", URL_BASE + "/api");
|
||||
text = text.Replace("API_KEY", API_KEY);
|
||||
text = text.Replace("APP_VERSION", BuildInfo.Version.ToString());
|
||||
text = text.Replace("APP_ANALYTICS", _configFileProvider.AnalyticsEnabled.ToString().ToLowerInvariant());
|
||||
|
||||
text = text.Replace("APP_ANALYTICS", _analyticsService.IsEnabled.ToString().ToLowerInvariant());
|
||||
|
||||
_generatedContent = text;
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.Analytics
|
||||
{
|
||||
public interface IAnalyticsService
|
||||
{
|
||||
bool IsEnabled { get; }
|
||||
}
|
||||
|
||||
public class AnalyticsService : IAnalyticsService
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
|
||||
public AnalyticsService(IConfigFileProvider configFileProvider)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _configFileProvider.AnalyticsEnabled && RuntimeInfoBase.IsProduction;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -109,6 +109,7 @@
|
|||
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Analytics\AnalyticsService.cs" />
|
||||
<Compile Include="Annotations\FieldDefinitionAttribute.cs" />
|
||||
<Compile Include="Backup\Backup.cs" />
|
||||
<Compile Include="Backup\BackupCommand.cs" />
|
||||
|
|
Loading…
Reference in New Issue