Extra Stat collection (#407)

* Cleaned up error interceptor to avoid sending auth errors (when a 500 occurs) to sentry as auth errors aren't issues.

* Added extra stat collection

* Fixed a bad gitignore which ignored anything in a stats directory
This commit is contained in:
Joseph Milazzo 2021-07-20 11:32:37 -05:00 committed by GitHub
parent b9a06d3586
commit b11bb0e3b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 64 additions and 57 deletions

View file

@ -1,10 +1,10 @@
using System;
using System.IO;
using System.Threading.Tasks;
using API.DTOs;
using API.DTOs.Stats;
using API.Extensions;
using API.Interfaces.Services;
using API.Services;
using API.Services.Tasks;
using Kavita.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

View file

@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
using API.DTOs;
using API.DTOs.Stats;
using API.Interfaces.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

View file

@ -1,6 +1,6 @@
using System;
namespace API.DTOs
namespace API.DTOs.Stats
{
public class ClientInfoDto
{
@ -16,13 +16,14 @@ namespace API.DTOs
public DetailsVersion Os { get; set; }
public DateTime? CollectedAt { get; set; }
public bool UsingDarkTheme { get; set; }
public bool IsTheSameDevice(ClientInfoDto clientInfoDto)
{
return (clientInfoDto.ScreenResolution ?? "").Equals(ScreenResolution) &&
(clientInfoDto.PlatformType ?? "").Equals(PlatformType) &&
(clientInfoDto.Browser?.Name ?? "").Equals(Browser?.Name) &&
(clientInfoDto.Os?.Name ?? "").Equals(Os?.Name) &&
return (clientInfoDto.ScreenResolution ?? string.Empty).Equals(ScreenResolution) &&
(clientInfoDto.PlatformType ?? string.Empty).Equals(PlatformType) &&
(clientInfoDto.Browser?.Name ?? string.Empty).Equals(Browser?.Name) &&
(clientInfoDto.Os?.Name ?? string.Empty).Equals(Os?.Name) &&
clientInfoDto.CollectedAt.GetValueOrDefault().ToString("yyyy-MM-dd")
.Equals(CollectedAt.GetValueOrDefault().ToString("yyyy-MM-dd"));
}
@ -33,4 +34,4 @@ namespace API.DTOs
public string Name { get; set; }
public string Version { get; set; }
}
}
}

View file

@ -1,4 +1,4 @@
namespace API.DTOs
namespace API.DTOs.Stats
{
public class ServerInfoDto
{
@ -8,5 +8,7 @@
public string KavitaVersion { get; set; }
public string BuildBranch { get; set; }
public string Culture { get; set; }
public bool IsDocker { get; set; }
public int NumOfCores { get; set; }
}
}
}

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using API.Entities.Enums;
namespace API.DTOs
namespace API.DTOs.Stats
{
public class UsageInfoDto
{
@ -21,4 +21,4 @@ namespace API.DTOs
public LibraryType Type { get; set; }
public int Count { get; set; }
}
}
}

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
namespace API.DTOs
namespace API.DTOs.Stats
{
public class UsageStatisticsDto
{
@ -30,4 +30,4 @@ namespace API.DTOs
ClientsInfo.Add(clientInfoDto);
}
}
}
}

View file

@ -1,5 +1,5 @@
using System.Threading.Tasks;
using API.DTOs;
using API.DTOs.Stats;
namespace API.Interfaces.Services
{
@ -10,4 +10,4 @@ namespace API.Interfaces.Services
Task CollectRelevantData();
Task CollectAndSendStatsData();
}
}
}

View file

@ -2,7 +2,7 @@
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using API.DTOs;
using API.DTOs.Stats;
using Microsoft.Extensions.Logging;
namespace API.Services.Clients

View file

@ -6,7 +6,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using API.Data;
using API.DTOs;
using API.DTOs.Stats;
using API.Interfaces;
using API.Interfaces.Services;
using API.Services.Clients;
@ -15,7 +15,7 @@ using Kavita.Common.EnvironmentInfo;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace API.Services
namespace API.Services.Tasks
{
public class StatsService : IStatsService
{
@ -142,7 +142,9 @@ namespace API.Services
RunTimeVersion = RuntimeInformation.FrameworkDescription,
KavitaVersion = BuildInfo.Version.ToString(),
Culture = Thread.CurrentThread.CurrentCulture.Name,
BuildBranch = BuildInfo.Branch
BuildBranch = BuildInfo.Branch,
IsDocker = new OsInfo(Array.Empty<IOsVersionAdapter>()).IsDocker,
NumOfCores = Environment.ProcessorCount
};
return serverInfo;

View file

@ -7,6 +7,7 @@ using API.Services;
using API.Services.HostedServices;
using Hangfire;
using Hangfire.MemoryStorage;
using Kavita.Common;
using Kavita.Common.EnvironmentInfo;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;