gpt4 book ai didi

javascript - Gatsby + Hotjar : Env variables for Hotjar-Id & Hotjar-Snippet Version?

转载 作者:行者123 更新时间:2023-12-05 03:58:16 27 4
gpt4 key购买 nike

here it says如果我想将它与 gatsby 一起使用,我需要像这样设置 hotjar:

// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-hotjar`,
options: {
id: YOUR_HOTJAR_ID,
sv: YOUR_HOTJAR_SNIPPET_VERSION
},
},
]

我现在的新手问题是:我可以直接把id/snippet version 粘贴进去吗?还是我必须担心安全问题并且应该使用环境变量等?

最佳答案

您可以直接将它们粘贴到那里。

Hotjar 说明提到将此代码段添加到每个页面的顶部

<script>
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:99999999999999,hjsv:00000000000000};
// ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
// SITE ID SNIPPET VERSION

a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>

这个插件在做同样的事情,在这里:https://github.com/pavloko/gatsby-plugin-hotjar/blob/d30edfe1bf56b98feb819310d3a16d3d30118793/src/gatsby-ssr.js#L13

查看您网站源代码的任何人都可以看到任何一种实现方式。

关于javascript - Gatsby + Hotjar : Env variables for Hotjar-Id & Hotjar-Snippet Version?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58117558/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com