Skip to content

Commit 84910b9

Browse files
committed
feat: send content feedback plausible events
1 parent b5bb757 commit 84910b9

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use client';
2+
import {usePlausibleEvent} from 'sentry-docs/hooks/usePlausibleEvent';
3+
4+
type Props = {
5+
pathname: string;
6+
};
7+
8+
export function DocFeedback({pathname}: Props) {
9+
const {emit} = usePlausibleEvent();
10+
11+
const handleFeedback = (helpful: boolean) => {
12+
emit('Doc Feedback', {props: {page: pathname, helpful}});
13+
};
14+
15+
return (
16+
<div className="flex items-center gap-2 py-4 border-t border-[var(--gray-6)]">
17+
<span className="text-sm">Was this helpful?</span>
18+
<button
19+
onClick={() => handleFeedback(true)}
20+
className="w-10 h-10 py-2 px-2 hover:bg-[var(--gray-3)] rounded-full flex items-center justify-center"
21+
aria-label="Yes, this was helpful"
22+
>
23+
👍
24+
</button>
25+
<button
26+
onClick={() => handleFeedback(false)}
27+
className="w-10 h-10 py-2 px-2 hover:bg-[var(--gray-3)] rounded-full flex items-center justify-center"
28+
aria-label="No, this wasn't helpful"
29+
>
30+
👎
31+
</button>
32+
</div>
33+
);
34+
}

src/components/docPage/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import './type.scss';
1212
import {Banner} from '../banner';
1313
import {Breadcrumbs} from '../breadcrumbs';
1414
import {CodeContextProvider} from '../codeContext';
15+
import {DocFeedback} from '../docFeedback';
1516
import {GitHubCTA} from '../githubCTA';
1617
import {Header} from '../header';
1718
import Mermaid from '../mermaid';
@@ -91,6 +92,8 @@ export function DocPage({
9192
<CodeContextProvider>{children}</CodeContextProvider>
9293
</div>
9394

95+
<DocFeedback pathname={pathname} />
96+
9497
<div className="grid grid-cols-2 gap-4 not-prose mt-16">
9598
<div className="col-span-1">
9699
{previousPage && <PaginationNav node={previousPage} title="Previous" />}

src/hooks/usePlausibleEvent.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import {ReadProgressMilestone} from 'sentry-docs/types/plausible';
44

55
// Adding custom events here will make them available via the hook
66
type PlausibleEventProps = {
7+
['Doc Feedback']: {
8+
helpful: boolean;
9+
page: string;
10+
};
711
['Read Progress']: {
812
page: string;
913
readProgress: ReadProgressMilestone;

0 commit comments

Comments
 (0)