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

fix: Concatenate telemetry initializer data and method data #89

Merged
merged 3 commits into from
Aug 5, 2021

Conversation

c-owens
Copy link
Contributor

@c-owens c-owens commented Aug 2, 2021

This allows for setting some custom data to be passed in every telemetry request and also in custom properties on track method calls, e.g.:

var telemetryItem = new TelemetryItem()
{
    Tags = new Dictionary<string, object>()
    {
        { "ai.cloud.role", "SPA" },
        { "ai.cloud.roleInstance", "Blazor Wasm" },
    },
    Data = new Dictionary<string, object>
    {
        { "UserName", User?.Name ?? "" },
        { "UserEmail", User?.Email ?? "" },
        { "UserId", User?.UserId ?? Guid.Empty },
    }
};

await appInsights.AddTelemetryInitializer(telemetryItem);

await appInsights.TrackEvent("App Started", new Dictionary<string, object>()
{
    { "EnabledModules", true },
    { "ClientVersion", "1.2.3.4" }
});

Without this change, only UserName, UserEmail, and UserId would be included in the App Started event.

@IvanJosipovic IvanJosipovic changed the title Concatenate telemetry initializer data and method data fix: Concatenate telemetry initializer data and method data Aug 5, 2021
@IvanJosipovic IvanJosipovic changed the title fix: Concatenate telemetry initializer data and method data fix2: Concatenate telemetry initializer data and method data Aug 5, 2021
@IvanJosipovic IvanJosipovic changed the title fix2: Concatenate telemetry initializer data and method data fix: Concatenate telemetry initializer data and method data Aug 5, 2021
@IvanJosipovic IvanJosipovic merged commit 10da149 into IvanJosipovic:master Aug 5, 2021
@IvanJosipovic
Copy link
Owner

Thank you for this fix!

@github-actions
Copy link

github-actions bot commented Aug 5, 2021

🎉 This PR is included in version 1.2.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants