Skip to content

Commit

Permalink
Add blocks in RTE telemetry (#16104)
Browse files Browse the repository at this point in the history
* Add blocks telemetry

* Use constants and update tests

* V13: Add property type information to telemetry (#16109)

* Add property type counts to telemetry

* Use constants and fix tests

* Update description
  • Loading branch information
nikolajlauridsen authored Apr 22, 2024
1 parent a27a4dc commit 0980350
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Umbraco.Core/Constants-Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ public static class Telemetry
public static string WebhookTotal = $"{WebhookPrefix}Total";
public static string WebhookCustomHeaders = $"{WebhookPrefix}CustomHeaders";
public static string WebhookCustomEvent = $"{WebhookPrefix}CustomEvent";
public static string RichTextEditorCount = "RichTextEditorCount";
public static string RichTextBlockCount = "RichTextBlockCount";
public static string TotalPropertyCount = "TotalPropertyCount";
public static string HighestPropertyCount = "HighestPropertyCount";
public static string TotalCompositions = "TotalCompositions";
}
}
2 changes: 1 addition & 1 deletion src/Umbraco.Core/EmbeddedResources/Lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="detailedLevelDescription"><![CDATA[We will send:
<ul>
<li>Anonymized site ID, Umbraco version, and packages installed.</li>
<li>Number of: Root nodes, Content nodes, Macros, Media, Document Types, Templates, Languages, Domains, User Group, Users, Members, Backoffice external login providers, Webhooks, and Property Editors in use.</li>
<li>Number of: Root nodes, Content nodes, Macros, Media, Document Types, Property Types, Compositions, Templates, Languages, Domains, User Group, Users, Members, Backoffice external login providers, Webhooks, rich text datatypes, blocks used in rich text datatypes, and Property Editors in use.</li>
<li>System information: Webserver, server OS, server framework, server OS language, and database provider.</li>
<li>Configuration settings: Modelsbuilder mode, if custom Umbraco path exists, ASP environment, whether the delivery API is enabled, and allows public access, and if you are in debug mode.</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3096,7 +3096,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
We will send:
<ul>
<li>Anonymized site ID, Umbraco version, and packages installed.</li>
<li>Number of: Root nodes, Content nodes, Macros, Media, Document Types, Templates, Languages, Domains, User Group, Users, Members, Backoffice external login providers, Webhooks, and Property Editors in use.</li>
<li>Number of: Root nodes, Content nodes, Macros, Media, Document Types, Property Types, Compositions, Templates, Languages, Domains, User Group, Users, Members, Backoffice external login providers, Webhooks, rich text datatypes, blocks used in rich text datatypes, and Property Editors in use.</li>
<li>System information: Webserver, server OS, server framework, server OS language, and database provider.</li>
<li>Configuration settings: Modelsbuilder mode, if custom Umbraco path exists, ASP environment, whether the delivery API is enabled, and allows public access, and if you are in debug mode.</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static IUmbracoBuilder AddTelemetryProviders(this IUmbracoBuilder builder
builder.Services.AddTransient<IDetailedTelemetryProvider, SystemInformationTelemetryProvider>();
builder.Services.AddTransient<IDetailedTelemetryProvider, DeliveryApiTelemetryProvider>();
builder.Services.AddTransient<IDetailedTelemetryProvider, WebhookTelemetryProvider>();
builder.Services.AddTransient<IDetailedTelemetryProvider, BlocksInRichTextTelemetryProvider>();
return builder;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Telemetry.Interfaces;

namespace Umbraco.Cms.Infrastructure.Telemetry.Providers;

public class BlocksInRichTextTelemetryProvider : IDetailedTelemetryProvider
{
private readonly IDataTypeService _dataTypeService;

public BlocksInRichTextTelemetryProvider(IDataTypeService dataTypeService)
{
_dataTypeService = dataTypeService;
}

public IEnumerable<UsageInformation> GetInformation()
{
IEnumerable<IDataType> richTextDataTypes = _dataTypeService.GetByEditorAlias(Constants.PropertyEditors.Aliases.TinyMce).ToArray();
int registeredBlocks = 0;
yield return new UsageInformation(Constants.Telemetry.RichTextEditorCount, richTextDataTypes.Count());

foreach (IDataType richTextDataType in richTextDataTypes)
{
if (richTextDataType.Configuration is not RichTextConfiguration richTextConfiguration)
{
// Might be some custom data type, skip it
continue;
}

if (richTextConfiguration.Blocks is null)
{
continue;
}

registeredBlocks += richTextConfiguration.Blocks.Length;
}

yield return new UsageInformation(Constants.Telemetry.RichTextBlockCount, registeredBlocks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ public IEnumerable<UsageInformation> GetInformation()
{
IEnumerable<IContentType> contentTypes = _contentTypeService.GetAll();
var propertyTypes = new HashSet<string>();
var propertyTypeCounts = new List<int>();
var totalCompositions = 0;

foreach (IContentType contentType in contentTypes)
{
propertyTypes.UnionWith(contentType.PropertyTypes.Select(x => x.PropertyEditorAlias));
propertyTypeCounts.Add(contentType.CompositionPropertyTypes.Count());
totalCompositions += contentType.CompositionAliases().Count();
}

yield return new UsageInformation(Constants.Telemetry.Properties, propertyTypes);
yield return new UsageInformation(Constants.Telemetry.TotalPropertyCount, propertyTypeCounts.Sum());
yield return new UsageInformation(Constants.Telemetry.HighestPropertyCount, propertyTypeCounts.Count > 0 ? propertyTypeCounts.Max() : 0);
yield return new UsageInformation(Constants.Telemetry.TotalCompositions, totalCompositions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public void Expected_Detailed_Telemetry_Exists()
Constants.Telemetry.WebhookTotal,
Constants.Telemetry.WebhookCustomHeaders,
Constants.Telemetry.WebhookCustomEvent,
Constants.Telemetry.RichTextEditorCount,
Constants.Telemetry.RichTextBlockCount,
Constants.Telemetry.TotalPropertyCount,
Constants.Telemetry.HighestPropertyCount,
Constants.Telemetry.TotalCompositions,
};

// Add the default webhook events.
Expand Down

0 comments on commit 0980350

Please sign in to comment.