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

Add ability to add or update global properties #13

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

IeuanWalker
Copy link
Contributor

@IeuanWalker IeuanWalker commented Aug 21, 2024

My used case:

In our app we have the ability to allow the user to set the language the app uses manually.

Currently, the code sets the language based on the current culture at startup -
https://github.com/dhindrik/TinyInsights.Maui/blob/f94ee43e1c771fa3ec4213e4afdaa10276db0b89/TinyInsights/ApplicationInsightsProvider.cs#L141C8-L141C115

This happens before we set the app to the users saved preferred language, and the user could change the language at any point.

Meaning the stats in the application doesn't reflect the actual app settings

There are 2 changes in this PR -

  • Added UpsertGlobalProperty
    • This either Adds or Updates a property in the global properties dictionary.
    • i.e. i can use this to override the preset language insights.UpsertGlobalProperty("Language", AppSettings.SelectedLanguage)
    • It can also be used for other cases, f.e. we'd like to record the users theme so we can see whats the most used etc
  • Update the language query on the dashboard
    • Add | summarize arg_max(timestamp, *) by user_Id
    • This gets the last pageView event for the user, without this even with just one user the dashboard was showing 2 languages being used -
      image
    • It now just counts the latest language used by each user -
      image

@dhindrik dhindrik merged commit 1237925 into dhindrik:main Aug 21, 2024
1 check passed
@dhindrik
Copy link
Owner

Great improvement! Thank you for contributing!

@IeuanWalker IeuanWalker deleted the AddUpdateGlobalProperty branch August 21, 2024 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants