Skip to content

Commit cea979d

Browse files
authored
prevent posthog error during development (#177)
1 parent 11fdcbc commit cea979d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/theme/CodeBlock/CopyButton/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export default function CopyButton({ code, className }: Props): JSX.Element {
1515
const handleCopyCode = useCallback(() => {
1616
copy(code)
1717
setIsCopied(true)
18-
window.posthog.capture("snippet_copied")
18+
if (window.posthog) {
19+
window.posthog.capture("snippet_copied")
20+
}
1921
copyTimeout.current = window.setTimeout(() => {
2022
setIsCopied(false)
2123
}, 1000)

0 commit comments

Comments
 (0)