我需要像这样设置here it says,如果我想在gatsby中使用它:
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-plugin-hotjar`,
options: {
id: YOUR_HOTJAR_ID,
sv: YOUR_HOTJAR_SNIPPET_VERSION
},
},
]我现在的新手问题是:我可以直接粘贴id / snippet版本到那里吗?或者我必须担心安全问题,应该使用环境变量等?
发布于 2019-11-17 06:17:50
您可以直接将它们粘贴到那里。
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
任何一个实现都将被任何查看你网站源代码的人看到。
https://stackoverflow.com/questions/58117558
复制相似问题