Skip to content
Closed
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
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@prismicio/types-internal": "3.16.1",
"@sentry/node-core": "10.42.0",
"@types/node": "25.0.9",
"@vercel/detect-agent": "^1.2.3",
"change-case": "5.4.4",
"concurrently": "^9.2.1",
"cross-env": "^10.1.0",
Expand Down
8 changes: 5 additions & 3 deletions src/clients/wroom.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { determineAgent } from "@vercel/detect-agent";
import * as z from "zod/mini";

import { NotFoundRequestError, request } from "../lib/request";
Expand Down Expand Up @@ -320,14 +321,15 @@ export async function createRepository(config: {
domain: string;
name?: string;
framework: string;
agent: string | undefined;
token: string | undefined;
host: string;
}): Promise<void> {
const { domain, name, framework, agent, token, host } = config;
const { domain, name, framework, token, host } = config;
const url = new URL("app/dashboard/repositories", getDashboardUrl(host));
url.searchParams.set("app", "cli");
if (agent) url.searchParams.set("agent", agent);

const { isAgent, agent } = await determineAgent();
Comment thread
lihbr marked this conversation as resolved.
if (isAgent) url.searchParams.set("agent", agent.name);
Comment on lines +331 to +332
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 #idea: I prefer keeping the clients as a light layer above the API, essentially just a TypeScript wrapper around the endpoints. It helps keep the mental model simple in each area of the CLI.

That being said, I see the benefit of adding it in here.


const body: Record<string, unknown> = { domain, framework, plan: "personal" };
if (name) {
Expand Down
3 changes: 0 additions & 3 deletions src/commands/repo-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getAdapter } from "../adapters";
import { getHost, getToken } from "../auth";
import { completeOnboardingStepsSilently } from "../clients/repository";
import { checkIsDomainAvailable, createRepository } from "../clients/wroom";
import { detectAgent } from "../lib/ai";
import { CommandError, createCommand, type CommandConfig } from "../lib/command";
import { UnknownRequestError } from "../lib/request";

Expand Down Expand Up @@ -68,14 +67,12 @@ export async function createRepo(config: {

const adapter = await getAdapter().catch(() => undefined);
const framework = adapter?.id ?? "other";
const agent = await detectAgent();

try {
await createRepository({
domain,
name: displayName,
framework,
agent,
token,
host,
});
Expand Down
40 changes: 0 additions & 40 deletions src/lib/ai.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/tracking.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { homedir } from "node:os";
import { pathToFileURL } from "node:url";
import { determineAgent } from "@vercel/detect-agent";
import * as z from "zod/mini";

import type { Profile } from "./clients/user";

import { DEFAULT_PRISMIC_HOST, env } from "./env";
import { detectAgent } from "./lib/ai";
import { readJsonFile } from "./lib/file";
import { initSegment, trackEvent, trackIdentity } from "./lib/segment";
import { appendTrailingSlash } from "./lib/url";
Expand All @@ -22,7 +22,8 @@ export async function initTracking(config: { host: string }): Promise<void> {
const enabled = await isTelemetryEnabled();
if (!enabled) return;
const writeKey = host === DEFAULT_PRISMIC_HOST ? PROD_WRITE_KEY : STAGING_WRITE_KEY;
agent = await detectAgent();
const result = await determineAgent();
agent = result.isAgent ? result.agent.name : undefined;
await initSegment({ writeKey });
}

Expand Down