Skip to content

Commit 9401a7f

Browse files
add copy code plausible event for tracking
1 parent c9e1888 commit 9401a7f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/components/codeBlock/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import styles from './code-blocks.module.scss';
77

88
import {makeHighlightBlocks} from '../codeHighlights';
99
import {makeKeywordsClickable} from '../codeKeywords';
10+
import {usePlausibleEvent} from 'sentry-docs/hooks/usePlausibleEvent';
11+
1012

1113
export interface CodeBlockProps {
1214
children: React.ReactNode;
@@ -47,6 +49,8 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
4749
// Show the copy button after js has loaded
4850
// otherwise the copy button will not work
4951
const [showCopyButton, setShowCopyButton] = useState(false);
52+
const {emit} = usePlausibleEvent();
53+
5054

5155
useEffect(() => {
5256
setShowCopyButton(true);
@@ -83,6 +87,7 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
8387
try {
8488
await navigator.clipboard.writeText(code);
8589
setShowCopied(true);
90+
emit('copy sentry code', {props: {page: window.location.pathname}});
8691
setTimeout(() => setShowCopied(false), 1200);
8792
} catch (error) {
8893
// eslint-disable-next-line no-console

src/components/codeTabs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {KEYWORDS_REGEX, ORG_AUTH_TOKEN_REGEX} from './codeKeywords';
1717
import {updateElementsVisibilityForOptions} from './onboarding';
1818
import {SignInNote} from './signInNote';
1919

20+
2021
// human readable versions of names
2122
const HUMAN_LANGUAGE_NAMES = {
2223
coffee: 'CoffeeScript',

0 commit comments

Comments
 (0)