New: added self hosted analytics to help improve nzbdrone. Can be turned off in Setting>General

pull/4/head
Keivan Beigi 10 years ago
parent cc8c88e921
commit a21b535937

@ -10,7 +10,8 @@ namespace NzbDrone.Api.Config
public Int32 SslPort { get; set; } public Int32 SslPort { get; set; }
public Boolean EnableSsl { get; set; } public Boolean EnableSsl { get; set; }
public Boolean LaunchBrowser { get; set; } public Boolean LaunchBrowser { get; set; }
public Boolean AuthenticationEnabled { get; set; } public bool AuthenticationEnabled { get; set; }
public Boolean AnalyticsEnabled { get; set; }
public String Username { get; set; } public String Username { get; set; }
public String Password { get; set; } public String Password { get; set; }
public String LogLevel { get; set; } public String LogLevel { get; set; }

@ -13,6 +13,7 @@ namespace NzbDrone.Api.Frontend.Mappers
public class IndexHtmlMapper : StaticResourceMapperBase public class IndexHtmlMapper : StaticResourceMapperBase
{ {
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IConfigFileProvider _configFileProvider;
private readonly Func<ICacheBreakerProvider> _cacheBreakProviderFactory; private readonly Func<ICacheBreakerProvider> _cacheBreakProviderFactory;
private readonly string _indexPath; private readonly string _indexPath;
private static readonly Regex ReplaceRegex = new Regex("(?<=(?:href|src|data-main)=\").*?(?=\")", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ReplaceRegex = new Regex("(?<=(?:href|src|data-main)=\").*?(?=\")", RegexOptions.Compiled | RegexOptions.IgnoreCase);
@ -30,6 +31,7 @@ namespace NzbDrone.Api.Frontend.Mappers
: base(diskProvider, logger) : base(diskProvider, logger)
{ {
_diskProvider = diskProvider; _diskProvider = diskProvider;
_configFileProvider = configFileProvider;
_cacheBreakProviderFactory = cacheBreakProviderFactory; _cacheBreakProviderFactory = cacheBreakProviderFactory;
_indexPath = Path.Combine(appFolderInfo.StartUpFolder, "UI", "index.html"); _indexPath = Path.Combine(appFolderInfo.StartUpFolder, "UI", "index.html");
@ -87,6 +89,7 @@ namespace NzbDrone.Api.Frontend.Mappers
text = text.Replace("API_ROOT", URL_BASE + "/api"); text = text.Replace("API_ROOT", URL_BASE + "/api");
text = text.Replace("API_KEY", API_KEY); text = text.Replace("API_KEY", API_KEY);
text = text.Replace("APP_VERSION", BuildInfo.Version.ToString()); text = text.Replace("APP_VERSION", BuildInfo.Version.ToString());
text = text.Replace("APP_ANALYTICS", _configFileProvider.AnalyticsEnabled.ToString().ToLowerInvariant());
_generatedContent = text; _generatedContent = text;

@ -27,6 +27,7 @@ namespace NzbDrone.Core.Configuration
bool EnableSsl { get; } bool EnableSsl { get; }
bool LaunchBrowser { get; } bool LaunchBrowser { get; }
bool AuthenticationEnabled { get; } bool AuthenticationEnabled { get; }
bool AnalyticsEnabled { get; }
string Username { get; } string Username { get; }
string Password { get; } string Password { get; }
string LogLevel { get; } string LogLevel { get; }
@ -139,6 +140,14 @@ namespace NzbDrone.Core.Configuration
get { return GetValueBoolean("AuthenticationEnabled", false); } get { return GetValueBoolean("AuthenticationEnabled", false); }
} }
public bool AnalyticsEnabled
{
get
{
return GetValueBoolean("AnalyticsEnabled", true, persist: false);
}
}
public string Branch public string Branch
{ {
get { return GetValue("Branch", "master").ToLowerInvariant(); } get { return GetValue("Branch", "master").ToLowerInvariant(); }

@ -173,9 +173,33 @@
</div> </div>
</div> </div>
</fieldset> </fieldset>
<fieldset>
<legend>Analytics</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Enable</label>
<div class="col-sm-8">
<div class="input-group">
<label class="checkbox toggle well">
<input type="checkbox" name="analyticsEnabled" class="form-control"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Send anonymous information about your browser and which parts of the web interface you use to NzbDrone servers. We use this information to prioritize features and browser support. We will NEVER include any person information or any information that could identify you."/>
</span>
</div>
</div>
</div>
</fieldset>
<fieldset class="advanced-setting"> <fieldset class="advanced-setting">
<legend>Updating</legend> <legend>Updates</legend>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">Branch</label> <label class="col-sm-3 control-label">Branch</label>

@ -25,6 +25,19 @@ define(
else { else {
document.title = title + ' - nzbdrone'; document.title = title + ' - nzbdrone';
} }
if(window.Piwik){
try {
var piwik = window.Piwik.getTracker('http://piwik.nzbdrone.com/piwik.php', 1);
piwik.setReferrerUrl('');
piwik.setCustomUrl('http://local' + window.location.pathname);
piwik.setCustomVariable(1, 'version', window.NzbDrone.version, 'page');
piwik.trackPageView(title);
}
catch (e){
console.error(e);
}
}
}, },
_onServerUpdated: function () { _onServerUpdated: function () {

@ -75,10 +75,12 @@
window.NzbDrone = { window.NzbDrone = {
ApiRoot: 'API_ROOT', ApiRoot: 'API_ROOT',
ApiKey : 'API_KEY', ApiKey : 'API_KEY',
Version: 'APP_VERSION' Version: 'APP_VERSION',
Analytics: APP_ANALYTICS
}; };
</script> </script>
<script src="/piwik.js"></script>
<script src="/polyfills.js"></script> <script src="/polyfills.js"></script>
<script src="/JsLibraries/handlebars.runtime.js"></script> <script src="/JsLibraries/handlebars.runtime.js"></script>
<script data-main="/main" src="/JsLibraries/require.js"></script> <script data-main="/main" src="/JsLibraries/require.js"></script>

@ -0,0 +1,14 @@
'use strict';
(function () {
if(window.NzbDrone.Analytics) {
var d = document;
var g = d.createElement('script');
var s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = 'http://piwik.nzbdrone.com/piwik.js';
s.parentNode.insertBefore(g, s);
}
})();
Loading…
Cancel
Save