Skip to content

Commit

Permalink
chore: send posthog version (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Dec 13, 2023
1 parent addf526 commit 4c7af79
Show file tree
Hide file tree
Showing 17 changed files with 1,411 additions and 1,396 deletions.
1 change: 1 addition & 0 deletions docker-compose-with-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- NEXT_PUBLIC_PUSHER_HOST=localhost
- NEXT_PUBLIC_PUSHER_PORT=6001
- NEXT_PUBLIC_PUSHER_APP_KEY=keepappkey
- NEXT_PUBLIC_KEEP_VERSION=0.2.9
volumes:
- ./state:/state
depends_on:
Expand Down
1 change: 1 addition & 0 deletions docker-compose-with-otel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ services:
- NEXT_PUBLIC_PUSHER_HOST=keep-websocket-server
- NEXT_PUBLIC_PUSHER_PORT=6001
- NEXT_PUBLIC_PUSHER_APP_KEY=keepappkey
- NEXT_PUBLIC_KEEP_VERSION=0.2.9
volumes:
- ./keep/keep-ui:/app
- /app/node_modules
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- NEXT_PUBLIC_PUSHER_HOST=localhost
- NEXT_PUBLIC_PUSHER_PORT=6001
- NEXT_PUBLIC_PUSHER_APP_KEY=keepappkey
- NEXT_PUBLIC_KEEP_VERSION=0.2.9
volumes:
- ./keep-ui:/app
- /app/node_modules
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- NEXT_PUBLIC_PUSHER_HOST=localhost
- NEXT_PUBLIC_PUSHER_PORT=6001
- NEXT_PUBLIC_PUSHER_APP_KEY=keepappkey
- NEXT_PUBLIC_KEEP_VERSION=0.2.9
volumes:
- ./state:/state
depends_on:
Expand Down
14 changes: 10 additions & 4 deletions keep-ui/app/alerts/alert-presets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,13 @@ export default function AlertPresets({
icon={PlusIcon}
size="xs"
color="orange"
title="Create preset"
className="ml-2.5"
disabled={selectedOptions.length <= 0}
onClick={async () => await addOrUpdatePreset()}
/>
tooltip="Save current filter as a view"
>
Create Preset
</Button>
)}
{preset?.name !== "Deleted" && preset?.name !== "Feed" && (
<div className="flex ml-2.5">
Expand All @@ -245,7 +247,9 @@ export default function AlertPresets({
className="mr-1"
disabled={selectedOptions.length <= 0}
onClick={async () => await addOrUpdatePreset()}
/>
>
Save Preset
</Button>
<Button
icon={TrashIcon}
size="xs"
Expand All @@ -255,7 +259,9 @@ export default function AlertPresets({
onClick={async () => {
await deletePreset(preset!.id!);
}}
/>
>
Delete Preset
</Button>
</div>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions keep-ui/app/alerts/alerts.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default function AlertsPage() {
data: configData,
error,
isLoading,
} = useSWR<InternalConfig>("/api/config", fetcher);
} = useSWR<InternalConfig>("/api/config", fetcher, undefined);
const [pusherClient, setPusherClient] = useState<Pusher | null>(null);
const router = useRouter();
const pusherDisabled = configData?.PUSHER_DISABLED === true
const pusherDisabled = configData?.PUSHER_DISABLED === true;

useEffect(() => {
if (
Expand Down
2 changes: 1 addition & 1 deletion keep-ui/app/alerts/alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default function Alerts({
groupBy="fingerprint"
workflows={workflows}
providers={providers?.installed_providers}
mutate={() => mutate(null, { optimisticData: [] })}
mutate={() => mutate(undefined, { optimisticData: [] })}
isAsyncLoading={isAsyncLoading}
onDelete={onDelete}
setAssignee={setAssignee}
Expand Down
6 changes: 5 additions & 1 deletion keep-ui/app/navbar-inner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ const GnipLogo = (props: any) => (

export default function NavbarInner({ user }: { user?: User }) {
const pathname = usePathname();
const { data: configData } = useSWR<InternalConfig>("/api/config", fetcher);
const { data: configData } = useSWR<InternalConfig>(
"/api/config",
fetcher,
undefined
);
const [imageError, setImageError] = useState(false);

// Determine runtime configuration
Expand Down
73 changes: 35 additions & 38 deletions keep-ui/app/posthog-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// app/posthog.tsx
// took this from https://posthog.com/tutorials/nextjs-app-directory-analytics
'use client'
import React from 'react';
import posthog from 'posthog-js';
import { PostHogProvider } from 'posthog-js/react';
"use client";
import React from "react";
import posthog from "posthog-js";
import { PostHogProvider } from "posthog-js/react";
import { usePathname, useSearchParams } from "next/navigation";
import { useEffect } from "react";
import { useSession } from "next-auth/react"
import { NoAuthUserEmail } from "utils/authenticationType";
import { useSession } from "next-auth/react";
import { NoAuthUserEmail } from "utils/authenticationType";



if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
if (typeof window !== "undefined" && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
});
Expand All @@ -22,37 +20,36 @@ interface PHProviderProps {
}

const PHProvider: React.FC<PHProviderProps> = ({ children }) => {
const pathname = usePathname();
const searchParams = useSearchParams();
const { data: session, status, update } = useSession();
const pathname = usePathname();
const searchParams = useSearchParams();
const { data: session } = useSession();
useEffect(() => {
const user = session?.user;
useEffect(() => {
const fetchData = () => {

if (pathname && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
let url = window.origin + pathname;
if (searchParams?.toString()) {
url = url + `?${searchParams.toString()}`;
}
const posthog_id = user?.email;
console.log("PostHog ID: " + posthog_id);
if(posthog_id && posthog_id !== NoAuthUserEmail) {
console.log("Identifying user in PostHog")
posthog.identify(posthog_id);
}
console.log("Sending pageview event to PostHog");
posthog.capture(
'$pageview',
{
'$current_url': url,
}
);
console.log("Event sent to PostHog");
}
const fetchData = () => {
if (
pathname &&
process.env.NEXT_PUBLIC_POSTHOG_KEY &&
process.env.POSTHOG_DISABLED !== "true" &&
process.env.NEXT_PUBLIC_POSTHOG_DISABLED !== "true"
) {
let url = window.origin + pathname;
if (searchParams?.toString()) {
url = url + `?${searchParams.toString()}`;
}
const posthog_id = user?.email;
if (posthog_id && posthog_id !== NoAuthUserEmail) {
console.log("Identifying user in PostHog");
posthog.identify(posthog_id);
}
posthog.capture("$pageview", {
$current_url: url,
keep_version: process.env.NEXT_PUBLIC_KEEP_VERSION ?? "unknown",
});
}
fetchData();
}, [pathname, searchParams, session, status]);
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
};
fetchData();
}, [pathname, searchParams, session]);
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
};

export default PHProvider;
2 changes: 1 addition & 1 deletion keep-ui/app/providers/provider-semi-automated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ProviderSemiAutomated = ({ provider, accessToken }: Props) => {
const apiUrl = getApiURL();
const { data, error, isLoading } = useSWR<WebhookSettings>(
`${apiUrl}/providers/${provider.type}/webhook`,
(url) => fetcher(url, accessToken)
(url: string) => fetcher(url, accessToken)
);

if (isLoading) return <div>Loading...</div>;
Expand Down
10 changes: 6 additions & 4 deletions keep-ui/app/settings/webhook-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,22 @@ export default function WebhookSettings({ accessToken, selectedTab }: Props) {
<div className="flex justify-between">
<Icon variant="light" icon={GlobeAltIcon} size="lg" color="orange" />
<Button
variant="light"
variant="primary"
icon={PlayIcon}
color="orange"
onClick={tryNow}
>
Try now
</Button>
</div>
<div className="flex">
<div className="w-3/5">
<div className="flex divide-x">
<div className="w-4/5 mr-1">
<Title className="mt-6">URL: {data?.webhookApi}</Title>
<Subtitle className="mt-2">API Key: {data?.apiKey}</Subtitle>
</div>
<CopyBlock {...copyBlockProps} />
<div className="w-full">
<CopyBlock {...copyBlockProps} />
</div>
</div>
</Card>
</div>
Expand Down
2 changes: 1 addition & 1 deletion keep-ui/app/workflows/[workflow_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function WorkflowDetailPage({
status === "authenticated"
? `${apiUrl}/workflows/${params.workflow_id}`
: null,
(url) => fetcher(url, session?.accessToken!)
(url: string) => fetcher(url, session?.accessToken!)
);

if (isLoading || !data) return <Loading />;
Expand Down
2 changes: 1 addition & 1 deletion keep-ui/app/workflows/workflows.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function WorkflowsPage() {
// Only fetch data when the user is authenticated
const { data, error, isLoading } = useSWR<Workflow[]>(
status === "authenticated" ? `${apiUrl}/workflows` : null,
(url) => fetcher(url, session?.accessToken!)
(url: string) => fetcher(url, session?.accessToken!)
);

if (isLoading || !data) return <Loading />;
Expand Down
Loading

1 comment on commit 4c7af79

@vercel
Copy link

@vercel vercel bot commented on 4c7af79 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

keep – ./

keep-eight.vercel.app
keep-git-main-keephq.vercel.app
keep-keephq.vercel.app
platform.keephq.dev

Please sign in to comment.