Skip to content

Commit f7b2ecf

Browse files
add copy code plausible event for tracking (#14952)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR *Tell us what you're changing and why. If your PR **resolves an issue**, please link it so it closes automatically.* Adds "copy sentry code" plausible event to install code copies for better tracking/understanding how often they're used. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 249a672 commit f7b2ecf

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/components/codeBlock/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import {RefObject, useEffect, useRef, useState} from 'react';
44
import {Clipboard} from 'react-feather';
55

6+
import {usePlausibleEvent} from 'sentry-docs/hooks/usePlausibleEvent';
7+
68
import styles from './code-blocks.module.scss';
79

810
import {makeHighlightBlocks} from '../codeHighlights';
@@ -47,6 +49,7 @@ 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();
5053

5154
useEffect(() => {
5255
setShowCopyButton(true);
@@ -83,6 +86,7 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
8386
try {
8487
await navigator.clipboard.writeText(code);
8588
setShowCopied(true);
89+
emit('copy sentry code', {props: {page: window.location.pathname}});
8690
setTimeout(() => setShowCopied(false), 1200);
8791
} catch (error) {
8892
// eslint-disable-next-line no-console

src/hooks/usePlausibleEvent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ type PlausibleEventProps = {
3535
page: string;
3636
source: string;
3737
};
38+
['copy sentry code']: {
39+
page: string;
40+
};
3841
};
3942

4043
/**

0 commit comments

Comments
 (0)