mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
Extends the sweep beyond packages/ to the whole repo (178 files): workflows,
.eslintrc, playground, examples, tooling, root docs. Zero upstream-brand refs and
zero such filenames outside the exemptions.
REVERTS A LICENSING ERROR (from earlier rebrand e43ab1af, not this sweep):
- LICENSE had its copyright holder rewritten to 'Insights'. Restored to the real
holder: 'Copyright 2020 Posthog / Hiberly, Inc.' (+ Mixpanel, Inc.).
- NOTICE credited a non-existent upstream (github.com/getinsights/insights-js).
Restored to the real one: github.com/PostHog/posthog-js.
Apache-2.0 4(c) requires retaining upstream attribution; rewriting a third
party's copyright line falsifies ownership. Both files are now excluded from the
guard and documented as exempt in LLM.md.
Also:
- Deleted junk: AGENTS.md~upstream_main (merge leftover), the now-obsolete
rebrand script; renamed upload-*-s3.ts tooling (still used by cli.ts).
- Removed 42 stale playground/example pnpm-lock.yaml files: they pinned upstream
packages the package.json no longer references. Regenerated on install —
sed-ing a lockfile would corrupt its integrity hashes.
- Guard renamed no-posthog.yml -> brand-guard.yml and now assembles the pattern
at runtime, so no filename or file content carries the string (the previous
guard was swept by its own rule, inverting it to forbid 'insights').
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
/**
|
|
* Convex-style OpenTelemetry integration with Insights.
|
|
*
|
|
* This example shows how to use the Insights OTEL span processor with the
|
|
* Vercel AI SDK, which is the pattern used in Convex actions.
|
|
* In a real Convex app, this code runs inside a "use node" action.
|
|
*/
|
|
|
|
import { NodeSDK } from '@opentelemetry/sdk-node'
|
|
import { resourceFromAttributes } from '@opentelemetry/resources'
|
|
import { InsightsSpanProcessor } from '@hanzo/insights-ai/otel'
|
|
import { generateText } from 'ai'
|
|
import { openai } from '@ai-sdk/openai'
|
|
|
|
const sdk = new NodeSDK({
|
|
resource: resourceFromAttributes({
|
|
'service.name': 'example-convex-app',
|
|
foo: 'bar',
|
|
conversation_id: 'abc-123',
|
|
}),
|
|
spanProcessors: [
|
|
new InsightsSpanProcessor({
|
|
apiKey: process.env.INSIGHTS_API_KEY!,
|
|
host: process.env.INSIGHTS_HOST || 'https://us.i.insights.com',
|
|
}),
|
|
],
|
|
})
|
|
sdk.start()
|
|
|
|
async function main() {
|
|
const result = await generateText({
|
|
model: openai('gpt-4o-mini'),
|
|
prompt: 'Tell me a fun fact about hedgehogs.',
|
|
experimental_telemetry: {
|
|
isEnabled: true,
|
|
functionId: 'example-convex-action',
|
|
metadata: {
|
|
insights_distinct_id: 'example-user',
|
|
},
|
|
},
|
|
})
|
|
|
|
console.log(result.text)
|
|
}
|
|
|
|
main().finally(() => sdk.shutdown())
|