diff --git a/biome.json b/biome.json index 925b741..351a1a3 100644 --- a/biome.json +++ b/biome.json @@ -23,6 +23,12 @@ } }, "overrides": [ + { + "includes": ["docs/stylesheets/**"], + "linter": { + "enabled": false + } + }, { "includes": ["**/*.test.ts"], "linter": { diff --git a/packages/server/rpc/handler.ts b/packages/server/rpc/handler.ts index b0d94c1..87504c8 100644 --- a/packages/server/rpc/handler.ts +++ b/packages/server/rpc/handler.ts @@ -127,11 +127,33 @@ export async function handleRpcRequest( return json(invalidParams(requestId, formatZodError(paramsResult.error))); } + // Build identity attributes from auth context + const identityAttrs: Record = {}; + const ctx = context as Record; + if (ctx.engine && typeof ctx.engine === "object") { + const engine = ctx.engine as { + id?: string; + orgId?: string; + slug?: string; + }; + if (engine.id) identityAttrs["engine.id"] = engine.id; + if (engine.orgId) identityAttrs["org.id"] = engine.orgId; + if (engine.slug) identityAttrs["engine.slug"] = engine.slug; + } + if (typeof ctx.userId === "string") identityAttrs["user.id"] = ctx.userId; + if (typeof ctx.apiKeyId === "string") + identityAttrs["api_key.id"] = ctx.apiKeyId; + if (ctx.identity && typeof ctx.identity === "object") { + const identity = ctx.identity as { id?: string }; + if (identity.id) identityAttrs["identity.id"] = identity.id; + } + // Execute handler in a span const result = await span(`rpc.${rpcRequest.method}`, { attributes: { "rpc.method": rpcRequest.method, "rpc.request_id": String(requestId), + ...identityAttrs, }, callback: async () => { const handlerContext: HandlerContext = {