Installer: Removes unused telemetry functionality (#20995)

* fix: removes the non-functioning installer telemetry and obsoletes all InstallHelper functionality

* fix: deprecates related cookie

* fix: adds ActivatorUtilitiesConstructor for DI

* fix: obsoletes and removes more telemetry functionality

* fix: removes uneeded modifier

* docs: removes docs

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jacob Overgaard
2025-11-28 22:21:04 +01:00
committed by GitHub
parent f99e9394f8
commit 050b37ed1a
6 changed files with 31 additions and 110 deletions

View File

@@ -1,6 +1,7 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Infrastructure.Install;
using Umbraco.Cms.Api.Management.ViewModels.Installer;
@@ -12,16 +13,23 @@ namespace Umbraco.Cms.Api.Management.Controllers.Install;
[ApiVersion("1.0")]
public class SettingsInstallController : InstallControllerBase
{
private readonly InstallHelper _installHelper;
private readonly IInstallSettingsFactory _installSettingsFactory;
private readonly IUmbracoMapper _mapper;
[Obsolete("Please use the constructor without the InstallHelper parameter. Scheduled for removal in Umbraco 19.")]
public SettingsInstallController(
InstallHelper installHelper,
IInstallSettingsFactory installSettingsFactory,
IUmbracoMapper mapper)
: this(installSettingsFactory, mapper)
{
}
[ActivatorUtilitiesConstructor]
public SettingsInstallController(
IInstallSettingsFactory installSettingsFactory,
IUmbracoMapper mapper)
{
_installHelper = installHelper;
_installSettingsFactory = installSettingsFactory;
_mapper = mapper;
}
@@ -32,9 +40,6 @@ public class SettingsInstallController : InstallControllerBase
[ProducesResponseType(typeof(InstallSettingsResponseModel), StatusCodes.Status200OK)]
public async Task<IActionResult> Settings(CancellationToken cancellationToken)
{
// Register that the install has started
await _installHelper.SetInstallStatusAsync(false, string.Empty);
InstallSettingsModel installSettings = _installSettingsFactory.GetInstallSettings();
InstallSettingsResponseModel responseModel = _mapper.Map<InstallSettingsResponseModel>(installSettings)!;

View File

@@ -17,6 +17,7 @@ public static partial class Constants
/// </summary>
public const string AcceptPreviewCookieName = "UMB-WEBSITE-PREVIEW-ACCEPT";
[Obsolete("InstallerCookieName is no longer used and will be removed in Umbraco 19.")]
public const string InstallerCookieName = "umb_installId";
/// <summary>

View File

@@ -1,6 +1,8 @@
namespace Umbraco.Cms.Core.Persistence.Repositories;
[Obsolete("Installation logging is no longer supported and this interface will be removed in Umbraco 19.")]
public interface IInstallationRepository
{
[Obsolete("This method no longer has any function and will be removed in Umbraco 19.")]
Task SaveInstallLogAsync(InstallLog installLog);
}

View File

@@ -3,31 +3,15 @@ using Umbraco.Cms.Core.Serialization;
namespace Umbraco.Cms.Core.Persistence.Repositories;
[Obsolete("Installation logging is no longer supported and this class will be removed in Umbraco 19.")]
public class InstallationRepository : IInstallationRepository
{
private const string RestApiInstallUrl = "https://our.umbraco.com/umbraco/api/Installation/Install";
private static HttpClient? _httpClient;
private readonly IJsonSerializer _jsonSerializer;
public InstallationRepository(IJsonSerializer jsonSerializer) => _jsonSerializer = jsonSerializer;
public async Task SaveInstallLogAsync(InstallLog installLog)
public InstallationRepository(IJsonSerializer jsonSerializer)
{
try
{
if (_httpClient == null)
{
_httpClient = new HttpClient();
}
using var content = new StringContent(_jsonSerializer.Serialize(installLog), Encoding.UTF8, "application/json");
await _httpClient.PostAsync(RestApiInstallUrl, content);
}
// this occurs if the server for Our is down or cannot be reached
catch (HttpRequestException)
{
}
}
[Obsolete("This method no longer has any function and will be removed in Umbraco 19.")]
public Task SaveInstallLogAsync(InstallLog installLog) => Task.CompletedTask;
}

View File

@@ -8,23 +8,12 @@ using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Migrations.Install;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Extensions;
using Constants = Umbraco.Cms.Core.Constants;
namespace Umbraco.Cms.Infrastructure.Install
{
[Obsolete("InstallHelper is no longer used internally and will be removed in Umbraco 19.")]
public sealed class InstallHelper
{
private readonly DatabaseBuilder _databaseBuilder;
private readonly ILogger<InstallHelper> _logger;
private readonly IUmbracoVersion _umbracoVersion;
private readonly IOptionsMonitor<ConnectionStrings> _connectionStrings;
private readonly IInstallationService _installationService;
private readonly ICookieManager _cookieManager;
private readonly IUserAgentProvider _userAgentProvider;
private readonly IUmbracoDatabaseFactory _umbracoDatabaseFactory;
private readonly IFireAndForgetRunner _fireAndForgetRunner;
private readonly IEnumerable<IDatabaseProviderMetadata> _databaseProviderMetadata;
public InstallHelper(
DatabaseBuilder databaseBuilder,
@@ -38,74 +27,12 @@ namespace Umbraco.Cms.Infrastructure.Install
IFireAndForgetRunner fireAndForgetRunner,
IEnumerable<IDatabaseProviderMetadata> databaseProviderMetadata)
{
_logger = logger;
_umbracoVersion = umbracoVersion;
_databaseBuilder = databaseBuilder;
_connectionStrings = connectionStrings;
_installationService = installationService;
_cookieManager = cookieManager;
_userAgentProvider = userAgentProvider;
_umbracoDatabaseFactory = umbracoDatabaseFactory;
_fireAndForgetRunner = fireAndForgetRunner;
_databaseProviderMetadata = databaseProviderMetadata;
}
public Task SetInstallStatusAsync(bool isCompleted, string errorMsg)
{
try
{
var userAgent = _userAgentProvider.GetUserAgent();
// Check for current install ID
var installCookie = _cookieManager.GetCookieValue(Constants.Web.InstallerCookieName);
if (!Guid.TryParse(installCookie, out Guid installId))
{
installId = Guid.NewGuid();
_cookieManager.SetCookieValue(Constants.Web.InstallerCookieName, installId.ToString(), false, false, "Unspecified");
}
var dbProvider = string.Empty;
if (IsBrandNewInstall == false)
{
// we don't have DatabaseProvider anymore... doing it differently
//dbProvider = ApplicationContext.Current.DatabaseContext.DatabaseProvider.ToString();
dbProvider = _umbracoDatabaseFactory.SqlContext.SqlSyntax.DbProvider;
}
var installLog = new InstallLog(
installId: installId,
isUpgrade: IsBrandNewInstall == false,
installCompleted: isCompleted,
timestamp: DateTime.Now,
versionMajor: _umbracoVersion.Version.Major,
versionMinor: _umbracoVersion.Version.Minor,
versionPatch: _umbracoVersion.Version.Build,
versionComment: _umbracoVersion.Comment,
error: errorMsg,
userAgent: userAgent,
dbProvider: dbProvider);
_fireAndForgetRunner.RunFireAndForget(() => _installationService.LogInstall(installLog));
}
catch (Exception ex)
{
_logger.LogError(ex, "An error occurred in InstallStatus trying to check upgrades");
}
return Task.CompletedTask;
}
/// <summary>
/// Checks if this is a brand new install, meaning that there is no configured database connection or the database is empty.
/// This method used to send installer telemetry to Our.Umbraco.com but no longer does anything and will be removed in Umbraco 19.
/// </summary>
/// <value>
/// <c>true</c> if this is a brand new install; otherwise, <c>false</c>.
/// </value>
private bool IsBrandNewInstall =>
_connectionStrings.CurrentValue.IsConnectionStringConfigured() == false ||
_databaseBuilder.IsDatabaseConfigured == false ||
(_databaseBuilder.CanConnectToDatabase == false && _databaseProviderMetadata.CanForceCreateDatabase(_umbracoDatabaseFactory)) ||
_databaseBuilder.IsUmbracoInstalled() == false;
[Obsolete("SetInstallStatusAsync no longer has any function and will be removed in Umbraco 19.")]
public Task SetInstallStatusAsync(bool isCompleted, string errorMsg) => Task.CompletedTask;
}
}

View File

@@ -7,19 +7,21 @@ namespace Umbraco.Cms.Infrastructure.Installer.Steps;
public class RegisterInstallCompleteStep : StepBase, IInstallStep, IUpgradeStep
{
private readonly InstallHelper _installHelper;
[Obsolete("Please use the constructor without parameters. Scheduled for removal in Umbraco 19.")]
public RegisterInstallCompleteStep(InstallHelper installHelper)
: this()
{
}
public RegisterInstallCompleteStep(InstallHelper installHelper) => _installHelper = installHelper;
public RegisterInstallCompleteStep()
{
}
public Task<Attempt<InstallationResult>> ExecuteAsync(InstallData _) => Execute();
public Task<Attempt<InstallationResult>> ExecuteAsync() => Execute();
private async Task<Attempt<InstallationResult>> Execute()
{
await _installHelper.SetInstallStatusAsync(true, string.Empty);
return Success();
}
private Task<Attempt<InstallationResult>> Execute() => Task.FromResult(Success());
public Task<bool> RequiresExecutionAsync(InstallData _) => ShouldExecute();