diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2019-01-07 00:47:06 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-07 00:47:06 -0500 |
| commit | c986340c02cb0b7fe06569d25a1b5d1c8375f7f6 (patch) | |
| tree | 4971c970bbdb797cc5b3da2d8bae506231b173a5 /Emby.Server.Implementations/EntryPoints/UsageReporter.cs | |
| parent | 76b647e0a8eddd65dc9c4de7b887a3faf6e12bcc (diff) | |
| parent | 0b804629b85498370c882f5562dfc7acd84bfd11 (diff) | |
Merge pull request #419 from jellyfin/dev
Master 10.0.0
Diffstat (limited to 'Emby.Server.Implementations/EntryPoints/UsageReporter.cs')
| -rw-r--r-- | Emby.Server.Implementations/EntryPoints/UsageReporter.cs | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/Emby.Server.Implementations/EntryPoints/UsageReporter.cs b/Emby.Server.Implementations/EntryPoints/UsageReporter.cs deleted file mode 100644 index d9c9e1a40..000000000 --- a/Emby.Server.Implementations/EntryPoints/UsageReporter.cs +++ /dev/null @@ -1,130 +0,0 @@ -using MediaBrowser.Common; -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Connect; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Controller; -using MediaBrowser.Model.Logging; - -namespace Emby.Server.Implementations.EntryPoints -{ - public class UsageReporter - { - private readonly IServerApplicationHost _applicationHost; - private readonly IHttpClient _httpClient; - private readonly ILogger _logger; - private const string MbAdminUrl = "https://www.mb3admin.local/admin/"; - - public UsageReporter(IServerApplicationHost applicationHost, IHttpClient httpClient, ILogger logger) - { - _applicationHost = applicationHost; - _httpClient = httpClient; - _logger = logger; - } - - public async Task ReportServerUsage(CancellationToken cancellationToken) - { - cancellationToken.ThrowIfCancellationRequested(); - - var data = new Dictionary<string, string> - { - { "feature", _applicationHost.Name }, - { "mac", _applicationHost.SystemId }, - { "serverid", _applicationHost.SystemId }, - { "deviceid", _applicationHost.SystemId }, - { "ver", _applicationHost.ApplicationVersion.ToString() }, - { "platform", _applicationHost.OperatingSystemDisplayName } - }; - - data["plugins"] = string.Join(",", _applicationHost.Plugins.Select(i => i.Id).ToArray()); - - var logErrors = false; -#if DEBUG - logErrors = true; -#endif - var options = new HttpRequestOptions - { - Url = MbAdminUrl + "service/registration/ping", - CancellationToken = cancellationToken, - - // Seeing block length errors - EnableHttpCompression = false, - - LogRequest = false, - LogErrors = logErrors, - BufferContent = false - }; - - options.SetPostData(data); - - using (var response = await _httpClient.SendAsync(options, "POST").ConfigureAwait(false)) - { - - } - } - - public async Task ReportAppUsage(ClientInfo app, CancellationToken cancellationToken) - { - if (string.IsNullOrEmpty(app.DeviceId)) - { - throw new ArgumentException("Client info must have a device Id"); - } - - _logger.Info("App Activity: app: {0}, version: {1}, deviceId: {2}, deviceName: {3}", - app.AppName ?? "Unknown App", - app.AppVersion ?? "Unknown", - app.DeviceId, - app.DeviceName ?? "Unknown"); - - cancellationToken.ThrowIfCancellationRequested(); - - var data = new Dictionary<string, string> - { - { "feature", app.AppName ?? "Unknown App" }, - { "serverid", _applicationHost.SystemId }, - { "deviceid", app.DeviceId }, - { "mac", app.DeviceId }, - { "ver", app.AppVersion ?? "Unknown" }, - { "platform", app.DeviceName }, - }; - - var logErrors = false; - -#if DEBUG - logErrors = true; -#endif - var options = new HttpRequestOptions - { - Url = MbAdminUrl + "service/registration/ping", - CancellationToken = cancellationToken, - - // Seeing block length errors - EnableHttpCompression = false, - - LogRequest = false, - LogErrors = logErrors, - BufferContent = false - }; - - options.SetPostData(data); - - using (var response = await _httpClient.SendAsync(options, "POST").ConfigureAwait(false)) - { - - } - } - } - - public class ClientInfo - { - public string AppName { get; set; } - public string AppVersion { get; set; } - public string DeviceName { get; set; } - public string DeviceId { get; set; } - } -} |
