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.
81 lines
3.4 KiB
TypeScript
81 lines
3.4 KiB
TypeScript
import { OnboardingComponentsContext, createInstallation } from 'scenes/onboarding/shared/OnboardingDocsContentWrapper'
|
|
|
|
import { getReactRouterSteps as getReactRouterStepsPA } from '../product-analytics/react-router'
|
|
import { StepDefinition } from '../steps'
|
|
|
|
export const getReactRouterSteps = (ctx: OnboardingComponentsContext): StepDefinition[] => {
|
|
const { CodeBlock, Markdown, dedent, snippets } = ctx
|
|
const BooleanFlag = snippets?.BooleanFlagSnippet
|
|
const MultivariateFlag = snippets?.MultivariateFlagSnippet
|
|
|
|
const installationSteps = getReactRouterStepsPA(ctx)
|
|
const flagSteps: StepDefinition[] = [
|
|
{
|
|
title: 'Client-side rendering',
|
|
badge: 'required',
|
|
content: (
|
|
<>
|
|
<Markdown>**Basic flag implementation**</Markdown>
|
|
{BooleanFlag && <BooleanFlag language="typescript" />}
|
|
<Markdown>**Multivariate flags**</Markdown>
|
|
{MultivariateFlag && <MultivariateFlag language="typescript" />}
|
|
</>
|
|
),
|
|
},
|
|
{
|
|
title: 'Server-side rendering',
|
|
badge: 'required',
|
|
content: (
|
|
<>
|
|
<Markdown>
|
|
Use `insights-node` to evaluate feature flags on the server. You can access Insights in a React
|
|
Router loader:
|
|
</Markdown>
|
|
<CodeBlock
|
|
blocks={[
|
|
{
|
|
language: 'typescript',
|
|
file: 'app/routes/example.tsx',
|
|
code: dedent`
|
|
import { Insights } from 'insights-node'
|
|
import type { Route } from './+types/example'
|
|
|
|
export async function loader({ request }: Route.LoaderArgs) {
|
|
const insights = new Insights(process.env.VITE_INSIGHTS_PROJECT_TOKEN!, {
|
|
host: process.env.VITE_INSIGHTS_HOST
|
|
})
|
|
|
|
try {
|
|
// use insights for feature flags here
|
|
} finally {
|
|
await insights.shutdown()
|
|
}
|
|
}
|
|
`,
|
|
},
|
|
]}
|
|
/>
|
|
<Markdown>**Basic flag implementation**</Markdown>
|
|
{BooleanFlag && <BooleanFlag language="node.js" />}
|
|
<Markdown>**Multivariate flags**</Markdown>
|
|
{MultivariateFlag && <MultivariateFlag language="node.js" />}
|
|
</>
|
|
),
|
|
},
|
|
{
|
|
title: 'Running experiments',
|
|
badge: 'optional',
|
|
content: (
|
|
<Markdown>
|
|
Experiments run on top of our feature flags. Once you've implemented the flag in your code, you run
|
|
an experiment by creating a new experiment in the Insights dashboard.
|
|
</Markdown>
|
|
),
|
|
},
|
|
]
|
|
|
|
return [...installationSteps, ...flagSteps]
|
|
}
|
|
|
|
export const ReactRouterInstallation = createInstallation(getReactRouterSteps)
|