我有一条线索,我用它来跟踪KRL中的应用历史记录。我正在寻找一种简单的方法来调试跟踪,包括查看当前正在跟踪的内容并清除它。
在KRL中有一种简单的方法吗?
答案 0 :(得分:2)
对我来说,最简单的方法是查看其中的内容是将其内容输出到浏览器控制台。
rule inspect_data_on_trail {
select when pageview ".*"
pre {
visitedDomains = ent:visitedDomains;
}
{
emit <|
console.log(visitedDomains);
|>;
}
}
运行规则集几次后firebug输出:
要清除实体变量(包括路径),我通常只会编写一个规则,选择不属于我应用体验的域,并清除应用在该域上运行时的变量。
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;
}
}
}