Files
insights-js/packages/node/scripts/generate-docs.mjs
zeekay d57cb038bd chore: rename all PostHog references to Insights/Hanzo
Bulk rename across 989 files:
- Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc.
- Repository URLs: posthog/posthog-js → hanzoai/insights-js
- Brand names: PostHog → Insights
- File renames: 259 reference JSON files, source files, workflow files
- Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights

Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
2026-03-06 01:41:12 -08:00

66 lines
2.2 KiB
JavaScript

import path from 'path'
import fs from 'fs'
import { generateApiSpecs } from '../../../scripts/docs/parser.js'
import { HOG_REF } from '../../../scripts/docs/constants.js'
// Read package.json to get version
const packageJson = JSON.parse(fs.readFileSync(path.resolve(import.meta.dirname, '../package.json'), 'utf8'));
const version = packageJson.version;
// Node-specific configuration
const NODE_SPEC_INFO = {
id: 'insights-node',
title: 'Insights Node.js SDK',
description:
'Insights Node.js SDK allows you to capture events and send them to Insights from your Node.js applications.',
slugPrefix: 'insights-node',
specUrl: 'https://github.com/Insights/@hanzo/insights',
}
// Node-specific type examples (can be customized as needed)
const NODE_TYPE_EXAMPLES = {
Properties: `// Properties for Node.js events
{
event: 'user_signed_up',
userId: 'user123',
timestamp: new Date().toISOString(),
distinct_id: 'user123',
$set: {
email: '[email protected]',
name: 'John Doe'
}
}`,
Property: `// Node.js property value
"[email protected]" | { name: "John", age: 25 }`,
}
const __dirname = import.meta.dirname
const config = {
packageDir: path.resolve(import.meta.dirname, '..'), // packages/node
apiJsonPath: path.resolve(import.meta.dirname, '../docs/insights-node.api.json'),
outputPath: path.resolve(import.meta.dirname, `../references/insights-node-references-${version}.json`),
version: version,
id: NODE_SPEC_INFO.id,
hogRef: HOG_REF,
specInfo: NODE_SPEC_INFO,
typeExamples: NODE_TYPE_EXAMPLES,
parentClass: 'Insights',
}
// Ensure references directory exists
const referencesDir = path.resolve(__dirname, '../references');
if (!fs.existsSync(referencesDir)) {
fs.mkdirSync(referencesDir, { recursive: true });
}
// Generate versioned file
const output = generateApiSpecs(config)
// Write versioned file
const versionedPath = path.resolve(__dirname, `../references/insights-node-references-${version}.json`);
fs.writeFileSync(versionedPath, JSON.stringify(output, null, 2));
// Copy to latest file
const latestPath = path.resolve(__dirname, '../references/insights-node-references-latest.json');
fs.writeFileSync(latestPath, JSON.stringify(output, null, 2));