add advanced setting

This commit is contained in:
Luke Pulverenti 2016-03-03 00:17:00 -05:00
parent 11a5bbf9b5
commit 32204107dd
3 changed files with 31 additions and 5 deletions

View File

@ -206,6 +206,8 @@ namespace MediaBrowser.Model.Configuration
public bool DownloadImagesInAdvance { get; set; } public bool DownloadImagesInAdvance { get; set; }
public bool EnableAnonymousUsageReporting { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary> /// </summary>
@ -221,6 +223,7 @@ namespace MediaBrowser.Model.Configuration
EnableHttps = false; EnableHttps = false;
EnableDashboardResponseCaching = true; EnableDashboardResponseCaching = true;
EnableDashboardResourceMinification = true; EnableDashboardResourceMinification = true;
EnableAnonymousUsageReporting = true;
EnableAutomaticRestart = true; EnableAutomaticRestart = true;
DenyIFrameEmbedding = true; DenyIFrameEmbedding = true;

View File

@ -10,6 +10,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
namespace MediaBrowser.Server.Implementations.EntryPoints namespace MediaBrowser.Server.Implementations.EntryPoints
{ {
@ -23,18 +24,18 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ISessionManager _sessionManager; private readonly ISessionManager _sessionManager;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IServerConfigurationManager _config;
private readonly TimeSpan _frequency = TimeSpan.FromHours(24);
private readonly ConcurrentDictionary<Guid, ClientInfo> _apps = new ConcurrentDictionary<Guid, ClientInfo>(); private readonly ConcurrentDictionary<Guid, ClientInfo> _apps = new ConcurrentDictionary<Guid, ClientInfo>();
public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, IHttpClient httpClient, ISessionManager sessionManager, IUserManager userManager) public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, IHttpClient httpClient, ISessionManager sessionManager, IUserManager userManager, IServerConfigurationManager config)
{ {
_logger = logger; _logger = logger;
_applicationHost = applicationHost; _applicationHost = applicationHost;
_httpClient = httpClient; _httpClient = httpClient;
_sessionManager = sessionManager; _sessionManager = sessionManager;
_userManager = userManager; _userManager = userManager;
_config = config;
_sessionManager.SessionStarted += _sessionManager_SessionStarted; _sessionManager.SessionStarted += _sessionManager_SessionStarted;
} }
@ -64,6 +65,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
private async void ReportNewSession(ClientInfo client) private async void ReportNewSession(ClientInfo client)
{ {
if (!_config.Configuration.EnableAnonymousUsageReporting)
{
return;
}
try try
{ {
await new UsageReporter(_applicationHost, _httpClient, _userManager, _logger) await new UsageReporter(_applicationHost, _httpClient, _userManager, _logger)
@ -106,6 +112,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// </summary> /// </summary>
private async void OnTimerFired() private async void OnTimerFired()
{ {
if (!_config.Configuration.EnableAnonymousUsageReporting)
{
return;
}
try try
{ {
await new UsageReporter(_applicationHost, _httpClient, _userManager, _logger) await new UsageReporter(_applicationHost, _httpClient, _userManager, _logger)

View File

@ -8,6 +8,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
namespace MediaBrowser.Server.Implementations.EntryPoints namespace MediaBrowser.Server.Implementations.EntryPoints
@ -51,6 +52,10 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
data["plugins"] = string.Join(",", _applicationHost.Plugins.Select(i => i.Id).ToArray()); data["plugins"] = string.Join(",", _applicationHost.Plugins.Select(i => i.Id).ToArray());
var logErrors = false;
#if DEBUG
logErrors = true;
#endif
var options = new HttpRequestOptions var options = new HttpRequestOptions
{ {
Url = MbAdminUrl + "service/registration/ping", Url = MbAdminUrl + "service/registration/ping",
@ -59,7 +64,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
// Seeing block length errors // Seeing block length errors
EnableHttpCompression = false, EnableHttpCompression = false,
LogRequest = false LogRequest = false,
LogErrors = logErrors
}; };
options.SetPostData(data); options.SetPostData(data);
@ -95,6 +101,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{ "platform", app.DeviceName }, { "platform", app.DeviceName },
}; };
var logErrors = false;
#if DEBUG
logErrors = true;
#endif
var options = new HttpRequestOptions var options = new HttpRequestOptions
{ {
Url = MbAdminUrl + "service/registration/ping", Url = MbAdminUrl + "service/registration/ping",
@ -103,7 +114,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
// Seeing block length errors // Seeing block length errors
EnableHttpCompression = false, EnableHttpCompression = false,
LogRequest = false LogRequest = false,
LogErrors = logErrors
}; };
options.SetPostData(data); options.SetPostData(data);