我有一条线索用于跟踪 KRL 中的应用历史记录。我正在寻找一种简单的方法来调试跟踪,包括查看当前跟踪的内容并清除它。
在 KRL 中是否有一种简单的方法可以做到这一点?
对我来说,查看跟踪内容的最简单方法是将其内容输出到浏览器控制台。
rule inspect_data_on_trail {
select when pageview ".*"
pre {
visitedDomains = ent:visitedDomains;
}
{
emit <|
console.log(visitedDomains);
|>;
}
}
多次运行规则集后的萤火虫输出:
要清除包括轨迹在内的实体变量,我通常只编写一个规则,选择一个不属于我的应用程序体验的域,并在应用程序在该域上运行时清除变量。
rule clear_everything {
select when pageview "yahoo\.com"
{
notify("Cleared",":)") with sticky = true;
}
fired {
clear ent:visitedDomains;
}
}
完整的示例应用程序:
ruleset a60x458 {
meta {
name "trail-debugging"
description <<
trail-debugging
>>
author "Mike Grace"
logging on
}
rule put_data_onto_trail {
select when pageview ".*"
pre {
domain = page:url("domain");
}
{
notify("Thanks for visiting #{domain}","You visit has been recorded") with sticky = true;
}
fired {
mark ent:visitedDomains with domain;
}
}
rule inspect_data_on_trail {
select when pageview ".*"
pre {
visitedDomains = ent:visitedDomains;
}
{
emit <|
console.log(visitedDomains);
|>;
}
}
rule clear_everything {
select when pageview "yahoo\.com"
{
notify("Cleared",":)") with sticky = true;
}
fired {
clear ent:visitedDomains;
}
}
}