Skip to content

Commit 976a8e1

Browse files
committed
[PageOptions] Update analytics value
1 parent afb8cba commit 976a8e1

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/components/CopyPageButton.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
PiCheckCircleLight,
1717
PiXCircleLight,
1818
PiChatCircleLight,
19+
PiLinkLight,
1920
} from "react-icons/pi";
2021
import ClaudeIcon from "./icons/ClaudeIcon";
2122
import ChatGPTIcon from "./icons/ChatGPTIcon";
@@ -63,8 +64,7 @@ export default function CopyPageButton() {
6364
const indexMdUrl = new URL("index.md", window.location.href).toString();
6465
const prompt = `Read this page from the Cloudflare docs: ${encodeURIComponent(indexMdUrl)} and answer questions about the content.`;
6566
track("clicked copy page button", {
66-
value: "docs ai",
67-
label: vendor,
67+
value: `${vendor} ai`,
6868
});
6969
window.open(`${externalAIURL}${prompt}`, "_blank");
7070
};
@@ -100,7 +100,34 @@ export default function CopyPageButton() {
100100
}
101101
};
102102

103+
const handleCopyPageLink = async () => {
104+
try {
105+
await navigator.clipboard.writeText(window.location.href);
106+
track("clicked copy page button", {
107+
value: "copy page link",
108+
});
109+
110+
setCopyState("success");
111+
setTimeout(() => {
112+
setCopyState("idle");
113+
}, 1500);
114+
} catch (error) {
115+
console.error("Failed to copy page link:", error);
116+
117+
setCopyState("error");
118+
setTimeout(() => {
119+
setCopyState("idle");
120+
}, 1500);
121+
}
122+
};
123+
103124
const options = [
125+
{
126+
label: "Copy page link",
127+
description: "Copy the current page URL to clipboard",
128+
icon: PiLinkLight,
129+
onClick: handleCopyPageLink,
130+
},
104131
{
105132
label: "View Page as Markdown",
106133
description: "Open the Markdown file in a new tab",

0 commit comments

Comments
 (0)