Skip to content

Commit ebdb109

Browse files
committed
Replace Hotjar with GA buttons
1 parent a2138f2 commit ebdb109

5 files changed

Lines changed: 36 additions & 64 deletions

File tree

beta/.env.development

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
NEXT_PUBLIC_HJ_SITE_ID = 2411683
2-
NEXT_PUBLIC_HJ_SITE_V = 6

beta/.env.production

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
NEXT_PUBLIC_HJ_SITE_ID = 2411651
2-
NEXT_PUBLIC_HJ_SITE_V = 6
31
NEXT_PUBLIC_GA_TRACKING_ID = 'G-3918VS75Y6'

beta/src/components/Layout/Sidebar/Sidebar.tsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ export function Sidebar({isMobileOnly}: {isMobileOnly?: boolean}) {
2525
routeTree = (routeTree as any).routes[0];
2626
}
2727

28-
function handleFeedback() {
29-
const nodes: any = document.querySelectorAll(
30-
'#_hj_feedback_container button'
31-
);
32-
if (nodes.length > 0) {
33-
nodes[nodes.length - 1].click();
34-
} else {
35-
window.location.href =
36-
'https://github.com/reactjs/reactjs.org/issues/3308';
37-
}
38-
}
3928
const feedbackIcon = (
4029
<svg
4130
xmlns="http://www.w3.org/2000/svg"
@@ -80,12 +69,28 @@ export function Sidebar({isMobileOnly}: {isMobileOnly?: boolean}) {
8069
<SidebarRouteTree routeTree={routeTree} />
8170
)}
8271
</nav>
83-
<div className="px-5 py-3 sticky bottom-0 lg:px-5 w-full hidden lg:flex items-center bg-gradient-to-t from-wash dark:from-wash-dark">
84-
<Button
85-
className="w-full text-center justify-center"
86-
onClick={handleFeedback}>
87-
{feedbackIcon} Feedback
88-
</Button>
72+
<div className="px-5 py-3 sticky bottom-0 lg:px-5 w-full hidden lg:flex bg-gradient-to-t from-wash dark:from-wash-dark">
73+
<p>Is this page useful?</p>
74+
<button
75+
onClick={() => {
76+
gtag('event', 'feedback', {
77+
event_category: 'button',
78+
event_label: window.location.pathname,
79+
value: 1,
80+
});
81+
}}>
82+
Yes
83+
</button>
84+
<button
85+
onClick={() => {
86+
gtag('event', 'feedback', {
87+
event_category: 'button',
88+
event_label: window.location.pathname,
89+
value: 0,
90+
});
91+
}}>
92+
No
93+
</button>
8994
</div>
9095
</aside>
9196
);

beta/src/pages/_app.tsx

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ import '../styles/sandpack.css';
1212
import '@codesandbox/sandpack-react/dist/index.css';
1313
import Script from 'next/script';
1414

15-
import {hotjar} from 'utils/hotjar';
16-
if (typeof window !== 'undefined') {
17-
hotjar(process.env.NEXT_PUBLIC_HJ_SITE_ID, process.env.NEXT_PUBLIC_HJ_SITE_V);
18-
}
19-
2015
const EmptyAppShell: React.FC = ({children}) => <>{children}</>;
2116

2217
export default function MyApp({Component, pageProps}: AppProps) {
@@ -31,23 +26,21 @@ export default function MyApp({Component, pageProps}: AppProps) {
3126
<AppShell>
3227
<Component {...pageProps} />
3328
{process.env.NODE_ENV === 'production' && (
34-
<>
35-
<Script
36-
strategy="lazyOnload"
37-
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_TRACKING_ID}`}
38-
/>
39-
<Script id="google-analytics" strategy="lazyOnload">
40-
{`
41-
window.dataLayer = window.dataLayer || [];
42-
function gtag(){dataLayer.push(arguments);}
43-
gtag('js', new Date());
44-
gtag('config', '${process.env.NEXT_PUBLIC_GA_TRACKING_ID}', {
45-
page_path: window.location.pathname,
46-
});
47-
`}
48-
</Script>
49-
</>
29+
<Script
30+
strategy="lazyOnload"
31+
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_TRACKING_ID}`}
32+
/>
5033
)}
34+
<Script id="google-analytics" strategy="lazyOnload">
35+
{`
36+
window.dataLayer = window.dataLayer || [];
37+
function gtag(){dataLayer.push(arguments);}
38+
gtag('js', new Date());
39+
gtag('config', '${process.env.NEXT_PUBLIC_GA_TRACKING_ID}', {
40+
page_path: window.location.pathname,
41+
});
42+
`}
43+
</Script>
5144
</AppShell>
5245
);
5346
}

beta/src/utils/hotjar.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)