Skip to content

Commit

Permalink
fix: safe event capturing & security options for window opening (#2556)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiryous authored Nov 20, 2024
1 parent a5a674e commit 108dee0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
18 changes: 13 additions & 5 deletions keep-ui/app/read-only-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import { Text, Button } from "@tremor/react";
import Image from "next/image";
import KeepPng from "../keep.png";
import posthog from "posthog-js";
import { capture } from "@/shared/lib/capture";

const ReadOnlyBanner = () => {
return (
Expand All @@ -23,10 +23,14 @@ const ReadOnlyBanner = () => {
<Button
className="[&>span]:text-xs"
onClick={() => {
posthog.capture("try-keep-for-free", {
capture("try-keep-for-free", {
source: "read-only-banner",
});
window.open("https://platform.keephq.dev/providers", "_blank");
window.open(
"https://platform.keephq.dev/providers",
"_blank",
"noopener,noreferrer"
);
}}
variant="primary"
color="orange"
Expand All @@ -37,10 +41,14 @@ const ReadOnlyBanner = () => {
<Button
className="[&>span]:text-xs"
onClick={() => {
posthog.capture("talk-to-us", {
capture("talk-to-us", {
source: "read-only-banner",
});
window.open("https://www.keephq.dev/meet-keep", "_blank");
window.open(
"https://www.keephq.dev/meet-keep",
"_blank",
"noopener,noreferrer"
);
}}
color="orange"
variant="secondary"
Expand Down
9 changes: 9 additions & 0 deletions keep-ui/shared/lib/capture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import posthog from "posthog-js";

export const capture = (event: string, properties?: Record<string, any>) => {
try {
posthog.capture(event, properties);
} catch (error) {
console.error("Error capturing event:", error);
}
};

0 comments on commit 108dee0

Please sign in to comment.