Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
IeuanWalker committed Aug 21, 2024
1 parent f94ee43 commit 368a172
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TinyInsights.Web/Services/InsightsService.Analytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Task<List<CountPerKey>> GetUserPerCountry(GlobalFilter filter)
public Task<List<CountPerKey>> GetUserPerLanguage(GlobalFilter filter)
{
var queryFilter = GetFilter(filter);
var query = $"pageViews | extend language = tostring(customDimensions.Language) | where{queryFilter} timestamp > ago({filter.NumberOfDays}d) | summarize PageViewsCount = dcount(user_Id) by language";
var query = $"pageViews | extend language = tostring(customDimensions.Language) | where{queryFilter} timestamp > ago({filter.NumberOfDays}d) | summarize arg_max(timestamp, *) by user_Id | summarize PageViewsCount = dcount(user_Id) by language";

return GetPerKeyResult(query);
}
Expand Down
2 changes: 0 additions & 2 deletions TinyInsights.Web/TinyInsights.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>


</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions TinyInsights/ApplicationInsightsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledEx
}
#endif

public void AddGlobalProperty(string key, string value)
{
client.Context.GlobalProperties[key] = value;
}

public void OverrideAnonymousUserId(string userId)
{
SetUserId(userId);
Expand Down
2 changes: 2 additions & 0 deletions TinyInsights/IInsights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ public interface IInsights
{
void AddProvider(IInsightsProvider provider);

void AddGlobalProperty(string key, string value);

Task TrackErrorAsync(Exception ex, Dictionary<string, string>? properties = null);

Task TrackPageViewAsync(string viewName, Dictionary<string, string>? properties = null);
Expand Down
2 changes: 2 additions & 0 deletions TinyInsights/IInsightsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public interface IInsightsProvider
bool IsTrackEventsEnabled { get; set; }
bool IsTrackDependencyEnabled { get; set; }

void AddGlobalProperty(string key, string value);

Task TrackErrorAsync(Exception ex, Dictionary<string, string>? properties = null);

Task TrackPageViewAsync(string viewName, Dictionary<string, string>? properties = null);
Expand Down
8 changes: 8 additions & 0 deletions TinyInsights/Insights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ public class Insights : IInsights
{
private readonly List<IInsightsProvider> insightsProviders = new();

public void AddGlobalProperty(string key, string value)
{
foreach(var provider in insightsProviders.Where(x => x.IsTrackErrorsEnabled))
{
provider.AddGlobalProperty(key, value);
}
}

public void AddProvider(IInsightsProvider provider)
{
insightsProviders.Add(provider);
Expand Down

0 comments on commit 368a172

Please sign in to comment.