Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log MsalVersion to ITelemetryClient #3747

Merged
merged 8 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Microsoft.Identity.Client.Extensibility;
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.Internal.ClientCredential;
using Microsoft.Identity.Client.TelemetryCore;
using Microsoft.Identity.Client.TelemetryCore.TelemetryClient;
using Microsoft.IdentityModel.Abstractions;

namespace Microsoft.Identity.Client
Expand Down Expand Up @@ -343,9 +345,25 @@ public ConfidentialClientApplicationBuilder WithTelemetryClient(params ITelemetr
Config.TelemetryClients = telemetryClients;
}

TelemetryClientLogMsalVersion();

return this;
}

private void TelemetryClientLogMsalVersion()
{
MsalTelemetryEventDetails telemetryEventDetails = new MsalTelemetryEventDetails(TelemetryConstants.ConfigurationUpdateEventName);
neha-bhargava marked this conversation as resolved.
Show resolved Hide resolved
telemetryEventDetails.SetProperty(TelemetryConstants.MsalVersion, MsalIdHelper.GetMsalVersion());
neha-bhargava marked this conversation as resolved.
Show resolved Hide resolved

foreach (var telemetryClient in Config.TelemetryClients)
neha-bhargava marked this conversation as resolved.
Show resolved Hide resolved
{
if (telemetryClient.IsEnabled(TelemetryConstants.ConfigurationUpdateEventName))
{
telemetryClient.TrackEvent(telemetryEventDetails);
}
}
}

internal ConfidentialClientApplicationBuilder WithAppTokenCacheInternalForTest(ITokenCacheInternal tokenCacheInternal)
{
Config.AppTokenCacheInternalForTest = tokenCacheInternal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task<AuthenticationResult> RunAsync(CancellationToken cancellationT

ApiEvent apiEvent = InitializeApiEvent(AuthenticationRequestParameters.Account?.HomeAccountId?.Identifier);
AuthenticationRequestParameters.RequestContext.ApiEvent = apiEvent;
MsalTelemetryEventDetails telemetryEventDetails = new MsalTelemetryEventDetails();
MsalTelemetryEventDetails telemetryEventDetails = new MsalTelemetryEventDetails(TelemetryConstants.AcquireTokenEventName);
ITelemetryClient[] telemetryClients = AuthenticationRequestParameters.RequestContext.ServiceBundle.Config.TelemetryClients;

using (AuthenticationRequestParameters.RequestContext.CreateTelemetryHelper(apiEvent))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace Microsoft.Identity.Client.TelemetryCore.TelemetryClient
{
internal class MsalTelemetryEventDetails : TelemetryEventDetails
{
public MsalTelemetryEventDetails()
public MsalTelemetryEventDetails(string eventName)
neha-bhargava marked this conversation as resolved.
Show resolved Hide resolved
{
Name = TelemetryConstants.AcquireTokenEventName;
Name = eventName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ internal static class TelemetryConstants
#region Telemetry Client Constants

public const string AcquireTokenEventName = "acquire_token";
public const string ConfigurationUpdateEventName = "config_update";
public const string MsalVersion = "MsalVersion";
public const string RemainingLifetime = "RemainingLifetime";
public const string PopToken = "PopToken";
public const string TokenSource = "TokenSource";
Expand Down