mirror of https://github.com/abpframework/abp.git
6 changed files with 225 additions and 182 deletions
@ -1,38 +1,34 @@ |
|||
using System; |
|||
using System.Reflection; |
|||
using System.Threading.Tasks; |
|||
using Helpers; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Telemetry.Activity; |
|||
|
|||
namespace Volo.Abp.Telemetry; |
|||
|
|||
public class AbpTelemetryModule : AbpModule |
|||
{ |
|||
|
|||
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) |
|||
{ |
|||
var packageMetadata = AbpPackageMetadataHelper.GetMetaData(Assembly.GetCallingAssembly()); |
|||
|
|||
if (packageMetadata != null) |
|||
{ |
|||
var activityStorage = context.ServiceProvider.GetRequiredService<IActivityStorage>(); |
|||
var lastApplicationInfoSendTime = await activityStorage.GetApplicationInfoLastActivitySendTimeAsync(packageMetadata.ProjectId!.To<Guid>()); |
|||
if (lastApplicationInfoSendTime is null || |
|||
DateTimeOffset.UtcNow - lastApplicationInfoSendTime > TimeSpan.FromDays(7)) |
|||
{ |
|||
var telemetryService = context.ServiceProvider.GetRequiredService<ITelemetryService>(); |
|||
|
|||
await using var _ = telemetryService.TrackActivity(ActivityNameConsts.ApplicationRun, c => |
|||
{ |
|||
c.Add("ProjectAssemblyForScan", Assembly.GetCallingAssembly()); |
|||
c.Add("ProjectId", packageMetadata.ProjectId!); |
|||
c.Add("ProjectType", packageMetadata.Role!); |
|||
}); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
|||
// using System;
|
|||
// using System.Reflection;
|
|||
// using System.Threading.Tasks;
|
|||
// using Microsoft.Extensions.DependencyInjection;
|
|||
// using Volo.Abp.Modularity;
|
|||
// using Volo.Abp.Telemetry.Activity;
|
|||
// using Volo.Abp.Telemetry.Helpers;
|
|||
//
|
|||
// namespace Volo.Abp.Telemetry;
|
|||
//
|
|||
// public class AbpTelemetryModule : AbpModule
|
|||
// {
|
|||
//
|
|||
// public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
|
|||
// {
|
|||
// var packageMetadata = AbpPackageMetadataHelper.GetMetaData(Assembly.GetCallingAssembly());
|
|||
//
|
|||
// if (packageMetadata != null)
|
|||
// {
|
|||
//
|
|||
// var telemetryService = context.ServiceProvider.GetRequiredService<ITelemetryService>();
|
|||
//
|
|||
// await using var _ = telemetryService.TrackActivity(ActivityNameConsts.ApplicationRun, activity =>
|
|||
// {
|
|||
// activity.Add("ProjectAssemblyForScan", Assembly.GetCallingAssembly());
|
|||
// activity.Add("ProjectId", packageMetadata.ProjectId!);
|
|||
// activity.Add("ProjectType", packageMetadata.Role!);
|
|||
// activity.Add("SolutionPath", packageMetadata.AbpSlnPath ?? string.Empty);
|
|||
// });
|
|||
//
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// }
|
|||
@ -0,0 +1,42 @@ |
|||
namespace Volo.Abp.Telemetry.Activity; |
|||
|
|||
public static class ActivityPropertyNameConstants |
|||
{ |
|||
public const string SessionId = nameof(SessionId); |
|||
public const string IsFirstSession = nameof(IsFirstSession); |
|||
public const string DeviceId = nameof(DeviceId); |
|||
public const string DeviceType = nameof(DeviceType); |
|||
public const string DeviceLanguage = nameof(DeviceLanguage); |
|||
public const string OperatingSystem = nameof(OperatingSystem); |
|||
public const string CountryIsoCode = nameof(CountryIsoCode); |
|||
public const string InstalledSoftwares = nameof(InstalledSoftwares); |
|||
public const string ControllerCount = nameof(ControllerCount); |
|||
public const string EntityCount = nameof(EntityCount); |
|||
public const string AbpModuleCount = nameof(AbpModuleCount); |
|||
public const string PermissionCount = nameof(PermissionCount); |
|||
public const string AppServiceCount = nameof(AppServiceCount); |
|||
public const string ProjectType = nameof(ProjectType); |
|||
public const string ProjectId = nameof(ProjectId); |
|||
public const string SolutionId = nameof(SolutionId); |
|||
public const string Template = nameof(Template); |
|||
public const string CreatedAbpStudioVersion = nameof(CreatedAbpStudioVersion); |
|||
public const string IsTiered = nameof(IsTiered); |
|||
public const string UiFramework = nameof(UiFramework); |
|||
public const string DatabaseProvider = nameof(DatabaseProvider); |
|||
public const string DatabaseManagementSystem = nameof(DatabaseManagementSystem); |
|||
public const string IsSeparateTenantSchema = nameof(IsSeparateTenantSchema); |
|||
public const string Theme = nameof(Theme); |
|||
public const string ThemeStyle = nameof(ThemeStyle); |
|||
public const string MobileFramework = nameof(MobileFramework); |
|||
public const string HasPublicWebsite = nameof(HasPublicWebsite); |
|||
public const string IncludeTests = nameof(IncludeTests); |
|||
public const string MultiTenancy = nameof(MultiTenancy); |
|||
public const string DynamicLocalization = nameof(DynamicLocalization); |
|||
public const string KubernetesConfiguration = nameof(KubernetesConfiguration); |
|||
public const string GrafanaDashboard = nameof(GrafanaDashboard); |
|||
public const string SocialLogins = nameof(SocialLogins); |
|||
public const string InstalledModules = nameof(InstalledModules); |
|||
public const string ProjectAssemblyForScan = nameof(ProjectAssemblyForScan); |
|||
public const string SolutionPath = nameof(SolutionPath); |
|||
public const string Assembly = nameof(Assembly); |
|||
} |
|||
Loading…
Reference in new issue