* Run code cleanup * Start manual run * Finish dotnet format + manual cleanup * Fix up after merge * Fix substrings changed to [..] Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Zeegaan <nge@umbraco.dk>
31 lines
968 B
C#
31 lines
968 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
namespace Umbraco.Cms.Web.BackOffice.Controllers;
|
|
|
|
public class AnalyticsController : UmbracoAuthorizedJsonController
|
|
{
|
|
private readonly IMetricsConsentService _metricsConsentService;
|
|
|
|
public AnalyticsController(IMetricsConsentService metricsConsentService) =>
|
|
_metricsConsentService = metricsConsentService;
|
|
|
|
public TelemetryLevel GetConsentLevel() => _metricsConsentService.GetConsentLevel();
|
|
|
|
[HttpPost]
|
|
public IActionResult SetConsentLevel([FromBody] TelemetryResource telemetryResource)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return BadRequest();
|
|
}
|
|
|
|
_metricsConsentService.SetConsentLevel(telemetryResource.TelemetryLevel);
|
|
return Ok();
|
|
}
|
|
|
|
public IEnumerable<TelemetryLevel> GetAllLevels() =>
|
|
new[] { TelemetryLevel.Minimal, TelemetryLevel.Basic, TelemetryLevel.Detailed };
|
|
}
|