mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The five days of upstream evolution since the 2026-08-01 import land through bin/debrand: new query schema, billing counters, ducklake compaction, the desktop sandbox default, capture evolution. Ours' invariants hold everywhere they met it: IAM-native auth only, no ee, no upsell surfaces, one sessions model, org-is-the-tenant, v1-first serving, fail-closed capture. Crates and workflows the fork retired stay retired; the Lemon prefix finishes dissolving into elements.
128 lines
5.5 KiB
TypeScript
128 lines
5.5 KiB
TypeScript
import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/shared/OnboardingDocsContentWrapper'
|
|
|
|
import { StepDefinition } from '../steps'
|
|
|
|
export const getEveSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {
|
|
const { Blockquote, CodeBlock, Markdown, dedent, snippets } = ctx
|
|
|
|
const NotableGenerationProperties = snippets?.NotableGenerationProperties
|
|
|
|
return [
|
|
{
|
|
title: 'Install dependencies',
|
|
badge: 'required',
|
|
content: (
|
|
<>
|
|
<Markdown>
|
|
Install Insights AI, its OpenTelemetry peer dependencies, and Vercel's OpenTelemetry package.
|
|
</Markdown>
|
|
|
|
<CodeBlock
|
|
language="bash"
|
|
code={dedent`
|
|
npm install @hanzo/ai @opentelemetry/api @opentelemetry/exporter-trace-otlp-http @opentelemetry/sdk-trace-base @vercel/otel
|
|
`}
|
|
/>
|
|
|
|
<Blockquote>
|
|
<Markdown>
|
|
**Version note:** This example uses `projectToken`, which is available in `@hanzo/ai`
|
|
7.19.6 and later. Earlier 7.x versions use `apiKey`.
|
|
</Markdown>
|
|
</Blockquote>
|
|
</>
|
|
),
|
|
},
|
|
{
|
|
title: 'Set environment variables',
|
|
badge: 'required',
|
|
content: (
|
|
<>
|
|
<Markdown>Set your Insights project token and host in your Eve project's environment.</Markdown>
|
|
|
|
<CodeBlock
|
|
language="bash"
|
|
code={dedent`
|
|
INSIGHTS_PROJECT_TOKEN=<ph_project_token>
|
|
INSIGHTS_HOST=<ph_client_api_host>
|
|
`}
|
|
/>
|
|
</>
|
|
),
|
|
},
|
|
{
|
|
title: 'Add Eve instrumentation',
|
|
badge: 'required',
|
|
content: (
|
|
<>
|
|
<Markdown>
|
|
Create `agent/instrumentation.ts`. Eve discovers this file and starts the exporter when your
|
|
agent server starts. The optional `events` handler uses [Eve runtime
|
|
context](https://eve.dev/docs/guides/instrumentation#runtime-context) to identify spans with the
|
|
user who started the session, falling back to the caller for the current turn.
|
|
</Markdown>
|
|
|
|
<CodeBlock
|
|
language="typescript"
|
|
code={dedent`
|
|
import { trace } from '@opentelemetry/api'
|
|
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
|
|
import { InsightsTraceExporter } from '@hanzo/ai/otel'
|
|
import { registerOTel } from '@vercel/otel'
|
|
import { defineInstrumentation } from 'eve/instrumentation'
|
|
|
|
export default defineInstrumentation({
|
|
setup: ({ agentName }) =>
|
|
registerOTel({
|
|
serviceName: agentName,
|
|
spanProcessors: [
|
|
new SimpleSpanProcessor(
|
|
new InsightsTraceExporter({
|
|
projectToken: process.env.INSIGHTS_PROJECT_TOKEN!,
|
|
host: process.env.INSIGHTS_HOST,
|
|
})
|
|
),
|
|
],
|
|
}),
|
|
// Optional: Link Eve and AI SDK spans to a Insights user.
|
|
events: {
|
|
'step.started'(input) {
|
|
const distinctId =
|
|
input.session.auth.initiator?.principalId ??
|
|
input.session.auth.current?.principalId
|
|
|
|
if (!distinctId) {
|
|
return undefined
|
|
}
|
|
|
|
trace.getActiveSpan()?.setAttribute('insights.distinct_id', distinctId)
|
|
return { runtimeContext: { insights_distinct_id: distinctId } }
|
|
},
|
|
},
|
|
})
|
|
`}
|
|
/>
|
|
|
|
<Blockquote>
|
|
<Markdown>
|
|
**Note:** To capture LLM events anonymously, omit the `events` handler. See our docs on
|
|
[anonymous vs identified
|
|
events](https://hanzo.ai/docs/data/anonymous-vs-identified-events) to learn more.
|
|
</Markdown>
|
|
</Blockquote>
|
|
|
|
<Markdown>
|
|
{dedent`
|
|
You can expect captured \`$ai_generation\` events to have the following properties:
|
|
`}
|
|
</Markdown>
|
|
|
|
{NotableGenerationProperties && <NotableGenerationProperties />}
|
|
</>
|
|
),
|
|
},
|
|
]
|
|
}
|
|
|
|
export const EveInstallation = createInstallation(getEveSteps)
|