Skip to content

Commit

Permalink
fix: production only analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
veryCrunchy committed Mar 9, 2024
1 parent 718d13c commit 11d19c6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default defineNuxtConfig({
public: {
apiBase: process.env.API_BASE,
callbackUrl: process.env.CALLBACK_URL,
env: process.env.NODE_ENV || "development",
branch: process.env.CONTENT_BRANCH ?? "main",
},
},
Expand Down
3 changes: 0 additions & 3 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { GqlGetContent } from "#gql";
const buttons = [
{
icon: { name: "discord", type: "fab" },
Expand Down Expand Up @@ -120,7 +118,6 @@ try {
}"
>
<NuxtImg

src="/mac/babe.png"
class="w-full h-full object-cover rounded-xl"
></NuxtImg>
Expand Down
5 changes: 3 additions & 2 deletions plugins/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export default defineNuxtPlugin(() => {
const production = useRuntimeConfig().public.env === "production";
addRouteMiddleware(
"clarity",
() => {
if (process.client) {
if (process.client && production) {
const script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML = `(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window, document, "clarity", "script", "lamwpyz0kn");`;
Expand All @@ -14,7 +15,7 @@ export default defineNuxtPlugin(() => {
addRouteMiddleware(
"google",
() => {
if (process.client) {
if (process.client && production) {
const gtag = document.createElement("script");
gtag.async = true;
gtag.src = "https://www.googletagmanager.com/gtag/js?id=G-PVTY71FRX0";
Expand Down

0 comments on commit 11d19c6

Please sign in to comment.