Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Enhance TrackedButton component with target and rel attributes

Bill Yangf81125a093fb
diff --git a/docs/src/app/(home)/page.tsx b/docs/src/app/(home)/page.tsx
index 20c246b7f..83919bafa 100644
--- a/docs/src/app/(home)/page.tsx
+++ b/docs/src/app/(home)/page.tsx
@@ -154,6 +154,8 @@ export default function HomePage() {
<TrackedButton
href="https://demo.rybbit.com/21"
eventName="demo"
+ target="_blank"
+ rel="noopener noreferrer"
eventProps={{ location: "hero", button_text: "See live demo" }}
className="w-full whitespace-nowrap sm:w-auto bg-neutral-800 hover:bg-neutral-700 text-white font-medium px-5 py-3 rounded-lg border border-neutral-600 transform hover:-translate-y-0.5 transition-all duration-200 hover:border-neutral-400 focus:outline-none focus:ring-2 focus:ring-neutral-400 focus:ring-opacity-50 cursor-pointer"
>
diff --git a/docs/src/components/TrackedButton.tsx b/docs/src/components/TrackedButton.tsx
index 527b81129..3f589c73c 100644
--- a/docs/src/components/TrackedButton.tsx
+++ b/docs/src/components/TrackedButton.tsx
@@ -9,15 +9,19 @@ interface TrackedButtonProps {
eventProps: Record<string, string | number | boolean>;
className: string;
children: React.ReactNode;
+ target?: string;
+ rel?: string;
}
-export function TrackedButton({ href, eventName, eventProps, className, children }: TrackedButtonProps) {
+export function TrackedButton({ href, eventName, eventProps, className, children, target, rel }: TrackedButtonProps) {
return (
<Link
href={href}
className="w-full sm:w-auto"
data-rybbit-event={eventName}
data-rybbit-prop-location={eventProps.location}
+ target={target}
+ rel={rel}
>
<button onClick={() => trackAdEvent(eventName, eventProps)} className={className}>
{children}