Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: safe event capturing & security options for window opening #2556

Merged
merged 1 commit into from
Nov 20, 2024
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
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";
talboren marked this conversation as resolved.
Show resolved Hide resolved

export const capture = (event: string, properties?: Record<string, any>) => {
try {
posthog.capture(event, properties);
} catch (error) {
console.error("Error capturing event:", error);
}
talboren marked this conversation as resolved.
Show resolved Hide resolved
};
Loading