Files
insights-js/packages/node/references/insights-node-references-5.12.0.json
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

1243 lines
47 KiB
JSON

{
"id": "@hanzo/insights-node",
"hogRef": "0.3",
"info": {
"version": "5.12.0",
"id": "@hanzo/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": "@hanzo/insights-node",
"specUrl": "https://github.com/hanzoai/@hanzo/insights"
},
"classes": [
{
"id": "Insights",
"title": "Insights",
"functions": [
{
"category": "",
"details": null,
"id": "getLibraryId",
"showDocs": true,
"title": "getLibraryId",
"examples": [
{
"id": "getlibraryid",
"name": "Generated example for getLibraryId",
"code": "// Generated example for getLibraryId\ninsights.getLibraryId();"
}
],
"releaseTag": "public",
"params": [],
"returnType": {
"id": "string",
"name": "string"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Initialization",
"description": "Initialize a new Insights client instance.",
"details": null,
"id": "Insights",
"showDocs": true,
"title": "Insights",
"examples": [
{
"id": "basic_initialization",
"name": "Basic initialization",
"code": "\n\n// Basic initialization\nconst client = new InsightsBackendClient(\n 'your-api-key',\n { host: 'https://app.insights.hanzo.ai' }\n)\n\n\n"
},
{
"id": "with_personal_api_key",
"name": "With personal API key",
"code": "\n\n// With personal API key\nconst client = new InsightsBackendClient(\n 'your-api-key',\n {\n host: 'https://app.insights.hanzo.ai',\n personalApiKey: 'your-personal-api-key'\n }\n)\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "Your Insights project API key",
"isOptional": false,
"type": "string",
"name": "apiKey"
},
{
"description": "Configuration options for the client",
"isOptional": true,
"type": "InsightsOptions",
"name": "options"
}
],
"returnType": {
"id": "any",
"name": "any"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Identification",
"description": "Create an alias to link two distinct IDs together.",
"details": null,
"id": "alias",
"showDocs": true,
"title": "alias",
"examples": [
{
"id": "link_an_anonymous_user_to_an_identified_user",
"name": "Link an anonymous user to an identified user",
"code": "\n\n// Link an anonymous user to an identified user\nclient.alias({\n distinctId: 'anonymous_123',\n alias: 'user_456'\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The alias data containing distinctId and alias",
"isOptional": false,
"type": "{\n distinctId: string;\n alias: string;\n disableGeoip?: boolean;\n }",
"name": "data"
}
],
"returnType": {
"id": "void",
"name": "void"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Identification",
"description": "Create an alias to link two distinct IDs together immediately (synchronously).",
"details": null,
"id": "aliasImmediate",
"showDocs": true,
"title": "aliasImmediate",
"examples": [
{
"id": "link_an_anonymous_user_to_an_identified_user_immediately",
"name": "Link an anonymous user to an identified user immediately",
"code": "\n\n// Link an anonymous user to an identified user immediately\nawait client.aliasImmediate({\n distinctId: 'anonymous_123',\n alias: 'user_456'\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The alias data containing distinctId and alias",
"isOptional": false,
"type": "{\n distinctId: string;\n alias: string;\n disableGeoip?: boolean;\n }",
"name": "data"
}
],
"returnType": {
"id": "Promise<void>",
"name": "Promise<void>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Capture",
"description": "Capture an event manually.",
"details": null,
"id": "capture",
"showDocs": true,
"title": "capture",
"examples": [
{
"id": "basic_capture",
"name": "Basic capture",
"code": "\n\n// Basic capture\nclient.capture({\n distinctId: 'user_123',\n event: 'button_clicked',\n properties: { button_color: 'red' }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The event properties",
"isOptional": false,
"type": "EventMessage",
"name": "props"
}
],
"returnType": {
"id": "void",
"name": "void"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Error tracking",
"description": "Capture an error exception as an event.",
"details": null,
"id": "captureException",
"showDocs": true,
"title": "captureException",
"examples": [
{
"id": "capture_an_error_with_user_id",
"name": "Capture an error with user ID",
"code": "\n\n// Capture an error with user ID\ntry {\n // Some risky operation\n riskyOperation()\n} catch (error) {\n client.captureException(error, 'user_123')\n}\n\n\n"
},
{
"id": "capture_with_additional_properties",
"name": "Capture with additional properties",
"code": "\n\n// Capture with additional properties\ntry {\n apiCall()\n} catch (error) {\n client.captureException(error, 'user_123', {\n endpoint: '/api/users',\n method: 'POST',\n status_code: 500\n })\n}\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The error to capture",
"isOptional": false,
"type": "unknown",
"name": "error"
},
{
"description": "Optional user distinct ID",
"isOptional": true,
"type": "string",
"name": "distinctId"
},
{
"description": "Optional additional properties to include",
"isOptional": true,
"type": "Record<string | number, any>",
"name": "additionalProperties"
}
],
"returnType": {
"id": "void",
"name": "void"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Error tracking",
"description": "Capture an error exception as an event immediately (synchronously).",
"details": null,
"id": "captureExceptionImmediate",
"showDocs": true,
"title": "captureExceptionImmediate",
"examples": [
{
"id": "capture_an_error_immediately_with_user_id",
"name": "Capture an error immediately with user ID",
"code": "\n\n// Capture an error immediately with user ID\ntry {\n // Some risky operation\n riskyOperation()\n} catch (error) {\n await client.captureExceptionImmediate(error, 'user_123')\n}\n\n\n"
},
{
"id": "capture_with_additional_properties",
"name": "Capture with additional properties",
"code": "\n\n// Capture with additional properties\ntry {\n apiCall()\n} catch (error) {\n await client.captureExceptionImmediate(error, 'user_123', {\n endpoint: '/api/users',\n method: 'POST',\n status_code: 500\n })\n}\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The error to capture",
"isOptional": false,
"type": "unknown",
"name": "error"
},
{
"description": "Optional user distinct ID",
"isOptional": true,
"type": "string",
"name": "distinctId"
},
{
"description": "Optional additional properties to include",
"isOptional": true,
"type": "Record<string | number, any>",
"name": "additionalProperties"
}
],
"returnType": {
"id": "Promise<void>",
"name": "Promise<void>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Capture",
"description": "Capture an event immediately (synchronously).",
"details": null,
"id": "captureImmediate",
"showDocs": true,
"title": "captureImmediate",
"examples": [
{
"id": "basic_immediate_capture",
"name": "Basic immediate capture",
"code": "\n\n// Basic immediate capture\nawait client.captureImmediate({\n distinctId: 'user_123',\n event: 'button_clicked',\n properties: { button_color: 'red' }\n})\n\n\n"
},
{
"id": "with_feature_flags",
"name": "With feature flags",
"code": "\n\n// With feature flags\nawait client.captureImmediate({\n distinctId: 'user_123',\n event: 'user_action',\n sendFeatureFlags: true\n})\n\n\n"
},
{
"id": "with_custom_feature_flags_options",
"name": "With custom feature flags options",
"code": "\n\n// With custom feature flags options\nawait client.captureImmediate({\n distinctId: 'user_123',\n event: 'user_action',\n sendFeatureFlags: {\n onlyEvaluateLocally: true,\n personProperties: { plan: 'premium' },\n groupProperties: { org: { tier: 'enterprise' } }\n flagKeys: ['flag1', 'flag2']\n }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The event properties",
"isOptional": false,
"type": "EventMessage",
"name": "props"
}
],
"returnType": {
"id": "Promise<void>",
"name": "Promise<void>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Initialization",
"description": "Enable or disable debug logging.",
"details": null,
"id": "debug",
"showDocs": true,
"title": "debug",
"examples": [
{
"id": "enable_debug_logging",
"name": "Enable debug logging",
"code": "\n\n// Enable debug logging\nclient.debug(true)\n\n\n"
},
{
"id": "disable_debug_logging",
"name": "Disable debug logging",
"code": "\n\n// Disable debug logging\nclient.debug(false)\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "Whether to enable debug logging",
"isOptional": true,
"type": "boolean",
"name": "enabled"
}
],
"returnType": {
"id": "void",
"name": "void"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Privacy",
"description": "Disable the Insights client (opt-out).",
"details": null,
"id": "disable",
"showDocs": true,
"title": "disable",
"examples": [
{
"id": "disable_client",
"name": "Disable client",
"code": "\n\n// Disable client\nawait client.disable()\n// Client is now disabled and will not capture events\n\n\n\n"
}
],
"releaseTag": "public",
"params": [],
"returnType": {
"id": "Promise<void>",
"name": "Promise<void>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Privacy",
"description": "Enable the Insights client (opt-in).",
"details": null,
"id": "enable",
"showDocs": true,
"title": "enable",
"examples": [
{
"id": "enable_client",
"name": "Enable client",
"code": "\n\n// Enable client\nawait client.enable()\n// Client is now enabled and will capture events\n\n\n\n"
}
],
"releaseTag": "public",
"params": [],
"returnType": {
"id": "Promise<void>",
"name": "Promise<void>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Get all feature flag values for a specific user.",
"details": null,
"id": "getAllFlags",
"showDocs": true,
"title": "getAllFlags",
"examples": [
{
"id": "get_all_flags_for_a_user",
"name": "Get all flags for a user",
"code": "\n\n// Get all flags for a user\nconst allFlags = await client.getAllFlags('user_123')\nconsole.log('User flags:', allFlags)\n// Output: { 'flag-1': 'variant-a', 'flag-2': false, 'flag-3': 'variant-b' }\n\n\n"
},
{
"id": "with_specific_flag_keys",
"name": "With specific flag keys",
"code": "\n\n// With specific flag keys\nconst specificFlags = await client.getAllFlags('user_123', {\n flagKeys: ['flag-1', 'flag-2']\n})\n\n\n"
},
{
"id": "with_groups_and_properties",
"name": "With groups and properties",
"code": "\n\n// With groups and properties\nconst orgFlags = await client.getAllFlags('user_123', {\n groups: { organization: 'acme-corp' },\n personProperties: { plan: 'enterprise' }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The user's distinct ID",
"isOptional": false,
"type": "string",
"name": "distinctId"
},
{
"description": "Optional configuration for flag evaluation",
"isOptional": true,
"type": "{\n groups?: Record<string, string>;\n personProperties?: Record<string, string>;\n groupProperties?: Record<string, Record<string, string>>;\n onlyEvaluateLocally?: boolean;\n disableGeoip?: boolean;\n flagKeys?: string[];\n }",
"name": "options"
}
],
"returnType": {
"id": "Promise<Record<string, FeatureFlagValue>>",
"name": "Promise<Record<string, FeatureFlagValue>>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Get all feature flag values and payloads for a specific user.",
"details": null,
"id": "getAllFlagsAndPayloads",
"showDocs": true,
"title": "getAllFlagsAndPayloads",
"examples": [
{
"id": "get_all_flags_and_payloads_for_a_user",
"name": "Get all flags and payloads for a user",
"code": "\n\n// Get all flags and payloads for a user\nconst result = await client.getAllFlagsAndPayloads('user_123')\nconsole.log('Flags:', result.featureFlags)\nconsole.log('Payloads:', result.featureFlagPayloads)\n\n\n"
},
{
"id": "with_specific_flag_keys",
"name": "With specific flag keys",
"code": "\n\n// With specific flag keys\nconst result = await client.getAllFlagsAndPayloads('user_123', {\n flagKeys: ['flag-1', 'flag-2']\n})\n\n\n"
},
{
"id": "only_evaluate_locally",
"name": "Only evaluate locally",
"code": "\n\n// Only evaluate locally\nconst result = await client.getAllFlagsAndPayloads('user_123', {\n onlyEvaluateLocally: true\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The user's distinct ID",
"isOptional": false,
"type": "string",
"name": "distinctId"
},
{
"description": "Optional configuration for flag evaluation",
"isOptional": true,
"type": "{\n groups?: Record<string, string>;\n personProperties?: Record<string, string>;\n groupProperties?: Record<string, Record<string, string>>;\n onlyEvaluateLocally?: boolean;\n disableGeoip?: boolean;\n flagKeys?: string[];\n }",
"name": "options"
}
],
"returnType": {
"id": "Promise<InsightsFlagsAndPayloadsResponse>",
"name": "Promise<InsightsFlagsAndPayloadsResponse>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Identification",
"description": "Get the custom user agent string for this client.",
"details": null,
"id": "getCustomUserAgent",
"showDocs": true,
"title": "getCustomUserAgent",
"examples": [
{
"id": "get_user_agent",
"name": "Get user agent",
"code": "\n\n// Get user agent\nconst userAgent = client.getCustomUserAgent()\n// Returns: \"@hanzo/insights-node/5.7.0\"\n\n\n\n"
}
],
"releaseTag": "public",
"params": [],
"returnType": {
"id": "string",
"name": "string"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Get the value of a feature flag for a specific user.",
"details": null,
"id": "getFeatureFlag",
"showDocs": true,
"title": "getFeatureFlag",
"examples": [
{
"id": "basic_feature_flag_check",
"name": "Basic feature flag check",
"code": "\n\n// Basic feature flag check\nconst flagValue = await client.getFeatureFlag('new-feature', 'user_123')\nif (flagValue === 'variant-a') {\n // Show variant A\n} else if (flagValue === 'variant-b') {\n // Show variant B\n} else {\n // Flag is disabled or not found\n}\n\n\n"
},
{
"id": "with_groups_and_properties",
"name": "With groups and properties",
"code": "\n\n// With groups and properties\nconst flagValue = await client.getFeatureFlag('org-feature', 'user_123', {\n groups: { organization: 'acme-corp' },\n personProperties: { plan: 'enterprise' },\n groupProperties: { organization: { tier: 'premium' } }\n})\n\n\n"
},
{
"id": "only_evaluate_locally",
"name": "Only evaluate locally",
"code": "\n\n// Only evaluate locally\nconst flagValue = await client.getFeatureFlag('local-flag', 'user_123', {\n onlyEvaluateLocally: true\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The feature flag key",
"isOptional": false,
"type": "string",
"name": "key"
},
{
"description": "The user's distinct ID",
"isOptional": false,
"type": "string",
"name": "distinctId"
},
{
"description": "Optional configuration for flag evaluation",
"isOptional": true,
"type": "{\n groups?: Record<string, string>;\n personProperties?: Record<string, string>;\n groupProperties?: Record<string, Record<string, string>>;\n onlyEvaluateLocally?: boolean;\n sendFeatureFlagEvents?: boolean;\n disableGeoip?: boolean;\n }",
"name": "options"
}
],
"returnType": {
"id": "Promise<FeatureFlagValue | undefined>",
"name": "Promise<FeatureFlagValue | undefined>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Get the payload for a feature flag.",
"details": null,
"id": "getFeatureFlagPayload",
"showDocs": true,
"title": "getFeatureFlagPayload",
"examples": [
{
"id": "get_payload_for_a_feature_flag",
"name": "Get payload for a feature flag",
"code": "\n\n// Get payload for a feature flag\nconst payload = await client.getFeatureFlagPayload('flag-key', 'user_123')\nif (payload) {\n console.log('Flag payload:', payload)\n}\n\n\n"
},
{
"id": "get_payload_with_specific_match_value",
"name": "Get payload with specific match value",
"code": "\n\n// Get payload with specific match value\nconst payload = await client.getFeatureFlagPayload('flag-key', 'user_123', 'variant-a')\n\n\n"
},
{
"id": "with_groups_and_properties",
"name": "With groups and properties",
"code": "\n\n// With groups and properties\nconst payload = await client.getFeatureFlagPayload('org-flag', 'user_123', undefined, {\n groups: { organization: 'acme-corp' },\n personProperties: { plan: 'enterprise' }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The feature flag key",
"isOptional": false,
"type": "string",
"name": "key"
},
{
"description": "The user's distinct ID",
"isOptional": false,
"type": "string",
"name": "distinctId"
},
{
"description": "Optional match value to get payload for",
"isOptional": true,
"type": "FeatureFlagValue",
"name": "matchValue"
},
{
"description": "Optional configuration for flag evaluation",
"isOptional": true,
"type": "{\n groups?: Record<string, string>;\n personProperties?: Record<string, string>;\n groupProperties?: Record<string, Record<string, string>>;\n onlyEvaluateLocally?: boolean;\n sendFeatureFlagEvents?: boolean;\n disableGeoip?: boolean;\n }",
"name": "options"
}
],
"returnType": {
"id": "Promise<JsonType | undefined>",
"name": "Promise<JsonType | undefined>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Initialization",
"description": "Get the library version from package.json.",
"details": null,
"id": "getLibraryVersion",
"showDocs": true,
"title": "getLibraryVersion",
"examples": [
{
"id": "get_version",
"name": "Get version",
"code": "\n\n// Get version\nconst version = client.getLibraryVersion()\nconsole.log(`Using Insights SDK version: ${version}`)\n\n\n\n"
}
],
"releaseTag": "public",
"params": [],
"returnType": {
"id": "string",
"name": "string"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Initialization",
"description": "Get a persisted property value from memory storage.",
"details": null,
"id": "getPersistedProperty",
"showDocs": true,
"title": "getPersistedProperty",
"examples": [
{
"id": "get_user_id",
"name": "Get user ID",
"code": "\n\n// Get user ID\nconst userId = client.getPersistedProperty('userId')\n\n\n"
},
{
"id": "get_session_id",
"name": "Get session ID",
"code": "\n\n// Get session ID\nconst sessionId = client.getPersistedProperty('sessionId')\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The property key to retrieve",
"isOptional": false,
"type": "InsightsPersistedProperty",
"name": "key"
}
],
"returnType": {
"id": "any | undefined",
"name": "any | undefined"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Get the remote config payload for a feature flag.",
"details": null,
"id": "getRemoteConfigPayload",
"showDocs": true,
"title": "getRemoteConfigPayload",
"examples": [
{
"id": "get_remote_config_payload",
"name": "Get remote config payload",
"code": "\n\n// Get remote config payload\nconst payload = await client.getRemoteConfigPayload('flag-key')\nif (payload) {\n console.log('Remote config payload:', payload)\n}\n\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The feature flag key",
"isOptional": false,
"type": "string",
"name": "flagKey"
}
],
"returnType": {
"id": "Promise<JsonType | undefined>",
"name": "Promise<JsonType | undefined>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Identification",
"description": "Create or update a group and its properties.",
"details": null,
"id": "groupIdentify",
"showDocs": true,
"title": "groupIdentify",
"examples": [
{
"id": "create_a_company_group",
"name": "Create a company group",
"code": "\n\n// Create a company group\nclient.groupIdentify({\n groupType: 'company',\n groupKey: 'acme-corp',\n properties: {\n name: 'Acme Corporation',\n industry: 'Technology',\n employee_count: 500\n },\n distinctId: 'user_123'\n})\n\n\n"
},
{
"id": "update_organization_properties",
"name": "Update organization properties",
"code": "\n\n// Update organization properties\nclient.groupIdentify({\n groupType: 'organization',\n groupKey: 'org-456',\n properties: {\n plan: 'enterprise',\n region: 'US-West'\n }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "",
"isOptional": false,
"type": "GroupIdentifyMessage",
"name": "{ groupType, groupKey, properties, distinctId, disableGeoip }"
}
],
"returnType": {
"id": "void",
"name": "void"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Identification",
"description": "Identify a user and set their properties.",
"details": null,
"id": "identify",
"showDocs": true,
"title": "identify",
"examples": [
{
"id": "basic_identify_with_properties",
"name": "Basic identify with properties",
"code": "\n\n// Basic identify with properties\nclient.identify({\n distinctId: 'user_123',\n properties: {\n name: 'John Doe',\n email: '[email protected]',\n plan: 'premium'\n }\n})\n\n\n"
},
{
"id": "using_$set_and_$set_once",
"name": "Using $set and $set_once",
"code": "\n\n// Using $set and $set_once\nclient.identify({\n distinctId: 'user_123',\n properties: {\n $set: { name: 'John Doe', email: '[email protected]' },\n $set_once: { first_login: new Date().toISOString() }\n }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "",
"isOptional": false,
"type": "IdentifyMessage",
"name": "{ distinctId, properties, disableGeoip }"
}
],
"returnType": {
"id": "void",
"name": "void"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Identification",
"description": "Identify a user and set their properties immediately (synchronously).",
"details": null,
"id": "identifyImmediate",
"showDocs": true,
"title": "identifyImmediate",
"examples": [
{
"id": "basic_immediate_identify",
"name": "Basic immediate identify",
"code": "\n\n// Basic immediate identify\nawait client.identifyImmediate({\n distinctId: 'user_123',\n properties: {\n name: 'John Doe',\n email: '[email protected]'\n }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "",
"isOptional": false,
"type": "IdentifyMessage",
"name": "{ distinctId, properties, disableGeoip }"
}
],
"returnType": {
"id": "Promise<void>",
"name": "Promise<void>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Check if a feature flag is enabled for a specific user.",
"details": null,
"id": "isFeatureEnabled",
"showDocs": true,
"title": "isFeatureEnabled",
"examples": [
{
"id": "basic_feature_flag_check",
"name": "Basic feature flag check",
"code": "\n\n// Basic feature flag check\nconst isEnabled = await client.isFeatureEnabled('new-feature', 'user_123')\nif (isEnabled) {\n // Feature is enabled\n console.log('New feature is active')\n} else {\n // Feature is disabled\n console.log('New feature is not active')\n}\n\n\n"
},
{
"id": "with_groups_and_properties",
"name": "With groups and properties",
"code": "\n\n// With groups and properties\nconst isEnabled = await client.isFeatureEnabled('org-feature', 'user_123', {\n groups: { organization: 'acme-corp' },\n personProperties: { plan: 'enterprise' }\n})\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The feature flag key",
"isOptional": false,
"type": "string",
"name": "key"
},
{
"description": "The user's distinct ID",
"isOptional": false,
"type": "string",
"name": "distinctId"
},
{
"description": "Optional configuration for flag evaluation",
"isOptional": true,
"type": "{\n groups?: Record<string, string>;\n personProperties?: Record<string, string>;\n groupProperties?: Record<string, Record<string, string>>;\n onlyEvaluateLocally?: boolean;\n sendFeatureFlagEvents?: boolean;\n disableGeoip?: boolean;\n }",
"name": "options"
}
],
"returnType": {
"id": "Promise<boolean | undefined>",
"name": "Promise<boolean | undefined>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Check if local evaluation of feature flags is ready.",
"details": null,
"id": "isLocalEvaluationReady",
"showDocs": true,
"title": "isLocalEvaluationReady",
"examples": [
{
"id": "check_if_ready",
"name": "Check if ready",
"code": "\n\n// Check if ready\nif (client.isLocalEvaluationReady()) {\n // Local evaluation is ready, can evaluate flags locally\n const flag = await client.getFeatureFlag('flag-key', 'user_123')\n} else {\n // Local evaluation not ready, will use remote evaluation\n const flag = await client.getFeatureFlag('flag-key', 'user_123')\n}\n\n\n\n"
}
],
"releaseTag": "public",
"params": [],
"returnType": {
"id": "boolean",
"name": "boolean"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "",
"details": null,
"id": "prepareEventMessage",
"showDocs": true,
"title": "prepareEventMessage",
"examples": [
{
"id": "prepareeventmessage",
"name": "Generated example for prepareEventMessage",
"code": "// Generated example for prepareEventMessage\ninsights.prepareEventMessage();"
}
],
"releaseTag": "public",
"params": [
{
"description": "",
"isOptional": false,
"type": "EventMessage",
"name": "props"
}
],
"returnType": {
"id": "Promise<{\n distinctId: string;\n event: string;\n properties: InsightsEventProperties;\n options: InsightsCaptureOptions;\n }>",
"name": "Promise<{\n distinctId: string;\n event: string;\n properties: InsightsEventProperties;\n options: InsightsCaptureOptions;\n }>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Reload feature flag definitions from the server for local evaluation.",
"details": null,
"id": "reloadFeatureFlags",
"showDocs": true,
"title": "reloadFeatureFlags",
"examples": [
{
"id": "force_reload_of_feature_flags",
"name": "Force reload of feature flags",
"code": "\n\n// Force reload of feature flags\nawait client.reloadFeatureFlags()\nconsole.log('Feature flags reloaded')\n\n\n"
},
{
"id": "reload_before_checking_a_specific_flag",
"name": "Reload before checking a specific flag",
"code": "\n\n// Reload before checking a specific flag\nawait client.reloadFeatureFlags()\nconst flag = await client.getFeatureFlag('flag-key', 'user_123')\n\n\n\n"
}
],
"releaseTag": "public",
"params": [],
"returnType": {
"id": "Promise<void>",
"name": "Promise<void>"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Initialization",
"description": "Set a persisted property value in memory storage.",
"details": null,
"id": "setPersistedProperty",
"showDocs": true,
"title": "setPersistedProperty",
"examples": [
{
"id": "set_user_id",
"name": "Set user ID",
"code": "\n\n// Set user ID\nclient.setPersistedProperty('userId', 'user_123')\n\n\n"
},
{
"id": "set_session_id",
"name": "Set session ID",
"code": "\n\n// Set session ID\nclient.setPersistedProperty('sessionId', 'session_456')\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "The property key to set",
"isOptional": false,
"type": "InsightsPersistedProperty",
"name": "key"
},
{
"description": "The value to store (null to remove)",
"isOptional": false,
"type": "any | null",
"name": "value"
}
],
"returnType": {
"id": "void",
"name": "void"
},
"path": "src/entrypoints/index.node.ts"
},
{
"category": "Feature flags",
"description": "Wait for local evaluation of feature flags to be ready.",
"details": null,
"id": "waitForLocalEvaluationReady",
"showDocs": true,
"title": "waitForLocalEvaluationReady",
"examples": [
{
"id": "wait_for_local_evaluation",
"name": "Wait for local evaluation",
"code": "\n\n// Wait for local evaluation\nconst isReady = await client.waitForLocalEvaluationReady()\nif (isReady) {\n console.log('Local evaluation is ready')\n} else {\n console.log('Local evaluation timed out')\n}\n\n\n"
},
{
"id": "wait_with_custom_timeout",
"name": "Wait with custom timeout",
"code": "\n\n// Wait with custom timeout\nconst isReady = await client.waitForLocalEvaluationReady(10000) // 10 seconds\n\n\n\n"
}
],
"releaseTag": "public",
"params": [
{
"description": "Timeout in milliseconds (default: 30000)",
"isOptional": true,
"type": "number",
"name": "timeoutMs"
}
],
"returnType": {
"id": "Promise<boolean>",
"name": "Promise<boolean>"
},
"path": "src/entrypoints/index.node.ts"
}
]
}
],
"types": [
{
"id": "_SentryEvent",
"name": "_SentryEvent",
"properties": [],
"path": "src/extensions/sentry-integration.ts"
},
{
"id": "_SentryEventProcessor",
"name": "_SentryEventProcessor",
"properties": [],
"path": "src/extensions/sentry-integration.ts"
},
{
"id": "_SentryHub",
"name": "_SentryHub",
"properties": [],
"path": "src/extensions/sentry-integration.ts"
},
{
"id": "_SentryIntegration",
"name": "_SentryIntegration",
"properties": [
{
"type": "string",
"name": "name"
}
],
"path": "src/extensions/sentry-integration.ts"
},
{
"id": "_SentryIntegrationClass",
"name": "_SentryIntegrationClass",
"properties": [
{
"type": "string",
"name": "name"
}
],
"path": "src/extensions/sentry-integration.ts"
},
{
"id": "BeforeSendFn",
"name": "BeforeSendFn",
"properties": [],
"path": "src/types.ts",
"example": "(event: EventMessage | null) => EventMessage | null"
},
{
"id": "EventMessage",
"name": "EventMessage",
"properties": [
{
"type": "string",
"name": "event"
},
{
"type": "Record<string, string | number>",
"name": "groups"
},
{
"type": "boolean | SendFeatureFlagsOptions",
"name": "sendFeatureFlags"
},
{
"type": "Date",
"name": "timestamp"
},
{
"type": "string",
"name": "uuid"
}
],
"path": "src/types.ts"
},
{
"id": "ExpressErrorMiddleware",
"name": "ExpressErrorMiddleware",
"properties": [],
"path": "src/extensions/express.ts",
"example": "(error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void"
},
{
"id": "ExpressMiddleware",
"name": "ExpressMiddleware",
"properties": [],
"path": "src/extensions/express.ts",
"example": "(req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void"
},
{
"id": "FeatureFlagCondition",
"name": "FeatureFlagCondition",
"properties": [],
"path": "src/types.ts",
"example": "{\n properties: FlagProperty[];\n rollout_percentage?: number;\n variant?: string;\n}"
},
{
"id": "FlagDefinitionCacheData",
"name": "FlagDefinitionCacheData",
"properties": [
{
"description": "Cohort property groups for local evaluation",
"type": "Record<string, PropertyGroup>",
"name": "cohorts"
},
{
"description": "Array of feature flag definitions",
"type": "InsightsFeatureFlag[]",
"name": "flags"
},
{
"description": "Mapping of group type index to group name",
"type": "Record<string, string>",
"name": "groupTypeMapping"
}
],
"path": "src/extensions/feature-flags/cache.ts"
},
{
"id": "FlagDefinitionCacheProvider",
"name": "FlagDefinitionCacheProvider",
"properties": [],
"path": "src/extensions/feature-flags/cache.ts"
},
{
"id": "FlagProperty",
"name": "FlagProperty",
"properties": [],
"path": "src/types.ts",
"example": "{\n key: string;\n type?: string;\n value: FlagPropertyValue;\n operator?: string;\n negation?: boolean;\n dependency_chain?: string[];\n}"
},
{
"id": "FlagPropertyValue",
"name": "FlagPropertyValue",
"properties": [],
"path": "src/types.ts",
"example": "string | number | (string | number)[] | boolean"
},
{
"id": "GroupIdentifyMessage",
"name": "GroupIdentifyMessage",
"properties": [
{
"type": "boolean",
"name": "disableGeoip"
},
{
"type": "string",
"name": "distinctId"
},
{
"type": "string",
"name": "groupKey"
},
{
"type": "string",
"name": "groupType"
},
{
"type": "Record<string | number, any>",
"name": "properties"
}
],
"path": "src/types.ts"
},
{
"id": "IdentifyMessage",
"name": "IdentifyMessage",
"properties": [
{
"type": "boolean",
"name": "disableGeoip"
},
{
"type": "string",
"name": "distinctId"
},
{
"type": "Record<string | number, any>",
"name": "properties"
}
],
"path": "src/types.ts"
},
{
"id": "IInsights",
"name": "IInsights",
"properties": [],
"path": "src/types.ts"
},
{
"id": "MiddlewareError",
"name": "MiddlewareError",
"properties": [
{
"type": "{\n statusCode?: number | string;\n }",
"name": "output"
},
{
"type": "number | string",
"name": "status_code"
},
{
"type": "number | string",
"name": "status"
},
{
"type": "number | string",
"name": "statusCode"
}
],
"path": "src/extensions/express.ts"
},
{
"id": "InsightsFeatureFlag",
"name": "InsightsFeatureFlag",
"properties": [],
"path": "src/types.ts",
"example": "{\n id: number;\n name: string;\n key: string;\n filters?: {\n aggregation_group_type_index?: number;\n groups?: FeatureFlagCondition[];\n multivariate?: {\n variants: {\n key: string;\n rollout_percentage: number;\n }[];\n };\n payloads?: Record<string, string>;\n };\n deleted: boolean;\n active: boolean;\n rollout_percentage: null | number;\n ensure_experience_continuity: boolean;\n experiment_set: number[];\n}"
},
{
"id": "InsightsOptions",
"name": "InsightsOptions",
"properties": [],
"path": "src/types.ts",
"example": "InsightsCoreOptions & {\n persistence?: 'memory';\n personalApiKey?: string;\n privacyMode?: boolean;\n enableExceptionAutocapture?: boolean;\n featureFlagsPollingInterval?: number;\n maxCacheSize?: number;\n fetch?: (url: string, options: InsightsFetchOptions) => Promise<InsightsFetchResponse>;\n enableLocalEvaluation?: boolean;\n flagDefinitionCacheProvider?: FlagDefinitionCacheProvider;\n before_send?: BeforeSendFn | BeforeSendFn[];\n evaluationEnvironments?: readonly string[];\n custom_blocked_useragents?: string[];\n __preview_capture_bot_pageviews?: boolean;\n}"
},
{
"id": "PropertyGroup",
"name": "PropertyGroup",
"properties": [],
"path": "src/types.ts",
"example": "{\n type: 'AND' | 'OR';\n values: PropertyGroup[] | FlagProperty[];\n}"
},
{
"id": "SendFeatureFlagsOptions",
"name": "SendFeatureFlagsOptions",
"properties": [
{
"type": "string[]",
"name": "flagKeys"
},
{
"type": "Record<string, Record<string, any>>",
"name": "groupProperties"
},
{
"type": "boolean",
"name": "onlyEvaluateLocally"
},
{
"type": "Record<string, any>",
"name": "personProperties"
}
],
"path": "src/types.ts"
},
{
"id": "SentryIntegrationOptions",
"name": "SentryIntegrationOptions",
"properties": [],
"path": "src/extensions/sentry-integration.ts",
"example": "{\n organization?: string;\n projectId?: number;\n prefix?: string;\n severityAllowList?: CoreErrorTracking.SeverityLevel[] | '*';\n sendExceptionsToInsights?: boolean;\n}"
}
],
"categories": ["Initialization", "Identification", "Capture", "Error tracking", "Privacy", "Feature flags"]
}