Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion docs/integrations/matomo/matomo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import type { MatomoConfig } from "./config.ts";

declare global {
var _paq: Array<[string] | [string, string | number | boolean]>;
var _paq: Array<
[string] | [string, string | number | boolean] | [
string,
string,
string | number | boolean,
]
>;
var _mtm: Array<[string]>;
}

Expand Down
12 changes: 12 additions & 0 deletions docs/plugins/copy-page/components/CopyPage/CopyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
import "./CopyPage.css";
import { fetchMarkdown, getMarkdownUrl, getPromptUrl } from "./helpers.ts";

const ANALYTICS_EVENT_NAME = "CopyPage";

enum CopyStatus {
IDLE = "Copy Page",
COPIED = "Copied!",
Expand All @@ -26,6 +28,10 @@ export function CopyPage() {
const markdownUrl = React.useMemo(() => getMarkdownUrl(), []);

const handleCopyMarkdown = async () => {
if (!markdownUrl) {
return;
}

// The dev server doesn't serve markdown files,
// so this is supposed to fail in development.
try {
Expand All @@ -36,6 +42,12 @@ export function CopyPage() {

await navigator.clipboard.writeText(markdownContent);

globalThis._paq.push([
"trackEvent",
ANALYTICS_EVENT_NAME,
new URL(markdownUrl).pathname,
]);

setCopyStatus(CopyStatus.COPIED);
setTimeout(() => {
setCopyStatus(CopyStatus.IDLE);
Expand Down