Skip to content
Merged
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: 3 additions & 1 deletion packages/preset-nuxt4/src/features/mastra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
/** Mastra AI runtime. Talks to an OpenAI-compatible AI gateway (sluis.ai preset, or any compatible URL) via `@ai-sdk/openai-compatible`. */
export const mastraFeature: Feature = {
id: 'nuxt4:mastra',
version: '2.1.1',
version: '2.1.2',
label: 'Mastra AI runtime',
frameworks: ['nuxt4'],
stage: STAGE.AI_CORE,
Expand Down Expand Up @@ -305,6 +305,8 @@ export const mastraFeature: Feature = {
const env: Record<string, string> = {}
for (const [k, v] of await readDotEnv(ctx.projectDir)) env[k] = v
env.PORT = String(port)
// The CLI reports its own analytics to PostHog; same opt-out as the runtime in server/mastra/index.ts.
env.MASTRA_TELEMETRY_DISABLED ??= 'true'
// `mastra dev` reads PORT from env, defaulting to 4111.
await run(pm, ['exec', 'mastra', 'dev', '--dir', 'server/mastra'], {
cwd: ctx.projectDir,
Expand Down
3 changes: 3 additions & 0 deletions packages/preset-nuxt4/templates/mastra/server/mastra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ if (!databaseUrl) {
throw new Error('NUXT_DATABASE_URL is not set in `.env`.')
}

// Mastra sends usage telemetry to PostHog (US) unless told not to; opt back in with `MASTRA_TELEMETRY_DISABLED=false`.
process.env.MASTRA_TELEMETRY_DISABLED ??= 'true'

const storage = new PostgresStore({
id: 'mastra-storage',
connectionString: databaseUrl,
Expand Down
9 changes: 9 additions & 0 deletions packages/preset-nuxt4/test/ai-gateway-templates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,12 @@ describe('no legacy gateway wiring remains anywhere in templates', () => {
expect(src).not.toMatch(LEGACY)
})
})

describe('Mastra telemetry', () => {
it('is off by default before the Mastra instance is created', async () => {
const src = await read('mastra', 'server', 'mastra', 'index.ts')
const optOut = src.indexOf("process.env.MASTRA_TELEMETRY_DISABLED ??= 'true'")
expect(optOut).toBeGreaterThan(-1)
expect(optOut).toBeLessThan(src.indexOf('new Mastra('))
})
})
Loading