Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/codeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import {RefObject, useEffect, useRef, useState} from 'react';
import {Clipboard} from 'react-feather';

import {usePlausibleEvent} from 'sentry-docs/hooks/usePlausibleEvent';

import styles from './code-blocks.module.scss';

import {makeHighlightBlocks} from '../codeHighlights';
Expand Down Expand Up @@ -47,6 +49,7 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
// Show the copy button after js has loaded
// otherwise the copy button will not work
const [showCopyButton, setShowCopyButton] = useState(false);
const {emit} = usePlausibleEvent();

useEffect(() => {
setShowCopyButton(true);
Expand Down Expand Up @@ -83,6 +86,7 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
try {
await navigator.clipboard.writeText(code);
setShowCopied(true);
emit('copy sentry code', {props: {page: window.location.pathname}});
setTimeout(() => setShowCopied(false), 1200);
} catch (error) {
// eslint-disable-next-line no-console
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/usePlausibleEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type PlausibleEventProps = {
page: string;
source: string;
};
['copy sentry code']: {
page: string;
};
};

/**
Expand Down
Loading