mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the container entrypoint, so the misspelling does not degrade a feature -- it runs migrate --check against a database whose history this tree does not share and the container never starts. Both replacements are measured against the shipped tree rather than chosen: every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL -> INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12 determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_ tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of the bad rule and cannot collide with an upstream name. The rule is fixed for the next convergence, and the tree it already produced is repaired in the same commit -- the codemod is idempotent against its own output, so it cannot undo this itself.
116 lines
4.8 KiB
TypeScript
116 lines
4.8 KiB
TypeScript
import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/shared/OnboardingDocsContentWrapper'
|
|
|
|
import { getNodeJSSteps as getNodeJSStepsPA } from '../product-analytics/nodejs'
|
|
import { StepDefinition } from '../steps'
|
|
|
|
export const getNodeJSSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {
|
|
const { CodeBlock, Markdown, Blockquote, dedent } = ctx
|
|
|
|
const installSteps = getNodeJSStepsPA(ctx)
|
|
|
|
const exceptionAutocaptureStep: StepDefinition = {
|
|
title: 'Configure exception autocapture',
|
|
badge: 'recommended',
|
|
content: (
|
|
<>
|
|
<Markdown>
|
|
{dedent`
|
|
You can enable exception autocapture when initializing the Insights client to automatically capture uncaught exceptions and unhandled rejections in your Node app.
|
|
`}
|
|
</Markdown>
|
|
<CodeBlock
|
|
blocks={[
|
|
{
|
|
language: 'javascript',
|
|
file: 'Node.js',
|
|
code: dedent`
|
|
import { Insights } from 'insights-node'
|
|
const client = new Insights(
|
|
'<ph_project_token>',
|
|
{ host: 'https://us.i.hanzo.ai', enableExceptionAutocapture: true }
|
|
)
|
|
`,
|
|
},
|
|
]}
|
|
/>
|
|
<Markdown>
|
|
{dedent`
|
|
If you are using the Express framework, you will need to import and call \`setupExpressErrorHandler\` with your Insights client and Express app. This is because Express handles uncaught exceptions internally meaning exception autocapture will not work by default.
|
|
`}
|
|
</Markdown>
|
|
<CodeBlock
|
|
blocks={[
|
|
{
|
|
language: 'javascript',
|
|
file: 'server.ts',
|
|
code: dedent`
|
|
import express from 'express'
|
|
import { Insights, setupExpressErrorHandler } from 'insights-node'
|
|
const app = express()
|
|
const insights = new Insights(INSIGHTS_PROJECT_TOKEN)
|
|
setupExpressErrorHandler(insights, app)
|
|
`,
|
|
},
|
|
]}
|
|
/>
|
|
<Blockquote>
|
|
<Markdown>
|
|
{dedent`
|
|
**Note:** Error tracking requires access the file system to process stack traces. Some providers, like Cloudflare Workers, do not support Node.js runtime APIs by default and need to be [included as per their documentation](https://developers.cloudflare.com/workers/runtime-apis/nodejs/#nodejs-compatibility).
|
|
`}
|
|
</Markdown>
|
|
</Blockquote>
|
|
</>
|
|
),
|
|
}
|
|
|
|
const manualCaptureStep: StepDefinition = {
|
|
title: 'Manually capture exceptions',
|
|
badge: 'optional',
|
|
content: (
|
|
<>
|
|
<Markdown>
|
|
{dedent`
|
|
If you need to manually capture exceptions, you can do so by calling the \`captureException\` method:
|
|
`}
|
|
</Markdown>
|
|
<CodeBlock
|
|
blocks={[
|
|
{
|
|
language: 'javascript',
|
|
file: 'Node.js',
|
|
code: dedent`
|
|
insights.captureException(e, 'user_distinct_id', additionalProperties)
|
|
`,
|
|
},
|
|
]}
|
|
/>
|
|
<Markdown>
|
|
{dedent`
|
|
This is helpful if you've built your own error handling logic or want to capture exceptions normally handled by the framework.
|
|
`}
|
|
</Markdown>
|
|
</>
|
|
),
|
|
}
|
|
|
|
const verifyStep: StepDefinition = {
|
|
title: 'Verify error tracking',
|
|
badge: 'recommended',
|
|
checkpoint: true,
|
|
content: (
|
|
<Markdown>
|
|
{dedent`
|
|
Confirm exception events are being captured and sent to Insights. You should see events appear in the activity feed.
|
|
|
|
[Check for exceptions in Insights](https://app.hanzo.ai/activity/explore)
|
|
`}
|
|
</Markdown>
|
|
),
|
|
}
|
|
|
|
return [...installSteps, exceptionAutocaptureStep, manualCaptureStep, verifyStep]
|
|
}
|
|
|
|
export const NodeJSInstallation = createInstallation(getNodeJSSteps)
|