fix: self-hosting

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-10-22 11:56:27 +02:00
parent 42d0fb8572
commit 49a4f5b8ae
7 changed files with 25 additions and 13 deletions

View File

@@ -18,12 +18,7 @@ type Props = {
onVerified: (verified: boolean) => void;
};
const VerifyListener = ({
client,
events: _events,
onVerified,
project,
}: Props) => {
const VerifyListener = ({ client, events: _events, onVerified }: Props) => {
const [events, setEvents] = useState<IServiceEvent[]>(_events ?? []);
useWS<IServiceEvent>(
`/live/events/${client?.projectId}?type=received`,

View File

@@ -130,10 +130,10 @@ export function SidebarContainer({
>
{children}
<div className="mt-auto w-full ">
<div className="mt-auto w-full pt-6">
<FeedbackButton />
{isSelfHosted && (
<div className={cn('text-sm w-full text-center')}>
<div className={cn('text-sm w-full text-left mt-2')}>
Self-hosted instance
</div>
)}

View File

@@ -5,7 +5,11 @@ export function useAppContext() {
strict: false,
});
if (!params.apiUrl || !params.dashboardUrl || !params.isSelfHosted) {
if (
!params.apiUrl ||
!params.dashboardUrl ||
typeof params.isSelfHosted === 'undefined'
) {
throw new Error('API URL or dashboard URL is not set');
}

View File

@@ -2,6 +2,7 @@ import {
HeadContent,
Scripts,
createRootRouteWithContext,
useRouteContext,
} from '@tanstack/react-router';
import 'flag-icons/css/flag-icons.min.css';
@@ -23,7 +24,9 @@ import { op } from '@/utils/op';
import type { AppRouter } from '@openpanel/trpc';
import type { TRPCOptionsProxy } from '@trpc/tanstack-react-query';
op.init();
if (import.meta.env.VITE_OP_CLIENT_ID) {
op.init();
}
interface MyRouterContext {
queryClient: QueryClient;

View File

@@ -10,6 +10,7 @@ import { PAGE_TITLES, createEntityTitle } from '@/utils/title';
import { useQuery } from '@tanstack/react-query';
import { Link, createFileRoute, redirect } from '@tanstack/react-router';
import { BoxSelectIcon } from 'lucide-react';
import { useEffect, useState } from 'react';
export const Route = createFileRoute('/_steps/onboarding/$projectId/verify')({
head: () => ({
@@ -32,6 +33,7 @@ export const Route = createFileRoute('/_steps/onboarding/$projectId/verify')({
});
function Component() {
const [isVerified, setIsVerified] = useState(false);
const { projectId } = Route.useParams();
const trpc = useTRPC();
const { data: events, refetch } = useQuery(
@@ -41,7 +43,11 @@ function Component() {
trpc.project.getProjectWithClients.queryOptions({ projectId }),
);
const isVerified = events && events.data.length > 0;
useEffect(() => {
if (events && events.data.length > 0) {
setIsVerified(true);
}
}, [events]);
if (!project) {
return (
@@ -60,7 +66,10 @@ function Component() {
project={project}
client={client}
events={events?.data ?? []}
onVerified={() => refetch()}
onVerified={() => {
refetch();
setIsVerified(true);
}}
/>
<CurlPreview project={project} />

View File

@@ -1,7 +1,7 @@
import { OpenPanel } from '@openpanel/web';
export const op = new OpenPanel({
clientId: '301c6dc1-424c-4bc3-9886-a8beab09b615',
clientId: import.meta.env.VITE_OP_CLIENT_ID,
trackScreenViews: true,
trackOutgoingLinks: true,
trackAttributes: true,

View File

@@ -12,6 +12,7 @@
}
],
"vars": {
"VITE_OP_CLIENT_ID": "301c6dc1-424c-4bc3-9886-a8beab09b615",
"API_URL": "https://api.openpanel.dev",
"DASHBOARD_URL": "https://dashboard.openpanel.dev",
"NODE_ENV": "production",