Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/junior/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
"./vercel": {
"types": "./dist/vercel.d.ts",
"default": "./dist/vercel.js"
},
"./version": {
"types": "./dist/version.d.ts",
"default": "./dist/version.js"
}
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions packages/junior/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { createAgentRunner } from "@/chat/runtime/agent-runner";
import type { WaitUntilFn } from "@/handlers/types";

export { defineJuniorPlugins } from "./plugins";
export { JUNIOR_VERSION } from "./version";
export type {
JuniorPluginInput,
JuniorPluginSet,
Expand Down
3 changes: 3 additions & 0 deletions packages/junior/src/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { JUNIOR_VERSION } from "@/version";

export const JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";
export const JUNIOR_HEARTBEAT_CRON_SCHEDULE = "* * * * *";
export const JUNIOR_RETENTION_ROUTE = "/api/internal/retention";
Expand Down Expand Up @@ -28,6 +30,7 @@ export function getDeploymentTelemetryAttributes(): Record<string, string> {
const attributes: Record<string, string> = {};
const serviceVersion = getDeploymentServiceVersion();
const deploymentId = toOptionalTrimmed(process.env.VERCEL_DEPLOYMENT_ID);
attributes["app.junior.version"] = JUNIOR_VERSION;
if (serviceVersion) {
attributes["service.version"] = serviceVersion;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/junior/src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import packageMetadata from "../package.json" with { type: "json" };

/** Installed Junior package version, or `unknown` when package metadata is unavailable. */
export const JUNIOR_VERSION =
typeof packageMetadata.version === "string" && packageMetadata.version.trim()
? packageMetadata.version
: "unknown";
2 changes: 2 additions & 0 deletions packages/junior/tests/unit/instrumentation.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { JUNIOR_VERSION } from "@/version";
import { runWithConversationPrivacy } from "@/chat/conversation-privacy";

const ORIGINAL_SENTRY_DSN = process.env.SENTRY_DSN;
Expand Down Expand Up @@ -114,6 +115,7 @@ describe("initSentry", () => {

expect(globalScope.setAttributes).toHaveBeenCalledWith(
expect.objectContaining({
"app.junior.version": JUNIOR_VERSION,
"deployment.id": "dpl_123",
"service.version": "git-sha",
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { JUNIOR_VERSION } from "@/version";
import type { EmittedLogRecord } from "@/chat/logging";

const ORIGINAL_SENTRY_RELEASE = process.env.SENTRY_RELEASE;
Expand Down Expand Up @@ -72,6 +73,7 @@ describe("deployment log attributes", () => {

expect(records).toHaveLength(1);
expect(records[0]?.attributes).toMatchObject({
"app.junior.version": JUNIOR_VERSION,
"deployment.id": "dpl_123",
"service.version": "git-sha",
});
Expand Down
1 change: 1 addition & 0 deletions packages/junior/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"src/nitro.ts",
"src/reporting.ts",
"src/vercel.ts",
"src/version.ts",
"src/virtual-modules.d.ts"
]
}
1 change: 1 addition & 0 deletions packages/junior/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default defineConfig({
instrumentation: "src/instrumentation.ts",
nitro: "src/nitro.ts",
vercel: "src/vercel.ts",
version: "src/version.ts",
},
format: "esm",
tsconfig: "tsconfig.build.json",
Expand Down
Loading