如何检查 KRL 中的路径并与之交互?

发布于 2024-10-05 20:45:21 字数 99 浏览 4 评论 0原文

我有一条记录,用于跟踪 KRL 中的应用程序历史记录。我正在寻找一种简单的方法来调试踪迹,包括查看当前踪迹上的内容并清除它。

KRL 有没有简单的方法可以做到这一点?

I have a trail that I'm using to track app history in KRL. I'm looking for an easy way to debug the trail, including seeing what is currently on the trail and clearing it.

Is there an easy way to do that in KRL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初心 2024-10-12 20:45:21

对我来说,查看路径上的内容的最简单方法是将其内容输出到浏览器控制台。

rule inspect_data_on_trail {
  select when pageview ".*"
  pre {
    visitedDomains = ent:visitedDomains;
  }
  {
    emit <|
      console.log(visitedDomains);
    |>;
  }
}

多次运行规则集后的 firebug 输出:

alt text

要清除包括路径在内的实体变量,我通常只编写一个选择的规则一个不属于我的应用程序体验的域,并在应用程序在该域上运行时清除变量。

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;
    }
  }

}

The easiest way, for me, to see what is on the trail is to output it's contents to the browser console.

rule inspect_data_on_trail {
  select when pageview ".*"
  pre {
    visitedDomains = ent:visitedDomains;
  }
  {
    emit <|
      console.log(visitedDomains);
    |>;
  }
}

firebug output after running ruleset several times:

alt text

To clear entity variables including trails, I usually just write a rule that selects on a domain that isn't part of my app's experience and clear the varaibles when the app is run on that domain.

rule clear_everything {
  select when pageview "yahoo\.com"
  {
    notify("Cleared",":)") with sticky = true;
  }
  fired {
    clear ent:visitedDomains;
  }
}

Full example app:

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;
    }
  }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文