oh-my-opencode 5.0.0-beta.3 → 5.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/command/publish.md +44 -16
- package/.agents/skills/publish/SKILL.md +44 -16
- package/.agents/skills/senpi-qa/SKILL.md +80 -0
- package/.agents/skills/senpi-qa/scripts/resolve-evidence-dir.mjs +65 -0
- package/.agents/skills/senpi-qa/scripts/resolve-evidence-dir.test.mjs +171 -0
- package/.agents/skills/work-with-pr/SKILL.md +37 -23
- package/.opencode/command/publish.md +44 -16
- package/.opencode/skills/work-with-pr/SKILL.md +37 -23
- package/README.ja.md +25 -21
- package/README.ko.md +25 -21
- package/README.md +38 -23
- package/README.ru.md +24 -20
- package/README.zh-cn.md +25 -21
- package/dist/agents/atlas/agent.d.ts +0 -1
- package/dist/agents/sisyphus/grok-4.d.ts +20 -0
- package/dist/agents/sisyphus/index.d.ts +2 -0
- package/dist/agents/sisyphus-agent-config.d.ts +6 -0
- package/dist/agents/sisyphus-agent-factory.d.ts +1 -1
- package/dist/agents/sisyphus-runtime-prompt-reconciler.d.ts +15 -4
- package/dist/agents/types.d.ts +2 -2
- package/dist/cli/config-manager/parse-opencode-config-file.d.ts +2 -1
- package/dist/cli/doctor/checks/system-plugin.d.ts +4 -3
- package/dist/cli/fallback-lane-policy.d.ts +1 -0
- package/dist/cli/index.js +22572 -20322
- package/dist/cli/install-codex/install-codex-test-fixtures.d.ts +1 -1
- package/dist/cli/run/on-complete-hook.d.ts +2 -0
- package/dist/cli/runtime-commands.d.ts +1 -1
- package/dist/cli/worktree-sweep/classify.d.ts +16 -0
- package/dist/cli/worktree-sweep/format.d.ts +8 -0
- package/dist/cli/worktree-sweep/git.d.ts +19 -0
- package/dist/cli/worktree-sweep/index.d.ts +7 -0
- package/dist/cli/worktree-sweep/options.d.ts +2 -0
- package/dist/cli/worktree-sweep/parse-worktree-list.d.ts +8 -0
- package/dist/cli/worktree-sweep/sweep.d.ts +2 -0
- package/dist/cli/worktree-sweep/types.d.ts +65 -0
- package/dist/cli/worktree-sweep/worktree-sweep.d.ts +2 -0
- package/dist/cli-node/index.js +22190 -19917
- package/dist/config/schema/commands.d.ts +1 -1
- package/dist/config/schema/hooks.d.ts +1 -1
- package/dist/config/schema/oh-my-opencode-config.d.ts +4 -1
- package/dist/config/schema/ulw-execute.d.ts +5 -0
- package/dist/config/validate.d.ts +2 -0
- package/dist/create-hooks.d.ts +3 -1
- package/dist/features/btw-side/btw-command-draft.d.ts +7 -0
- package/dist/features/btw-side/context-injector.d.ts +15 -0
- package/dist/features/btw-side/index.d.ts +8 -0
- package/dist/features/btw-side/metadata.d.ts +15 -0
- package/dist/features/btw-side/parent-context-budget.d.ts +9 -0
- package/dist/features/btw-side/server-session-registry.d.ts +8 -0
- package/dist/features/btw-side/tui-adoption-cache.d.ts +13 -0
- package/dist/features/btw-side/tui-adoption-guard.d.ts +5 -0
- package/dist/features/btw-side/tui-controller-types.d.ts +68 -0
- package/dist/features/btw-side/tui-controller.d.ts +19 -0
- package/dist/features/btw-side/tui-escape-return.d.ts +12 -0
- package/dist/features/btw-side/tui-keymap.d.ts +17 -0
- package/dist/features/btw-side/tui-parent-validator.d.ts +6 -0
- package/dist/features/btw-side/tui-picker-options.d.ts +20 -0
- package/dist/features/btw-side/tui-picker.d.ts +9 -0
- package/dist/features/btw-side/tui-prompt-queue.d.ts +8 -0
- package/dist/features/btw-side/tui-session-bridge.d.ts +11 -0
- package/dist/features/btw-side/tui-session-catalog.d.ts +35 -0
- package/dist/features/btw-side/tui-side-removal.d.ts +11 -0
- package/dist/features/btw-side/tui-side-start.d.ts +9 -0
- package/dist/features/btw-side/tui-wiring.d.ts +8 -0
- package/dist/features/builtin-commands/templates/ulw-execute.d.ts +1 -0
- package/dist/features/builtin-commands/types.d.ts +1 -1
- package/dist/features/opengateway-provider/index.d.ts +13 -0
- package/dist/features/team-mode/tools/messaging-fallback-wake.d.ts +15 -0
- package/dist/hooks/atlas/atlas-hook.d.ts +1 -0
- package/dist/hooks/atlas/atlas-lifecycle-store.d.ts +50 -0
- package/dist/hooks/atlas/event-handler.d.ts +1 -0
- package/dist/hooks/atlas/final-wave-approval-gate.test-support.d.ts +50 -0
- package/dist/hooks/atlas/system-reminder-templates.d.ts +0 -1
- package/dist/hooks/atlas/tool-execute-before.d.ts +3 -0
- package/dist/hooks/atlas/types.d.ts +1 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/prometheus-md-only/agent-resolution.d.ts +2 -2
- package/dist/hooks/runtime-fallback/chat-message-handler.d.ts +2 -0
- package/dist/hooks/runtime-fallback/retry-model-payload.d.ts +1 -0
- package/dist/hooks/runtime-fallback/runtime-model-settings.d.ts +6 -0
- package/dist/hooks/runtime-fallback/session-status-handler.d.ts +1 -1
- package/dist/hooks/runtime-fallback/types.d.ts +3 -1
- package/dist/hooks/sisyphus-junior-notepad/constants.d.ts +1 -1
- package/dist/hooks/todo-continuation-enforcer/types.d.ts +1 -0
- package/dist/hooks/{start-work → ulw-execute}/context-info-builder.d.ts +1 -1
- package/dist/hooks/{start-work → ulw-execute}/index.d.ts +1 -1
- package/dist/hooks/ulw-execute/ulw-execute-hook.d.ts +23 -0
- package/dist/index.js +12573 -6957
- package/dist/oh-my-opencode.schema.json +15 -2
- package/dist/plugin/chat-message/types.d.ts +3 -3
- package/dist/plugin/chat-message/ulw-execute-message.d.ts +5 -0
- package/dist/plugin/event-session-lifecycle.d.ts +1 -0
- package/dist/plugin/hooks/create-core-hooks.d.ts +2 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -2
- package/dist/plugin/hooks/create-transform-hooks.d.ts +2 -0
- package/dist/plugin/messages-transform.d.ts +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/legacy-plugin-warning.d.ts +2 -1
- package/dist/shared/normalize-sdk-response.d.ts +1 -0
- package/dist/shared/plugin-entry-migrator.d.ts +4 -3
- package/dist/shared/plugin-entry-shape.d.ts +6 -0
- package/dist/shared/runtime-fallback-retry-marker.d.ts +16 -0
- package/dist/shared/shell-env.d.ts +1 -1
- package/dist/skills/ast-grep/AGENTS.md +51 -0
- package/dist/skills/coding-agent-sessions/AGENTS.md +62 -0
- package/dist/skills/coding-agent-sessions/SKILL.md +3 -2
- package/dist/skills/coding-agent-sessions/references/all-platforms.md +1 -1
- package/dist/skills/coding-agent-sessions/references/senpi.md +4 -4
- package/dist/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +1 -1
- package/dist/skills/data-scientist/SKILL.md +99 -239
- package/dist/skills/data-scientist/references/execution-surfaces.md +91 -0
- package/dist/skills/data-scientist/references/placement.md +74 -0
- package/dist/skills/data-scientist/references/polars-lane.md +95 -0
- package/dist/skills/data-scientist/references/uv-setup.md +1 -1
- package/dist/skills/data-scientist/references/visualization.md +64 -0
- package/dist/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
- package/dist/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
- package/dist/skills/debugging/SKILL.md +2 -0
- package/dist/skills/debugging/references/methodology/00-setup.md +12 -0
- package/dist/skills/debugging/references/methodology/02-investigate.md +21 -0
- package/dist/skills/debugging/references/runtimes/go.md +15 -1
- package/dist/skills/debugging/references/runtimes/native-binary.md +38 -0
- package/dist/skills/debugging/references/runtimes/node.md +25 -0
- package/dist/skills/debugging/references/runtimes/python.md +13 -0
- package/dist/skills/debugging/references/runtimes/rust.md +41 -0
- package/dist/skills/debugging/references/scripts/dap.mjs +267 -0
- package/dist/skills/debugging/references/scripts/dap.test.ts +86 -0
- package/dist/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
- package/dist/skills/debugging/references/tools/dap.md +103 -0
- package/dist/skills/debugging/references/tools/frida.md +193 -0
- package/dist/skills/frontend/SKILL.md +11 -7
- package/dist/skills/frontend/references/design/_INDEX.md +1 -0
- package/dist/skills/frontend/references/design/print-paged-media.md +76 -0
- package/dist/skills/frontend/references/design/stylegallery.md +80 -0
- package/dist/skills/frontend/references/designpowers/README.md +1 -1
- package/dist/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
- package/dist/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
- package/dist/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
- package/dist/skills/frontend/references/designpowers/orchestration.md +1 -1
- package/dist/skills/frontend/references/designpowers/routing.md +5 -5
- package/dist/skills/review-work/SKILL.md +3 -3
- package/dist/skills/ultimate-browsing/ATTRIBUTION.md +37 -10
- package/dist/skills/ultimate-browsing/SKILL.md +2 -0
- package/dist/skills/ultimate-browsing/engine/AGENTS.md +179 -0
- package/dist/skills/ultimate-browsing/engine/templates/package.json +1 -1
- package/dist/skills/ultimate-browsing/references/chrome-stealth.md +13 -11
- package/dist/skills/{start-work → ulw-execute}/SKILL.md +9 -8
- package/dist/skills/ulw-plan/SKILL.md +6 -6
- package/dist/skills/ulw-plan/references/full-workflow.md +31 -7
- package/dist/skills/ulw-plan/references/intent-clear.md +2 -1
- package/dist/skills/ulw-plan/references/intent-unclear.md +5 -5
- package/dist/skills/ulw-research/SKILL.md +4 -2
- package/dist/skills/visual-qa/AGENTS.md +58 -0
- package/dist/skills/visual-qa/SKILL.md +3 -2
- package/dist/tools/delegate-task/builtin-categories.d.ts +1 -0
- package/dist/tools/delegate-task/builtin-category-definition.d.ts +1 -0
- package/dist/tools/delegate-task/tool-description.d.ts +3 -1
- package/dist/tools/delegate-task/types.d.ts +3 -0
- package/dist/tui.d.ts +12 -0
- package/dist/tui.js +11480 -11512
- package/package.json +42 -36
- package/packages/git-bash-mcp/dist/cli.js +5 -1
- package/packages/git-bash-mcp/package.json +1 -1
- package/packages/lsp-core/src/index.ts +1 -0
- package/packages/lsp-core/src/lsp/client-diagnostics-concurrency.integration.test.ts +44 -0
- package/packages/lsp-core/src/lsp/client-diagnostics-freshness.integration.test.ts +0 -28
- package/packages/lsp-core/src/lsp/client-wrapper-outside-cwd.test.ts +78 -0
- package/packages/lsp-core/src/lsp/client-wrapper.test.ts +66 -13
- package/packages/lsp-core/src/lsp/client-wrapper.ts +95 -23
- package/packages/lsp-core/src/lsp/client.ts +26 -0
- package/packages/lsp-core/src/lsp/connection.ts +16 -0
- package/packages/lsp-core/src/lsp/constants.ts +1 -0
- package/packages/lsp-core/src/lsp/format-document.test.ts +143 -0
- package/packages/lsp-core/src/lsp/format-document.ts +90 -0
- package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +151 -0
- package/packages/lsp-core/src/lsp/manager.ts +34 -1
- package/packages/lsp-core/src/lsp/outside-context-workspace.ts +33 -0
- package/packages/lsp-core/src/lsp/server-definitions.ts +29 -0
- package/packages/lsp-core/src/lsp/server-installation.test.ts +376 -0
- package/packages/lsp-core/src/lsp/server-installation.ts +200 -27
- package/packages/lsp-core/src/lsp/server-resolution-local-binary.test.ts +170 -0
- package/packages/lsp-core/src/lsp/server-resolution.ts +18 -5
- package/packages/lsp-core/src/lsp/transport.ts +9 -0
- package/packages/lsp-core/src/lsp/types.ts +8 -0
- package/packages/lsp-core/src/lsp/workspace-edit-adversarial.test.ts +20 -1
- package/packages/lsp-core/src/lsp/workspace-markers.ts +1 -0
- package/packages/lsp-core/src/request-context.test.ts +29 -0
- package/packages/lsp-core/src/request-context.ts +1 -1
- package/packages/lsp-core/src/tool-surface.test.ts +13 -1
- package/packages/lsp-core/src/tools/definitions.ts +14 -0
- package/packages/lsp-core/src/tools/diagnostics.ts +3 -3
- package/packages/lsp-core/src/tools/format.test.ts +56 -0
- package/packages/lsp-core/src/tools/format.ts +56 -0
- package/packages/lsp-core/src/tools/index.ts +1 -0
- package/packages/lsp-core/src/tools/navigation.ts +4 -2
- package/packages/lsp-core/src/tools/rename.ts +4 -2
- package/packages/lsp-core/src/tools/symbols.ts +1 -1
- package/packages/lsp-core/src/tools/types.ts +10 -0
- package/packages/lsp-daemon/dist/cli.js +645 -296
- package/packages/lsp-daemon/dist/client.d.ts +10 -0
- package/packages/lsp-daemon/dist/client.js +605 -253
- package/packages/lsp-daemon/dist/daemon-client.d.ts +1 -0
- package/packages/lsp-daemon/dist/daemon-client.js +3 -0
- package/packages/lsp-daemon/dist/ensure-daemon.js +1 -0
- package/packages/lsp-daemon/dist/index.js +609 -262
- package/packages/lsp-daemon/dist/version-reap.js +1 -1
- package/packages/lsp-daemon/package.json +1 -1
- package/packages/lsp-tools-mcp/dist/cli.js +564 -217
- package/packages/lsp-tools-mcp/dist/lsp/manager.js +115 -92
- package/packages/lsp-tools-mcp/dist/mcp.js +566 -219
- package/packages/lsp-tools-mcp/dist/request-context.js +12 -13
- package/packages/lsp-tools-mcp/dist/tools.js +571 -227
- package/packages/omo-codex/THIRD-PARTY-NOTICES.md +4 -4
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +4 -4
- package/packages/omo-codex/plugin/AGENTS.md +47 -0
- package/packages/omo-codex/plugin/README.md +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +34 -33
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/src/hook.ts +1 -0
- package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +293 -116
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +245 -84
- package/packages/omo-codex/plugin/components/codegraph/package.json +4 -4
- package/packages/omo-codex/plugin/components/codegraph/src/mcp-bridge.ts +1 -0
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-hook-runtime.ts +1 -0
- package/packages/omo-codex/plugin/components/comment-checker/AGENTS.md +9 -0
- package/packages/omo-codex/plugin/components/comment-checker/biome.json +2 -2
- package/packages/omo-codex/plugin/components/comment-checker/dist/cli.js +2 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +5 -5
- package/packages/omo-codex/plugin/components/comment-checker/src/apply-patch.ts +2 -8
- package/packages/omo-codex/plugin/components/comment-checker/src/core.ts +1 -2
- package/packages/omo-codex/plugin/components/comment-checker/src/request-extractor.ts +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/src/runner.ts +1 -0
- package/packages/omo-codex/plugin/components/git-bash/AGENTS.md +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +3 -4
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/biome.json +2 -2
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/cli.js +1 -5
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/codex-hook.js +1 -5
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +5 -5
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/codex-hook.ts +1 -5
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/codex-hook.test.ts +4 -21
- package/packages/omo-codex/plugin/components/lsp/AGENTS.md +30 -15
- package/packages/omo-codex/plugin/components/lsp/biome.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +4 -4
- package/packages/omo-codex/plugin/components/lsp/dist/cli.js +596 -267
- package/packages/omo-codex/plugin/components/lsp/dist/daemon-cli-path.js +1 -1
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +5 -5
- package/packages/omo-codex/plugin/components/lsp/src/cli.ts +1 -1
- package/packages/omo-codex/plugin/components/lsp/src/codex-hook.ts +1 -1
- package/packages/omo-codex/plugin/components/lsp/src/daemon-cli-path.ts +1 -5
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook-unavailable.test.ts +6 -7
- package/packages/omo-codex/plugin/components/lsp/test/codex-hook.test.ts +1 -2
- package/packages/omo-codex/plugin/components/lsp/test/package-smoke.test.ts +11 -1
- package/packages/omo-codex/plugin/components/rules/AGENTS.md +12 -0
- package/packages/omo-codex/plugin/components/rules/biome.json +2 -2
- package/packages/omo-codex/plugin/components/rules/dist/cli.js +60 -45
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +7 -7
- package/packages/omo-codex/plugin/components/rules/src/config.ts +1 -2
- package/packages/omo-codex/plugin/components/rules/src/persistent-cache.ts +1 -2
- package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +9 -5
- package/packages/omo-codex/plugin/components/rules/src/rules-engine-factory.ts +1 -4
- package/packages/omo-codex/plugin/components/rules/src/static-injection.ts +4 -9
- package/packages/omo-codex/plugin/components/rules/test/bundled-rules-priority.test.ts +11 -16
- package/packages/omo-codex/plugin/components/rules/test/bundled-rules.test.ts +17 -25
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-budget.test.ts +9 -7
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-context.test.ts +0 -6
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-dedup.test.ts +6 -4
- package/packages/omo-codex/plugin/components/rules/test/codex-hook-post-compact-directive.test.ts +12 -9
- package/packages/omo-codex/plugin/components/rules/test/codex-hook.test.ts +28 -37
- package/packages/omo-codex/plugin/components/rules/test/dynamic-target-fingerprints.test.ts +1 -2
- package/packages/omo-codex/plugin/components/rules/test/engine.test.ts +7 -4
- package/packages/omo-codex/plugin/components/rules/test/finder.test.ts +2 -3
- package/packages/omo-codex/plugin/components/rules/test/formatter.test.ts +39 -72
- package/packages/omo-codex/plugin/components/rules/test/hephaestus-model-variant.test.ts +1 -2
- package/packages/omo-codex/plugin/components/rules/test/hook-output.test.ts +2 -3
- package/packages/omo-codex/plugin/components/rules/test/matcher.test.ts +2 -3
- package/packages/omo-codex/plugin/components/rules/test/package-smoke.test.ts +1 -1
- package/packages/omo-codex/plugin/components/rules/test/parser.test.ts +1 -2
- package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +5 -6
- package/packages/omo-codex/plugin/components/rules/test/rules-engine-consumption.test.ts +3 -6
- package/packages/omo-codex/plugin/components/rules/test/scanner.test.ts +1 -2
- package/packages/omo-codex/plugin/components/rules/test/sources.test.ts +2 -5
- package/packages/omo-codex/plugin/components/rules/test/windows-git-bash-bundled-rule.test.ts +2 -17
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +5 -5
- package/packages/omo-codex/plugin/components/teammode/test/thread-title-hook.test.ts +3 -9
- package/packages/omo-codex/plugin/components/telemetry/AGENTS.md +8 -0
- package/packages/omo-codex/plugin/components/telemetry/biome.json +2 -2
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +2463 -437
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +2467 -441
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +5 -5
- package/packages/omo-codex/plugin/components/telemetry/src/codex-hook.ts +1 -4
- package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +4 -14
- package/packages/omo-codex/plugin/components/telemetry/src/product-identity.ts +1 -1
- package/packages/omo-codex/plugin/components/telemetry/test/diagnostics.test.ts +2 -5
- package/packages/omo-codex/plugin/components/ultrawork/AGENTS.md +5 -0
- package/packages/omo-codex/plugin/components/ultrawork/biome.json +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/directive.md +13 -1
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +5 -5
- package/packages/omo-codex/plugin/components/ultrawork/skills/ultrawork/SKILL.md +13 -1
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +6 -6
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +31 -7
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-clear.md +2 -1
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-unclear.md +5 -5
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook-trigger-policy.test.ts +9 -1
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +0 -136
- package/packages/omo-codex/plugin/components/ultrawork/test/skill-pointer.test.ts +0 -2
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/AGENTS.md +5 -4
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/NOTICE +1 -1
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/README.md +5 -5
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/biome.json +2 -2
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/directive.md +6 -6
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/dist/cli.js +12 -12
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +28 -0
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/package.json +12 -12
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/boulder-reader.ts +1 -1
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/cli.ts +1 -1
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/codex-hook.ts +3 -3
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/directive.ts +1 -1
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/index.ts +1 -1
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/boulder-reader.test.ts +3 -3
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/cli.test.ts +1 -4
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/codex-hook.test.ts +8 -22
- package/packages/omo-codex/plugin/components/ulw-loop/AGENTS.md +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/biome.json +2 -2
- package/packages/omo-codex/plugin/components/ulw-loop/directive.md +13 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +5 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.d.ts +2 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-output.js +11 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +24 -14
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.js +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.js +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/stop-resume-hook.js +3 -3
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +3 -2
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/define-goal.md +108 -0
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +5 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-output.ts +13 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +3 -5
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-snapshot.ts +3 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-hook.ts +3 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/paths.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/stop-resume-hook.ts +3 -3
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-continuation.test.ts +0 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-create-goals.test.ts +25 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-entrypoint.test.ts +26 -2
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-instruction.test.ts +2 -2
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-snapshot.test.ts +18 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-hook.test.ts +0 -3
- package/packages/omo-codex/plugin/components/ulw-loop/test/package-smoke.test.ts +5 -37
- package/packages/omo-codex/plugin/components/ulw-loop/test/paths.test.ts +9 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/steering.test.ts +8 -5
- package/packages/omo-codex/plugin/components/ulw-loop/test/stop-resume-hook.test.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/ultrawork-directive.test.ts +4 -5
- package/packages/omo-codex/plugin/components/ulw-loop/vitest.config.ts +1 -0
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +17 -0
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-checking-ulw-execute-continuation.json +17 -0
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/model-catalog.json +3 -3
- package/packages/omo-codex/plugin/package-lock.json +681 -395
- package/packages/omo-codex/plugin/package.json +2 -2
- package/packages/omo-codex/plugin/scripts/AGENTS.md +40 -0
- package/packages/omo-codex/plugin/scripts/auto-update-plan.mjs +1 -1
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/catalog.mjs +3 -3
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +11 -11
- package/packages/omo-codex/plugin/shared/package.json +3 -4
- package/packages/omo-codex/plugin/skills/ast-grep/AGENTS.md +51 -0
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/AGENTS.md +62 -0
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +3 -2
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/all-platforms.md +1 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/references/senpi.md +4 -4
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +1 -1
- package/packages/omo-codex/plugin/skills/data-scientist/SKILL.md +99 -239
- package/packages/omo-codex/plugin/skills/data-scientist/references/execution-surfaces.md +91 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/placement.md +74 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/polars-lane.md +95 -0
- package/packages/omo-codex/plugin/skills/data-scientist/references/uv-setup.md +1 -1
- package/packages/omo-codex/plugin/skills/data-scientist/references/visualization.md +64 -0
- package/packages/omo-codex/plugin/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
- package/packages/omo-codex/plugin/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
- package/packages/omo-codex/plugin/skills/debugging/SKILL.md +2 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/00-setup.md +12 -0
- package/packages/omo-codex/plugin/skills/debugging/references/methodology/02-investigate.md +21 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/go.md +15 -1
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/native-binary.md +38 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/node.md +25 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/python.md +13 -0
- package/packages/omo-codex/plugin/skills/debugging/references/runtimes/rust.md +41 -0
- package/packages/omo-codex/plugin/skills/debugging/references/scripts/dap.mjs +267 -0
- package/packages/omo-codex/plugin/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/dap.md +103 -0
- package/packages/omo-codex/plugin/skills/debugging/references/tools/frida.md +193 -0
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +11 -7
- package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +1 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/print-paged-media.md +76 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/stylegallery.md +80 -0
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/README.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/orchestration.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/routing.md +5 -5
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +4 -4
- package/packages/omo-codex/plugin/skills/ultimate-browsing/ATTRIBUTION.md +37 -10
- package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +2 -0
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +179 -0
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/package.json +1 -1
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/chrome-stealth.md +13 -11
- package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +13 -1
- package/packages/omo-codex/plugin/skills/{start-work → ulw-execute}/SKILL.md +12 -11
- package/packages/omo-codex/plugin/skills/ulw-execute/agents/openai.yaml +2 -0
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +3 -2
- package/packages/omo-codex/plugin/skills/ulw-loop/references/define-goal.md +108 -0
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +1 -0
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +6 -6
- package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +31 -7
- package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-clear.md +2 -1
- package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-unclear.md +5 -5
- package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +4 -2
- package/packages/omo-codex/plugin/skills/visual-qa/AGENTS.md +58 -0
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +3 -2
- package/packages/omo-codex/plugin/test/AGENTS.md +47 -0
- package/packages/omo-codex/plugin/test/aggregate-agents.test.mjs +19 -173
- package/packages/omo-codex/plugin/test/aggregate-hooks.test.mjs +8 -28
- package/packages/omo-codex/plugin/test/aggregate-manifest.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/aggregate-model-catalog.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/aggregate-plugin-fixture.mjs +175 -13
- package/packages/omo-codex/plugin/test/aggregate.test.mjs +78 -2
- package/packages/omo-codex/plugin/test/auto-update-release-notes.test.mjs +19 -33
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +2 -2
- package/packages/omo-codex/plugin/test/component-bin-names.test.mjs +2 -2
- package/packages/omo-codex/plugin/test/component-bundled-cli.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/component-hook-contract-cases.mjs +2 -2
- package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +4 -4
- package/packages/omo-codex/plugin/test/lcx-contribute-bug-fix-template.test.mjs +21 -27
- package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +8 -8
- package/packages/omo-codex/plugin/test/scaffold-plan.test.mjs +0 -36
- package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +101 -0
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +12 -12
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +1 -119
- package/packages/omo-codex/plugin/test/teammode-archive-ambiguity.test.mjs +0 -40
- package/packages/omo-codex/plugin/test/teammode-communication.test.mjs +6 -62
- package/packages/omo-codex/plugin/test/teammode-thread-links.test.mjs +3 -36
- package/packages/omo-codex/plugin/test/teammode-transport.test.mjs +0 -44
- package/packages/omo-codex/plugin/test/teammode-worktree.test.mjs +2 -6
- package/packages/omo-codex/plugin/test/ultrawork-skill-pointer.test.mjs +0 -3
- package/packages/omo-codex/plugin/test/ulw-plan-review-state-contract.test.mjs +0 -3
- package/packages/omo-codex/scripts/AGENTS.md +36 -0
- package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +2 -2
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +2637 -549
- package/packages/omo-codex/scripts/install-lazycodex-version-stamp.test.mjs +7 -2
- package/packages/shared-skills/skills/ast-grep/AGENTS.md +51 -0
- package/packages/shared-skills/skills/coding-agent-sessions/AGENTS.md +62 -0
- package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +3 -2
- package/packages/shared-skills/skills/coding-agent-sessions/references/all-platforms.md +1 -1
- package/packages/shared-skills/skills/coding-agent-sessions/references/senpi.md +4 -4
- package/packages/shared-skills/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +1 -1
- package/packages/shared-skills/skills/data-scientist/SKILL.md +99 -239
- package/packages/shared-skills/skills/data-scientist/references/execution-surfaces.md +91 -0
- package/packages/shared-skills/skills/data-scientist/references/placement.md +74 -0
- package/packages/shared-skills/skills/data-scientist/references/polars-lane.md +95 -0
- package/packages/shared-skills/skills/data-scientist/references/uv-setup.md +1 -1
- package/packages/shared-skills/skills/data-scientist/references/visualization.md +64 -0
- package/packages/shared-skills/skills/data-scientist/scripts/ensure-js-deps.sh +28 -0
- package/packages/shared-skills/skills/data-scientist/scripts/ensure-py-deps.sh +37 -0
- package/packages/shared-skills/skills/debugging/SKILL.md +2 -0
- package/packages/shared-skills/skills/debugging/references/methodology/00-setup.md +12 -0
- package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +21 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/go.md +15 -1
- package/packages/shared-skills/skills/debugging/references/runtimes/native-binary.md +38 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/node.md +25 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/python.md +13 -0
- package/packages/shared-skills/skills/debugging/references/runtimes/rust.md +41 -0
- package/packages/shared-skills/skills/debugging/references/scripts/dap.mjs +267 -0
- package/packages/shared-skills/skills/debugging/references/scripts/dap.test.ts +86 -0
- package/packages/shared-skills/skills/debugging/references/scripts/fixture-adapter.mjs +59 -0
- package/packages/shared-skills/skills/debugging/references/tools/dap.md +103 -0
- package/packages/shared-skills/skills/debugging/references/tools/frida.md +193 -0
- package/packages/shared-skills/skills/frontend/SKILL.md +11 -7
- package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +1 -0
- package/packages/shared-skills/skills/frontend/references/design/print-paged-media.md +76 -0
- package/packages/shared-skills/skills/frontend/references/design/stylegallery.md +80 -0
- package/packages/shared-skills/skills/frontend/references/designpowers/README.md +1 -1
- package/packages/shared-skills/skills/frontend/references/designpowers/lane-a-direction.md +1 -1
- package/packages/shared-skills/skills/frontend/references/designpowers/lane-b-execution.md +11 -11
- package/packages/shared-skills/skills/frontend/references/designpowers/lane-d-memory.md +3 -3
- package/packages/shared-skills/skills/frontend/references/designpowers/orchestration.md +1 -1
- package/packages/shared-skills/skills/frontend/references/designpowers/routing.md +5 -5
- package/packages/shared-skills/skills/review-work/SKILL.md +3 -3
- package/packages/shared-skills/skills/ultimate-browsing/ATTRIBUTION.md +37 -10
- package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +2 -0
- package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +179 -0
- package/packages/shared-skills/skills/ultimate-browsing/engine/templates/package.json +1 -1
- package/packages/shared-skills/skills/ultimate-browsing/references/chrome-stealth.md +13 -11
- package/packages/shared-skills/skills/{start-work → ulw-execute}/SKILL.md +9 -8
- package/packages/shared-skills/skills/ulw-plan/SKILL.md +6 -6
- package/packages/shared-skills/skills/ulw-plan/references/full-workflow.md +31 -7
- package/packages/shared-skills/skills/ulw-plan/references/intent-clear.md +2 -1
- package/packages/shared-skills/skills/ulw-plan/references/intent-unclear.md +5 -5
- package/packages/shared-skills/skills/ulw-research/SKILL.md +4 -2
- package/packages/shared-skills/skills/visual-qa/AGENTS.md +58 -0
- package/packages/shared-skills/skills/visual-qa/SKILL.md +3 -2
- package/script/qa/web-terminal-visual-qa.mjs +2 -0
- package/script/qa/xterm-live-terminal.mjs +18 -2
- package/dist/config/schema/start-work.d.ts +0 -5
- package/dist/features/builtin-commands/templates/start-work.d.ts +0 -1
- package/dist/hooks/start-work/start-work-hook.d.ts +0 -23
- package/dist/plugin/chat-message/start-work-message.d.ts +0 -5
- package/dist/skills/data-scientist/references/common-scenarios.md +0 -176
- package/dist/skills/data-scientist/references/execution-templates.md +0 -197
- package/dist/skills/data-scientist/references/integration-patterns.md +0 -153
- package/dist/skills/data-scientist/references/performance-benchmarks.md +0 -37
- package/dist/tools/call-omo-agent/background-agent-executor.d.ts +0 -5
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +0 -28
- package/packages/omo-codex/plugin/hooks/stop-checking-start-work-continuation.json +0 -17
- package/packages/omo-codex/plugin/hooks/subagent-stop-checking-start-work-continuation.json +0 -17
- package/packages/omo-codex/plugin/skills/data-scientist/references/common-scenarios.md +0 -176
- package/packages/omo-codex/plugin/skills/data-scientist/references/execution-templates.md +0 -197
- package/packages/omo-codex/plugin/skills/data-scientist/references/integration-patterns.md +0 -153
- package/packages/omo-codex/plugin/skills/data-scientist/references/performance-benchmarks.md +0 -37
- package/packages/omo-codex/plugin/skills/start-work/agents/openai.yaml +0 -2
- package/packages/omo-codex/plugin/test/aggregate-skills.test.mjs +0 -92
- package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +0 -314
- package/packages/omo-codex/plugin/test/ulw-plan-scope-contract.test.mjs +0 -24
- package/packages/shared-skills/skills/data-scientist/references/common-scenarios.md +0 -176
- package/packages/shared-skills/skills/data-scientist/references/execution-templates.md +0 -197
- package/packages/shared-skills/skills/data-scientist/references/integration-patterns.md +0 -153
- package/packages/shared-skills/skills/data-scientist/references/performance-benchmarks.md +0 -37
- /package/dist/hooks/{start-work → ulw-execute}/context-info-formatters.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/explicit-plan-context.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/notepad-scaffold.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/parse-user-request.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/plan-discovery-context.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/plan-selection.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/session-plan-affinity.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/work-initializer.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/worktree-block.d.ts +0 -0
- /package/dist/hooks/{start-work → ulw-execute}/worktree-detector.d.ts +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/.gitattributes +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/CHANGELOG.md +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/LICENSE +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/plan-checklist.ts +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/src/types.ts +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-completed.json +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-mixed-platforms.json +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/boulder-single-codex-work.json +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-all-done.md +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-scaffold.md +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-with-nested-checkboxes.md +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/fixtures/plan-with-unchecked.md +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/tsconfig.build.json +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/tsconfig.json +0 -0
- /package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/vitest.config.ts +0 -0
|
@@ -27,9 +27,12 @@ import {
|
|
|
27
27
|
fsyncSync,
|
|
28
28
|
openSync,
|
|
29
29
|
renameSync,
|
|
30
|
+
rmSync,
|
|
30
31
|
unlinkSync,
|
|
31
32
|
writeFileSync
|
|
32
33
|
} from "node:fs";
|
|
34
|
+
import { randomUUID } from "node:crypto";
|
|
35
|
+
import { dirname } from "node:path";
|
|
33
36
|
var TOLERATED_FSYNC_CODES = new Set([
|
|
34
37
|
"EPERM",
|
|
35
38
|
"EACCES",
|
|
@@ -51,24 +54,36 @@ function tolerantFsyncSync(fileDescriptor, fsyncImpl) {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
function writeFileAtomically(filePath, content, options = {}) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
+
const platform = options.platform ?? process.platform;
|
|
58
|
+
const fsyncImpl = options.fsyncSync ?? fsyncSync;
|
|
59
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
57
60
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
writeFileSync(tempPath, content, "utf-8");
|
|
62
|
+
const tempFileDescriptor = openSync(tempPath, "r+");
|
|
63
|
+
try {
|
|
64
|
+
tolerantFsyncSync(tempFileDescriptor, fsyncImpl);
|
|
65
|
+
} finally {
|
|
66
|
+
closeSync(tempFileDescriptor);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
renameSync(tempPath, filePath);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
|
|
72
|
+
if (platform !== "win32" || !isPermissionError)
|
|
73
|
+
throw error;
|
|
67
74
|
unlinkSync(filePath);
|
|
68
75
|
renameSync(tempPath, filePath);
|
|
76
|
+
}
|
|
77
|
+
if (platform === "win32")
|
|
69
78
|
return;
|
|
79
|
+
const directoryFileDescriptor = openSync(dirname(filePath), "r");
|
|
80
|
+
try {
|
|
81
|
+
tolerantFsyncSync(directoryFileDescriptor, fsyncImpl);
|
|
82
|
+
} finally {
|
|
83
|
+
closeSync(directoryFileDescriptor);
|
|
70
84
|
}
|
|
71
|
-
|
|
85
|
+
} finally {
|
|
86
|
+
rmSync(tempPath, { force: true });
|
|
72
87
|
}
|
|
73
88
|
}
|
|
74
89
|
|
|
@@ -174,6 +189,7 @@ function writePostHogActivityState(stateDir, nextState, diagnostics) {
|
|
|
174
189
|
// ../../telemetry-core/src/constants.ts
|
|
175
190
|
var DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
|
|
176
191
|
var DEFAULT_POSTHOG_API_KEY = "phc_CFJhj5HyvA62QPhvyaUCtaq23aUfznnijg5VaaGkNk74";
|
|
192
|
+
var UNCONFIGURED_POSTHOG_API_KEY = "phc_REPLACE_ME_OMO_NATIVE";
|
|
177
193
|
|
|
178
194
|
// ../../telemetry-core/src/diagnostics.ts
|
|
179
195
|
import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
@@ -310,6 +326,9 @@ function shouldDisableTelemetry(input) {
|
|
|
310
326
|
const env = input.env ?? process.env;
|
|
311
327
|
const globalPrefix = input.globalEnvPrefix ?? "OMO";
|
|
312
328
|
const prefixes = Array.from(new Set([globalPrefix, input.productEnvPrefix]));
|
|
329
|
+
if (isDisableFlag(env["DO_NOT_TRACK"])) {
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
313
332
|
for (const prefix of prefixes) {
|
|
314
333
|
if (isDisableFlag(env[`${prefix}_DISABLE_POSTHOG`])) {
|
|
315
334
|
return true;
|
|
@@ -323,22 +342,19 @@ function shouldDisableTelemetry(input) {
|
|
|
323
342
|
function getTelemetryApiKey(env = process.env, defaultApiKey = DEFAULT_POSTHOG_API_KEY) {
|
|
324
343
|
return env["POSTHOG_API_KEY"]?.trim() ?? defaultApiKey;
|
|
325
344
|
}
|
|
326
|
-
function
|
|
327
|
-
|
|
345
|
+
function isConfiguredTelemetryApiKey(apiKey) {
|
|
346
|
+
const normalized = apiKey.trim();
|
|
347
|
+
return normalized.length > 0 && normalized !== UNCONFIGURED_POSTHOG_API_KEY;
|
|
328
348
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
import { createHash } from "node:crypto";
|
|
332
|
-
import os2 from "node:os";
|
|
333
|
-
function getDefaultTelemetryOsProvider() {
|
|
334
|
-
return os2;
|
|
349
|
+
function hasTelemetryApiKey(env, defaultApiKey) {
|
|
350
|
+
return isConfiguredTelemetryApiKey(getTelemetryApiKey(env, defaultApiKey));
|
|
335
351
|
}
|
|
336
|
-
function
|
|
337
|
-
return
|
|
352
|
+
function getTelemetryHost(env = process.env, defaultHost = DEFAULT_POSTHOG_HOST) {
|
|
353
|
+
return env["POSTHOG_HOST"]?.trim() || defaultHost;
|
|
338
354
|
}
|
|
339
355
|
|
|
340
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
341
|
-
import { dirname, posix, sep } from "node:path";
|
|
356
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
357
|
+
import { dirname as dirname2, posix, sep } from "node:path";
|
|
342
358
|
function createModulerModifier() {
|
|
343
359
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
344
360
|
return async (frames) => {
|
|
@@ -347,7 +363,7 @@ function createModulerModifier() {
|
|
|
347
363
|
return frames;
|
|
348
364
|
};
|
|
349
365
|
}
|
|
350
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
366
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname2(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
|
|
351
367
|
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
352
368
|
return (filename) => {
|
|
353
369
|
if (!filename)
|
|
@@ -373,7 +389,7 @@ function normalizeWindowsPath(path2) {
|
|
|
373
389
|
return path2.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
374
390
|
}
|
|
375
391
|
|
|
376
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
392
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
377
393
|
var normalizeFlagsResponse = (flagsResponse) => {
|
|
378
394
|
if ("flags" in flagsResponse) {
|
|
379
395
|
const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
|
|
@@ -443,8 +459,69 @@ var parsePayload = (response) => {
|
|
|
443
459
|
return response;
|
|
444
460
|
}
|
|
445
461
|
};
|
|
462
|
+
var MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES = [
|
|
463
|
+
"utm_source",
|
|
464
|
+
"utm_medium",
|
|
465
|
+
"utm_campaign",
|
|
466
|
+
"utm_content",
|
|
467
|
+
"utm_term",
|
|
468
|
+
"gad_source",
|
|
469
|
+
"mc_cid",
|
|
470
|
+
"gclid",
|
|
471
|
+
"gclsrc",
|
|
472
|
+
"dclid",
|
|
473
|
+
"gbraid",
|
|
474
|
+
"wbraid",
|
|
475
|
+
"fbclid",
|
|
476
|
+
"msclkid",
|
|
477
|
+
"twclid",
|
|
478
|
+
"li_fat_id",
|
|
479
|
+
"igshid",
|
|
480
|
+
"ttclid",
|
|
481
|
+
"rdt_cid",
|
|
482
|
+
"epik",
|
|
483
|
+
"qclid",
|
|
484
|
+
"sccid",
|
|
485
|
+
"irclid",
|
|
486
|
+
"_kx"
|
|
487
|
+
];
|
|
488
|
+
var MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
|
|
489
|
+
"$feature_flag",
|
|
490
|
+
"$feature_flag_response",
|
|
491
|
+
"$feature_flag_has_experiment",
|
|
492
|
+
"$feature_flag_id",
|
|
493
|
+
"$feature_flag_version",
|
|
494
|
+
"$feature_flag_reason",
|
|
495
|
+
"$feature_flag_request_id",
|
|
496
|
+
"$feature_flag_evaluated_at",
|
|
497
|
+
"$feature_flag_error",
|
|
498
|
+
"locally_evaluated",
|
|
499
|
+
"$groups",
|
|
500
|
+
"$process_person_profile",
|
|
501
|
+
"$geoip_disable",
|
|
502
|
+
"$current_url",
|
|
503
|
+
"$pathname",
|
|
504
|
+
"$referring_domain",
|
|
505
|
+
...MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES,
|
|
506
|
+
"$session_id",
|
|
507
|
+
"$window_id",
|
|
508
|
+
"$lib",
|
|
509
|
+
"$lib_version",
|
|
510
|
+
"$device_id",
|
|
511
|
+
"$is_server"
|
|
512
|
+
];
|
|
513
|
+
var minimizeFlagCalledEventProperties = (properties, transportKeys = []) => {
|
|
514
|
+
const minimal = {};
|
|
515
|
+
const copyKey = (key) => {
|
|
516
|
+
if (properties[key] !== undefined)
|
|
517
|
+
minimal[key] = properties[key];
|
|
518
|
+
};
|
|
519
|
+
MINIMAL_FLAG_CALLED_EVENT_PROPERTIES.forEach(copyKey);
|
|
520
|
+
transportKeys.forEach(copyKey);
|
|
521
|
+
return minimal;
|
|
522
|
+
};
|
|
446
523
|
|
|
447
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
524
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/types.mjs
|
|
448
525
|
var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedProperty) {
|
|
449
526
|
PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
|
|
450
527
|
PostHogPersistedProperty["DistinctId"] = "distinct_id";
|
|
@@ -459,6 +536,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
459
536
|
PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
|
|
460
537
|
PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
|
|
461
538
|
PostHogPersistedProperty["Queue"] = "queue";
|
|
539
|
+
PostHogPersistedProperty["AiQueue"] = "ai_queue";
|
|
540
|
+
PostHogPersistedProperty["AiCaptureQueue"] = "ai_capture_queue";
|
|
462
541
|
PostHogPersistedProperty["LogsQueue"] = "logs_queue";
|
|
463
542
|
PostHogPersistedProperty["OptedOut"] = "opted_out";
|
|
464
543
|
PostHogPersistedProperty["SessionId"] = "session_id";
|
|
@@ -469,6 +548,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
469
548
|
PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
|
|
470
549
|
PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
|
|
471
550
|
PostHogPersistedProperty["SessionReplay"] = "session_replay";
|
|
551
|
+
PostHogPersistedProperty["PushRegistered"] = "push_registered";
|
|
552
|
+
PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
|
|
472
553
|
PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
|
|
473
554
|
PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
|
|
474
555
|
PostHogPersistedProperty["Surveys"] = "surveys";
|
|
@@ -478,7 +559,7 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
478
559
|
return PostHogPersistedProperty;
|
|
479
560
|
}({});
|
|
480
561
|
|
|
481
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
562
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/gzip.mjs
|
|
482
563
|
function isGzipSupported() {
|
|
483
564
|
return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && typeof Response.prototype.blob == "function";
|
|
484
565
|
}
|
|
@@ -528,7 +609,7 @@ var validateNativeGzip = async (compressed, inputBytes) => {
|
|
|
528
609
|
async function gzipCompress(input, isDebug = true, options) {
|
|
529
610
|
try {
|
|
530
611
|
const inputBytes = new TextEncoder().encode(input);
|
|
531
|
-
const compressedStream = new CompressionStream("gzip");
|
|
612
|
+
const compressedStream = new globalThis.CompressionStream("gzip");
|
|
532
613
|
const writer = compressedStream.writable.getWriter();
|
|
533
614
|
const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
|
|
534
615
|
try {
|
|
@@ -552,7 +633,34 @@ async function gzipCompress(input, isDebug = true, options) {
|
|
|
552
633
|
}
|
|
553
634
|
}
|
|
554
635
|
|
|
555
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
636
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/json-utils.mjs
|
|
637
|
+
var MAX_JSON_SAFE_VALUE_DEPTH = 20;
|
|
638
|
+
var MAX_JSON_SAFE_VALUE_ITEMS = 1000;
|
|
639
|
+
var MAX_JSON_SAFE_VALUE_NODES = 1e4;
|
|
640
|
+
var CIRCULAR_VALUE = "[Circular]";
|
|
641
|
+
var TRUNCATED_VALUE = "[Truncated]";
|
|
642
|
+
var UNSERIALIZABLE_VALUE = "[Unserializable]";
|
|
643
|
+
var FUNCTION_VALUE = "[Function]";
|
|
644
|
+
var dateGetTime = Date.prototype.getTime;
|
|
645
|
+
var dateToISOString = Date.prototype.toISOString;
|
|
646
|
+
function sanitizeString(value) {
|
|
647
|
+
let output = "";
|
|
648
|
+
for (let index = 0;index < value.length; index++) {
|
|
649
|
+
const codeUnit = value.charCodeAt(index);
|
|
650
|
+
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
651
|
+
const nextCodeUnit = value.charCodeAt(index + 1);
|
|
652
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
653
|
+
output += value[index] + value[index + 1];
|
|
654
|
+
index++;
|
|
655
|
+
} else
|
|
656
|
+
output += "�";
|
|
657
|
+
} else
|
|
658
|
+
output += codeUnit >= 56320 && codeUnit <= 57343 ? "�" : value[index];
|
|
659
|
+
}
|
|
660
|
+
return output;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bot-detection.mjs
|
|
556
664
|
var DEFAULT_BLOCKED_UA_STRS = [
|
|
557
665
|
"amazonbot",
|
|
558
666
|
"amazonproductbot",
|
|
@@ -641,7 +749,31 @@ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
|
|
|
641
749
|
return uaLower.indexOf(blockedUaLower) !== -1;
|
|
642
750
|
});
|
|
643
751
|
};
|
|
644
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
752
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/string-utils.mjs
|
|
753
|
+
function safeJsonStringify(value) {
|
|
754
|
+
const ancestors = [];
|
|
755
|
+
return JSON.stringify(value, function(_key, replacementValue) {
|
|
756
|
+
if (typeof replacementValue == "bigint")
|
|
757
|
+
return replacementValue.toString();
|
|
758
|
+
if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
|
|
759
|
+
return;
|
|
760
|
+
if (replacementValue instanceof Error)
|
|
761
|
+
return {
|
|
762
|
+
name: replacementValue.name,
|
|
763
|
+
message: replacementValue.message,
|
|
764
|
+
stack: replacementValue.stack
|
|
765
|
+
};
|
|
766
|
+
if (replacementValue && typeof replacementValue == "object") {
|
|
767
|
+
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
|
|
768
|
+
ancestors.pop();
|
|
769
|
+
if (ancestors.includes(replacementValue))
|
|
770
|
+
return "[Circular]";
|
|
771
|
+
ancestors.push(replacementValue);
|
|
772
|
+
}
|
|
773
|
+
return replacementValue;
|
|
774
|
+
}) ?? "null";
|
|
775
|
+
}
|
|
776
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/type-utils.mjs
|
|
645
777
|
var nativeIsArray = Array.isArray;
|
|
646
778
|
var ObjProto = Object.prototype;
|
|
647
779
|
var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
|
|
@@ -653,14 +785,28 @@ var isObject = (x) => x === Object(x) && !isArray(x);
|
|
|
653
785
|
var isUndefined = (x) => x === undefined;
|
|
654
786
|
var isString = (x) => type_utils_toString.call(x) == "[object String]";
|
|
655
787
|
var isEmptyString = (x) => isString(x) && x.trim().length === 0;
|
|
788
|
+
var isNull = (x) => x === null;
|
|
789
|
+
var isNullish = (x) => isUndefined(x) || isNull(x);
|
|
656
790
|
var isNumber = (x) => type_utils_toString.call(x) == "[object Number]" && x === x;
|
|
657
|
-
var
|
|
791
|
+
var isBoolean = (x) => type_utils_toString.call(x) === "[object Boolean]";
|
|
658
792
|
function isPrimitive(value) {
|
|
659
793
|
return value === null || typeof value != "object";
|
|
660
794
|
}
|
|
661
795
|
function isBuiltin(candidate, className) {
|
|
662
796
|
return Object.prototype.toString.call(candidate) === `[object ${className}]`;
|
|
663
797
|
}
|
|
798
|
+
function isError(candidate) {
|
|
799
|
+
switch (Object.prototype.toString.call(candidate)) {
|
|
800
|
+
case "[object Error]":
|
|
801
|
+
case "[object Exception]":
|
|
802
|
+
case "[object DOMException]":
|
|
803
|
+
case "[object DOMError]":
|
|
804
|
+
case "[object WebAssembly.Exception]":
|
|
805
|
+
return true;
|
|
806
|
+
default:
|
|
807
|
+
return isInstanceOf(candidate, Error);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
664
810
|
function isErrorEvent(event) {
|
|
665
811
|
return isBuiltin(event, "ErrorEvent");
|
|
666
812
|
}
|
|
@@ -678,7 +824,7 @@ function isInstanceOf(candidate, base) {
|
|
|
678
824
|
}
|
|
679
825
|
}
|
|
680
826
|
|
|
681
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
827
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/number-utils.mjs
|
|
682
828
|
function clampToRange(value, min, max, logger, fallbackValue) {
|
|
683
829
|
if (min > max) {
|
|
684
830
|
logger.warn("min cannot be greater than max.");
|
|
@@ -698,8 +844,16 @@ function clampToRange(value, min, max, logger, fallbackValue) {
|
|
|
698
844
|
return clampToRange(fallbackValue || max, min, max, logger);
|
|
699
845
|
}
|
|
700
846
|
|
|
701
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
847
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
|
|
702
848
|
var ONE_DAY_IN_MS = 86400000;
|
|
849
|
+
var DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE = 1;
|
|
850
|
+
var DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE = 10;
|
|
851
|
+
function resolveExceptionRateLimiterConfig(config = {}) {
|
|
852
|
+
return {
|
|
853
|
+
refillRate: config.exceptionRateLimiterRefillRate ?? config.__exceptionRateLimiterRefillRate ?? DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE,
|
|
854
|
+
bucketSize: config.exceptionRateLimiterBucketSize ?? config.__exceptionRateLimiterBucketSize ?? DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE
|
|
855
|
+
};
|
|
856
|
+
}
|
|
703
857
|
|
|
704
858
|
class BucketedRateLimiter {
|
|
705
859
|
constructor(options) {
|
|
@@ -742,7 +896,7 @@ class BucketedRateLimiter {
|
|
|
742
896
|
this._buckets = {};
|
|
743
897
|
}
|
|
744
898
|
}
|
|
745
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
899
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
|
|
746
900
|
/*! For license information please see uuidv7.mjs.LICENSE.txt */
|
|
747
901
|
var DIGITS = "0123456789abcdef";
|
|
748
902
|
|
|
@@ -920,33 +1074,45 @@ var defaultGenerator;
|
|
|
920
1074
|
var uuidv7 = () => uuidv7obj().toString();
|
|
921
1075
|
var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator)).generate();
|
|
922
1076
|
|
|
923
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1077
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/promise-queue.mjs
|
|
924
1078
|
class PromiseQueue {
|
|
925
1079
|
add(promise) {
|
|
926
1080
|
const promiseUUID = uuidv7();
|
|
927
|
-
|
|
1081
|
+
const id = ++this.nextId;
|
|
1082
|
+
this.promiseByIds[promiseUUID] = {
|
|
1083
|
+
id,
|
|
1084
|
+
promise
|
|
1085
|
+
};
|
|
928
1086
|
promise.catch(() => {}).finally(() => {
|
|
929
1087
|
delete this.promiseByIds[promiseUUID];
|
|
930
1088
|
});
|
|
931
1089
|
return promise;
|
|
932
1090
|
}
|
|
933
1091
|
async join() {
|
|
934
|
-
let promises = Object.values(this.promiseByIds);
|
|
1092
|
+
let promises = Object.values(this.promiseByIds).map((item) => item.promise);
|
|
935
1093
|
let length = promises.length;
|
|
936
1094
|
while (length > 0) {
|
|
937
1095
|
await Promise.all(promises);
|
|
938
|
-
promises = Object.values(this.promiseByIds);
|
|
1096
|
+
promises = Object.values(this.promiseByIds).map((item) => item.promise);
|
|
939
1097
|
length = promises.length;
|
|
940
1098
|
}
|
|
941
1099
|
}
|
|
1100
|
+
getPromises(ignoredPromises = [], maxId = this.nextId) {
|
|
1101
|
+
const ignoredPromiseSet = new Set(ignoredPromises);
|
|
1102
|
+
return Object.values(this.promiseByIds).filter((item) => item.id <= maxId && !ignoredPromiseSet.has(item.promise)).map((item) => item.promise);
|
|
1103
|
+
}
|
|
1104
|
+
get maxId() {
|
|
1105
|
+
return this.nextId;
|
|
1106
|
+
}
|
|
942
1107
|
get length() {
|
|
943
1108
|
return Object.keys(this.promiseByIds).length;
|
|
944
1109
|
}
|
|
945
1110
|
constructor() {
|
|
946
1111
|
this.promiseByIds = {};
|
|
1112
|
+
this.nextId = 0;
|
|
947
1113
|
}
|
|
948
1114
|
}
|
|
949
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1115
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/logger.mjs
|
|
950
1116
|
function createConsole(consoleLike = console) {
|
|
951
1117
|
const lockedMethods = {
|
|
952
1118
|
log: consoleLike.log.bind(consoleLike),
|
|
@@ -987,7 +1153,7 @@ var passThrough = (fn) => fn();
|
|
|
987
1153
|
function createLogger(prefix, maybeCall = passThrough) {
|
|
988
1154
|
return _createLogger(prefix, maybeCall, createConsole());
|
|
989
1155
|
}
|
|
990
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1156
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
|
|
991
1157
|
var MOBILE = "Mobile";
|
|
992
1158
|
var IOS = "iOS";
|
|
993
1159
|
var ANDROID = "Android";
|
|
@@ -1030,6 +1196,7 @@ var DUCKDUCKGO = "DuckDuckGo";
|
|
|
1030
1196
|
var PALE_MOON = "Pale Moon";
|
|
1031
1197
|
var WATERFOX = "Waterfox";
|
|
1032
1198
|
var BRAVE = "Brave";
|
|
1199
|
+
var GOOGLE_SEARCH_APP = "Google Search App";
|
|
1033
1200
|
var BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
|
|
1034
1201
|
var DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
|
|
1035
1202
|
var XBOX_REGEX = new RegExp(XBOX, "i");
|
|
@@ -1117,6 +1284,9 @@ var versionRegexes = {
|
|
|
1117
1284
|
[WATERFOX]: [
|
|
1118
1285
|
new RegExp(WATERFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1119
1286
|
],
|
|
1287
|
+
[GOOGLE_SEARCH_APP]: [
|
|
1288
|
+
new RegExp("GSA\\/" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1289
|
+
],
|
|
1120
1290
|
[INTERNET_EXPLORER]: [
|
|
1121
1291
|
new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1122
1292
|
],
|
|
@@ -1276,8 +1446,15 @@ var osMatchers = [
|
|
|
1276
1446
|
]
|
|
1277
1447
|
];
|
|
1278
1448
|
|
|
1279
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1449
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/index.mjs
|
|
1280
1450
|
var STRING_FORMAT = "utf8";
|
|
1451
|
+
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1452
|
+
function isValidUUID(value) {
|
|
1453
|
+
return typeof value == "string" && UUID_REGEX.test(value);
|
|
1454
|
+
}
|
|
1455
|
+
function getEventUuid(uuid, generateUuid) {
|
|
1456
|
+
return isValidUUID(uuid) ? uuid : generateUuid();
|
|
1457
|
+
}
|
|
1281
1458
|
function removeTrailingSlash(url) {
|
|
1282
1459
|
return url?.replace(/\/+$/, "");
|
|
1283
1460
|
}
|
|
@@ -1305,7 +1482,26 @@ function safeSetTimeout(fn, timeout) {
|
|
|
1305
1482
|
t?.unref && t?.unref();
|
|
1306
1483
|
return t;
|
|
1307
1484
|
}
|
|
1308
|
-
|
|
1485
|
+
async function raceWithTimeout(promise, timeoutMs, onTimeout) {
|
|
1486
|
+
let timeoutHandle;
|
|
1487
|
+
try {
|
|
1488
|
+
return await Promise.race([
|
|
1489
|
+
promise,
|
|
1490
|
+
new Promise((resolve, reject) => {
|
|
1491
|
+
timeoutHandle = safeSetTimeout(() => {
|
|
1492
|
+
try {
|
|
1493
|
+
onTimeout?.();
|
|
1494
|
+
resolve();
|
|
1495
|
+
} catch (error) {
|
|
1496
|
+
reject(error);
|
|
1497
|
+
}
|
|
1498
|
+
}, timeoutMs);
|
|
1499
|
+
})
|
|
1500
|
+
]);
|
|
1501
|
+
} finally {
|
|
1502
|
+
clearTimeout(timeoutHandle);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1309
1505
|
function allSettled(promises) {
|
|
1310
1506
|
return Promise.all(promises.map((p) => (p ?? Promise.resolve()).then((value) => ({
|
|
1311
1507
|
status: "fulfilled",
|
|
@@ -1316,7 +1512,7 @@ function allSettled(promises) {
|
|
|
1316
1512
|
}))));
|
|
1317
1513
|
}
|
|
1318
1514
|
|
|
1319
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1515
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/logs/logs-utils.mjs
|
|
1320
1516
|
var OTLP_SEVERITY_MAP = {
|
|
1321
1517
|
trace: {
|
|
1322
1518
|
text: "TRACE",
|
|
@@ -1344,7 +1540,570 @@ var OTLP_SEVERITY_MAP = {
|
|
|
1344
1540
|
}
|
|
1345
1541
|
};
|
|
1346
1542
|
var DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
|
|
1347
|
-
|
|
1543
|
+
var INT64_RANGE_LIMIT = 9223372036854776000;
|
|
1544
|
+
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
1545
|
+
function newState() {
|
|
1546
|
+
return {
|
|
1547
|
+
ancestors: new WeakSet,
|
|
1548
|
+
remainingNodes: MAX_JSON_SAFE_VALUE_NODES
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
function toOtlpKeyValueList(attrs, logger2) {
|
|
1552
|
+
try {
|
|
1553
|
+
return encodeKeyValueList(attrs, logger2, newState(), 0);
|
|
1554
|
+
} catch {
|
|
1555
|
+
return [];
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function encodeAnyValue(value, logger2, state, depth) {
|
|
1559
|
+
if (state.remainingNodes <= 0)
|
|
1560
|
+
return {
|
|
1561
|
+
stringValue: TRUNCATED_VALUE
|
|
1562
|
+
};
|
|
1563
|
+
state.remainingNodes--;
|
|
1564
|
+
if (isBoolean(value))
|
|
1565
|
+
return {
|
|
1566
|
+
boolValue: value
|
|
1567
|
+
};
|
|
1568
|
+
if (typeof value == "number") {
|
|
1569
|
+
if (!Number.isFinite(value))
|
|
1570
|
+
return {
|
|
1571
|
+
stringValue: String(value)
|
|
1572
|
+
};
|
|
1573
|
+
if (Number.isInteger(value)) {
|
|
1574
|
+
if (Number.isSafeInteger(value))
|
|
1575
|
+
return {
|
|
1576
|
+
intValue: String(value)
|
|
1577
|
+
};
|
|
1578
|
+
if (typeof BigInt == "undefined")
|
|
1579
|
+
return {
|
|
1580
|
+
stringValue: String(value)
|
|
1581
|
+
};
|
|
1582
|
+
const decimal = BigInt(value).toString();
|
|
1583
|
+
if (value >= INT64_RANGE_LIMIT || value < -INT64_RANGE_LIMIT) {
|
|
1584
|
+
logger2?.debug(`Attribute ${decimal} is outside the int64 range; encoding it as a string`);
|
|
1585
|
+
return {
|
|
1586
|
+
stringValue: decimal
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
return {
|
|
1590
|
+
intValue: decimal
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
return {
|
|
1594
|
+
doubleValue: value
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
if (typeof value == "string")
|
|
1598
|
+
return {
|
|
1599
|
+
stringValue: sanitizeString(value)
|
|
1600
|
+
};
|
|
1601
|
+
if (typeof value == "function")
|
|
1602
|
+
return {
|
|
1603
|
+
stringValue: FUNCTION_VALUE
|
|
1604
|
+
};
|
|
1605
|
+
if (typeof value == "symbol")
|
|
1606
|
+
return {
|
|
1607
|
+
stringValue: String(value)
|
|
1608
|
+
};
|
|
1609
|
+
if (typeof value == "object" && value !== null) {
|
|
1610
|
+
if (state.ancestors.has(value))
|
|
1611
|
+
return {
|
|
1612
|
+
stringValue: CIRCULAR_VALUE
|
|
1613
|
+
};
|
|
1614
|
+
if (depth >= MAX_JSON_SAFE_VALUE_DEPTH)
|
|
1615
|
+
return {
|
|
1616
|
+
stringValue: TRUNCATED_VALUE
|
|
1617
|
+
};
|
|
1618
|
+
if (value instanceof Date) {
|
|
1619
|
+
const time = value.getTime();
|
|
1620
|
+
const iso = Number.isFinite(time) ? value.toISOString() : String(value);
|
|
1621
|
+
return {
|
|
1622
|
+
stringValue: typeof iso == "string" ? sanitizeString(iso) : String(iso)
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
state.ancestors.add(value);
|
|
1626
|
+
try {
|
|
1627
|
+
try {
|
|
1628
|
+
const toJSON = value.toJSON;
|
|
1629
|
+
if (typeof toJSON == "function")
|
|
1630
|
+
return encodeAnyValue(toJSON.call(value), logger2, state, depth + 1);
|
|
1631
|
+
} catch {}
|
|
1632
|
+
if (isArray(value))
|
|
1633
|
+
return {
|
|
1634
|
+
arrayValue: {
|
|
1635
|
+
values: encodeArrayValues(value, logger2, state, depth + 1)
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
return {
|
|
1639
|
+
kvlistValue: {
|
|
1640
|
+
values: encodeKeyValueList(value, logger2, state, depth + 1)
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
} finally {
|
|
1644
|
+
state.ancestors.delete(value);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
return {
|
|
1648
|
+
stringValue: sanitizeString(String(value))
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
function encodeArrayValues(values, logger2, state, depth) {
|
|
1652
|
+
const result = [];
|
|
1653
|
+
const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
|
|
1654
|
+
let index = 0;
|
|
1655
|
+
for (;index < itemCount && state.remainingNodes > 0; index++)
|
|
1656
|
+
try {
|
|
1657
|
+
const element = index in values ? values[index] : undefined;
|
|
1658
|
+
if (isNullish(element))
|
|
1659
|
+
continue;
|
|
1660
|
+
result.push(encodeAnyValue(element, logger2, state, depth));
|
|
1661
|
+
} catch {
|
|
1662
|
+
result.push({
|
|
1663
|
+
stringValue: UNSERIALIZABLE_VALUE
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
if (values.length > index)
|
|
1667
|
+
result.push({
|
|
1668
|
+
stringValue: TRUNCATED_VALUE
|
|
1669
|
+
});
|
|
1670
|
+
return result;
|
|
1671
|
+
}
|
|
1672
|
+
function encodeKeyValueList(attrs, logger2, state, depth) {
|
|
1673
|
+
const result = [];
|
|
1674
|
+
for (const key in attrs)
|
|
1675
|
+
if (propertyIsEnumerable.call(attrs, key)) {
|
|
1676
|
+
if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
|
|
1677
|
+
logger2?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");
|
|
1678
|
+
break;
|
|
1679
|
+
}
|
|
1680
|
+
try {
|
|
1681
|
+
const value = attrs[key];
|
|
1682
|
+
if (isNull(value) || isUndefined(value))
|
|
1683
|
+
continue;
|
|
1684
|
+
result.push({
|
|
1685
|
+
key: sanitizeString(key),
|
|
1686
|
+
value: encodeAnyValue(value, logger2, state, depth)
|
|
1687
|
+
});
|
|
1688
|
+
} catch {
|
|
1689
|
+
result.push({
|
|
1690
|
+
key: sanitizeString(key),
|
|
1691
|
+
value: {
|
|
1692
|
+
stringValue: UNSERIALIZABLE_VALUE
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
return result;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
|
|
1701
|
+
var DEFAULT_HISTOGRAM_BOUNDS = [
|
|
1702
|
+
0,
|
|
1703
|
+
5,
|
|
1704
|
+
10,
|
|
1705
|
+
25,
|
|
1706
|
+
50,
|
|
1707
|
+
75,
|
|
1708
|
+
100,
|
|
1709
|
+
250,
|
|
1710
|
+
500,
|
|
1711
|
+
750,
|
|
1712
|
+
1000,
|
|
1713
|
+
2500,
|
|
1714
|
+
5000,
|
|
1715
|
+
7500,
|
|
1716
|
+
1e4
|
|
1717
|
+
];
|
|
1718
|
+
function msToUnixNano(ms) {
|
|
1719
|
+
return String(ms) + "000000";
|
|
1720
|
+
}
|
|
1721
|
+
function seriesKey(type, name, unit, attributes) {
|
|
1722
|
+
let attrsKey = "";
|
|
1723
|
+
if (attributes) {
|
|
1724
|
+
const keys = Object.keys(attributes).sort();
|
|
1725
|
+
attrsKey = keys.map((k) => `${JSON.stringify(k)}:${JSON.stringify(attributes[k])}`).join(",");
|
|
1726
|
+
}
|
|
1727
|
+
return `${type}\x00${name}\x00${unit ?? ""}\x00${attrsKey}`;
|
|
1728
|
+
}
|
|
1729
|
+
function bucketIndexFor(value, bounds) {
|
|
1730
|
+
for (let i = 0;i < bounds.length; i++)
|
|
1731
|
+
if (value <= bounds[i])
|
|
1732
|
+
return i;
|
|
1733
|
+
return bounds.length;
|
|
1734
|
+
}
|
|
1735
|
+
function buildMetricsResourceAttributes(config, scopeName, scopeVersion) {
|
|
1736
|
+
return {
|
|
1737
|
+
...config.resourceAttributes,
|
|
1738
|
+
"service.name": config.serviceName || "unknown_service",
|
|
1739
|
+
...config.environment && {
|
|
1740
|
+
"deployment.environment": config.environment
|
|
1741
|
+
},
|
|
1742
|
+
...config.serviceVersion && {
|
|
1743
|
+
"service.version": config.serviceVersion
|
|
1744
|
+
},
|
|
1745
|
+
"telemetry.sdk.name": scopeName,
|
|
1746
|
+
"telemetry.sdk.version": scopeVersion
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVersion) {
|
|
1750
|
+
return {
|
|
1751
|
+
resourceMetrics: [
|
|
1752
|
+
{
|
|
1753
|
+
resource: {
|
|
1754
|
+
attributes: toOtlpKeyValueList(resourceAttributes)
|
|
1755
|
+
},
|
|
1756
|
+
scopeMetrics: [
|
|
1757
|
+
{
|
|
1758
|
+
scope: {
|
|
1759
|
+
name: scopeName,
|
|
1760
|
+
version: scopeVersion
|
|
1761
|
+
},
|
|
1762
|
+
metrics
|
|
1763
|
+
}
|
|
1764
|
+
]
|
|
1765
|
+
}
|
|
1766
|
+
]
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/config.mjs
|
|
1771
|
+
var DEFAULT_FLUSH_INTERVAL_MS = 1e4;
|
|
1772
|
+
var DEFAULT_MAX_SERIES_PER_FLUSH = 1000;
|
|
1773
|
+
function resolveMetricsConfig(config) {
|
|
1774
|
+
const resourceAttributes = config?.resourceAttributes;
|
|
1775
|
+
return {
|
|
1776
|
+
serviceName: resourceAttributes?.["service.name"] ?? config?.serviceName,
|
|
1777
|
+
serviceVersion: resourceAttributes?.["service.version"] ?? config?.serviceVersion,
|
|
1778
|
+
environment: resourceAttributes?.["deployment.environment"] ?? config?.environment,
|
|
1779
|
+
resourceAttributes,
|
|
1780
|
+
beforeSend: config?.beforeSend,
|
|
1781
|
+
flushIntervalMs: config?.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
|
|
1782
|
+
maxSeriesPerFlush: config?.maxSeriesPerFlush ?? DEFAULT_MAX_SERIES_PER_FLUSH
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/index.mjs
|
|
1787
|
+
var OTLP_TEMPORALITY_DELTA = 1;
|
|
1788
|
+
|
|
1789
|
+
class PostHogMetrics {
|
|
1790
|
+
constructor(_instance, _config, _logger) {
|
|
1791
|
+
this._instance = _instance;
|
|
1792
|
+
this._config = _config;
|
|
1793
|
+
this._logger = _logger;
|
|
1794
|
+
this._series = new Map;
|
|
1795
|
+
this._flushPromise = null;
|
|
1796
|
+
this._seriesCapWarned = false;
|
|
1797
|
+
this._typeByName = new Map;
|
|
1798
|
+
this._typeCollisionWarned = new Set;
|
|
1799
|
+
this._generation = 0;
|
|
1800
|
+
}
|
|
1801
|
+
count(name, value = 1, options) {
|
|
1802
|
+
this._capture({
|
|
1803
|
+
name,
|
|
1804
|
+
type: "count",
|
|
1805
|
+
value,
|
|
1806
|
+
unit: options?.unit,
|
|
1807
|
+
attributes: options?.attributes
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
gauge(name, value, options) {
|
|
1811
|
+
this._capture({
|
|
1812
|
+
name,
|
|
1813
|
+
type: "gauge",
|
|
1814
|
+
value,
|
|
1815
|
+
unit: options?.unit,
|
|
1816
|
+
attributes: options?.attributes
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
histogram(name, value, options) {
|
|
1820
|
+
this._capture({
|
|
1821
|
+
name,
|
|
1822
|
+
type: "histogram",
|
|
1823
|
+
value,
|
|
1824
|
+
unit: options?.unit,
|
|
1825
|
+
attributes: options?.attributes
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
flush() {
|
|
1829
|
+
const prev = this._flushPromise;
|
|
1830
|
+
const run = async () => {
|
|
1831
|
+
if (prev)
|
|
1832
|
+
await prev.catch(() => {});
|
|
1833
|
+
await this._doFlush();
|
|
1834
|
+
};
|
|
1835
|
+
const p = run().finally(() => {
|
|
1836
|
+
if (this._flushPromise === p)
|
|
1837
|
+
this._flushPromise = null;
|
|
1838
|
+
});
|
|
1839
|
+
this._flushPromise = p;
|
|
1840
|
+
return p;
|
|
1841
|
+
}
|
|
1842
|
+
drainWindow() {
|
|
1843
|
+
if (this._series.size === 0)
|
|
1844
|
+
return null;
|
|
1845
|
+
const window = this._series;
|
|
1846
|
+
this._series = new Map;
|
|
1847
|
+
this._seriesCapWarned = false;
|
|
1848
|
+
this._typeByName = new Map;
|
|
1849
|
+
this._typeCollisionWarned = new Set;
|
|
1850
|
+
return this._buildPayload(window);
|
|
1851
|
+
}
|
|
1852
|
+
reset() {
|
|
1853
|
+
this._generation++;
|
|
1854
|
+
this._clearFlushTimer();
|
|
1855
|
+
this._series = new Map;
|
|
1856
|
+
this._flushPromise = null;
|
|
1857
|
+
this._seriesCapWarned = false;
|
|
1858
|
+
this._typeByName = new Map;
|
|
1859
|
+
this._typeCollisionWarned = new Set;
|
|
1860
|
+
}
|
|
1861
|
+
_capture(sample) {
|
|
1862
|
+
if (this._instance.isDisabled || this._instance.optedOut)
|
|
1863
|
+
return;
|
|
1864
|
+
const filtered = this._runBeforeSend(sample);
|
|
1865
|
+
if (filtered === null)
|
|
1866
|
+
return;
|
|
1867
|
+
if (!filtered.name || typeof filtered.name != "string")
|
|
1868
|
+
return void this._logger.warn("Dropping metric with empty name");
|
|
1869
|
+
if (typeof filtered.value != "number" || !Number.isFinite(filtered.value))
|
|
1870
|
+
return void this._logger.warn(`Dropping metric '${filtered.name}': value must be a finite number`);
|
|
1871
|
+
if (filtered.type === "count" && filtered.value < 0)
|
|
1872
|
+
return void this._logger.warn(`Dropping count '${filtered.name}': counters are monotonic, value must be >= 0`);
|
|
1873
|
+
let attributes;
|
|
1874
|
+
let key;
|
|
1875
|
+
try {
|
|
1876
|
+
attributes = filtered.attributes ? {
|
|
1877
|
+
...filtered.attributes
|
|
1878
|
+
} : undefined;
|
|
1879
|
+
key = seriesKey(filtered.type, filtered.name, filtered.unit, attributes);
|
|
1880
|
+
} catch (e) {
|
|
1881
|
+
this._logger.warn(`Dropping metric '${filtered.name}': attributes could not be serialized`, e);
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
let state = this._series.get(key);
|
|
1885
|
+
if (!state) {
|
|
1886
|
+
if (!this._admitNewSeries())
|
|
1887
|
+
return;
|
|
1888
|
+
state = {
|
|
1889
|
+
name: filtered.name,
|
|
1890
|
+
type: filtered.type,
|
|
1891
|
+
unit: filtered.unit,
|
|
1892
|
+
attributes,
|
|
1893
|
+
windowStartMs: Date.now()
|
|
1894
|
+
};
|
|
1895
|
+
this._series.set(key, state);
|
|
1896
|
+
}
|
|
1897
|
+
const seenType = this._typeByName.get(filtered.name);
|
|
1898
|
+
if (seenType === undefined)
|
|
1899
|
+
this._typeByName.set(filtered.name, filtered.type);
|
|
1900
|
+
else if (seenType !== filtered.type && !this._typeCollisionWarned.has(filtered.name)) {
|
|
1901
|
+
this._typeCollisionWarned.add(filtered.name);
|
|
1902
|
+
this._logger.warn(`Metric name '${filtered.name}' is already used as a ${seenType}; recording it as a ${filtered.type} too will blend both series in charts. Use a distinct name.`);
|
|
1903
|
+
}
|
|
1904
|
+
this._fold(state, filtered.value);
|
|
1905
|
+
this._armFlushTimer();
|
|
1906
|
+
}
|
|
1907
|
+
_admitNewSeries() {
|
|
1908
|
+
if (this._series.size < this._config.maxSeriesPerFlush)
|
|
1909
|
+
return true;
|
|
1910
|
+
if (!this._seriesCapWarned) {
|
|
1911
|
+
this._seriesCapWarned = true;
|
|
1912
|
+
this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`);
|
|
1913
|
+
}
|
|
1914
|
+
return false;
|
|
1915
|
+
}
|
|
1916
|
+
_fold(state, value) {
|
|
1917
|
+
switch (state.type) {
|
|
1918
|
+
case "count":
|
|
1919
|
+
state.total = (state.total ?? 0) + value;
|
|
1920
|
+
break;
|
|
1921
|
+
case "gauge":
|
|
1922
|
+
state.last = value;
|
|
1923
|
+
break;
|
|
1924
|
+
case "histogram": {
|
|
1925
|
+
if (!state.hist)
|
|
1926
|
+
state.hist = {
|
|
1927
|
+
count: 0,
|
|
1928
|
+
sum: 0,
|
|
1929
|
+
min: value,
|
|
1930
|
+
max: value,
|
|
1931
|
+
bucketCounts: new Array(DEFAULT_HISTOGRAM_BOUNDS.length + 1).fill(0)
|
|
1932
|
+
};
|
|
1933
|
+
const hist = state.hist;
|
|
1934
|
+
hist.count += 1;
|
|
1935
|
+
hist.sum += value;
|
|
1936
|
+
hist.min = Math.min(hist.min, value);
|
|
1937
|
+
hist.max = Math.max(hist.max, value);
|
|
1938
|
+
hist.bucketCounts[bucketIndexFor(value, DEFAULT_HISTOGRAM_BOUNDS)] += 1;
|
|
1939
|
+
break;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
_runBeforeSend(sample) {
|
|
1944
|
+
const beforeSend = this._config.beforeSend;
|
|
1945
|
+
if (!beforeSend)
|
|
1946
|
+
return sample;
|
|
1947
|
+
const fns = isArray(beforeSend) ? beforeSend : [
|
|
1948
|
+
beforeSend
|
|
1949
|
+
];
|
|
1950
|
+
let result = sample;
|
|
1951
|
+
for (const fn of fns)
|
|
1952
|
+
try {
|
|
1953
|
+
const next = fn(result);
|
|
1954
|
+
if (!next) {
|
|
1955
|
+
this._logger.info("Metric was rejected in beforeSend function");
|
|
1956
|
+
return null;
|
|
1957
|
+
}
|
|
1958
|
+
result = next;
|
|
1959
|
+
} catch (e) {
|
|
1960
|
+
this._logger.error("Error in beforeSend function for metric:", e);
|
|
1961
|
+
return null;
|
|
1962
|
+
}
|
|
1963
|
+
return result;
|
|
1964
|
+
}
|
|
1965
|
+
_armFlushTimer() {
|
|
1966
|
+
if (this._flushTimer)
|
|
1967
|
+
return;
|
|
1968
|
+
this._flushTimer = safeSetTimeout(() => {
|
|
1969
|
+
this._flushTimer = undefined;
|
|
1970
|
+
this.flush().catch((e) => {
|
|
1971
|
+
this._logger.error("Metrics flush failed:", e);
|
|
1972
|
+
});
|
|
1973
|
+
}, this._config.flushIntervalMs);
|
|
1974
|
+
}
|
|
1975
|
+
_clearFlushTimer() {
|
|
1976
|
+
if (this._flushTimer) {
|
|
1977
|
+
clearTimeout(this._flushTimer);
|
|
1978
|
+
this._flushTimer = undefined;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
async _doFlush() {
|
|
1982
|
+
if (this._series.size === 0)
|
|
1983
|
+
return;
|
|
1984
|
+
const window = this._series;
|
|
1985
|
+
this._series = new Map;
|
|
1986
|
+
this._seriesCapWarned = false;
|
|
1987
|
+
this._typeByName = new Map;
|
|
1988
|
+
this._typeCollisionWarned = new Set;
|
|
1989
|
+
const generation = this._generation;
|
|
1990
|
+
const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
|
|
1991
|
+
if (generation !== this._generation)
|
|
1992
|
+
return;
|
|
1993
|
+
switch (outcome.kind) {
|
|
1994
|
+
case "ok":
|
|
1995
|
+
return;
|
|
1996
|
+
case "retry-later":
|
|
1997
|
+
this._mergeWindowBack(window);
|
|
1998
|
+
this._armFlushTimer();
|
|
1999
|
+
return;
|
|
2000
|
+
case "too-large":
|
|
2001
|
+
this._logger.warn("Metrics batch exceeded the server size limit and was dropped");
|
|
2002
|
+
return;
|
|
2003
|
+
case "fatal":
|
|
2004
|
+
this._logger.error("Failed to send metrics batch:", outcome.error);
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
_buildPayload(window) {
|
|
2009
|
+
return buildOtlpMetricsPayload(this._buildMetrics(window), buildMetricsResourceAttributes(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion()), this._instance.getLibraryId(), this._instance.getLibraryVersion());
|
|
2010
|
+
}
|
|
2011
|
+
_buildMetrics(window) {
|
|
2012
|
+
const nowNano = msToUnixNano(Date.now());
|
|
2013
|
+
const byMetric = new Map;
|
|
2014
|
+
for (const state of window.values()) {
|
|
2015
|
+
const metricKey = seriesKey(state.type, state.name, state.unit, undefined);
|
|
2016
|
+
let metric = byMetric.get(metricKey);
|
|
2017
|
+
if (!metric) {
|
|
2018
|
+
metric = {
|
|
2019
|
+
name: state.name,
|
|
2020
|
+
...state.unit && {
|
|
2021
|
+
unit: state.unit
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
if (state.type === "count")
|
|
2025
|
+
metric.sum = {
|
|
2026
|
+
aggregationTemporality: OTLP_TEMPORALITY_DELTA,
|
|
2027
|
+
isMonotonic: true,
|
|
2028
|
+
dataPoints: []
|
|
2029
|
+
};
|
|
2030
|
+
else if (state.type === "gauge")
|
|
2031
|
+
metric.gauge = {
|
|
2032
|
+
dataPoints: []
|
|
2033
|
+
};
|
|
2034
|
+
else
|
|
2035
|
+
metric.histogram = {
|
|
2036
|
+
aggregationTemporality: OTLP_TEMPORALITY_DELTA,
|
|
2037
|
+
dataPoints: []
|
|
2038
|
+
};
|
|
2039
|
+
byMetric.set(metricKey, metric);
|
|
2040
|
+
}
|
|
2041
|
+
const attributes = toOtlpKeyValueList(state.attributes ?? {}, this._logger);
|
|
2042
|
+
const startNano = msToUnixNano(state.windowStartMs);
|
|
2043
|
+
if (state.type === "count") {
|
|
2044
|
+
const dp = {
|
|
2045
|
+
attributes,
|
|
2046
|
+
startTimeUnixNano: startNano,
|
|
2047
|
+
timeUnixNano: nowNano,
|
|
2048
|
+
asDouble: state.total ?? 0
|
|
2049
|
+
};
|
|
2050
|
+
metric.sum.dataPoints.push(dp);
|
|
2051
|
+
} else if (state.type === "gauge") {
|
|
2052
|
+
const dp = {
|
|
2053
|
+
attributes,
|
|
2054
|
+
timeUnixNano: nowNano,
|
|
2055
|
+
asDouble: state.last ?? 0
|
|
2056
|
+
};
|
|
2057
|
+
metric.gauge.dataPoints.push(dp);
|
|
2058
|
+
} else if (state.hist) {
|
|
2059
|
+
const dp = {
|
|
2060
|
+
attributes,
|
|
2061
|
+
startTimeUnixNano: startNano,
|
|
2062
|
+
timeUnixNano: nowNano,
|
|
2063
|
+
count: state.hist.count,
|
|
2064
|
+
sum: state.hist.sum,
|
|
2065
|
+
min: state.hist.min,
|
|
2066
|
+
max: state.hist.max,
|
|
2067
|
+
bucketCounts: state.hist.bucketCounts,
|
|
2068
|
+
explicitBounds: DEFAULT_HISTOGRAM_BOUNDS
|
|
2069
|
+
};
|
|
2070
|
+
metric.histogram.dataPoints.push(dp);
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
return Array.from(byMetric.values());
|
|
2074
|
+
}
|
|
2075
|
+
_mergeWindowBack(window) {
|
|
2076
|
+
for (const [key, old] of window) {
|
|
2077
|
+
const current = this._series.get(key);
|
|
2078
|
+
if (!current) {
|
|
2079
|
+
if (this._admitNewSeries())
|
|
2080
|
+
this._series.set(key, old);
|
|
2081
|
+
continue;
|
|
2082
|
+
}
|
|
2083
|
+
current.windowStartMs = Math.min(current.windowStartMs, old.windowStartMs);
|
|
2084
|
+
switch (current.type) {
|
|
2085
|
+
case "count":
|
|
2086
|
+
current.total = (current.total ?? 0) + (old.total ?? 0);
|
|
2087
|
+
break;
|
|
2088
|
+
case "gauge":
|
|
2089
|
+
break;
|
|
2090
|
+
case "histogram":
|
|
2091
|
+
if (old.hist)
|
|
2092
|
+
if (current.hist) {
|
|
2093
|
+
current.hist.count += old.hist.count;
|
|
2094
|
+
current.hist.sum += old.hist.sum;
|
|
2095
|
+
current.hist.min = Math.min(current.hist.min, old.hist.min);
|
|
2096
|
+
current.hist.max = Math.max(current.hist.max, old.hist.max);
|
|
2097
|
+
for (let i = 0;i < current.hist.bucketCounts.length; i++)
|
|
2098
|
+
current.hist.bucketCounts[i] += old.hist.bucketCounts[i];
|
|
2099
|
+
} else
|
|
2100
|
+
current.hist = old.hist;
|
|
2101
|
+
break;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/eventemitter.mjs
|
|
1348
2107
|
class SimpleEventEmitter {
|
|
1349
2108
|
constructor() {
|
|
1350
2109
|
this.events = {};
|
|
@@ -1366,37 +2125,38 @@ class SimpleEventEmitter {
|
|
|
1366
2125
|
}
|
|
1367
2126
|
}
|
|
1368
2127
|
|
|
1369
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2128
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
1370
2129
|
var exports_error_tracking = {};
|
|
1371
2130
|
__export(exports_error_tracking, {
|
|
1372
|
-
|
|
1373
|
-
stripReservedExceptionStepFields: () => stripReservedExceptionStepFields,
|
|
1374
|
-
reverseAndStripFrames: () => reverseAndStripFrames,
|
|
1375
|
-
resolveExceptionStepsConfig: () => resolveExceptionStepsConfig,
|
|
1376
|
-
opera11StackLineParser: () => opera11StackLineParser,
|
|
1377
|
-
opera10StackLineParser: () => opera10StackLineParser,
|
|
1378
|
-
nodeStackLineParser: () => nodeStackLineParser,
|
|
1379
|
-
getUtf8ByteLength: () => getUtf8ByteLength,
|
|
1380
|
-
geckoStackLineParser: () => geckoStackLineParser,
|
|
1381
|
-
createStackParser: () => createStackParser,
|
|
1382
|
-
createDefaultStackParser: () => createDefaultStackParser,
|
|
1383
|
-
chromeStackLineParser: () => chromeStackLineParser,
|
|
1384
|
-
StringCoercer: () => StringCoercer,
|
|
1385
|
-
ReduceableCache: () => ReduceableCache,
|
|
1386
|
-
PromiseRejectionEventCoercer: () => PromiseRejectionEventCoercer,
|
|
1387
|
-
PrimitiveCoercer: () => PrimitiveCoercer,
|
|
1388
|
-
ObjectCoercer: () => ObjectCoercer,
|
|
1389
|
-
ExceptionStepsBuffer: () => ExceptionStepsBuffer,
|
|
1390
|
-
EventCoercer: () => EventCoercer,
|
|
1391
|
-
ErrorPropertiesBuilder: () => ErrorPropertiesBuilder,
|
|
1392
|
-
ErrorEventCoercer: () => ErrorEventCoercer,
|
|
1393
|
-
ErrorCoercer: () => ErrorCoercer,
|
|
1394
|
-
EXCEPTION_STEP_INTERNAL_FIELDS: () => EXCEPTION_STEP_INTERNAL_FIELDS,
|
|
2131
|
+
DEFAULT_EXCEPTION_STEPS_CONFIG: () => DEFAULT_EXCEPTION_STEPS_CONFIG,
|
|
1395
2132
|
DOMExceptionCoercer: () => DOMExceptionCoercer,
|
|
1396
|
-
|
|
2133
|
+
EXCEPTION_STEP_INTERNAL_FIELDS: () => EXCEPTION_STEP_INTERNAL_FIELDS,
|
|
2134
|
+
ErrorCoercer: () => ErrorCoercer,
|
|
2135
|
+
ErrorEventCoercer: () => ErrorEventCoercer,
|
|
2136
|
+
ErrorPropertiesBuilder: () => ErrorPropertiesBuilder,
|
|
2137
|
+
EventCoercer: () => EventCoercer,
|
|
2138
|
+
ExceptionStepsBuffer: () => ExceptionStepsBuffer,
|
|
2139
|
+
ObjectCoercer: () => ObjectCoercer,
|
|
2140
|
+
PrimitiveCoercer: () => PrimitiveCoercer,
|
|
2141
|
+
PromiseRejectionEventCoercer: () => PromiseRejectionEventCoercer,
|
|
2142
|
+
ReduceableCache: () => ReduceableCache,
|
|
2143
|
+
StringCoercer: () => StringCoercer,
|
|
2144
|
+
chromeStackLineParser: () => chromeStackLineParser,
|
|
2145
|
+
createDefaultStackParser: () => createDefaultStackParser,
|
|
2146
|
+
createStackParser: () => createStackParser,
|
|
2147
|
+
geckoStackLineParser: () => geckoStackLineParser,
|
|
2148
|
+
getInjectedReleaseId: () => getInjectedReleaseId,
|
|
2149
|
+
getUtf8ByteLength: () => getUtf8ByteLength,
|
|
2150
|
+
nodeStackLineParser: () => nodeStackLineParser,
|
|
2151
|
+
opera10StackLineParser: () => opera10StackLineParser,
|
|
2152
|
+
opera11StackLineParser: () => opera11StackLineParser,
|
|
2153
|
+
resolveExceptionStepsConfig: () => resolveExceptionStepsConfig,
|
|
2154
|
+
reverseAndStripFrames: () => reverseAndStripFrames,
|
|
2155
|
+
stripReservedExceptionStepFields: () => stripReservedExceptionStepFields,
|
|
2156
|
+
winjsStackLineParser: () => winjsStackLineParser
|
|
1397
2157
|
});
|
|
1398
2158
|
|
|
1399
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2159
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
|
|
1400
2160
|
var parsedStackResults;
|
|
1401
2161
|
var lastKeysCount;
|
|
1402
2162
|
var cachedFilenameChunkIds;
|
|
@@ -1435,7 +2195,7 @@ function getFilenameToChunkIdMap(stackParser) {
|
|
|
1435
2195
|
return cachedFilenameChunkIds;
|
|
1436
2196
|
}
|
|
1437
2197
|
|
|
1438
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2198
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
|
|
1439
2199
|
var MAX_CAUSE_RECURSION = 4;
|
|
1440
2200
|
|
|
1441
2201
|
class ErrorPropertiesBuilder {
|
|
@@ -1557,14 +2317,16 @@ class ErrorPropertiesBuilder {
|
|
|
1557
2317
|
return context;
|
|
1558
2318
|
}
|
|
1559
2319
|
}
|
|
1560
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2320
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
|
|
1561
2321
|
var UNKNOWN_FUNCTION = "?";
|
|
2322
|
+
var MASKED_URL_PREFIX = "webkit-masked-url://";
|
|
2323
|
+
var ANONYMOUS_FILENAME = "<anonymous>";
|
|
1562
2324
|
function createFrame(platform, filename, func, lineno, colno) {
|
|
1563
2325
|
const frame = {
|
|
1564
2326
|
platform,
|
|
1565
2327
|
filename,
|
|
1566
2328
|
function: func === "<anonymous>" ? UNKNOWN_FUNCTION : func,
|
|
1567
|
-
in_app:
|
|
2329
|
+
in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
|
|
1568
2330
|
};
|
|
1569
2331
|
if (!isUndefined(lineno))
|
|
1570
2332
|
frame.lineno = lineno;
|
|
@@ -1573,7 +2335,7 @@ function createFrame(platform, filename, func, lineno, colno) {
|
|
|
1573
2335
|
return frame;
|
|
1574
2336
|
}
|
|
1575
2337
|
|
|
1576
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2338
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
|
|
1577
2339
|
var extractSafariExtensionDetails = (func, filename) => {
|
|
1578
2340
|
const isSafariExtension = func.indexOf("safari-extension") !== -1;
|
|
1579
2341
|
const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
|
|
@@ -1586,7 +2348,7 @@ var extractSafariExtensionDetails = (func, filename) => {
|
|
|
1586
2348
|
];
|
|
1587
2349
|
};
|
|
1588
2350
|
|
|
1589
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2351
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
|
|
1590
2352
|
var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
|
|
1591
2353
|
var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
1592
2354
|
var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
|
@@ -1612,7 +2374,7 @@ var chromeStackLineParser = (line, platform) => {
|
|
|
1612
2374
|
}
|
|
1613
2375
|
};
|
|
1614
2376
|
|
|
1615
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2377
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
|
|
1616
2378
|
var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
1617
2379
|
var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
1618
2380
|
var geckoStackLineParser = (line, platform) => {
|
|
@@ -1635,14 +2397,14 @@ var geckoStackLineParser = (line, platform) => {
|
|
|
1635
2397
|
}
|
|
1636
2398
|
};
|
|
1637
2399
|
|
|
1638
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2400
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/winjs.mjs
|
|
1639
2401
|
var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1640
2402
|
var winjsStackLineParser = (line, platform) => {
|
|
1641
2403
|
const parts = winjsRegex.exec(line);
|
|
1642
2404
|
return parts ? createFrame(platform, parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined) : undefined;
|
|
1643
2405
|
};
|
|
1644
2406
|
|
|
1645
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2407
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
|
|
1646
2408
|
var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
|
|
1647
2409
|
var opera10StackLineParser = (line, platform) => {
|
|
1648
2410
|
const parts = opera10Regex.exec(line);
|
|
@@ -1654,9 +2416,12 @@ var opera11StackLineParser = (line, platform) => {
|
|
|
1654
2416
|
return parts ? createFrame(platform, parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
|
|
1655
2417
|
};
|
|
1656
2418
|
|
|
1657
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2419
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
|
|
1658
2420
|
var FILENAME_MATCH = /^\s*[-]{4,}$/;
|
|
1659
2421
|
var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
|
|
2422
|
+
var PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
|
|
2423
|
+
var PROMISE_INDEX = /^index \d+$/;
|
|
2424
|
+
var PROMISE_FRAME_FILENAME = "node:internal/promise";
|
|
1660
2425
|
var nodeStackLineParser = (line, platform) => {
|
|
1661
2426
|
const lineMatch = line.match(FULL_MATCH);
|
|
1662
2427
|
if (lineMatch) {
|
|
@@ -1699,6 +2464,8 @@ var nodeStackLineParser = (line, platform) => {
|
|
|
1699
2464
|
filename = filename.slice(1);
|
|
1700
2465
|
if (!filename && lineMatch[5] && !isNative)
|
|
1701
2466
|
filename = lineMatch[5];
|
|
2467
|
+
if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || ""))
|
|
2468
|
+
filename = PROMISE_FRAME_FILENAME;
|
|
1702
2469
|
return {
|
|
1703
2470
|
filename: filename ? decodeURI(filename) : undefined,
|
|
1704
2471
|
module: undefined,
|
|
@@ -1723,7 +2490,7 @@ function _parseIntOrUndefined(input) {
|
|
|
1723
2490
|
return parseInt(input || "", 10) || undefined;
|
|
1724
2491
|
}
|
|
1725
2492
|
|
|
1726
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2493
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
|
|
1727
2494
|
var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
1728
2495
|
var STACKTRACE_FRAME_LIMIT = 50;
|
|
1729
2496
|
function reverseAndStripFrames(stack) {
|
|
@@ -1768,7 +2535,7 @@ function createStackParser(platform, ...parsers) {
|
|
|
1768
2535
|
return reverseAndStripFrames(frames);
|
|
1769
2536
|
};
|
|
1770
2537
|
}
|
|
1771
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2538
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/dom-exception-coercer.mjs
|
|
1772
2539
|
class DOMExceptionCoercer {
|
|
1773
2540
|
match(err) {
|
|
1774
2541
|
return this.isDOMException(err) || this.isDOMError(err);
|
|
@@ -1798,18 +2565,20 @@ class DOMExceptionCoercer {
|
|
|
1798
2565
|
return isBuiltin(err, "DOMError");
|
|
1799
2566
|
}
|
|
1800
2567
|
}
|
|
1801
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2568
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
|
|
1802
2569
|
class ErrorCoercer {
|
|
1803
2570
|
match(err) {
|
|
1804
|
-
return
|
|
2571
|
+
return isError(err);
|
|
1805
2572
|
}
|
|
1806
2573
|
coerce(err, ctx) {
|
|
2574
|
+
const stack = this.getStack(err);
|
|
2575
|
+
const synthetic = stack === undefined;
|
|
1807
2576
|
return {
|
|
1808
2577
|
type: this.getType(err),
|
|
1809
2578
|
value: this.getMessage(err, ctx),
|
|
1810
|
-
stack:
|
|
2579
|
+
stack: stack ?? ctx.syntheticException?.stack,
|
|
1811
2580
|
cause: err.cause ? ctx.next(err.cause) : undefined,
|
|
1812
|
-
synthetic
|
|
2581
|
+
synthetic
|
|
1813
2582
|
};
|
|
1814
2583
|
}
|
|
1815
2584
|
getType(err) {
|
|
@@ -1825,25 +2594,41 @@ class ErrorCoercer {
|
|
|
1825
2594
|
return err.stacktrace || err.stack || undefined;
|
|
1826
2595
|
}
|
|
1827
2596
|
}
|
|
1828
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2597
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/error-event-coercer.mjs
|
|
1829
2598
|
class ErrorEventCoercer {
|
|
1830
2599
|
constructor() {}
|
|
1831
2600
|
match(err) {
|
|
1832
|
-
|
|
2601
|
+
if (!isErrorEvent(err))
|
|
2602
|
+
return false;
|
|
2603
|
+
const errorEvent = err;
|
|
2604
|
+
return errorEvent.error != null || this._hasUsableMessage(errorEvent);
|
|
1833
2605
|
}
|
|
1834
2606
|
coerce(err, ctx) {
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
2607
|
+
if (err.error != null)
|
|
2608
|
+
return ctx.apply(err.error);
|
|
2609
|
+
const exceptionLike = ctx.apply(err.message);
|
|
2610
|
+
return {
|
|
2611
|
+
...exceptionLike,
|
|
2612
|
+
stack: this._buildLocationStack(err) ?? exceptionLike.stack,
|
|
2613
|
+
synthetic: true
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
_hasUsableMessage(err) {
|
|
2617
|
+
return isString(err.message) && err.message.length > 0;
|
|
2618
|
+
}
|
|
2619
|
+
_buildLocationStack(err) {
|
|
2620
|
+
const location = err;
|
|
2621
|
+
const lineno = location.lineno ?? 0;
|
|
2622
|
+
const colno = location.colno ?? 0;
|
|
2623
|
+
if (!isString(location.filename) || location.filename.length === 0)
|
|
2624
|
+
return;
|
|
2625
|
+
if (lineno === 0)
|
|
2626
|
+
return;
|
|
2627
|
+
return `Error
|
|
2628
|
+
at ${location.filename}:${lineno}:${colno}`;
|
|
1844
2629
|
}
|
|
1845
2630
|
}
|
|
1846
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2631
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
|
|
1847
2632
|
var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
|
|
1848
2633
|
|
|
1849
2634
|
class StringCoercer {
|
|
@@ -1873,7 +2658,7 @@ class StringCoercer {
|
|
|
1873
2658
|
];
|
|
1874
2659
|
}
|
|
1875
2660
|
}
|
|
1876
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2661
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/types.mjs
|
|
1877
2662
|
var severityLevels = [
|
|
1878
2663
|
"fatal",
|
|
1879
2664
|
"error",
|
|
@@ -1883,7 +2668,7 @@ var severityLevels = [
|
|
|
1883
2668
|
"debug"
|
|
1884
2669
|
];
|
|
1885
2670
|
|
|
1886
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2671
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
|
|
1887
2672
|
function extractExceptionKeysForMessage(err, maxLength = 40) {
|
|
1888
2673
|
const keys = Object.keys(err);
|
|
1889
2674
|
keys.sort();
|
|
@@ -1900,7 +2685,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
|
|
|
1900
2685
|
return "";
|
|
1901
2686
|
}
|
|
1902
2687
|
|
|
1903
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2688
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
|
|
1904
2689
|
class ObjectCoercer {
|
|
1905
2690
|
match(candidate) {
|
|
1906
2691
|
return typeof candidate == "object" && candidate !== null;
|
|
@@ -1912,13 +2697,16 @@ class ObjectCoercer {
|
|
|
1912
2697
|
return {
|
|
1913
2698
|
type: this.getType(candidate),
|
|
1914
2699
|
value: this.getValue(candidate),
|
|
1915
|
-
stack: ctx.syntheticException?.stack,
|
|
2700
|
+
stack: this.getStack(candidate) ?? ctx.syntheticException?.stack,
|
|
1916
2701
|
level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
|
|
1917
2702
|
synthetic: true
|
|
1918
2703
|
};
|
|
1919
2704
|
}
|
|
1920
2705
|
getType(err) {
|
|
1921
|
-
|
|
2706
|
+
if (isEvent(err))
|
|
2707
|
+
return err.constructor.name;
|
|
2708
|
+
const name = "name" in err ? err.name : undefined;
|
|
2709
|
+
return isString(name) && !isEmptyString(name) ? name : "Error";
|
|
1922
2710
|
}
|
|
1923
2711
|
getValue(err) {
|
|
1924
2712
|
if ("name" in err && typeof err.name == "string") {
|
|
@@ -1936,6 +2724,15 @@ class ObjectCoercer {
|
|
|
1936
2724
|
isSeverityLevel(x) {
|
|
1937
2725
|
return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
|
|
1938
2726
|
}
|
|
2727
|
+
getStack(candidate) {
|
|
2728
|
+
try {
|
|
2729
|
+
if (isString(candidate.stacktrace) && candidate.stacktrace.length > 0)
|
|
2730
|
+
return candidate.stacktrace;
|
|
2731
|
+
return isString(candidate.stack) && candidate.stack.length > 0 ? candidate.stack : undefined;
|
|
2732
|
+
} catch {
|
|
2733
|
+
return;
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
1939
2736
|
getErrorPropertyFromObject(obj) {
|
|
1940
2737
|
for (const prop in obj)
|
|
1941
2738
|
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
@@ -1953,7 +2750,7 @@ class ObjectCoercer {
|
|
|
1953
2750
|
}
|
|
1954
2751
|
}
|
|
1955
2752
|
}
|
|
1956
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2753
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
|
|
1957
2754
|
class EventCoercer {
|
|
1958
2755
|
match(err) {
|
|
1959
2756
|
return isEvent(err);
|
|
@@ -1968,7 +2765,7 @@ class EventCoercer {
|
|
|
1968
2765
|
};
|
|
1969
2766
|
}
|
|
1970
2767
|
}
|
|
1971
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2768
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
|
|
1972
2769
|
class PrimitiveCoercer {
|
|
1973
2770
|
match(candidate) {
|
|
1974
2771
|
return isPrimitive(candidate);
|
|
@@ -1982,7 +2779,7 @@ class PrimitiveCoercer {
|
|
|
1982
2779
|
};
|
|
1983
2780
|
}
|
|
1984
2781
|
}
|
|
1985
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2782
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/promise-rejection-event.mjs
|
|
1986
2783
|
class PromiseRejectionEventCoercer {
|
|
1987
2784
|
match(err) {
|
|
1988
2785
|
return isBuiltin(err, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(err);
|
|
@@ -2018,7 +2815,7 @@ class PromiseRejectionEventCoercer {
|
|
|
2018
2815
|
return error;
|
|
2019
2816
|
}
|
|
2020
2817
|
}
|
|
2021
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2818
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/utils.mjs
|
|
2022
2819
|
class ReduceableCache {
|
|
2023
2820
|
constructor(_maxSize) {
|
|
2024
2821
|
this._maxSize = _maxSize;
|
|
@@ -2043,7 +2840,7 @@ class ReduceableCache {
|
|
|
2043
2840
|
}
|
|
2044
2841
|
}
|
|
2045
2842
|
}
|
|
2046
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2843
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
|
|
2047
2844
|
var EXCEPTION_STEP_INTERNAL_FIELDS = {
|
|
2048
2845
|
MESSAGE: "$message",
|
|
2049
2846
|
TIMESTAMP: "$timestamp"
|
|
@@ -2138,9 +2935,12 @@ function normalizePositiveInteger(input, fallback) {
|
|
|
2138
2935
|
return normalized;
|
|
2139
2936
|
}
|
|
2140
2937
|
function normalizeAndSerializeStep(step) {
|
|
2141
|
-
|
|
2142
|
-
|
|
2938
|
+
let json;
|
|
2939
|
+
try {
|
|
2940
|
+
json = safeJsonStringify(step);
|
|
2941
|
+
} catch {
|
|
2143
2942
|
return;
|
|
2943
|
+
}
|
|
2144
2944
|
try {
|
|
2145
2945
|
const parsed = JSON.parse(json);
|
|
2146
2946
|
if (!isObject(parsed))
|
|
@@ -2160,33 +2960,6 @@ function normalizeAndSerializeStep(step) {
|
|
|
2160
2960
|
return;
|
|
2161
2961
|
}
|
|
2162
2962
|
}
|
|
2163
|
-
function safeStringify(value) {
|
|
2164
|
-
const seen = new WeakSet;
|
|
2165
|
-
try {
|
|
2166
|
-
return JSON.stringify(value, (_key, replacementValue) => {
|
|
2167
|
-
if (typeof replacementValue == "bigint")
|
|
2168
|
-
return replacementValue.toString();
|
|
2169
|
-
if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
|
|
2170
|
-
return;
|
|
2171
|
-
if (replacementValue instanceof Date)
|
|
2172
|
-
return replacementValue.toISOString();
|
|
2173
|
-
if (replacementValue instanceof Error)
|
|
2174
|
-
return {
|
|
2175
|
-
name: replacementValue.name,
|
|
2176
|
-
message: replacementValue.message,
|
|
2177
|
-
stack: replacementValue.stack
|
|
2178
|
-
};
|
|
2179
|
-
if (replacementValue && typeof replacementValue == "object") {
|
|
2180
|
-
if (seen.has(replacementValue))
|
|
2181
|
-
return "[Circular]";
|
|
2182
|
-
seen.add(replacementValue);
|
|
2183
|
-
}
|
|
2184
|
-
return replacementValue;
|
|
2185
|
-
});
|
|
2186
|
-
} catch {
|
|
2187
|
-
return;
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
2963
|
function getUtf8ByteLength(value) {
|
|
2191
2964
|
if (typeof TextEncoder != "undefined")
|
|
2192
2965
|
return new TextEncoder().encode(value).length;
|
|
@@ -2200,19 +2973,65 @@ function getUtf8ByteLength(value) {
|
|
|
2200
2973
|
byteLength += 1;
|
|
2201
2974
|
return byteLength;
|
|
2202
2975
|
}
|
|
2203
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2976
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/release.mjs
|
|
2977
|
+
function getInjectedReleaseId() {
|
|
2978
|
+
const injected = globalThis._posthogReleaseId;
|
|
2979
|
+
return typeof injected == "string" && injected.length > 0 ? injected : undefined;
|
|
2980
|
+
}
|
|
2981
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
|
|
2204
2982
|
class PostHogFetchHttpError extends Error {
|
|
2205
|
-
constructor(response, reqByteLength) {
|
|
2206
|
-
super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
|
|
2983
|
+
constructor(response, reqByteLength, responseBodyDeadline, abortController) {
|
|
2984
|
+
super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.responseBodyDeadline = responseBodyDeadline, this.abortController = abortController, this.name = "PostHogFetchHttpError", this._bodyReadTimedOut = false;
|
|
2207
2985
|
}
|
|
2208
2986
|
get status() {
|
|
2209
2987
|
return this.response.status;
|
|
2210
2988
|
}
|
|
2989
|
+
get bodyReadTimedOut() {
|
|
2990
|
+
return this._bodyReadTimedOut;
|
|
2991
|
+
}
|
|
2211
2992
|
get text() {
|
|
2212
|
-
|
|
2993
|
+
if (!this.responseBodyTextPromise)
|
|
2994
|
+
if (Date.now() >= this.responseBodyDeadline) {
|
|
2995
|
+
this._bodyReadTimedOut = true;
|
|
2996
|
+
const timeoutError = new Error("Response body read timed out");
|
|
2997
|
+
timeoutError.name = "AbortError";
|
|
2998
|
+
this.cancelResponseBody(timeoutError);
|
|
2999
|
+
this.responseBodyTextPromise = Promise.reject(timeoutError);
|
|
3000
|
+
} else {
|
|
3001
|
+
const responseBodyTimeout = new Promise((_resolve, reject) => {
|
|
3002
|
+
this.responseBodyTimer = safeSetTimeout(() => {
|
|
3003
|
+
this._bodyReadTimedOut = true;
|
|
3004
|
+
const timeoutError = new Error("Response body read timed out");
|
|
3005
|
+
timeoutError.name = "AbortError";
|
|
3006
|
+
reject(timeoutError);
|
|
3007
|
+
this.cancelResponseBody(timeoutError);
|
|
3008
|
+
}, this.responseBodyDeadline - Date.now());
|
|
3009
|
+
});
|
|
3010
|
+
let responseBodyText;
|
|
3011
|
+
try {
|
|
3012
|
+
responseBodyText = Promise.resolve(this.response.text());
|
|
3013
|
+
} catch (error) {
|
|
3014
|
+
responseBodyText = Promise.reject(error);
|
|
3015
|
+
}
|
|
3016
|
+
this.responseBodyTextPromise = Promise.race([
|
|
3017
|
+
responseBodyText,
|
|
3018
|
+
responseBodyTimeout
|
|
3019
|
+
]).finally(() => clearTimeout(this.responseBodyTimer));
|
|
3020
|
+
}
|
|
3021
|
+
return this.responseBodyTextPromise;
|
|
2213
3022
|
}
|
|
2214
3023
|
get json() {
|
|
2215
|
-
return this.
|
|
3024
|
+
return this.text.then((text) => JSON.parse(text));
|
|
3025
|
+
}
|
|
3026
|
+
cancelResponseBody(reason) {
|
|
3027
|
+
clearTimeout(this.responseBodyTimer);
|
|
3028
|
+
if (!this.abortController.signal.aborted)
|
|
3029
|
+
this.abortController.abort(reason);
|
|
3030
|
+
(async () => {
|
|
3031
|
+
try {
|
|
3032
|
+
await this.response.body?.cancel();
|
|
3033
|
+
} catch {}
|
|
3034
|
+
})();
|
|
2216
3035
|
}
|
|
2217
3036
|
}
|
|
2218
3037
|
|
|
@@ -2223,12 +3042,20 @@ class PostHogFetchNetworkError extends Error {
|
|
|
2223
3042
|
} : {}), this.error = error, this.name = "PostHogFetchNetworkError";
|
|
2224
3043
|
}
|
|
2225
3044
|
}
|
|
3045
|
+
var applyCallerFeatureFlagOverrides = (target, callerProperties) => {
|
|
3046
|
+
for (const key of Object.keys(callerProperties))
|
|
3047
|
+
if (key.startsWith("$feature/") || key === "$active_feature_flags")
|
|
3048
|
+
target[key] = callerProperties[key];
|
|
3049
|
+
};
|
|
2226
3050
|
async function logFlushError(err) {
|
|
2227
3051
|
if (err instanceof PostHogFetchHttpError) {
|
|
2228
3052
|
let text = "";
|
|
2229
3053
|
try {
|
|
2230
3054
|
text = await err.text;
|
|
2231
|
-
} catch {
|
|
3055
|
+
} catch {
|
|
3056
|
+
if (err.bodyReadTimedOut)
|
|
3057
|
+
text = "<response body read timed out>";
|
|
3058
|
+
}
|
|
2232
3059
|
console.error(`Error while flushing PostHog: message=${err.message}, response body=${text}`, err);
|
|
2233
3060
|
} else
|
|
2234
3061
|
console.error("Error while flushing PostHog", err);
|
|
@@ -2240,9 +3067,28 @@ function isPostHogFetchError(err) {
|
|
|
2240
3067
|
function isPostHogFetchNetworkError(err) {
|
|
2241
3068
|
return err instanceof PostHogFetchNetworkError;
|
|
2242
3069
|
}
|
|
3070
|
+
function isRetryableFlagsFetchError(err) {
|
|
3071
|
+
if (err instanceof PostHogFetchHttpError)
|
|
3072
|
+
return err.status === 502 || err.status === 504;
|
|
3073
|
+
if (!(err instanceof PostHogFetchNetworkError))
|
|
3074
|
+
return false;
|
|
3075
|
+
const cause = err.error;
|
|
3076
|
+
const code = cause?.code ?? cause?.cause?.code;
|
|
3077
|
+
return code !== "ECONNREFUSED";
|
|
3078
|
+
}
|
|
2243
3079
|
function isPostHogFetchContentTooLargeError(err) {
|
|
2244
3080
|
return typeof err == "object" && err instanceof PostHogFetchHttpError && err.status === 413;
|
|
2245
3081
|
}
|
|
3082
|
+
function isPostHogFetchRetryableError(err) {
|
|
3083
|
+
if (err instanceof PostHogFetchHttpError)
|
|
3084
|
+
return err.status === 408 || err.status === 429 || err.status >= 500;
|
|
3085
|
+
return isPostHogFetchNetworkError(err);
|
|
3086
|
+
}
|
|
3087
|
+
function isPostHogEventProperties(value) {
|
|
3088
|
+
return value !== null && typeof value == "object" && !Array.isArray(value);
|
|
3089
|
+
}
|
|
3090
|
+
var DEFAULT_QUEUE_ROUTE = "default";
|
|
3091
|
+
|
|
2246
3092
|
class PostHogCoreStateless {
|
|
2247
3093
|
getErrorPropertiesBuilder() {
|
|
2248
3094
|
if (!this._errorPropertiesBuilder)
|
|
@@ -2259,6 +3105,9 @@ class PostHogCoreStateless {
|
|
|
2259
3105
|
}
|
|
2260
3106
|
constructor(apiKey, options = {}) {
|
|
2261
3107
|
this.flushPromise = null;
|
|
3108
|
+
this.pendingFlushPromise = null;
|
|
3109
|
+
this.flushPromises = new Set;
|
|
3110
|
+
this._dequeuedMessagesCount = 0;
|
|
2262
3111
|
this.shutdownPromise = null;
|
|
2263
3112
|
this.promiseQueue = new PromiseQueue;
|
|
2264
3113
|
this._events = new SimpleEventEmitter;
|
|
@@ -2281,10 +3130,11 @@ class PostHogCoreStateless {
|
|
|
2281
3130
|
this._retryOptions = {
|
|
2282
3131
|
retryCount: options.fetchRetryCount ?? 3,
|
|
2283
3132
|
retryDelay: options.fetchRetryDelay ?? 3000,
|
|
2284
|
-
retryCheck:
|
|
3133
|
+
retryCheck: isPostHogFetchRetryableError
|
|
2285
3134
|
};
|
|
2286
3135
|
this.requestTimeout = options.requestTimeout ?? 1e4;
|
|
2287
3136
|
this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3000;
|
|
3137
|
+
this.featureFlagsRequestMaxRetries = options.featureFlagsRequestMaxRetries ?? 1;
|
|
2288
3138
|
this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3000;
|
|
2289
3139
|
this.disableGeoip = options.disableGeoip ?? true;
|
|
2290
3140
|
this.disabled = (options.disabled ?? false) || missingApiKey;
|
|
@@ -2346,15 +3196,23 @@ class PostHogCoreStateless {
|
|
|
2346
3196
|
return this.disabled;
|
|
2347
3197
|
}
|
|
2348
3198
|
buildPayload(payload) {
|
|
3199
|
+
const userProperties = payload.properties || {};
|
|
3200
|
+
let properties = {
|
|
3201
|
+
...userProperties,
|
|
3202
|
+
...this.getCommonEventProperties()
|
|
3203
|
+
};
|
|
3204
|
+
applyCallerFeatureFlagOverrides(properties, userProperties);
|
|
3205
|
+
if (payload.event === "$feature_flag_called" && properties.$feature_flag_has_experiment === false && this.isMinimalFlagCalledEventsEnabled())
|
|
3206
|
+
properties = minimizeFlagCalledEventProperties(properties);
|
|
2349
3207
|
return {
|
|
2350
3208
|
distinct_id: payload.distinct_id,
|
|
2351
3209
|
event: payload.event,
|
|
2352
|
-
properties
|
|
2353
|
-
...payload.properties || {},
|
|
2354
|
-
...this.getCommonEventProperties()
|
|
2355
|
-
}
|
|
3210
|
+
properties
|
|
2356
3211
|
};
|
|
2357
3212
|
}
|
|
3213
|
+
isMinimalFlagCalledEventsEnabled() {
|
|
3214
|
+
return false;
|
|
3215
|
+
}
|
|
2358
3216
|
addPendingPromise(promise) {
|
|
2359
3217
|
return this.promiseQueue.add(promise);
|
|
2360
3218
|
}
|
|
@@ -2439,6 +3297,19 @@ class PostHogCoreStateless {
|
|
|
2439
3297
|
this.enqueue("capture", payload, options);
|
|
2440
3298
|
});
|
|
2441
3299
|
}
|
|
3300
|
+
async groupIdentifyStatelessImmediate(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
|
|
3301
|
+
const payload = this.buildPayload({
|
|
3302
|
+
distinct_id: distinctId || `$${groupType}_${groupKey}`,
|
|
3303
|
+
event: "$groupidentify",
|
|
3304
|
+
properties: {
|
|
3305
|
+
$group_type: groupType,
|
|
3306
|
+
$group_key: groupKey,
|
|
3307
|
+
$group_set: groupProperties || {},
|
|
3308
|
+
...eventProperties || {}
|
|
3309
|
+
}
|
|
3310
|
+
});
|
|
3311
|
+
await this.sendImmediate("capture", payload, options);
|
|
3312
|
+
}
|
|
2442
3313
|
async getRemoteConfig() {
|
|
2443
3314
|
await this._initPromise;
|
|
2444
3315
|
let host = this.host;
|
|
@@ -2455,8 +3326,11 @@ class PostHogCoreStateless {
|
|
|
2455
3326
|
}
|
|
2456
3327
|
};
|
|
2457
3328
|
return this.fetchWithRetry(url, fetchOptions, {
|
|
3329
|
+
type: "required",
|
|
3330
|
+
consume: (response) => response.json()
|
|
3331
|
+
}, {
|
|
2458
3332
|
retryCount: 0
|
|
2459
|
-
}, this.remoteConfigRequestTimeoutMs).
|
|
3333
|
+
}, this.remoteConfigRequestTimeoutMs).catch((error) => {
|
|
2460
3334
|
this._logger.error("Remote config could not be loaded", error);
|
|
2461
3335
|
this._events.emit("error", error);
|
|
2462
3336
|
});
|
|
@@ -2487,8 +3361,12 @@ class PostHogCoreStateless {
|
|
|
2487
3361
|
};
|
|
2488
3362
|
this._logger.info("Flags URL", url);
|
|
2489
3363
|
return this.fetchWithRetry(url, fetchOptions, {
|
|
2490
|
-
|
|
2491
|
-
|
|
3364
|
+
type: "required",
|
|
3365
|
+
consume: (response) => response.json()
|
|
3366
|
+
}, {
|
|
3367
|
+
retryCount: this.featureFlagsRequestMaxRetries,
|
|
3368
|
+
retryCheck: isRetryableFlagsFetchError
|
|
3369
|
+
}, this.featureFlagsRequestTimeoutMs).then((response) => ({
|
|
2492
3370
|
success: true,
|
|
2493
3371
|
response: normalizeFlagsResponse(response)
|
|
2494
3372
|
})).catch((error) => {
|
|
@@ -2588,9 +3466,9 @@ class PostHogCoreStateless {
|
|
|
2588
3466
|
}
|
|
2589
3467
|
async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
|
|
2590
3468
|
await this._initPromise;
|
|
2591
|
-
const extraPayload = {
|
|
2592
|
-
|
|
2593
|
-
|
|
3469
|
+
const extraPayload = {
|
|
3470
|
+
geoip_disable: disableGeoip ?? this.disableGeoip
|
|
3471
|
+
};
|
|
2594
3472
|
if (flagKeysToEvaluate)
|
|
2595
3473
|
extraPayload["flag_keys_to_evaluate"] = flagKeysToEvaluate;
|
|
2596
3474
|
const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
|
|
@@ -2627,15 +3505,18 @@ class PostHogCoreStateless {
|
|
|
2627
3505
|
"Content-Type": "application/json"
|
|
2628
3506
|
}
|
|
2629
3507
|
};
|
|
2630
|
-
const response = await this.fetchWithRetry(url, fetchOptions
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
3508
|
+
const response = await this.fetchWithRetry(url, fetchOptions, {
|
|
3509
|
+
type: "required",
|
|
3510
|
+
consume: (response2) => {
|
|
3511
|
+
if (response2.status !== 200 || !response2.json) {
|
|
3512
|
+
const msg = `Surveys API could not be loaded: ${response2.status}`;
|
|
3513
|
+
const error = new Error(msg);
|
|
3514
|
+
this._logger.error(error);
|
|
3515
|
+
this._events.emit("error", new Error(msg));
|
|
3516
|
+
return Promise.resolve(undefined);
|
|
3517
|
+
}
|
|
3518
|
+
return response2.json();
|
|
2637
3519
|
}
|
|
2638
|
-
return response2.json();
|
|
2639
3520
|
}).catch((error) => {
|
|
2640
3521
|
this._logger.error("Surveys API could not be loaded", error);
|
|
2641
3522
|
this._events.emit("error", error);
|
|
@@ -2672,23 +3553,39 @@ class PostHogCoreStateless {
|
|
|
2672
3553
|
return message;
|
|
2673
3554
|
}
|
|
2674
3555
|
async flushStorage() {}
|
|
2675
|
-
|
|
3556
|
+
getQueueRouteKey(_message) {
|
|
3557
|
+
return DEFAULT_QUEUE_ROUTE;
|
|
3558
|
+
}
|
|
3559
|
+
persistedQueueKeyForRoute(_route) {
|
|
3560
|
+
return types_PostHogPersistedProperty.Queue;
|
|
3561
|
+
}
|
|
3562
|
+
getActiveQueueRoutes() {
|
|
3563
|
+
return [
|
|
3564
|
+
DEFAULT_QUEUE_ROUTE
|
|
3565
|
+
];
|
|
3566
|
+
}
|
|
3567
|
+
getRouteQueue(route) {
|
|
3568
|
+
return this.getPersistedProperty(this.persistedQueueKeyForRoute(route)) || [];
|
|
3569
|
+
}
|
|
3570
|
+
enqueue(type, _message, options, explicitRoute) {
|
|
2676
3571
|
this.wrap(() => {
|
|
2677
3572
|
if (this.optedOut)
|
|
2678
3573
|
return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
2679
|
-
let message = this.prepareMessage(
|
|
3574
|
+
let message = this.prepareMessage(_message, options);
|
|
2680
3575
|
message = this.processBeforeEnqueue(message);
|
|
2681
3576
|
if (message === null)
|
|
2682
3577
|
return;
|
|
2683
|
-
|
|
3578
|
+
message = this.normalizeMessage(message);
|
|
3579
|
+
const queueKey = this.persistedQueueKeyForRoute(explicitRoute ?? this.getQueueRouteKey(message));
|
|
3580
|
+
const queue = this.getPersistedProperty(queueKey) || [];
|
|
2684
3581
|
if (queue.length >= this.maxQueueSize) {
|
|
2685
3582
|
queue.shift();
|
|
2686
|
-
this._logger.
|
|
3583
|
+
this._logger.warn("Queue is full, the oldest event is dropped.");
|
|
2687
3584
|
}
|
|
2688
3585
|
queue.push({
|
|
2689
3586
|
message
|
|
2690
3587
|
});
|
|
2691
|
-
this.setPersistedProperty(
|
|
3588
|
+
this.setPersistedProperty(queueKey, queue);
|
|
2692
3589
|
this._events.emit(type, message);
|
|
2693
3590
|
if (queue.length >= this.flushAt)
|
|
2694
3591
|
this.flushBackground();
|
|
@@ -2696,61 +3593,63 @@ class PostHogCoreStateless {
|
|
|
2696
3593
|
this._flushTimer = safeSetTimeout(() => this.flushBackground(), this.flushInterval);
|
|
2697
3594
|
});
|
|
2698
3595
|
}
|
|
2699
|
-
async sendImmediate(type, _message, options) {
|
|
3596
|
+
async sendImmediate(type, _message, options, explicitRoute) {
|
|
2700
3597
|
if (this.disabled)
|
|
2701
3598
|
return void this._logger.warn("The client is disabled");
|
|
2702
3599
|
if (!this._isInitialized)
|
|
2703
3600
|
await this._initPromise;
|
|
2704
3601
|
if (this.optedOut)
|
|
2705
3602
|
return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
2706
|
-
let message = this.prepareMessage(
|
|
3603
|
+
let message = this.prepareMessage(_message, options);
|
|
2707
3604
|
message = this.processBeforeEnqueue(message);
|
|
2708
3605
|
if (message === null)
|
|
2709
3606
|
return;
|
|
2710
|
-
|
|
2711
|
-
api_key: this.apiKey,
|
|
2712
|
-
batch: [
|
|
2713
|
-
message
|
|
2714
|
-
],
|
|
2715
|
-
sent_at: currentISOTime()
|
|
2716
|
-
};
|
|
2717
|
-
if (this.historicalMigration)
|
|
2718
|
-
data.historical_migration = true;
|
|
2719
|
-
const payload = JSON.stringify(data);
|
|
2720
|
-
const url = `${this.host}/batch/`;
|
|
2721
|
-
const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
|
|
2722
|
-
const fetchOptions = {
|
|
2723
|
-
method: "POST",
|
|
2724
|
-
headers: {
|
|
2725
|
-
...this.getCustomHeaders(),
|
|
2726
|
-
"Content-Type": "application/json",
|
|
2727
|
-
...gzippedPayload !== null && {
|
|
2728
|
-
"Content-Encoding": "gzip"
|
|
2729
|
-
}
|
|
2730
|
-
},
|
|
2731
|
-
body: gzippedPayload || payload
|
|
2732
|
-
};
|
|
3607
|
+
message = this.normalizeMessage(message);
|
|
2733
3608
|
try {
|
|
2734
|
-
|
|
2735
|
-
|
|
3609
|
+
await this.sendBatch([
|
|
3610
|
+
message
|
|
3611
|
+
], undefined, explicitRoute ?? this.getQueueRouteKey(message));
|
|
2736
3612
|
} catch (err) {
|
|
2737
3613
|
this._events.emit("error", err);
|
|
2738
3614
|
}
|
|
2739
3615
|
}
|
|
2740
|
-
|
|
3616
|
+
normalizeMessage(message) {
|
|
3617
|
+
const { type: _type, library, library_version, ...sanitizedMessage } = message;
|
|
3618
|
+
let properties = isPostHogEventProperties(sanitizedMessage.properties) ? sanitizedMessage.properties : undefined;
|
|
3619
|
+
if (library !== undefined && properties?.$lib === undefined)
|
|
3620
|
+
properties = {
|
|
3621
|
+
...properties || {},
|
|
3622
|
+
$lib: library
|
|
3623
|
+
};
|
|
3624
|
+
if (library_version !== undefined && properties?.$lib_version === undefined)
|
|
3625
|
+
properties = {
|
|
3626
|
+
...properties || {},
|
|
3627
|
+
$lib_version: library_version
|
|
3628
|
+
};
|
|
3629
|
+
if (properties)
|
|
3630
|
+
sanitizedMessage.properties = properties;
|
|
3631
|
+
sanitizedMessage.uuid = getEventUuid(sanitizedMessage.uuid, uuidv7);
|
|
3632
|
+
return sanitizedMessage;
|
|
3633
|
+
}
|
|
3634
|
+
normalizeTimestampForWire(timestamp) {
|
|
3635
|
+
const parsedTimestamp = timestamp instanceof Date ? timestamp : typeof timestamp == "string" ? new Date(timestamp) : null;
|
|
3636
|
+
if (!parsedTimestamp || Number.isNaN(parsedTimestamp.getTime()))
|
|
3637
|
+
return timestamp;
|
|
3638
|
+
const normalized = parsedTimestamp.toISOString();
|
|
3639
|
+
const fractionalSeconds = typeof timestamp == "string" ? timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1] : undefined;
|
|
3640
|
+
return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
|
|
3641
|
+
}
|
|
3642
|
+
prepareMessage(_message, options) {
|
|
2741
3643
|
const message = {
|
|
2742
3644
|
..._message,
|
|
2743
|
-
type,
|
|
2744
|
-
library: this.getLibraryId(),
|
|
2745
|
-
library_version: this.getLibraryVersion(),
|
|
2746
3645
|
timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
|
|
2747
|
-
uuid: options?.uuid
|
|
3646
|
+
uuid: getEventUuid(options?.uuid, uuidv7)
|
|
2748
3647
|
};
|
|
2749
3648
|
const addGeoipDisableProperty = options?.disableGeoip ?? this.disableGeoip;
|
|
2750
3649
|
if (addGeoipDisableProperty) {
|
|
2751
|
-
if (!message.properties)
|
|
3650
|
+
if (!isPostHogEventProperties(message.properties))
|
|
2752
3651
|
message.properties = {};
|
|
2753
|
-
message
|
|
3652
|
+
message.properties["$geoip_disable"] = true;
|
|
2754
3653
|
}
|
|
2755
3654
|
if (message.distinctId) {
|
|
2756
3655
|
message.distinct_id = message.distinctId;
|
|
@@ -2765,21 +3664,64 @@ class PostHogCoreStateless {
|
|
|
2765
3664
|
}
|
|
2766
3665
|
}
|
|
2767
3666
|
flushBackground() {
|
|
3667
|
+
if (this.pendingFlushPromise)
|
|
3668
|
+
return;
|
|
2768
3669
|
this.flush().catch(async (err) => {
|
|
2769
3670
|
await logFlushError(err);
|
|
2770
3671
|
});
|
|
2771
3672
|
}
|
|
2772
|
-
async
|
|
3673
|
+
async waitForPendingPromises(maxPromiseId, ignoredPromises = []) {
|
|
3674
|
+
const ignoredPendingPromises = ignoredPromises.filter((promise) => !!promise);
|
|
3675
|
+
let iteration = 0;
|
|
3676
|
+
while (true) {
|
|
3677
|
+
const promises = this.promiseQueue.getPromises([
|
|
3678
|
+
...ignoredPendingPromises,
|
|
3679
|
+
...this.flushPromises
|
|
3680
|
+
], maxPromiseId);
|
|
3681
|
+
if (promises.length === 0)
|
|
3682
|
+
return;
|
|
3683
|
+
if (iteration > 0)
|
|
3684
|
+
this._logger.debug(`flush() re-checking ${promises.length} pending promise(s) before flushing`);
|
|
3685
|
+
await Promise.all(promises.map((promise) => promise.catch(() => {})));
|
|
3686
|
+
iteration++;
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
flushWithPendingPromises() {
|
|
3690
|
+
return this.flushInternal(true);
|
|
3691
|
+
}
|
|
3692
|
+
flush() {
|
|
3693
|
+
return this.flushInternal(false);
|
|
3694
|
+
}
|
|
3695
|
+
flushInternal(waitForPendingPromises) {
|
|
2773
3696
|
if (this.disabled)
|
|
2774
|
-
return;
|
|
2775
|
-
|
|
2776
|
-
this.
|
|
2777
|
-
|
|
3697
|
+
return Promise.resolve();
|
|
3698
|
+
if (!waitForPendingPromises && this.pendingFlushPromise)
|
|
3699
|
+
return this.pendingFlushPromise;
|
|
3700
|
+
const previousFlushPromise = this.flushPromise;
|
|
3701
|
+
const maxPromiseId = this.promiseQueue.maxId;
|
|
3702
|
+
const nextFlushPromise = Promise.resolve().then(() => {
|
|
3703
|
+
if (waitForPendingPromises)
|
|
3704
|
+
return this.waitForPendingPromises(maxPromiseId, [
|
|
3705
|
+
previousFlushPromise,
|
|
3706
|
+
nextFlushPromise
|
|
3707
|
+
]);
|
|
3708
|
+
}).then(() => allSettled([
|
|
3709
|
+
previousFlushPromise
|
|
3710
|
+
])).then(() => {
|
|
3711
|
+
if (this.pendingFlushPromise === nextFlushPromise)
|
|
3712
|
+
this.pendingFlushPromise = null;
|
|
3713
|
+
return this._flush();
|
|
3714
|
+
});
|
|
3715
|
+
this.pendingFlushPromise = nextFlushPromise;
|
|
2778
3716
|
this.flushPromise = nextFlushPromise;
|
|
3717
|
+
this.flushPromises.add(nextFlushPromise);
|
|
2779
3718
|
this.addPendingPromise(nextFlushPromise);
|
|
2780
3719
|
allSettled([
|
|
2781
3720
|
nextFlushPromise
|
|
2782
3721
|
]).then(() => {
|
|
3722
|
+
this.flushPromises.delete(nextFlushPromise);
|
|
3723
|
+
if (this.pendingFlushPromise === nextFlushPromise)
|
|
3724
|
+
this.pendingFlushPromise = null;
|
|
2783
3725
|
if (this.flushPromise === nextFlushPromise)
|
|
2784
3726
|
this.flushPromise = null;
|
|
2785
3727
|
});
|
|
@@ -2792,55 +3734,102 @@ class PostHogCoreStateless {
|
|
|
2792
3734
|
headers["User-Agent"] = customUserAgent;
|
|
2793
3735
|
return headers;
|
|
2794
3736
|
}
|
|
3737
|
+
compressPayload(payload) {
|
|
3738
|
+
return gzipCompress(payload, this.isDebug);
|
|
3739
|
+
}
|
|
3740
|
+
getBatchEndpointPath(_route) {
|
|
3741
|
+
return "/batch/";
|
|
3742
|
+
}
|
|
3743
|
+
async sendBatch(batchMessages, retryOptions, route = DEFAULT_QUEUE_ROUTE) {
|
|
3744
|
+
const data = {
|
|
3745
|
+
api_key: this.apiKey,
|
|
3746
|
+
batch: batchMessages.map((message) => {
|
|
3747
|
+
if (!message)
|
|
3748
|
+
return message;
|
|
3749
|
+
const timestamp = this.normalizeTimestampForWire(message.timestamp);
|
|
3750
|
+
return timestamp === message.timestamp ? message : {
|
|
3751
|
+
...message,
|
|
3752
|
+
timestamp
|
|
3753
|
+
};
|
|
3754
|
+
}),
|
|
3755
|
+
sent_at: currentISOTime()
|
|
3756
|
+
};
|
|
3757
|
+
if (this.historicalMigration)
|
|
3758
|
+
data.historical_migration = true;
|
|
3759
|
+
const payload = safeJsonStringify(data);
|
|
3760
|
+
const url = `${this.host}${this.getBatchEndpointPath(route)}`;
|
|
3761
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(payload);
|
|
3762
|
+
const fetchOptions = {
|
|
3763
|
+
method: "POST",
|
|
3764
|
+
headers: {
|
|
3765
|
+
...this.getCustomHeaders(),
|
|
3766
|
+
"Content-Type": "application/json",
|
|
3767
|
+
...gzippedPayload !== null && {
|
|
3768
|
+
"Content-Encoding": "gzip"
|
|
3769
|
+
}
|
|
3770
|
+
},
|
|
3771
|
+
body: gzippedPayload || payload
|
|
3772
|
+
};
|
|
3773
|
+
await this.fetchWithRetry(url, fetchOptions, {
|
|
3774
|
+
type: "successful-write"
|
|
3775
|
+
}, retryOptions);
|
|
3776
|
+
}
|
|
2795
3777
|
async _flush() {
|
|
2796
3778
|
this.clearFlushTimer();
|
|
2797
3779
|
await this._initPromise;
|
|
2798
|
-
|
|
2799
|
-
if (!
|
|
3780
|
+
const routes = this.getActiveQueueRoutes();
|
|
3781
|
+
if (!routes.some((route) => this.getRouteQueue(route).length > 0))
|
|
2800
3782
|
return;
|
|
2801
3783
|
const sentMessages = [];
|
|
3784
|
+
let firstError;
|
|
3785
|
+
for (const route of routes)
|
|
3786
|
+
try {
|
|
3787
|
+
await this._flushRoute(route, sentMessages);
|
|
3788
|
+
} catch (err) {
|
|
3789
|
+
if (firstError === undefined)
|
|
3790
|
+
firstError = err;
|
|
3791
|
+
}
|
|
3792
|
+
if (firstError !== undefined)
|
|
3793
|
+
throw firstError;
|
|
3794
|
+
this._events.emit("flush", sentMessages);
|
|
3795
|
+
}
|
|
3796
|
+
async _flushRoute(route, sentMessages) {
|
|
3797
|
+
const queueKey = this.persistedQueueKeyForRoute(route);
|
|
3798
|
+
let queue = this.getPersistedProperty(queueKey) || [];
|
|
3799
|
+
if (!queue.length)
|
|
3800
|
+
return;
|
|
2802
3801
|
const originalQueueLength = queue.length;
|
|
2803
|
-
|
|
3802
|
+
let sentFromRoute = 0;
|
|
3803
|
+
while (queue.length > 0 && sentFromRoute < originalQueueLength) {
|
|
2804
3804
|
const batchItems = queue.slice(0, this.maxBatchSize);
|
|
2805
|
-
const batchMessages = batchItems.map((item) => item.message);
|
|
3805
|
+
const batchMessages = batchItems.map((item) => item.message === undefined ? item.message : this.normalizeMessage(item.message));
|
|
2806
3806
|
const persistQueueChange = async () => {
|
|
2807
|
-
const refreshedQueue = this.getPersistedProperty(
|
|
2808
|
-
const
|
|
2809
|
-
|
|
3807
|
+
const refreshedQueue = this.getPersistedProperty(queueKey) || [];
|
|
3808
|
+
const remainingBatchItems = [
|
|
3809
|
+
...batchItems
|
|
3810
|
+
];
|
|
3811
|
+
const newQueue = refreshedQueue.filter((item) => {
|
|
3812
|
+
const itemUuid = item.message?.uuid;
|
|
3813
|
+
const batchItemIndex = remainingBatchItems.findIndex((batchItem) => batchItem === item || typeof itemUuid == "string" && itemUuid.length > 0 && batchItem.message?.uuid === itemUuid);
|
|
3814
|
+
if (batchItemIndex === -1)
|
|
3815
|
+
return true;
|
|
3816
|
+
remainingBatchItems.splice(batchItemIndex, 1);
|
|
3817
|
+
return false;
|
|
3818
|
+
});
|
|
3819
|
+
this.setPersistedProperty(queueKey, newQueue);
|
|
2810
3820
|
queue = newQueue;
|
|
3821
|
+
this._dequeuedMessagesCount += batchItems.length;
|
|
2811
3822
|
await this.flushStorage();
|
|
2812
3823
|
};
|
|
2813
|
-
const data = {
|
|
2814
|
-
api_key: this.apiKey,
|
|
2815
|
-
batch: batchMessages,
|
|
2816
|
-
sent_at: currentISOTime()
|
|
2817
|
-
};
|
|
2818
|
-
if (this.historicalMigration)
|
|
2819
|
-
data.historical_migration = true;
|
|
2820
|
-
const payload = JSON.stringify(data);
|
|
2821
|
-
const url = `${this.host}/batch/`;
|
|
2822
|
-
const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
|
|
2823
|
-
const fetchOptions = {
|
|
2824
|
-
method: "POST",
|
|
2825
|
-
headers: {
|
|
2826
|
-
...this.getCustomHeaders(),
|
|
2827
|
-
"Content-Type": "application/json",
|
|
2828
|
-
...gzippedPayload !== null && {
|
|
2829
|
-
"Content-Encoding": "gzip"
|
|
2830
|
-
}
|
|
2831
|
-
},
|
|
2832
|
-
body: gzippedPayload || payload
|
|
2833
|
-
};
|
|
2834
3824
|
const retryOptions = {
|
|
2835
3825
|
retryCheck: (err) => {
|
|
2836
3826
|
if (isPostHogFetchContentTooLargeError(err))
|
|
2837
3827
|
return false;
|
|
2838
|
-
return
|
|
3828
|
+
return isPostHogFetchRetryableError(err);
|
|
2839
3829
|
}
|
|
2840
3830
|
};
|
|
2841
3831
|
try {
|
|
2842
|
-
|
|
2843
|
-
await response.body?.cancel()?.catch(() => {});
|
|
3832
|
+
await this.sendBatch(batchMessages, retryOptions, route);
|
|
2844
3833
|
} catch (err) {
|
|
2845
3834
|
if (isPostHogFetchContentTooLargeError(err) && batchMessages.length > 1) {
|
|
2846
3835
|
this.maxBatchSize = Math.max(1, Math.floor(batchMessages.length / 2));
|
|
@@ -2854,8 +3843,8 @@ class PostHogCoreStateless {
|
|
|
2854
3843
|
}
|
|
2855
3844
|
await persistQueueChange();
|
|
2856
3845
|
sentMessages.push(...batchMessages);
|
|
3846
|
+
sentFromRoute += batchMessages.length;
|
|
2857
3847
|
}
|
|
2858
|
-
this._events.emit("flush", sentMessages);
|
|
2859
3848
|
}
|
|
2860
3849
|
async _sendLogsBatch(payload) {
|
|
2861
3850
|
if (this.disabled)
|
|
@@ -2865,7 +3854,7 @@ class PostHogCoreStateless {
|
|
|
2865
3854
|
};
|
|
2866
3855
|
const serialized = JSON.stringify(payload);
|
|
2867
3856
|
const url = `${this.host}/i/v1/logs?token=${encodeURIComponent(this.apiKey)}`;
|
|
2868
|
-
const gzippedPayload = this.disableCompression ? null : await
|
|
3857
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
2869
3858
|
const fetchOptions = {
|
|
2870
3859
|
method: "POST",
|
|
2871
3860
|
headers: {
|
|
@@ -2879,10 +3868,12 @@ class PostHogCoreStateless {
|
|
|
2879
3868
|
};
|
|
2880
3869
|
try {
|
|
2881
3870
|
await this.fetchWithRetry(url, fetchOptions, {
|
|
3871
|
+
type: "successful-write"
|
|
3872
|
+
}, {
|
|
2882
3873
|
retryCheck: (err) => {
|
|
2883
3874
|
if (isPostHogFetchContentTooLargeError(err))
|
|
2884
3875
|
return false;
|
|
2885
|
-
return
|
|
3876
|
+
return isPostHogFetchRetryableError(err);
|
|
2886
3877
|
}
|
|
2887
3878
|
});
|
|
2888
3879
|
return {
|
|
@@ -2904,41 +3895,155 @@ class PostHogCoreStateless {
|
|
|
2904
3895
|
};
|
|
2905
3896
|
}
|
|
2906
3897
|
}
|
|
2907
|
-
async
|
|
3898
|
+
async _sendMetricsBatch(payload) {
|
|
3899
|
+
if (this.disabled)
|
|
3900
|
+
return {
|
|
3901
|
+
kind: "fatal",
|
|
3902
|
+
error: new Error("The client is disabled")
|
|
3903
|
+
};
|
|
3904
|
+
const serialized = JSON.stringify(payload);
|
|
3905
|
+
const url = `${this.host}/i/v1/metrics?token=${encodeURIComponent(this.apiKey)}`;
|
|
3906
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
3907
|
+
const fetchOptions = {
|
|
3908
|
+
method: "POST",
|
|
3909
|
+
headers: {
|
|
3910
|
+
...this.getCustomHeaders(),
|
|
3911
|
+
"Content-Type": "application/json",
|
|
3912
|
+
...gzippedPayload !== null && {
|
|
3913
|
+
"Content-Encoding": "gzip"
|
|
3914
|
+
}
|
|
3915
|
+
},
|
|
3916
|
+
body: gzippedPayload || serialized
|
|
3917
|
+
};
|
|
3918
|
+
try {
|
|
3919
|
+
await this.fetchWithRetry(url, fetchOptions, {
|
|
3920
|
+
type: "successful-write"
|
|
3921
|
+
}, {
|
|
3922
|
+
retryCheck: (err) => {
|
|
3923
|
+
if (isPostHogFetchContentTooLargeError(err))
|
|
3924
|
+
return false;
|
|
3925
|
+
return isPostHogFetchRetryableError(err);
|
|
3926
|
+
}
|
|
3927
|
+
});
|
|
3928
|
+
return {
|
|
3929
|
+
kind: "ok"
|
|
3930
|
+
};
|
|
3931
|
+
} catch (err) {
|
|
3932
|
+
if (isPostHogFetchContentTooLargeError(err))
|
|
3933
|
+
return {
|
|
3934
|
+
kind: "too-large"
|
|
3935
|
+
};
|
|
3936
|
+
if (isPostHogFetchRetryableError(err))
|
|
3937
|
+
return {
|
|
3938
|
+
kind: "retry-later",
|
|
3939
|
+
error: err
|
|
3940
|
+
};
|
|
3941
|
+
return {
|
|
3942
|
+
kind: "fatal",
|
|
3943
|
+
error: err
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
async fetchWithRetry(url, options, responseHandling, retryOptions, requestTimeout) {
|
|
2908
3948
|
const body = options.body ? options.body : "";
|
|
2909
3949
|
let reqByteLength = -1;
|
|
2910
3950
|
try {
|
|
2911
|
-
reqByteLength = body instanceof Blob ? body.size : Buffer.byteLength(body, STRING_FORMAT);
|
|
3951
|
+
reqByteLength = body instanceof Blob ? body.size : body instanceof Uint8Array ? body.byteLength : Buffer.byteLength(body, STRING_FORMAT);
|
|
2912
3952
|
} catch {
|
|
2913
3953
|
if (body instanceof Blob)
|
|
2914
3954
|
reqByteLength = body.size;
|
|
3955
|
+
else if (body instanceof Uint8Array)
|
|
3956
|
+
reqByteLength = body.byteLength;
|
|
2915
3957
|
else {
|
|
2916
3958
|
const encoded = new TextEncoder().encode(body);
|
|
2917
3959
|
reqByteLength = encoded.length;
|
|
2918
3960
|
}
|
|
2919
3961
|
}
|
|
3962
|
+
const retriableOptions = {
|
|
3963
|
+
...this._retryOptions,
|
|
3964
|
+
...retryOptions
|
|
3965
|
+
};
|
|
3966
|
+
let attempt = 0;
|
|
2920
3967
|
return await retriable(async () => {
|
|
3968
|
+
attempt++;
|
|
2921
3969
|
const ctrl = new AbortController;
|
|
2922
3970
|
const timeoutMs = requestTimeout ?? this.requestTimeout;
|
|
2923
|
-
const
|
|
2924
|
-
let
|
|
3971
|
+
const requestDeadline = Date.now() + timeoutMs;
|
|
3972
|
+
let timer;
|
|
3973
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
3974
|
+
timer = safeSetTimeout(() => {
|
|
3975
|
+
const timeoutError = new Error(`Request timed out after ${timeoutMs}ms`);
|
|
3976
|
+
timeoutError.name = "AbortError";
|
|
3977
|
+
reject(timeoutError);
|
|
3978
|
+
ctrl.abort(timeoutError);
|
|
3979
|
+
}, timeoutMs);
|
|
3980
|
+
});
|
|
3981
|
+
let res;
|
|
3982
|
+
let responseAccepted = false;
|
|
3983
|
+
let cancellation;
|
|
3984
|
+
const cancelBody = () => cancellation ??= (async () => {
|
|
3985
|
+
try {
|
|
3986
|
+
await res?.body?.cancel();
|
|
3987
|
+
} catch {}
|
|
3988
|
+
})();
|
|
2925
3989
|
try {
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3990
|
+
let fetchPromise;
|
|
3991
|
+
try {
|
|
3992
|
+
fetchPromise = this.fetch(url, {
|
|
3993
|
+
signal: ctrl.signal,
|
|
3994
|
+
...options
|
|
3995
|
+
});
|
|
3996
|
+
} catch (e) {
|
|
3997
|
+
throw new PostHogFetchNetworkError(e);
|
|
3998
|
+
}
|
|
3999
|
+
fetchPromise.then((lateResponse) => {
|
|
4000
|
+
if (ctrl.signal.aborted && !responseAccepted)
|
|
4001
|
+
Promise.resolve(lateResponse.body?.cancel()).catch(() => {});
|
|
4002
|
+
}).catch(() => {});
|
|
4003
|
+
try {
|
|
4004
|
+
res = await Promise.race([
|
|
4005
|
+
fetchPromise,
|
|
4006
|
+
deadline
|
|
4007
|
+
]);
|
|
4008
|
+
responseAccepted = true;
|
|
4009
|
+
} catch (e) {
|
|
4010
|
+
throw new PostHogFetchNetworkError(e);
|
|
4011
|
+
}
|
|
4012
|
+
const isNoCors = options.mode === "no-cors";
|
|
4013
|
+
if (!isNoCors && (res.status < 200 || res.status >= 400))
|
|
4014
|
+
throw new PostHogFetchHttpError(res, reqByteLength, requestDeadline, ctrl);
|
|
4015
|
+
if (responseHandling.type === "successful-write") {
|
|
4016
|
+
try {
|
|
4017
|
+
await Promise.race([
|
|
4018
|
+
cancelBody(),
|
|
4019
|
+
deadline
|
|
4020
|
+
]);
|
|
4021
|
+
} catch {}
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
4024
|
+
try {
|
|
4025
|
+
return await Promise.race([
|
|
4026
|
+
responseHandling.consume(res),
|
|
4027
|
+
deadline
|
|
4028
|
+
]);
|
|
4029
|
+
} catch (e) {
|
|
4030
|
+
if (ctrl.signal.aborted)
|
|
4031
|
+
throw new PostHogFetchNetworkError(e);
|
|
4032
|
+
throw e;
|
|
4033
|
+
}
|
|
2932
4034
|
} finally {
|
|
2933
4035
|
clearTimeout(timer);
|
|
4036
|
+
if (ctrl.signal.aborted && res)
|
|
4037
|
+
cancelBody();
|
|
2934
4038
|
}
|
|
2935
|
-
const isNoCors = options.mode === "no-cors";
|
|
2936
|
-
if (!isNoCors && (res.status < 200 || res.status >= 400))
|
|
2937
|
-
throw new PostHogFetchHttpError(res, reqByteLength);
|
|
2938
|
-
return res;
|
|
2939
4039
|
}, {
|
|
2940
|
-
...
|
|
2941
|
-
|
|
4040
|
+
...retriableOptions,
|
|
4041
|
+
retryCheck: (error) => {
|
|
4042
|
+
const shouldRetry = retriableOptions.retryCheck(error);
|
|
4043
|
+
if (shouldRetry && attempt <= retriableOptions.retryCount && error instanceof PostHogFetchHttpError)
|
|
4044
|
+
error.cancelResponseBody();
|
|
4045
|
+
return shouldRetry;
|
|
4046
|
+
}
|
|
2942
4047
|
});
|
|
2943
4048
|
}
|
|
2944
4049
|
async _shutdown(shutdownTimeoutMs = 30000) {
|
|
@@ -2951,12 +4056,17 @@ class PostHogCoreStateless {
|
|
|
2951
4056
|
try {
|
|
2952
4057
|
await this.promiseQueue.join();
|
|
2953
4058
|
while (true) {
|
|
2954
|
-
const
|
|
2955
|
-
if (
|
|
4059
|
+
const hasQueuedEvents = this.getActiveQueueRoutes().some((route) => this.getRouteQueue(route).length > 0);
|
|
4060
|
+
if (!hasQueuedEvents)
|
|
2956
4061
|
break;
|
|
4062
|
+
const dequeuedBeforeFlush = this._dequeuedMessagesCount;
|
|
2957
4063
|
await this.flush();
|
|
2958
4064
|
if (hasTimedOut)
|
|
2959
4065
|
break;
|
|
4066
|
+
if (this._dequeuedMessagesCount === dequeuedBeforeFlush) {
|
|
4067
|
+
this._logger.warn("Shutdown flush completed but did not send any queued events. Stopping drain to avoid a loop.");
|
|
4068
|
+
break;
|
|
4069
|
+
}
|
|
2960
4070
|
}
|
|
2961
4071
|
} catch (e) {
|
|
2962
4072
|
if (!isPostHogFetchError(e))
|
|
@@ -2964,21 +4074,12 @@ class PostHogCoreStateless {
|
|
|
2964
4074
|
await logFlushError(e);
|
|
2965
4075
|
}
|
|
2966
4076
|
};
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
hasTimedOut = true;
|
|
2974
|
-
reject("Timeout while shutting down PostHog. Some events may not have been sent.");
|
|
2975
|
-
}, shutdownTimeoutMs);
|
|
2976
|
-
}),
|
|
2977
|
-
doShutdown()
|
|
2978
|
-
]);
|
|
2979
|
-
} finally {
|
|
2980
|
-
clearTimeout(timeoutHandle);
|
|
2981
|
-
}
|
|
4077
|
+
return raceWithTimeout(doShutdown(), shutdownTimeoutMs, () => {
|
|
4078
|
+
this._logger.critical("Timeout while shutting down PostHog. Some events may not have been sent.", {
|
|
4079
|
+
shutdownTimeoutMs
|
|
4080
|
+
});
|
|
4081
|
+
hasTimedOut = true;
|
|
4082
|
+
});
|
|
2982
4083
|
}
|
|
2983
4084
|
async shutdown(shutdownTimeoutMs = 30000) {
|
|
2984
4085
|
if (this.shutdownPromise)
|
|
@@ -2990,21 +4091,30 @@ class PostHogCoreStateless {
|
|
|
2990
4091
|
return this.shutdownPromise;
|
|
2991
4092
|
}
|
|
2992
4093
|
}
|
|
2993
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
2994
|
-
import {
|
|
4094
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
|
|
4095
|
+
import { constants as constants2 } from "node:fs";
|
|
4096
|
+
import { open as promises_open } from "node:fs/promises";
|
|
4097
|
+
import { isAbsolute } from "node:path";
|
|
2995
4098
|
import { createInterface } from "node:readline";
|
|
2996
4099
|
var LRU_FILE_CONTENTS_CACHE = new exports_error_tracking.ReduceableCache(25);
|
|
2997
4100
|
var LRU_FILE_CONTENTS_FS_READ_FAILED = new exports_error_tracking.ReduceableCache(20);
|
|
2998
4101
|
var DEFAULT_LINES_OF_CONTEXT = 7;
|
|
2999
4102
|
var MAX_CONTEXTLINES_COLNO = 1000;
|
|
3000
4103
|
var MAX_CONTEXTLINES_LINENO = 1e4;
|
|
3001
|
-
|
|
4104
|
+
var MAX_CONTEXTLINES_FILE_SIZE = 10485760;
|
|
4105
|
+
async function addSourceContext(frames, openSourceFile = promises_open, logger2) {
|
|
3002
4106
|
const filesToLines = {};
|
|
4107
|
+
let basePath;
|
|
4108
|
+
try {
|
|
4109
|
+
basePath = process.cwd();
|
|
4110
|
+
} catch {}
|
|
3003
4111
|
for (let i = frames.length - 1;i >= 0; i--) {
|
|
3004
4112
|
const frame = frames[i];
|
|
3005
4113
|
const filename = frame?.filename;
|
|
3006
4114
|
if (!frame || typeof filename != "string" || typeof frame.lineno != "number" || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame))
|
|
3007
4115
|
continue;
|
|
4116
|
+
if (!isAbsolute(filename) && basePath === undefined)
|
|
4117
|
+
continue;
|
|
3008
4118
|
const filesToLinesOutput = filesToLines[filename];
|
|
3009
4119
|
if (!filesToLinesOutput)
|
|
3010
4120
|
filesToLines[filename] = [];
|
|
@@ -3015,50 +4125,98 @@ async function addSourceContext(frames) {
|
|
|
3015
4125
|
return frames;
|
|
3016
4126
|
const readlinePromises = [];
|
|
3017
4127
|
for (const file of files) {
|
|
3018
|
-
|
|
4128
|
+
const cacheKey = makeSourceCacheKey(file, basePath);
|
|
4129
|
+
if (cacheKey === undefined)
|
|
4130
|
+
continue;
|
|
4131
|
+
if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey))
|
|
3019
4132
|
continue;
|
|
3020
4133
|
const filesToLineRanges = filesToLines[file];
|
|
3021
4134
|
if (!filesToLineRanges)
|
|
3022
4135
|
continue;
|
|
3023
4136
|
filesToLineRanges.sort((a, b) => a - b);
|
|
3024
4137
|
const ranges = makeLineReaderRanges(filesToLineRanges);
|
|
3025
|
-
if (ranges.every((r) => rangeExistsInContentCache(
|
|
4138
|
+
if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r)))
|
|
3026
4139
|
continue;
|
|
3027
|
-
const cache = emplace(LRU_FILE_CONTENTS_CACHE,
|
|
3028
|
-
readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
|
|
4140
|
+
const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
|
|
4141
|
+
readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger2));
|
|
3029
4142
|
}
|
|
3030
4143
|
await Promise.all(readlinePromises).catch(() => {});
|
|
3031
4144
|
if (frames && frames.length > 0)
|
|
3032
|
-
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
|
|
4145
|
+
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
|
|
3033
4146
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
3034
4147
|
return frames;
|
|
3035
4148
|
}
|
|
3036
|
-
function
|
|
4149
|
+
async function openRegularSourceFile(path2, openSourceFile, logger2) {
|
|
4150
|
+
let fileHandle;
|
|
4151
|
+
let isValid = false;
|
|
4152
|
+
try {
|
|
4153
|
+
fileHandle = await openSourceFile(path2, constants2.O_RDONLY | constants2.O_NONBLOCK);
|
|
4154
|
+
const fileStat = await fileHandle.stat();
|
|
4155
|
+
if (!fileStat.isFile())
|
|
4156
|
+
return;
|
|
4157
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE)
|
|
4158
|
+
return void logger2?.debug(`Skipping source context for oversized file ${path2}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
4159
|
+
isValid = true;
|
|
4160
|
+
return fileHandle;
|
|
4161
|
+
} catch {
|
|
4162
|
+
return;
|
|
4163
|
+
} finally {
|
|
4164
|
+
if (fileHandle && !isValid)
|
|
4165
|
+
await fileHandle.close().catch(() => {});
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
async function getContextLinesFromFile(path2, ranges, output, cacheKey, openSourceFile, logger2) {
|
|
4169
|
+
const fileHandle = await openRegularSourceFile(path2, openSourceFile, logger2);
|
|
4170
|
+
if (fileHandle === undefined)
|
|
4171
|
+
return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
4172
|
+
const openedFileHandle = fileHandle;
|
|
3037
4173
|
return new Promise((resolve) => {
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
4174
|
+
let finished = false;
|
|
4175
|
+
function destroyStreamAndResolve(stream2) {
|
|
4176
|
+
if (finished)
|
|
4177
|
+
return;
|
|
4178
|
+
finished = true;
|
|
4179
|
+
stream2?.destroy();
|
|
4180
|
+
openedFileHandle.close().then(resolve, resolve);
|
|
4181
|
+
}
|
|
4182
|
+
let stream;
|
|
4183
|
+
try {
|
|
4184
|
+
stream = openedFileHandle.createReadStream({
|
|
4185
|
+
autoClose: false,
|
|
4186
|
+
start: 0,
|
|
4187
|
+
end: MAX_CONTEXTLINES_FILE_SIZE - 1
|
|
4188
|
+
});
|
|
4189
|
+
} catch {
|
|
4190
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
4191
|
+
destroyStreamAndResolve();
|
|
4192
|
+
return;
|
|
4193
|
+
}
|
|
4194
|
+
let lineReaded;
|
|
4195
|
+
try {
|
|
4196
|
+
lineReaded = createInterface({
|
|
4197
|
+
input: stream
|
|
4198
|
+
});
|
|
4199
|
+
} catch {
|
|
4200
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
4201
|
+
destroyStreamAndResolve(stream);
|
|
4202
|
+
return;
|
|
3045
4203
|
}
|
|
3046
4204
|
let lineNumber = 0;
|
|
3047
4205
|
let currentRangeIndex = 0;
|
|
3048
4206
|
const range = ranges[currentRangeIndex];
|
|
3049
4207
|
if (range === undefined)
|
|
3050
|
-
return void destroyStreamAndResolve();
|
|
4208
|
+
return void destroyStreamAndResolve(stream);
|
|
3051
4209
|
let rangeStart = range[0];
|
|
3052
4210
|
let rangeEnd = range[1];
|
|
3053
4211
|
function onStreamError() {
|
|
3054
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
4212
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3055
4213
|
lineReaded.close();
|
|
3056
4214
|
lineReaded.removeAllListeners();
|
|
3057
|
-
destroyStreamAndResolve();
|
|
4215
|
+
destroyStreamAndResolve(stream);
|
|
3058
4216
|
}
|
|
3059
4217
|
stream.on("error", onStreamError);
|
|
3060
4218
|
lineReaded.on("error", onStreamError);
|
|
3061
|
-
lineReaded.on("close", destroyStreamAndResolve);
|
|
4219
|
+
lineReaded.on("close", () => destroyStreamAndResolve(stream));
|
|
3062
4220
|
lineReaded.on("line", (line) => {
|
|
3063
4221
|
lineNumber++;
|
|
3064
4222
|
if (lineNumber < rangeStart)
|
|
@@ -3083,10 +4241,11 @@ function getContextLinesFromFile(path2, ranges, output) {
|
|
|
3083
4241
|
});
|
|
3084
4242
|
});
|
|
3085
4243
|
}
|
|
3086
|
-
function addSourceContextToFrames(frames, cache) {
|
|
4244
|
+
function addSourceContextToFrames(frames, cache, basePath) {
|
|
3087
4245
|
for (const frame of frames)
|
|
3088
4246
|
if (frame.filename && frame.context_line === undefined && typeof frame.lineno == "number") {
|
|
3089
|
-
const
|
|
4247
|
+
const cacheKey = makeSourceCacheKey(frame.filename, basePath);
|
|
4248
|
+
const contents = cacheKey === undefined ? undefined : cache.get(cacheKey);
|
|
3090
4249
|
if (contents === undefined)
|
|
3091
4250
|
continue;
|
|
3092
4251
|
addContextToFrame(frame.lineno, frame, contents);
|
|
@@ -3129,8 +4288,19 @@ function shouldSkipContextLinesForFrame(frame) {
|
|
|
3129
4288
|
return true;
|
|
3130
4289
|
return false;
|
|
3131
4290
|
}
|
|
3132
|
-
function
|
|
3133
|
-
|
|
4291
|
+
function makeSourceCacheKey(path2, basePath) {
|
|
4292
|
+
if (isAbsolute(path2))
|
|
4293
|
+
return JSON.stringify([
|
|
4294
|
+
null,
|
|
4295
|
+
path2
|
|
4296
|
+
]);
|
|
4297
|
+
return basePath === undefined ? undefined : JSON.stringify([
|
|
4298
|
+
basePath,
|
|
4299
|
+
path2
|
|
4300
|
+
]);
|
|
4301
|
+
}
|
|
4302
|
+
function rangeExistsInContentCache(cacheKey, range) {
|
|
4303
|
+
const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
|
|
3134
4304
|
if (contents === undefined)
|
|
3135
4305
|
return false;
|
|
3136
4306
|
for (let i = range[0];i <= range[1]; i++)
|
|
@@ -3208,8 +4378,8 @@ function snipLine(line, colno) {
|
|
|
3208
4378
|
return newLine;
|
|
3209
4379
|
}
|
|
3210
4380
|
|
|
3211
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
3212
|
-
import { isAbsolute, relative, sep as sep2 } from "node:path";
|
|
4381
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
|
|
4382
|
+
import { isAbsolute as isAbsolute2, relative, sep as sep2 } from "node:path";
|
|
3213
4383
|
function createRelativePathModifier(basePath = process.cwd()) {
|
|
3214
4384
|
const isWindows = sep2 === "\\";
|
|
3215
4385
|
const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
|
|
@@ -3217,17 +4387,17 @@ function createRelativePathModifier(basePath = process.cwd()) {
|
|
|
3217
4387
|
return async (frames) => {
|
|
3218
4388
|
for (const frame of frames)
|
|
3219
4389
|
if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
|
|
3220
|
-
if (
|
|
4390
|
+
if (isAbsolute2(frame.filename))
|
|
3221
4391
|
frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
|
|
3222
4392
|
}
|
|
3223
4393
|
return frames;
|
|
3224
4394
|
};
|
|
3225
4395
|
}
|
|
3226
4396
|
|
|
3227
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
3228
|
-
var version = "5.
|
|
4397
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/version.mjs
|
|
4398
|
+
var version = "5.51.1";
|
|
3229
4399
|
|
|
3230
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4400
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/types.mjs
|
|
3231
4401
|
var FeatureFlagError2 = {
|
|
3232
4402
|
ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
|
|
3233
4403
|
FLAG_MISSING: "flag_missing",
|
|
@@ -3235,7 +4405,7 @@ var FeatureFlagError2 = {
|
|
|
3235
4405
|
UNKNOWN_ERROR: "unknown_error"
|
|
3236
4406
|
};
|
|
3237
4407
|
|
|
3238
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4408
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
|
|
3239
4409
|
class FeatureFlagEvaluations {
|
|
3240
4410
|
constructor(init) {
|
|
3241
4411
|
this._host = init.host;
|
|
@@ -3251,10 +4421,10 @@ class FeatureFlagEvaluations {
|
|
|
3251
4421
|
this._accessed = init.accessed ?? new Set;
|
|
3252
4422
|
this._isSlice = init.isSlice ?? false;
|
|
3253
4423
|
}
|
|
3254
|
-
isEnabled(key) {
|
|
4424
|
+
isEnabled(key, options = {}) {
|
|
3255
4425
|
const flag = this._flags[key];
|
|
3256
4426
|
this._recordAccess(key);
|
|
3257
|
-
return flag?.enabled ?? false;
|
|
4427
|
+
return flag?.enabled ?? options.defaultValue ?? false;
|
|
3258
4428
|
}
|
|
3259
4429
|
getFlag(key) {
|
|
3260
4430
|
const flag = this._flags[key];
|
|
@@ -3344,6 +4514,8 @@ class FeatureFlagEvaluations {
|
|
|
3344
4514
|
$feature_flag_request_id: this._requestId,
|
|
3345
4515
|
$feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt
|
|
3346
4516
|
};
|
|
4517
|
+
if (flag?.hasExperiment !== undefined)
|
|
4518
|
+
properties.$feature_flag_has_experiment = flag.hasExperiment;
|
|
3347
4519
|
if (flag?.locallyEvaluated && this._flagDefinitionsLoadedAt !== undefined)
|
|
3348
4520
|
properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt;
|
|
3349
4521
|
const errors = [];
|
|
@@ -3366,7 +4538,7 @@ class FeatureFlagEvaluations {
|
|
|
3366
4538
|
}
|
|
3367
4539
|
}
|
|
3368
4540
|
|
|
3369
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4541
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
|
|
3370
4542
|
async function hashSHA1(text) {
|
|
3371
4543
|
const subtle = globalThis.crypto?.subtle;
|
|
3372
4544
|
if (!subtle)
|
|
@@ -3376,7 +4548,7 @@ async function hashSHA1(text) {
|
|
|
3376
4548
|
return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3377
4549
|
}
|
|
3378
4550
|
|
|
3379
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4551
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
|
|
3380
4552
|
var SIXTY_SECONDS = 60000;
|
|
3381
4553
|
var LONG_SCALE = 1152921504606847000;
|
|
3382
4554
|
var NULL_VALUES_ALLOWED_OPERATORS = [
|
|
@@ -3393,22 +4565,23 @@ class ClientError extends Error {
|
|
|
3393
4565
|
Object.setPrototypeOf(this, ClientError.prototype);
|
|
3394
4566
|
}
|
|
3395
4567
|
}
|
|
4568
|
+
function setCustomErrorPrototype(error, constructor) {
|
|
4569
|
+
error.name = constructor.name;
|
|
4570
|
+
Error.captureStackTrace(error, constructor);
|
|
4571
|
+
Object.setPrototypeOf(error, constructor.prototype);
|
|
4572
|
+
}
|
|
3396
4573
|
|
|
3397
4574
|
class InconclusiveMatchError extends Error {
|
|
3398
4575
|
constructor(message) {
|
|
3399
4576
|
super(message);
|
|
3400
|
-
this
|
|
3401
|
-
Error.captureStackTrace(this, this.constructor);
|
|
3402
|
-
Object.setPrototypeOf(this, InconclusiveMatchError.prototype);
|
|
4577
|
+
setCustomErrorPrototype(this, InconclusiveMatchError);
|
|
3403
4578
|
}
|
|
3404
4579
|
}
|
|
3405
4580
|
|
|
3406
4581
|
class RequiresServerEvaluation extends Error {
|
|
3407
4582
|
constructor(message) {
|
|
3408
4583
|
super(message);
|
|
3409
|
-
this
|
|
3410
|
-
Error.captureStackTrace(this, this.constructor);
|
|
3411
|
-
Object.setPrototypeOf(this, RequiresServerEvaluation.prototype);
|
|
4584
|
+
setCustomErrorPrototype(this, RequiresServerEvaluation);
|
|
3412
4585
|
}
|
|
3413
4586
|
}
|
|
3414
4587
|
|
|
@@ -3417,6 +4590,7 @@ class FeatureFlagsPoller {
|
|
|
3417
4590
|
this.debugMode = false;
|
|
3418
4591
|
this.shouldBeginExponentialBackoff = false;
|
|
3419
4592
|
this.backOffCount = 0;
|
|
4593
|
+
this.pollerStopped = false;
|
|
3420
4594
|
this.pollingInterval = pollingInterval;
|
|
3421
4595
|
this.personalApiKey = personalApiKey;
|
|
3422
4596
|
this.featureFlags = [];
|
|
@@ -3432,6 +4606,7 @@ class FeatureFlagsPoller {
|
|
|
3432
4606
|
this.onError = options.onError;
|
|
3433
4607
|
this.customHeaders = customHeaders;
|
|
3434
4608
|
this.onLoad = options.onLoad;
|
|
4609
|
+
this.onMinimalFlagCalledEvents = options.onMinimalFlagCalledEvents;
|
|
3435
4610
|
this.cacheProvider = options.cacheProvider;
|
|
3436
4611
|
this.strictLocalEvaluation = options.strictLocalEvaluation ?? false;
|
|
3437
4612
|
this.loadFeatureFlags();
|
|
@@ -3629,6 +4804,7 @@ class FeatureFlagsPoller {
|
|
|
3629
4804
|
const flagFilters = flag.filters || {};
|
|
3630
4805
|
const flagConditions = flagFilters.groups || [];
|
|
3631
4806
|
const flagAggregation = flagFilters.aggregation_group_type_index;
|
|
4807
|
+
const earlyExitEnabled = flagFilters.early_exit ?? false;
|
|
3632
4808
|
const { groups, groupProperties } = evaluationContext;
|
|
3633
4809
|
let isInconclusive = false;
|
|
3634
4810
|
let result;
|
|
@@ -3652,12 +4828,15 @@ class FeatureFlagsPoller {
|
|
|
3652
4828
|
effectiveBucketingValue = groups[groupName];
|
|
3653
4829
|
}
|
|
3654
4830
|
}
|
|
3655
|
-
|
|
4831
|
+
const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
|
|
4832
|
+
if (matchResult === "match") {
|
|
3656
4833
|
const variantOverride = condition.variant;
|
|
3657
4834
|
const flagVariants = flagFilters.multivariate?.variants || [];
|
|
3658
4835
|
result = variantOverride && flagVariants.some((variant) => variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
|
|
3659
4836
|
break;
|
|
3660
4837
|
}
|
|
4838
|
+
if (earlyExitEnabled && matchResult === "out_of_rollout_bound")
|
|
4839
|
+
return false;
|
|
3661
4840
|
} catch (e) {
|
|
3662
4841
|
if (e instanceof RequiresServerEvaluation)
|
|
3663
4842
|
throw e;
|
|
@@ -3681,16 +4860,20 @@ class FeatureFlagsPoller {
|
|
|
3681
4860
|
for (const prop of condition.properties) {
|
|
3682
4861
|
const propertyType = prop.type;
|
|
3683
4862
|
let matches = false;
|
|
3684
|
-
|
|
4863
|
+
if (propertyType === "cohort") {
|
|
4864
|
+
const inCohort = await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext));
|
|
4865
|
+
matches = prop.operator === "not_in" ? !inCohort : inCohort;
|
|
4866
|
+
} else
|
|
4867
|
+
matches = propertyType === "flag" ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
|
|
3685
4868
|
if (!matches)
|
|
3686
|
-
return
|
|
4869
|
+
return "no_match";
|
|
3687
4870
|
}
|
|
3688
4871
|
if (rolloutPercentage == undefined)
|
|
3689
|
-
return
|
|
4872
|
+
return "match";
|
|
3690
4873
|
}
|
|
3691
4874
|
if (rolloutPercentage != null && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100)
|
|
3692
|
-
return
|
|
3693
|
-
return
|
|
4875
|
+
return "out_of_rollout_bound";
|
|
4876
|
+
return "match";
|
|
3694
4877
|
}
|
|
3695
4878
|
async getMatchingVariant(flag, bucketingValue) {
|
|
3696
4879
|
const hashValue = await _hash(flag.key, bucketingValue, "variant");
|
|
@@ -3721,6 +4904,7 @@ class FeatureFlagsPoller {
|
|
|
3721
4904
|
this.groupTypeMapping = flagData.groupTypeMapping;
|
|
3722
4905
|
this.cohorts = flagData.cohorts;
|
|
3723
4906
|
this.loadedSuccessfullyOnce = true;
|
|
4907
|
+
this.onMinimalFlagCalledEvents?.(flagData.minimalFlagCalledEvents === true);
|
|
3724
4908
|
}
|
|
3725
4909
|
warnAboutExperienceContinuityFlags(flags) {
|
|
3726
4910
|
if (this.strictLocalEvaluation)
|
|
@@ -3784,7 +4968,6 @@ class FeatureFlagsPoller {
|
|
|
3784
4968
|
clearTimeout(this.poller);
|
|
3785
4969
|
this.poller = undefined;
|
|
3786
4970
|
}
|
|
3787
|
-
this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
|
|
3788
4971
|
try {
|
|
3789
4972
|
let shouldFetch = true;
|
|
3790
4973
|
if (this.cacheProvider)
|
|
@@ -3812,17 +4995,18 @@ class FeatureFlagsPoller {
|
|
|
3812
4995
|
return;
|
|
3813
4996
|
case 401:
|
|
3814
4997
|
this.beginBackoff();
|
|
3815
|
-
throw new ClientError(`Your project key or
|
|
4998
|
+
throw new ClientError(`Your project key or secret key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
|
|
3816
4999
|
case 402:
|
|
3817
5000
|
console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts");
|
|
3818
5001
|
this.featureFlags = [];
|
|
3819
5002
|
this.featureFlagsByKey = {};
|
|
3820
5003
|
this.groupTypeMapping = {};
|
|
3821
5004
|
this.cohorts = {};
|
|
5005
|
+
this.onMinimalFlagCalledEvents?.(false);
|
|
3822
5006
|
return;
|
|
3823
5007
|
case 403:
|
|
3824
5008
|
this.beginBackoff();
|
|
3825
|
-
throw new ClientError(`Your
|
|
5009
|
+
throw new ClientError(`Your secret key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct secret and Project API key pair? More information: https://posthog.com/docs/api/overview`);
|
|
3826
5010
|
case 429:
|
|
3827
5011
|
this.beginBackoff();
|
|
3828
5012
|
throw new ClientError(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
|
|
@@ -3834,7 +5018,8 @@ class FeatureFlagsPoller {
|
|
|
3834
5018
|
const flagData = {
|
|
3835
5019
|
flags: responseJson.flags ?? [],
|
|
3836
5020
|
groupTypeMapping: responseJson.group_type_mapping || {},
|
|
3837
|
-
cohorts: responseJson.cohorts || {}
|
|
5021
|
+
cohorts: responseJson.cohorts || {},
|
|
5022
|
+
minimalFlagCalledEvents: responseJson.minimal_flag_called_events === true
|
|
3838
5023
|
};
|
|
3839
5024
|
this.updateFlagState(flagData);
|
|
3840
5025
|
this.flagDefinitionsLoadedAt = Date.now();
|
|
@@ -3855,6 +5040,9 @@ class FeatureFlagsPoller {
|
|
|
3855
5040
|
} catch (err) {
|
|
3856
5041
|
if (err instanceof ClientError)
|
|
3857
5042
|
this.onError?.(err);
|
|
5043
|
+
} finally {
|
|
5044
|
+
if (!this.pollerStopped)
|
|
5045
|
+
this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
|
|
3858
5046
|
}
|
|
3859
5047
|
}
|
|
3860
5048
|
getPersonalApiKeyRequestOptions(method = "GET", etag) {
|
|
@@ -3870,7 +5058,7 @@ class FeatureFlagsPoller {
|
|
|
3870
5058
|
headers
|
|
3871
5059
|
};
|
|
3872
5060
|
}
|
|
3873
|
-
_requestFeatureFlagDefinitions() {
|
|
5061
|
+
async _requestFeatureFlagDefinitions() {
|
|
3874
5062
|
const url = `${this.host}/flags/definitions?token=${this.projectApiKey}&send_cohorts`;
|
|
3875
5063
|
const options = this.getPersonalApiKeyRequestOptions("GET", this.flagsEtag);
|
|
3876
5064
|
let abortTimeout = null;
|
|
@@ -3881,23 +5069,49 @@ class FeatureFlagsPoller {
|
|
|
3881
5069
|
}, this.timeout);
|
|
3882
5070
|
options.signal = controller.signal;
|
|
3883
5071
|
}
|
|
5072
|
+
const clearAbortTimeout = () => clearTimeout(abortTimeout);
|
|
3884
5073
|
try {
|
|
3885
5074
|
const fetch1 = this.fetch;
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
5075
|
+
const res = await fetch1(url, options);
|
|
5076
|
+
if (res.status !== 200) {
|
|
5077
|
+
clearAbortTimeout();
|
|
5078
|
+
return res;
|
|
5079
|
+
}
|
|
5080
|
+
return {
|
|
5081
|
+
status: res.status,
|
|
5082
|
+
headers: res.headers,
|
|
5083
|
+
body: res.body,
|
|
5084
|
+
text: async () => {
|
|
5085
|
+
try {
|
|
5086
|
+
return await res.text();
|
|
5087
|
+
} finally {
|
|
5088
|
+
clearAbortTimeout();
|
|
5089
|
+
}
|
|
5090
|
+
},
|
|
5091
|
+
json: async () => {
|
|
5092
|
+
try {
|
|
5093
|
+
return await res.json();
|
|
5094
|
+
} finally {
|
|
5095
|
+
clearAbortTimeout();
|
|
5096
|
+
}
|
|
5097
|
+
}
|
|
5098
|
+
};
|
|
5099
|
+
} catch (err) {
|
|
5100
|
+
clearAbortTimeout();
|
|
5101
|
+
throw err;
|
|
3889
5102
|
}
|
|
3890
5103
|
}
|
|
3891
5104
|
async stopPoller(timeoutMs = 30000) {
|
|
5105
|
+
this.pollerStopped = true;
|
|
3892
5106
|
clearTimeout(this.poller);
|
|
5107
|
+
this.poller = undefined;
|
|
3893
5108
|
if (this.cacheProvider)
|
|
3894
5109
|
try {
|
|
3895
5110
|
const shutdownResult = this.cacheProvider.shutdown();
|
|
3896
5111
|
if (shutdownResult instanceof Promise)
|
|
3897
|
-
await
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
]);
|
|
5112
|
+
await raceWithTimeout(shutdownResult, timeoutMs, () => {
|
|
5113
|
+
throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
|
|
5114
|
+
});
|
|
3901
5115
|
} catch (err) {
|
|
3902
5116
|
this.onError?.(new Error(`Error during cache shutdown: ${err}`));
|
|
3903
5117
|
}
|
|
@@ -3952,6 +5166,14 @@ function matchProperty(property, propertyValues, warnFunction) {
|
|
|
3952
5166
|
return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
3953
5167
|
case "not_icontains":
|
|
3954
5168
|
return !String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
5169
|
+
case "starts_with":
|
|
5170
|
+
return String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
|
|
5171
|
+
case "not_starts_with":
|
|
5172
|
+
return !String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
|
|
5173
|
+
case "ends_with":
|
|
5174
|
+
return String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
|
|
5175
|
+
case "not_ends_with":
|
|
5176
|
+
return !String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
|
|
3955
5177
|
case "regex":
|
|
3956
5178
|
return isValidRegex(String(value)) && String(overrideValue).match(String(value)) !== null;
|
|
3957
5179
|
case "not_regex":
|
|
@@ -4278,19 +5500,75 @@ function relativeDateParseForFeatureFlagMatching(value) {
|
|
|
4278
5500
|
}
|
|
4279
5501
|
}
|
|
4280
5502
|
|
|
4281
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5503
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
|
|
5504
|
+
var UNHANDLED_REJECTION_OPTION_NAMES = [
|
|
5505
|
+
"--unhandled-rejections",
|
|
5506
|
+
"--unhandled_rejections"
|
|
5507
|
+
];
|
|
5508
|
+
var UNHANDLED_REJECTION_MODES = new Set([
|
|
5509
|
+
"throw",
|
|
5510
|
+
"strict",
|
|
5511
|
+
"warn",
|
|
5512
|
+
"warn-with-error-code",
|
|
5513
|
+
"none"
|
|
5514
|
+
]);
|
|
5515
|
+
var STARTUP_EXEC_ARGV = [
|
|
5516
|
+
...globalThis.process?.execArgv ?? []
|
|
5517
|
+
];
|
|
5518
|
+
var STARTUP_NODE_OPTIONS = globalThis.process?.env?.NODE_OPTIONS;
|
|
5519
|
+
function splitNodeOptions(nodeOptions) {
|
|
5520
|
+
const args = [];
|
|
5521
|
+
let current = "";
|
|
5522
|
+
let isInString = false;
|
|
5523
|
+
for (let index = 0;index < nodeOptions.length; index++) {
|
|
5524
|
+
const character = nodeOptions[index];
|
|
5525
|
+
if (character === "\\" && isInString && index + 1 < nodeOptions.length)
|
|
5526
|
+
current += nodeOptions[++index];
|
|
5527
|
+
else if (character !== " " || isInString)
|
|
5528
|
+
if (character === '"')
|
|
5529
|
+
isInString = !isInString;
|
|
5530
|
+
else
|
|
5531
|
+
current += character;
|
|
5532
|
+
else if (current) {
|
|
5533
|
+
args.push(current);
|
|
5534
|
+
current = "";
|
|
5535
|
+
}
|
|
5536
|
+
}
|
|
5537
|
+
if (current)
|
|
5538
|
+
args.push(current);
|
|
5539
|
+
return args;
|
|
5540
|
+
}
|
|
5541
|
+
function findUnhandledRejectionMode(args) {
|
|
5542
|
+
let mode;
|
|
5543
|
+
for (let index = 0;index < args.length; index++) {
|
|
5544
|
+
const argument = args[index];
|
|
5545
|
+
const optionName = UNHANDLED_REJECTION_OPTION_NAMES.find((name) => argument === name || argument.startsWith(`${name}=`));
|
|
5546
|
+
if (!optionName)
|
|
5547
|
+
continue;
|
|
5548
|
+
const value = argument === optionName ? args[++index] : argument.slice(optionName.length + 1);
|
|
5549
|
+
if (UNHANDLED_REJECTION_MODES.has(value))
|
|
5550
|
+
mode = value;
|
|
5551
|
+
}
|
|
5552
|
+
return mode;
|
|
5553
|
+
}
|
|
5554
|
+
function getUnhandledRejectionMode(execArgv = STARTUP_EXEC_ARGV, nodeOptions = STARTUP_NODE_OPTIONS) {
|
|
5555
|
+
return findUnhandledRejectionMode(execArgv) ?? findUnhandledRejectionMode(splitNodeOptions(nodeOptions ?? "")) ?? "throw";
|
|
5556
|
+
}
|
|
5557
|
+
var STARTUP_UNHANDLED_REJECTION_MODE = getUnhandledRejectionMode();
|
|
5558
|
+
function captureUncaughtException(captureFn, error, origin) {
|
|
5559
|
+
captureFn(error, {
|
|
5560
|
+
mechanism: {
|
|
5561
|
+
type: origin === "unhandledRejection" ? "onunhandledrejection" : "onuncaughtexception",
|
|
5562
|
+
handled: false
|
|
5563
|
+
}
|
|
5564
|
+
});
|
|
5565
|
+
}
|
|
4282
5566
|
function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
|
|
4283
5567
|
let calledFatalError = false;
|
|
4284
|
-
return Object.assign((error) => {
|
|
5568
|
+
return Object.assign((error, origin) => {
|
|
4285
5569
|
const userProvidedListenersCount = global.process.listeners("uncaughtException").filter((listener) => listener.name !== "domainUncaughtExceptionClear" && listener._posthogErrorHandler !== true).length;
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
mechanism: {
|
|
4289
|
-
type: "onuncaughtexception",
|
|
4290
|
-
handled: false
|
|
4291
|
-
}
|
|
4292
|
-
});
|
|
4293
|
-
if (!calledFatalError && processWouldExit) {
|
|
5570
|
+
captureUncaughtException(captureFn, error, origin);
|
|
5571
|
+
if (!calledFatalError && userProvidedListenersCount === 0) {
|
|
4294
5572
|
calledFatalError = true;
|
|
4295
5573
|
onFatalFn(error);
|
|
4296
5574
|
}
|
|
@@ -4298,29 +5576,38 @@ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
|
|
|
4298
5576
|
_posthogErrorHandler: true
|
|
4299
5577
|
});
|
|
4300
5578
|
}
|
|
4301
|
-
function addUncaughtExceptionListener(captureFn, onFatalFn) {
|
|
4302
|
-
globalThis.process
|
|
5579
|
+
function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
|
|
5580
|
+
const process2 = globalThis.process;
|
|
5581
|
+
if (!process2)
|
|
5582
|
+
return;
|
|
5583
|
+
if (mode === "strict")
|
|
5584
|
+
return void process2.on("uncaughtExceptionMonitor", (error, origin) => captureUncaughtException(captureFn, error, origin));
|
|
5585
|
+
process2.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
|
|
4303
5586
|
}
|
|
4304
|
-
function addUnhandledRejectionListener(captureFn) {
|
|
4305
|
-
globalThis.process
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
5587
|
+
function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
|
|
5588
|
+
const process2 = globalThis.process;
|
|
5589
|
+
if (!process2 || mode === "throw" || mode === "strict" || mode === "warn-with-error-code")
|
|
5590
|
+
return;
|
|
5591
|
+
process2.on("unhandledRejection", (reason) => {
|
|
5592
|
+
captureFn(reason, {
|
|
5593
|
+
mechanism: {
|
|
5594
|
+
type: "onunhandledrejection",
|
|
5595
|
+
handled: false
|
|
5596
|
+
}
|
|
5597
|
+
});
|
|
5598
|
+
});
|
|
4311
5599
|
}
|
|
4312
5600
|
|
|
4313
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5601
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
|
|
4314
5602
|
var SHUTDOWN_TIMEOUT = 2000;
|
|
4315
5603
|
|
|
4316
|
-
class
|
|
5604
|
+
class error_tracking_ErrorTracking {
|
|
4317
5605
|
constructor(client, options, _logger) {
|
|
4318
5606
|
this.client = client;
|
|
4319
5607
|
this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
|
|
4320
5608
|
this._logger = _logger;
|
|
4321
5609
|
this._rateLimiter = new BucketedRateLimiter({
|
|
4322
|
-
|
|
4323
|
-
bucketSize: 10,
|
|
5610
|
+
...resolveExceptionRateLimiterConfig(options),
|
|
4324
5611
|
refillInterval: 1e4,
|
|
4325
5612
|
_logger: this._logger
|
|
4326
5613
|
});
|
|
@@ -4335,6 +5622,9 @@ class ErrorTracking {
|
|
|
4335
5622
|
};
|
|
4336
5623
|
const exceptionProperties = builder.buildFromUnknown(error, hint);
|
|
4337
5624
|
exceptionProperties.$exception_list = await builder.modifyFrames(exceptionProperties.$exception_list);
|
|
5625
|
+
const injectedReleaseId = exports_error_tracking.getInjectedReleaseId();
|
|
5626
|
+
if (injectedReleaseId)
|
|
5627
|
+
properties.$release_id = injectedReleaseId;
|
|
4338
5628
|
return {
|
|
4339
5629
|
event: "$exception",
|
|
4340
5630
|
distinctId,
|
|
@@ -4353,8 +5643,8 @@ class ErrorTracking {
|
|
|
4353
5643
|
}
|
|
4354
5644
|
onException(exception, hint) {
|
|
4355
5645
|
this.client.addPendingPromise((async () => {
|
|
4356
|
-
if (!
|
|
4357
|
-
const eventMessage = await
|
|
5646
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(exception)) {
|
|
5647
|
+
const eventMessage = await error_tracking_ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
|
|
4358
5648
|
const exceptionProperties = eventMessage.properties;
|
|
4359
5649
|
const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
|
|
4360
5650
|
const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
|
|
@@ -4362,14 +5652,14 @@ class ErrorTracking {
|
|
|
4362
5652
|
return void this._logger.info("Skipping exception capture because of client rate limiting.", {
|
|
4363
5653
|
exception: exceptionType
|
|
4364
5654
|
});
|
|
4365
|
-
return this.client.
|
|
5655
|
+
return this.client._capturePreparedEvent(eventMessage, false);
|
|
4366
5656
|
}
|
|
4367
5657
|
})());
|
|
4368
5658
|
}
|
|
4369
5659
|
async onFatalError(exception) {
|
|
4370
5660
|
console.error(exception);
|
|
4371
5661
|
await this.client.shutdown(SHUTDOWN_TIMEOUT);
|
|
4372
|
-
process.exit(1);
|
|
5662
|
+
globalThis.process.exit(1);
|
|
4373
5663
|
}
|
|
4374
5664
|
isEnabled() {
|
|
4375
5665
|
return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
|
|
@@ -4379,7 +5669,7 @@ class ErrorTracking {
|
|
|
4379
5669
|
}
|
|
4380
5670
|
}
|
|
4381
5671
|
|
|
4382
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5672
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/storage-memory.mjs
|
|
4383
5673
|
class PostHogMemoryStorage {
|
|
4384
5674
|
getProperty(key) {
|
|
4385
5675
|
return this._memoryStorage[key];
|
|
@@ -4392,7 +5682,452 @@ class PostHogMemoryStorage {
|
|
|
4392
5682
|
}
|
|
4393
5683
|
}
|
|
4394
5684
|
|
|
4395
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5685
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/config.mjs
|
|
5686
|
+
function isCaptureMode(value) {
|
|
5687
|
+
return value === "v0" || value === "v1";
|
|
5688
|
+
}
|
|
5689
|
+
function resolveCaptureMode() {
|
|
5690
|
+
const envMode = typeof process != "undefined" ? process.env?.POSTHOG_CAPTURE_MODE : undefined;
|
|
5691
|
+
return isCaptureMode(envMode) ? envMode : "v0";
|
|
5692
|
+
}
|
|
5693
|
+
|
|
5694
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/routing.mjs
|
|
5695
|
+
var AI_EVENT_PREFIX = "$ai_";
|
|
5696
|
+
var ANALYTICS_ROUTE = "analytics";
|
|
5697
|
+
var AI_ROUTE = "ai";
|
|
5698
|
+
function isLegacyOnlyEvent(message) {
|
|
5699
|
+
return typeof message.event == "string" && message.event.startsWith(AI_EVENT_PREFIX);
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5702
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/errors.mjs
|
|
5703
|
+
class CaptureV1Error extends Error {
|
|
5704
|
+
constructor({ requestId, drops, retryExhausted, cause }) {
|
|
5705
|
+
super(CaptureV1Error.buildMessage(requestId, drops, retryExhausted, cause)), this.name = "CaptureV1Error";
|
|
5706
|
+
this.requestId = requestId;
|
|
5707
|
+
this.drops = drops;
|
|
5708
|
+
this.retryExhausted = retryExhausted;
|
|
5709
|
+
this.cause = cause;
|
|
5710
|
+
}
|
|
5711
|
+
static buildMessage(requestId, drops, retryExhausted, cause) {
|
|
5712
|
+
let message = `Capture V1 batch ${requestId} did not fully deliver: ${drops.length} dropped, ${retryExhausted.length} undelivered`;
|
|
5713
|
+
if (cause instanceof Error)
|
|
5714
|
+
message += ` (${cause.message})`;
|
|
5715
|
+
return message;
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/transform.mjs
|
|
5720
|
+
function coerceBool(value) {
|
|
5721
|
+
if (typeof value == "boolean")
|
|
5722
|
+
return value;
|
|
5723
|
+
if (typeof value == "number")
|
|
5724
|
+
return value !== 0;
|
|
5725
|
+
if (typeof value == "string") {
|
|
5726
|
+
const normalized = value.trim().toLowerCase();
|
|
5727
|
+
if (normalized === "true" || normalized === "1")
|
|
5728
|
+
return true;
|
|
5729
|
+
if (normalized === "false" || normalized === "0")
|
|
5730
|
+
return false;
|
|
5731
|
+
}
|
|
5732
|
+
}
|
|
5733
|
+
function coerceString(value) {
|
|
5734
|
+
return typeof value == "string" ? value : undefined;
|
|
5735
|
+
}
|
|
5736
|
+
var OPTION_SENTINELS = [
|
|
5737
|
+
{
|
|
5738
|
+
property: "$cookieless_mode",
|
|
5739
|
+
optionKey: "cookieless_mode",
|
|
5740
|
+
coerce: coerceBool
|
|
5741
|
+
},
|
|
5742
|
+
{
|
|
5743
|
+
property: "$ignore_sent_at",
|
|
5744
|
+
optionKey: "disable_skew_correction",
|
|
5745
|
+
coerce: coerceBool
|
|
5746
|
+
},
|
|
5747
|
+
{
|
|
5748
|
+
property: "$process_person_profile",
|
|
5749
|
+
optionKey: "process_person_profile",
|
|
5750
|
+
coerce: coerceBool
|
|
5751
|
+
},
|
|
5752
|
+
{
|
|
5753
|
+
property: "$product_tour_id",
|
|
5754
|
+
optionKey: "product_tour_id",
|
|
5755
|
+
coerce: coerceString
|
|
5756
|
+
}
|
|
5757
|
+
];
|
|
5758
|
+
var TOPLEVEL_SENTINELS = [
|
|
5759
|
+
{
|
|
5760
|
+
property: "$session_id",
|
|
5761
|
+
field: "session_id"
|
|
5762
|
+
},
|
|
5763
|
+
{
|
|
5764
|
+
property: "$window_id",
|
|
5765
|
+
field: "window_id"
|
|
5766
|
+
}
|
|
5767
|
+
];
|
|
5768
|
+
function isRecord2(value) {
|
|
5769
|
+
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
5770
|
+
}
|
|
5771
|
+
function toRfc3339(timestamp) {
|
|
5772
|
+
if (typeof timestamp == "string") {
|
|
5773
|
+
const asDate2 = new Date(timestamp);
|
|
5774
|
+
if (Number.isNaN(asDate2.getTime()))
|
|
5775
|
+
return new Date().toISOString();
|
|
5776
|
+
const normalized = asDate2.toISOString();
|
|
5777
|
+
const fractionalSeconds = timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1];
|
|
5778
|
+
return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
|
|
5779
|
+
}
|
|
5780
|
+
if (timestamp instanceof Date)
|
|
5781
|
+
return Number.isNaN(timestamp.getTime()) ? new Date().toISOString() : timestamp.toISOString();
|
|
5782
|
+
const asDate = timestamp == null ? new Date : new Date(timestamp);
|
|
5783
|
+
return Number.isNaN(asDate.getTime()) ? new Date().toISOString() : asDate.toISOString();
|
|
5784
|
+
}
|
|
5785
|
+
function relocateInto(properties, key, value) {
|
|
5786
|
+
if (value !== undefined && !(key in properties))
|
|
5787
|
+
properties[key] = value;
|
|
5788
|
+
}
|
|
5789
|
+
function buildV1Event(message) {
|
|
5790
|
+
const sourceProperties = isRecord2(message.properties) ? message.properties : {};
|
|
5791
|
+
const properties = {
|
|
5792
|
+
...sourceProperties
|
|
5793
|
+
};
|
|
5794
|
+
const options = {};
|
|
5795
|
+
for (const { property, optionKey, coerce } of OPTION_SENTINELS)
|
|
5796
|
+
if (property in properties) {
|
|
5797
|
+
const coerced = coerce(properties[property]);
|
|
5798
|
+
if (coerced !== undefined)
|
|
5799
|
+
options[optionKey] = coerced;
|
|
5800
|
+
delete properties[property];
|
|
5801
|
+
}
|
|
5802
|
+
const topLevel = {};
|
|
5803
|
+
for (const { property, field } of TOPLEVEL_SENTINELS)
|
|
5804
|
+
if (property in properties) {
|
|
5805
|
+
const value = properties[property];
|
|
5806
|
+
if (typeof value == "string")
|
|
5807
|
+
topLevel[field] = value;
|
|
5808
|
+
delete properties[property];
|
|
5809
|
+
}
|
|
5810
|
+
delete properties.$lib;
|
|
5811
|
+
delete properties.$lib_version;
|
|
5812
|
+
relocateInto(properties, "$set", message.$set);
|
|
5813
|
+
relocateInto(properties, "$set_once", message.$set_once);
|
|
5814
|
+
return {
|
|
5815
|
+
event: String(message.event ?? ""),
|
|
5816
|
+
uuid: String(message.uuid ?? ""),
|
|
5817
|
+
distinct_id: String(message.distinct_id ?? ""),
|
|
5818
|
+
timestamp: toRfc3339(message.timestamp),
|
|
5819
|
+
...topLevel,
|
|
5820
|
+
options,
|
|
5821
|
+
properties
|
|
5822
|
+
};
|
|
5823
|
+
}
|
|
5824
|
+
function buildV1Batch(messages, { createdAt, historicalMigration }) {
|
|
5825
|
+
const batch = {
|
|
5826
|
+
created_at: createdAt,
|
|
5827
|
+
batch: messages.map(buildV1Event)
|
|
5828
|
+
};
|
|
5829
|
+
if (historicalMigration)
|
|
5830
|
+
batch.historical_migration = true;
|
|
5831
|
+
return batch;
|
|
5832
|
+
}
|
|
5833
|
+
|
|
5834
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/sender.mjs
|
|
5835
|
+
var V1_ANALYTICS_PATH = "/i/v1/analytics/events";
|
|
5836
|
+
var DEFAULT_MAX_BACKOFF_MS = 30000;
|
|
5837
|
+
var RETRYABLE_STATUSES = new Set([
|
|
5838
|
+
408,
|
|
5839
|
+
500,
|
|
5840
|
+
502,
|
|
5841
|
+
503,
|
|
5842
|
+
504
|
|
5843
|
+
]);
|
|
5844
|
+
|
|
5845
|
+
class V1CaptureSender {
|
|
5846
|
+
constructor(config, hooks) {
|
|
5847
|
+
this.config = config;
|
|
5848
|
+
this.maxBackoffMs = config.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
5849
|
+
this.fetchFn = hooks.fetch;
|
|
5850
|
+
this.onError = hooks.onError;
|
|
5851
|
+
this.now = hooks.now ?? Date.now;
|
|
5852
|
+
this.sleep = hooks.sleep ?? ((ms) => new Promise((resolve) => safeSetTimeout(resolve, ms)));
|
|
5853
|
+
this.generateRequestId = hooks.generateRequestId ?? uuidv7;
|
|
5854
|
+
this.compress = hooks.compress ?? gzipCompress;
|
|
5855
|
+
}
|
|
5856
|
+
async sendV1Batch(messages) {
|
|
5857
|
+
if (messages.length === 0)
|
|
5858
|
+
return;
|
|
5859
|
+
const requestId = this.generateRequestId();
|
|
5860
|
+
const createdAt = new Date(this.now()).toISOString();
|
|
5861
|
+
const { batch } = buildV1Batch(messages, {
|
|
5862
|
+
createdAt,
|
|
5863
|
+
historicalMigration: this.config.historicalMigration
|
|
5864
|
+
});
|
|
5865
|
+
const url = `${this.config.host}${V1_ANALYTICS_PATH}`;
|
|
5866
|
+
const drops = [];
|
|
5867
|
+
let pending = batch;
|
|
5868
|
+
const maxAttempts = Math.max(1, this.config.maxAttempts);
|
|
5869
|
+
for (let attempt = 1;attempt <= maxAttempts; attempt++) {
|
|
5870
|
+
const isLastAttempt = attempt === maxAttempts;
|
|
5871
|
+
const payload = safeJsonStringify({
|
|
5872
|
+
created_at: createdAt,
|
|
5873
|
+
...this.config.historicalMigration ? {
|
|
5874
|
+
historical_migration: true
|
|
5875
|
+
} : {},
|
|
5876
|
+
batch: pending
|
|
5877
|
+
});
|
|
5878
|
+
let captureAttempt;
|
|
5879
|
+
let retryDelayMs;
|
|
5880
|
+
try {
|
|
5881
|
+
captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
|
|
5882
|
+
const { response, signal } = captureAttempt;
|
|
5883
|
+
const { status } = response;
|
|
5884
|
+
if (status < 200 || status >= 300)
|
|
5885
|
+
if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
5886
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
5887
|
+
await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(() => {});
|
|
5888
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
5889
|
+
} else {
|
|
5890
|
+
const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
|
|
5891
|
+
return this.surfaceBatchFailure(requestId, drops, pending, httpError);
|
|
5892
|
+
}
|
|
5893
|
+
else {
|
|
5894
|
+
let parsed;
|
|
5895
|
+
try {
|
|
5896
|
+
parsed = await captureAttempt.waitFor(this.parseResponse(response));
|
|
5897
|
+
} catch (error) {
|
|
5898
|
+
if (signal.aborted)
|
|
5899
|
+
throw error;
|
|
5900
|
+
return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
|
|
5901
|
+
}
|
|
5902
|
+
const retryable = this.classify(pending, parsed, drops);
|
|
5903
|
+
if (retryable.length === 0)
|
|
5904
|
+
return this.surfacePartialDrops(requestId, drops);
|
|
5905
|
+
if (isLastAttempt)
|
|
5906
|
+
return void this.onError(new CaptureV1Error({
|
|
5907
|
+
requestId,
|
|
5908
|
+
drops,
|
|
5909
|
+
retryExhausted: retryable.map((event) => event.uuid)
|
|
5910
|
+
}));
|
|
5911
|
+
pending = retryable;
|
|
5912
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
5913
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
5914
|
+
}
|
|
5915
|
+
} catch (transportError) {
|
|
5916
|
+
if (captureAttempt && !captureAttempt.signal.aborted)
|
|
5917
|
+
throw transportError;
|
|
5918
|
+
if (isLastAttempt)
|
|
5919
|
+
return this.surfaceBatchFailure(requestId, drops, pending, transportError);
|
|
5920
|
+
retryDelayMs = this.backoffDelay(attempt);
|
|
5921
|
+
} finally {
|
|
5922
|
+
captureAttempt?.cleanup();
|
|
5923
|
+
}
|
|
5924
|
+
if (retryDelayMs !== undefined)
|
|
5925
|
+
await this.sleep(retryDelayMs);
|
|
5926
|
+
}
|
|
5927
|
+
}
|
|
5928
|
+
async sendOnce(url, payload, attempt, requestId) {
|
|
5929
|
+
const headers = this.buildHeaders(attempt, requestId);
|
|
5930
|
+
let body = payload;
|
|
5931
|
+
if (this.config.compressionEnabled) {
|
|
5932
|
+
const compressed = await this.compress(payload, this.config.isDebug);
|
|
5933
|
+
if (compressed !== null) {
|
|
5934
|
+
body = compressed;
|
|
5935
|
+
headers["Content-Encoding"] = "gzip";
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5938
|
+
const controller = new AbortController;
|
|
5939
|
+
let timeoutPhase = "waiting for response headers";
|
|
5940
|
+
let timer;
|
|
5941
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
5942
|
+
timer = safeSetTimeout(() => {
|
|
5943
|
+
const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
|
|
5944
|
+
timeoutError.name = "AbortError";
|
|
5945
|
+
reject(timeoutError);
|
|
5946
|
+
controller.abort(timeoutError);
|
|
5947
|
+
}, this.config.requestTimeoutMs);
|
|
5948
|
+
});
|
|
5949
|
+
try {
|
|
5950
|
+
const fetchPromise = this.fetchFn(url, {
|
|
5951
|
+
method: "POST",
|
|
5952
|
+
headers,
|
|
5953
|
+
body,
|
|
5954
|
+
signal: controller.signal
|
|
5955
|
+
});
|
|
5956
|
+
let responseAccepted = false;
|
|
5957
|
+
fetchPromise.then((lateResponse) => {
|
|
5958
|
+
if (controller.signal.aborted && !responseAccepted)
|
|
5959
|
+
this.cancelBody(lateResponse);
|
|
5960
|
+
}).catch(() => {});
|
|
5961
|
+
const response = await Promise.race([
|
|
5962
|
+
fetchPromise,
|
|
5963
|
+
deadline
|
|
5964
|
+
]);
|
|
5965
|
+
responseAccepted = true;
|
|
5966
|
+
timeoutPhase = "while reading the response body";
|
|
5967
|
+
let cleanedUp = false;
|
|
5968
|
+
let cancellation;
|
|
5969
|
+
const cancelBody = () => cancellation ??= this.cancelBody(response);
|
|
5970
|
+
return {
|
|
5971
|
+
response,
|
|
5972
|
+
signal: controller.signal,
|
|
5973
|
+
waitFor: (operation) => Promise.race([
|
|
5974
|
+
operation,
|
|
5975
|
+
deadline
|
|
5976
|
+
]),
|
|
5977
|
+
cancelBody,
|
|
5978
|
+
cleanup: () => {
|
|
5979
|
+
if (cleanedUp)
|
|
5980
|
+
return;
|
|
5981
|
+
cleanedUp = true;
|
|
5982
|
+
clearTimeout(timer);
|
|
5983
|
+
if (controller.signal.aborted)
|
|
5984
|
+
cancelBody();
|
|
5985
|
+
}
|
|
5986
|
+
};
|
|
5987
|
+
} catch (error) {
|
|
5988
|
+
clearTimeout(timer);
|
|
5989
|
+
throw error;
|
|
5990
|
+
}
|
|
5991
|
+
}
|
|
5992
|
+
buildHeaders(attempt, requestId) {
|
|
5993
|
+
const sdkInfo = `${this.config.libraryId}/${this.config.libraryVersion}`;
|
|
5994
|
+
const headers = {
|
|
5995
|
+
"Content-Type": "application/json",
|
|
5996
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
5997
|
+
"PostHog-Sdk-Info": sdkInfo,
|
|
5998
|
+
"PostHog-Attempt": String(attempt),
|
|
5999
|
+
"PostHog-Request-Id": requestId,
|
|
6000
|
+
"PostHog-Request-Timestamp": new Date(this.now()).toISOString()
|
|
6001
|
+
};
|
|
6002
|
+
if (this.config.userAgent)
|
|
6003
|
+
headers["User-Agent"] = this.config.userAgent;
|
|
6004
|
+
return headers;
|
|
6005
|
+
}
|
|
6006
|
+
classify(pending, parsed, drops) {
|
|
6007
|
+
const results = parsed.results ?? {};
|
|
6008
|
+
const retryable = [];
|
|
6009
|
+
for (const event of pending) {
|
|
6010
|
+
const result = results[event.uuid];
|
|
6011
|
+
if (result) {
|
|
6012
|
+
if (result.result === "drop")
|
|
6013
|
+
drops.push({
|
|
6014
|
+
uuid: event.uuid,
|
|
6015
|
+
details: result.details ?? undefined
|
|
6016
|
+
});
|
|
6017
|
+
else if (result.result === "retry")
|
|
6018
|
+
retryable.push(event);
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
return retryable;
|
|
6022
|
+
}
|
|
6023
|
+
backoffDelay(attempt, retryAfterMs) {
|
|
6024
|
+
const exponential = Math.min(this.config.initialRetryDelayMs * 2 ** (attempt - 1), this.maxBackoffMs);
|
|
6025
|
+
if (retryAfterMs === undefined)
|
|
6026
|
+
return exponential;
|
|
6027
|
+
return Math.max(exponential, Math.min(retryAfterMs, this.maxBackoffMs));
|
|
6028
|
+
}
|
|
6029
|
+
parseRetryAfter(response) {
|
|
6030
|
+
const raw = response.headers?.get("Retry-After");
|
|
6031
|
+
if (!raw)
|
|
6032
|
+
return;
|
|
6033
|
+
const trimmed = raw.trim();
|
|
6034
|
+
if (/^\d+$/.test(trimmed)) {
|
|
6035
|
+
const seconds = parseInt(trimmed, 10);
|
|
6036
|
+
return Number.isFinite(seconds) && seconds > 0 ? 1000 * seconds : undefined;
|
|
6037
|
+
}
|
|
6038
|
+
const dateMs = Date.parse(trimmed);
|
|
6039
|
+
if (Number.isNaN(dateMs))
|
|
6040
|
+
return;
|
|
6041
|
+
const delta = dateMs - this.now();
|
|
6042
|
+
return delta > 0 ? delta : undefined;
|
|
6043
|
+
}
|
|
6044
|
+
async parseResponse(response) {
|
|
6045
|
+
const text = await response.text();
|
|
6046
|
+
const parsed = JSON.parse(text);
|
|
6047
|
+
if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
|
|
6048
|
+
throw new Error("unexpected response shape");
|
|
6049
|
+
const results = parsed.results;
|
|
6050
|
+
if (results !== undefined && (typeof results != "object" || results === null || Array.isArray(results)))
|
|
6051
|
+
throw new Error("unexpected results shape");
|
|
6052
|
+
return {
|
|
6053
|
+
results: results ?? {}
|
|
6054
|
+
};
|
|
6055
|
+
}
|
|
6056
|
+
async buildHttpError(response, status, waitFor) {
|
|
6057
|
+
let bodyText = "";
|
|
6058
|
+
try {
|
|
6059
|
+
bodyText = (await waitFor(response.text())).slice(0, 512);
|
|
6060
|
+
} catch {}
|
|
6061
|
+
const suffix = bodyText ? `: ${bodyText}` : "";
|
|
6062
|
+
return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
|
|
6063
|
+
}
|
|
6064
|
+
surfaceBatchFailure(requestId, drops, pending, cause) {
|
|
6065
|
+
this.onError(new CaptureV1Error({
|
|
6066
|
+
requestId,
|
|
6067
|
+
drops,
|
|
6068
|
+
retryExhausted: pending.map((event) => event.uuid),
|
|
6069
|
+
cause
|
|
6070
|
+
}));
|
|
6071
|
+
}
|
|
6072
|
+
surfacePartialDrops(requestId, drops) {
|
|
6073
|
+
if (drops.length > 0)
|
|
6074
|
+
this.onError(new CaptureV1Error({
|
|
6075
|
+
requestId,
|
|
6076
|
+
drops,
|
|
6077
|
+
retryExhausted: []
|
|
6078
|
+
}));
|
|
6079
|
+
}
|
|
6080
|
+
async cancelBody(response) {
|
|
6081
|
+
try {
|
|
6082
|
+
await response.body?.cancel();
|
|
6083
|
+
} catch {}
|
|
6084
|
+
}
|
|
6085
|
+
}
|
|
6086
|
+
|
|
6087
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/routing.mjs
|
|
6088
|
+
var AI_CAPTURE_ROUTE = "ai-capture";
|
|
6089
|
+
var AI_CAPTURE_ENDPOINT_PATH = "/i/v0/ai/batch/";
|
|
6090
|
+
var AI_MAX_EVENT_BYTES = 8388608;
|
|
6091
|
+
var AI_BATCH_TARGET_BYTES = 5242880;
|
|
6092
|
+
|
|
6093
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/batching.mjs
|
|
6094
|
+
var encoder = new TextEncoder;
|
|
6095
|
+
function eventByteSize(message) {
|
|
6096
|
+
return encoder.encode(safeJsonStringify(message)).length;
|
|
6097
|
+
}
|
|
6098
|
+
function partitionAiBatch(messages, maxEventBytes = AI_MAX_EVENT_BYTES, targetBatchBytes = AI_BATCH_TARGET_BYTES) {
|
|
6099
|
+
const batches = [];
|
|
6100
|
+
const dropped = [];
|
|
6101
|
+
let current = [];
|
|
6102
|
+
let currentBytes = 0;
|
|
6103
|
+
for (const message of messages) {
|
|
6104
|
+
if (message === undefined)
|
|
6105
|
+
continue;
|
|
6106
|
+
const bytes = eventByteSize(message);
|
|
6107
|
+
if (bytes > maxEventBytes) {
|
|
6108
|
+
dropped.push({
|
|
6109
|
+
event: typeof message.event == "string" ? message.event : "unknown",
|
|
6110
|
+
bytes
|
|
6111
|
+
});
|
|
6112
|
+
continue;
|
|
6113
|
+
}
|
|
6114
|
+
if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
|
|
6115
|
+
batches.push(current);
|
|
6116
|
+
current = [];
|
|
6117
|
+
currentBytes = 0;
|
|
6118
|
+
}
|
|
6119
|
+
current.push(message);
|
|
6120
|
+
currentBytes += bytes;
|
|
6121
|
+
}
|
|
6122
|
+
if (current.length > 0)
|
|
6123
|
+
batches.push(current);
|
|
6124
|
+
return {
|
|
6125
|
+
batches,
|
|
6126
|
+
dropped
|
|
6127
|
+
};
|
|
6128
|
+
}
|
|
6129
|
+
|
|
6130
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/client.mjs
|
|
4396
6131
|
var MINIMUM_POLLING_INTERVAL = 100;
|
|
4397
6132
|
var THIRTY_SECONDS = 30000;
|
|
4398
6133
|
var MAX_CACHE_SIZE = 50000;
|
|
@@ -4417,6 +6152,12 @@ function normalizeHost(value) {
|
|
|
4417
6152
|
const normalizedValue = typeof value == "string" ? value.trim() : "";
|
|
4418
6153
|
return normalizedValue || DEFAULT_NODE_HOST;
|
|
4419
6154
|
}
|
|
6155
|
+
function normalizeUnsetPersonProperties(value) {
|
|
6156
|
+
const propertyNames = Array.isArray(value) ? value : [
|
|
6157
|
+
value
|
|
6158
|
+
];
|
|
6159
|
+
return propertyNames.filter((propertyName) => typeof propertyName == "string" && propertyName.trim().length > 0);
|
|
6160
|
+
}
|
|
4420
6161
|
function buildFlagEventProperties(flagValues) {
|
|
4421
6162
|
if (!flagValues)
|
|
4422
6163
|
return {};
|
|
@@ -4434,11 +6175,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4434
6175
|
const normalizedApiKey = normalizeApiKey(apiKey);
|
|
4435
6176
|
const normalizedOptions = {
|
|
4436
6177
|
...options,
|
|
6178
|
+
maxQueueSize: options.maxQueueSize ?? 1e4,
|
|
6179
|
+
flushInterval: options.flushInterval ?? 5000,
|
|
4437
6180
|
host: normalizeHost(options.host),
|
|
4438
|
-
personalApiKey: normalizePersonalApiKey(options.personalApiKey)
|
|
6181
|
+
personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
|
|
4439
6182
|
};
|
|
4440
|
-
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage;
|
|
6183
|
+
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage, this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
|
|
4441
6184
|
this.options = normalizedOptions;
|
|
6185
|
+
this.captureMode = resolveCaptureMode();
|
|
6186
|
+
this.enableFullAiCapture = normalizedOptions.enableFullAiCapture === true;
|
|
4442
6187
|
this.context = this.initializeContext();
|
|
4443
6188
|
this.options.featureFlagsPollingInterval = typeof normalizedOptions.featureFlagsPollingInterval == "number" ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
4444
6189
|
if (typeof normalizedOptions.waitUntilDebounceMs == "number")
|
|
@@ -4463,21 +6208,24 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4463
6208
|
onLoad: (count) => {
|
|
4464
6209
|
this._events.emit("localEvaluationFlagsLoaded", count);
|
|
4465
6210
|
},
|
|
6211
|
+
onMinimalFlagCalledEvents: (enabled) => {
|
|
6212
|
+
this._minimalFlagCalledEvents = enabled;
|
|
6213
|
+
},
|
|
4466
6214
|
customHeaders: this.getCustomHeaders(),
|
|
4467
6215
|
cacheProvider: normalizedOptions.flagDefinitionCacheProvider,
|
|
4468
6216
|
strictLocalEvaluation: normalizedOptions.strictLocalEvaluation
|
|
4469
6217
|
});
|
|
4470
6218
|
}
|
|
4471
|
-
this.errorTracking = new
|
|
6219
|
+
this.errorTracking = new error_tracking_ErrorTracking(this, normalizedOptions, this._logger);
|
|
4472
6220
|
this.distinctIdHasSentFlagCalls = {};
|
|
4473
6221
|
this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
|
|
4474
6222
|
}
|
|
4475
|
-
enqueue(type, message, options) {
|
|
4476
|
-
super.enqueue(type, message, options);
|
|
6223
|
+
enqueue(type, message, options, explicitRoute) {
|
|
6224
|
+
super.enqueue(type, message, options, explicitRoute);
|
|
4477
6225
|
this.scheduleDebouncedFlush();
|
|
4478
6226
|
}
|
|
4479
6227
|
async flush() {
|
|
4480
|
-
const flushPromise =
|
|
6228
|
+
const flushPromise = this.flushWithPendingPromises();
|
|
4481
6229
|
const waitUntil = this.options.waitUntil;
|
|
4482
6230
|
if (waitUntil && !this._waitUntilCycle)
|
|
4483
6231
|
try {
|
|
@@ -4530,7 +6278,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4530
6278
|
async resolveWaitUntilFlush() {
|
|
4531
6279
|
const resolve = this._consumeWaitUntilCycle();
|
|
4532
6280
|
try {
|
|
4533
|
-
await
|
|
6281
|
+
await this.flushWithPendingPromises();
|
|
4534
6282
|
} catch {} finally {
|
|
4535
6283
|
resolve?.();
|
|
4536
6284
|
}
|
|
@@ -4544,12 +6292,103 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4544
6292
|
fetch(url, options) {
|
|
4545
6293
|
return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
|
|
4546
6294
|
}
|
|
6295
|
+
getQueueRouteKey(message) {
|
|
6296
|
+
return this.captureMode === "v1" && isLegacyOnlyEvent(message) ? AI_ROUTE : ANALYTICS_ROUTE;
|
|
6297
|
+
}
|
|
6298
|
+
persistedQueueKeyForRoute(route) {
|
|
6299
|
+
if (route === AI_CAPTURE_ROUTE)
|
|
6300
|
+
return types_PostHogPersistedProperty.AiCaptureQueue;
|
|
6301
|
+
return route === AI_ROUTE ? types_PostHogPersistedProperty.AiQueue : types_PostHogPersistedProperty.Queue;
|
|
6302
|
+
}
|
|
6303
|
+
getActiveQueueRoutes() {
|
|
6304
|
+
const routes = this.captureMode === "v1" ? [
|
|
6305
|
+
ANALYTICS_ROUTE,
|
|
6306
|
+
AI_ROUTE
|
|
6307
|
+
] : [
|
|
6308
|
+
ANALYTICS_ROUTE
|
|
6309
|
+
];
|
|
6310
|
+
if (this._aiCaptureRouteActive)
|
|
6311
|
+
routes.push(AI_CAPTURE_ROUTE);
|
|
6312
|
+
return routes;
|
|
6313
|
+
}
|
|
6314
|
+
getBatchEndpointPath(route) {
|
|
6315
|
+
return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
|
|
6316
|
+
}
|
|
6317
|
+
async sendBatch(batchMessages, retryOptions, route = ANALYTICS_ROUTE) {
|
|
6318
|
+
if (route === AI_CAPTURE_ROUTE)
|
|
6319
|
+
return this.sendAiCaptureBatch(batchMessages, retryOptions);
|
|
6320
|
+
if (this.captureMode !== "v1" || route === AI_ROUTE)
|
|
6321
|
+
return super.sendBatch(batchMessages, retryOptions, route);
|
|
6322
|
+
const v1Events = batchMessages.filter((message) => message !== undefined);
|
|
6323
|
+
await this.getV1Sender().sendV1Batch(v1Events);
|
|
6324
|
+
}
|
|
6325
|
+
async sendAiCaptureBatch(batchMessages, retryOptions) {
|
|
6326
|
+
const { batches, dropped } = partitionAiBatch(batchMessages);
|
|
6327
|
+
for (const { event, bytes } of dropped) {
|
|
6328
|
+
const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
|
|
6329
|
+
this._logger.error(message);
|
|
6330
|
+
this._events.emit("error", new Error(message));
|
|
6331
|
+
}
|
|
6332
|
+
for (const batch of batches)
|
|
6333
|
+
await this.sendAiSubBatch(batch, retryOptions);
|
|
6334
|
+
}
|
|
6335
|
+
async sendAiSubBatch(batch, retryOptions) {
|
|
6336
|
+
try {
|
|
6337
|
+
await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE);
|
|
6338
|
+
} catch (err) {
|
|
6339
|
+
if (!isPostHogFetchContentTooLargeError(err))
|
|
6340
|
+
throw err;
|
|
6341
|
+
if (batch.length === 1) {
|
|
6342
|
+
const [event] = batch;
|
|
6343
|
+
const eventName = typeof event.event == "string" ? event.event : "unknown";
|
|
6344
|
+
const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
|
|
6345
|
+
this._logger.error(message);
|
|
6346
|
+
this._events.emit("error", new Error(message));
|
|
6347
|
+
return;
|
|
6348
|
+
}
|
|
6349
|
+
const mid = Math.ceil(batch.length / 2);
|
|
6350
|
+
await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
|
|
6351
|
+
await this.sendAiSubBatch(batch.slice(mid), retryOptions);
|
|
6352
|
+
}
|
|
6353
|
+
}
|
|
6354
|
+
getV1Sender() {
|
|
6355
|
+
if (!this._v1Sender)
|
|
6356
|
+
this._v1Sender = new V1CaptureSender({
|
|
6357
|
+
host: this.host,
|
|
6358
|
+
apiKey: this.apiKey,
|
|
6359
|
+
libraryId: this.getLibraryId(),
|
|
6360
|
+
libraryVersion: this.getLibraryVersion(),
|
|
6361
|
+
userAgent: this.getCustomUserAgent() || undefined,
|
|
6362
|
+
historicalMigration: this.historicalMigration,
|
|
6363
|
+
compressionEnabled: !this.disableCompression,
|
|
6364
|
+
requestTimeoutMs: this.requestTimeout,
|
|
6365
|
+
maxAttempts: (this.options.fetchRetryCount ?? 3) + 1,
|
|
6366
|
+
initialRetryDelayMs: this.options.fetchRetryDelay ?? 3000,
|
|
6367
|
+
isDebug: this.isDebug
|
|
6368
|
+
}, {
|
|
6369
|
+
fetch: (url, fetchOptions) => this.fetch(url, fetchOptions),
|
|
6370
|
+
onError: (error) => this._events.emit("error", error),
|
|
6371
|
+
compress: (payload) => this.compressPayload(payload)
|
|
6372
|
+
});
|
|
6373
|
+
return this._v1Sender;
|
|
6374
|
+
}
|
|
4547
6375
|
getLibraryVersion() {
|
|
4548
6376
|
return version;
|
|
4549
6377
|
}
|
|
6378
|
+
get metrics() {
|
|
6379
|
+
if (!this._metrics)
|
|
6380
|
+
this._metrics = new PostHogMetrics(this, resolveMetricsConfig(this.options.metrics), this._logger);
|
|
6381
|
+
return this._metrics;
|
|
6382
|
+
}
|
|
4550
6383
|
getCustomUserAgent() {
|
|
4551
6384
|
return `${this.getLibraryId()}/${this.getLibraryVersion()}`;
|
|
4552
6385
|
}
|
|
6386
|
+
getCommonEventProperties() {
|
|
6387
|
+
const commonProperties = super.getCommonEventProperties();
|
|
6388
|
+
if (this.options.isServer ?? true)
|
|
6389
|
+
commonProperties.$is_server = true;
|
|
6390
|
+
return commonProperties;
|
|
6391
|
+
}
|
|
4553
6392
|
enable() {
|
|
4554
6393
|
return super.optIn();
|
|
4555
6394
|
}
|
|
@@ -4560,33 +6399,69 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4560
6399
|
super.debug(enabled);
|
|
4561
6400
|
this.featureFlagsPoller?.debug(enabled);
|
|
4562
6401
|
}
|
|
4563
|
-
|
|
6402
|
+
_warnIfInvalidCapture(props, stringArgumentWarning, exceptionCaptureWarning) {
|
|
4564
6403
|
if (typeof props == "string")
|
|
4565
|
-
this._logger.warn(
|
|
6404
|
+
this._logger.warn(stringArgumentWarning);
|
|
4566
6405
|
if (props.event === "$exception" && !props._originatedFromCaptureException)
|
|
4567
|
-
this._logger.warn(
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
6406
|
+
this._logger.warn(exceptionCaptureWarning);
|
|
6407
|
+
}
|
|
6408
|
+
_sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
|
|
6409
|
+
return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options }) => {
|
|
6410
|
+
const captureOptions = {
|
|
6411
|
+
timestamp: options.timestamp,
|
|
6412
|
+
disableGeoip: options.disableGeoip,
|
|
6413
|
+
uuid: options.uuid
|
|
6414
|
+
};
|
|
6415
|
+
const message = {
|
|
6416
|
+
distinctId,
|
|
6417
|
+
event,
|
|
6418
|
+
properties: {
|
|
6419
|
+
...properties,
|
|
6420
|
+
...this.getCommonEventProperties()
|
|
6421
|
+
}
|
|
6422
|
+
};
|
|
6423
|
+
return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
|
|
6424
|
+
}).catch((err) => {
|
|
4573
6425
|
if (err)
|
|
4574
6426
|
console.error(err);
|
|
4575
6427
|
}));
|
|
4576
6428
|
}
|
|
6429
|
+
_capturePreparedEvent(props, immediate) {
|
|
6430
|
+
return this._sendPreparedEvent("capture", props, immediate);
|
|
6431
|
+
}
|
|
6432
|
+
capture(props) {
|
|
6433
|
+
this._warnIfInvalidCapture(props, "Called capture() with a string as the first argument when an object was expected.", "Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically.");
|
|
6434
|
+
this._capturePreparedEvent(props, false);
|
|
6435
|
+
}
|
|
4577
6436
|
async captureImmediate(props) {
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
6437
|
+
this._warnIfInvalidCapture(props, "Called captureImmediate() with a string as the first argument when an object was expected.", "Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default.");
|
|
6438
|
+
return this._capturePreparedEvent(props, true);
|
|
6439
|
+
}
|
|
6440
|
+
captureAi(props) {
|
|
6441
|
+
if (this.disabled)
|
|
6442
|
+
return;
|
|
6443
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
6444
|
+
this._sendPreparedAiEvent({
|
|
6445
|
+
...props,
|
|
6446
|
+
uuid
|
|
6447
|
+
}, false);
|
|
6448
|
+
return uuid;
|
|
6449
|
+
}
|
|
6450
|
+
async captureAiImmediate(props) {
|
|
6451
|
+
if (this.disabled)
|
|
6452
|
+
return;
|
|
6453
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
6454
|
+
await this._sendPreparedAiEvent({
|
|
6455
|
+
...props,
|
|
6456
|
+
uuid
|
|
6457
|
+
}, true);
|
|
6458
|
+
return uuid;
|
|
6459
|
+
}
|
|
6460
|
+
_sendPreparedAiEvent(props, immediate) {
|
|
6461
|
+
if (typeof props?.event == "string" && !props.event.startsWith("$ai_"))
|
|
6462
|
+
this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
|
|
6463
|
+
this._aiCaptureRouteActive = true;
|
|
6464
|
+
return this._sendPreparedEvent("capture", props, immediate, undefined, AI_CAPTURE_ROUTE);
|
|
4590
6465
|
}
|
|
4591
6466
|
identify({ distinctId, properties = {}, disableGeoip }) {
|
|
4592
6467
|
const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
|
|
@@ -4597,8 +6472,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4597
6472
|
$set_once: setOnceProps,
|
|
4598
6473
|
$anon_distinct_id: $anon_distinct_id ?? undefined
|
|
4599
6474
|
};
|
|
4600
|
-
|
|
6475
|
+
this._sendPreparedEvent("identify", {
|
|
6476
|
+
distinctId,
|
|
6477
|
+
event: "$identify",
|
|
6478
|
+
properties: eventProperties,
|
|
4601
6479
|
disableGeoip
|
|
6480
|
+
}, false, {
|
|
6481
|
+
includeContextProperties: false
|
|
4602
6482
|
});
|
|
4603
6483
|
}
|
|
4604
6484
|
async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
|
|
@@ -4610,18 +6490,65 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4610
6490
|
$set_once: setOnceProps,
|
|
4611
6491
|
$anon_distinct_id: $anon_distinct_id ?? undefined
|
|
4612
6492
|
};
|
|
4613
|
-
await
|
|
6493
|
+
await this._sendPreparedEvent("identify", {
|
|
6494
|
+
distinctId,
|
|
6495
|
+
event: "$identify",
|
|
6496
|
+
properties: eventProperties,
|
|
4614
6497
|
disableGeoip
|
|
6498
|
+
}, true, {
|
|
6499
|
+
includeContextProperties: false
|
|
6500
|
+
});
|
|
6501
|
+
}
|
|
6502
|
+
setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
|
|
6503
|
+
if (Object.keys(properties).length === 0 && Object.keys(propertiesOnce).length === 0)
|
|
6504
|
+
return;
|
|
6505
|
+
const eventProperties = {};
|
|
6506
|
+
if (Object.keys(properties).length > 0)
|
|
6507
|
+
eventProperties.$set = properties;
|
|
6508
|
+
if (Object.keys(propertiesOnce).length > 0)
|
|
6509
|
+
eventProperties.$set_once = propertiesOnce;
|
|
6510
|
+
this.capture({
|
|
6511
|
+
distinctId,
|
|
6512
|
+
event: "$set",
|
|
6513
|
+
properties: eventProperties
|
|
6514
|
+
});
|
|
6515
|
+
}
|
|
6516
|
+
unsetPersonProperties({ distinctId, properties }) {
|
|
6517
|
+
const propertyNames = normalizeUnsetPersonProperties(properties);
|
|
6518
|
+
if (propertyNames.length === 0)
|
|
6519
|
+
return;
|
|
6520
|
+
this.capture({
|
|
6521
|
+
distinctId,
|
|
6522
|
+
event: "$set",
|
|
6523
|
+
properties: {
|
|
6524
|
+
$unset: propertyNames
|
|
6525
|
+
}
|
|
4615
6526
|
});
|
|
4616
6527
|
}
|
|
4617
6528
|
alias(data) {
|
|
4618
|
-
|
|
6529
|
+
this._sendPreparedEvent("alias", {
|
|
6530
|
+
distinctId: data.distinctId,
|
|
6531
|
+
event: "$create_alias",
|
|
6532
|
+
properties: {
|
|
6533
|
+
distinct_id: data.distinctId,
|
|
6534
|
+
alias: data.alias
|
|
6535
|
+
},
|
|
4619
6536
|
disableGeoip: data.disableGeoip
|
|
6537
|
+
}, false, {
|
|
6538
|
+
includeContextProperties: false
|
|
4620
6539
|
});
|
|
4621
6540
|
}
|
|
4622
6541
|
async aliasImmediate(data) {
|
|
4623
|
-
await
|
|
6542
|
+
await this._sendPreparedEvent("alias", {
|
|
6543
|
+
distinctId: data.distinctId,
|
|
6544
|
+
event: "$create_alias",
|
|
6545
|
+
properties: {
|
|
6546
|
+
distinct_id: data.distinctId,
|
|
6547
|
+
alias: data.alias
|
|
6548
|
+
},
|
|
4624
6549
|
disableGeoip: data.disableGeoip
|
|
6550
|
+
}, true, {
|
|
6551
|
+
includeContextProperties: false
|
|
4625
6552
|
});
|
|
4626
6553
|
}
|
|
4627
6554
|
isLocalEvaluationReady() {
|
|
@@ -4676,7 +6603,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4676
6603
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
|
|
4677
6604
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4678
6605
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4679
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties);
|
|
6606
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, this.personPropertiesForLocalEvaluation(distinctId, personProperties), groupProperties);
|
|
4680
6607
|
if (onlyEvaluateLocally == undefined)
|
|
4681
6608
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
4682
6609
|
let result;
|
|
@@ -4687,6 +6614,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4687
6614
|
let flagId;
|
|
4688
6615
|
let flagVersion;
|
|
4689
6616
|
let flagReason;
|
|
6617
|
+
let flagHasExperiment;
|
|
4690
6618
|
const localEvaluationEnabled = this.featureFlagsPoller !== undefined;
|
|
4691
6619
|
if (localEvaluationEnabled) {
|
|
4692
6620
|
await this.featureFlagsPoller?.loadFeatureFlags();
|
|
@@ -4701,6 +6629,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4701
6629
|
const value = localResult.value;
|
|
4702
6630
|
flagId = flag.id;
|
|
4703
6631
|
flagReason = "Evaluated locally";
|
|
6632
|
+
flagHasExperiment = flag.has_experiment;
|
|
4704
6633
|
result = {
|
|
4705
6634
|
key,
|
|
4706
6635
|
enabled: value !== false,
|
|
@@ -4716,12 +6645,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4716
6645
|
}
|
|
4717
6646
|
}
|
|
4718
6647
|
if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
|
|
4719
|
-
const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6648
|
+
const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [
|
|
4720
6649
|
key
|
|
4721
6650
|
]);
|
|
4722
6651
|
if (flagsResponse === undefined)
|
|
4723
6652
|
featureFlagError = FeatureFlagError2.UNKNOWN_ERROR;
|
|
4724
6653
|
else {
|
|
6654
|
+
this._minimalFlagCalledEvents = flagsResponse.minimalFlagCalledEvents === true;
|
|
4725
6655
|
requestId = flagsResponse.requestId;
|
|
4726
6656
|
evaluatedAt = flagsResponse.evaluatedAt;
|
|
4727
6657
|
const errors = [];
|
|
@@ -4736,6 +6666,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4736
6666
|
flagId = flagDetail.metadata?.id;
|
|
4737
6667
|
flagVersion = flagDetail.metadata?.version;
|
|
4738
6668
|
flagReason = flagDetail.reason?.description ?? flagDetail.reason?.code;
|
|
6669
|
+
flagHasExperiment = flagDetail.metadata?.has_experiment;
|
|
4739
6670
|
let parsedPayload;
|
|
4740
6671
|
if (flagDetail.metadata?.payload !== undefined)
|
|
4741
6672
|
try {
|
|
@@ -4746,7 +6677,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4746
6677
|
result = {
|
|
4747
6678
|
key,
|
|
4748
6679
|
enabled: flagDetail.enabled,
|
|
4749
|
-
variant: flagDetail.variant,
|
|
6680
|
+
variant: flagDetail.variant ?? undefined,
|
|
4750
6681
|
payload: parsedPayload
|
|
4751
6682
|
};
|
|
4752
6683
|
}
|
|
@@ -4767,6 +6698,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4767
6698
|
$feature_flag_request_id: requestId,
|
|
4768
6699
|
$feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt
|
|
4769
6700
|
};
|
|
6701
|
+
if (flagHasExperiment !== undefined)
|
|
6702
|
+
properties.$feature_flag_has_experiment = flagHasExperiment;
|
|
4770
6703
|
if (flagWasLocallyEvaluated && this.featureFlagsPoller) {
|
|
4771
6704
|
const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt();
|
|
4772
6705
|
if (flagDefinitionsLoadedAt !== undefined)
|
|
@@ -4881,7 +6814,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4881
6814
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
4882
6815
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4883
6816
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4884
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
6817
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
|
|
4885
6818
|
if (onlyEvaluateLocally == undefined)
|
|
4886
6819
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
4887
6820
|
const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys);
|
|
@@ -4894,7 +6827,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4894
6827
|
fallbackToFlags = localEvaluationResult.fallbackToFlags;
|
|
4895
6828
|
}
|
|
4896
6829
|
if (fallbackToFlags && !onlyEvaluateLocally) {
|
|
4897
|
-
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6830
|
+
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
|
|
4898
6831
|
featureFlags = {
|
|
4899
6832
|
...featureFlags,
|
|
4900
6833
|
...remoteEvaluationResult.flags || {}
|
|
@@ -4942,9 +6875,10 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4942
6875
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
4943
6876
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4944
6877
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4945
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
6878
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
|
|
4946
6879
|
if (onlyEvaluateLocally == undefined)
|
|
4947
6880
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
6881
|
+
const requestedFlagKeys = flagKeys ? new Set(flagKeys) : undefined;
|
|
4948
6882
|
const records = {};
|
|
4949
6883
|
let requestId;
|
|
4950
6884
|
let evaluatedAt;
|
|
@@ -4963,14 +6897,17 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4963
6897
|
id: flagDef?.id,
|
|
4964
6898
|
version: undefined,
|
|
4965
6899
|
reason: "Evaluated locally",
|
|
4966
|
-
locallyEvaluated: true
|
|
6900
|
+
locallyEvaluated: true,
|
|
6901
|
+
hasExperiment: flagDef?.has_experiment
|
|
4967
6902
|
};
|
|
4968
6903
|
locallyEvaluatedKeys.add(key);
|
|
4969
6904
|
}
|
|
4970
|
-
const
|
|
6905
|
+
const requestedFlagMissingLocally = requestedFlagKeys !== undefined && Array.from(requestedFlagKeys).some((key) => this.featureFlagsPoller?.featureFlagsByKey[key] === undefined);
|
|
6906
|
+
const fallbackToFlags = localResult ? localResult.fallbackToFlags || requestedFlagMissingLocally : true;
|
|
4971
6907
|
if (fallbackToFlags && !onlyEvaluateLocally) {
|
|
4972
|
-
const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6908
|
+
const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
|
|
4973
6909
|
if (details) {
|
|
6910
|
+
this._minimalFlagCalledEvents = details.minimalFlagCalledEvents === true;
|
|
4974
6911
|
requestId = details.requestId;
|
|
4975
6912
|
evaluatedAt = details.evaluatedAt;
|
|
4976
6913
|
errorsWhileComputing = Boolean(details.errorsWhileComputingFlags);
|
|
@@ -4993,7 +6930,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4993
6930
|
id: detail.metadata?.id,
|
|
4994
6931
|
version: detail.metadata?.version,
|
|
4995
6932
|
reason: detail.reason?.description ?? detail.reason?.code,
|
|
4996
|
-
locallyEvaluated: false
|
|
6933
|
+
locallyEvaluated: false,
|
|
6934
|
+
hasExperiment: detail.metadata?.has_experiment
|
|
4997
6935
|
};
|
|
4998
6936
|
}
|
|
4999
6937
|
}
|
|
@@ -5013,7 +6951,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5013
6951
|
id: existing?.id,
|
|
5014
6952
|
version: existing?.version,
|
|
5015
6953
|
reason: existing?.reason,
|
|
5016
|
-
locallyEvaluated: existing?.locallyEvaluated ?? false
|
|
6954
|
+
locallyEvaluated: existing?.locallyEvaluated ?? false,
|
|
6955
|
+
hasExperiment: existing?.hasExperiment
|
|
5017
6956
|
};
|
|
5018
6957
|
}
|
|
5019
6958
|
if (this._payloadOverrides !== undefined)
|
|
@@ -5025,6 +6964,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5025
6964
|
payload
|
|
5026
6965
|
};
|
|
5027
6966
|
}
|
|
6967
|
+
if (requestedFlagKeys !== undefined) {
|
|
6968
|
+
for (const key of Object.keys(records))
|
|
6969
|
+
if (!requestedFlagKeys.has(key))
|
|
6970
|
+
delete records[key];
|
|
6971
|
+
}
|
|
5028
6972
|
return new FeatureFlagEvaluations({
|
|
5029
6973
|
host: this._getFeatureFlagEvaluationsHost(),
|
|
5030
6974
|
distinctId: resolvedDistinctId,
|
|
@@ -5038,6 +6982,9 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5038
6982
|
quotaLimited
|
|
5039
6983
|
});
|
|
5040
6984
|
}
|
|
6985
|
+
_shouldSendMinimalFlagCalledEvent(event, properties) {
|
|
6986
|
+
return event === "$feature_flag_called" && this._minimalFlagCalledEvents && properties.$feature_flag_has_experiment === false;
|
|
6987
|
+
}
|
|
5041
6988
|
_captureFlagCalledEventIfNeeded(params) {
|
|
5042
6989
|
const { distinctId, key, response, groups, disableGeoip, properties } = params;
|
|
5043
6990
|
const groupSuffix = groups && Object.keys(groups).length > 0 ? `_${JSON.stringify(Object.entries(groups).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0))}` : "";
|
|
@@ -5072,9 +7019,32 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5072
7019
|
return this._featureFlagEvaluationsHost;
|
|
5073
7020
|
}
|
|
5074
7021
|
groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
5075
|
-
|
|
7022
|
+
this._sendPreparedEvent("capture", {
|
|
7023
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
7024
|
+
event: "$groupidentify",
|
|
7025
|
+
properties: {
|
|
7026
|
+
$group_type: groupType,
|
|
7027
|
+
$group_key: groupKey,
|
|
7028
|
+
$group_set: properties || {}
|
|
7029
|
+
},
|
|
7030
|
+
disableGeoip
|
|
7031
|
+
}, false, {
|
|
7032
|
+
includeContextProperties: false
|
|
7033
|
+
});
|
|
7034
|
+
}
|
|
7035
|
+
async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
7036
|
+
await this._sendPreparedEvent("capture", {
|
|
7037
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
7038
|
+
event: "$groupidentify",
|
|
7039
|
+
properties: {
|
|
7040
|
+
$group_type: groupType,
|
|
7041
|
+
$group_key: groupKey,
|
|
7042
|
+
$group_set: properties || {}
|
|
7043
|
+
},
|
|
5076
7044
|
disableGeoip
|
|
5077
|
-
},
|
|
7045
|
+
}, true, {
|
|
7046
|
+
includeContextProperties: false
|
|
7047
|
+
});
|
|
5078
7048
|
}
|
|
5079
7049
|
async reloadFeatureFlags() {
|
|
5080
7050
|
await this.featureFlagsPoller?.loadFeatureFlags(true);
|
|
@@ -5146,12 +7116,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5146
7116
|
this.context?.enter(data, options);
|
|
5147
7117
|
}
|
|
5148
7118
|
async _shutdown(shutdownTimeoutMs) {
|
|
7119
|
+
const shutdownDeadlineMs = Date.now() + (shutdownTimeoutMs ?? 30000);
|
|
5149
7120
|
const resolve = this._consumeWaitUntilCycle();
|
|
5150
7121
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
5151
7122
|
this.errorTracking.shutdown();
|
|
7123
|
+
if (this._metrics) {
|
|
7124
|
+
await raceWithTimeout(this._metrics.flush().catch(() => {}), Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
7125
|
+
this._metrics.reset();
|
|
7126
|
+
}
|
|
5152
7127
|
try {
|
|
5153
|
-
return await super._shutdown(
|
|
7128
|
+
return await super._shutdown(Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
5154
7129
|
} finally {
|
|
7130
|
+
this.distinctIdHasSentFlagCalls = {};
|
|
5155
7131
|
resolve?.();
|
|
5156
7132
|
}
|
|
5157
7133
|
}
|
|
@@ -5246,7 +7222,6 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5246
7222
|
}
|
|
5247
7223
|
addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties) {
|
|
5248
7224
|
const allPersonProperties = {
|
|
5249
|
-
distinct_id: distinctId,
|
|
5250
7225
|
...personProperties || {}
|
|
5251
7226
|
};
|
|
5252
7227
|
const allGroupProperties = {};
|
|
@@ -5261,6 +7236,12 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5261
7236
|
allGroupProperties
|
|
5262
7237
|
};
|
|
5263
7238
|
}
|
|
7239
|
+
personPropertiesForLocalEvaluation(distinctId, personProperties) {
|
|
7240
|
+
return {
|
|
7241
|
+
distinct_id: distinctId,
|
|
7242
|
+
...personProperties || {}
|
|
7243
|
+
};
|
|
7244
|
+
}
|
|
5264
7245
|
createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties) {
|
|
5265
7246
|
return {
|
|
5266
7247
|
distinctId,
|
|
@@ -5271,21 +7252,21 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5271
7252
|
};
|
|
5272
7253
|
}
|
|
5273
7254
|
captureException(error, distinctId, additionalProperties, uuid, flags) {
|
|
5274
|
-
if (!
|
|
7255
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
5275
7256
|
const syntheticException = new Error("PostHog syntheticException");
|
|
5276
|
-
this.addPendingPromise(
|
|
7257
|
+
this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
5277
7258
|
syntheticException
|
|
5278
|
-
}, distinctId, additionalProperties).then((msg) => this.
|
|
7259
|
+
}, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
|
|
5279
7260
|
...msg,
|
|
5280
7261
|
uuid,
|
|
5281
7262
|
flags
|
|
5282
|
-
})));
|
|
7263
|
+
}, false)));
|
|
5283
7264
|
}
|
|
5284
7265
|
}
|
|
5285
7266
|
async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
|
|
5286
|
-
if (!
|
|
7267
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
5287
7268
|
const syntheticException = new Error("PostHog syntheticException");
|
|
5288
|
-
return this.addPendingPromise(
|
|
7269
|
+
return this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
5289
7270
|
syntheticException
|
|
5290
7271
|
}, distinctId, additionalProperties).then((msg) => this.captureImmediate({
|
|
5291
7272
|
...msg,
|
|
@@ -5294,24 +7275,31 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5294
7275
|
}
|
|
5295
7276
|
}
|
|
5296
7277
|
async prepareEventMessage(props) {
|
|
7278
|
+
return this._prepareEventMessage(props);
|
|
7279
|
+
}
|
|
7280
|
+
async _prepareEventMessage(props, options = {}) {
|
|
5297
7281
|
const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
|
|
5298
7282
|
const contextData = this.context?.get();
|
|
7283
|
+
const includeContextProperties = options.includeContextProperties ?? true;
|
|
5299
7284
|
let mergedDistinctId = distinctId || contextData?.distinctId;
|
|
5300
|
-
const mergedProperties = {
|
|
7285
|
+
const mergedProperties = includeContextProperties ? {
|
|
5301
7286
|
...this.props,
|
|
5302
7287
|
...contextData?.properties || {},
|
|
5303
7288
|
...properties || {}
|
|
7289
|
+
} : {
|
|
7290
|
+
...properties || {}
|
|
5304
7291
|
};
|
|
5305
7292
|
if (!mergedDistinctId) {
|
|
5306
7293
|
mergedDistinctId = uuidv7();
|
|
5307
7294
|
mergedProperties.$process_person_profile = false;
|
|
5308
7295
|
}
|
|
5309
|
-
if (contextData?.sessionId && !mergedProperties.$session_id)
|
|
7296
|
+
if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id)
|
|
5310
7297
|
mergedProperties.$session_id = contextData.sessionId;
|
|
7298
|
+
const finalProperties = this._shouldSendMinimalFlagCalledEvent(event, mergedProperties) ? minimizeFlagCalledEventProperties(mergedProperties) : mergedProperties;
|
|
5311
7299
|
const eventMessage = this._runBeforeSend({
|
|
5312
7300
|
distinctId: mergedDistinctId,
|
|
5313
7301
|
event,
|
|
5314
|
-
properties:
|
|
7302
|
+
properties: finalProperties,
|
|
5315
7303
|
groups,
|
|
5316
7304
|
flags,
|
|
5317
7305
|
sendFeatureFlags,
|
|
@@ -5335,12 +7323,14 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5335
7323
|
}
|
|
5336
7324
|
return {};
|
|
5337
7325
|
}).catch(() => ({})).then((additionalProperties) => {
|
|
5338
|
-
const
|
|
7326
|
+
const resolvedGroups = eventMessage.groups || groups;
|
|
7327
|
+
return {
|
|
5339
7328
|
...additionalProperties,
|
|
5340
7329
|
...eventMessage.properties || {},
|
|
5341
|
-
|
|
7330
|
+
...resolvedGroups !== undefined && Object.keys(resolvedGroups).length > 0 ? {
|
|
7331
|
+
$groups: resolvedGroups
|
|
7332
|
+
} : {}
|
|
5342
7333
|
};
|
|
5343
|
-
return props2;
|
|
5344
7334
|
});
|
|
5345
7335
|
if (eventMessage.event === "$pageview" && this.options.__preview_capture_bot_pageviews && typeof eventProperties.$raw_user_agent == "string") {
|
|
5346
7336
|
if (isBlockedUA(eventProperties.$raw_user_agent, this.options.custom_blocked_useragents || [])) {
|
|
@@ -5367,22 +7357,26 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5367
7357
|
beforeSend
|
|
5368
7358
|
];
|
|
5369
7359
|
let result = eventMessage;
|
|
5370
|
-
for (const fn of fns)
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
7360
|
+
for (const fn of fns)
|
|
7361
|
+
try {
|
|
7362
|
+
result = fn(result);
|
|
7363
|
+
if (!result) {
|
|
7364
|
+
this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
|
|
7365
|
+
return null;
|
|
7366
|
+
}
|
|
7367
|
+
if (!result.properties || Object.keys(result.properties).length === 0) {
|
|
7368
|
+
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
7369
|
+
this._logger.warn(message);
|
|
7370
|
+
}
|
|
7371
|
+
} catch (error) {
|
|
7372
|
+
this._logger.error(`Error in before_send function for event '${eventMessage.event}':`, error);
|
|
5374
7373
|
return null;
|
|
5375
7374
|
}
|
|
5376
|
-
if (!result.properties || Object.keys(result.properties).length === 0) {
|
|
5377
|
-
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
5378
|
-
this._logger.warn(message);
|
|
5379
|
-
}
|
|
5380
|
-
}
|
|
5381
7375
|
return result;
|
|
5382
7376
|
}
|
|
5383
7377
|
}
|
|
5384
7378
|
|
|
5385
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
7379
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/context/context.mjs
|
|
5386
7380
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5387
7381
|
|
|
5388
7382
|
class PostHogContext {
|
|
@@ -5413,7 +7407,22 @@ class PostHogContext {
|
|
|
5413
7407
|
}
|
|
5414
7408
|
}
|
|
5415
7409
|
|
|
5416
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
7410
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/gzip.node.mjs
|
|
7411
|
+
import { gzip } from "node:zlib";
|
|
7412
|
+
import { promisify } from "node:util";
|
|
7413
|
+
var gzipAsync = promisify(gzip);
|
|
7414
|
+
async function gzipCompress2(input, isDebug = true) {
|
|
7415
|
+
try {
|
|
7416
|
+
const compressed = await gzipAsync(input);
|
|
7417
|
+
return new Uint8Array(compressed);
|
|
7418
|
+
} catch (error) {
|
|
7419
|
+
if (isDebug)
|
|
7420
|
+
console.error("Failed to gzip compress data", error);
|
|
7421
|
+
return null;
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7424
|
+
|
|
7425
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
|
|
5417
7426
|
var NAME = "posthog-node";
|
|
5418
7427
|
function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
|
|
5419
7428
|
"error"
|
|
@@ -5453,6 +7462,9 @@ function createEventProcessor(_posthog, { organization, projectId, prefix, sever
|
|
|
5453
7462
|
$sentry_exception_type: exceptions[0]?.type,
|
|
5454
7463
|
$sentry_tags: event.tags
|
|
5455
7464
|
};
|
|
7465
|
+
const injectedReleaseId = exports_error_tracking.getInjectedReleaseId();
|
|
7466
|
+
if (injectedReleaseId)
|
|
7467
|
+
properties.$release_id = injectedReleaseId;
|
|
5456
7468
|
if (organization && projectId)
|
|
5457
7469
|
properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
|
|
5458
7470
|
if (sendExceptionsToPostHog)
|
|
@@ -5481,11 +7493,14 @@ class PostHogSentryIntegration {
|
|
|
5481
7493
|
};
|
|
5482
7494
|
}
|
|
5483
7495
|
}
|
|
5484
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
7496
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/entrypoints/index.node.mjs
|
|
5485
7497
|
class PostHog extends PostHogBackendClient {
|
|
5486
7498
|
getLibraryId() {
|
|
5487
7499
|
return "posthog-node";
|
|
5488
7500
|
}
|
|
7501
|
+
compressPayload(payload) {
|
|
7502
|
+
return gzipCompress2(payload, this.isDebug);
|
|
7503
|
+
}
|
|
5489
7504
|
initializeContext() {
|
|
5490
7505
|
return new PostHogContext;
|
|
5491
7506
|
}
|
|
@@ -5498,12 +7513,22 @@ class PostHog extends PostHogBackendClient {
|
|
|
5498
7513
|
new exports_error_tracking.PrimitiveCoercer
|
|
5499
7514
|
], exports_error_tracking.createStackParser("node:javascript", exports_error_tracking.nodeStackLineParser), [
|
|
5500
7515
|
createModulerModifier(),
|
|
5501
|
-
addSourceContext,
|
|
7516
|
+
(frames) => addSourceContext(frames, undefined, this._logger),
|
|
5502
7517
|
createRelativePathModifier()
|
|
5503
7518
|
]);
|
|
5504
7519
|
}
|
|
5505
7520
|
}
|
|
5506
7521
|
|
|
7522
|
+
// ../../telemetry-core/src/machine-id.ts
|
|
7523
|
+
import { createHash } from "node:crypto";
|
|
7524
|
+
import os2 from "node:os";
|
|
7525
|
+
function getDefaultTelemetryOsProvider() {
|
|
7526
|
+
return os2;
|
|
7527
|
+
}
|
|
7528
|
+
function getTelemetryDistinctId(machineIdPrefix, osProvider = getDefaultTelemetryOsProvider()) {
|
|
7529
|
+
return createHash("sha256").update(`${machineIdPrefix}${osProvider.hostname()}`).digest("hex");
|
|
7530
|
+
}
|
|
7531
|
+
|
|
5507
7532
|
// ../../telemetry-core/src/posthog-client.ts
|
|
5508
7533
|
var NO_OP_CLIENT = {
|
|
5509
7534
|
enabled: false,
|
|
@@ -5538,7 +7563,7 @@ function createDefaultPostHogTransport(apiKey, options) {
|
|
|
5538
7563
|
}
|
|
5539
7564
|
function isTelemetryClientEnabled(input) {
|
|
5540
7565
|
const env = input.env ?? process.env;
|
|
5541
|
-
return !shouldDisableTelemetry({ env, productEnvPrefix: input.product.productEnvPrefix }) &&
|
|
7566
|
+
return !shouldDisableTelemetry({ env, productEnvPrefix: input.product.productEnvPrefix }) && hasTelemetryApiKey(env, input.product.defaultApiKey);
|
|
5542
7567
|
}
|
|
5543
7568
|
function createTelemetryClient(input) {
|
|
5544
7569
|
if (!isTelemetryClientEnabled(input)) {
|
|
@@ -5604,7 +7629,8 @@ function createTransport(input) {
|
|
|
5604
7629
|
flushAt: 1,
|
|
5605
7630
|
flushInterval: 0,
|
|
5606
7631
|
host: getTelemetryHost(env, input.product.defaultHost),
|
|
5607
|
-
disableGeoip: false
|
|
7632
|
+
disableGeoip: input.product.disableGeoip ?? false,
|
|
7633
|
+
...input.product.transportOptions
|
|
5608
7634
|
});
|
|
5609
7635
|
} catch (error) {
|
|
5610
7636
|
input.diagnostics?.({
|
|
@@ -5872,12 +7898,12 @@ function parseHookInput(raw) {
|
|
|
5872
7898
|
}
|
|
5873
7899
|
}
|
|
5874
7900
|
function isCodexSessionStartInput(value) {
|
|
5875
|
-
return
|
|
7901
|
+
return isRecord3(value) && value["hook_event_name"] === "SessionStart" && typeof value["session_id"] === "string" && isStringOrNull(value["transcript_path"]) && typeof value["cwd"] === "string" && typeof value["model"] === "string" && typeof value["permission_mode"] === "string" && typeof value["source"] === "string";
|
|
5876
7902
|
}
|
|
5877
7903
|
function isStringOrNull(value) {
|
|
5878
7904
|
return typeof value === "string" || value === null;
|
|
5879
7905
|
}
|
|
5880
|
-
function
|
|
7906
|
+
function isRecord3(value) {
|
|
5881
7907
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5882
7908
|
}
|
|
5883
7909
|
function readStdin() {
|