Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat: tracking events on trpc and api (#1136)
Maximilian Kaske832b3a2bed2b
diff --git a/apps/server/.env.example b/apps/server/.env.exampleindex 00d498551..89773de5e 100644--- a/apps/server/.env.example+++ b/apps/server/.env.example@@ -11,3 +11,6 @@ TWILLIO_ACCOUNT_ID=your_account_idSCREENSHOT_SERVICE_URL=http://your.endpointQSTASH_TOKEN=your_token++OPENPANEL_CLIENT_ID=+OPENPANEL_CLIENT_SECRET=\ No newline at end of filediff --git a/apps/server/.env.test b/apps/server/.env.testindex a0dace1a2..dfc6ddf67 100644--- a/apps/server/.env.test+++ b/apps/server/.env.test@@ -11,3 +11,5 @@ FLY_REGION=amsRESEND_API_KEY=testSQLD_HTTP_AUTH=basic:tokenSCREENSHOT_SERVICE_URL=http://your.endpoint+OPENPANEL_CLIENT_ID=test+OPENPANEL_CLIENT_SECRET=test\ No newline at end of filediff --git a/apps/server/src/env.ts b/apps/server/src/env.tsindex c13bb769b..675d53d21 100644--- a/apps/server/src/env.ts+++ b/apps/server/src/env.ts@@ -11,8 +11,6 @@ export const env = createEnv({UPSTASH_REDIS_REST_TOKEN: z.string().min(1),FLY_REGION: z.enum(flyRegions),CRON_SECRET: z.string(),- JITSU_WRITE_KEY: z.string().optional(),- JITSU_HOST: z.string().optional(),SCREENSHOT_SERVICE_URL: z.string(),QSTASH_TOKEN: z.string(),NODE_ENV: z.string().default("development"),diff --git a/apps/server/src/v1/incidents/put.ts b/apps/server/src/v1/incidents/put.tsindex a692b2113..d0a43a6cb 100644--- a/apps/server/src/v1/incidents/put.ts+++ b/apps/server/src/v1/incidents/put.ts@@ -3,8 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi";import { and, db, eq } from "@openstatus/db";import { incidentTable } from "@openstatus/db/src/schema/incidents";+import { Events } from "@openstatus/analytics";import { HTTPException } from "hono/http-exception";import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";+import { trackMiddleware } from "../middleware";import type { incidentsApi } from "./index";import { IncidentSchema, ParamsSchema } from "./schema";@@ -13,6 +15,7 @@ const putRoute = createRoute({tags: ["incident"],description: "Update an incident",path: "/:id",+ middleware: [trackMiddleware(Events.UpdateIncident)],request: {params: ParamsSchema,body: {diff --git a/apps/server/src/v1/index.ts b/apps/server/src/v1/index.tsindex 88cf2eb81..a66ce25e8 100644--- a/apps/server/src/v1/index.ts+++ b/apps/server/src/v1/index.ts@@ -3,11 +3,12 @@ import { apiReference } from "@scalar/hono-api-reference";import { cors } from "hono/cors";import { logger } from "hono/logger";+import type { WorkspacePlan } from "@openstatus/db/src/schema";import type { Limits } from "@openstatus/db/src/schema/plan/schema";import { handleError, handleZodError } from "../libs/errors";import { checkAPI } from "./check";import { incidentsApi } from "./incidents";-import { middleware } from "./middleware";+import { secureMiddleware } from "./middleware";import { monitorsApi } from "./monitors";import { notificationsApi } from "./notifications";import { pageSubscribersApi } from "./pageSubscribers";@@ -20,6 +21,7 @@ export type Variables = {workspaceId: string;workspacePlan: {title: "Hobby" | "Starter" | "Growth" | "Pro";+ id: WorkspacePlan;description: string;price: number;};@@ -72,7 +74,7 @@ api.get(/*** Authentification Middleware*/-api.use("/*", middleware);+api.use("/*", secureMiddleware);api.use("/*", logger());/**diff --git a/apps/server/src/v1/middleware.ts b/apps/server/src/v1/middleware.tsindex 0486b0134..2a8b7bf6d 100644--- a/apps/server/src/v1/middleware.ts+++ b/apps/server/src/v1/middleware.ts@@ -1,6 +1,11 @@import { verifyKey } from "@unkey/api";import type { Context, Next } from "hono";+import {+ type EventProps,+ parseInputToProps,+ setupAnalytics,+} from "@openstatus/analytics";import { db, eq } from "@openstatus/db";import { selectWorkspaceSchema, workspace } from "@openstatus/db/src/schema";import { getPlanConfig } from "@openstatus/db/src/schema/plan/utils";@@ -8,7 +13,7 @@ import { HTTPException } from "hono/http-exception";import { env } from "../env";import type { Variables } from "./index";-export async function middleware(+export async function secureMiddleware(c: Context<{ Variables: Variables }, "/*">,next: Next,) {@@ -35,7 +40,9 @@ export async function middleware(console.error("Workspace not found");throw new HTTPException(401, { message: "Unauthorized" });}+const _work = selectWorkspaceSchema.parse(_workspace);+c.set("workspacePlan", getPlanConfig(_workspace.plan));c.set("workspaceId", `${result.ownerId}`);c.set("limits", _work.limits);@@ -43,6 +50,36 @@ export async function middleware(await next();}+export function trackMiddleware(event: EventProps, eventProps?: string[]) {+ return async (c: Context<{ Variables: Variables }, "/*">, next: Next) => {+ await next();++ // REMINDER: only track the event if the request was successful+ if (!c.error) {+ // We have checked the request to be valid already+ let json: unknown;+ if (c.req.raw.bodyUsed) {+ try {+ json = await c.req.json();+ } catch {+ json = {};+ }+ }+ const additionalProps = parseInputToProps(json, eventProps);++ // REMINDER: use setTimeout to avoid blocking the response+ setTimeout(async () => {+ const analytics = await setupAnalytics({+ userId: `api_${c.get("workspaceId")}`,+ workspaceId: c.get("workspaceId"),+ plan: c.get("workspacePlan").id,+ });+ await analytics.track({ ...event, additionalProps });+ }, 0);+ }+ };+}+/*** TODO: move the plan limit into the Unkey `{ meta }` to avoid an additional db call.* When an API Key is created, we need to include the `{ meta: { plan: "free" } }` to the key.diff --git a/apps/server/src/v1/monitors/delete.ts b/apps/server/src/v1/monitors/delete.tsindex eb17193de..bbf6e8c54 100644--- a/apps/server/src/v1/monitors/delete.ts+++ b/apps/server/src/v1/monitors/delete.ts@@ -3,8 +3,10 @@ import { createRoute, z } from "@hono/zod-openapi";import { db, eq } from "@openstatus/db";import { monitor } from "@openstatus/db/src/schema";+import { Events } from "@openstatus/analytics";import { HTTPException } from "hono/http-exception";import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";+import { trackMiddleware } from "../middleware";import type { monitorsApi } from "./index";import { ParamsSchema } from "./schema";@@ -16,6 +18,7 @@ const deleteRoute = createRoute({request: {params: ParamsSchema,},+ middleware: [trackMiddleware(Events.DeleteMonitor)],responses: {200: {content: {diff --git a/apps/server/src/v1/monitors/post.ts b/apps/server/src/v1/monitors/post.tsindex 34bab9447..7f405a62a 100644--- a/apps/server/src/v1/monitors/post.ts+++ b/apps/server/src/v1/monitors/post.ts@@ -1,6 +1,6 @@import { createRoute, z } from "@hono/zod-openapi";-import { trackAnalytics } from "@openstatus/analytics";+import { Events } from "@openstatus/analytics";import { and, db, eq, isNull, sql } from "@openstatus/db";import { monitor } from "@openstatus/db/src/schema";@@ -8,8 +8,8 @@ import { HTTPException } from "hono/http-exception";import { serialize } from "../../../../../packages/assertions/src";import { getLimit } from "@openstatus/db/src/schema/plan/utils";-import { env } from "../../env";import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";+import { trackMiddleware } from "../middleware";import type { monitorsApi } from "./index";import { MonitorSchema } from "./schema";import { getAssertions } from "./utils";@@ -19,6 +19,7 @@ const postRoute = createRoute({tags: ["monitor"],description: "Create a monitor",path: "/",+ middleware: [trackMiddleware(Events.CreateMonitor, ["url", "jobType"])],request: {body: {description: "The monitor to create",@@ -92,15 +93,6 @@ export function registerPostMonitor(api: typeof monitorsApi) {}).returning().get();- if (env.JITSU_WRITE_KEY) {- trackAnalytics({- event: "Monitor Created",- url: input.url,- periodicity: input.periodicity,- api: true,- workspaceId: String(workspaceId),- });- }const data = MonitorSchema.parse(_newMonitor);diff --git a/apps/server/src/v1/monitors/put.ts b/apps/server/src/v1/monitors/put.tsindex a911143dc..d880cf6f9 100644--- a/apps/server/src/v1/monitors/put.ts+++ b/apps/server/src/v1/monitors/put.ts@@ -3,9 +3,11 @@ import { createRoute, z } from "@hono/zod-openapi";import { and, db, eq } from "@openstatus/db";import { monitor } from "@openstatus/db/src/schema";+import { Events } from "@openstatus/analytics";import { HTTPException } from "hono/http-exception";import { serialize } from "../../../../../packages/assertions/src/serializing";import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";+import { trackMiddleware } from "../middleware";import type { monitorsApi } from "./index";import { MonitorSchema, ParamsSchema } from "./schema";import { getAssertions } from "./utils";@@ -15,6 +17,7 @@ const putRoute = createRoute({tags: ["monitor"],description: "Update a monitor",path: "/:id",+ middleware: [trackMiddleware(Events.UpdateMonitor)],request: {params: ParamsSchema,body: {diff --git a/apps/server/src/v1/notifications/post.ts b/apps/server/src/v1/notifications/post.tsindex 0941f925a..2bcd5d9e1 100644--- a/apps/server/src/v1/notifications/post.ts+++ b/apps/server/src/v1/notifications/post.ts@@ -1,5 +1,6 @@import { createRoute } from "@hono/zod-openapi";+import { Events } from "@openstatus/analytics";import { and, db, eq, inArray, isNull, sql } from "@openstatus/db";import {NotificationDataSchema,@@ -11,6 +12,7 @@ import {import { getLimit } from "@openstatus/db/src/schema/plan/utils";import { HTTPException } from "hono/http-exception";import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";+import { trackMiddleware } from "../middleware";import type { notificationsApi } from "./index";import { NotificationSchema } from "./schema";@@ -19,6 +21,7 @@ const postRoute = createRoute({tags: ["notification"],description: "Create a notification",path: "/",+ middleware: [trackMiddleware(Events.CreateNotification)],request: {body: {description: "The notification to create",diff --git a/apps/server/src/v1/pages/post.ts b/apps/server/src/v1/pages/post.tsindex d697fe28f..ee044d3bb 100644--- a/apps/server/src/v1/pages/post.ts+++ b/apps/server/src/v1/pages/post.ts@@ -4,9 +4,11 @@ import { and, eq, inArray, isNull, sql } from "@openstatus/db";import { db } from "@openstatus/db/src/db";import { monitor, monitorsToPages, page } from "@openstatus/db/src/schema";+import { Events } from "@openstatus/analytics";import { getLimit } from "@openstatus/db/src/schema/plan/utils";import { HTTPException } from "hono/http-exception";import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";+import { trackMiddleware } from "../middleware";import { isNumberArray } from "../utils";import type { pagesApi } from "./index";import { PageSchema } from "./schema";@@ -16,6 +18,7 @@ const postRoute = createRoute({tags: ["page"],description: "Create a status page",path: "/",+ middleware: [trackMiddleware(Events.CreatePage, ["slug"])],request: {body: {description: "The status page to create",diff --git a/apps/server/src/v1/pages/put.ts b/apps/server/src/v1/pages/put.tsindex 472f4657f..a68a800a3 100644--- a/apps/server/src/v1/pages/put.ts+++ b/apps/server/src/v1/pages/put.ts@@ -1,10 +1,12 @@import { createRoute } from "@hono/zod-openapi";+import { Events } from "@openstatus/analytics";import { and, eq, inArray, isNull, sql } from "@openstatus/db";import { db } from "@openstatus/db/src/db";import { monitor, monitorsToPages, page } from "@openstatus/db/src/schema";import { HTTPException } from "hono/http-exception";import { openApiErrorResponses } from "../../libs/errors/openapi-error-responses";+import { trackMiddleware } from "../middleware";import { isNumberArray } from "../utils";import type { pagesApi } from "./index";import { PageSchema, ParamsSchema } from "./schema";@@ -14,6 +16,7 @@ const putRoute = createRoute({tags: ["page"],description: "Update a status page",path: "/:id",+ middleware: [trackMiddleware(Events.UpdatePage)],request: {params: ParamsSchema,body: {diff --git a/apps/web/.env.example b/apps/web/.env.exampleindex 53a61394a..f97b006ce 100644--- a/apps/web/.env.example+++ b/apps/web/.env.example@@ -18,10 +18,6 @@ TINY_BIRD_API_KEY=tiny-bird-api-keyDATABASE_URL=file:./../../openstatus-dev.dbDATABASE_AUTH_TOKEN=any-token-# JITSU - no need to touch on local development-# JITSU_HOST="https://your-jitsu-domain.com"-# JITSU_WRITE_KEY="jitsu-key:jitsu-secret"-# Solves 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY', see https://github.com/nextauthjs/next-auth/issues/3580# NODE_TLS_REJECT_UNAUTHORIZED="0"@@ -55,9 +51,6 @@ CRON_SECRET=EXTERNAL_API_URL=-NEXT_PUBLIC_POSTHOG_KEY=-NEXT_PUBLIC_POSTHOG_HOST=-PLAYGROUND_UNKEY_API_KEY=# RUM server with separate clickhouse for self-hostdiff --git a/apps/web/content-collections.ts b/apps/web/content-collections.tsindex 87f1e8c00..6b3d7740c 100644--- a/apps/web/content-collections.ts+++ b/apps/web/content-collections.ts@@ -28,6 +28,8 @@ const prettyCode = [dark: "github-dark-dimmed",light: "github-light",},+ grid: true,+ keepBackground: false,// biome-ignore lint/suspicious/noExplicitAny: <explanation>onVisitLine(node: any) {// Prevent lines from collapsing in `display: grid` mode, and@@ -36,14 +38,6 @@ const prettyCode = [node.children = [{ type: "text", value: " " }];}},- // biome-ignore lint/suspicious/noExplicitAny: <explanation>- onVisitHighlightedLine(node: any) {- node.properties.className.push("highlighted");- },- // biome-ignore lint/suspicious/noExplicitAny: <explanation>- onVisitHighlightedWord(node: any) {- node.properties.className = ["word"];- },},];@@ -61,6 +55,7 @@ const posts = defineCollection({url: z.string().optional(),avatar: z.string().optional(),}),+ tag: z.enum(["company", "engineering", "education"]),}),transform: async (document, context) => {const mdx = await compileMDX(context, document, {diff --git a/apps/web/package.json b/apps/web/package.jsonindex c0ad724d5..9a8596b7d 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -62,8 +62,6 @@"next-plausible": "3.12.4","next-themes": "0.2.1","nuqs": "2.2.3",- "posthog-js": "1.136.1",- "posthog-node": "4.0.1","random-word-slugs": "0.1.7","react": "19.0.0","react-day-picker": "8.10.1",@@ -99,7 +97,6 @@"postcss": "8.4.38","rehype-autolink-headings": "7.1.0","rehype-slug": "5.1.0",- "remark-gfm": "3.0.1","tailwindcss": "3.4.3","typescript": "5.6.2","unified": "10.1.2"diff --git a/apps/web/public/assets/posts/event-analytics-implementation/event-analytics-implementation.png b/apps/web/public/assets/posts/event-analytics-implementation/event-analytics-implementation.pngnew file mode 100644index 000000000..f81be4a1fBinary files /dev/null and b/apps/web/public/assets/posts/event-analytics-implementation/event-analytics-implementation.png differdiff --git a/apps/web/src/app/(content)/blog/[slug]/page.tsx b/apps/web/src/app/(content)/blog/[slug]/page.tsxindex 59eb4f673..67308b146 100644--- a/apps/web/src/app/(content)/blog/[slug]/page.tsx+++ b/apps/web/src/app/(content)/blog/[slug]/page.tsx@@ -29,6 +29,10 @@ export async function generateMetadata(props: {}const { title, publishedAt, description, slug, image } = post;+ const encodedTitle = encodeURIComponent(title);+ const encodedDescription = encodeURIComponent(description);+ const encodedImage = encodeURIComponent(image);+return {...defaultMetadata,title,@@ -42,7 +46,7 @@ export async function generateMetadata(props: {url: `https://www.openstatus.dev/blog/${slug}`,images: [{- url: `https://openstatus.dev/api/og/post?title=${title}&image=${image}`,+ url: `https://openstatus.dev/api/og/post?title=${encodedTitle}&image=${encodedImage}&description=${encodedDescription}`,},],},@@ -51,7 +55,7 @@ export async function generateMetadata(props: {title,description,images: [- `https://openstatus.dev/api/og/post?title=${title}&image=${image}`,+ `https://openstatus.dev/api/og/post?title=${encodedTitle}&image=${encodedImage}&description=${encodedDescription}`,],},};diff --git a/apps/web/src/app/(content)/changelog/[slug]/page.tsx b/apps/web/src/app/(content)/changelog/[slug]/page.tsxindex 874df4d65..c34b90397 100644--- a/apps/web/src/app/(content)/changelog/[slug]/page.tsx+++ b/apps/web/src/app/(content)/changelog/[slug]/page.tsx@@ -33,6 +33,10 @@ export async function generateMetadata(props: {const { title, publishedAt, description, slug, image } = post;+ const encodedTitle = encodeURIComponent(title);+ const encodedDescription = encodeURIComponent(description);+ const encodedImage = encodeURIComponent(image);+return {...defaultMetadata,title,@@ -46,7 +50,7 @@ export async function generateMetadata(props: {url: `https://www.openstatus.dev/changelog/${slug}`,images: [{- url: `https://openstatus.dev/api/og/post?title=${title}&description=${description}&image=${image}`,+ url: `https://openstatus.dev/api/og/post?title=${encodedTitle}&description=${encodedDescription}&image=${encodedImage}`,},],},@@ -55,7 +59,7 @@ export async function generateMetadata(props: {title,description,images: [- `https://openstatus.dev/api/og/post?title=${title}&description=${description}&image=${image}`,+ `https://openstatus.dev/api/og/post?title=${encodedTitle}&description=${encodedDescription}&image=${encodedImage}`,],},};diff --git a/apps/web/src/app/api/og/_components/basic-layout.tsx b/apps/web/src/app/api/og/_components/basic-layout.tsxindex 0f3608ef2..ac99ea220 100644--- a/apps/web/src/app/api/og/_components/basic-layout.tsx+++ b/apps/web/src/app/api/og/_components/basic-layout.tsx@@ -17,11 +17,16 @@ export function BasicLayout({<div tw="flex flex-col h-full w-full px-24"><div tw="flex flex-col flex-1 justify-end"><div tw="flex flex-col px-12">- <h1 style={{ fontFamily: "Cal" }} tw="text-6xl">+ <h3 style={{ fontFamily: "Cal" }} tw="text-5xl">{title}- </h1>+ </h3>{description ? (- <p tw="text-slate-600 text-3xl">{description}</p>+ <p+ tw="text-slate-600 text-3xl"+ style={{ lineClamp: 2, display: "block" }}+ >+ {description}+ </p>) : null}</div></div>diff --git a/apps/web/src/app/api/og/post/route.tsx b/apps/web/src/app/api/og/post/route.tsxindex bfb1dbc84..a45050c86 100644--- a/apps/web/src/app/api/og/post/route.tsx+++ b/apps/web/src/app/api/og/post/route.tsx@@ -34,7 +34,7 @@ export async function GET(req: Request) {{image ? (<imgalt=""- style={{ objectFit: "cover", height: 350 }} // h-80 = 320px+ style={{ objectFit: "cover", height: 330 }} // h-80 = 320pxtw="flex w-full"src={new URL(image, DEFAULT_URL).toString()}/>diff --git a/apps/web/src/app/app/layout.tsx b/apps/web/src/app/app/layout.tsxindex fb27594e1..30e2097d3 100644--- a/apps/web/src/app/app/layout.tsx+++ b/apps/web/src/app/app/layout.tsx@@ -1,7 +1,5 @@import { SessionProvider } from "next-auth/react";-import { PHProvider } from "@/lib/posthog/provider";-import { Bubble } from "@/components/support/bubble";export default function AuthLayout({@@ -10,11 +8,9 @@ export default function AuthLayout({children: React.ReactNode;}) {return (- <PHProvider>- <SessionProvider>- {children}- <Bubble />- </SessionProvider>- </PHProvider>+ <SessionProvider>+ {children}+ <Bubble />+ </SessionProvider>);}diff --git a/apps/web/src/app/status-page/[domain]/_components/actions.ts b/apps/web/src/app/status-page/[domain]/_components/actions.tsindex 25e957871..7f58a3d04 100644--- a/apps/web/src/app/status-page/[domain]/_components/actions.ts+++ b/apps/web/src/app/status-page/[domain]/_components/actions.ts@@ -2,7 +2,7 @@import { z } from "zod";-import { trackAnalytics } from "@openstatus/analytics";+import { Events, setupAnalytics } from "@openstatus/analytics";import { and, eq, sql } from "@openstatus/db";import { db } from "@openstatus/db/src/db";import { page, pageSubscriber } from "@openstatus/db/src/schema";@@ -87,10 +87,8 @@ export async function handleSubscribe(formData: FormData) {}).execute();- await trackAnalytics({- event: "Subscribe to Status Page",- slug: pageData.slug,- });+ const analytics = await setupAnalytics({});+ analytics.track({ ...Events.SubscribePage, slug: pageData.slug });}const passwordSchema = z.object({diff --git a/apps/web/src/components/content/article.tsx b/apps/web/src/components/content/article.tsxindex 01eecc463..c1e81021b 100644--- a/apps/web/src/components/content/article.tsx+++ b/apps/web/src/components/content/article.tsx@@ -2,7 +2,7 @@ import type { Post } from "content-collections";import Image from "next/image";import Link from "next/link";-import { Avatar, AvatarFallback, AvatarImage } from "@openstatus/ui";+import { Avatar, AvatarFallback, AvatarImage, Badge } from "@openstatus/ui";import { Mdx } from "@/components/content/mdx";import { formatDate } from "@/lib/utils";@@ -40,11 +40,15 @@ export function Article({ post }: { post: Post }) {>{post.author.name}</Link>- <p>- {formatDate(post.publishedAt)}- <span className="mx-1 text-muted-foreground/70">•</span>- {post.readingTime}- </p>+ <div className="flex items-center gap-1.5 flex-wrap">+ <time className="font-mono">{formatDate(post.publishedAt)}</time>+ <span className="text-muted-foreground/70">•</span>+ <span className="font-mono">{post.readingTime}</span>+ <span className="text-muted-foreground/70">•</span>+ <Badge variant="outline" className="font-normal capitalize">+ {post.tag}+ </Badge>+ </div></div></div></div>diff --git a/apps/web/src/components/content/mdx.tsx b/apps/web/src/components/content/mdx.tsxindex 8ebbc9218..acf0602b5 100644--- a/apps/web/src/components/content/mdx.tsx+++ b/apps/web/src/components/content/mdx.tsx@@ -13,7 +13,7 @@ export function Mdx({ code, className }: MdxProps) {// FIXME: weird behaviour when `prose-headings:font-cal` and on mouse movement font gets bigger<divclassName={cn(- "prose prose-slate dark:prose-invert prose-pre:my-0 prose-img:rounded-lg prose-pre:rounded-lg prose-img:border prose-pre:border prose-img:border-border prose-pre:border-border prose-headings:font-cal prose-headings:font-normal",+ "prose prose-slate dark:prose-invert prose-pre:my-0 prose-img:rounded-lg prose-pre:bg-background prose-pre:rounded-lg prose-img:border prose-pre:border prose-img:border-border prose-pre:border-border prose-headings:font-cal prose-headings:font-normal",className,)}>diff --git a/apps/web/src/components/content/pre.tsx b/apps/web/src/components/content/pre.tsxindex a0ff9e4b0..e2021627f 100644--- a/apps/web/src/components/content/pre.tsx+++ b/apps/web/src/components/content/pre.tsx@@ -1,11 +1,12 @@"use client";+import { cn } from "@/lib/utils";import { Button } from "@openstatus/ui/src/components/button";import { Clipboard, ClipboardCopy } from "lucide-react";import React from "react";export interface PreProps extends React.HTMLAttributes<HTMLPreElement> {}-export default function Pre({ children, ...props }: PreProps) {+export default function Pre({ children, className, ...props }: PreProps) {const [copied, setCopied] = React.useState(false);const ref = React.useRef<HTMLPreElement>(null);@@ -43,7 +44,7 @@ export default function Pre({ children, ...props }: PreProps) {<ClipboardCopy className="h-5 w-5" />)}</Button>- <pre ref={ref} {...props}>+ <pre ref={ref} className={cn("[&_code]:grid", className)} {...props}>{children}</pre></div>diff --git a/apps/web/src/components/data-table/monitor/data-table-row-actions.tsx b/apps/web/src/components/data-table/monitor/data-table-row-actions.tsxindex a208c287c..7418e1724 100644--- a/apps/web/src/components/data-table/monitor/data-table-row-actions.tsx+++ b/apps/web/src/components/data-table/monitor/data-table-row-actions.tsx@@ -109,6 +109,7 @@ export function DataTableRowActions<TData>({createdAt: undefined,};+ // Create a clone function in the apiawait api.monitor.create.mutate(cloneMonitorData);toast.success("Monitor cloned!");diff --git a/apps/web/src/content/posts/2023-year-review.mdx b/apps/web/src/content/posts/2023-year-review.mdxindex ebcec053d..25219465b 100644--- a/apps/web/src/content/posts/2023-year-review.mdx+++ b/apps/web/src/content/posts/2023-year-review.mdx@@ -6,8 +6,10 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2023-12-29image: /assets/posts/2023-year-review/title.png+tag: company---It has been a wild six months for us at OpenStatus. In late June, we begandiff --git a/apps/web/src/content/posts/dynamic-breadcrumb-nextjs.mdx b/apps/web/src/content/posts/dynamic-breadcrumb-nextjs.mdxindex 375387a0a..abab0a0cf 100644--- a/apps/web/src/content/posts/dynamic-breadcrumb-nextjs.mdx+++ b/apps/web/src/content/posts/dynamic-breadcrumb-nextjs.mdx@@ -5,8 +5,10 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-08-19image: /assets/posts/dynamic-breadcrumb-nextjs/breadcrumb.png+tag: engineering---In this post, we'll dive into the process of creating dynamic breadcrumbs in Next.js using parallel routes. Our goal is to build a breadcrumb component that automatically updates based on the current page and its hierarchy, all while leveraging server-side rendering for optimal performance.diff --git a/apps/web/src/content/posts/event-analytics-implementation.mdx b/apps/web/src/content/posts/event-analytics-implementation.mdxnew file mode 100644index 000000000..50e7bc9b5--- /dev/null+++ b/apps/web/src/content/posts/event-analytics-implementation.mdx@@ -0,0 +1,195 @@+---+title: How We Implemented Event Analytics with OpenPanel+description:+ Leveraging Hono OpenAPI middleware and tRPC metadata + middleware to implement event analytics easily.+author:+ name: Maximilian Kaske+ url: https://x.com/mxkaske+ avatar: /assets/authors/max.png+publishedAt: 2024-12-27+image: /assets/posts/event-analytics-implementation/event-analytics-implementation.png+tag: engineering+---++We had never really tracked events properly. We had some basic tracking in place, but it was not very useful. It is time to improve that with [OpenPanel](https://openpanel.dev?ref=openstatus).++After some research, we finally settled on leveraging tRPC and Hono middlewares. Shoutout to [Midday](https://midday.ai?ref=openstatus) for the (tRPC) inspiration. They use a similar approach with [next-safe-action](https://next-safe-action.dev?ref=openstatus) for their server actions.++This post is not a step-by-step guide but instead presents the core concepts and ideas behind the implementation. Please refer to the [Hono](https://hono.dev?ref=openstatus) or [tRPC](https://trpc.io?ref=openstatus) documentation for more detailed information and our [GitHub](https://openstatus.dev/github) repository for the full implementation.++---++First, let's start with the basics. We need to define the events we want to track, like `page_created`, `user_created`, etc.++```ts+// packages/analytics/src/events.ts+export type EventProps = {+ name: string;+ channel: string;+};++export const Events = {+ CreatePage: {+ name: "page_created",+ channel: "page",+ },+ UpdatePage: {+ name: "page_upated",+ channel: "page",+ },+ // ... add more events+} as const satisfies Record<string, EventProps>;+```++Next, we need to initialize OpenPanel (see [installation](https://openpanel.dev/docs/sdks/javascript?ref=openstatus)) and set up the analytics in our application.++```ts+// packages/analytics/src/index.ts+import {+ OpenPanel,+ type PostEventPayload,+ type IdentifyPayload,+} from "@openpanel/sdk";+import { type EventProps } from "@openstatus/analytics";++const op = new OpenPanel({+ clientId: process.env.OPENPANEL_CLIENT_ID,+ clientSecret: process.env.OPENPANEL_CLIENT_SECRET,+});++export async function setupAnalytics(props: Partial<IdentifyPayload>) {+ if (props.profileId) {+ await op.identify(props):+ }++ return {+ track: (opts: EventProps & PostEventPayload["properties"]) => {+ const { name, ...rest } = opts;+ return op.track(name, rest);+ },+ };+}+```++Now that we have the basic setup in place, we can start implementing the tracking in our application. We will use the tRPC middleware and metadata to track events. Below, we define the `trackEvent` middleware that will track the event after the procedure has been executed. An `enforceUserSession` middleware can be added to include the user's ID for tracking.++```ts {8,12,35} /trackEvent/+// packages/trpc/src/index.ts+import { after } from "next/server";+import { initTRPC } from "@trpc/server";+import { setupAnalytics, type EventProps } from "@openstatus/analytics";+import type { User } from "@openstatus/auth";++type Context = { user?: User };+type Meta = { track?: EventProps };++export const t = initTRPC+ .context<Context>()+ .meta<Meta>()+ .create({ /* ... */ });+++const trackEvent = t.middleware(async opts => {+ const result = await opts.next(opts.ctx);++ if (!result.ok) return result;++ if (opts.meta.track) {+ after(async () => {+ const identify = opts.ctx.user ? { userId: opts.ctx.user.id } : {};+ const analytics = await setupAnalytics(identify);+ await analytics.track(opts.meta.track);+ })+ }+ return result;+});++const enforceUserSession = t.middleware(async opts => {+ // ... set user to ctx+});++export const protectedProcedure = t.procedure+ .use(enforceUserSession)+ .use(trackEvent);+```++The `after` function (similar to `waitUntil`) will execute the tracking after the procedure has been executed and won't block the response.++The `next()` return value has an `ok` boolean property to check if the procedure was successful. If not, we don't want to track the event.++How will we use it in a procedure? Adding a `meta` property will allow us to track the event by defining the event we want to track.++```ts {8}+// packages/trpc/src/router/page.ts+import { Events } from '@openstatus/analytics';+import { insertPageSchema } from "@openstatus/db";+import { createTRPCRouter, protectedProcedure } from "../trpc";++export const pageRouter = createTRPCRouter({+ create: protectedProcedure+ .meta({ track: Events.CreatePage })+ .input(insertPageSchema)+ .mutation(async (opts) => { /* ... */ })+});+```++Voilà! Each time you want to add tracking to a new procedure, you only need to add the `meta` property with the event you want to track. The middleware handles the rest.++---++Now, how do we track the events within our API? Let's start by adding the `trackMiddleware` function and only track the event if the response has been finalized.++```ts /trackMiddleware/+// app/server/src/middleware.ts+import { setupAnalytics, type EventProps } from "@openstatus/analytics";+import type { Context, Next } from "hono";+import type { User } from "@openstatus/auth";++export function trackMiddleware(event: EventProps) {+ return async (c: Context<{ Variables: { user?: User } }, "/*">, next: Next) => {+ await next();++ if (!c.error) {+ setTimeout(async () => {+ const analytics = await setupAnalytics({+ profileId: c.get("user")?.id,+ });+ await analytics.track(event);+ }, 0);+ }+ };+}+```++Depending on where you are running the server, you might want to replace `setTimeout` with `waitUntil` (cf workers, Vercel) or other functions that extend the lifetime of the request without blocking the response.++And again, we check if there was an `error` before tracking the event. We don't want to track unsuccessful events.++The [`@hono/zod-openapi`](https://github.com/honojs/middleware/tree/main/packages/zod-openapi?ref=openstatus) routes have a `middleware` property that allows you to add middleware to the route. This is where we will add the tracking middleware.++```ts {11}+// apps/web/src/pages/post.ts+import { createRoute } from "@hono/zod-openapi";+import { Events } from "@openstatus/analytics";+import { trackMiddleware } from "../middleware";++const postRoute = createRoute({+ method: "post",+ tags: ["page"],+ description: "Create a new Page",+ path: "/",+ middleware: [trackMiddleware(Events.CreatePage)],+ request: { /* ... */ },+ responses: { /* ... */},+});++// ...+```++---++And that's it. With minimal code changes and the help of middlewares, we have implemented event tracking in our application. You can swap [OpenPanel](https://openpanel.dev?ref=openstatus) with any other analytics provider like PostHog, but give it a try, it's an amazing tool!++By the way, this approach can be used for audit log tracking for example as well.++Check out our [GitHub](https://openstatus.dev/github) repository for the full implementation and don't forget to leave a star if you found this helpful.\ No newline at end of filediff --git a/apps/web/src/content/posts/migration-auth-clerk-to-next-auth.mdx b/apps/web/src/content/posts/migration-auth-clerk-to-next-auth.mdxindex 4d2134684..7a2e6c0ed 100644--- a/apps/web/src/content/posts/migration-auth-clerk-to-next-auth.mdx+++ b/apps/web/src/content/posts/migration-auth-clerk-to-next-auth.mdx@@ -5,8 +5,10 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-05-15image: /assets/posts/migration-auth-clerk-to-next-auth/authjs.png+tag: engineering---We recently switched from [Clerk](https://clerk.com) to NextAuthdiff --git a/apps/web/src/content/posts/migration-backend-from-vercel-to-fly.mdx b/apps/web/src/content/posts/migration-backend-from-vercel-to-fly.mdxindex 9952224ca..ff41f11df 100644--- a/apps/web/src/content/posts/migration-backend-from-vercel-to-fly.mdx+++ b/apps/web/src/content/posts/migration-backend-from-vercel-to-fly.mdx@@ -6,8 +6,10 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2023-10-29image: /assets/posts/migration-backend-from-vercel-to-fly/fly.png+tag: company---In this article, we are going to see the reasons that made us change our backenddiff --git a/apps/web/src/content/posts/migration-planetscale-to-turso.mdx b/apps/web/src/content/posts/migration-planetscale-to-turso.mdxindex 16955f50e..de7aa9bde 100644--- a/apps/web/src/content/posts/migration-planetscale-to-turso.mdx+++ b/apps/web/src/content/posts/migration-planetscale-to-turso.mdx@@ -6,7 +6,9 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2023-08-20+tag: company---## What are we building ? 🏗️diff --git a/apps/web/src/content/posts/monitoring-latency-cf-workers-fly-koyeb-raylway-render.mdx b/apps/web/src/content/posts/monitoring-latency-cf-workers-fly-koyeb-raylway-render.mdxindex 3e15466a7..3906c9e65 100644--- a/apps/web/src/content/posts/monitoring-latency-cf-workers-fly-koyeb-raylway-render.mdx+++ b/apps/web/src/content/posts/monitoring-latency-cf-workers-fly-koyeb-raylway-render.mdx@@ -7,8 +7,10 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-02-19image: /assets/posts/monitoring-latency/all-hosting-providers.png+tag: education---> ⚠️ We are using the default settings for each provider and conductingdiff --git a/apps/web/src/content/posts/monitoring-latency-vercel-edge-vs-serverless.mdx b/apps/web/src/content/posts/monitoring-latency-vercel-edge-vs-serverless.mdxindex 38755594a..060122cd1 100644--- a/apps/web/src/content/posts/monitoring-latency-vercel-edge-vs-serverless.mdx+++ b/apps/web/src/content/posts/monitoring-latency-vercel-edge-vs-serverless.mdx@@ -6,8 +6,10 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-03-14image: /assets/posts/monitoring-vercel/serverless-vs-edge.png+tag: education---In our previousdiff --git a/apps/web/src/content/posts/our-new-pricing-explained.mdx b/apps/web/src/content/posts/our-new-pricing-explained.mdxindex 48a8dbde7..b4ec6ac9f 100644--- a/apps/web/src/content/posts/our-new-pricing-explained.mdx+++ b/apps/web/src/content/posts/our-new-pricing-explained.mdx@@ -6,8 +6,10 @@ description:author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-01-15image: /assets/posts/our-new-pricing-explained/pricing-hard.png+tag: company---We began the new year with two goals: to increase profitability and attract morediff --git a/apps/web/src/content/posts/pricing-update-july-2024.mdx b/apps/web/src/content/posts/pricing-update-july-2024.mdxindex 6bacef27e..ddb98a1b0 100644--- a/apps/web/src/content/posts/pricing-update-july-2024.mdx+++ b/apps/web/src/content/posts/pricing-update-july-2024.mdx@@ -4,8 +4,10 @@ description: We have update our pricing again, let's deep dive into it.author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-07-24image: /assets/posts/pricing-update-july-2024/pricing.png+tag: company---diff --git a/apps/web/src/content/posts/q1-2024-update.mdx b/apps/web/src/content/posts/q1-2024-update.mdxindex d56eea2a6..ab10ff392 100644--- a/apps/web/src/content/posts/q1-2024-update.mdx+++ b/apps/web/src/content/posts/q1-2024-update.mdx@@ -4,8 +4,10 @@ description: Let's review our first quarter of 2024.author:name: Thibault Le Ouay Ducasseurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-04-29image: /assets/posts/q1-2024-update/q1-2024-update.png+tag: company---A lot has happened in the first quarter of 2024. We have been working hard todiff --git a/apps/web/src/content/posts/reflecting-1-year-building-openstatus.mdx b/apps/web/src/content/posts/reflecting-1-year-building-openstatus.mdxindex d8da09080..9688b5ed6 100644--- a/apps/web/src/content/posts/reflecting-1-year-building-openstatus.mdx+++ b/apps/web/src/content/posts/reflecting-1-year-building-openstatus.mdx@@ -5,8 +5,10 @@ description: Reflecting on our first year of building OpenStatus, an open sourceauthor:name: Thibault Le Ouayurl: https://bsky.app/profile/thibaultleouay.dev+ avatar: /assets/authors/thibault.jpegpublishedAt: 2024-09-26image: /assets/posts/reflecting-1-year-building-openstatus/first-year.png+tag: company---In one year, we've grown our open-source synthetic monitoring platform to more than 6,000 GitHub stars and 5,000 users. This article will reflect on our first year of building OpenStatus.diff --git a/apps/web/src/content/posts/secure-api-with-unkey.mdx b/apps/web/src/content/posts/secure-api-with-unkey.mdxindex c5d51acd4..7c8ec66bb 100644--- a/apps/web/src/content/posts/secure-api-with-unkey.mdx+++ b/apps/web/src/content/posts/secure-api-with-unkey.mdx@@ -4,8 +4,10 @@ description: The simplest way to secure your API routes within seconds.author:name: Maximilian Kaskeurl: https://twitter.com/mxkaske+ avatar: /assets/authors/max.pngpublishedAt: 2023-10-01image: /assets/posts/secure-api-with-unkey/unkey.png+tag: engineering---## Introductiondiff --git a/apps/web/src/content/posts/the-first-48-hours.mdx b/apps/web/src/content/posts/the-first-48-hours.mdxindex bebf22571..222cc0e41 100644--- a/apps/web/src/content/posts/the-first-48-hours.mdx+++ b/apps/web/src/content/posts/the-first-48-hours.mdx@@ -5,7 +5,9 @@ description: The numbers, limits we faced and consequences we have taken.author:name: Maximilian Kaskeurl: https://twitter.com/mxkaske+ avatar: /assets/authors/max.pngpublishedAt: 2023-08-02+tag: company---## 48 hours of Rollercoaster 🎢diff --git a/apps/web/src/env.ts b/apps/web/src/env.tsindex 0e9424301..102681b73 100644--- a/apps/web/src/env.ts+++ b/apps/web/src/env.ts@@ -30,8 +30,6 @@ export const env = createEnv({NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string(),NEXT_PUBLIC_URL: z.string(),NEXT_PUBLIC_SENTRY_DSN: z.string(),- NEXT_PUBLIC_POSTHOG_KEY: z.string(),- NEXT_PUBLIC_POSTHOG_HOST: z.string(),},runtimeEnv: {TINY_BIRD_API_KEY: process.env.TINY_BIRD_API_KEY,@@ -44,8 +42,6 @@ export const env = createEnv({STRIPE_WEBHOOK_SECRET_KEY: process.env.STRIPE_WEBHOOK_SECRET_KEY,NEXT_PUBLIC_URL: process.env.NEXT_PUBLIC_URL,NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,- NEXT_PUBLIC_POSTHOG_KEY: process.env.NEXT_PUBLIC_POSTHOG_KEY,- NEXT_PUBLIC_POSTHOG_HOST: process.env.NEXT_PUBLIC_POSTHOG_HOST,UNKEY_TOKEN: process.env.UNKEY_TOKEN,UNKEY_API_ID: process.env.UNKEY_API_ID,GCP_PROJECT_ID: process.env.GCP_PROJECT_ID,diff --git a/apps/web/src/lib/auth/index.ts b/apps/web/src/lib/auth/index.tsindex 365918df5..d0fd07892 100644--- a/apps/web/src/lib/auth/index.ts+++ b/apps/web/src/lib/auth/index.ts@@ -1,12 +1,11 @@import type { DefaultSession } from "next-auth";import NextAuth from "next-auth";-import { analytics, trackAnalytics } from "@openstatus/analytics";+import { Events, setupAnalytics } from "@openstatus/analytics";import { db, eq } from "@openstatus/db";import { user } from "@openstatus/db/src/schema";import { sendEmail } from "@openstatus/emails/src/send";-import { identifyUser } from "@/lib/posthog/provider";import { WelcomeEmail } from "@openstatus/emails/emails/welcome";import { adapter } from "./adapter";import { GitHubProvider, GoogleProvider, ResendProvider } from "./providers";@@ -89,26 +88,24 @@ export const { handlers, signIn, signOut, auth } = NextAuth({react: WelcomeEmail(),});- const { id: userId, email } = params.user;+ const analytics = await setupAnalytics({+ userId: `usr_${params.user.id}`,+ email: params.user.id,+ });- if (process.env.NODE_ENV !== "development") {- await analytics.identify(userId, { email, userId });- await trackAnalytics({ event: "User Created", userId, email });- await identifyUser({ user: params.user });- }+ await analytics.track(Events.CreateUser);},async signIn(params) {if (params.isNewUser) return;if (!params.user.id || !params.user.email) return;- const { id: userId, email } = params.user;+ const analytics = await setupAnalytics({+ userId: `usr_${params.user.id}`,+ email: params.user.id,+ });- if (process.env.NODE_ENV !== "development") {- await analytics.identify(userId, { userId, email });- await identifyUser({ user: params.user });- await trackAnalytics({ event: "User Signed In" });- }+ await analytics.track(Events.SignInUser);},},pages: {diff --git a/apps/web/src/lib/posthog/client.ts b/apps/web/src/lib/posthog/client.tsdeleted file mode 100644index dc1866f18..000000000--- a/apps/web/src/lib/posthog/client.ts+++ /dev/null@@ -1,14 +0,0 @@-import { PostHog } from "posthog-node";--import { env } from "@/env";--// REMINDER: SSR actions--export default function PostHogClient() {- const posthogClient = new PostHog(env.NEXT_PUBLIC_POSTHOG_KEY, {- host: env.NEXT_PUBLIC_POSTHOG_HOST,- flushAt: 1,- flushInterval: 0,- });- return posthogClient;-}diff --git a/apps/web/src/lib/posthog/pageview.tsx b/apps/web/src/lib/posthog/pageview.tsxdeleted file mode 100644index 1096b8efb..000000000--- a/apps/web/src/lib/posthog/pageview.tsx+++ /dev/null@@ -1,37 +0,0 @@-// app/PostHogPageView.tsx-"use client";--import { usePathname, useSearchParams } from "next/navigation";-import { usePostHog } from "posthog-js/react";-import { Suspense, useEffect } from "react";--function PostHogPageView(): null {- const pathname = usePathname();- const searchParams = useSearchParams();- const posthog = usePostHog();- useEffect(() => {- // Track pageviews- if (pathname && posthog) {- let url = window.origin + pathname;- if (searchParams.toString()) {- url = `${url}?${searchParams.toString()}`;- }- posthog.capture("$pageview", {- $current_url: url,- });- }- }, [pathname, searchParams, posthog]);-- return null;-}--// Wrap this in Suspense to avoid the `useSearchParams` usage above-// from deopting the whole app into client-side rendering-// See https://nextjs.org/docs/messages/deopted-into-client-rendering-export function SuspendedPostHogPageView() {- return (- <Suspense fallback={null}>- <PostHogPageView />- </Suspense>- );-}diff --git a/apps/web/src/lib/posthog/provider.tsx b/apps/web/src/lib/posthog/provider.tsxdeleted file mode 100644index 691435a8b..000000000--- a/apps/web/src/lib/posthog/provider.tsx+++ /dev/null@@ -1,46 +0,0 @@-"use client";--import type { User } from "next-auth";-import type { CaptureOptions, Properties } from "posthog-js";-import posthog from "posthog-js";-import { PostHogProvider } from "posthog-js/react";-import { SuspendedPostHogPageView } from "./pageview";--import { env } from "@/env";-import { useEffect } from "react";--export function PHProvider({ children }: { children: React.ReactNode }) {- if (process.env.NODE_ENV !== "production") return children;-- useEffect(() => {- posthog.init(env.NEXT_PUBLIC_POSTHOG_KEY, {- api_host: env.NEXT_PUBLIC_POSTHOG_HOST,- capture_pageview: false, // Disable automatic pageview capture, as we capture manually- capture_pageleave: true, // Enable automatic pageleave capture- disable_session_recording: false, // Enable automatic session recording- });- }, []);-- return (- <PostHogProvider client={posthog}>- <SuspendedPostHogPageView />- {children}- </PostHogProvider>- );-}--export function trackEvent({- name,- props,- opts,-}: {- name: string;- props: Properties;- opts: CaptureOptions;-}) {- posthog.capture(name, props, opts);-}--export function identifyUser({ user }: { user: User }) {- posthog.identify(user.id, { email: user.email });-}diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.cssindex 6a9f3a0b0..cacf0fa5f 100644--- a/apps/web/src/styles/globals.css+++ b/apps/web/src/styles/globals.css@@ -102,4 +102,12 @@body {@apply bg-background text-foreground;}++ [data-highlighted-chars] {+ @apply bg-muted rounded;+ }++ [data-highlighted-line] {+ @apply bg-muted rounded;+ }}diff --git a/packages/analytics/.env.example b/packages/analytics/.env.exampleindex c7ccae640..6fbd3eadd 100644--- a/packages/analytics/.env.example+++ b/packages/analytics/.env.example@@ -1,2 +1,2 @@-JITSU_HOST="https://your-jitsu-domain.com"-JITSU_WRITE_KEY="jitsu-key:jitsu-secret"+OPENPANEL_CLIENT_ID=+OPENPANEL_CLIENT_SECRET=\ No newline at end of filediff --git a/packages/analytics/env.ts b/packages/analytics/env.tsindex 4bd63c7d8..80b37c48c 100644--- a/packages/analytics/env.ts+++ b/packages/analytics/env.ts@@ -3,11 +3,11 @@ import { z } from "zod";export const env = createEnv({server: {- JITSU_HOST: z.string().optional(),- JITSU_WRITE_KEY: z.string().optional(),+ OPENPANEL_CLIENT_ID: z.string(),+ OPENPANEL_CLIENT_SECRET: z.string(),},runtimeEnv: {- JITSU_HOST: process.env.JITSU_HOST,- JITSU_WRITE_KEY: process.env.JITSU_WRITE_KEY,+ OPENPANEL_CLIENT_ID: process.env.OPENPANEL_CLIENT_ID,+ OPENPANEL_CLIENT_SECRET: process.env.OPENPANEL_CLIENT_SECRET,},});diff --git a/packages/analytics/package.json b/packages/analytics/package.jsonindex 380ffd105..9c011b0ae 100644--- a/packages/analytics/package.json+++ b/packages/analytics/package.json@@ -5,6 +5,7 @@"main": "src/index.ts","dependencies": {"@jitsu/js": "1.9.2",+ "@openpanel/sdk": "^1.0.0","@t3-oss/env-core": "0.7.0","zod": "3.23.8"},diff --git a/packages/analytics/src/events.ts b/packages/analytics/src/events.tsnew file mode 100644index 000000000..4436bec05--- /dev/null+++ b/packages/analytics/src/events.ts@@ -0,0 +1,151 @@+export type EventProps = {+ name: string;+ channel: string;+};++export const Events = {+ CreateUser: {+ name: "user_created",+ channel: "registration",+ },+ SkipOnboarding: {+ name: "onboarding_skipped",+ channel: "onboarding",+ },+ CompleteOnboarding: {+ name: "onboarding_completed",+ channel: "onboarding",+ },+ SignInUser: {+ name: "user_signed_in",+ channel: "login",+ },+ SignOutUser: {+ name: "user_signed_out",+ channel: "login",+ },+ CreateMonitor: {+ name: "monitor_created",+ channel: "monitor",+ },+ UpdateMonitor: {+ name: "monitor_updated",+ channel: "monitor",+ },+ DeleteMonitor: {+ name: "monitor_deleted",+ channel: "monitor",+ },+ CloneMonitor: {+ name: "monitor_cloned",+ channel: "monitor",+ },+ TestMonitor: {+ name: "monitor_tested",+ channel: "monitor",+ },+ CreatePage: {+ name: "page_created",+ channel: "page",+ },+ UpdatePage: {+ name: "page_updated",+ channel: "page",+ },+ DeletePage: {+ name: "page_deleted",+ channel: "page",+ },+ SubscribePage: {+ name: "user_subscribed",+ channel: "page",+ },+ CreateReport: {+ name: "report_created",+ channel: "report",+ },+ UpdateReport: {+ name: "report_updated",+ channel: "report",+ },+ DeleteReport: {+ name: "report_deleted",+ channel: "report",+ },+ CreateMaintenance: {+ name: "maintenance_created",+ channel: "maintenance",+ },+ UpdateMaintenance: {+ name: "maintenance_updated",+ channel: "maintenance",+ },+ DeleteMaintenance: {+ name: "maintenance_deleted",+ channel: "maintenance",+ },+ CreateNotification: {+ name: "notification_created",+ channel: "notification",+ },+ UpdateNotification: {+ name: "notification_updated",+ channel: "notification",+ },+ DeleteNotification: {+ name: "notification_deleted",+ channel: "notification",+ },+ AcknowledgeIncident: {+ name: "incident_acknowledged",+ channel: "incident",+ },+ ResolveIncident: {+ name: "incident_resolved",+ channel: "incident",+ },+ UpdateIncident: {+ name: "incident_updated",+ channel: "incident",+ },+ DeleteIncident: {+ name: "incident_deleted",+ channel: "incident",+ },+ InviteUser: {+ name: "user_invited",+ channel: "team",+ },+ DeleteInvite: {+ name: "invitation_deleted",+ channel: "team",+ },+ AcceptInvite: {+ name: "invitation_accepted",+ channel: "team",+ },+ RemoveUser: {+ name: "user_removed",+ channel: "team",+ },+ CreateAPI: {+ name: "api_key_created",+ channel: "api_key",+ },+ RevokeAPI: {+ name: "api_key_revoked",+ channel: "api_key",+ },+ UpgradeWorkspace: {+ name: "workspace_updated",+ channel: "billing",+ },+ StripePortal: {+ name: "stripe_portal",+ channel: "billing",+ },+ DowngradeWorkspace: {+ name: "workspace_downgraded",+ channel: "billing",+ },+} as const satisfies Record<string, EventProps>;diff --git a/packages/analytics/src/index.ts b/packages/analytics/src/index.tsindex 9766b1296..338eca465 100644--- a/packages/analytics/src/index.ts+++ b/packages/analytics/src/index.ts@@ -1,17 +1,3 @@-import { emptyAnalytics, jitsuAnalytics } from "@jitsu/js";--import { env } from "../env";-import type { AnalyticsEvents } from "./type";--export const analytics =- env.JITSU_HOST && env.JITSU_WRITE_KEY- ? jitsuAnalytics({- host: env.JITSU_HOST,- writeKey: env.JITSU_WRITE_KEY,- })- : emptyAnalytics;--export const trackAnalytics = (args: AnalyticsEvents) =>- env.JITSU_HOST && env.JITSU_WRITE_KEY- ? analytics.track(args)- : emptyAnalytics.track(args);+export * from "./events";+export * from "./server";+export * from "./utils";diff --git a/packages/analytics/src/server.ts b/packages/analytics/src/server.tsnew file mode 100644index 000000000..4f3710347--- /dev/null+++ b/packages/analytics/src/server.ts@@ -0,0 +1,64 @@+import { OpenPanel, type PostEventPayload } from "@openpanel/sdk";+import { env } from "../env";+import type { EventProps } from "./events";++const op = new OpenPanel({+ clientId: env.OPENPANEL_CLIENT_ID,+ clientSecret: env.OPENPANEL_CLIENT_SECRET,+});++op.setGlobalProperties({+ env: process.env.VERCEL_ENV || process.env.NODE_ENV || "localhost",+ // app_version+});++export type IdentifyProps = {+ userId?: string;+ fullName?: string | null;+ email?: string;+ workspaceId?: string;+ plan?: string;+};++export async function setupAnalytics(props: IdentifyProps) {+ if (process.env.NODE_ENV !== "production") {+ return noop();+ }++ if (props.userId) {+ const [firstName, lastName] = props.fullName?.split(" ") || [];+ await op.identify({+ profileId: props.userId,+ email: props.email,+ firstName: firstName,+ lastName: lastName,+ properties: {+ workspaceId: props.workspaceId,+ plan: props.plan,+ },+ });+ }++ return {+ track: (opts: EventProps & PostEventPayload["properties"]) => {+ const { name, ...rest } = opts;+ return op.track(name, rest);+ },+ };+}++/**+ * Noop analytics for development environment+ */+async function noop() {+ return {+ track: (+ opts: EventProps & PostEventPayload["properties"],+ ): Promise<unknown> => {+ return new Promise((resolve) => {+ console.log(`>>> Track Event: ${opts.name}`);+ resolve(null);+ });+ },+ };+}diff --git a/packages/analytics/src/type.ts b/packages/analytics/src/type.tsdeleted file mode 100644index 03630e717..000000000--- a/packages/analytics/src/type.ts+++ /dev/null@@ -1,24 +0,0 @@-export type AnalyticsEvents =- | {- event: "User Created";- userId: string;- email: string;- }- | {- event: "Monitor Created";- url: string;- periodicity: string;- api?: boolean;- workspaceId?: string;- }- | {- event: "Page Created";- slug: string;- api?: boolean;- }- | { event: "User Upgraded"; email: string }- | { event: "User Signed In" }- | { event: "User RUM Beta Requested"; email: string }- | { event: "Notification Created"; provider: string }- | { event: "Subscribe to Status Page"; slug: string }- | { event: "Invitation Created"; emailTo: string; workspaceId: number };diff --git a/packages/analytics/src/utils.ts b/packages/analytics/src/utils.tsnew file mode 100644index 000000000..5c151916c--- /dev/null+++ b/packages/analytics/src/utils.ts@@ -0,0 +1,18 @@+export function parseInputToProps(+ json: unknown,+ eventProps?: string[],+): Record<string, unknown> {+ if (typeof json !== "object" || json === null) return {};++ if (!eventProps) return {};++ return eventProps.reduce(+ (acc, prop) => {+ if (prop in json) {+ acc[prop] = json[prop as keyof typeof json];+ }+ return acc;+ },+ {} as Record<string, unknown>,+ );+}diff --git a/packages/api/.env.test b/packages/api/.env.testindex 43e7bc953..c8095c925 100644--- a/packages/api/.env.test+++ b/packages/api/.env.test@@ -1 +1,3 @@RESEND_API_KEY='test'+OPENPANEL_CLIENT_ID='test'+OPENPANEL_CLIENT_SECRET='test'\ No newline at end of filediff --git a/packages/api/src/analytics.ts b/packages/api/src/analytics.tsdeleted file mode 100644index be88accba..000000000--- a/packages/api/src/analytics.ts+++ /dev/null@@ -1,61 +0,0 @@-import { analytics, trackAnalytics } from "@openstatus/analytics";-import type { User } from "@openstatus/db/src/schema";--export async function trackNewPage(user: User, config: { slug: string }) {- await analytics.identify(user.id, {- userId: user.id,- email: user.email,- });- await trackAnalytics({- event: "Page Created",- ...config,- });-}--export async function trackNewMonitor(- user: User,- config: { url: string; periodicity: string },-) {- await analytics.identify(user.id, {- userId: user.id,- email: user.email,- });- await trackAnalytics({- event: "Monitor Created",- ...config,- });-}--export async function trackNewUser() {}--export async function trackNewWorkspace() {}--export async function trackNewNotification(- user: User,- config: { provider: string },-) {- await analytics.identify(user.id, {- userId: user.id,- email: user.email,- });- await trackAnalytics({- event: "Notification Created",- ...config,- });-}--export async function trackNewStatusReport() {}--export async function trackNewInvitation(- user: User,- config: { emailTo: string; workspaceId: number },-) {- await analytics.identify(user.id, {- userId: user.id,- email: user.email,- });- await trackAnalytics({- event: "Invitation Created",- ...config,- });-}diff --git a/packages/api/src/env.ts b/packages/api/src/env.tsindex 45f1e54d5..5ae3f1088 100644--- a/packages/api/src/env.ts+++ b/packages/api/src/env.ts@@ -8,8 +8,6 @@ export const env = createEnv({TEAM_ID_VERCEL: z.string(),VERCEL_AUTH_BEARER_TOKEN: z.string(),TINY_BIRD_API_KEY: z.string(),- JITSU_HOST: z.string().optional(),- JITSU_WRITE_KEY: z.string().optional(),},runtimeEnv: {@@ -18,8 +16,6 @@ export const env = createEnv({TEAM_ID_VERCEL: process.env.TEAM_ID_VERCEL,VERCEL_AUTH_BEARER_TOKEN: process.env.VERCEL_AUTH_BEARER_TOKEN,TINY_BIRD_API_KEY: process.env.TINY_BIRD_API_KEY,- JITSU_HOST: process.env.JITSU_HOST,- JITSU_WRITE_KEY: process.env.JITSU_WRITE_KEY,},skipValidation: process.env.NODE_ENV === "test",});diff --git a/packages/api/src/lambda.ts b/packages/api/src/lambda.tsindex f6d866ff5..7948ddf37 100644--- a/packages/api/src/lambda.ts+++ b/packages/api/src/lambda.ts@@ -1,11 +1,9 @@-import { rumRouter } from "./router/rum";import { stripeRouter } from "./router/stripe";import { createTRPCRouter } from "./trpc";// Deployed to /trpc/lambda/**export const lambdaRouter = createTRPCRouter({stripeRouter: stripeRouter,- rumRouter: rumRouter,});export { stripe } from "./router/stripe/shared";diff --git a/packages/api/src/router/incident.ts b/packages/api/src/router/incident.tsindex 49cf77395..7adf96fb7 100644--- a/packages/api/src/router/incident.ts+++ b/packages/api/src/router/incident.ts@@ -3,6 +3,7 @@ import { z } from "zod";import { and, eq, isNull, schema } from "@openstatus/db";import { selectIncidentSchema } from "@openstatus/db/src/schema";+import { Events } from "@openstatus/analytics";import { createTRPCRouter, protectedProcedure } from "../trpc";export const incidentRouter = createTRPCRouter({@@ -65,6 +66,7 @@ export const incidentRouter = createTRPCRouter({}),acknowledgeIncident: protectedProcedure+ .meta({ track: Events.AcknowledgeIncident }).input(z.object({ id: z.number() })).mutation(async (opts) => {const currentIncident = await opts.ctx.db@@ -98,6 +100,7 @@ export const incidentRouter = createTRPCRouter({return true;}),resolvedIncident: protectedProcedure+ .meta({ track: Events.ResolveIncident }).input(z.object({ id: z.number() })).mutation(async (opts) => {const currentIncident = await opts.ctx.db@@ -135,6 +138,7 @@ export const incidentRouter = createTRPCRouter({}),delete: protectedProcedure+ .meta({ track: Events.DeleteIncident }).input(z.object({ id: z.number() })).mutation(async (opts) => {const incidentToDelete = await opts.ctx.dbdiff --git a/packages/api/src/router/invitation.ts b/packages/api/src/router/invitation.tsindex 451af3de8..4c8b091ef 100644--- a/packages/api/src/router/invitation.ts+++ b/packages/api/src/router/invitation.ts@@ -1,6 +1,7 @@import { TRPCError } from "@trpc/server";import { z } from "zod";+import { Events } from "@openstatus/analytics";import { and, eq, gte, isNull } from "@openstatus/db";import {insertInvitationSchema,@@ -9,14 +10,13 @@ import {user,usersToWorkspaces,} from "@openstatus/db/src/schema";-import { allPlans } from "@openstatus/db/src/schema/plan/config";-import { trackNewInvitation } from "../analytics";import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";export const invitationRouter = createTRPCRouter({create: protectedProcedure.input(insertInvitationSchema.pick({ email: true }))+ .meta({ track: Events.InviteUser }).mutation(async (opts) => {const { email } = opts.input;@@ -88,16 +88,12 @@ export const invitationRouter = createTRPCRouter({});}- await trackNewInvitation(opts.ctx.user, {- emailTo: email,- workspaceId: opts.ctx.workspace.id,- });-return _invitation;}),delete: protectedProcedure.input(z.object({ id: z.number() }))+ .meta({ track: Events.DeleteInvite }).mutation(async (opts) => {await opts.ctx.db.delete(invitation)@@ -140,6 +136,7 @@ export const invitationRouter = createTRPCRouter({*/acceptInvitation: publicProcedure.input(z.object({ token: z.string() }))+ .meta({ track: Events.AcceptInvite }).output(z.object({message: z.string(),diff --git a/packages/api/src/router/maintenance.ts b/packages/api/src/router/maintenance.tsindex b99f6f256..a3d31f261 100644--- a/packages/api/src/router/maintenance.ts+++ b/packages/api/src/router/maintenance.ts@@ -8,11 +8,13 @@ import {selectMaintenanceSchema,} from "@openstatus/db/src/schema";+import { Events } from "@openstatus/analytics";import { TRPCError } from "@trpc/server";import { createTRPCRouter, protectedProcedure } from "../trpc";export const maintenanceRouter = createTRPCRouter({create: protectedProcedure+ .meta({ track: Events.CreateMaintenance }).input(insertMaintenanceSchema).mutation(async (opts) => {const _maintenance = await opts.ctx.db@@ -111,6 +113,7 @@ export const maintenanceRouter = createTRPCRouter({return _maintenances;}),update: protectedProcedure+ .meta({ track: Events.UpdateMaintenance }).input(insertMaintenanceSchema).mutation(async (opts) => {if (!opts.input.id) {@@ -175,6 +178,7 @@ export const maintenanceRouter = createTRPCRouter({return _maintenance;}),delete: protectedProcedure+ .meta({ track: Events.DeleteMaintenance }).input(z.object({ id: z.number() })).mutation(async (opts) => {return await opts.ctx.dbdiff --git a/packages/api/src/router/monitor.ts b/packages/api/src/router/monitor.tsindex f43e706a0..dc6981c69 100644--- a/packages/api/src/router/monitor.ts+++ b/packages/api/src/router/monitor.ts@@ -26,11 +26,12 @@ import {selectPublicMonitorSchema,} from "@openstatus/db/src/schema";-import { trackNewMonitor } from "../analytics";+import { Events } from "@openstatus/analytics";import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";export const monitorRouter = createTRPCRouter({create: protectedProcedure+ .meta({ track: Events.CreateMonitor, trackProps: ["url", "jobType"] }).input(insertMonitorSchema).output(selectMonitorSchema).mutation(async (opts) => {@@ -167,11 +168,6 @@ export const monitorRouter = createTRPCRouter({await opts.ctx.db.insert(monitorsToPages).values(values).run();}- await trackNewMonitor(opts.ctx.user, {- url: newMonitor.url,- periodicity: newMonitor.periodicity,- });-return selectMonitorSchema.parse(newMonitor);}),@@ -262,6 +258,7 @@ export const monitorRouter = createTRPCRouter({}),update: protectedProcedure+ .meta({ track: Events.UpdateMonitor }).input(insertMonitorSchema).mutation(async (opts) => {if (!opts.input.id) return;@@ -535,6 +532,7 @@ export const monitorRouter = createTRPCRouter({}),delete: protectedProcedure+ .meta({ track: Events.DeleteMonitor }).input(z.object({ id: z.number() })).mutation(async (opts) => {const monitorToDelete = await opts.ctx.dbdiff --git a/packages/api/src/router/notification.ts b/packages/api/src/router/notification.tsindex 4678aa27a..3c9bd5a64 100644--- a/packages/api/src/router/notification.ts+++ b/packages/api/src/router/notification.ts@@ -12,13 +12,13 @@ import {selectNotificationSchema,} from "@openstatus/db/src/schema";+import { Events } from "@openstatus/analytics";import { SchemaError } from "@openstatus/error";-import { trackNewNotification } from "../analytics";-import { env } from "../env";import { createTRPCRouter, protectedProcedure } from "../trpc";export const notificationRouter = createTRPCRouter({create: protectedProcedure+ .meta({ track: Events.CreateNotification }).input(insertNotificationSchema).mutation(async (opts) => {const { monitors, ...props } = opts.input;@@ -63,16 +63,11 @@ export const notificationRouter = createTRPCRouter({await opts.ctx.db.insert(notificationsToMonitors).values(values);}- if (env.JITSU_HOST !== undefined && env.JITSU_WRITE_KEY !== undefined) {- await trackNewNotification(opts.ctx.user, {- provider: _notification.provider,- });- }-return _notification;}),update: protectedProcedure+ .meta({ track: Events.UpdateNotification }).input(insertNotificationSchema).mutation(async (opts) => {if (!opts.input.id) return;@@ -160,6 +155,7 @@ export const notificationRouter = createTRPCRouter({}),deleteNotification: protectedProcedure+ .meta({ track: Events.DeleteNotification }).input(z.object({ id: z.number() })).mutation(async (opts) => {await opts.ctx.dbdiff --git a/packages/api/src/router/page.ts b/packages/api/src/router/page.tsindex a810b13af..ab63b5c65 100644--- a/packages/api/src/router/page.ts+++ b/packages/api/src/router/page.ts@@ -15,78 +15,80 @@ import {workspace,} from "@openstatus/db/src/schema";-import { trackNewPage } from "../analytics";+import { Events } from "@openstatus/analytics";import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";export const pageRouter = createTRPCRouter({- create: protectedProcedure.input(insertPageSchema).mutation(async (opts) => {- const { monitors, workspaceId, id, ...pageProps } = opts.input;-- const monitorIds = monitors?.map((item) => item.monitorId) || [];-- const pageNumbers = (- await opts.ctx.db.query.page.findMany({- where: eq(page.workspaceId, opts.ctx.workspace.id),- })- ).length;+ create: protectedProcedure+ .meta({ track: Events.CreatePage, trackProps: ["slug"] })+ .input(insertPageSchema)+ .mutation(async (opts) => {+ const { monitors, workspaceId, id, ...pageProps } = opts.input;- const limit = opts.ctx.workspace.limits;+ const monitorIds = monitors?.map((item) => item.monitorId) || [];- // the user has reached the status page number limits- if (pageNumbers >= limit["status-pages"]) {- throw new TRPCError({- code: "FORBIDDEN",- message: "You reached your status-page limits.",- });- }-- // the user is not eligible for password protection- if (- limit["password-protection"] === false &&- opts.input.passwordProtected === true- ) {- throw new TRPCError({- code: "FORBIDDEN",- message: "Password protection is not available for your current plan.",- });- }+ const pageNumbers = (+ await opts.ctx.db.query.page.findMany({+ where: eq(page.workspaceId, opts.ctx.workspace.id),+ })+ ).length;- const newPage = await opts.ctx.db- .insert(page)- .values({ workspaceId: opts.ctx.workspace.id, ...pageProps })- .returning()- .get();+ const limit = opts.ctx.workspace.limits;- if (monitorIds.length) {- // We should make sure the user has access to the monitors- const allMonitors = await opts.ctx.db.query.monitor.findMany({- where: and(- inArray(monitor.id, monitorIds),- eq(monitor.workspaceId, opts.ctx.workspace.id),- isNull(monitor.deletedAt),- ),- });+ // the user has reached the status page number limits+ if (pageNumbers >= limit["status-pages"]) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "You reached your status-page limits.",+ });+ }- if (allMonitors.length !== monitorIds.length) {+ // the user is not eligible for password protection+ if (+ limit["password-protection"] === false &&+ opts.input.passwordProtected === true+ ) {throw new TRPCError({code: "FORBIDDEN",- message: "You don't have access to all the monitors.",+ message:+ "Password protection is not available for your current plan.",});}- const values = monitors.map(({ monitorId }, index) => ({- pageId: newPage.id,- order: index,- monitorId,- }));+ const newPage = await opts.ctx.db+ .insert(page)+ .values({ workspaceId: opts.ctx.workspace.id, ...pageProps })+ .returning()+ .get();- await opts.ctx.db.insert(monitorsToPages).values(values).run();- }+ if (monitorIds.length) {+ // We should make sure the user has access to the monitors+ const allMonitors = await opts.ctx.db.query.monitor.findMany({+ where: and(+ inArray(monitor.id, monitorIds),+ eq(monitor.workspaceId, opts.ctx.workspace.id),+ isNull(monitor.deletedAt),+ ),+ });- await trackNewPage(opts.ctx.user, { slug: newPage.slug });+ if (allMonitors.length !== monitorIds.length) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "You don't have access to all the monitors.",+ });+ }- return newPage;- }),+ const values = monitors.map(({ monitorId }, index) => ({+ pageId: newPage.id,+ order: index,+ monitorId,+ }));++ await opts.ctx.db.insert(monitorsToPages).values(values).run();+ }++ return newPage;+ }),getPageById: protectedProcedure.input(z.object({ id: z.number() })).query(async (opts) => {@@ -105,94 +107,99 @@ export const pageRouter = createTRPCRouter({return selectPageSchemaWithMonitorsRelation.parse(firstPage);}),- update: protectedProcedure.input(insertPageSchema).mutation(async (opts) => {- const { monitors, ...pageInput } = opts.input;- if (!pageInput.id) return;-- const monitorIds = monitors?.map((item) => item.monitorId) || [];-- const limit = opts.ctx.workspace.limits;+ update: protectedProcedure+ .meta({ track: Events.UpdatePage })+ .input(insertPageSchema)+ .mutation(async (opts) => {+ const { monitors, ...pageInput } = opts.input;+ if (!pageInput.id) return;- // the user is not eligible for password protection- if (- limit["password-protection"] === false &&- opts.input.passwordProtected === true- ) {- throw new TRPCError({- code: "FORBIDDEN",- message: "Password protection is not available for your current plan.",- });- }-- const currentPage = await opts.ctx.db- .update(page)- .set({ ...pageInput, updatedAt: new Date() })- .where(- and(- eq(page.id, pageInput.id),- eq(page.workspaceId, opts.ctx.workspace.id),- ),- )- .returning()- .get();+ const monitorIds = monitors?.map((item) => item.monitorId) || [];- if (monitorIds.length) {- // We should make sure the user has access to the monitors- const allMonitors = await opts.ctx.db.query.monitor.findMany({- where: and(- inArray(monitor.id, monitorIds),- eq(monitor.workspaceId, opts.ctx.workspace.id),- isNull(monitor.deletedAt),- ),- });+ const limit = opts.ctx.workspace.limits;- if (allMonitors.length !== monitorIds.length) {+ // the user is not eligible for password protection+ if (+ limit["password-protection"] === false &&+ opts.input.passwordProtected === true+ ) {throw new TRPCError({code: "FORBIDDEN",- message: "You don't have access to all the monitors.",+ message:+ "Password protection is not available for your current plan.",});}- }-- // TODO: check for monitor order!- const currentMonitorsToPages = await opts.ctx.db- .select()- .from(monitorsToPages)- .where(eq(monitorsToPages.pageId, currentPage.id))- .all();-- const removedMonitors = currentMonitorsToPages- .map(({ monitorId }) => monitorId)- .filter((x) => !monitorIds?.includes(x));- if (removedMonitors.length) {- await opts.ctx.db- .delete(monitorsToPages)+ const currentPage = await opts.ctx.db+ .update(page)+ .set({ ...pageInput, updatedAt: new Date() }).where(and(- inArray(monitorsToPages.monitorId, removedMonitors),- eq(monitorsToPages.pageId, currentPage.id),+ eq(page.id, pageInput.id),+ eq(page.workspaceId, opts.ctx.workspace.id),),- );- }-- const values = monitors.map(({ monitorId }, index) => ({- pageId: currentPage.id,- order: index,- monitorId,- }));+ )+ .returning()+ .get();- if (values.length) {- await opts.ctx.db- .insert(monitorsToPages)- .values(values)- .onConflictDoUpdate({- target: [monitorsToPages.monitorId, monitorsToPages.pageId],- set: { order: sql.raw("excluded.`order`") },+ if (monitorIds.length) {+ // We should make sure the user has access to the monitors+ const allMonitors = await opts.ctx.db.query.monitor.findMany({+ where: and(+ inArray(monitor.id, monitorIds),+ eq(monitor.workspaceId, opts.ctx.workspace.id),+ isNull(monitor.deletedAt),+ ),});- }- }),++ if (allMonitors.length !== monitorIds.length) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "You don't have access to all the monitors.",+ });+ }+ }++ // TODO: check for monitor order!+ const currentMonitorsToPages = await opts.ctx.db+ .select()+ .from(monitorsToPages)+ .where(eq(monitorsToPages.pageId, currentPage.id))+ .all();++ const removedMonitors = currentMonitorsToPages+ .map(({ monitorId }) => monitorId)+ .filter((x) => !monitorIds?.includes(x));++ if (removedMonitors.length) {+ await opts.ctx.db+ .delete(monitorsToPages)+ .where(+ and(+ inArray(monitorsToPages.monitorId, removedMonitors),+ eq(monitorsToPages.pageId, currentPage.id),+ ),+ );+ }++ const values = monitors.map(({ monitorId }, index) => ({+ pageId: currentPage.id,+ order: index,+ monitorId,+ }));++ if (values.length) {+ await opts.ctx.db+ .insert(monitorsToPages)+ .values(values)+ .onConflictDoUpdate({+ target: [monitorsToPages.monitorId, monitorsToPages.pageId],+ set: { order: sql.raw("excluded.`order`") },+ });+ }+ }),delete: protectedProcedure+ .meta({ track: Events.DeletePage }).input(z.object({ id: z.number() })).mutation(async (opts) => {await opts.ctx.dbdiff --git a/packages/api/src/router/rum/index.ts b/packages/api/src/router/rum/index.tsdeleted file mode 100644index 8c6a60dc2..000000000--- a/packages/api/src/router/rum/index.ts+++ /dev/null@@ -1,33 +0,0 @@-import { z } from "zod";--import { createTRPCRouter, protectedProcedure } from "../../trpc";--const event = z.enum(["CLS", "FCP", "FID", "INP", "LCP", "TTFB"]);--const _RouteData = z.object({- href: z.string(),- total_event: z.coerce.number(),- clsValue: z.number().optional(),- fcpValue: z.number().optional(),- inpValue: z.number().optional(),- lcpValue: z.number().optional(),- ttfbValue: z.number().optional(),-});--export const rumRouter = createTRPCRouter({- GetEventMetricsForWorkspace: protectedProcedure- .input(- z.object({- event: event,- }),- )- .query((_opts) => {- // FIXME: Use tb pipe instead- return null;- }),-- GetAggregatedPerPage: protectedProcedure.query((_opts) => {- // FIXME: Use tb pipe instead- return null;- }),-});diff --git a/packages/api/src/router/stripe/webhook.ts b/packages/api/src/router/stripe/webhook.tsindex d852dbb00..d5b624652 100644--- a/packages/api/src/router/stripe/webhook.ts+++ b/packages/api/src/router/stripe/webhook.ts@@ -2,7 +2,7 @@ import { TRPCError } from "@trpc/server";import type Stripe from "stripe";import { z } from "zod";-import { analytics, trackAnalytics } from "@openstatus/analytics";+import { Events, setupAnalytics } from "@openstatus/analytics";import { eq } from "@openstatus/db";import { user, workspace } from "@openstatus/db/src/schema";@@ -81,14 +81,13 @@ export const webhookRouter = createTRPCRouter({.get();if (!userResult) return;- await analytics.identify(String(userResult.id), {- email: customer.email,- userId: userResult.id,- });- await trackAnalytics({- event: "User Upgraded",- email: customer.email,+ const analytics = await setupAnalytics({+ userId: `usr_${userResult.id}`,+ email: userResult.email || undefined,+ workspaceId: String(result.id),+ plan: plan.plan,});+ await analytics.track(Events.UpgradeWorkspace);}}),customerSubscriptionDeleted: webhookProcedure.mutation(async (opts) => {@@ -98,7 +97,7 @@ export const webhookRouter = createTRPCRouter({? subscription.customer: subscription.customer.id;- await opts.ctx.db+ const _workspace = await opts.ctx.db.update(workspace).set({subscriptionId: null,@@ -106,6 +105,32 @@ export const webhookRouter = createTRPCRouter({paidUntil: null,}).where(eq(workspace.stripeId, customerId))- .run();+ .returning();++ const customer = await stripe.customers.retrieve(customerId);++ if (!_workspace) {+ throw new TRPCError({+ code: "BAD_REQUEST",+ message: "Workspace not found",+ });+ }++ if (!customer.deleted && customer.email) {+ const userResult = await opts.ctx.db+ .select()+ .from(user)+ .where(eq(user.email, customer.email))+ .get();+ if (!userResult) return;++ const analytics = await setupAnalytics({+ userId: `usr_${userResult.id}`,+ email: customer.email || undefined,+ workspaceId: String(_workspace[0].id),+ plan: "free",+ });+ await analytics.track(Events.DowngradeWorkspace);+ }}),});diff --git a/packages/api/src/router/user.ts b/packages/api/src/router/user.tsindex da31dbb99..540a01530 100644--- a/packages/api/src/router/user.ts+++ b/packages/api/src/router/user.ts@@ -1,5 +1,3 @@-import { z } from "zod";-import { eq } from "@openstatus/db";import { user } from "@openstatus/db/src/schema";diff --git a/packages/api/src/router/workspace.ts b/packages/api/src/router/workspace.tsindex 545505b78..d747cabdf 100644--- a/packages/api/src/router/workspace.ts+++ b/packages/api/src/router/workspace.ts@@ -1,9 +1,8 @@import { TRPCError } from "@trpc/server";-import { generateSlug } from "random-word-slugs";import * as randomWordSlugs from "random-word-slugs";import { z } from "zod";-import { and, eq, isNotNull, isNull, sql } from "@openstatus/db";+import { and, eq, isNull, sql } from "@openstatus/db";import {application,monitor,diff --git a/packages/api/src/trpc.ts b/packages/api/src/trpc.tsindex 32b7e3dc7..48127ff6c 100644--- a/packages/api/src/trpc.ts+++ b/packages/api/src/trpc.ts@@ -1,8 +1,14 @@import { TRPCError, initTRPC } from "@trpc/server";-import type { NextRequest } from "next/server";+import { type NextRequest, after } from "next/server";import superjson from "superjson";import { ZodError } from "zod";+import {+ type EventProps,+ type IdentifyProps,+ parseInputToProps,+ setupAnalytics,+} from "@openstatus/analytics";import { db, eq, schema } from "@openstatus/db";import type { User, Workspace } from "@openstatus/db/src/schema";@@ -28,6 +34,11 @@ type CreateContextOptions = {req?: NextRequest;};+type Meta = {+ track?: EventProps;+ trackProps?: string[];+};+/*** This helper generates the "internals" for a tRPC context. If you need to use* it, you can export it from here@@ -73,19 +84,22 @@ export type Context = Awaited<ReturnType<typeof createTRPCContext>>;* This is where the trpc api is initialized, connecting the context and* transformer*/-export const t = initTRPC.context<typeof createTRPCContext>().create({- transformer: superjson,- errorFormatter({ shape, error }) {- return {- ...shape,- data: {- ...shape.data,- zodError:- error.cause instanceof ZodError ? error.cause.flatten() : null,- },- };- },-});+export const t = initTRPC+ .context<Context>()+ .meta<Meta>()+ .create({+ transformer: superjson,+ errorFormatter({ shape, error }) {+ return {+ ...shape,+ data: {+ ...shape.data,+ zodError:+ error.cause instanceof ZodError ? error.cause.flatten() : null,+ },+ };+ },+ });/*** 3. ROUTER & PROCEDURE (THE IMPORTANT BIT)@@ -114,7 +128,8 @@ export const publicProcedure = t.procedure;* Reusable middleware that enforces users are logged in before running the* procedure*/-const enforceUserIsAuthed = t.middleware(async ({ ctx, next }) => {+const enforceUserIsAuthed = t.middleware(async (opts) => {+ const { ctx } = opts;if (!ctx.session?.user?.id) {throw new TRPCError({ code: "UNAUTHORIZED" });}@@ -173,13 +188,42 @@ const enforceUserIsAuthed = t.middleware(async ({ ctx, next }) => {const user = schema.selectUserSchema.parse(userProps);const workspace = schema.selectWorkspaceSchema.parse(activeWorkspace);- return next({- ctx: {- ...ctx,- user,- workspace,- },+ const result = await opts.next({ ctx: { ...ctx, user, workspace } });++ if (process.env.NODE_ENV === "test") {+ return result;+ }++ // REMINDER: We only track the event if the request was successful+ if (!result.ok) {+ return result;+ }++ // REMINDER: We only track the event if the request was successful+ // REMINDER: We are not blocking the request+ after(async () => {+ const { ctx, meta, getRawInput } = opts;+ if (meta?.track) {+ let identify: IdentifyProps = {};++ if (ctx.user && ctx.workspace) {+ identify = {+ userId: `usr_${ctx.user.id}`,+ email: ctx.user.email || undefined,+ workspaceId: String(ctx.workspace.id),+ plan: ctx.workspace.plan,+ };+ }++ const analytics = await setupAnalytics(identify);+ const rawInput = await getRawInput();+ const additionalProps = parseInputToProps(rawInput, meta.trackProps);++ await analytics.track({ ...meta.track, ...additionalProps });+ }});++ return result;});/**@@ -193,6 +237,7 @@ export const formdataMiddleware = t.middleware(async (opts) => {input: formData,});});+/*** Protected (authed) procedure*diff --git a/packages/db/src/schema/plan/config.ts b/packages/db/src/schema/plan/config.tsindex 87143d127..4e2a228c9 100644--- a/packages/db/src/schema/plan/config.ts+++ b/packages/db/src/schema/plan/config.ts@@ -6,6 +6,7 @@ export const allPlans: Record<WorkspacePlan,{title: "Hobby" | "Starter" | "Growth" | "Pro";+ id: WorkspacePlan;description: string;price: number;limits: Limits;@@ -13,6 +14,7 @@ export const allPlans: Record<> = {free: {title: "Hobby",+ id: "free",description: "For personal projects",price: 0,limits: {@@ -42,6 +44,7 @@ export const allPlans: Record<},starter: {title: "Starter",+ id: "starter",description: "For small projects",price: 30,limits: {@@ -107,6 +110,7 @@ export const allPlans: Record<},team: {title: "Growth",+ id: "team",description: "For small teams",price: 100,limits: {@@ -172,6 +176,7 @@ export const allPlans: Record<},pro: {title: "Pro",+ id: "pro",description: "For bigger teams",price: 300,limits: {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 087f6726b..36104bd5a 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -359,12 +359,6 @@ importers:nuqs:specifier: 2.2.3version: 2.2.3([email protected](@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected])- posthog-js:- specifier: 1.136.1- version: 1.136.1- posthog-node:- specifier: 4.0.1- version: 4.0.1random-word-slugs:specifier: 0.1.7version: 0.1.7@@ -465,9 +459,6 @@ importers:rehype-slug:specifier: 5.1.0version: 5.1.0- remark-gfm:- specifier: 3.0.1- version: 3.0.1tailwindcss:specifier: 3.4.3@@ -511,6 +502,9 @@ importers:'@jitsu/js':specifier: 1.9.2version: 1.9.2(@types/[email protected])+ '@openpanel/sdk':+ specifier: ^1.0.0+ version: 1.0.0'@t3-oss/env-core':specifier: 0.7.0version: 0.7.0([email protected])([email protected])@@ -3029,6 +3023,9 @@ packages:'@one-ini/[email protected]':resolution: {integrity: sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw==}+ '@openpanel/[email protected]':+ resolution: {integrity: sha512-FNmmfjdXoC/VHEjA+WkrQ4lyM5lxEmV7xDd57uj4E+lIS0sU3DLG2mV/dpS8AscnZbUvuMn3kPhiLCqYzuv/gg==}+'@opentelemetry/[email protected]':resolution: {integrity: sha512-qnSqB2DQ9TPP96dl8cDubDvrUyWc0/sK81xHTK8eSUspzDM3bsewX903qclQFvVhgStjRWdC5bLb3kQqMkfV5A==}engines: {node: '>=14'}@@ -6616,9 +6613,6 @@ packages:resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}engines: {node: ^12.20 || >= 14.13}- resolution: {integrity: sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==}-resolution: {integrity: sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==}engines: {node: '>=8'}@@ -7639,9 +7633,6 @@ packages:resolution: {integrity: sha512-JUpYOqKI4mM3sZcNxmF/ox04XYFFkNwr0CFlrQIkCwbvH0xzMCqkMqAde9wRd80VAhaUrwFwKm2nxretdT1h7Q==}- resolution: {integrity: sha512-MTtdFRz/eMDHXzeK6W3dO7mXUlF82Gom4y0oOgvHhh/HXZAGvIQDUvQ0SuUx+j2tv44b8xTHOm8K/9OoRFnXKw==}-resolution: {integrity: sha512-SG21kZHGC3XRTSUhtofZkBzZTJNM5ecCi0SK2IMKmSXR8vO3peL+kb1O0z7Zl83jKtutG4k5Wv/W7V3/YHvzPA==}@@ -7654,39 +7645,21 @@ packages:resolution: {integrity: sha512-LRqI9+wdgC25P0URIJY9vwocIzCcksduHQ9OF2joxQoyTNVduwLAFUzjoopuRJbJAReaKrNQKAZKL3uCMugWJA==}- resolution: {integrity: sha512-My8KJ57FYEy2W2LyNom4n3E7hKTuQk/0SES0u16tjA9Z3oFkF4RrC/hPAPgjlSpezsOvI8ObcXcElo92wn5IGA==}-resolution: {integrity: sha512-FyzMsduZZHSc3i0Px3PQcBT4WJY/X/RCtEJKuybiC6sjPqLv7h1yqAkmILZtuxMSsUyaLUWNp71+vQH2zqp5cg==}- resolution: {integrity: sha512-56D19KOGbE00uKVj3sgIykpwKL179QsVFwx/DCW0u/0+URsryacI4MAdNJl0dh+u2PSsD9FtxPFbHCzJ78qJFQ==}-resolution: {integrity: sha512-5jOT2boTSVkMnQ7LTrd6n/18kqwjmuYqo7JUPe+tRCY6O7dAuTFMtTPauYYrMPpox9hlN0uOx/FL8XvEfG9/mQ==}- resolution: {integrity: sha512-DAPhYzTYrRcXdMjUtUjKvW9z/FNAMTdU0ORyMcbmkwYNbKocDpdk+PX1L1dQgOID/+vVs1uBQ7ElrBQfZ0cuiQ==}-resolution: {integrity: sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==}- resolution: {integrity: sha512-jjcpmNnQvrmN5Vx7y7lEc2iIOEytYv7rTvu+MeyAsSHTASGCCRA79Igg2uKssgOs1i1po8s3plW0sTu1wkkLGg==}-resolution: {integrity: sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==}- resolution: {integrity: sha512-PFTA1gzfp1B1UaiJVyhJZA1rm0+Tzn690frc/L8vNX1Jop4STZgOE6bxUhnzdVSB+vm2GU1tIsuQcA9bxTQpMQ==}-resolution: {integrity: sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==}- resolution: {integrity: sha512-qvZ608nBppZ4icQlhQQIAdc6S3Ffj9RGmzwUKUWuEICFnd1LVkN3EktF7ZHAgfcEdvZB5owU9tQgt99e2TlLjg==}-resolution: {integrity: sha512-dgQEX5Amaq+DuUqf26jJqSK9qgixgd6rYDHAv4aTBuA92cTknZlKpPfa86Z/s8Dj8xsAQpFfBmPUHWJBWqS4Bw==}@@ -7702,9 +7675,6 @@ packages:resolution: {integrity: sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==}- resolution: {integrity: sha512-WmI1gTXUBJo4/ZmSk79Wcb2HcjPJBzM1nlI/OUWA8yk2X9ik3ffNbBGsU+09BFmXaL1IBb9fiuvq6/KMiNycSg==}-resolution: {integrity: sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==}@@ -7714,9 +7684,6 @@ packages:resolution: {integrity: sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==}- resolution: {integrity: sha512-bbv7TPv/WC49thZPg3jXuqzuvI45IL2EVAr/KxF0BSdHsU0ceFHOmwQn6evxAh1GaoK/6GQ1wp4R4oW2+LFL/A==}-resolution: {integrity: sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==}@@ -7751,45 +7718,24 @@ packages:resolution: {integrity: sha512-C4AkuM3dA58cgZha7zVnuVxBhDsbttIMiytjgsM2XbHAB2faRVaHRle40558FBN+DJcrLNCoqG5mlrpdU4cRtg==}- resolution: {integrity: sha512-z3wJSLrDf8kRDOh2qBtoTRD53vJ+CWIyo7uyZuxf/JAbNJjiHsOpG1y5wxk8drtv3ETAHutCu6N3thkOOgueWg==}-resolution: {integrity: sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==}- resolution: {integrity: sha512-Yxn7z7SxgyGWRNa4wzf8AhYYWNrwl5q1Z8ii+CSTTIqVkmGZF1CElX2JI8g5yGoM3GAman9/PVCUFUSJ0kB/8Q==}-resolution: {integrity: sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==}- resolution: {integrity: sha512-sX0FawVE1o3abGk3vRjOH50L5TTLr3b5XMqnP9YDRb34M0v5OoZhG+OHFz1OffZ9dlwgpTBKaT4XW/AsUVnSDw==}-resolution: {integrity: sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==}- resolution: {integrity: sha512-3ZORTHtcSnMQEKtAOsBQ9/oHp9096pI/UvdPtN7ehKvrmZZ2+bbWhi0ln+I9drmwXMt5boocn6OlwQzNXeVeqw==}-resolution: {integrity: sha512-Ub2ncQv+fwD70/l4ou27b4YzfNaCJOvyX4HxXU15m7mpYY+rjuWzsLIPZHJL253Z643RpbcP1oeIJlQ/SKW67g==}- resolution: {integrity: sha512-5XWB9GbAUSHTn8VPU8/1DBXMuKYT5uOgEjJb8gN3mW0PNW5OPHpSdojoqf+iq1xo7vWzw/P8bAHY0n6ijpXF7g==}-resolution: {integrity: sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==}- resolution: {integrity: sha512-RMFXl2uQ0pNQy6Lun2YBYT9g9INXtWJULgbt01D/x8/6yJ2qpKyzdZD3pi6UIkzF++Da49xAelVKUeUMqd5eIQ==}-resolution: {integrity: sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==}- resolution: {integrity: sha512-vb9OoHqrhCmbRidQv/2+Bc6pkP0FrtlhurxZofvOEy5o8RtuuvTq+RQ1Vw5ZDNrVraQZu3HixESqbG+0iKk/MQ==}-resolution: {integrity: sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==}@@ -8609,13 +8555,6 @@ packages:resolution: {integrity: sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w==}- resolution: {integrity: sha512-hM3PCDtPdyzO52l0FXEFAw1sI6PJm1U9U3MVanAcrOY3QgeJ+z241OnYm5XMrTyDF5ImCTWzq4p23moLQSZvDA==}-- resolution: {integrity: sha512-rtqm2h22QxLGBrW2bLYzbRhliIrqgZ0k+gF0LkQ1SNdeD06YE5eilV0MxZppFSxC8TfH0+B0cWCuebEnreIDgQ==}- engines: {node: '>=15.0.0'}-resolution: {integrity: sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==}peerDependencies:@@ -8624,9 +8563,6 @@ packages:resolution: {integrity: sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==}- resolution: {integrity: sha512-RRurnSjJPj4rp5K6XoP45Ui33ncb7e4H7WiOHVpjbkvqvA3U+N8Z6Qbo0AE6leGYBV66n8EhEaFixvIu3SkxFw==}-resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==}engines: {node: '>=10'}@@ -8967,9 +8903,6 @@ packages:resolution: {integrity: sha512-XTFYvNASMe5iPN0719nPrdItC9aU0ssC4v14mH1BCi1u0n1gAocqcujWUrByftZTbLhRtiKRyjYTSIOcr69UVQ==}- resolution: {integrity: sha512-lEFDoi2PICJyNrACFOfDD3JlLkuSbOa5Wd8EPt06HUdptv8Gn0bxYTdbU/XXQ3swAPkEaGxxPN9cbnMHvVu1Ig==}-resolution: {integrity: sha512-U92vJgBPkbw4Zfu/IiW2oTZLSL3Zpv+uI7My2eq8JxKgqraFdU8YUGicEJCEgSbeaG+QDFqIcwwfMTOEelPxuA==}@@ -9105,9 +9038,6 @@ packages:resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}- resolution: {integrity: sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA==}-resolution: {integrity: sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==}engines: {npm: '>=2.0.0'}@@ -9261,8 +9191,8 @@ packages:react: ^18.0.0 || ^19.0.0 || ^19.0.0-rcreact-dom: ^18.0.0 || ^19.0.0 || ^19.0.0-rc- resolution: {integrity: sha512-Pdz01AvCAottHTPQGzndktFNdbRA75BgOfeT1hH+AMnJFv8lynkPi42rfeEhpx1saTEI3YNMWxfqu0sFD1G8pw==}+ resolution: {integrity: sha512-aSbHV0DaBcr7u0PVHXzM6NbZNAtrr9sF6+Qfs9UUVG7Ll3jQ6hHi8F/xqIIcn2rvIVbr0v/2zyjSdwSV47AgLQ==}engines: {node: '>=12'}@@ -12570,6 +12500,8 @@ snapshots:'@one-ini/[email protected]': {}+ '@openpanel/[email protected]': {}+'@opentelemetry/[email protected]':dependencies:'@opentelemetry/api': 1.9.0@@ -13868,7 +13800,7 @@ snapshots:nanoid: 5.0.7postcss-nested: 6.0.1([email protected])unhead: 1.9.15- unified: 11.0.4+ unified: 11.0.5vue: 3.4.31([email protected])transitivePeerDependencies:- '@jest/globals'@@ -16836,8 +16768,6 @@ snapshots:node-domexception: 1.0.0web-streams-polyfill: 3.2.1- [email protected]: {}-dependencies:escape-string-regexp: 1.0.5@@ -17168,7 +17098,7 @@ snapshots:dependencies:is-obj: 3.0.0- sort-keys: 5.0.0+ sort-keys: 5.1.0type-fest: 1.4.0@@ -18029,13 +17959,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- '@types/mdast': 3.0.14- escape-string-regexp: 5.0.0- unist-util-is: 5.2.1- unist-util-visit-parents: 5.1.3-dependencies:'@types/mdast': 4.0.4@@ -18088,13 +18011,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- '@types/mdast': 3.0.14- ccount: 2.0.1- mdast-util-find-and-replace: 2.2.2- micromark-util-character: 1.2.0-dependencies:'@types/mdast': 4.0.4@@ -18103,12 +18019,6 @@ snapshots:mdast-util-find-and-replace: 3.0.1micromark-util-character: 2.1.0- dependencies:- '@types/mdast': 3.0.14- mdast-util-to-markdown: 1.5.0- micromark-util-normalize-identifier: 1.1.0-dependencies:'@types/mdast': 4.0.4@@ -18119,11 +18029,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- '@types/mdast': 3.0.14- mdast-util-to-markdown: 1.5.0-dependencies:'@types/mdast': 4.0.4@@ -18132,15 +18037,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- '@types/mdast': 3.0.14- markdown-table: 3.0.3- mdast-util-from-markdown: 1.3.1- mdast-util-to-markdown: 1.5.0- transitivePeerDependencies:- - supports-color-dependencies:'@types/mdast': 4.0.4@@ -18151,11 +18047,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- '@types/mdast': 3.0.14- mdast-util-to-markdown: 1.5.0-dependencies:'@types/mdast': 4.0.4@@ -18165,18 +18056,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- mdast-util-from-markdown: 1.3.1- mdast-util-gfm-autolink-literal: 1.0.3- mdast-util-gfm-footnote: 1.0.2- mdast-util-gfm-strikethrough: 1.0.3- mdast-util-gfm-table: 1.0.7- mdast-util-gfm-task-list-item: 1.0.2- mdast-util-to-markdown: 1.5.0- transitivePeerDependencies:- - supports-color-dependencies:mdast-util-from-markdown: 2.0.1@@ -18238,11 +18117,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- '@types/mdast': 3.0.14- unist-util-is: 5.2.1-dependencies:'@types/mdast': 4.0.4@@ -18271,17 +18145,6 @@ snapshots:unist-util-visit: 5.0.0vfile: 6.0.3- dependencies:- '@types/mdast': 3.0.14- '@types/unist': 2.0.9- longest-streak: 3.1.0- mdast-util-phrasing: 3.0.1- mdast-util-to-string: 3.2.0- micromark-util-decode-string: 1.1.0- unist-util-visit: 4.1.2- zwitch: 2.0.4-dependencies:'@types/mdast': 4.0.4@@ -18376,13 +18239,6 @@ snapshots:micromark-util-symbol: 2.0.0micromark-util-types: 2.0.0- dependencies:- micromark-util-character: 1.2.0- micromark-util-sanitize-uri: 1.2.0- micromark-util-symbol: 1.1.0- micromark-util-types: 1.1.0-dependencies:micromark-util-character: 2.1.0@@ -18390,17 +18246,6 @@ snapshots:micromark-util-symbol: 2.0.0micromark-util-types: 2.0.0- dependencies:- micromark-core-commonmark: 1.1.0- micromark-factory-space: 1.1.0- micromark-util-character: 1.2.0- micromark-util-normalize-identifier: 1.1.0- micromark-util-sanitize-uri: 1.2.0- micromark-util-symbol: 1.1.0- micromark-util-types: 1.1.0- uvu: 0.5.6-dependencies:devlop: 1.1.0@@ -18412,15 +18257,6 @@ snapshots:micromark-util-symbol: 2.0.0micromark-util-types: 2.0.0- dependencies:- micromark-util-chunked: 1.1.0- micromark-util-classify-character: 1.1.0- micromark-util-resolve-all: 1.1.0- micromark-util-symbol: 1.1.0- micromark-util-types: 1.1.0- uvu: 0.5.6-dependencies:devlop: 1.1.0@@ -18430,14 +18266,6 @@ snapshots:micromark-util-symbol: 2.0.0micromark-util-types: 2.0.0- dependencies:- micromark-factory-space: 1.1.0- micromark-util-character: 1.2.0- micromark-util-symbol: 1.1.0- micromark-util-types: 1.1.0- uvu: 0.5.6-dependencies:devlop: 1.1.0@@ -18446,22 +18274,10 @@ snapshots:micromark-util-symbol: 2.0.0micromark-util-types: 2.0.0- dependencies:- micromark-util-types: 1.1.0-dependencies:micromark-util-types: 2.0.0- dependencies:- micromark-factory-space: 1.1.0- micromark-util-character: 1.2.0- micromark-util-symbol: 1.1.0- micromark-util-types: 1.1.0- uvu: 0.5.6-dependencies:devlop: 1.1.0@@ -18470,17 +18286,6 @@ snapshots:micromark-util-symbol: 2.0.0micromark-util-types: 2.0.0- dependencies:- micromark-extension-gfm-autolink-literal: 1.0.5- micromark-extension-gfm-footnote: 1.1.2- micromark-extension-gfm-strikethrough: 1.0.7- micromark-extension-gfm-table: 1.0.7- micromark-extension-gfm-tagfilter: 1.0.2- micromark-extension-gfm-task-list-item: 1.0.5- micromark-util-combine-extensions: 1.1.0- micromark-util-types: 1.1.0-dependencies:micromark-extension-gfm-autolink-literal: 2.1.0@@ -19501,18 +19306,6 @@ snapshots:optional: true- dependencies:- fflate: 0.4.8- preact: 10.22.0-- dependencies:- axios: 1.7.2- rusha: 0.8.14- transitivePeerDependencies:- - debug-dependencies:preact: 10.11.3@@ -19520,8 +19313,6 @@ snapshots:- [email protected]: {}-dependencies:detect-libc: 2.0.2@@ -19950,7 +19741,7 @@ snapshots:dependencies:'@types/hast': 3.0.4- hast-util-from-html: 2.0.1+ hast-util-from-html: 2.0.3unified: 11.0.5@@ -20035,15 +19826,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- '@types/mdast': 3.0.14- mdast-util-gfm: 2.0.2- micromark-extension-gfm: 2.0.3- unified: 10.1.2- transitivePeerDependencies:- - supports-color-dependencies:'@types/mdast': 4.0.4@@ -20279,8 +20061,6 @@ snapshots:dependencies:queue-microtask: 1.2.3- [email protected]: {}-dependencies:tslib: 1.14.1@@ -20488,7 +20268,7 @@ snapshots:react: 19.0.0react-dom: 19.0.0([email protected])dependencies:is-plain-obj: 4.1.0