应用程序见解 - 使用数据数组作为属性跟踪自定义事件



我有一个具有搜索功能的Web应用程序。

我希望能够使用查找的关键字列表跟踪搜索事件(以便能够识别最常见的关键字(。

我目前跟踪数据如下:

telemetryClient.TrackEvent(Names.RepositorySearch, new Dictionary<string, string>()
{
{PropertyKeys.OrganizationName, repositoryQueryParameter.OrganizationName},
{PropertyKeys.RepositoryName, repositoryQueryParameter.RepositoryName},
{PropertyKeys.Query, query },
{PropertyKeys.IsRegex, isRegex.ToString()},
{PropertyKeys.ResultsCount, resultsCount.ToString()},
{PropertyKeys.QueryExecutionTime, elapsed.TotalMilliseconds.ToString()},
});

我跟踪一个完整的查询,这与令牌/关键字列表略有不同。

我知道我可以在循环中为每个关键字发布另一个小事件,但这似乎很讨厌......

如果对搜索参数进行 JSON 编码,则可以使用 extract_json(( 函数在 Kusto 查询中解压缩它们。

跟踪代码:

telemetryClient.TrackEvent(
"RepositorySearch",
new Dictionary<string,string> {
// JSON literal used for example purposes.
// Use your favorite JSON serializer in real life.
["SearchTerms"] = "[ "Term1", "Term2" ]",
}
);

库斯托查询:

customEvents
| where name == "RepositorySearch" 
| extend searchTerms = parse_json(customDimensions.SearchTerms) 

某些应用见解数据可视化工具足够智能,可以很好地自动识别和呈现 JSON 列表/对象。如果只想直观地检查数据,则甚至可能不需要自定义查询。

最新更新