Skip to content

Commit

Permalink
feat: setup in-app clarity tracker (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
elcharitas authored Jan 19, 2024
1 parent aa75bda commit 7089560
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jobs:
VITE_FIRE_MESSAGE_SENDER_ID: ${{ secrets.DEV__REACT_APP_FIRE_MESSAGE_SENDER_ID }}
VITE_FIRE_APP_ID: ${{ secrets.DEV__REACT_APP_FIRE_APP_ID }}
VITE_SENTRY_DSN: ${{ secrets.PROD__VITE_SENTRY_DSN }}
VITE_CLARITY_PROJECT_ID: ${{ secrets.DEV__REACT_APP_CLARITY_PROJECT_ID }}

NODE_OPTIONS: "--max_old_space_size=4096"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-epsilon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
VITE_FIRE_MESSAGE_SENDER_ID: ${{ secrets.DEV__REACT_APP_FIRE_MESSAGE_SENDER_ID }}
VITE_FIRE_APP_ID: ${{ secrets.DEV__REACT_APP_FIRE_APP_ID }}
VITE_SENTRY_DSN: ${{ secrets.PROD__VITE_SENTRY_DSN }}
VITE_CLARITY_PROJECT_ID: ${{ secrets.DEV__REACT_APP_CLARITY_PROJECT_ID }}

NODE_OPTIONS: "--max_old_space_size=4096"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
VITE_FIRE_MESSAGE_SENDER_ID: ${{ secrets.PROD__REACT_APP_FIRE_MESSAGE_SENDER_ID }}
VITE_FIRE_APP_ID: ${{ secrets.PROD__REACT_APP_FIRE_APP_ID }}
VITE_SENTRY_DSN: ${{ secrets.PROD__VITE_SENTRY_DSN }}
VITE_CLARITY_PROJECT_ID: ${{ secrets.PROD__VITE_CLARITY_PROJECT_ID }}

NODE_OPTIONS: "--max_old_space_size=4096"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
VITE_FIRE_MESSAGE_SENDER_ID: ${{ secrets.STAGING__REACT_APP_FIRE_MESSAGE_SENDER_ID }}
VITE_FIRE_APP_ID: ${{ secrets.STAGING__REACT_APP_FIRE_APP_ID }}
VITE_SENTRY_DSN: ${{ secrets.PROD__VITE_SENTRY_DSN }}
VITE_CLARITY_PROJECT_ID: ${{ secrets.STAGING__VITE_CLARITY_PROJECT_ID }}

NODE_OPTIONS: "--max_old_space_size=4096"

Expand Down
1 change: 1 addition & 0 deletions packages/frontend/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ VITE_SWAP_FEE_ADDRESS=0x038C5e782FcE70C5CAf39b0Ba2Afe211F34f0bC5

VITE_GA_MEASUREMENT_ID=G-ZT80HRR0MD
VITE_SENTRY_DSN=https://[email protected]/0
VITE_CLARITY_PROJECT_ID=X

VITE_HOTJAR_SITE_ID=X
VITE_HOTJAR_SNIPPET_VERSION=6
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"react-hot-toast": "2.4.1",
"react-laag": "2.0.5",
"react-markdown": "8.0.7",
"react-microsoft-clarity": "1.2.0",
"react-redux": "8.0.2",
"react-router": "5.3.4",
"react-router-dom": "5.3.4",
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ const SENTRY = {
ENABLE: true,
};

const CLARITY = {
ENABLE: !!import.meta.env.VITE_CLARITY_PROJECT_ID,
PROJECT_ID: import.meta.env.VITE_CLARITY_PROJECT_ID,
};

const COOKIES = {
// in these, a "reject all" option will be included
STRICT_COUNTRY_LIST: ["DE", "FR", "UK", "IE"],
Expand All @@ -73,6 +78,7 @@ const CONFIG = {
SEO: SEO_CONFIG,
FIREBASE: FIREBASE_CONFIG,
SENTRY,
CLARITY,
COOKIES,
API_PROVIDERS,
NUMBERS,
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "./polyfills";
import * as Sentry from "@sentry/react";
import { BrowserTracing } from "@sentry/tracing";
import { createRoot } from "react-dom/client";
import { clarity } from "react-microsoft-clarity";
import { Provider } from "react-redux";
import { WagmiConfig } from "wagmi";
import { useIsMobile } from "./api/hooks/useIsMobile";
Expand Down Expand Up @@ -56,6 +57,13 @@ try {
);
}

if (CONFIG.CLARITY.ENABLE) {
Logger.debug("initializing clarity...");
clarity.init(CONFIG.CLARITY.PROJECT_ID);
clarity.consent();
Logger.debug("clarity initialized");
}

const AppSwitcher = () => {
const isMobile = useIsMobile();
return isMobile ? <MobileApp /> : <App />;
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14595,6 +14595,11 @@ [email protected]:
unist-util-visit "^4.0.0"
vfile "^5.0.0"

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/react-microsoft-clarity/-/react-microsoft-clarity-1.2.0.tgz#949f953cec4d4f9d7b4eaab01c240dfa48fb44c8"
integrity sha512-a1bsJR1uN1daWq3cBc7NheEGPXrotMRE0oFeRio7kXvHawzQfqu5iX9BoYFF9zRUL0dn+Mz57h1fNlcv3pqXEg==

react-popper@^2.2.3:
version "2.3.0"
resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-2.3.0.tgz#17891c620e1320dce318bad9fede46a5f71c70ba"
Expand Down

0 comments on commit 7089560

Please sign in to comment.