OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix: checkout
Carl-Gerhard Lindesvärd21fc07636830
diff --git a/apps/api/src/controllers/webhook.controller.ts b/apps/api/src/controllers/webhook.controller.tsindex 36785c449..c2e1c4321 100644--- a/apps/api/src/controllers/webhook.controller.ts+++ b/apps/api/src/controllers/webhook.controller.ts@@ -27,7 +27,6 @@ const paramsSchema = z.object({const metadataSchema = z.object({organizationId: z.string(),- projectId: z.string(),integrationId: z.string(),});@@ -89,7 +88,7 @@ export async function slackWebhook('👋 Hello. You have successfully connected OpenPanel.dev to your Slack workspace.',});- const { projectId, organizationId, integrationId } = parsedMetadata.data;+ const { organizationId, integrationId } = parsedMetadata.data;await db.integration.update({where: {@@ -105,7 +104,7 @@ export async function slackWebhook(});return reply.redirect(- `${process.env.DASHBOARD_URL || process.env.NEXT_PUBLIC_DASHBOARD_URL}/${organizationId}/${projectId}/settings/integrations?tab=installed`,+ `${process.env.DASHBOARD_URL || process.env.NEXT_PUBLIC_DASHBOARD_URL}/${organizationId}/integrations/installed`,);} catch (err) {request.log.error(err);diff --git a/apps/start/src/components/organization/billing.tsx b/apps/start/src/components/organization/billing.tsxindex c817f99b9..c41431587 100644--- a/apps/start/src/components/organization/billing.tsx+++ b/apps/start/src/components/organization/billing.tsx@@ -29,7 +29,6 @@ type Props = {};export default function Billing({ organization }: Props) {- const { projectId } = useAppParams();const queryClient = useQueryClient();const trpc = useTRPC();const [customerSessionToken, setCustomerSessionToken] = useQueryState(@@ -271,7 +270,6 @@ export default function Billing({ organization }: Props) {key={selectedProduct.prices[0].id}price={selectedProduct.prices[0]}organization={organization}- projectId={projectId}buttonText={isUpgrade? 'Upgrade'@@ -350,13 +348,11 @@ export default function Billing({ organization }: Props) {function CheckoutButton({price,organization,- projectId,disabled,buttonText,}: {price: IPolarPrice;organization: IServiceOrganization;- projectId: string;disabled?: string | null;buttonText?: string;}) {@@ -396,7 +392,6 @@ function CheckoutButton({onClick={() => {const createCheckout = () =>checkout.mutate({- projectId,organizationId: organization.id,productPriceId: price!.id,productId: price.productId,diff --git a/packages/db/src/services/project.service.ts b/packages/db/src/services/project.service.tsindex ab5fded4b..f13b8a4ae 100644--- a/packages/db/src/services/project.service.ts+++ b/packages/db/src/services/project.service.ts@@ -28,7 +28,7 @@ export async function getProjectById(id: string) {export const getProjectByIdCached = cacheable(getProjectById, 60 * 60 * 24);export async function getProjectWithClients(id: string) {- const res = await db.project.findUnique({+ const res = await db.$primary().project.findUnique({where: {id,},diff --git a/packages/payments/src/polar.ts b/packages/payments/src/polar.tsindex 854c16db1..872edea79 100644--- a/packages/payments/src/polar.ts+++ b/packages/payments/src/polar.ts@@ -13,14 +13,8 @@ export const polar = new Polar({server: process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',});-export const getSuccessUrl = (- baseUrl: string,- organizationId: string,- projectId?: string,-) =>- projectId- ? `${baseUrl}/${organizationId}/${projectId}/settings?tab=billing`- : `${baseUrl}/${organizationId}`;+export const getSuccessUrl = (baseUrl: string, organizationId: string) =>+ `${baseUrl}/${organizationId}/billing`;export async function getProducts() {const products = await polar.products.list({@@ -52,13 +46,11 @@ export async function createPortal({export async function createCheckout({productId,organizationId,- projectId,user,ipAddress,}: {productId: string;organizationId: string;- projectId?: string;user: {id: string;firstName: string | null;@@ -73,7 +65,6 @@ export async function createCheckout({successUrl: getSuccessUrl(process.env.DASHBOARD_URL || process.env.NEXT_PUBLIC_DASHBOARD_URL!,organizationId,- projectId,),customerEmail: user.email,customerName: [user.firstName, user.lastName].filter(Boolean).join(' '),diff --git a/packages/trpc/src/routers/subscription.ts b/packages/trpc/src/routers/subscription.tsindex 4c3e38e4c..792c55a32 100644--- a/packages/trpc/src/routers/subscription.ts+++ b/packages/trpc/src/routers/subscription.ts@@ -77,7 +77,6 @@ export const subscriptionRouter = createTRPCRouter({const checkout = await createCheckout({productId: input.productId,organizationId: input.organizationId,- projectId: input.projectId ?? undefined,user,ipAddress: ctx.req.ip,});