oh-my-opencode 5.0.0-beta.8 → 5.0.0-beta.80
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 +59 -23
- package/.agents/command/remove-deadcode.md +1 -1
- package/.agents/skills/codex-qa/scripts/lsp-e2e.sh +1 -3
- package/.agents/skills/hyperplan/SKILL.md +5 -5
- package/.agents/skills/opencode-qa/scripts/lsp-e2e.sh +1 -1
- package/.agents/skills/pre-publish-review/SKILL.md +9 -12
- package/.agents/skills/publish/SKILL.md +59 -23
- package/.agents/skills/remove-deadcode/SKILL.md +1 -1
- package/.agents/skills/security-research/SKILL.md +4 -4
- 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/tech-debt-audit/SKILL.md +6 -76
- package/.opencode/command/publish.md +59 -23
- package/.opencode/skills/pre-publish-review/SKILL.md +9 -12
- package/README.ja.md +66 -61
- package/README.ko.md +67 -62
- package/README.md +108 -182
- package/README.ru.md +63 -61
- package/README.zh-cn.md +62 -61
- package/THIRD-PARTY-NOTICES.md +35 -105
- package/dist/agents/atlas/agent.d.ts +0 -1
- package/dist/agents/gpt-prompt-identity.d.ts +1 -1
- package/dist/agents/sisyphus-runtime-prompt-reconciler.d.ts +15 -4
- package/dist/agents/types.d.ts +4 -2
- package/dist/cli/config-manager/parse-opencode-config-file.d.ts +2 -1
- package/dist/cli/doctor/checks/browser-provider.d.ts +2 -0
- package/dist/cli/doctor/checks/index.d.ts +2 -0
- package/dist/cli/doctor/checks/latest-version.d.ts +11 -0
- package/dist/cli/doctor/checks/system-plugin.d.ts +4 -3
- package/dist/cli/doctor/framework/constants.d.ts +5 -0
- package/dist/cli/doctor/framework/types.d.ts +2 -0
- package/dist/cli/fallback-lane-policy.d.ts +1 -0
- package/dist/cli/index.js +50191 -58043
- 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 +51708 -59537
- package/dist/config/index.d.ts +1 -1
- package/dist/config/schema/agent-names.d.ts +0 -1
- package/dist/config/schema/background-task.d.ts +1 -0
- package/dist/config/schema/browser-automation.d.ts +0 -2
- package/dist/config/schema/commands.d.ts +1 -1
- package/dist/config/schema/hooks.d.ts +1 -2
- package/dist/config/schema/oh-my-opencode-config.d.ts +5 -12
- package/dist/config/schema/ulw-execute.d.ts +5 -0
- package/dist/config/schema.d.ts +0 -1
- package/dist/config/validate.d.ts +2 -0
- package/dist/config-migration/category-deep-split.d.ts +3 -0
- package/dist/config-migration/migration-plans.d.ts +1 -0
- package/dist/create-hooks.d.ts +3 -2
- package/dist/features/background-agent/compaction-aware-message-resolver.d.ts +1 -0
- package/dist/features/background-agent/constants.d.ts +0 -7
- package/dist/features/background-agent/error-classifier.d.ts +1 -0
- package/dist/features/background-agent/manager.d.ts +9 -1
- package/dist/features/background-agent/parent-wake-dispatched-tracker.d.ts +0 -1
- package/dist/features/background-agent/parent-wake-notifier-types.d.ts +1 -1
- package/dist/features/background-agent/parent-wake-prompt-dispatch.d.ts +1 -1
- package/dist/features/background-agent/parent-wake-session-inspector.d.ts +1 -1
- package/dist/features/background-agent/subagent-spawn-limits.d.ts +8 -0
- package/dist/features/background-agent/types.d.ts +4 -0
- package/dist/features/boulder-state/storage.d.ts +1 -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/hyperplan.d.ts +1 -1
- package/dist/features/builtin-commands/templates/refactor-sections/team-mode-addendum.d.ts +1 -1
- package/dist/features/builtin-commands/templates/remove-ai-slops.d.ts +1 -1
- 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/claude-tasks/storage.d.ts +7 -2
- package/dist/features/hook-message-injector/index.d.ts +1 -0
- package/dist/features/hook-message-injector/sdk-message-lookup.d.ts +1 -0
- package/dist/features/monitor/manager-internals.d.ts +1 -1
- package/dist/features/monitor/output-injector-types.d.ts +1 -1
- package/dist/features/opengateway-provider/index.d.ts +13 -0
- package/dist/features/task-toast-manager/manager.d.ts +0 -24
- package/dist/features/team-mode/tools/messaging-fallback-wake.d.ts +17 -0
- package/dist/features/team-mode/tools/messaging-live-delivery-recipient.d.ts +3 -0
- package/dist/features/team-mode/tools/messaging-runtime.d.ts +7 -0
- package/dist/hooks/anthropic-context-window-limit-recovery/message-storage-directory.d.ts +0 -3
- package/dist/hooks/anthropic-context-window-limit-recovery/state.d.ts +1 -0
- package/dist/hooks/anthropic-context-window-limit-recovery/storage/empty-messages.d.ts +0 -1
- package/dist/hooks/anthropic-context-window-limit-recovery/tool-result-storage.d.ts +11 -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/claude-code-hooks/session-hook-state.d.ts +1 -0
- package/dist/hooks/claude-code-hooks/stop.d.ts +2 -0
- package/dist/hooks/claude-code-hooks/todo.d.ts +0 -1
- package/dist/hooks/claude-code-hooks/transcript.d.ts +2 -0
- package/dist/hooks/comment-checker/__fixtures__/download-probe.fixture.d.ts +1 -0
- package/dist/hooks/compaction-context-injector/validated-model.d.ts +2 -0
- package/dist/hooks/fsync-skip-warning/index.d.ts +4 -0
- package/dist/hooks/hashline-edit-diff-enhancer/hook.d.ts +1 -0
- package/dist/hooks/hashline-edit-diff-enhancer/pending-captures.d.ts +13 -0
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/keyword-detector/hook.d.ts +9 -0
- package/dist/hooks/keyword-detector/ultrawork/index.d.ts +2 -0
- package/dist/hooks/keyword-detector/ultrawork/source-detector.d.ts +0 -1
- package/dist/hooks/model-fallback/hook.d.ts +1 -1
- package/dist/hooks/plan-format-validator/hook.d.ts +19 -0
- 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/hooks/unstable-agent-babysitter/task-message-analyzer.d.ts +1 -0
- package/dist/index.js +30870 -27341
- package/dist/mcp/index.d.ts +0 -4
- package/dist/mcp/types.d.ts +0 -1
- package/dist/oh-my-opencode.schema.json +25 -52
- package/dist/plugin/chat-message/types.d.ts +6 -4
- 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 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -3
- package/dist/plugin/hooks/create-transform-hooks.d.ts +2 -0
- package/dist/plugin/messages-transform.d.ts +1 -0
- package/dist/plugin/stop-continuation.d.ts +3 -0
- package/dist/plugin/system-transform.d.ts +5 -1
- package/dist/plugin-config/omo-config-chain.d.ts +1 -0
- package/dist/plugin-dispose.d.ts +3 -0
- package/dist/shared/agent-tool-restrictions.d.ts +0 -1
- package/dist/shared/compaction-agent-config-checkpoint.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/omo-process-sweep.d.ts +2 -4
- 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/ast-grep/SKILL.md +13 -1
- package/dist/skills/coding-agent-sessions/AGENTS.md +62 -0
- package/dist/skills/coding-agent-sessions/SKILL.md +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 +3 -1
- package/dist/skills/debugging/references/methodology/00-setup.md +12 -0
- package/dist/skills/debugging/references/methodology/02-investigate.md +26 -5
- 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/debugging/references/tools/playwright-cli.md +79 -161
- package/dist/skills/frontend/ATTRIBUTION.md +10 -0
- package/dist/skills/frontend/SKILL.md +7 -3
- package/dist/skills/frontend/references/design/README.md +10 -2
- package/dist/skills/frontend/references/design/_INDEX.md +1 -0
- package/dist/skills/frontend/references/design/ambience-skill.md +145 -0
- package/dist/skills/frontend/references/design/aside.md +1 -1
- package/dist/skills/frontend/references/design/clone-from-url.md +1 -1
- package/dist/skills/frontend/references/design/interaction-skill.md +2 -0
- package/dist/skills/frontend/references/design/print-paged-media.md +76 -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/frontend/scripts/perfection/lighthouse-audit.py +2 -2
- package/dist/skills/git-master/SKILL.md +1 -1
- package/dist/skills/init-deep/SKILL.md +14 -14
- package/dist/skills/lsp-setup/SKILL.md +1 -1
- package/dist/skills/programming/SKILL.md +1 -1
- package/dist/skills/refactor/SKILL.md +5 -5
- package/dist/skills/remove-ai-slops/SKILL.md +5 -5
- package/dist/skills/review-work/SKILL.md +101 -419
- package/dist/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
- package/dist/skills/ultimate-browsing/SKILL.md +32 -27
- package/dist/skills/ultimate-browsing/engine/AGENTS.md +111 -0
- package/dist/skills/ultimate-browsing/engine/templates/package.json +2 -2
- package/dist/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
- package/dist/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
- package/dist/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
- package/dist/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
- package/dist/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
- package/dist/skills/ultimate-browsing/references/insane-search/README.md +18 -5
- package/dist/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
- package/dist/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
- package/dist/skills/{start-work → ulw-execute}/SKILL.md +24 -22
- package/dist/skills/ulw-plan/SKILL.md +5 -6
- package/dist/skills/ulw-plan/references/full-workflow.md +6 -5
- package/dist/skills/ulw-plan/references/intent-unclear.md +2 -2
- package/dist/skills/ulw-plan/scripts/scaffold-plan.mjs +2 -1
- package/dist/skills/ulw-research/SKILL.md +10 -5
- package/dist/skills/visual-qa/AGENTS.md +58 -0
- package/dist/skills/visual-qa/SKILL.md +4 -3
- package/dist/skills/visual-qa/references/browser-setup.md +75 -0
- package/dist/tools/delegate-task/builtin-categories.d.ts +3 -1
- package/dist/tools/delegate-task/builtin-category-definition.d.ts +2 -1
- package/dist/tools/delegate-task/constants.d.ts +2 -2
- package/dist/tools/delegate-task/openai-categories.d.ts +10 -3
- package/dist/tools/delegate-task/sync-session-cleanup.d.ts +3 -0
- package/dist/tools/delegate-task/sync-session-poller.d.ts +1 -0
- package/dist/tools/delegate-task/tool-description.d.ts +3 -1
- package/dist/tools/delegate-task/types.d.ts +4 -0
- package/dist/tools/session-manager/directory-filter.d.ts +2 -0
- package/dist/tui.d.ts +12 -0
- package/dist/tui.js +37073 -46672
- package/package.json +44 -45
- package/packages/git-bash-mcp/dist/cli.js +6 -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 +9 -1
- package/packages/lsp-core/src/lsp/client-diagnostics-freshness.integration.test.ts +100 -28
- package/packages/lsp-core/src/lsp/client-diagnostics-pull-timeout.test.ts +64 -0
- package/packages/lsp-core/src/lsp/client-wrapper-outside-cwd.test.ts +78 -0
- package/packages/lsp-core/src/lsp/client-wrapper.test.ts +103 -6
- package/packages/lsp-core/src/lsp/client-wrapper.ts +50 -16
- package/packages/lsp-core/src/lsp/client.ts +32 -3
- package/packages/lsp-core/src/lsp/connection.ts +16 -0
- package/packages/lsp-core/src/lsp/constants.ts +6 -0
- package/packages/lsp-core/src/lsp/controlled-clock-test-support.ts +90 -0
- package/packages/lsp-core/src/lsp/errors.ts +15 -0
- package/packages/lsp-core/src/lsp/fixtures/workspace-edit-server.mjs +10 -3
- 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/json-rpc-connection.ts +11 -6
- package/packages/lsp-core/src/lsp/manager-lifecycle.test.ts +262 -0
- package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +151 -0
- package/packages/lsp-core/src/lsp/manager.ts +138 -12
- 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/timer-provider.ts +13 -0
- package/packages/lsp-core/src/lsp/transport-request-timeout.test.ts +73 -0
- package/packages/lsp-core/src/lsp/transport.ts +16 -2
- package/packages/lsp-core/src/lsp/types.ts +8 -0
- package/packages/lsp-core/src/lsp/workspace-apply-edit-test-support.ts +29 -1
- package/packages/lsp-core/src/lsp/workspace-document-state.test.ts +84 -1
- package/packages/lsp-core/src/lsp/workspace-document-state.ts +35 -11
- package/packages/lsp-core/src/lsp/workspace-markers.ts +18 -0
- package/packages/lsp-core/src/mcp.ts +3 -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/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/parameters.test.ts +51 -0
- package/packages/lsp-core/src/tools/types.ts +10 -0
- package/packages/lsp-daemon/dist/cli.js +904 -479
- package/packages/lsp-daemon/dist/client.d.ts +10 -0
- package/packages/lsp-daemon/dist/client.js +922 -493
- 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.d.ts +6 -1
- package/packages/lsp-daemon/dist/ensure-daemon.js +10 -2
- package/packages/lsp-daemon/dist/index.js +826 -402
- package/packages/lsp-daemon/dist/ownership.js +2 -2
- package/packages/lsp-daemon/dist/proxy.js +3 -0
- 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 +764 -341
- package/packages/lsp-tools-mcp/dist/lsp/manager.js +274 -138
- package/packages/lsp-tools-mcp/dist/mcp.js +789 -368
- package/packages/lsp-tools-mcp/dist/request-context.js +12 -13
- package/packages/lsp-tools-mcp/dist/tools.js +719 -302
- package/packages/lsp-tools-mcp/package.json +1 -1
- package/packages/omo-codex/THIRD-PARTY-NOTICES.md +4 -21
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +4 -6
- package/packages/omo-codex/plugin/.mcp.json +0 -6
- package/packages/omo-codex/plugin/AGENTS.md +47 -0
- package/packages/omo-codex/plugin/README.md +6 -2
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +7175 -408
- 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/bootstrap/src/setup.ts +7 -1
- 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/dist/cli.js +1 -1
- package/packages/omo-codex/plugin/components/git-bash/dist/codex-hook.js +2 -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/git-bash/src/codex-hook.ts +2 -1
- package/packages/omo-codex/plugin/components/git-bash/test/codex-hook.test.ts +6 -7
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/AGENTS.md +2 -2
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/biome.json +2 -2
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/directive.md +2 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/cli.js +36 -29
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/codex-hook.js +32 -26
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/dist/types.d.ts +3 -0
- 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 +32 -28
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/src/types.ts +3 -0
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/cli.test.ts +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/test/codex-hook.test.ts +137 -28
- package/packages/omo-codex/plugin/components/lcx/skills/lcx-doctor/SKILL.md +4 -2
- 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 +943 -540
- 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/README.md +2 -0
- package/packages/omo-codex/plugin/components/rules/biome.json +2 -2
- package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus/gpt-6.md +123 -0
- package/packages/omo-codex/plugin/components/rules/dist/cli.js +91 -68
- 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 +15 -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 +38 -3
- 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 +29 -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 +4 -10
- 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 +2470 -701
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +2488 -720
- 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 +10 -4
- package/packages/omo-codex/plugin/components/ultrawork/README.md +2 -0
- package/packages/omo-codex/plugin/components/ultrawork/agents/explorer.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-clone-fidelity-reviewer.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-code-reviewer.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-gate-reviewer.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-qa-executor.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-high.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-low.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-medium.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/librarian.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/metis.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/momus.toml +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +4 -4
- package/packages/omo-codex/plugin/components/ultrawork/biome.json +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/dist/cli.js +500 -4
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +5 -6
- package/packages/omo-codex/plugin/components/ultrawork/scripts/sync-directive.mjs +30 -14
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +4 -5
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +5 -5
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/intent-unclear.md +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/scripts/scaffold-plan.mjs +1 -0
- package/packages/omo-codex/plugin/components/ultrawork/src/directive-content.ts +4 -0
- package/packages/omo-codex/plugin/components/ultrawork/src/directive.ts +5 -2
- 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/directive-source.test.ts +14 -8
- package/packages/omo-codex/plugin/components/ultrawork/test/package-smoke.test.ts +12 -1
- 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 +4 -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 +6 -6
- 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 +11 -11
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/dist/cli.js +16 -16
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +16 -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 +4 -4
- 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}/src/types.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 +4 -11
- package/packages/omo-codex/plugin/components/{start-work-continuation → ulw-execute-continuation}/test/codex-hook.test.ts +24 -22
- package/packages/omo-codex/plugin/components/ulw-loop/AGENTS.md +19 -0
- package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +17 -1
- package/packages/omo-codex/plugin/components/ulw-loop/README.md +12 -1
- package/packages/omo-codex/plugin/components/ulw-loop/biome.json +2 -2
- package/packages/omo-codex/plugin/components/ulw-loop/directive.md +44 -27
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.d.ts +18 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-codex-validation.js +30 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-continuation.js +10 -4
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.d.ts +2 -5
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-reconciliation.js +5 -78
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.d.ts +12 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint-template.js +114 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.d.ts +7 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +57 -46
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-arg-parser.js +2 -2
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +21 -8
- 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 +12 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.d.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-subcommands.js +40 -37
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +2191 -737
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +28 -8
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.d.ts +8 -5
- package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-snapshot.js +35 -23
- package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.d.ts +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/constants.js +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/domain-types.d.ts +25 -9
- package/packages/omo-codex/plugin/components/ulw-loop/dist/driver-objective-ack.d.ts +4 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/driver-objective-ack.js +18 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence-artifacts.d.ts +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence-artifacts.js +37 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.d.ts +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/evidence.js +24 -12
- package/packages/omo-codex/plugin/components/ulw-loop/dist/ledger.d.ts +4 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/ledger.js +39 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/paths.js +19 -4
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-commit.d.ts +19 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-commit.js +108 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.d.ts +6 -2
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-crud.js +54 -25
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.d.ts +10 -3
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-goal-factory.js +38 -31
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.d.ts +10 -7
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.js +121 -100
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-log.d.ts +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-log.js +115 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-missing-recovery.d.ts +18 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-missing-recovery.js +41 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.d.ts +7 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-aggregate.js +9 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-artifacts.d.ts +12 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-artifacts.js +104 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.d.ts +13 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-fields.js +65 -9
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate-verdicts.js +5 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.d.ts +4 -2
- package/packages/omo-codex/plugin/components/ulw-loop/dist/quality-gate.js +72 -117
- package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/review-blockers.js +25 -13
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/factory.js +157 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.d.ts +381 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/manifest.js +127 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.d.ts +130 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk/types.js +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.d.ts +3 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/sdk.js +3 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-budget-io.d.ts +5 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-budget-io.js +67 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.d.ts +7 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-guard.js +188 -59
- package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.d.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/spawn-role-guard.js +22 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/state-lock.d.ts +19 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/state-lock.js +259 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/status-next-actions.d.ts +7 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/status-next-actions.js +41 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-batch.js +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-mutations.d.ts +3 -2
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-mutations.js +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.d.ts +9 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.d.ts +3 -2
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.js +11 -11
- package/packages/omo-codex/plugin/components/ulw-loop/dist/stop-resume-hook.js +28 -23
- package/packages/omo-codex/plugin/components/ulw-loop/dist/success-criteria-input.d.ts +9 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/success-criteria-input.js +41 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.d.ts +19 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/surface.js +83 -0
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +18 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +6 -6
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +7 -2
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +33 -10
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-codex-validation.ts +52 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-continuation.ts +8 -6
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-reconciliation.ts +5 -98
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint-template.ts +134 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +59 -77
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-arg-parser.ts +10 -4
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +24 -8
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-output.ts +14 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-subcommands.ts +52 -46
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli.ts +8 -6
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +35 -7
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-snapshot.ts +51 -33
- package/packages/omo-codex/plugin/components/ulw-loop/src/codex-hook.ts +3 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/constants.ts +1 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/domain-types.ts +27 -9
- package/packages/omo-codex/plugin/components/ulw-loop/src/driver-objective-ack.ts +20 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/evidence-artifacts.ts +45 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/evidence.ts +23 -16
- package/packages/omo-codex/plugin/components/ulw-loop/src/ledger.ts +38 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/paths.ts +32 -4
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-commit.ts +132 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-crud.ts +67 -54
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-goal-factory.ts +63 -31
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-io.ts +140 -119
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-log.ts +112 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-missing-recovery.ts +61 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-aggregate.ts +11 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-artifacts.ts +123 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-fields.ts +71 -15
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate-verdicts.ts +6 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/quality-gate.ts +92 -136
- package/packages/omo-codex/plugin/components/ulw-loop/src/review-blockers.ts +38 -13
- package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/factory.ts +218 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/manifest.ts +156 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/sdk/types.ts +143 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/sdk.ts +3 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-budget-io.ts +59 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-guard.ts +196 -52
- package/packages/omo-codex/plugin/components/ulw-loop/src/spawn-role-guard.ts +22 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/state-lock.ts +257 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/status-next-actions.ts +45 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering-batch.ts +4 -4
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering-mutations.ts +5 -4
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering-types.ts +13 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering.ts +12 -10
- package/packages/omo-codex/plugin/components/ulw-loop/src/stop-resume-hook.ts +27 -22
- package/packages/omo-codex/plugin/components/ulw-loop/src/success-criteria-input.ts +56 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/surface.ts +115 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-continuation.test.ts +0 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-final.test.ts +131 -82
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint-template.test.ts +147 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/checkpoint.test.ts +16 -22
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-checkpoint-continuation.test.ts +4 -2
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-checkpoint.test.ts +31 -2
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-commands.test.ts +2 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-complete-goals.test.ts +3 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-create-goals.test.ts +35 -8
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-entrypoint.test.ts +38 -4
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-json-errors.test.ts +27 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-scope-required.test.ts +144 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-status-next-actions.test.ts +185 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-steering-batch.test.ts +8 -3
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-validation-batch.test.ts +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-instruction.test.ts +37 -2
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-goal-snapshot.test.ts +88 -11
- package/packages/omo-codex/plugin/components/ulw-loop/test/codex-hook.test.ts +0 -3
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/barrier.ts +13 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/cli-session.ts +4 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-child.ts +65 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-cli-qa.mjs +76 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-crash.ts +23 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-mutations.mjs +58 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-writer.ts +65 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/lease-clock.ts +23 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/quality-gate-builder.ts +9 -4
- package/packages/omo-codex/plugin/components/ulw-loop/test/guided-recovery.test.ts +67 -0
- 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/plan-commit-log.test.ts +252 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-commit-recovery.test.ts +190 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io-cross-process.test.ts +106 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io.test.ts +74 -25
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-log-legacy-projection.test.ts +228 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-log-newest.test.ts +72 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-aggregate-basics.test.ts +258 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-cap-and-dedupe.test.ts +22 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-fields-messages.test.ts +98 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-lazycodex-surface.test.ts +93 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-poisoning-cascades.test.ts +97 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-roles.test.ts +51 -2
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-senpi-surface.test.ts +131 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate-single-report.test.ts +241 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/quality-gate.test.ts +58 -3
- package/packages/omo-codex/plugin/components/ulw-loop/test/review-blockers.test.ts +9 -7
- package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-completed-plan.test.ts +43 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-contract.test.ts +137 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-driver-states.test.ts +174 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-dx.test.ts +219 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/sdk-session-context.test.ts +169 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-guard.test.ts +450 -7
- package/packages/omo-codex/plugin/components/ulw-loop/test/spawn-role-matrix.test.ts +113 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/state-lock.test.ts +310 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/status-next-actions-surface.test.ts +133 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/steering-batch.test.ts +12 -12
- package/packages/omo-codex/plugin/components/ulw-loop/test/steering.test.ts +12 -6
- 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/surface.test.ts +74 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/ultrawork-directive.test.ts +13 -8
- 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-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/post-tool-use-recording-spawn-admission.json +18 -0
- 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-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-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 +16 -7
- package/packages/omo-codex/plugin/package-lock.json +676 -524
- package/packages/omo-codex/plugin/package.json +2 -3
- package/packages/omo-codex/plugin/scripts/AGENTS.md +39 -0
- package/packages/omo-codex/plugin/scripts/auto-update-plan.mjs +1 -2
- package/packages/omo-codex/plugin/scripts/auto-update.mjs +0 -9
- package/packages/omo-codex/plugin/scripts/canonical-ultrawork-directive.mjs +17 -0
- package/packages/omo-codex/plugin/scripts/hook-status-message.mjs +0 -1
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/catalog.mjs +16 -7
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/multi-agent-v2-guard.mjs +8 -4
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/subagent-limit-guard.mjs +19 -90
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/toml-section-editor.mjs +1 -1
- package/packages/omo-codex/plugin/scripts/sync-skills.d.mts +4 -0
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +111 -64
- package/packages/omo-codex/plugin/shared/package.json +3 -4
- package/packages/omo-codex/plugin/shared/src/config-loader.ts +2 -102
- package/packages/omo-codex/plugin/shared/src/config-migration.ts +0 -1
- package/packages/omo-codex/plugin/shared/test/config-loader.test.ts +41 -130
- package/packages/omo-codex/plugin/skills/ast-grep/AGENTS.md +51 -0
- package/packages/omo-codex/plugin/skills/ast-grep/SKILL.md +13 -1
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/AGENTS.md +62 -0
- package/packages/omo-codex/plugin/skills/coding-agent-sessions/SKILL.md +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 +3 -1
- 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 +26 -5
- 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/debugging/references/tools/playwright-cli.md +79 -161
- package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +10 -0
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +7 -3
- package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +10 -2
- package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +1 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/ambience-skill.md +145 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/aside.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/references/design/clone-from-url.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/references/design/interaction-skill.md +2 -0
- package/packages/omo-codex/plugin/skills/frontend/references/design/print-paged-media.md +76 -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/frontend/scripts/perfection/lighthouse-audit.py +2 -2
- package/packages/omo-codex/plugin/skills/git-master/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +20 -18
- package/packages/omo-codex/plugin/skills/lcx-doctor/SKILL.md +4 -2
- package/packages/omo-codex/plugin/skills/lsp-setup/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/refactor/SKILL.md +11 -9
- package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +11 -9
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +116 -424
- package/packages/omo-codex/plugin/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
- package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +32 -27
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +111 -0
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/package.json +2 -2
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
- package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/README.md +18 -5
- package/packages/omo-codex/plugin/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
- package/packages/omo-codex/plugin/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
- package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +44 -27
- package/packages/omo-codex/plugin/skills/{start-work → ulw-execute}/SKILL.md +35 -36
- package/packages/omo-codex/plugin/skills/ulw-execute/agents/openai.yaml +2 -0
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +31 -2
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +33 -10
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +4 -5
- package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +5 -5
- package/packages/omo-codex/plugin/skills/ulw-plan/references/intent-unclear.md +2 -2
- package/packages/omo-codex/plugin/skills/ulw-plan/scripts/scaffold-plan.mjs +1 -0
- package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +16 -9
- package/packages/omo-codex/plugin/skills/visual-qa/AGENTS.md +58 -0
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +10 -7
- package/packages/omo-codex/plugin/skills/visual-qa/references/browser-setup.md +75 -0
- 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 +16 -51
- package/packages/omo-codex/plugin/test/aggregate-manifest.test.mjs +2 -3
- package/packages/omo-codex/plugin/test/aggregate-mcp.test.mjs +2 -7
- package/packages/omo-codex/plugin/test/aggregate-model-catalog.test.mjs +14 -4
- 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 +4 -29
- package/packages/omo-codex/plugin/test/bootstrap-default-role.test.mjs +66 -0
- package/packages/omo-codex/plugin/test/bootstrap-setup.test.mjs +0 -31
- package/packages/omo-codex/plugin/test/canonical-ultrawork-directive.test.mjs +53 -0
- 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 -51
- package/packages/omo-codex/plugin/test/component-hook-contract-cases.mjs +100 -2
- package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +5 -6
- package/packages/omo-codex/plugin/test/lcx-contribute-bug-fix-template.test.mjs +21 -27
- package/packages/omo-codex/plugin/test/mcp-research-servers.test.mjs +1 -3
- package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +35 -35
- package/packages/omo-codex/plugin/test/multi-agent-v2-regression.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/scaffold-plan.test.mjs +0 -36
- package/packages/omo-codex/plugin/test/subagent-limit-migration.test.mjs +107 -15
- package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +168 -0
- package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +54 -24
- package/packages/omo-codex/plugin/test/sync-skills.test.mjs +18 -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 +5 -5
- 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/check-model-catalog-parity.mjs +42 -0
- package/packages/omo-codex/scripts/install-cache-copy.test.mjs +27 -1
- package/packages/omo-codex/scripts/install-config-autonomous-features.test.mjs +1 -1
- package/packages/omo-codex/scripts/install-config-autonomous.test.mjs +2 -1
- package/packages/omo-codex/scripts/install-config-git-bash.test.mjs +0 -23
- package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +5 -5
- package/packages/omo-codex/scripts/install-config.test.mjs +15 -17
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +9832 -1445
- package/packages/omo-codex/scripts/install-generated-bundle.test.mjs +3 -4
- package/packages/omo-codex/scripts/install-git-bash-mcp-env.test.mjs +1 -25
- package/packages/omo-codex/scripts/install-lazycodex-version-stamp.test.mjs +7 -2
- package/packages/omo-codex/scripts/install-mcp-runtime.test.mjs +0 -36
- package/packages/omo-codex/scripts/install-packaged-local.test.mjs +1 -6
- package/packages/{omo-codex/plugin/components/ultrawork/skills/ultrawork/SKILL.md → prompts-core/prompts/ultrawork/codex.md} +44 -34
- package/packages/shared-skills/package.json +7 -1
- package/packages/shared-skills/skill-source-filter.d.ts +16 -0
- package/packages/shared-skills/skill-source-filter.mjs +44 -0
- package/packages/shared-skills/skills/ast-grep/AGENTS.md +51 -0
- package/packages/shared-skills/skills/ast-grep/SKILL.md +13 -1
- package/packages/shared-skills/skills/coding-agent-sessions/AGENTS.md +62 -0
- package/packages/shared-skills/skills/coding-agent-sessions/SKILL.md +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 +3 -1
- package/packages/shared-skills/skills/debugging/references/methodology/00-setup.md +12 -0
- package/packages/shared-skills/skills/debugging/references/methodology/02-investigate.md +26 -5
- 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/debugging/references/tools/playwright-cli.md +79 -161
- package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +10 -0
- package/packages/shared-skills/skills/frontend/SKILL.md +7 -3
- package/packages/shared-skills/skills/frontend/references/design/README.md +10 -2
- package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +1 -0
- package/packages/shared-skills/skills/frontend/references/design/ambience-skill.md +145 -0
- package/packages/shared-skills/skills/frontend/references/design/aside.md +1 -1
- package/packages/shared-skills/skills/frontend/references/design/clone-from-url.md +1 -1
- package/packages/shared-skills/skills/frontend/references/design/interaction-skill.md +2 -0
- package/packages/shared-skills/skills/frontend/references/design/print-paged-media.md +76 -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/frontend/scripts/perfection/lighthouse-audit.py +2 -2
- package/packages/shared-skills/skills/git-master/SKILL.md +1 -1
- package/packages/shared-skills/skills/init-deep/SKILL.md +14 -14
- package/packages/shared-skills/skills/lsp-setup/SKILL.md +1 -1
- package/packages/shared-skills/skills/programming/SKILL.md +1 -1
- package/packages/shared-skills/skills/refactor/SKILL.md +5 -5
- package/packages/shared-skills/skills/remove-ai-slops/SKILL.md +5 -5
- package/packages/shared-skills/skills/review-work/SKILL.md +101 -419
- package/packages/shared-skills/skills/ultimate-browsing/ATTRIBUTION.md +32 -86
- package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +32 -27
- package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +111 -0
- package/packages/shared-skills/skills/ultimate-browsing/engine/templates/package.json +2 -2
- package/packages/shared-skills/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +5 -2
- package/packages/shared-skills/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +8 -6
- package/packages/shared-skills/skills/ultimate-browsing/engine/tests/test_playwright_stealth.py +86 -0
- package/packages/shared-skills/skills/ultimate-browsing/engine/tests/test_playwright_templates.py +4 -7
- package/packages/shared-skills/skills/ultimate-browsing/references/chrome-stealth.md +86 -95
- package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/README.md +18 -5
- package/packages/shared-skills/skills/ultimate-browsing/references/insane-search/playwright.md +16 -13
- package/packages/shared-skills/skills/ultimate-browsing/scripts/extract_cookies.py +3 -3
- package/packages/shared-skills/skills/{start-work → ulw-execute}/SKILL.md +24 -22
- package/packages/shared-skills/skills/ulw-plan/SKILL.md +5 -6
- package/packages/shared-skills/skills/ulw-plan/references/full-workflow.md +6 -5
- package/packages/shared-skills/skills/ulw-plan/references/intent-unclear.md +2 -2
- package/packages/shared-skills/skills/ulw-plan/scripts/scaffold-plan.mjs +2 -1
- package/packages/shared-skills/skills/ulw-research/SKILL.md +10 -5
- package/packages/shared-skills/skills/visual-qa/AGENTS.md +58 -0
- package/packages/shared-skills/skills/visual-qa/SKILL.md +4 -3
- package/packages/shared-skills/skills/visual-qa/references/browser-setup.md +75 -0
- package/postinstall.mjs +2 -0
- package/script/qa/web-terminal-visual-qa.mjs +2 -0
- package/script/qa/xterm-live-terminal.mjs +18 -2
- package/.agents/skills/work-with-pr-workspace/evals/evals.json +0 -76
- package/.agents/skills/work-with-pr-workspace/iteration-1/benchmark.json +0 -138
- package/.agents/skills/work-with-pr-workspace/iteration-1/benchmark.md +0 -42
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/eval_metadata.json +0 -57
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/grading.json +0 -15
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/code-changes.md +0 -454
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/execution-plan.md +0 -136
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/pr-description.md +0 -47
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/verification-strategy.md +0 -163
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/grading.json +0 -15
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/code-changes.md +0 -615
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/execution-plan.md +0 -99
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/pr-description.md +0 -50
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/verification-strategy.md +0 -111
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/eval_metadata.json +0 -37
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/grading.json +0 -11
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/code-changes.md +0 -205
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/execution-plan.md +0 -78
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/pr-description.md +0 -42
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/verification-strategy.md +0 -87
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/grading.json +0 -11
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/code-changes.md +0 -334
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/execution-plan.md +0 -86
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/pr-description.md +0 -23
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/verification-strategy.md +0 -119
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/eval_metadata.json +0 -32
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/grading.json +0 -10
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/code-changes.md +0 -221
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/execution-plan.md +0 -104
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/pr-description.md +0 -41
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/verification-strategy.md +0 -84
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/grading.json +0 -10
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/code-changes.md +0 -342
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/execution-plan.md +0 -131
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/pr-description.md +0 -39
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/verification-strategy.md +0 -128
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/eval_metadata.json +0 -32
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/grading.json +0 -10
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/code-changes.md +0 -143
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/execution-plan.md +0 -82
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/pr-description.md +0 -51
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/verification-strategy.md +0 -69
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/grading.json +0 -10
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/code-changes.md +0 -252
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/execution-plan.md +0 -83
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/pr-description.md +0 -33
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/verification-strategy.md +0 -101
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/eval_metadata.json +0 -32
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/grading.json +0 -10
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/code-changes.md +0 -387
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/execution-plan.md +0 -112
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/pr-description.md +0 -51
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/verification-strategy.md +0 -75
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/grading.json +0 -10
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/code-changes.md +0 -529
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/execution-plan.md +0 -127
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/pr-description.md +0 -42
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/verification-strategy.md +0 -120
- package/.agents/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/timing.json +0 -1
- package/.agents/skills/work-with-pr-workspace/iteration-1/review.html +0 -1326
- package/.opencode/skills/work-with-pr-workspace/evals/evals.json +0 -76
- package/.opencode/skills/work-with-pr-workspace/iteration-1/benchmark.json +0 -138
- package/.opencode/skills/work-with-pr-workspace/iteration-1/benchmark.md +0 -42
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/eval_metadata.json +0 -57
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/grading.json +0 -15
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/code-changes.md +0 -454
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/execution-plan.md +0 -136
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/pr-description.md +0 -47
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/outputs/verification-strategy.md +0 -163
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/with_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/grading.json +0 -15
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/code-changes.md +0 -615
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/execution-plan.md +0 -99
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/pr-description.md +0 -50
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/outputs/verification-strategy.md +0 -111
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-1/without_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/eval_metadata.json +0 -37
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/grading.json +0 -11
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/code-changes.md +0 -205
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/execution-plan.md +0 -78
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/pr-description.md +0 -42
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/outputs/verification-strategy.md +0 -87
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/with_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/grading.json +0 -11
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/code-changes.md +0 -334
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/execution-plan.md +0 -86
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/pr-description.md +0 -23
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/outputs/verification-strategy.md +0 -119
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-2/without_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/eval_metadata.json +0 -32
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/grading.json +0 -10
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/code-changes.md +0 -221
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/execution-plan.md +0 -104
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/pr-description.md +0 -41
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/outputs/verification-strategy.md +0 -84
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/with_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/grading.json +0 -10
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/code-changes.md +0 -342
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/execution-plan.md +0 -131
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/pr-description.md +0 -39
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/outputs/verification-strategy.md +0 -128
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-3/without_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/eval_metadata.json +0 -32
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/grading.json +0 -10
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/code-changes.md +0 -143
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/execution-plan.md +0 -82
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/pr-description.md +0 -51
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/outputs/verification-strategy.md +0 -69
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/with_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/grading.json +0 -10
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/code-changes.md +0 -252
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/execution-plan.md +0 -83
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/pr-description.md +0 -33
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/outputs/verification-strategy.md +0 -101
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-4/without_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/eval_metadata.json +0 -32
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/grading.json +0 -10
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/code-changes.md +0 -387
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/execution-plan.md +0 -112
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/pr-description.md +0 -51
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/outputs/verification-strategy.md +0 -75
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/with_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/grading.json +0 -10
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/code-changes.md +0 -529
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/execution-plan.md +0 -127
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/pr-description.md +0 -42
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/outputs/verification-strategy.md +0 -120
- package/.opencode/skills/work-with-pr-workspace/iteration-1/eval-5/without_skill/timing.json +0 -1
- package/.opencode/skills/work-with-pr-workspace/iteration-1/review.html +0 -1326
- package/dist/config/schema/codegraph.d.ts +0 -12
- package/dist/config/schema/start-work.d.ts +0 -5
- package/dist/features/builtin-commands/templates/start-work.d.ts +0 -1
- package/dist/features/builtin-skills/index.d.ts +0 -1
- package/dist/features/builtin-skills/skill-file-loader.d.ts +0 -1
- package/dist/features/builtin-skills/skills/agent-browser-skill.d.ts +0 -1
- package/dist/features/builtin-skills/skills/agent-browser-template.d.ts +0 -1
- package/dist/features/builtin-skills/skills/debugging.d.ts +0 -1
- package/dist/features/builtin-skills/skills/dev-browser.d.ts +0 -1
- package/dist/features/builtin-skills/skills/frontend.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/commit-atomic-planning.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/commit-context-analysis.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/commit-execution-verification.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/commit-workflow.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/history-search-workflow.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/overview.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/quick-reference.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-sections/rebase-workflow.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master-skill-metadata.d.ts +0 -1
- package/dist/features/builtin-skills/skills/git-master.d.ts +0 -1
- package/dist/features/builtin-skills/skills/index.d.ts +0 -1
- package/dist/features/builtin-skills/skills/init-deep.d.ts +0 -1
- package/dist/features/builtin-skills/skills/playwright-cli.d.ts +0 -1
- package/dist/features/builtin-skills/skills/playwright-mcp-skill.d.ts +0 -1
- package/dist/features/builtin-skills/skills/playwright.d.ts +0 -1
- package/dist/features/builtin-skills/skills/remove-ai-slops.d.ts +0 -1
- package/dist/features/builtin-skills/skills/review-work.d.ts +0 -1
- package/dist/features/builtin-skills/skills/security-research.d.ts +0 -1
- package/dist/features/builtin-skills/skills/security-review.d.ts +0 -1
- package/dist/features/builtin-skills/skills/team-mode.d.ts +0 -1
- package/dist/features/builtin-skills/skills/visual-qa.d.ts +0 -1
- package/dist/features/builtin-skills/skills.d.ts +0 -1
- package/dist/features/builtin-skills/types.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/agent-loader.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/command-loader.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/discovery-core.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/discovery-paths.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/discovery.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/hook-loader.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/index.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/install-path-resolver.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/installed-plugin-database.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/loaded-plugin.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/loader.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/mcp-server-loader.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/plugin-key.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/plugin-manifest.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/plugin-path-resolver.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/plugin-settings.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/scope-filter.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/skill-loader.d.ts +0 -1
- package/dist/features/claude-code-plugin-loader/types.d.ts +0 -1
- package/dist/hooks/codegraph-bootstrap/command-runner.d.ts +0 -17
- package/dist/hooks/codegraph-bootstrap/hook.d.ts +0 -35
- package/dist/hooks/codegraph-bootstrap/index.d.ts +0 -1
- package/dist/hooks/codegraph-bootstrap/project-root.d.ts +0 -1
- package/dist/hooks/codegraph-bootstrap/status.d.ts +0 -11
- package/dist/hooks/ralph-loop/completion-promise-detector-test-input.d.ts +0 -11
- package/dist/hooks/ralph-loop/loop-session-recovery.d.ts +0 -7
- package/dist/hooks/start-work/start-work-hook.d.ts +0 -23
- package/dist/mcp/codegraph.d.ts +0 -16
- package/dist/plugin/chat-message/start-work-message.d.ts +0 -5
- package/dist/shared/prompt-async-gate/message-inspection-error.d.ts +0 -1
- package/dist/shared/prompt-async-gate/pending-tool-turn.d.ts +0 -1
- package/dist/shared/prompt-async-gate/prompt-message-state.d.ts +0 -1
- package/dist/shared/prompt-async-gate/queue.d.ts +0 -1
- package/dist/shared/prompt-async-gate/recent-dispatches.d.ts +0 -1
- package/dist/shared/prompt-async-gate/reservations.d.ts +0 -1
- package/dist/shared/prompt-async-gate/semantic-dedupe.d.ts +0 -1
- package/dist/shared/prompt-async-gate/session-idle-dispatch.d.ts +0 -1
- package/dist/shared/prompt-async-gate/timing.d.ts +0 -1
- package/dist/shared/prompt-async-gate/types.d.ts +0 -1
- 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/skills/visual-qa/references/agent-browser-setup.md +0 -45
- package/dist/tools/call-omo-agent/background-agent-executor.d.ts +0 -5
- package/dist/tools/call-omo-agent/message-storage-directory.d.ts +0 -1
- package/dist/tools/delegate-task/anthropic-categories.d.ts +0 -2
- package/dist/tools/delegate-task/model-string-parser.d.ts +0 -1
- package/packages/lsp-tools-mcp/dist/lsp/cleanup-errors.d.ts +0 -1
- package/packages/lsp-tools-mcp/dist/lsp/constants.d.ts +0 -1
- package/packages/lsp-tools-mcp/dist/lsp/language-mappings.d.ts +0 -1
- package/packages/lsp-tools-mcp/dist/lsp/process-signal-cleanup.d.ts +0 -1
- package/packages/lsp-tools-mcp/dist/missing-dependency-result.d.ts +0 -1
- package/packages/omo-codex/plugin/components/codegraph/AGENTS.md +0 -58
- package/packages/omo-codex/plugin/components/codegraph/NODE-RUNTIME-LICENSES.md +0 -2951
- package/packages/omo-codex/plugin/components/codegraph/NOTICE +0 -16
- package/packages/omo-codex/plugin/components/codegraph/dist/cli.js +0 -12244
- package/packages/omo-codex/plugin/components/codegraph/dist/serve.js +0 -9842
- package/packages/omo-codex/plugin/components/codegraph/package.json +0 -33
- package/packages/omo-codex/plugin/components/codegraph/src/cache-gc.ts +0 -29
- package/packages/omo-codex/plugin/components/codegraph/src/cli.ts +0 -79
- package/packages/omo-codex/plugin/components/codegraph/src/hook-input.ts +0 -33
- package/packages/omo-codex/plugin/components/codegraph/src/hook-sweep.ts +0 -25
- package/packages/omo-codex/plugin/components/codegraph/src/hook-types.ts +0 -131
- package/packages/omo-codex/plugin/components/codegraph/src/hook.ts +0 -258
- package/packages/omo-codex/plugin/components/codegraph/src/mcp-bridge.ts +0 -309
- package/packages/omo-codex/plugin/components/codegraph/src/mcp-unavailable.ts +0 -80
- package/packages/omo-codex/plugin/components/codegraph/src/post-tool-use-hook.ts +0 -34
- package/packages/omo-codex/plugin/components/codegraph/src/serve-invocation.ts +0 -29
- package/packages/omo-codex/plugin/components/codegraph/src/serve.ts +0 -263
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-command.ts +0 -106
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-cooldown.ts +0 -145
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-hook-runtime.ts +0 -21
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-lock.ts +0 -139
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-outcome.ts +0 -15
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-paths.ts +0 -32
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-project.ts +0 -109
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker-result.ts +0 -148
- package/packages/omo-codex/plugin/components/codegraph/src/session-start-worker.ts +0 -175
- package/packages/omo-codex/plugin/components/codegraph/src/sweep-cli.ts +0 -81
- package/packages/omo-codex/plugin/components/codegraph/test/cache-gc.test.ts +0 -34
- package/packages/omo-codex/plugin/components/codegraph/test/hook-exclusion.test.ts +0 -112
- package/packages/omo-codex/plugin/components/codegraph/test/hook-registration.test.ts +0 -26
- package/packages/omo-codex/plugin/components/codegraph/test/hook-session-start-guard.test.ts +0 -160
- package/packages/omo-codex/plugin/components/codegraph/test/hook-store-upgrade.test.ts +0 -50
- package/packages/omo-codex/plugin/components/codegraph/test/hook-sweep.test.ts +0 -29
- package/packages/omo-codex/plugin/components/codegraph/test/hook.test.ts +0 -320
- package/packages/omo-codex/plugin/components/codegraph/test/mcp-bridge-fixtures.ts +0 -172
- package/packages/omo-codex/plugin/components/codegraph/test/package-runtime.test.ts +0 -91
- package/packages/omo-codex/plugin/components/codegraph/test/provisioned-node-guard.test.ts +0 -100
- package/packages/omo-codex/plugin/components/codegraph/test/serve-built-wrapper.test.ts +0 -76
- package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge-lifecycle.test.ts +0 -133
- package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-bridge.test.ts +0 -245
- package/packages/omo-codex/plugin/components/codegraph/test/serve-mcp-facade.test.ts +0 -69
- package/packages/omo-codex/plugin/components/codegraph/test/serve-node-support.test.ts +0 -43
- package/packages/omo-codex/plugin/components/codegraph/test/serve-provision.test.ts +0 -147
- package/packages/omo-codex/plugin/components/codegraph/test/serve-unavailable.test.ts +0 -175
- package/packages/omo-codex/plugin/components/codegraph/test/serve.test.ts +0 -385
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-node-support.test.ts +0 -206
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-project.test.ts +0 -58
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-state.test.ts +0 -104
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-trust-boundary.test.ts +0 -65
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-availability.test.ts +0 -106
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-cooldown.test.ts +0 -116
- package/packages/omo-codex/plugin/components/codegraph/test/session-start-worker-flow.test.ts +0 -258
- package/packages/omo-codex/plugin/components/codegraph/test/sweep-cli.test.ts +0 -56
- package/packages/omo-codex/plugin/components/codegraph/tsconfig.build.json +0 -13
- package/packages/omo-codex/plugin/components/codegraph/tsconfig.json +0 -25
- package/packages/omo-codex/plugin/components/start-work-continuation/LICENSE +0 -21
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +0 -28
- package/packages/omo-codex/plugin/components/ultrawork/directive.md +0 -477
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +0 -18
- package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +0 -17
- 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/scripts/migrate-omo-sot/editor.mjs +0 -125
- package/packages/omo-codex/plugin/scripts/migrate-omo-sot/jsonc.mjs +0 -43
- package/packages/omo-codex/plugin/scripts/migrate-omo-sot/scaffold.mjs +0 -29
- package/packages/omo-codex/plugin/scripts/migrate-omo-sot.mjs +0 -121
- 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/skills/visual-qa/references/agent-browser-setup.md +0 -45
- package/packages/omo-codex/plugin/test/aggregate-skills.test.mjs +0 -92
- package/packages/omo-codex/plugin/test/component-codegraph-mcp-smoke.test.mjs +0 -76
- package/packages/omo-codex/plugin/test/migrate-omo-sot.test.mjs +0 -179
- 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/packages/shared-skills/skills/visual-qa/references/agent-browser-setup.md +0 -45
- /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/{codegraph → 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}/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
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
2
|
|
|
17
3
|
// components/telemetry/src/cli.ts
|
|
18
4
|
import { stdin as processStdin, stdout as processStdout } from "node:process";
|
|
19
5
|
|
|
20
6
|
// ../../telemetry-core/src/activity-state.ts
|
|
21
|
-
import { existsSync, mkdirSync as
|
|
22
|
-
import { basename, join } from "node:path";
|
|
7
|
+
import { existsSync, mkdirSync as mkdirSync3, readFileSync } from "node:fs";
|
|
8
|
+
import { basename, join as join2 } from "node:path";
|
|
23
9
|
|
|
24
10
|
// ../../utils/src/atomic-write.ts
|
|
25
11
|
import {
|
|
@@ -27,9 +13,12 @@ import {
|
|
|
27
13
|
fsyncSync,
|
|
28
14
|
openSync,
|
|
29
15
|
renameSync,
|
|
16
|
+
rmSync,
|
|
30
17
|
unlinkSync,
|
|
31
18
|
writeFileSync
|
|
32
19
|
} from "node:fs";
|
|
20
|
+
import { randomUUID } from "node:crypto";
|
|
21
|
+
import { dirname } from "node:path";
|
|
33
22
|
var TOLERATED_FSYNC_CODES = new Set([
|
|
34
23
|
"EPERM",
|
|
35
24
|
"EACCES",
|
|
@@ -51,24 +40,36 @@ function tolerantFsyncSync(fileDescriptor, fsyncImpl) {
|
|
|
51
40
|
}
|
|
52
41
|
}
|
|
53
42
|
function writeFileAtomically(filePath, content, options = {}) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
try {
|
|
58
|
-
tolerantFsyncSync(tempFileDescriptor, options.fsyncSync ?? fsyncSync);
|
|
59
|
-
} finally {
|
|
60
|
-
closeSync(tempFileDescriptor);
|
|
61
|
-
}
|
|
43
|
+
const platform = options.platform ?? process.platform;
|
|
44
|
+
const fsyncImpl = options.fsyncSync ?? fsyncSync;
|
|
45
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
62
46
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
writeFileSync(tempPath, content, "utf-8");
|
|
48
|
+
const tempFileDescriptor = openSync(tempPath, "r+");
|
|
49
|
+
try {
|
|
50
|
+
tolerantFsyncSync(tempFileDescriptor, fsyncImpl);
|
|
51
|
+
} finally {
|
|
52
|
+
closeSync(tempFileDescriptor);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
renameSync(tempPath, filePath);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
|
|
58
|
+
if (platform !== "win32" || !isPermissionError)
|
|
59
|
+
throw error;
|
|
67
60
|
unlinkSync(filePath);
|
|
68
61
|
renameSync(tempPath, filePath);
|
|
62
|
+
}
|
|
63
|
+
if (platform === "win32")
|
|
69
64
|
return;
|
|
65
|
+
const directoryFileDescriptor = openSync(dirname(filePath), "r");
|
|
66
|
+
try {
|
|
67
|
+
tolerantFsyncSync(directoryFileDescriptor, fsyncImpl);
|
|
68
|
+
} finally {
|
|
69
|
+
closeSync(directoryFileDescriptor);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
} finally {
|
|
72
|
+
rmSync(tempPath, { force: true });
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -96,36 +97,82 @@ function resolveWritableDirectory(preferredDir, fallbackSuffix, osProvider) {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
// ../../telemetry-core/src/day-claim.ts
|
|
101
|
+
import { closeSync as closeSync2, mkdirSync as mkdirSync2, openSync as openSync2, readdirSync, rmSync as rmSync2 } from "node:fs";
|
|
102
|
+
import { join } from "node:path";
|
|
103
|
+
var CLAIM_PREFIX = "daily-active.";
|
|
104
|
+
var CLAIM_SUFFIX = ".claim";
|
|
105
|
+
function getTelemetryDayClaimFilePath(stateDir, dayUTC) {
|
|
106
|
+
return join(stateDir, `${CLAIM_PREFIX}${dayUTC}${CLAIM_SUFFIX}`);
|
|
107
|
+
}
|
|
108
|
+
function claimUtcDay(stateDir, dayUTC) {
|
|
109
|
+
try {
|
|
110
|
+
mkdirSync2(stateDir, { recursive: true });
|
|
111
|
+
closeSync2(openSync2(getTelemetryDayClaimFilePath(stateDir, dayUTC), "wx"));
|
|
112
|
+
} catch (error) {
|
|
113
|
+
return error.code === "EEXIST" ? "already-claimed" : "unavailable";
|
|
114
|
+
}
|
|
115
|
+
pruneSupersededClaims(stateDir, dayUTC);
|
|
116
|
+
return "claimed";
|
|
117
|
+
}
|
|
118
|
+
function pruneSupersededClaims(stateDir, dayUTC) {
|
|
119
|
+
const currentClaim = `${CLAIM_PREFIX}${dayUTC}${CLAIM_SUFFIX}`;
|
|
120
|
+
let entries;
|
|
121
|
+
try {
|
|
122
|
+
entries = readdirSync(stateDir);
|
|
123
|
+
} catch {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
if (entry === currentClaim)
|
|
128
|
+
continue;
|
|
129
|
+
if (!entry.startsWith(CLAIM_PREFIX) || !entry.endsWith(CLAIM_SUFFIX))
|
|
130
|
+
continue;
|
|
131
|
+
try {
|
|
132
|
+
rmSync2(join(stateDir, entry), { force: true });
|
|
133
|
+
} catch {}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
99
137
|
// ../../telemetry-core/src/activity-state.ts
|
|
100
138
|
var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
|
|
139
|
+
var capturedDaysByStateDir = new Map;
|
|
101
140
|
function resolveTelemetryStateDir(product, options = {}) {
|
|
102
141
|
const dataDir = resolveXdgDataDir(product.cacheDirName, {
|
|
103
142
|
env: options.env,
|
|
104
143
|
osProvider: options.osProvider
|
|
105
144
|
});
|
|
106
|
-
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined :
|
|
145
|
+
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join2(options.env.XDG_DATA_HOME, product.cacheDirName);
|
|
107
146
|
if (dataDir === xdgStateDir || xdgStateDir === undefined && basename(dataDir) === product.cacheDirName) {
|
|
108
147
|
return dataDir;
|
|
109
148
|
}
|
|
110
|
-
return
|
|
149
|
+
return join2(dataDir, product.cacheDirName);
|
|
111
150
|
}
|
|
112
151
|
function getTelemetryActivityStateFilePath(stateDir) {
|
|
113
|
-
return
|
|
152
|
+
return join2(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
|
|
114
153
|
}
|
|
115
154
|
function getDailyActiveCaptureState(input) {
|
|
116
|
-
const state = readPostHogActivityState(input.stateDir, input.diagnostics);
|
|
117
155
|
const dayUTC = getUtcDayString(input.now ?? new Date);
|
|
118
|
-
|
|
119
|
-
|
|
156
|
+
if (capturedDaysByStateDir.get(input.stateDir) === dayUTC) {
|
|
157
|
+
return { dayUTC, captureDaily: false };
|
|
158
|
+
}
|
|
159
|
+
const state = readPostHogActivityState(input.stateDir, input.diagnostics);
|
|
160
|
+
if (state.lastActiveDayUTC === dayUTC) {
|
|
161
|
+
capturedDaysByStateDir.set(input.stateDir, dayUTC);
|
|
162
|
+
return { dayUTC, captureDaily: false };
|
|
163
|
+
}
|
|
164
|
+
const claim = claimUtcDay(input.stateDir, dayUTC);
|
|
165
|
+
capturedDaysByStateDir.set(input.stateDir, dayUTC);
|
|
166
|
+
if (claim === "already-claimed") {
|
|
167
|
+
return { dayUTC, captureDaily: false };
|
|
168
|
+
}
|
|
169
|
+
if (claim === "claimed") {
|
|
120
170
|
writePostHogActivityState(input.stateDir, {
|
|
121
171
|
...state,
|
|
122
172
|
lastActiveDayUTC: dayUTC
|
|
123
173
|
}, input.diagnostics);
|
|
124
174
|
}
|
|
125
|
-
return {
|
|
126
|
-
dayUTC,
|
|
127
|
-
captureDaily
|
|
128
|
-
};
|
|
175
|
+
return { dayUTC, captureDaily: true };
|
|
129
176
|
}
|
|
130
177
|
function getUtcDayString(date) {
|
|
131
178
|
return date.toISOString().slice(0, 10);
|
|
@@ -158,7 +205,7 @@ function readPostHogActivityState(stateDir, diagnostics) {
|
|
|
158
205
|
function writePostHogActivityState(stateDir, nextState, diagnostics) {
|
|
159
206
|
const stateFilePath = getTelemetryActivityStateFilePath(stateDir);
|
|
160
207
|
try {
|
|
161
|
-
|
|
208
|
+
mkdirSync3(stateDir, { recursive: true });
|
|
162
209
|
writeFileAtomically(stateFilePath, `${JSON.stringify(nextState, null, 2)}
|
|
163
210
|
`);
|
|
164
211
|
} catch (error) {
|
|
@@ -177,19 +224,19 @@ var DEFAULT_POSTHOG_API_KEY = "phc_CFJhj5HyvA62QPhvyaUCtaq23aUfznnijg5VaaGkNk74"
|
|
|
177
224
|
var UNCONFIGURED_POSTHOG_API_KEY = "phc_REPLACE_ME_OMO_NATIVE";
|
|
178
225
|
|
|
179
226
|
// ../../telemetry-core/src/diagnostics.ts
|
|
180
|
-
import { appendFileSync, existsSync as existsSync2, mkdirSync as
|
|
181
|
-
import { join as
|
|
227
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync2 } from "node:fs";
|
|
228
|
+
import { join as join3 } from "node:path";
|
|
182
229
|
var DIAGNOSTICS_FILE_NAME = "telemetry-diagnostics.jsonl";
|
|
183
230
|
var DIAGNOSTICS_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
184
231
|
var DIAGNOSTICS_MAX_BYTES = 256 * 1024;
|
|
185
232
|
function getTelemetryDiagnosticsFilePath(diagnosticsDir) {
|
|
186
|
-
return
|
|
233
|
+
return join3(diagnosticsDir, DIAGNOSTICS_FILE_NAME);
|
|
187
234
|
}
|
|
188
235
|
function writeTelemetryDiagnostic(input, options) {
|
|
189
236
|
const now = options.now ?? new Date;
|
|
190
237
|
try {
|
|
191
238
|
cleanupTelemetryDiagnostics({ diagnosticsDir: options.diagnosticsDir, now });
|
|
192
|
-
|
|
239
|
+
mkdirSync4(options.diagnosticsDir, { recursive: true });
|
|
193
240
|
appendFileSync(getTelemetryDiagnosticsFilePath(options.diagnosticsDir), `${JSON.stringify(toDiagnosticRecord(input, now))}
|
|
194
241
|
`, "utf-8");
|
|
195
242
|
} catch (error) {
|
|
@@ -338,8 +385,8 @@ function getTelemetryHost(env = process.env, defaultHost = DEFAULT_POSTHOG_HOST)
|
|
|
338
385
|
return env["POSTHOG_HOST"]?.trim() || defaultHost;
|
|
339
386
|
}
|
|
340
387
|
|
|
341
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
342
|
-
import { dirname, posix, sep } from "node:path";
|
|
388
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
389
|
+
import { dirname as dirname2, posix, sep } from "node:path";
|
|
343
390
|
function createModulerModifier() {
|
|
344
391
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
345
392
|
return async (frames) => {
|
|
@@ -348,7 +395,7 @@ function createModulerModifier() {
|
|
|
348
395
|
return frames;
|
|
349
396
|
};
|
|
350
397
|
}
|
|
351
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
398
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname2(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
|
|
352
399
|
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
353
400
|
return (filename) => {
|
|
354
401
|
if (!filename)
|
|
@@ -370,11 +417,11 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(proces
|
|
|
370
417
|
return decodedFile;
|
|
371
418
|
};
|
|
372
419
|
}
|
|
373
|
-
function normalizeWindowsPath(
|
|
374
|
-
return
|
|
420
|
+
function normalizeWindowsPath(path) {
|
|
421
|
+
return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
375
422
|
}
|
|
376
423
|
|
|
377
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
424
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
378
425
|
var normalizeFlagsResponse = (flagsResponse) => {
|
|
379
426
|
if ("flags" in flagsResponse) {
|
|
380
427
|
const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
|
|
@@ -444,8 +491,69 @@ var parsePayload = (response) => {
|
|
|
444
491
|
return response;
|
|
445
492
|
}
|
|
446
493
|
};
|
|
494
|
+
var MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES = [
|
|
495
|
+
"utm_source",
|
|
496
|
+
"utm_medium",
|
|
497
|
+
"utm_campaign",
|
|
498
|
+
"utm_content",
|
|
499
|
+
"utm_term",
|
|
500
|
+
"gad_source",
|
|
501
|
+
"mc_cid",
|
|
502
|
+
"gclid",
|
|
503
|
+
"gclsrc",
|
|
504
|
+
"dclid",
|
|
505
|
+
"gbraid",
|
|
506
|
+
"wbraid",
|
|
507
|
+
"fbclid",
|
|
508
|
+
"msclkid",
|
|
509
|
+
"twclid",
|
|
510
|
+
"li_fat_id",
|
|
511
|
+
"igshid",
|
|
512
|
+
"ttclid",
|
|
513
|
+
"rdt_cid",
|
|
514
|
+
"epik",
|
|
515
|
+
"qclid",
|
|
516
|
+
"sccid",
|
|
517
|
+
"irclid",
|
|
518
|
+
"_kx"
|
|
519
|
+
];
|
|
520
|
+
var MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
|
|
521
|
+
"$feature_flag",
|
|
522
|
+
"$feature_flag_response",
|
|
523
|
+
"$feature_flag_has_experiment",
|
|
524
|
+
"$feature_flag_id",
|
|
525
|
+
"$feature_flag_version",
|
|
526
|
+
"$feature_flag_reason",
|
|
527
|
+
"$feature_flag_request_id",
|
|
528
|
+
"$feature_flag_evaluated_at",
|
|
529
|
+
"$feature_flag_error",
|
|
530
|
+
"locally_evaluated",
|
|
531
|
+
"$groups",
|
|
532
|
+
"$process_person_profile",
|
|
533
|
+
"$geoip_disable",
|
|
534
|
+
"$current_url",
|
|
535
|
+
"$pathname",
|
|
536
|
+
"$referring_domain",
|
|
537
|
+
...MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES,
|
|
538
|
+
"$session_id",
|
|
539
|
+
"$window_id",
|
|
540
|
+
"$lib",
|
|
541
|
+
"$lib_version",
|
|
542
|
+
"$device_id",
|
|
543
|
+
"$is_server"
|
|
544
|
+
];
|
|
545
|
+
var minimizeFlagCalledEventProperties = (properties, transportKeys = []) => {
|
|
546
|
+
const minimal = {};
|
|
547
|
+
const copyKey = (key) => {
|
|
548
|
+
if (properties[key] !== undefined)
|
|
549
|
+
minimal[key] = properties[key];
|
|
550
|
+
};
|
|
551
|
+
MINIMAL_FLAG_CALLED_EVENT_PROPERTIES.forEach(copyKey);
|
|
552
|
+
transportKeys.forEach(copyKey);
|
|
553
|
+
return minimal;
|
|
554
|
+
};
|
|
447
555
|
|
|
448
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
556
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/types.mjs
|
|
449
557
|
var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedProperty) {
|
|
450
558
|
PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
|
|
451
559
|
PostHogPersistedProperty["DistinctId"] = "distinct_id";
|
|
@@ -460,6 +568,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
460
568
|
PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
|
|
461
569
|
PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
|
|
462
570
|
PostHogPersistedProperty["Queue"] = "queue";
|
|
571
|
+
PostHogPersistedProperty["AiQueue"] = "ai_queue";
|
|
572
|
+
PostHogPersistedProperty["AiCaptureQueue"] = "ai_capture_queue";
|
|
463
573
|
PostHogPersistedProperty["LogsQueue"] = "logs_queue";
|
|
464
574
|
PostHogPersistedProperty["OptedOut"] = "opted_out";
|
|
465
575
|
PostHogPersistedProperty["SessionId"] = "session_id";
|
|
@@ -470,6 +580,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
470
580
|
PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
|
|
471
581
|
PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
|
|
472
582
|
PostHogPersistedProperty["SessionReplay"] = "session_replay";
|
|
583
|
+
PostHogPersistedProperty["PushRegistered"] = "push_registered";
|
|
584
|
+
PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
|
|
473
585
|
PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
|
|
474
586
|
PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
|
|
475
587
|
PostHogPersistedProperty["Surveys"] = "surveys";
|
|
@@ -479,7 +591,7 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
479
591
|
return PostHogPersistedProperty;
|
|
480
592
|
}({});
|
|
481
593
|
|
|
482
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
594
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/gzip.mjs
|
|
483
595
|
function isGzipSupported() {
|
|
484
596
|
return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && typeof Response.prototype.blob == "function";
|
|
485
597
|
}
|
|
@@ -529,7 +641,7 @@ var validateNativeGzip = async (compressed, inputBytes) => {
|
|
|
529
641
|
async function gzipCompress(input, isDebug = true, options) {
|
|
530
642
|
try {
|
|
531
643
|
const inputBytes = new TextEncoder().encode(input);
|
|
532
|
-
const compressedStream = new CompressionStream("gzip");
|
|
644
|
+
const compressedStream = new globalThis.CompressionStream("gzip");
|
|
533
645
|
const writer = compressedStream.writable.getWriter();
|
|
534
646
|
const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
|
|
535
647
|
try {
|
|
@@ -553,7 +665,34 @@ async function gzipCompress(input, isDebug = true, options) {
|
|
|
553
665
|
}
|
|
554
666
|
}
|
|
555
667
|
|
|
556
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
668
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/json-utils.mjs
|
|
669
|
+
var MAX_JSON_SAFE_VALUE_DEPTH = 20;
|
|
670
|
+
var MAX_JSON_SAFE_VALUE_ITEMS = 1000;
|
|
671
|
+
var MAX_JSON_SAFE_VALUE_NODES = 1e4;
|
|
672
|
+
var CIRCULAR_VALUE = "[Circular]";
|
|
673
|
+
var TRUNCATED_VALUE = "[Truncated]";
|
|
674
|
+
var UNSERIALIZABLE_VALUE = "[Unserializable]";
|
|
675
|
+
var FUNCTION_VALUE = "[Function]";
|
|
676
|
+
var dateGetTime = Date.prototype.getTime;
|
|
677
|
+
var dateToISOString = Date.prototype.toISOString;
|
|
678
|
+
function sanitizeString(value) {
|
|
679
|
+
let output = "";
|
|
680
|
+
for (let index = 0;index < value.length; index++) {
|
|
681
|
+
const codeUnit = value.charCodeAt(index);
|
|
682
|
+
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
683
|
+
const nextCodeUnit = value.charCodeAt(index + 1);
|
|
684
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
685
|
+
output += value[index] + value[index + 1];
|
|
686
|
+
index++;
|
|
687
|
+
} else
|
|
688
|
+
output += "�";
|
|
689
|
+
} else
|
|
690
|
+
output += codeUnit >= 56320 && codeUnit <= 57343 ? "�" : value[index];
|
|
691
|
+
}
|
|
692
|
+
return output;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bot-detection.mjs
|
|
557
696
|
var DEFAULT_BLOCKED_UA_STRS = [
|
|
558
697
|
"amazonbot",
|
|
559
698
|
"amazonproductbot",
|
|
@@ -642,7 +781,31 @@ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
|
|
|
642
781
|
return uaLower.indexOf(blockedUaLower) !== -1;
|
|
643
782
|
});
|
|
644
783
|
};
|
|
645
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
784
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/string-utils.mjs
|
|
785
|
+
function safeJsonStringify(value) {
|
|
786
|
+
const ancestors = [];
|
|
787
|
+
return JSON.stringify(value, function(_key, replacementValue) {
|
|
788
|
+
if (typeof replacementValue == "bigint")
|
|
789
|
+
return replacementValue.toString();
|
|
790
|
+
if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
|
|
791
|
+
return;
|
|
792
|
+
if (replacementValue instanceof Error)
|
|
793
|
+
return {
|
|
794
|
+
name: replacementValue.name,
|
|
795
|
+
message: replacementValue.message,
|
|
796
|
+
stack: replacementValue.stack
|
|
797
|
+
};
|
|
798
|
+
if (replacementValue && typeof replacementValue == "object") {
|
|
799
|
+
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
|
|
800
|
+
ancestors.pop();
|
|
801
|
+
if (ancestors.includes(replacementValue))
|
|
802
|
+
return "[Circular]";
|
|
803
|
+
ancestors.push(replacementValue);
|
|
804
|
+
}
|
|
805
|
+
return replacementValue;
|
|
806
|
+
}) ?? "null";
|
|
807
|
+
}
|
|
808
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/type-utils.mjs
|
|
646
809
|
var nativeIsArray = Array.isArray;
|
|
647
810
|
var ObjProto = Object.prototype;
|
|
648
811
|
var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
|
|
@@ -654,16 +817,27 @@ var isObject = (x) => x === Object(x) && !isArray(x);
|
|
|
654
817
|
var isUndefined = (x) => x === undefined;
|
|
655
818
|
var isString = (x) => type_utils_toString.call(x) == "[object String]";
|
|
656
819
|
var isEmptyString = (x) => isString(x) && x.trim().length === 0;
|
|
820
|
+
var isNull = (x) => x === null;
|
|
821
|
+
var isNullish = (x) => isUndefined(x) || isNull(x);
|
|
657
822
|
var isNumber = (x) => type_utils_toString.call(x) == "[object Number]" && x === x;
|
|
658
|
-
var
|
|
823
|
+
var isBoolean = (x) => type_utils_toString.call(x) === "[object Boolean]";
|
|
659
824
|
function isPrimitive(value) {
|
|
660
825
|
return value === null || typeof value != "object";
|
|
661
826
|
}
|
|
662
827
|
function isBuiltin(candidate, className) {
|
|
663
828
|
return Object.prototype.toString.call(candidate) === `[object ${className}]`;
|
|
664
829
|
}
|
|
665
|
-
function
|
|
666
|
-
|
|
830
|
+
function isError(candidate) {
|
|
831
|
+
switch (Object.prototype.toString.call(candidate)) {
|
|
832
|
+
case "[object Error]":
|
|
833
|
+
case "[object Exception]":
|
|
834
|
+
case "[object DOMException]":
|
|
835
|
+
case "[object DOMError]":
|
|
836
|
+
case "[object WebAssembly.Exception]":
|
|
837
|
+
return true;
|
|
838
|
+
default:
|
|
839
|
+
return isInstanceOf(candidate, Error);
|
|
840
|
+
}
|
|
667
841
|
}
|
|
668
842
|
function isEvent(candidate) {
|
|
669
843
|
return typeof Event != "undefined" && isInstanceOf(candidate, Event);
|
|
@@ -679,7 +853,7 @@ function isInstanceOf(candidate, base) {
|
|
|
679
853
|
}
|
|
680
854
|
}
|
|
681
855
|
|
|
682
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
856
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/number-utils.mjs
|
|
683
857
|
function clampToRange(value, min, max, logger, fallbackValue) {
|
|
684
858
|
if (min > max) {
|
|
685
859
|
logger.warn("min cannot be greater than max.");
|
|
@@ -699,8 +873,16 @@ function clampToRange(value, min, max, logger, fallbackValue) {
|
|
|
699
873
|
return clampToRange(fallbackValue || max, min, max, logger);
|
|
700
874
|
}
|
|
701
875
|
|
|
702
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
876
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
|
|
703
877
|
var ONE_DAY_IN_MS = 86400000;
|
|
878
|
+
var DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE = 1;
|
|
879
|
+
var DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE = 10;
|
|
880
|
+
function resolveExceptionRateLimiterConfig(config = {}) {
|
|
881
|
+
return {
|
|
882
|
+
refillRate: config.exceptionRateLimiterRefillRate ?? config.__exceptionRateLimiterRefillRate ?? DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE,
|
|
883
|
+
bucketSize: config.exceptionRateLimiterBucketSize ?? config.__exceptionRateLimiterBucketSize ?? DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE
|
|
884
|
+
};
|
|
885
|
+
}
|
|
704
886
|
|
|
705
887
|
class BucketedRateLimiter {
|
|
706
888
|
constructor(options) {
|
|
@@ -743,7 +925,7 @@ class BucketedRateLimiter {
|
|
|
743
925
|
this._buckets = {};
|
|
744
926
|
}
|
|
745
927
|
}
|
|
746
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
928
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
|
|
747
929
|
/*! For license information please see uuidv7.mjs.LICENSE.txt */
|
|
748
930
|
var DIGITS = "0123456789abcdef";
|
|
749
931
|
|
|
@@ -921,33 +1103,45 @@ var defaultGenerator;
|
|
|
921
1103
|
var uuidv7 = () => uuidv7obj().toString();
|
|
922
1104
|
var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator)).generate();
|
|
923
1105
|
|
|
924
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1106
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/promise-queue.mjs
|
|
925
1107
|
class PromiseQueue {
|
|
926
1108
|
add(promise) {
|
|
927
1109
|
const promiseUUID = uuidv7();
|
|
928
|
-
|
|
1110
|
+
const id = ++this.nextId;
|
|
1111
|
+
this.promiseByIds[promiseUUID] = {
|
|
1112
|
+
id,
|
|
1113
|
+
promise
|
|
1114
|
+
};
|
|
929
1115
|
promise.catch(() => {}).finally(() => {
|
|
930
1116
|
delete this.promiseByIds[promiseUUID];
|
|
931
1117
|
});
|
|
932
1118
|
return promise;
|
|
933
1119
|
}
|
|
934
1120
|
async join() {
|
|
935
|
-
let promises = Object.values(this.promiseByIds);
|
|
1121
|
+
let promises = Object.values(this.promiseByIds).map((item) => item.promise);
|
|
936
1122
|
let length = promises.length;
|
|
937
1123
|
while (length > 0) {
|
|
938
1124
|
await Promise.all(promises);
|
|
939
|
-
promises = Object.values(this.promiseByIds);
|
|
1125
|
+
promises = Object.values(this.promiseByIds).map((item) => item.promise);
|
|
940
1126
|
length = promises.length;
|
|
941
1127
|
}
|
|
942
1128
|
}
|
|
1129
|
+
getPromises(ignoredPromises = [], maxId = this.nextId) {
|
|
1130
|
+
const ignoredPromiseSet = new Set(ignoredPromises);
|
|
1131
|
+
return Object.values(this.promiseByIds).filter((item) => item.id <= maxId && !ignoredPromiseSet.has(item.promise)).map((item) => item.promise);
|
|
1132
|
+
}
|
|
1133
|
+
get maxId() {
|
|
1134
|
+
return this.nextId;
|
|
1135
|
+
}
|
|
943
1136
|
get length() {
|
|
944
1137
|
return Object.keys(this.promiseByIds).length;
|
|
945
1138
|
}
|
|
946
1139
|
constructor() {
|
|
947
1140
|
this.promiseByIds = {};
|
|
1141
|
+
this.nextId = 0;
|
|
948
1142
|
}
|
|
949
1143
|
}
|
|
950
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1144
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/logger.mjs
|
|
951
1145
|
function createConsole(consoleLike = console) {
|
|
952
1146
|
const lockedMethods = {
|
|
953
1147
|
log: consoleLike.log.bind(consoleLike),
|
|
@@ -988,7 +1182,7 @@ var passThrough = (fn) => fn();
|
|
|
988
1182
|
function createLogger(prefix, maybeCall = passThrough) {
|
|
989
1183
|
return _createLogger(prefix, maybeCall, createConsole());
|
|
990
1184
|
}
|
|
991
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1185
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
|
|
992
1186
|
var MOBILE = "Mobile";
|
|
993
1187
|
var IOS = "iOS";
|
|
994
1188
|
var ANDROID = "Android";
|
|
@@ -1031,6 +1225,7 @@ var DUCKDUCKGO = "DuckDuckGo";
|
|
|
1031
1225
|
var PALE_MOON = "Pale Moon";
|
|
1032
1226
|
var WATERFOX = "Waterfox";
|
|
1033
1227
|
var BRAVE = "Brave";
|
|
1228
|
+
var GOOGLE_SEARCH_APP = "Google Search App";
|
|
1034
1229
|
var BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
|
|
1035
1230
|
var DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
|
|
1036
1231
|
var XBOX_REGEX = new RegExp(XBOX, "i");
|
|
@@ -1118,6 +1313,9 @@ var versionRegexes = {
|
|
|
1118
1313
|
[WATERFOX]: [
|
|
1119
1314
|
new RegExp(WATERFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1120
1315
|
],
|
|
1316
|
+
[GOOGLE_SEARCH_APP]: [
|
|
1317
|
+
new RegExp("GSA\\/" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1318
|
+
],
|
|
1121
1319
|
[INTERNET_EXPLORER]: [
|
|
1122
1320
|
new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1123
1321
|
],
|
|
@@ -1277,8 +1475,15 @@ var osMatchers = [
|
|
|
1277
1475
|
]
|
|
1278
1476
|
];
|
|
1279
1477
|
|
|
1280
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1478
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/index.mjs
|
|
1281
1479
|
var STRING_FORMAT = "utf8";
|
|
1480
|
+
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1481
|
+
function isValidUUID(value) {
|
|
1482
|
+
return typeof value == "string" && UUID_REGEX.test(value);
|
|
1483
|
+
}
|
|
1484
|
+
function getEventUuid(uuid, generateUuid) {
|
|
1485
|
+
return isValidUUID(uuid) ? uuid : generateUuid();
|
|
1486
|
+
}
|
|
1282
1487
|
function removeTrailingSlash(url) {
|
|
1283
1488
|
return url?.replace(/\/+$/, "");
|
|
1284
1489
|
}
|
|
@@ -1306,7 +1511,26 @@ function safeSetTimeout(fn, timeout) {
|
|
|
1306
1511
|
t?.unref && t?.unref();
|
|
1307
1512
|
return t;
|
|
1308
1513
|
}
|
|
1309
|
-
|
|
1514
|
+
async function raceWithTimeout(promise, timeoutMs, onTimeout) {
|
|
1515
|
+
let timeoutHandle;
|
|
1516
|
+
try {
|
|
1517
|
+
return await Promise.race([
|
|
1518
|
+
promise,
|
|
1519
|
+
new Promise((resolve, reject) => {
|
|
1520
|
+
timeoutHandle = safeSetTimeout(() => {
|
|
1521
|
+
try {
|
|
1522
|
+
onTimeout?.();
|
|
1523
|
+
resolve();
|
|
1524
|
+
} catch (error) {
|
|
1525
|
+
reject(error);
|
|
1526
|
+
}
|
|
1527
|
+
}, timeoutMs);
|
|
1528
|
+
})
|
|
1529
|
+
]);
|
|
1530
|
+
} finally {
|
|
1531
|
+
clearTimeout(timeoutHandle);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1310
1534
|
function allSettled(promises) {
|
|
1311
1535
|
return Promise.all(promises.map((p) => (p ?? Promise.resolve()).then((value) => ({
|
|
1312
1536
|
status: "fulfilled",
|
|
@@ -1317,7 +1541,7 @@ function allSettled(promises) {
|
|
|
1317
1541
|
}))));
|
|
1318
1542
|
}
|
|
1319
1543
|
|
|
1320
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1544
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/logs/logs-utils.mjs
|
|
1321
1545
|
var OTLP_SEVERITY_MAP = {
|
|
1322
1546
|
trace: {
|
|
1323
1547
|
text: "TRACE",
|
|
@@ -1345,7 +1569,570 @@ var OTLP_SEVERITY_MAP = {
|
|
|
1345
1569
|
}
|
|
1346
1570
|
};
|
|
1347
1571
|
var DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
|
|
1348
|
-
|
|
1572
|
+
var INT64_RANGE_LIMIT = 9223372036854776000;
|
|
1573
|
+
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
1574
|
+
function newState() {
|
|
1575
|
+
return {
|
|
1576
|
+
ancestors: new WeakSet,
|
|
1577
|
+
remainingNodes: MAX_JSON_SAFE_VALUE_NODES
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
function toOtlpKeyValueList(attrs, logger) {
|
|
1581
|
+
try {
|
|
1582
|
+
return encodeKeyValueList(attrs, logger, newState(), 0);
|
|
1583
|
+
} catch {
|
|
1584
|
+
return [];
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
function encodeAnyValue(value, logger, state, depth) {
|
|
1588
|
+
if (state.remainingNodes <= 0)
|
|
1589
|
+
return {
|
|
1590
|
+
stringValue: TRUNCATED_VALUE
|
|
1591
|
+
};
|
|
1592
|
+
state.remainingNodes--;
|
|
1593
|
+
if (isBoolean(value))
|
|
1594
|
+
return {
|
|
1595
|
+
boolValue: value
|
|
1596
|
+
};
|
|
1597
|
+
if (typeof value == "number") {
|
|
1598
|
+
if (!Number.isFinite(value))
|
|
1599
|
+
return {
|
|
1600
|
+
stringValue: String(value)
|
|
1601
|
+
};
|
|
1602
|
+
if (Number.isInteger(value)) {
|
|
1603
|
+
if (Number.isSafeInteger(value))
|
|
1604
|
+
return {
|
|
1605
|
+
intValue: String(value)
|
|
1606
|
+
};
|
|
1607
|
+
if (typeof BigInt == "undefined")
|
|
1608
|
+
return {
|
|
1609
|
+
stringValue: String(value)
|
|
1610
|
+
};
|
|
1611
|
+
const decimal = BigInt(value).toString();
|
|
1612
|
+
if (value >= INT64_RANGE_LIMIT || value < -INT64_RANGE_LIMIT) {
|
|
1613
|
+
logger?.debug(`Attribute ${decimal} is outside the int64 range; encoding it as a string`);
|
|
1614
|
+
return {
|
|
1615
|
+
stringValue: decimal
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
return {
|
|
1619
|
+
intValue: decimal
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
return {
|
|
1623
|
+
doubleValue: value
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
if (typeof value == "string")
|
|
1627
|
+
return {
|
|
1628
|
+
stringValue: sanitizeString(value)
|
|
1629
|
+
};
|
|
1630
|
+
if (typeof value == "function")
|
|
1631
|
+
return {
|
|
1632
|
+
stringValue: FUNCTION_VALUE
|
|
1633
|
+
};
|
|
1634
|
+
if (typeof value == "symbol")
|
|
1635
|
+
return {
|
|
1636
|
+
stringValue: String(value)
|
|
1637
|
+
};
|
|
1638
|
+
if (typeof value == "object" && value !== null) {
|
|
1639
|
+
if (state.ancestors.has(value))
|
|
1640
|
+
return {
|
|
1641
|
+
stringValue: CIRCULAR_VALUE
|
|
1642
|
+
};
|
|
1643
|
+
if (depth >= MAX_JSON_SAFE_VALUE_DEPTH)
|
|
1644
|
+
return {
|
|
1645
|
+
stringValue: TRUNCATED_VALUE
|
|
1646
|
+
};
|
|
1647
|
+
if (value instanceof Date) {
|
|
1648
|
+
const time = value.getTime();
|
|
1649
|
+
const iso = Number.isFinite(time) ? value.toISOString() : String(value);
|
|
1650
|
+
return {
|
|
1651
|
+
stringValue: typeof iso == "string" ? sanitizeString(iso) : String(iso)
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
state.ancestors.add(value);
|
|
1655
|
+
try {
|
|
1656
|
+
try {
|
|
1657
|
+
const toJSON = value.toJSON;
|
|
1658
|
+
if (typeof toJSON == "function")
|
|
1659
|
+
return encodeAnyValue(toJSON.call(value), logger, state, depth + 1);
|
|
1660
|
+
} catch {}
|
|
1661
|
+
if (isArray(value))
|
|
1662
|
+
return {
|
|
1663
|
+
arrayValue: {
|
|
1664
|
+
values: encodeArrayValues(value, logger, state, depth + 1)
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
return {
|
|
1668
|
+
kvlistValue: {
|
|
1669
|
+
values: encodeKeyValueList(value, logger, state, depth + 1)
|
|
1670
|
+
}
|
|
1671
|
+
};
|
|
1672
|
+
} finally {
|
|
1673
|
+
state.ancestors.delete(value);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
return {
|
|
1677
|
+
stringValue: sanitizeString(String(value))
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
function encodeArrayValues(values, logger, state, depth) {
|
|
1681
|
+
const result = [];
|
|
1682
|
+
const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
|
|
1683
|
+
let index = 0;
|
|
1684
|
+
for (;index < itemCount && state.remainingNodes > 0; index++)
|
|
1685
|
+
try {
|
|
1686
|
+
const element = index in values ? values[index] : undefined;
|
|
1687
|
+
if (isNullish(element))
|
|
1688
|
+
continue;
|
|
1689
|
+
result.push(encodeAnyValue(element, logger, state, depth));
|
|
1690
|
+
} catch {
|
|
1691
|
+
result.push({
|
|
1692
|
+
stringValue: UNSERIALIZABLE_VALUE
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
if (values.length > index)
|
|
1696
|
+
result.push({
|
|
1697
|
+
stringValue: TRUNCATED_VALUE
|
|
1698
|
+
});
|
|
1699
|
+
return result;
|
|
1700
|
+
}
|
|
1701
|
+
function encodeKeyValueList(attrs, logger, state, depth) {
|
|
1702
|
+
const result = [];
|
|
1703
|
+
for (const key in attrs)
|
|
1704
|
+
if (propertyIsEnumerable.call(attrs, key)) {
|
|
1705
|
+
if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
|
|
1706
|
+
logger?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");
|
|
1707
|
+
break;
|
|
1708
|
+
}
|
|
1709
|
+
try {
|
|
1710
|
+
const value = attrs[key];
|
|
1711
|
+
if (isNull(value) || isUndefined(value))
|
|
1712
|
+
continue;
|
|
1713
|
+
result.push({
|
|
1714
|
+
key: sanitizeString(key),
|
|
1715
|
+
value: encodeAnyValue(value, logger, state, depth)
|
|
1716
|
+
});
|
|
1717
|
+
} catch {
|
|
1718
|
+
result.push({
|
|
1719
|
+
key: sanitizeString(key),
|
|
1720
|
+
value: {
|
|
1721
|
+
stringValue: UNSERIALIZABLE_VALUE
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
return result;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
|
|
1730
|
+
var DEFAULT_HISTOGRAM_BOUNDS = [
|
|
1731
|
+
0,
|
|
1732
|
+
5,
|
|
1733
|
+
10,
|
|
1734
|
+
25,
|
|
1735
|
+
50,
|
|
1736
|
+
75,
|
|
1737
|
+
100,
|
|
1738
|
+
250,
|
|
1739
|
+
500,
|
|
1740
|
+
750,
|
|
1741
|
+
1000,
|
|
1742
|
+
2500,
|
|
1743
|
+
5000,
|
|
1744
|
+
7500,
|
|
1745
|
+
1e4
|
|
1746
|
+
];
|
|
1747
|
+
function msToUnixNano(ms) {
|
|
1748
|
+
return String(ms) + "000000";
|
|
1749
|
+
}
|
|
1750
|
+
function seriesKey(type, name, unit, attributes) {
|
|
1751
|
+
let attrsKey = "";
|
|
1752
|
+
if (attributes) {
|
|
1753
|
+
const keys = Object.keys(attributes).sort();
|
|
1754
|
+
attrsKey = keys.map((k) => `${JSON.stringify(k)}:${JSON.stringify(attributes[k])}`).join(",");
|
|
1755
|
+
}
|
|
1756
|
+
return `${type}\x00${name}\x00${unit ?? ""}\x00${attrsKey}`;
|
|
1757
|
+
}
|
|
1758
|
+
function bucketIndexFor(value, bounds) {
|
|
1759
|
+
for (let i = 0;i < bounds.length; i++)
|
|
1760
|
+
if (value <= bounds[i])
|
|
1761
|
+
return i;
|
|
1762
|
+
return bounds.length;
|
|
1763
|
+
}
|
|
1764
|
+
function buildMetricsResourceAttributes(config, scopeName, scopeVersion) {
|
|
1765
|
+
return {
|
|
1766
|
+
...config.resourceAttributes,
|
|
1767
|
+
"service.name": config.serviceName || "unknown_service",
|
|
1768
|
+
...config.environment && {
|
|
1769
|
+
"deployment.environment": config.environment
|
|
1770
|
+
},
|
|
1771
|
+
...config.serviceVersion && {
|
|
1772
|
+
"service.version": config.serviceVersion
|
|
1773
|
+
},
|
|
1774
|
+
"telemetry.sdk.name": scopeName,
|
|
1775
|
+
"telemetry.sdk.version": scopeVersion
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVersion) {
|
|
1779
|
+
return {
|
|
1780
|
+
resourceMetrics: [
|
|
1781
|
+
{
|
|
1782
|
+
resource: {
|
|
1783
|
+
attributes: toOtlpKeyValueList(resourceAttributes)
|
|
1784
|
+
},
|
|
1785
|
+
scopeMetrics: [
|
|
1786
|
+
{
|
|
1787
|
+
scope: {
|
|
1788
|
+
name: scopeName,
|
|
1789
|
+
version: scopeVersion
|
|
1790
|
+
},
|
|
1791
|
+
metrics
|
|
1792
|
+
}
|
|
1793
|
+
]
|
|
1794
|
+
}
|
|
1795
|
+
]
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/config.mjs
|
|
1800
|
+
var DEFAULT_FLUSH_INTERVAL_MS = 1e4;
|
|
1801
|
+
var DEFAULT_MAX_SERIES_PER_FLUSH = 1000;
|
|
1802
|
+
function resolveMetricsConfig(config) {
|
|
1803
|
+
const resourceAttributes = config?.resourceAttributes;
|
|
1804
|
+
return {
|
|
1805
|
+
serviceName: resourceAttributes?.["service.name"] ?? config?.serviceName,
|
|
1806
|
+
serviceVersion: resourceAttributes?.["service.version"] ?? config?.serviceVersion,
|
|
1807
|
+
environment: resourceAttributes?.["deployment.environment"] ?? config?.environment,
|
|
1808
|
+
resourceAttributes,
|
|
1809
|
+
beforeSend: config?.beforeSend,
|
|
1810
|
+
flushIntervalMs: config?.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
|
|
1811
|
+
maxSeriesPerFlush: config?.maxSeriesPerFlush ?? DEFAULT_MAX_SERIES_PER_FLUSH
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/index.mjs
|
|
1816
|
+
var OTLP_TEMPORALITY_DELTA = 1;
|
|
1817
|
+
|
|
1818
|
+
class PostHogMetrics {
|
|
1819
|
+
constructor(_instance, _config, _logger) {
|
|
1820
|
+
this._instance = _instance;
|
|
1821
|
+
this._config = _config;
|
|
1822
|
+
this._logger = _logger;
|
|
1823
|
+
this._series = new Map;
|
|
1824
|
+
this._flushPromise = null;
|
|
1825
|
+
this._seriesCapWarned = false;
|
|
1826
|
+
this._typeByName = new Map;
|
|
1827
|
+
this._typeCollisionWarned = new Set;
|
|
1828
|
+
this._generation = 0;
|
|
1829
|
+
}
|
|
1830
|
+
count(name, value = 1, options) {
|
|
1831
|
+
this._capture({
|
|
1832
|
+
name,
|
|
1833
|
+
type: "count",
|
|
1834
|
+
value,
|
|
1835
|
+
unit: options?.unit,
|
|
1836
|
+
attributes: options?.attributes
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
gauge(name, value, options) {
|
|
1840
|
+
this._capture({
|
|
1841
|
+
name,
|
|
1842
|
+
type: "gauge",
|
|
1843
|
+
value,
|
|
1844
|
+
unit: options?.unit,
|
|
1845
|
+
attributes: options?.attributes
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
histogram(name, value, options) {
|
|
1849
|
+
this._capture({
|
|
1850
|
+
name,
|
|
1851
|
+
type: "histogram",
|
|
1852
|
+
value,
|
|
1853
|
+
unit: options?.unit,
|
|
1854
|
+
attributes: options?.attributes
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
flush() {
|
|
1858
|
+
const prev = this._flushPromise;
|
|
1859
|
+
const run = async () => {
|
|
1860
|
+
if (prev)
|
|
1861
|
+
await prev.catch(() => {});
|
|
1862
|
+
await this._doFlush();
|
|
1863
|
+
};
|
|
1864
|
+
const p = run().finally(() => {
|
|
1865
|
+
if (this._flushPromise === p)
|
|
1866
|
+
this._flushPromise = null;
|
|
1867
|
+
});
|
|
1868
|
+
this._flushPromise = p;
|
|
1869
|
+
return p;
|
|
1870
|
+
}
|
|
1871
|
+
drainWindow() {
|
|
1872
|
+
if (this._series.size === 0)
|
|
1873
|
+
return null;
|
|
1874
|
+
const window = this._series;
|
|
1875
|
+
this._series = new Map;
|
|
1876
|
+
this._seriesCapWarned = false;
|
|
1877
|
+
this._typeByName = new Map;
|
|
1878
|
+
this._typeCollisionWarned = new Set;
|
|
1879
|
+
return this._buildPayload(window);
|
|
1880
|
+
}
|
|
1881
|
+
reset() {
|
|
1882
|
+
this._generation++;
|
|
1883
|
+
this._clearFlushTimer();
|
|
1884
|
+
this._series = new Map;
|
|
1885
|
+
this._flushPromise = null;
|
|
1886
|
+
this._seriesCapWarned = false;
|
|
1887
|
+
this._typeByName = new Map;
|
|
1888
|
+
this._typeCollisionWarned = new Set;
|
|
1889
|
+
}
|
|
1890
|
+
_capture(sample) {
|
|
1891
|
+
if (this._instance.isDisabled || this._instance.optedOut)
|
|
1892
|
+
return;
|
|
1893
|
+
const filtered = this._runBeforeSend(sample);
|
|
1894
|
+
if (filtered === null)
|
|
1895
|
+
return;
|
|
1896
|
+
if (!filtered.name || typeof filtered.name != "string")
|
|
1897
|
+
return void this._logger.warn("Dropping metric with empty name");
|
|
1898
|
+
if (typeof filtered.value != "number" || !Number.isFinite(filtered.value))
|
|
1899
|
+
return void this._logger.warn(`Dropping metric '${filtered.name}': value must be a finite number`);
|
|
1900
|
+
if (filtered.type === "count" && filtered.value < 0)
|
|
1901
|
+
return void this._logger.warn(`Dropping count '${filtered.name}': counters are monotonic, value must be >= 0`);
|
|
1902
|
+
let attributes;
|
|
1903
|
+
let key;
|
|
1904
|
+
try {
|
|
1905
|
+
attributes = filtered.attributes ? {
|
|
1906
|
+
...filtered.attributes
|
|
1907
|
+
} : undefined;
|
|
1908
|
+
key = seriesKey(filtered.type, filtered.name, filtered.unit, attributes);
|
|
1909
|
+
} catch (e) {
|
|
1910
|
+
this._logger.warn(`Dropping metric '${filtered.name}': attributes could not be serialized`, e);
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
let state = this._series.get(key);
|
|
1914
|
+
if (!state) {
|
|
1915
|
+
if (!this._admitNewSeries())
|
|
1916
|
+
return;
|
|
1917
|
+
state = {
|
|
1918
|
+
name: filtered.name,
|
|
1919
|
+
type: filtered.type,
|
|
1920
|
+
unit: filtered.unit,
|
|
1921
|
+
attributes,
|
|
1922
|
+
windowStartMs: Date.now()
|
|
1923
|
+
};
|
|
1924
|
+
this._series.set(key, state);
|
|
1925
|
+
}
|
|
1926
|
+
const seenType = this._typeByName.get(filtered.name);
|
|
1927
|
+
if (seenType === undefined)
|
|
1928
|
+
this._typeByName.set(filtered.name, filtered.type);
|
|
1929
|
+
else if (seenType !== filtered.type && !this._typeCollisionWarned.has(filtered.name)) {
|
|
1930
|
+
this._typeCollisionWarned.add(filtered.name);
|
|
1931
|
+
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.`);
|
|
1932
|
+
}
|
|
1933
|
+
this._fold(state, filtered.value);
|
|
1934
|
+
this._armFlushTimer();
|
|
1935
|
+
}
|
|
1936
|
+
_admitNewSeries() {
|
|
1937
|
+
if (this._series.size < this._config.maxSeriesPerFlush)
|
|
1938
|
+
return true;
|
|
1939
|
+
if (!this._seriesCapWarned) {
|
|
1940
|
+
this._seriesCapWarned = true;
|
|
1941
|
+
this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`);
|
|
1942
|
+
}
|
|
1943
|
+
return false;
|
|
1944
|
+
}
|
|
1945
|
+
_fold(state, value) {
|
|
1946
|
+
switch (state.type) {
|
|
1947
|
+
case "count":
|
|
1948
|
+
state.total = (state.total ?? 0) + value;
|
|
1949
|
+
break;
|
|
1950
|
+
case "gauge":
|
|
1951
|
+
state.last = value;
|
|
1952
|
+
break;
|
|
1953
|
+
case "histogram": {
|
|
1954
|
+
if (!state.hist)
|
|
1955
|
+
state.hist = {
|
|
1956
|
+
count: 0,
|
|
1957
|
+
sum: 0,
|
|
1958
|
+
min: value,
|
|
1959
|
+
max: value,
|
|
1960
|
+
bucketCounts: new Array(DEFAULT_HISTOGRAM_BOUNDS.length + 1).fill(0)
|
|
1961
|
+
};
|
|
1962
|
+
const hist = state.hist;
|
|
1963
|
+
hist.count += 1;
|
|
1964
|
+
hist.sum += value;
|
|
1965
|
+
hist.min = Math.min(hist.min, value);
|
|
1966
|
+
hist.max = Math.max(hist.max, value);
|
|
1967
|
+
hist.bucketCounts[bucketIndexFor(value, DEFAULT_HISTOGRAM_BOUNDS)] += 1;
|
|
1968
|
+
break;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
_runBeforeSend(sample) {
|
|
1973
|
+
const beforeSend = this._config.beforeSend;
|
|
1974
|
+
if (!beforeSend)
|
|
1975
|
+
return sample;
|
|
1976
|
+
const fns = isArray(beforeSend) ? beforeSend : [
|
|
1977
|
+
beforeSend
|
|
1978
|
+
];
|
|
1979
|
+
let result = sample;
|
|
1980
|
+
for (const fn of fns)
|
|
1981
|
+
try {
|
|
1982
|
+
const next = fn(result);
|
|
1983
|
+
if (!next) {
|
|
1984
|
+
this._logger.info("Metric was rejected in beforeSend function");
|
|
1985
|
+
return null;
|
|
1986
|
+
}
|
|
1987
|
+
result = next;
|
|
1988
|
+
} catch (e) {
|
|
1989
|
+
this._logger.error("Error in beforeSend function for metric:", e);
|
|
1990
|
+
return null;
|
|
1991
|
+
}
|
|
1992
|
+
return result;
|
|
1993
|
+
}
|
|
1994
|
+
_armFlushTimer() {
|
|
1995
|
+
if (this._flushTimer)
|
|
1996
|
+
return;
|
|
1997
|
+
this._flushTimer = safeSetTimeout(() => {
|
|
1998
|
+
this._flushTimer = undefined;
|
|
1999
|
+
this.flush().catch((e) => {
|
|
2000
|
+
this._logger.error("Metrics flush failed:", e);
|
|
2001
|
+
});
|
|
2002
|
+
}, this._config.flushIntervalMs);
|
|
2003
|
+
}
|
|
2004
|
+
_clearFlushTimer() {
|
|
2005
|
+
if (this._flushTimer) {
|
|
2006
|
+
clearTimeout(this._flushTimer);
|
|
2007
|
+
this._flushTimer = undefined;
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
async _doFlush() {
|
|
2011
|
+
if (this._series.size === 0)
|
|
2012
|
+
return;
|
|
2013
|
+
const window = this._series;
|
|
2014
|
+
this._series = new Map;
|
|
2015
|
+
this._seriesCapWarned = false;
|
|
2016
|
+
this._typeByName = new Map;
|
|
2017
|
+
this._typeCollisionWarned = new Set;
|
|
2018
|
+
const generation = this._generation;
|
|
2019
|
+
const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
|
|
2020
|
+
if (generation !== this._generation)
|
|
2021
|
+
return;
|
|
2022
|
+
switch (outcome.kind) {
|
|
2023
|
+
case "ok":
|
|
2024
|
+
return;
|
|
2025
|
+
case "retry-later":
|
|
2026
|
+
this._mergeWindowBack(window);
|
|
2027
|
+
this._armFlushTimer();
|
|
2028
|
+
return;
|
|
2029
|
+
case "too-large":
|
|
2030
|
+
this._logger.warn("Metrics batch exceeded the server size limit and was dropped");
|
|
2031
|
+
return;
|
|
2032
|
+
case "fatal":
|
|
2033
|
+
this._logger.error("Failed to send metrics batch:", outcome.error);
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
_buildPayload(window) {
|
|
2038
|
+
return buildOtlpMetricsPayload(this._buildMetrics(window), buildMetricsResourceAttributes(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion()), this._instance.getLibraryId(), this._instance.getLibraryVersion());
|
|
2039
|
+
}
|
|
2040
|
+
_buildMetrics(window) {
|
|
2041
|
+
const nowNano = msToUnixNano(Date.now());
|
|
2042
|
+
const byMetric = new Map;
|
|
2043
|
+
for (const state of window.values()) {
|
|
2044
|
+
const metricKey = seriesKey(state.type, state.name, state.unit, undefined);
|
|
2045
|
+
let metric = byMetric.get(metricKey);
|
|
2046
|
+
if (!metric) {
|
|
2047
|
+
metric = {
|
|
2048
|
+
name: state.name,
|
|
2049
|
+
...state.unit && {
|
|
2050
|
+
unit: state.unit
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
if (state.type === "count")
|
|
2054
|
+
metric.sum = {
|
|
2055
|
+
aggregationTemporality: OTLP_TEMPORALITY_DELTA,
|
|
2056
|
+
isMonotonic: true,
|
|
2057
|
+
dataPoints: []
|
|
2058
|
+
};
|
|
2059
|
+
else if (state.type === "gauge")
|
|
2060
|
+
metric.gauge = {
|
|
2061
|
+
dataPoints: []
|
|
2062
|
+
};
|
|
2063
|
+
else
|
|
2064
|
+
metric.histogram = {
|
|
2065
|
+
aggregationTemporality: OTLP_TEMPORALITY_DELTA,
|
|
2066
|
+
dataPoints: []
|
|
2067
|
+
};
|
|
2068
|
+
byMetric.set(metricKey, metric);
|
|
2069
|
+
}
|
|
2070
|
+
const attributes = toOtlpKeyValueList(state.attributes ?? {}, this._logger);
|
|
2071
|
+
const startNano = msToUnixNano(state.windowStartMs);
|
|
2072
|
+
if (state.type === "count") {
|
|
2073
|
+
const dp = {
|
|
2074
|
+
attributes,
|
|
2075
|
+
startTimeUnixNano: startNano,
|
|
2076
|
+
timeUnixNano: nowNano,
|
|
2077
|
+
asDouble: state.total ?? 0
|
|
2078
|
+
};
|
|
2079
|
+
metric.sum.dataPoints.push(dp);
|
|
2080
|
+
} else if (state.type === "gauge") {
|
|
2081
|
+
const dp = {
|
|
2082
|
+
attributes,
|
|
2083
|
+
timeUnixNano: nowNano,
|
|
2084
|
+
asDouble: state.last ?? 0
|
|
2085
|
+
};
|
|
2086
|
+
metric.gauge.dataPoints.push(dp);
|
|
2087
|
+
} else if (state.hist) {
|
|
2088
|
+
const dp = {
|
|
2089
|
+
attributes,
|
|
2090
|
+
startTimeUnixNano: startNano,
|
|
2091
|
+
timeUnixNano: nowNano,
|
|
2092
|
+
count: state.hist.count,
|
|
2093
|
+
sum: state.hist.sum,
|
|
2094
|
+
min: state.hist.min,
|
|
2095
|
+
max: state.hist.max,
|
|
2096
|
+
bucketCounts: state.hist.bucketCounts,
|
|
2097
|
+
explicitBounds: DEFAULT_HISTOGRAM_BOUNDS
|
|
2098
|
+
};
|
|
2099
|
+
metric.histogram.dataPoints.push(dp);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
return Array.from(byMetric.values());
|
|
2103
|
+
}
|
|
2104
|
+
_mergeWindowBack(window) {
|
|
2105
|
+
for (const [key, old] of window) {
|
|
2106
|
+
const current = this._series.get(key);
|
|
2107
|
+
if (!current) {
|
|
2108
|
+
if (this._admitNewSeries())
|
|
2109
|
+
this._series.set(key, old);
|
|
2110
|
+
continue;
|
|
2111
|
+
}
|
|
2112
|
+
current.windowStartMs = Math.min(current.windowStartMs, old.windowStartMs);
|
|
2113
|
+
switch (current.type) {
|
|
2114
|
+
case "count":
|
|
2115
|
+
current.total = (current.total ?? 0) + (old.total ?? 0);
|
|
2116
|
+
break;
|
|
2117
|
+
case "gauge":
|
|
2118
|
+
break;
|
|
2119
|
+
case "histogram":
|
|
2120
|
+
if (old.hist)
|
|
2121
|
+
if (current.hist) {
|
|
2122
|
+
current.hist.count += old.hist.count;
|
|
2123
|
+
current.hist.sum += old.hist.sum;
|
|
2124
|
+
current.hist.min = Math.min(current.hist.min, old.hist.min);
|
|
2125
|
+
current.hist.max = Math.max(current.hist.max, old.hist.max);
|
|
2126
|
+
for (let i = 0;i < current.hist.bucketCounts.length; i++)
|
|
2127
|
+
current.hist.bucketCounts[i] += old.hist.bucketCounts[i];
|
|
2128
|
+
} else
|
|
2129
|
+
current.hist = old.hist;
|
|
2130
|
+
break;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/eventemitter.mjs
|
|
1349
2136
|
class SimpleEventEmitter {
|
|
1350
2137
|
constructor() {
|
|
1351
2138
|
this.events = {};
|
|
@@ -1367,37 +2154,7 @@ class SimpleEventEmitter {
|
|
|
1367
2154
|
}
|
|
1368
2155
|
}
|
|
1369
2156
|
|
|
1370
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1371
|
-
var exports_error_tracking = {};
|
|
1372
|
-
__export(exports_error_tracking, {
|
|
1373
|
-
winjsStackLineParser: () => winjsStackLineParser,
|
|
1374
|
-
stripReservedExceptionStepFields: () => stripReservedExceptionStepFields,
|
|
1375
|
-
reverseAndStripFrames: () => reverseAndStripFrames,
|
|
1376
|
-
resolveExceptionStepsConfig: () => resolveExceptionStepsConfig,
|
|
1377
|
-
opera11StackLineParser: () => opera11StackLineParser,
|
|
1378
|
-
opera10StackLineParser: () => opera10StackLineParser,
|
|
1379
|
-
nodeStackLineParser: () => nodeStackLineParser,
|
|
1380
|
-
getUtf8ByteLength: () => getUtf8ByteLength,
|
|
1381
|
-
geckoStackLineParser: () => geckoStackLineParser,
|
|
1382
|
-
createStackParser: () => createStackParser,
|
|
1383
|
-
createDefaultStackParser: () => createDefaultStackParser,
|
|
1384
|
-
chromeStackLineParser: () => chromeStackLineParser,
|
|
1385
|
-
StringCoercer: () => StringCoercer,
|
|
1386
|
-
ReduceableCache: () => ReduceableCache,
|
|
1387
|
-
PromiseRejectionEventCoercer: () => PromiseRejectionEventCoercer,
|
|
1388
|
-
PrimitiveCoercer: () => PrimitiveCoercer,
|
|
1389
|
-
ObjectCoercer: () => ObjectCoercer,
|
|
1390
|
-
ExceptionStepsBuffer: () => ExceptionStepsBuffer,
|
|
1391
|
-
EventCoercer: () => EventCoercer,
|
|
1392
|
-
ErrorPropertiesBuilder: () => ErrorPropertiesBuilder,
|
|
1393
|
-
ErrorEventCoercer: () => ErrorEventCoercer,
|
|
1394
|
-
ErrorCoercer: () => ErrorCoercer,
|
|
1395
|
-
EXCEPTION_STEP_INTERNAL_FIELDS: () => EXCEPTION_STEP_INTERNAL_FIELDS,
|
|
1396
|
-
DOMExceptionCoercer: () => DOMExceptionCoercer,
|
|
1397
|
-
DEFAULT_EXCEPTION_STEPS_CONFIG: () => DEFAULT_EXCEPTION_STEPS_CONFIG
|
|
1398
|
-
});
|
|
1399
|
-
|
|
1400
|
-
// ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
|
|
2157
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
|
|
1401
2158
|
var parsedStackResults;
|
|
1402
2159
|
var lastKeysCount;
|
|
1403
2160
|
var cachedFilenameChunkIds;
|
|
@@ -1436,7 +2193,7 @@ function getFilenameToChunkIdMap(stackParser) {
|
|
|
1436
2193
|
return cachedFilenameChunkIds;
|
|
1437
2194
|
}
|
|
1438
2195
|
|
|
1439
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2196
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
|
|
1440
2197
|
var MAX_CAUSE_RECURSION = 4;
|
|
1441
2198
|
|
|
1442
2199
|
class ErrorPropertiesBuilder {
|
|
@@ -1540,11 +2297,11 @@ class ErrorPropertiesBuilder {
|
|
|
1540
2297
|
return context;
|
|
1541
2298
|
}
|
|
1542
2299
|
buildCoercingContext(mechanism, hint, depth = 0) {
|
|
1543
|
-
const coerce = (input,
|
|
1544
|
-
if (!(
|
|
2300
|
+
const coerce = (input, depth) => {
|
|
2301
|
+
if (!(depth <= MAX_CAUSE_RECURSION))
|
|
1545
2302
|
return;
|
|
1546
2303
|
{
|
|
1547
|
-
const ctx = this.buildCoercingContext(mechanism, hint,
|
|
2304
|
+
const ctx = this.buildCoercingContext(mechanism, hint, depth);
|
|
1548
2305
|
return this.applyCoercers(input, ctx);
|
|
1549
2306
|
}
|
|
1550
2307
|
};
|
|
@@ -1558,14 +2315,16 @@ class ErrorPropertiesBuilder {
|
|
|
1558
2315
|
return context;
|
|
1559
2316
|
}
|
|
1560
2317
|
}
|
|
1561
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2318
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
|
|
1562
2319
|
var UNKNOWN_FUNCTION = "?";
|
|
2320
|
+
var MASKED_URL_PREFIX = "webkit-masked-url://";
|
|
2321
|
+
var ANONYMOUS_FILENAME = "<anonymous>";
|
|
1563
2322
|
function createFrame(platform, filename, func, lineno, colno) {
|
|
1564
2323
|
const frame = {
|
|
1565
2324
|
platform,
|
|
1566
2325
|
filename,
|
|
1567
2326
|
function: func === "<anonymous>" ? UNKNOWN_FUNCTION : func,
|
|
1568
|
-
in_app:
|
|
2327
|
+
in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
|
|
1569
2328
|
};
|
|
1570
2329
|
if (!isUndefined(lineno))
|
|
1571
2330
|
frame.lineno = lineno;
|
|
@@ -1574,7 +2333,7 @@ function createFrame(platform, filename, func, lineno, colno) {
|
|
|
1574
2333
|
return frame;
|
|
1575
2334
|
}
|
|
1576
2335
|
|
|
1577
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2336
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
|
|
1578
2337
|
var extractSafariExtensionDetails = (func, filename) => {
|
|
1579
2338
|
const isSafariExtension = func.indexOf("safari-extension") !== -1;
|
|
1580
2339
|
const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
|
|
@@ -1587,15 +2346,15 @@ var extractSafariExtensionDetails = (func, filename) => {
|
|
|
1587
2346
|
];
|
|
1588
2347
|
};
|
|
1589
2348
|
|
|
1590
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2349
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
|
|
1591
2350
|
var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
|
|
1592
2351
|
var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
1593
2352
|
var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
|
1594
2353
|
var chromeStackLineParser = (line, platform) => {
|
|
1595
2354
|
const noFnParts = chromeRegexNoFnName.exec(line);
|
|
1596
2355
|
if (noFnParts) {
|
|
1597
|
-
const [, filename,
|
|
1598
|
-
return createFrame(platform, filename, UNKNOWN_FUNCTION, +
|
|
2356
|
+
const [, filename, line, col] = noFnParts;
|
|
2357
|
+
return createFrame(platform, filename, UNKNOWN_FUNCTION, +line, +col);
|
|
1599
2358
|
}
|
|
1600
2359
|
const parts = chromeRegex.exec(line);
|
|
1601
2360
|
if (parts) {
|
|
@@ -1613,7 +2372,7 @@ var chromeStackLineParser = (line, platform) => {
|
|
|
1613
2372
|
}
|
|
1614
2373
|
};
|
|
1615
2374
|
|
|
1616
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2375
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
|
|
1617
2376
|
var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
1618
2377
|
var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
1619
2378
|
var geckoStackLineParser = (line, platform) => {
|
|
@@ -1636,28 +2395,12 @@ var geckoStackLineParser = (line, platform) => {
|
|
|
1636
2395
|
}
|
|
1637
2396
|
};
|
|
1638
2397
|
|
|
1639
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1640
|
-
var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1641
|
-
var winjsStackLineParser = (line, platform) => {
|
|
1642
|
-
const parts = winjsRegex.exec(line);
|
|
1643
|
-
return parts ? createFrame(platform, parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined) : undefined;
|
|
1644
|
-
};
|
|
1645
|
-
|
|
1646
|
-
// ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
|
|
1647
|
-
var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
|
|
1648
|
-
var opera10StackLineParser = (line, platform) => {
|
|
1649
|
-
const parts = opera10Regex.exec(line);
|
|
1650
|
-
return parts ? createFrame(platform, parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
|
|
1651
|
-
};
|
|
1652
|
-
var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
|
|
1653
|
-
var opera11StackLineParser = (line, platform) => {
|
|
1654
|
-
const parts = opera11Regex.exec(line);
|
|
1655
|
-
return parts ? createFrame(platform, parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
|
|
1656
|
-
};
|
|
1657
|
-
|
|
1658
|
-
// ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
|
|
2398
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
|
|
1659
2399
|
var FILENAME_MATCH = /^\s*[-]{4,}$/;
|
|
1660
2400
|
var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
|
|
2401
|
+
var PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
|
|
2402
|
+
var PROMISE_INDEX = /^index \d+$/;
|
|
2403
|
+
var PROMISE_FRAME_FILENAME = "node:internal/promise";
|
|
1661
2404
|
var nodeStackLineParser = (line, platform) => {
|
|
1662
2405
|
const lineMatch = line.match(FULL_MATCH);
|
|
1663
2406
|
if (lineMatch) {
|
|
@@ -1700,6 +2443,8 @@ var nodeStackLineParser = (line, platform) => {
|
|
|
1700
2443
|
filename = filename.slice(1);
|
|
1701
2444
|
if (!filename && lineMatch[5] && !isNative)
|
|
1702
2445
|
filename = lineMatch[5];
|
|
2446
|
+
if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || ""))
|
|
2447
|
+
filename = PROMISE_FRAME_FILENAME;
|
|
1703
2448
|
return {
|
|
1704
2449
|
filename: filename ? decodeURI(filename) : undefined,
|
|
1705
2450
|
module: undefined,
|
|
@@ -1724,7 +2469,7 @@ function _parseIntOrUndefined(input) {
|
|
|
1724
2469
|
return parseInt(input || "", 10) || undefined;
|
|
1725
2470
|
}
|
|
1726
2471
|
|
|
1727
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2472
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
|
|
1728
2473
|
var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
1729
2474
|
var STACKTRACE_FRAME_LIMIT = 50;
|
|
1730
2475
|
function reverseAndStripFrames(stack) {
|
|
@@ -1769,48 +2514,20 @@ function createStackParser(platform, ...parsers) {
|
|
|
1769
2514
|
return reverseAndStripFrames(frames);
|
|
1770
2515
|
};
|
|
1771
2516
|
}
|
|
1772
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1773
|
-
class DOMExceptionCoercer {
|
|
1774
|
-
match(err) {
|
|
1775
|
-
return this.isDOMException(err) || this.isDOMError(err);
|
|
1776
|
-
}
|
|
1777
|
-
coerce(err, ctx) {
|
|
1778
|
-
const hasStack = isString(err.stack);
|
|
1779
|
-
return {
|
|
1780
|
-
type: this.getType(err),
|
|
1781
|
-
value: this.getValue(err),
|
|
1782
|
-
stack: hasStack ? err.stack : undefined,
|
|
1783
|
-
cause: err.cause ? ctx.next(err.cause) : undefined,
|
|
1784
|
-
synthetic: false
|
|
1785
|
-
};
|
|
1786
|
-
}
|
|
1787
|
-
getType(candidate) {
|
|
1788
|
-
return this.isDOMError(candidate) ? "DOMError" : "DOMException";
|
|
1789
|
-
}
|
|
1790
|
-
getValue(err) {
|
|
1791
|
-
const name = err.name || (this.isDOMError(err) ? "DOMError" : "DOMException");
|
|
1792
|
-
const message = err.message ? `${name}: ${err.message}` : name;
|
|
1793
|
-
return message;
|
|
1794
|
-
}
|
|
1795
|
-
isDOMException(err) {
|
|
1796
|
-
return isBuiltin(err, "DOMException");
|
|
1797
|
-
}
|
|
1798
|
-
isDOMError(err) {
|
|
1799
|
-
return isBuiltin(err, "DOMError");
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
// ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
|
|
2517
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
|
|
1803
2518
|
class ErrorCoercer {
|
|
1804
2519
|
match(err) {
|
|
1805
|
-
return
|
|
2520
|
+
return isError(err);
|
|
1806
2521
|
}
|
|
1807
2522
|
coerce(err, ctx) {
|
|
2523
|
+
const stack = this.getStack(err);
|
|
2524
|
+
const synthetic = stack === undefined;
|
|
1808
2525
|
return {
|
|
1809
2526
|
type: this.getType(err),
|
|
1810
2527
|
value: this.getMessage(err, ctx),
|
|
1811
|
-
stack:
|
|
2528
|
+
stack: stack ?? ctx.syntheticException?.stack,
|
|
1812
2529
|
cause: err.cause ? ctx.next(err.cause) : undefined,
|
|
1813
|
-
synthetic
|
|
2530
|
+
synthetic
|
|
1814
2531
|
};
|
|
1815
2532
|
}
|
|
1816
2533
|
getType(err) {
|
|
@@ -1826,25 +2543,7 @@ class ErrorCoercer {
|
|
|
1826
2543
|
return err.stacktrace || err.stack || undefined;
|
|
1827
2544
|
}
|
|
1828
2545
|
}
|
|
1829
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1830
|
-
class ErrorEventCoercer {
|
|
1831
|
-
constructor() {}
|
|
1832
|
-
match(err) {
|
|
1833
|
-
return isErrorEvent(err) && err.error != null;
|
|
1834
|
-
}
|
|
1835
|
-
coerce(err, ctx) {
|
|
1836
|
-
const exceptionLike = ctx.apply(err.error);
|
|
1837
|
-
if (!exceptionLike)
|
|
1838
|
-
return {
|
|
1839
|
-
type: "ErrorEvent",
|
|
1840
|
-
value: err.message,
|
|
1841
|
-
stack: ctx.syntheticException?.stack,
|
|
1842
|
-
synthetic: true
|
|
1843
|
-
};
|
|
1844
|
-
return exceptionLike;
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
// ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
|
|
2546
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
|
|
1848
2547
|
var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
|
|
1849
2548
|
|
|
1850
2549
|
class StringCoercer {
|
|
@@ -1874,7 +2573,7 @@ class StringCoercer {
|
|
|
1874
2573
|
];
|
|
1875
2574
|
}
|
|
1876
2575
|
}
|
|
1877
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2576
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/types.mjs
|
|
1878
2577
|
var severityLevels = [
|
|
1879
2578
|
"fatal",
|
|
1880
2579
|
"error",
|
|
@@ -1884,7 +2583,7 @@ var severityLevels = [
|
|
|
1884
2583
|
"debug"
|
|
1885
2584
|
];
|
|
1886
2585
|
|
|
1887
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2586
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
|
|
1888
2587
|
function extractExceptionKeysForMessage(err, maxLength = 40) {
|
|
1889
2588
|
const keys = Object.keys(err);
|
|
1890
2589
|
keys.sort();
|
|
@@ -1901,7 +2600,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
|
|
|
1901
2600
|
return "";
|
|
1902
2601
|
}
|
|
1903
2602
|
|
|
1904
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2603
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
|
|
1905
2604
|
class ObjectCoercer {
|
|
1906
2605
|
match(candidate) {
|
|
1907
2606
|
return typeof candidate == "object" && candidate !== null;
|
|
@@ -1913,13 +2612,16 @@ class ObjectCoercer {
|
|
|
1913
2612
|
return {
|
|
1914
2613
|
type: this.getType(candidate),
|
|
1915
2614
|
value: this.getValue(candidate),
|
|
1916
|
-
stack: ctx.syntheticException?.stack,
|
|
2615
|
+
stack: this.getStack(candidate) ?? ctx.syntheticException?.stack,
|
|
1917
2616
|
level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
|
|
1918
2617
|
synthetic: true
|
|
1919
2618
|
};
|
|
1920
2619
|
}
|
|
1921
2620
|
getType(err) {
|
|
1922
|
-
|
|
2621
|
+
if (isEvent(err))
|
|
2622
|
+
return err.constructor.name;
|
|
2623
|
+
const name = "name" in err ? err.name : undefined;
|
|
2624
|
+
return isString(name) && !isEmptyString(name) ? name : "Error";
|
|
1923
2625
|
}
|
|
1924
2626
|
getValue(err) {
|
|
1925
2627
|
if ("name" in err && typeof err.name == "string") {
|
|
@@ -1937,6 +2639,15 @@ class ObjectCoercer {
|
|
|
1937
2639
|
isSeverityLevel(x) {
|
|
1938
2640
|
return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
|
|
1939
2641
|
}
|
|
2642
|
+
getStack(candidate) {
|
|
2643
|
+
try {
|
|
2644
|
+
if (isString(candidate.stacktrace) && candidate.stacktrace.length > 0)
|
|
2645
|
+
return candidate.stacktrace;
|
|
2646
|
+
return isString(candidate.stack) && candidate.stack.length > 0 ? candidate.stack : undefined;
|
|
2647
|
+
} catch {
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
1940
2651
|
getErrorPropertyFromObject(obj) {
|
|
1941
2652
|
for (const prop in obj)
|
|
1942
2653
|
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
@@ -1954,7 +2665,7 @@ class ObjectCoercer {
|
|
|
1954
2665
|
}
|
|
1955
2666
|
}
|
|
1956
2667
|
}
|
|
1957
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2668
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
|
|
1958
2669
|
class EventCoercer {
|
|
1959
2670
|
match(err) {
|
|
1960
2671
|
return isEvent(err);
|
|
@@ -1969,7 +2680,7 @@ class EventCoercer {
|
|
|
1969
2680
|
};
|
|
1970
2681
|
}
|
|
1971
2682
|
}
|
|
1972
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2683
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
|
|
1973
2684
|
class PrimitiveCoercer {
|
|
1974
2685
|
match(candidate) {
|
|
1975
2686
|
return isPrimitive(candidate);
|
|
@@ -1983,43 +2694,7 @@ class PrimitiveCoercer {
|
|
|
1983
2694
|
};
|
|
1984
2695
|
}
|
|
1985
2696
|
}
|
|
1986
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
1987
|
-
class PromiseRejectionEventCoercer {
|
|
1988
|
-
match(err) {
|
|
1989
|
-
return isBuiltin(err, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(err);
|
|
1990
|
-
}
|
|
1991
|
-
isCustomEventWrappingRejection(err) {
|
|
1992
|
-
if (!isEvent(err))
|
|
1993
|
-
return false;
|
|
1994
|
-
try {
|
|
1995
|
-
const detail = err.detail;
|
|
1996
|
-
return detail != null && typeof detail == "object" && "reason" in detail;
|
|
1997
|
-
} catch {
|
|
1998
|
-
return false;
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
coerce(err, ctx) {
|
|
2002
|
-
const reason = this.getUnhandledRejectionReason(err);
|
|
2003
|
-
if (isPrimitive(reason))
|
|
2004
|
-
return {
|
|
2005
|
-
type: "UnhandledRejection",
|
|
2006
|
-
value: `Non-Error promise rejection captured with value: ${String(reason)}`,
|
|
2007
|
-
stack: ctx.syntheticException?.stack,
|
|
2008
|
-
synthetic: true
|
|
2009
|
-
};
|
|
2010
|
-
return ctx.apply(reason);
|
|
2011
|
-
}
|
|
2012
|
-
getUnhandledRejectionReason(error) {
|
|
2013
|
-
try {
|
|
2014
|
-
if ("reason" in error)
|
|
2015
|
-
return error.reason;
|
|
2016
|
-
if ("detail" in error && error.detail != null && typeof error.detail == "object" && "reason" in error.detail)
|
|
2017
|
-
return error.detail.reason;
|
|
2018
|
-
} catch {}
|
|
2019
|
-
return error;
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
// ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/utils.mjs
|
|
2697
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/utils.mjs
|
|
2023
2698
|
class ReduceableCache {
|
|
2024
2699
|
constructor(_maxSize) {
|
|
2025
2700
|
this._maxSize = _maxSize;
|
|
@@ -2044,7 +2719,7 @@ class ReduceableCache {
|
|
|
2044
2719
|
}
|
|
2045
2720
|
}
|
|
2046
2721
|
}
|
|
2047
|
-
// ../../../node_modules/.bun/@posthog+core@1.
|
|
2722
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
|
|
2048
2723
|
var EXCEPTION_STEP_INTERNAL_FIELDS = {
|
|
2049
2724
|
MESSAGE: "$message",
|
|
2050
2725
|
TIMESTAMP: "$timestamp"
|
|
@@ -2053,167 +2728,65 @@ var RESERVED_EXCEPTION_STEP_KEYS = new Set([
|
|
|
2053
2728
|
EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
|
|
2054
2729
|
EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
|
|
2055
2730
|
]);
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
function resolveExceptionStepsConfig(config) {
|
|
2061
|
-
if (!config)
|
|
2062
|
-
return {
|
|
2063
|
-
...DEFAULT_EXCEPTION_STEPS_CONFIG
|
|
2064
|
-
};
|
|
2065
|
-
return {
|
|
2066
|
-
enabled: config.enabled ?? DEFAULT_EXCEPTION_STEPS_CONFIG.enabled,
|
|
2067
|
-
max_bytes: normalizePositiveInteger(config.max_bytes, DEFAULT_EXCEPTION_STEPS_CONFIG.max_bytes)
|
|
2068
|
-
};
|
|
2069
|
-
}
|
|
2070
|
-
function stripReservedExceptionStepFields(properties) {
|
|
2071
|
-
if (!properties)
|
|
2072
|
-
return {
|
|
2073
|
-
sanitizedProperties: {},
|
|
2074
|
-
droppedKeys: []
|
|
2075
|
-
};
|
|
2076
|
-
const droppedKeys = [];
|
|
2077
|
-
const sanitizedProperties = Object.keys(properties).reduce((acc, key) => {
|
|
2078
|
-
if (RESERVED_EXCEPTION_STEP_KEYS.has(key)) {
|
|
2079
|
-
droppedKeys.push(key);
|
|
2080
|
-
return acc;
|
|
2081
|
-
}
|
|
2082
|
-
acc[key] = properties[key];
|
|
2083
|
-
return acc;
|
|
2084
|
-
}, {});
|
|
2085
|
-
return {
|
|
2086
|
-
sanitizedProperties,
|
|
2087
|
-
droppedKeys
|
|
2088
|
-
};
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
class ExceptionStepsBuffer {
|
|
2092
|
-
constructor(config) {
|
|
2093
|
-
this._entries = [];
|
|
2094
|
-
this._totalBytes = 0;
|
|
2095
|
-
this._config = resolveExceptionStepsConfig(config);
|
|
2096
|
-
}
|
|
2097
|
-
setConfig(config) {
|
|
2098
|
-
this._config = resolveExceptionStepsConfig(config);
|
|
2099
|
-
this._trimToMaxBytes();
|
|
2100
|
-
}
|
|
2101
|
-
add(step) {
|
|
2102
|
-
const serialized = normalizeAndSerializeStep(step);
|
|
2103
|
-
if (!serialized)
|
|
2104
|
-
return;
|
|
2105
|
-
const bytes = getUtf8ByteLength(serialized.json);
|
|
2106
|
-
if (bytes > this._config.max_bytes)
|
|
2107
|
-
return;
|
|
2108
|
-
this._entries.push({
|
|
2109
|
-
step: serialized.step,
|
|
2110
|
-
bytes
|
|
2111
|
-
});
|
|
2112
|
-
this._totalBytes += bytes;
|
|
2113
|
-
this._trimToMaxBytes();
|
|
2114
|
-
}
|
|
2115
|
-
getAttachable() {
|
|
2116
|
-
return this._entries.map((e) => e.step);
|
|
2117
|
-
}
|
|
2118
|
-
clear() {
|
|
2119
|
-
this._entries = [];
|
|
2120
|
-
this._totalBytes = 0;
|
|
2121
|
-
}
|
|
2122
|
-
size() {
|
|
2123
|
-
return this._entries.length;
|
|
2124
|
-
}
|
|
2125
|
-
_trimToMaxBytes() {
|
|
2126
|
-
while (this._totalBytes > this._config.max_bytes && this._entries.length > 0) {
|
|
2127
|
-
const evicted = this._entries.shift();
|
|
2128
|
-
if (evicted)
|
|
2129
|
-
this._totalBytes -= evicted.bytes;
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
function normalizePositiveInteger(input, fallback) {
|
|
2134
|
-
if (!isNumber(input) || input === 1 / 0 || input === -1 / 0)
|
|
2135
|
-
return fallback;
|
|
2136
|
-
const normalized = Math.floor(input);
|
|
2137
|
-
if (normalized < 0)
|
|
2138
|
-
return fallback;
|
|
2139
|
-
return normalized;
|
|
2140
|
-
}
|
|
2141
|
-
function normalizeAndSerializeStep(step) {
|
|
2142
|
-
const json = safeStringify(step);
|
|
2143
|
-
if (!json)
|
|
2144
|
-
return;
|
|
2145
|
-
try {
|
|
2146
|
-
const parsed = JSON.parse(json);
|
|
2147
|
-
if (!isObject(parsed))
|
|
2148
|
-
return;
|
|
2149
|
-
const parsedStep = parsed;
|
|
2150
|
-
const message = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE];
|
|
2151
|
-
const timestamp = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP];
|
|
2152
|
-
if (!isString(message) || message.trim().length === 0)
|
|
2153
|
-
return;
|
|
2154
|
-
if (!isString(timestamp) && !isNumber(timestamp))
|
|
2155
|
-
return;
|
|
2156
|
-
return {
|
|
2157
|
-
step: parsedStep,
|
|
2158
|
-
json
|
|
2159
|
-
};
|
|
2160
|
-
} catch {
|
|
2161
|
-
return;
|
|
2162
|
-
}
|
|
2731
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/release.mjs
|
|
2732
|
+
function getInjectedReleaseId() {
|
|
2733
|
+
const injected = globalThis._posthogReleaseId;
|
|
2734
|
+
return typeof injected == "string" && injected.length > 0 ? injected : undefined;
|
|
2163
2735
|
}
|
|
2164
|
-
|
|
2165
|
-
const seen = new WeakSet;
|
|
2166
|
-
try {
|
|
2167
|
-
return JSON.stringify(value, (_key, replacementValue) => {
|
|
2168
|
-
if (typeof replacementValue == "bigint")
|
|
2169
|
-
return replacementValue.toString();
|
|
2170
|
-
if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
|
|
2171
|
-
return;
|
|
2172
|
-
if (replacementValue instanceof Date)
|
|
2173
|
-
return replacementValue.toISOString();
|
|
2174
|
-
if (replacementValue instanceof Error)
|
|
2175
|
-
return {
|
|
2176
|
-
name: replacementValue.name,
|
|
2177
|
-
message: replacementValue.message,
|
|
2178
|
-
stack: replacementValue.stack
|
|
2179
|
-
};
|
|
2180
|
-
if (replacementValue && typeof replacementValue == "object") {
|
|
2181
|
-
if (seen.has(replacementValue))
|
|
2182
|
-
return "[Circular]";
|
|
2183
|
-
seen.add(replacementValue);
|
|
2184
|
-
}
|
|
2185
|
-
return replacementValue;
|
|
2186
|
-
});
|
|
2187
|
-
} catch {
|
|
2188
|
-
return;
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
function getUtf8ByteLength(value) {
|
|
2192
|
-
if (typeof TextEncoder != "undefined")
|
|
2193
|
-
return new TextEncoder().encode(value).length;
|
|
2194
|
-
const encoded = encodeURIComponent(value);
|
|
2195
|
-
let byteLength = 0;
|
|
2196
|
-
for (let i = 0;i < encoded.length; i++)
|
|
2197
|
-
if (encoded[i] === "%") {
|
|
2198
|
-
byteLength += 1;
|
|
2199
|
-
i += 2;
|
|
2200
|
-
} else
|
|
2201
|
-
byteLength += 1;
|
|
2202
|
-
return byteLength;
|
|
2203
|
-
}
|
|
2204
|
-
// ../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
|
|
2736
|
+
// ../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
|
|
2205
2737
|
class PostHogFetchHttpError extends Error {
|
|
2206
|
-
constructor(response, reqByteLength) {
|
|
2207
|
-
super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
|
|
2738
|
+
constructor(response, reqByteLength, responseBodyDeadline, abortController) {
|
|
2739
|
+
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;
|
|
2208
2740
|
}
|
|
2209
2741
|
get status() {
|
|
2210
2742
|
return this.response.status;
|
|
2211
2743
|
}
|
|
2744
|
+
get bodyReadTimedOut() {
|
|
2745
|
+
return this._bodyReadTimedOut;
|
|
2746
|
+
}
|
|
2212
2747
|
get text() {
|
|
2213
|
-
|
|
2748
|
+
if (!this.responseBodyTextPromise)
|
|
2749
|
+
if (Date.now() >= this.responseBodyDeadline) {
|
|
2750
|
+
this._bodyReadTimedOut = true;
|
|
2751
|
+
const timeoutError = new Error("Response body read timed out");
|
|
2752
|
+
timeoutError.name = "AbortError";
|
|
2753
|
+
this.cancelResponseBody(timeoutError);
|
|
2754
|
+
this.responseBodyTextPromise = Promise.reject(timeoutError);
|
|
2755
|
+
} else {
|
|
2756
|
+
const responseBodyTimeout = new Promise((_resolve, reject) => {
|
|
2757
|
+
this.responseBodyTimer = safeSetTimeout(() => {
|
|
2758
|
+
this._bodyReadTimedOut = true;
|
|
2759
|
+
const timeoutError = new Error("Response body read timed out");
|
|
2760
|
+
timeoutError.name = "AbortError";
|
|
2761
|
+
reject(timeoutError);
|
|
2762
|
+
this.cancelResponseBody(timeoutError);
|
|
2763
|
+
}, this.responseBodyDeadline - Date.now());
|
|
2764
|
+
});
|
|
2765
|
+
let responseBodyText;
|
|
2766
|
+
try {
|
|
2767
|
+
responseBodyText = Promise.resolve(this.response.text());
|
|
2768
|
+
} catch (error) {
|
|
2769
|
+
responseBodyText = Promise.reject(error);
|
|
2770
|
+
}
|
|
2771
|
+
this.responseBodyTextPromise = Promise.race([
|
|
2772
|
+
responseBodyText,
|
|
2773
|
+
responseBodyTimeout
|
|
2774
|
+
]).finally(() => clearTimeout(this.responseBodyTimer));
|
|
2775
|
+
}
|
|
2776
|
+
return this.responseBodyTextPromise;
|
|
2214
2777
|
}
|
|
2215
2778
|
get json() {
|
|
2216
|
-
return this.
|
|
2779
|
+
return this.text.then((text) => JSON.parse(text));
|
|
2780
|
+
}
|
|
2781
|
+
cancelResponseBody(reason) {
|
|
2782
|
+
clearTimeout(this.responseBodyTimer);
|
|
2783
|
+
if (!this.abortController.signal.aborted)
|
|
2784
|
+
this.abortController.abort(reason);
|
|
2785
|
+
(async () => {
|
|
2786
|
+
try {
|
|
2787
|
+
await this.response.body?.cancel();
|
|
2788
|
+
} catch {}
|
|
2789
|
+
})();
|
|
2217
2790
|
}
|
|
2218
2791
|
}
|
|
2219
2792
|
|
|
@@ -2224,12 +2797,20 @@ class PostHogFetchNetworkError extends Error {
|
|
|
2224
2797
|
} : {}), this.error = error, this.name = "PostHogFetchNetworkError";
|
|
2225
2798
|
}
|
|
2226
2799
|
}
|
|
2800
|
+
var applyCallerFeatureFlagOverrides = (target, callerProperties) => {
|
|
2801
|
+
for (const key of Object.keys(callerProperties))
|
|
2802
|
+
if (key.startsWith("$feature/") || key === "$active_feature_flags")
|
|
2803
|
+
target[key] = callerProperties[key];
|
|
2804
|
+
};
|
|
2227
2805
|
async function logFlushError(err) {
|
|
2228
2806
|
if (err instanceof PostHogFetchHttpError) {
|
|
2229
2807
|
let text = "";
|
|
2230
2808
|
try {
|
|
2231
2809
|
text = await err.text;
|
|
2232
|
-
} catch {
|
|
2810
|
+
} catch {
|
|
2811
|
+
if (err.bodyReadTimedOut)
|
|
2812
|
+
text = "<response body read timed out>";
|
|
2813
|
+
}
|
|
2233
2814
|
console.error(`Error while flushing PostHog: message=${err.message}, response body=${text}`, err);
|
|
2234
2815
|
} else
|
|
2235
2816
|
console.error("Error while flushing PostHog", err);
|
|
@@ -2241,9 +2822,28 @@ function isPostHogFetchError(err) {
|
|
|
2241
2822
|
function isPostHogFetchNetworkError(err) {
|
|
2242
2823
|
return err instanceof PostHogFetchNetworkError;
|
|
2243
2824
|
}
|
|
2825
|
+
function isRetryableFlagsFetchError(err) {
|
|
2826
|
+
if (err instanceof PostHogFetchHttpError)
|
|
2827
|
+
return err.status === 502 || err.status === 504;
|
|
2828
|
+
if (!(err instanceof PostHogFetchNetworkError))
|
|
2829
|
+
return false;
|
|
2830
|
+
const cause = err.error;
|
|
2831
|
+
const code = cause?.code ?? cause?.cause?.code;
|
|
2832
|
+
return code !== "ECONNREFUSED";
|
|
2833
|
+
}
|
|
2244
2834
|
function isPostHogFetchContentTooLargeError(err) {
|
|
2245
2835
|
return typeof err == "object" && err instanceof PostHogFetchHttpError && err.status === 413;
|
|
2246
2836
|
}
|
|
2837
|
+
function isPostHogFetchRetryableError(err) {
|
|
2838
|
+
if (err instanceof PostHogFetchHttpError)
|
|
2839
|
+
return err.status === 408 || err.status === 429 || err.status >= 500;
|
|
2840
|
+
return isPostHogFetchNetworkError(err);
|
|
2841
|
+
}
|
|
2842
|
+
function isPostHogEventProperties(value) {
|
|
2843
|
+
return value !== null && typeof value == "object" && !Array.isArray(value);
|
|
2844
|
+
}
|
|
2845
|
+
var DEFAULT_QUEUE_ROUTE = "default";
|
|
2846
|
+
|
|
2247
2847
|
class PostHogCoreStateless {
|
|
2248
2848
|
getErrorPropertiesBuilder() {
|
|
2249
2849
|
if (!this._errorPropertiesBuilder)
|
|
@@ -2260,6 +2860,9 @@ class PostHogCoreStateless {
|
|
|
2260
2860
|
}
|
|
2261
2861
|
constructor(apiKey, options = {}) {
|
|
2262
2862
|
this.flushPromise = null;
|
|
2863
|
+
this.pendingFlushPromise = null;
|
|
2864
|
+
this.flushPromises = new Set;
|
|
2865
|
+
this._dequeuedMessagesCount = 0;
|
|
2263
2866
|
this.shutdownPromise = null;
|
|
2264
2867
|
this.promiseQueue = new PromiseQueue;
|
|
2265
2868
|
this._events = new SimpleEventEmitter;
|
|
@@ -2282,10 +2885,11 @@ class PostHogCoreStateless {
|
|
|
2282
2885
|
this._retryOptions = {
|
|
2283
2886
|
retryCount: options.fetchRetryCount ?? 3,
|
|
2284
2887
|
retryDelay: options.fetchRetryDelay ?? 3000,
|
|
2285
|
-
retryCheck:
|
|
2888
|
+
retryCheck: isPostHogFetchRetryableError
|
|
2286
2889
|
};
|
|
2287
2890
|
this.requestTimeout = options.requestTimeout ?? 1e4;
|
|
2288
2891
|
this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3000;
|
|
2892
|
+
this.featureFlagsRequestMaxRetries = options.featureFlagsRequestMaxRetries ?? 1;
|
|
2289
2893
|
this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3000;
|
|
2290
2894
|
this.disableGeoip = options.disableGeoip ?? true;
|
|
2291
2895
|
this.disabled = (options.disabled ?? false) || missingApiKey;
|
|
@@ -2347,15 +2951,23 @@ class PostHogCoreStateless {
|
|
|
2347
2951
|
return this.disabled;
|
|
2348
2952
|
}
|
|
2349
2953
|
buildPayload(payload) {
|
|
2954
|
+
const userProperties = payload.properties || {};
|
|
2955
|
+
let properties = {
|
|
2956
|
+
...userProperties,
|
|
2957
|
+
...this.getCommonEventProperties()
|
|
2958
|
+
};
|
|
2959
|
+
applyCallerFeatureFlagOverrides(properties, userProperties);
|
|
2960
|
+
if (payload.event === "$feature_flag_called" && properties.$feature_flag_has_experiment === false && this.isMinimalFlagCalledEventsEnabled())
|
|
2961
|
+
properties = minimizeFlagCalledEventProperties(properties);
|
|
2350
2962
|
return {
|
|
2351
2963
|
distinct_id: payload.distinct_id,
|
|
2352
2964
|
event: payload.event,
|
|
2353
|
-
properties
|
|
2354
|
-
...payload.properties || {},
|
|
2355
|
-
...this.getCommonEventProperties()
|
|
2356
|
-
}
|
|
2965
|
+
properties
|
|
2357
2966
|
};
|
|
2358
2967
|
}
|
|
2968
|
+
isMinimalFlagCalledEventsEnabled() {
|
|
2969
|
+
return false;
|
|
2970
|
+
}
|
|
2359
2971
|
addPendingPromise(promise) {
|
|
2360
2972
|
return this.promiseQueue.add(promise);
|
|
2361
2973
|
}
|
|
@@ -2440,6 +3052,19 @@ class PostHogCoreStateless {
|
|
|
2440
3052
|
this.enqueue("capture", payload, options);
|
|
2441
3053
|
});
|
|
2442
3054
|
}
|
|
3055
|
+
async groupIdentifyStatelessImmediate(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
|
|
3056
|
+
const payload = this.buildPayload({
|
|
3057
|
+
distinct_id: distinctId || `$${groupType}_${groupKey}`,
|
|
3058
|
+
event: "$groupidentify",
|
|
3059
|
+
properties: {
|
|
3060
|
+
$group_type: groupType,
|
|
3061
|
+
$group_key: groupKey,
|
|
3062
|
+
$group_set: groupProperties || {},
|
|
3063
|
+
...eventProperties || {}
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
await this.sendImmediate("capture", payload, options);
|
|
3067
|
+
}
|
|
2443
3068
|
async getRemoteConfig() {
|
|
2444
3069
|
await this._initPromise;
|
|
2445
3070
|
let host = this.host;
|
|
@@ -2456,8 +3081,11 @@ class PostHogCoreStateless {
|
|
|
2456
3081
|
}
|
|
2457
3082
|
};
|
|
2458
3083
|
return this.fetchWithRetry(url, fetchOptions, {
|
|
3084
|
+
type: "required",
|
|
3085
|
+
consume: (response) => response.json()
|
|
3086
|
+
}, {
|
|
2459
3087
|
retryCount: 0
|
|
2460
|
-
}, this.remoteConfigRequestTimeoutMs).
|
|
3088
|
+
}, this.remoteConfigRequestTimeoutMs).catch((error) => {
|
|
2461
3089
|
this._logger.error("Remote config could not be loaded", error);
|
|
2462
3090
|
this._events.emit("error", error);
|
|
2463
3091
|
});
|
|
@@ -2488,8 +3116,12 @@ class PostHogCoreStateless {
|
|
|
2488
3116
|
};
|
|
2489
3117
|
this._logger.info("Flags URL", url);
|
|
2490
3118
|
return this.fetchWithRetry(url, fetchOptions, {
|
|
2491
|
-
|
|
2492
|
-
|
|
3119
|
+
type: "required",
|
|
3120
|
+
consume: (response) => response.json()
|
|
3121
|
+
}, {
|
|
3122
|
+
retryCount: this.featureFlagsRequestMaxRetries,
|
|
3123
|
+
retryCheck: isRetryableFlagsFetchError
|
|
3124
|
+
}, this.featureFlagsRequestTimeoutMs).then((response) => ({
|
|
2493
3125
|
success: true,
|
|
2494
3126
|
response: normalizeFlagsResponse(response)
|
|
2495
3127
|
})).catch((error) => {
|
|
@@ -2589,9 +3221,9 @@ class PostHogCoreStateless {
|
|
|
2589
3221
|
}
|
|
2590
3222
|
async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
|
|
2591
3223
|
await this._initPromise;
|
|
2592
|
-
const extraPayload = {
|
|
2593
|
-
|
|
2594
|
-
|
|
3224
|
+
const extraPayload = {
|
|
3225
|
+
geoip_disable: disableGeoip ?? this.disableGeoip
|
|
3226
|
+
};
|
|
2595
3227
|
if (flagKeysToEvaluate)
|
|
2596
3228
|
extraPayload["flag_keys_to_evaluate"] = flagKeysToEvaluate;
|
|
2597
3229
|
const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
|
|
@@ -2628,15 +3260,18 @@ class PostHogCoreStateless {
|
|
|
2628
3260
|
"Content-Type": "application/json"
|
|
2629
3261
|
}
|
|
2630
3262
|
};
|
|
2631
|
-
const response = await this.fetchWithRetry(url, fetchOptions
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
3263
|
+
const response = await this.fetchWithRetry(url, fetchOptions, {
|
|
3264
|
+
type: "required",
|
|
3265
|
+
consume: (response) => {
|
|
3266
|
+
if (response.status !== 200 || !response.json) {
|
|
3267
|
+
const msg = `Surveys API could not be loaded: ${response.status}`;
|
|
3268
|
+
const error = new Error(msg);
|
|
3269
|
+
this._logger.error(error);
|
|
3270
|
+
this._events.emit("error", new Error(msg));
|
|
3271
|
+
return Promise.resolve(undefined);
|
|
3272
|
+
}
|
|
3273
|
+
return response.json();
|
|
2638
3274
|
}
|
|
2639
|
-
return response2.json();
|
|
2640
3275
|
}).catch((error) => {
|
|
2641
3276
|
this._logger.error("Surveys API could not be loaded", error);
|
|
2642
3277
|
this._events.emit("error", error);
|
|
@@ -2673,23 +3308,39 @@ class PostHogCoreStateless {
|
|
|
2673
3308
|
return message;
|
|
2674
3309
|
}
|
|
2675
3310
|
async flushStorage() {}
|
|
2676
|
-
|
|
3311
|
+
getQueueRouteKey(_message) {
|
|
3312
|
+
return DEFAULT_QUEUE_ROUTE;
|
|
3313
|
+
}
|
|
3314
|
+
persistedQueueKeyForRoute(_route) {
|
|
3315
|
+
return types_PostHogPersistedProperty.Queue;
|
|
3316
|
+
}
|
|
3317
|
+
getActiveQueueRoutes() {
|
|
3318
|
+
return [
|
|
3319
|
+
DEFAULT_QUEUE_ROUTE
|
|
3320
|
+
];
|
|
3321
|
+
}
|
|
3322
|
+
getRouteQueue(route) {
|
|
3323
|
+
return this.getPersistedProperty(this.persistedQueueKeyForRoute(route)) || [];
|
|
3324
|
+
}
|
|
3325
|
+
enqueue(type, _message, options, explicitRoute) {
|
|
2677
3326
|
this.wrap(() => {
|
|
2678
3327
|
if (this.optedOut)
|
|
2679
3328
|
return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
2680
|
-
let message = this.prepareMessage(
|
|
3329
|
+
let message = this.prepareMessage(_message, options);
|
|
2681
3330
|
message = this.processBeforeEnqueue(message);
|
|
2682
3331
|
if (message === null)
|
|
2683
3332
|
return;
|
|
2684
|
-
|
|
3333
|
+
message = this.normalizeMessage(message);
|
|
3334
|
+
const queueKey = this.persistedQueueKeyForRoute(explicitRoute ?? this.getQueueRouteKey(message));
|
|
3335
|
+
const queue = this.getPersistedProperty(queueKey) || [];
|
|
2685
3336
|
if (queue.length >= this.maxQueueSize) {
|
|
2686
3337
|
queue.shift();
|
|
2687
|
-
this._logger.
|
|
3338
|
+
this._logger.warn("Queue is full, the oldest event is dropped.");
|
|
2688
3339
|
}
|
|
2689
3340
|
queue.push({
|
|
2690
3341
|
message
|
|
2691
3342
|
});
|
|
2692
|
-
this.setPersistedProperty(
|
|
3343
|
+
this.setPersistedProperty(queueKey, queue);
|
|
2693
3344
|
this._events.emit(type, message);
|
|
2694
3345
|
if (queue.length >= this.flushAt)
|
|
2695
3346
|
this.flushBackground();
|
|
@@ -2697,61 +3348,63 @@ class PostHogCoreStateless {
|
|
|
2697
3348
|
this._flushTimer = safeSetTimeout(() => this.flushBackground(), this.flushInterval);
|
|
2698
3349
|
});
|
|
2699
3350
|
}
|
|
2700
|
-
async sendImmediate(type, _message, options) {
|
|
3351
|
+
async sendImmediate(type, _message, options, explicitRoute) {
|
|
2701
3352
|
if (this.disabled)
|
|
2702
3353
|
return void this._logger.warn("The client is disabled");
|
|
2703
3354
|
if (!this._isInitialized)
|
|
2704
3355
|
await this._initPromise;
|
|
2705
3356
|
if (this.optedOut)
|
|
2706
3357
|
return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
2707
|
-
let message = this.prepareMessage(
|
|
3358
|
+
let message = this.prepareMessage(_message, options);
|
|
2708
3359
|
message = this.processBeforeEnqueue(message);
|
|
2709
3360
|
if (message === null)
|
|
2710
3361
|
return;
|
|
2711
|
-
|
|
2712
|
-
api_key: this.apiKey,
|
|
2713
|
-
batch: [
|
|
2714
|
-
message
|
|
2715
|
-
],
|
|
2716
|
-
sent_at: currentISOTime()
|
|
2717
|
-
};
|
|
2718
|
-
if (this.historicalMigration)
|
|
2719
|
-
data.historical_migration = true;
|
|
2720
|
-
const payload = JSON.stringify(data);
|
|
2721
|
-
const url = `${this.host}/batch/`;
|
|
2722
|
-
const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
|
|
2723
|
-
const fetchOptions = {
|
|
2724
|
-
method: "POST",
|
|
2725
|
-
headers: {
|
|
2726
|
-
...this.getCustomHeaders(),
|
|
2727
|
-
"Content-Type": "application/json",
|
|
2728
|
-
...gzippedPayload !== null && {
|
|
2729
|
-
"Content-Encoding": "gzip"
|
|
2730
|
-
}
|
|
2731
|
-
},
|
|
2732
|
-
body: gzippedPayload || payload
|
|
2733
|
-
};
|
|
3362
|
+
message = this.normalizeMessage(message);
|
|
2734
3363
|
try {
|
|
2735
|
-
|
|
2736
|
-
|
|
3364
|
+
await this.sendBatch([
|
|
3365
|
+
message
|
|
3366
|
+
], undefined, explicitRoute ?? this.getQueueRouteKey(message));
|
|
2737
3367
|
} catch (err) {
|
|
2738
3368
|
this._events.emit("error", err);
|
|
2739
3369
|
}
|
|
2740
3370
|
}
|
|
2741
|
-
|
|
3371
|
+
normalizeMessage(message) {
|
|
3372
|
+
const { type: _type, library, library_version, ...sanitizedMessage } = message;
|
|
3373
|
+
let properties = isPostHogEventProperties(sanitizedMessage.properties) ? sanitizedMessage.properties : undefined;
|
|
3374
|
+
if (library !== undefined && properties?.$lib === undefined)
|
|
3375
|
+
properties = {
|
|
3376
|
+
...properties || {},
|
|
3377
|
+
$lib: library
|
|
3378
|
+
};
|
|
3379
|
+
if (library_version !== undefined && properties?.$lib_version === undefined)
|
|
3380
|
+
properties = {
|
|
3381
|
+
...properties || {},
|
|
3382
|
+
$lib_version: library_version
|
|
3383
|
+
};
|
|
3384
|
+
if (properties)
|
|
3385
|
+
sanitizedMessage.properties = properties;
|
|
3386
|
+
sanitizedMessage.uuid = getEventUuid(sanitizedMessage.uuid, uuidv7);
|
|
3387
|
+
return sanitizedMessage;
|
|
3388
|
+
}
|
|
3389
|
+
normalizeTimestampForWire(timestamp) {
|
|
3390
|
+
const parsedTimestamp = timestamp instanceof Date ? timestamp : typeof timestamp == "string" ? new Date(timestamp) : null;
|
|
3391
|
+
if (!parsedTimestamp || Number.isNaN(parsedTimestamp.getTime()))
|
|
3392
|
+
return timestamp;
|
|
3393
|
+
const normalized = parsedTimestamp.toISOString();
|
|
3394
|
+
const fractionalSeconds = typeof timestamp == "string" ? timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1] : undefined;
|
|
3395
|
+
return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
|
|
3396
|
+
}
|
|
3397
|
+
prepareMessage(_message, options) {
|
|
2742
3398
|
const message = {
|
|
2743
3399
|
..._message,
|
|
2744
|
-
type,
|
|
2745
|
-
library: this.getLibraryId(),
|
|
2746
|
-
library_version: this.getLibraryVersion(),
|
|
2747
3400
|
timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
|
|
2748
|
-
uuid: options?.uuid
|
|
3401
|
+
uuid: getEventUuid(options?.uuid, uuidv7)
|
|
2749
3402
|
};
|
|
2750
3403
|
const addGeoipDisableProperty = options?.disableGeoip ?? this.disableGeoip;
|
|
2751
3404
|
if (addGeoipDisableProperty) {
|
|
2752
|
-
if (!message.properties)
|
|
3405
|
+
if (!isPostHogEventProperties(message.properties))
|
|
2753
3406
|
message.properties = {};
|
|
2754
|
-
message
|
|
3407
|
+
message.properties["$geoip_disable"] = true;
|
|
2755
3408
|
}
|
|
2756
3409
|
if (message.distinctId) {
|
|
2757
3410
|
message.distinct_id = message.distinctId;
|
|
@@ -2766,21 +3419,64 @@ class PostHogCoreStateless {
|
|
|
2766
3419
|
}
|
|
2767
3420
|
}
|
|
2768
3421
|
flushBackground() {
|
|
3422
|
+
if (this.pendingFlushPromise)
|
|
3423
|
+
return;
|
|
2769
3424
|
this.flush().catch(async (err) => {
|
|
2770
3425
|
await logFlushError(err);
|
|
2771
3426
|
});
|
|
2772
3427
|
}
|
|
2773
|
-
async
|
|
3428
|
+
async waitForPendingPromises(maxPromiseId, ignoredPromises = []) {
|
|
3429
|
+
const ignoredPendingPromises = ignoredPromises.filter((promise) => !!promise);
|
|
3430
|
+
let iteration = 0;
|
|
3431
|
+
while (true) {
|
|
3432
|
+
const promises = this.promiseQueue.getPromises([
|
|
3433
|
+
...ignoredPendingPromises,
|
|
3434
|
+
...this.flushPromises
|
|
3435
|
+
], maxPromiseId);
|
|
3436
|
+
if (promises.length === 0)
|
|
3437
|
+
return;
|
|
3438
|
+
if (iteration > 0)
|
|
3439
|
+
this._logger.debug(`flush() re-checking ${promises.length} pending promise(s) before flushing`);
|
|
3440
|
+
await Promise.all(promises.map((promise) => promise.catch(() => {})));
|
|
3441
|
+
iteration++;
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
flushWithPendingPromises() {
|
|
3445
|
+
return this.flushInternal(true);
|
|
3446
|
+
}
|
|
3447
|
+
flush() {
|
|
3448
|
+
return this.flushInternal(false);
|
|
3449
|
+
}
|
|
3450
|
+
flushInternal(waitForPendingPromises) {
|
|
2774
3451
|
if (this.disabled)
|
|
2775
|
-
return;
|
|
2776
|
-
|
|
2777
|
-
this.
|
|
2778
|
-
|
|
3452
|
+
return Promise.resolve();
|
|
3453
|
+
if (!waitForPendingPromises && this.pendingFlushPromise)
|
|
3454
|
+
return this.pendingFlushPromise;
|
|
3455
|
+
const previousFlushPromise = this.flushPromise;
|
|
3456
|
+
const maxPromiseId = this.promiseQueue.maxId;
|
|
3457
|
+
const nextFlushPromise = Promise.resolve().then(() => {
|
|
3458
|
+
if (waitForPendingPromises)
|
|
3459
|
+
return this.waitForPendingPromises(maxPromiseId, [
|
|
3460
|
+
previousFlushPromise,
|
|
3461
|
+
nextFlushPromise
|
|
3462
|
+
]);
|
|
3463
|
+
}).then(() => allSettled([
|
|
3464
|
+
previousFlushPromise
|
|
3465
|
+
])).then(() => {
|
|
3466
|
+
if (this.pendingFlushPromise === nextFlushPromise)
|
|
3467
|
+
this.pendingFlushPromise = null;
|
|
3468
|
+
return this._flush();
|
|
3469
|
+
});
|
|
3470
|
+
this.pendingFlushPromise = nextFlushPromise;
|
|
2779
3471
|
this.flushPromise = nextFlushPromise;
|
|
3472
|
+
this.flushPromises.add(nextFlushPromise);
|
|
2780
3473
|
this.addPendingPromise(nextFlushPromise);
|
|
2781
3474
|
allSettled([
|
|
2782
3475
|
nextFlushPromise
|
|
2783
3476
|
]).then(() => {
|
|
3477
|
+
this.flushPromises.delete(nextFlushPromise);
|
|
3478
|
+
if (this.pendingFlushPromise === nextFlushPromise)
|
|
3479
|
+
this.pendingFlushPromise = null;
|
|
2784
3480
|
if (this.flushPromise === nextFlushPromise)
|
|
2785
3481
|
this.flushPromise = null;
|
|
2786
3482
|
});
|
|
@@ -2793,55 +3489,102 @@ class PostHogCoreStateless {
|
|
|
2793
3489
|
headers["User-Agent"] = customUserAgent;
|
|
2794
3490
|
return headers;
|
|
2795
3491
|
}
|
|
3492
|
+
compressPayload(payload) {
|
|
3493
|
+
return gzipCompress(payload, this.isDebug);
|
|
3494
|
+
}
|
|
3495
|
+
getBatchEndpointPath(_route) {
|
|
3496
|
+
return "/batch/";
|
|
3497
|
+
}
|
|
3498
|
+
async sendBatch(batchMessages, retryOptions, route = DEFAULT_QUEUE_ROUTE) {
|
|
3499
|
+
const data = {
|
|
3500
|
+
api_key: this.apiKey,
|
|
3501
|
+
batch: batchMessages.map((message) => {
|
|
3502
|
+
if (!message)
|
|
3503
|
+
return message;
|
|
3504
|
+
const timestamp = this.normalizeTimestampForWire(message.timestamp);
|
|
3505
|
+
return timestamp === message.timestamp ? message : {
|
|
3506
|
+
...message,
|
|
3507
|
+
timestamp
|
|
3508
|
+
};
|
|
3509
|
+
}),
|
|
3510
|
+
sent_at: currentISOTime()
|
|
3511
|
+
};
|
|
3512
|
+
if (this.historicalMigration)
|
|
3513
|
+
data.historical_migration = true;
|
|
3514
|
+
const payload = safeJsonStringify(data);
|
|
3515
|
+
const url = `${this.host}${this.getBatchEndpointPath(route)}`;
|
|
3516
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(payload);
|
|
3517
|
+
const fetchOptions = {
|
|
3518
|
+
method: "POST",
|
|
3519
|
+
headers: {
|
|
3520
|
+
...this.getCustomHeaders(),
|
|
3521
|
+
"Content-Type": "application/json",
|
|
3522
|
+
...gzippedPayload !== null && {
|
|
3523
|
+
"Content-Encoding": "gzip"
|
|
3524
|
+
}
|
|
3525
|
+
},
|
|
3526
|
+
body: gzippedPayload || payload
|
|
3527
|
+
};
|
|
3528
|
+
await this.fetchWithRetry(url, fetchOptions, {
|
|
3529
|
+
type: "successful-write"
|
|
3530
|
+
}, retryOptions);
|
|
3531
|
+
}
|
|
2796
3532
|
async _flush() {
|
|
2797
3533
|
this.clearFlushTimer();
|
|
2798
3534
|
await this._initPromise;
|
|
2799
|
-
|
|
2800
|
-
if (!
|
|
3535
|
+
const routes = this.getActiveQueueRoutes();
|
|
3536
|
+
if (!routes.some((route) => this.getRouteQueue(route).length > 0))
|
|
2801
3537
|
return;
|
|
2802
3538
|
const sentMessages = [];
|
|
3539
|
+
let firstError;
|
|
3540
|
+
for (const route of routes)
|
|
3541
|
+
try {
|
|
3542
|
+
await this._flushRoute(route, sentMessages);
|
|
3543
|
+
} catch (err) {
|
|
3544
|
+
if (firstError === undefined)
|
|
3545
|
+
firstError = err;
|
|
3546
|
+
}
|
|
3547
|
+
if (firstError !== undefined)
|
|
3548
|
+
throw firstError;
|
|
3549
|
+
this._events.emit("flush", sentMessages);
|
|
3550
|
+
}
|
|
3551
|
+
async _flushRoute(route, sentMessages) {
|
|
3552
|
+
const queueKey = this.persistedQueueKeyForRoute(route);
|
|
3553
|
+
let queue = this.getPersistedProperty(queueKey) || [];
|
|
3554
|
+
if (!queue.length)
|
|
3555
|
+
return;
|
|
2803
3556
|
const originalQueueLength = queue.length;
|
|
2804
|
-
|
|
3557
|
+
let sentFromRoute = 0;
|
|
3558
|
+
while (queue.length > 0 && sentFromRoute < originalQueueLength) {
|
|
2805
3559
|
const batchItems = queue.slice(0, this.maxBatchSize);
|
|
2806
|
-
const batchMessages = batchItems.map((item) => item.message);
|
|
3560
|
+
const batchMessages = batchItems.map((item) => item.message === undefined ? item.message : this.normalizeMessage(item.message));
|
|
2807
3561
|
const persistQueueChange = async () => {
|
|
2808
|
-
const refreshedQueue = this.getPersistedProperty(
|
|
2809
|
-
const
|
|
2810
|
-
|
|
3562
|
+
const refreshedQueue = this.getPersistedProperty(queueKey) || [];
|
|
3563
|
+
const remainingBatchItems = [
|
|
3564
|
+
...batchItems
|
|
3565
|
+
];
|
|
3566
|
+
const newQueue = refreshedQueue.filter((item) => {
|
|
3567
|
+
const itemUuid = item.message?.uuid;
|
|
3568
|
+
const batchItemIndex = remainingBatchItems.findIndex((batchItem) => batchItem === item || typeof itemUuid == "string" && itemUuid.length > 0 && batchItem.message?.uuid === itemUuid);
|
|
3569
|
+
if (batchItemIndex === -1)
|
|
3570
|
+
return true;
|
|
3571
|
+
remainingBatchItems.splice(batchItemIndex, 1);
|
|
3572
|
+
return false;
|
|
3573
|
+
});
|
|
3574
|
+
this.setPersistedProperty(queueKey, newQueue);
|
|
2811
3575
|
queue = newQueue;
|
|
3576
|
+
this._dequeuedMessagesCount += batchItems.length;
|
|
2812
3577
|
await this.flushStorage();
|
|
2813
3578
|
};
|
|
2814
|
-
const data = {
|
|
2815
|
-
api_key: this.apiKey,
|
|
2816
|
-
batch: batchMessages,
|
|
2817
|
-
sent_at: currentISOTime()
|
|
2818
|
-
};
|
|
2819
|
-
if (this.historicalMigration)
|
|
2820
|
-
data.historical_migration = true;
|
|
2821
|
-
const payload = JSON.stringify(data);
|
|
2822
|
-
const url = `${this.host}/batch/`;
|
|
2823
|
-
const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
|
|
2824
|
-
const fetchOptions = {
|
|
2825
|
-
method: "POST",
|
|
2826
|
-
headers: {
|
|
2827
|
-
...this.getCustomHeaders(),
|
|
2828
|
-
"Content-Type": "application/json",
|
|
2829
|
-
...gzippedPayload !== null && {
|
|
2830
|
-
"Content-Encoding": "gzip"
|
|
2831
|
-
}
|
|
2832
|
-
},
|
|
2833
|
-
body: gzippedPayload || payload
|
|
2834
|
-
};
|
|
2835
3579
|
const retryOptions = {
|
|
2836
3580
|
retryCheck: (err) => {
|
|
2837
3581
|
if (isPostHogFetchContentTooLargeError(err))
|
|
2838
3582
|
return false;
|
|
2839
|
-
return
|
|
3583
|
+
return isPostHogFetchRetryableError(err);
|
|
2840
3584
|
}
|
|
2841
3585
|
};
|
|
2842
3586
|
try {
|
|
2843
|
-
|
|
2844
|
-
await response.body?.cancel()?.catch(() => {});
|
|
3587
|
+
await this.sendBatch(batchMessages, retryOptions, route);
|
|
2845
3588
|
} catch (err) {
|
|
2846
3589
|
if (isPostHogFetchContentTooLargeError(err) && batchMessages.length > 1) {
|
|
2847
3590
|
this.maxBatchSize = Math.max(1, Math.floor(batchMessages.length / 2));
|
|
@@ -2855,8 +3598,8 @@ class PostHogCoreStateless {
|
|
|
2855
3598
|
}
|
|
2856
3599
|
await persistQueueChange();
|
|
2857
3600
|
sentMessages.push(...batchMessages);
|
|
3601
|
+
sentFromRoute += batchMessages.length;
|
|
2858
3602
|
}
|
|
2859
|
-
this._events.emit("flush", sentMessages);
|
|
2860
3603
|
}
|
|
2861
3604
|
async _sendLogsBatch(payload) {
|
|
2862
3605
|
if (this.disabled)
|
|
@@ -2866,7 +3609,7 @@ class PostHogCoreStateless {
|
|
|
2866
3609
|
};
|
|
2867
3610
|
const serialized = JSON.stringify(payload);
|
|
2868
3611
|
const url = `${this.host}/i/v1/logs?token=${encodeURIComponent(this.apiKey)}`;
|
|
2869
|
-
const gzippedPayload = this.disableCompression ? null : await
|
|
3612
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
2870
3613
|
const fetchOptions = {
|
|
2871
3614
|
method: "POST",
|
|
2872
3615
|
headers: {
|
|
@@ -2880,10 +3623,12 @@ class PostHogCoreStateless {
|
|
|
2880
3623
|
};
|
|
2881
3624
|
try {
|
|
2882
3625
|
await this.fetchWithRetry(url, fetchOptions, {
|
|
3626
|
+
type: "successful-write"
|
|
3627
|
+
}, {
|
|
2883
3628
|
retryCheck: (err) => {
|
|
2884
3629
|
if (isPostHogFetchContentTooLargeError(err))
|
|
2885
3630
|
return false;
|
|
2886
|
-
return
|
|
3631
|
+
return isPostHogFetchRetryableError(err);
|
|
2887
3632
|
}
|
|
2888
3633
|
});
|
|
2889
3634
|
return {
|
|
@@ -2905,41 +3650,155 @@ class PostHogCoreStateless {
|
|
|
2905
3650
|
};
|
|
2906
3651
|
}
|
|
2907
3652
|
}
|
|
2908
|
-
async
|
|
3653
|
+
async _sendMetricsBatch(payload) {
|
|
3654
|
+
if (this.disabled)
|
|
3655
|
+
return {
|
|
3656
|
+
kind: "fatal",
|
|
3657
|
+
error: new Error("The client is disabled")
|
|
3658
|
+
};
|
|
3659
|
+
const serialized = JSON.stringify(payload);
|
|
3660
|
+
const url = `${this.host}/i/v1/metrics?token=${encodeURIComponent(this.apiKey)}`;
|
|
3661
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
3662
|
+
const fetchOptions = {
|
|
3663
|
+
method: "POST",
|
|
3664
|
+
headers: {
|
|
3665
|
+
...this.getCustomHeaders(),
|
|
3666
|
+
"Content-Type": "application/json",
|
|
3667
|
+
...gzippedPayload !== null && {
|
|
3668
|
+
"Content-Encoding": "gzip"
|
|
3669
|
+
}
|
|
3670
|
+
},
|
|
3671
|
+
body: gzippedPayload || serialized
|
|
3672
|
+
};
|
|
3673
|
+
try {
|
|
3674
|
+
await this.fetchWithRetry(url, fetchOptions, {
|
|
3675
|
+
type: "successful-write"
|
|
3676
|
+
}, {
|
|
3677
|
+
retryCheck: (err) => {
|
|
3678
|
+
if (isPostHogFetchContentTooLargeError(err))
|
|
3679
|
+
return false;
|
|
3680
|
+
return isPostHogFetchRetryableError(err);
|
|
3681
|
+
}
|
|
3682
|
+
});
|
|
3683
|
+
return {
|
|
3684
|
+
kind: "ok"
|
|
3685
|
+
};
|
|
3686
|
+
} catch (err) {
|
|
3687
|
+
if (isPostHogFetchContentTooLargeError(err))
|
|
3688
|
+
return {
|
|
3689
|
+
kind: "too-large"
|
|
3690
|
+
};
|
|
3691
|
+
if (isPostHogFetchRetryableError(err))
|
|
3692
|
+
return {
|
|
3693
|
+
kind: "retry-later",
|
|
3694
|
+
error: err
|
|
3695
|
+
};
|
|
3696
|
+
return {
|
|
3697
|
+
kind: "fatal",
|
|
3698
|
+
error: err
|
|
3699
|
+
};
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
async fetchWithRetry(url, options, responseHandling, retryOptions, requestTimeout) {
|
|
2909
3703
|
const body = options.body ? options.body : "";
|
|
2910
3704
|
let reqByteLength = -1;
|
|
2911
3705
|
try {
|
|
2912
|
-
reqByteLength = body instanceof Blob ? body.size : Buffer.byteLength(body, STRING_FORMAT);
|
|
3706
|
+
reqByteLength = body instanceof Blob ? body.size : body instanceof Uint8Array ? body.byteLength : Buffer.byteLength(body, STRING_FORMAT);
|
|
2913
3707
|
} catch {
|
|
2914
3708
|
if (body instanceof Blob)
|
|
2915
3709
|
reqByteLength = body.size;
|
|
3710
|
+
else if (body instanceof Uint8Array)
|
|
3711
|
+
reqByteLength = body.byteLength;
|
|
2916
3712
|
else {
|
|
2917
3713
|
const encoded = new TextEncoder().encode(body);
|
|
2918
3714
|
reqByteLength = encoded.length;
|
|
2919
3715
|
}
|
|
2920
3716
|
}
|
|
3717
|
+
const retriableOptions = {
|
|
3718
|
+
...this._retryOptions,
|
|
3719
|
+
...retryOptions
|
|
3720
|
+
};
|
|
3721
|
+
let attempt = 0;
|
|
2921
3722
|
return await retriable(async () => {
|
|
3723
|
+
attempt++;
|
|
2922
3724
|
const ctrl = new AbortController;
|
|
2923
3725
|
const timeoutMs = requestTimeout ?? this.requestTimeout;
|
|
2924
|
-
const
|
|
2925
|
-
let
|
|
3726
|
+
const requestDeadline = Date.now() + timeoutMs;
|
|
3727
|
+
let timer;
|
|
3728
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
3729
|
+
timer = safeSetTimeout(() => {
|
|
3730
|
+
const timeoutError = new Error(`Request timed out after ${timeoutMs}ms`);
|
|
3731
|
+
timeoutError.name = "AbortError";
|
|
3732
|
+
reject(timeoutError);
|
|
3733
|
+
ctrl.abort(timeoutError);
|
|
3734
|
+
}, timeoutMs);
|
|
3735
|
+
});
|
|
3736
|
+
let res;
|
|
3737
|
+
let responseAccepted = false;
|
|
3738
|
+
let cancellation;
|
|
3739
|
+
const cancelBody = () => cancellation ??= (async () => {
|
|
3740
|
+
try {
|
|
3741
|
+
await res?.body?.cancel();
|
|
3742
|
+
} catch {}
|
|
3743
|
+
})();
|
|
2926
3744
|
try {
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
3745
|
+
let fetchPromise;
|
|
3746
|
+
try {
|
|
3747
|
+
fetchPromise = this.fetch(url, {
|
|
3748
|
+
signal: ctrl.signal,
|
|
3749
|
+
...options
|
|
3750
|
+
});
|
|
3751
|
+
} catch (e) {
|
|
3752
|
+
throw new PostHogFetchNetworkError(e);
|
|
3753
|
+
}
|
|
3754
|
+
fetchPromise.then((lateResponse) => {
|
|
3755
|
+
if (ctrl.signal.aborted && !responseAccepted)
|
|
3756
|
+
Promise.resolve(lateResponse.body?.cancel()).catch(() => {});
|
|
3757
|
+
}).catch(() => {});
|
|
3758
|
+
try {
|
|
3759
|
+
res = await Promise.race([
|
|
3760
|
+
fetchPromise,
|
|
3761
|
+
deadline
|
|
3762
|
+
]);
|
|
3763
|
+
responseAccepted = true;
|
|
3764
|
+
} catch (e) {
|
|
3765
|
+
throw new PostHogFetchNetworkError(e);
|
|
3766
|
+
}
|
|
3767
|
+
const isNoCors = options.mode === "no-cors";
|
|
3768
|
+
if (!isNoCors && (res.status < 200 || res.status >= 400))
|
|
3769
|
+
throw new PostHogFetchHttpError(res, reqByteLength, requestDeadline, ctrl);
|
|
3770
|
+
if (responseHandling.type === "successful-write") {
|
|
3771
|
+
try {
|
|
3772
|
+
await Promise.race([
|
|
3773
|
+
cancelBody(),
|
|
3774
|
+
deadline
|
|
3775
|
+
]);
|
|
3776
|
+
} catch {}
|
|
3777
|
+
return;
|
|
3778
|
+
}
|
|
3779
|
+
try {
|
|
3780
|
+
return await Promise.race([
|
|
3781
|
+
responseHandling.consume(res),
|
|
3782
|
+
deadline
|
|
3783
|
+
]);
|
|
3784
|
+
} catch (e) {
|
|
3785
|
+
if (ctrl.signal.aborted)
|
|
3786
|
+
throw new PostHogFetchNetworkError(e);
|
|
3787
|
+
throw e;
|
|
3788
|
+
}
|
|
2933
3789
|
} finally {
|
|
2934
3790
|
clearTimeout(timer);
|
|
3791
|
+
if (ctrl.signal.aborted && res)
|
|
3792
|
+
cancelBody();
|
|
2935
3793
|
}
|
|
2936
|
-
const isNoCors = options.mode === "no-cors";
|
|
2937
|
-
if (!isNoCors && (res.status < 200 || res.status >= 400))
|
|
2938
|
-
throw new PostHogFetchHttpError(res, reqByteLength);
|
|
2939
|
-
return res;
|
|
2940
3794
|
}, {
|
|
2941
|
-
...
|
|
2942
|
-
|
|
3795
|
+
...retriableOptions,
|
|
3796
|
+
retryCheck: (error) => {
|
|
3797
|
+
const shouldRetry = retriableOptions.retryCheck(error);
|
|
3798
|
+
if (shouldRetry && attempt <= retriableOptions.retryCount && error instanceof PostHogFetchHttpError)
|
|
3799
|
+
error.cancelResponseBody();
|
|
3800
|
+
return shouldRetry;
|
|
3801
|
+
}
|
|
2943
3802
|
});
|
|
2944
3803
|
}
|
|
2945
3804
|
async _shutdown(shutdownTimeoutMs = 30000) {
|
|
@@ -2952,12 +3811,17 @@ class PostHogCoreStateless {
|
|
|
2952
3811
|
try {
|
|
2953
3812
|
await this.promiseQueue.join();
|
|
2954
3813
|
while (true) {
|
|
2955
|
-
const
|
|
2956
|
-
if (
|
|
3814
|
+
const hasQueuedEvents = this.getActiveQueueRoutes().some((route) => this.getRouteQueue(route).length > 0);
|
|
3815
|
+
if (!hasQueuedEvents)
|
|
2957
3816
|
break;
|
|
3817
|
+
const dequeuedBeforeFlush = this._dequeuedMessagesCount;
|
|
2958
3818
|
await this.flush();
|
|
2959
3819
|
if (hasTimedOut)
|
|
2960
3820
|
break;
|
|
3821
|
+
if (this._dequeuedMessagesCount === dequeuedBeforeFlush) {
|
|
3822
|
+
this._logger.warn("Shutdown flush completed but did not send any queued events. Stopping drain to avoid a loop.");
|
|
3823
|
+
break;
|
|
3824
|
+
}
|
|
2961
3825
|
}
|
|
2962
3826
|
} catch (e) {
|
|
2963
3827
|
if (!isPostHogFetchError(e))
|
|
@@ -2965,21 +3829,12 @@ class PostHogCoreStateless {
|
|
|
2965
3829
|
await logFlushError(e);
|
|
2966
3830
|
}
|
|
2967
3831
|
};
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
hasTimedOut = true;
|
|
2975
|
-
reject("Timeout while shutting down PostHog. Some events may not have been sent.");
|
|
2976
|
-
}, shutdownTimeoutMs);
|
|
2977
|
-
}),
|
|
2978
|
-
doShutdown()
|
|
2979
|
-
]);
|
|
2980
|
-
} finally {
|
|
2981
|
-
clearTimeout(timeoutHandle);
|
|
2982
|
-
}
|
|
3832
|
+
return raceWithTimeout(doShutdown(), shutdownTimeoutMs, () => {
|
|
3833
|
+
this._logger.critical("Timeout while shutting down PostHog. Some events may not have been sent.", {
|
|
3834
|
+
shutdownTimeoutMs
|
|
3835
|
+
});
|
|
3836
|
+
hasTimedOut = true;
|
|
3837
|
+
});
|
|
2983
3838
|
}
|
|
2984
3839
|
async shutdown(shutdownTimeoutMs = 30000) {
|
|
2985
3840
|
if (this.shutdownPromise)
|
|
@@ -2991,21 +3846,30 @@ class PostHogCoreStateless {
|
|
|
2991
3846
|
return this.shutdownPromise;
|
|
2992
3847
|
}
|
|
2993
3848
|
}
|
|
2994
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
2995
|
-
import {
|
|
3849
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
|
|
3850
|
+
import { constants as constants2 } from "node:fs";
|
|
3851
|
+
import { open as promises_open } from "node:fs/promises";
|
|
3852
|
+
import { isAbsolute } from "node:path";
|
|
2996
3853
|
import { createInterface } from "node:readline";
|
|
2997
|
-
var LRU_FILE_CONTENTS_CACHE = new
|
|
2998
|
-
var LRU_FILE_CONTENTS_FS_READ_FAILED = new
|
|
3854
|
+
var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
|
|
3855
|
+
var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
|
|
2999
3856
|
var DEFAULT_LINES_OF_CONTEXT = 7;
|
|
3000
3857
|
var MAX_CONTEXTLINES_COLNO = 1000;
|
|
3001
3858
|
var MAX_CONTEXTLINES_LINENO = 1e4;
|
|
3002
|
-
|
|
3859
|
+
var MAX_CONTEXTLINES_FILE_SIZE = 10485760;
|
|
3860
|
+
async function addSourceContext(frames, openSourceFile = promises_open, logger) {
|
|
3003
3861
|
const filesToLines = {};
|
|
3862
|
+
let basePath;
|
|
3863
|
+
try {
|
|
3864
|
+
basePath = process.cwd();
|
|
3865
|
+
} catch {}
|
|
3004
3866
|
for (let i = frames.length - 1;i >= 0; i--) {
|
|
3005
3867
|
const frame = frames[i];
|
|
3006
3868
|
const filename = frame?.filename;
|
|
3007
3869
|
if (!frame || typeof filename != "string" || typeof frame.lineno != "number" || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame))
|
|
3008
3870
|
continue;
|
|
3871
|
+
if (!isAbsolute(filename) && basePath === undefined)
|
|
3872
|
+
continue;
|
|
3009
3873
|
const filesToLinesOutput = filesToLines[filename];
|
|
3010
3874
|
if (!filesToLinesOutput)
|
|
3011
3875
|
filesToLines[filename] = [];
|
|
@@ -3016,50 +3880,98 @@ async function addSourceContext(frames) {
|
|
|
3016
3880
|
return frames;
|
|
3017
3881
|
const readlinePromises = [];
|
|
3018
3882
|
for (const file of files) {
|
|
3019
|
-
|
|
3883
|
+
const cacheKey = makeSourceCacheKey(file, basePath);
|
|
3884
|
+
if (cacheKey === undefined)
|
|
3885
|
+
continue;
|
|
3886
|
+
if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey))
|
|
3020
3887
|
continue;
|
|
3021
3888
|
const filesToLineRanges = filesToLines[file];
|
|
3022
3889
|
if (!filesToLineRanges)
|
|
3023
3890
|
continue;
|
|
3024
3891
|
filesToLineRanges.sort((a, b) => a - b);
|
|
3025
3892
|
const ranges = makeLineReaderRanges(filesToLineRanges);
|
|
3026
|
-
if (ranges.every((r) => rangeExistsInContentCache(
|
|
3893
|
+
if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r)))
|
|
3027
3894
|
continue;
|
|
3028
|
-
const cache = emplace(LRU_FILE_CONTENTS_CACHE,
|
|
3029
|
-
readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
|
|
3895
|
+
const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
|
|
3896
|
+
readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
|
|
3030
3897
|
}
|
|
3031
3898
|
await Promise.all(readlinePromises).catch(() => {});
|
|
3032
3899
|
if (frames && frames.length > 0)
|
|
3033
|
-
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
|
|
3900
|
+
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
|
|
3034
3901
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
3035
3902
|
return frames;
|
|
3036
3903
|
}
|
|
3037
|
-
function
|
|
3904
|
+
async function openRegularSourceFile(path, openSourceFile, logger) {
|
|
3905
|
+
let fileHandle;
|
|
3906
|
+
let isValid = false;
|
|
3907
|
+
try {
|
|
3908
|
+
fileHandle = await openSourceFile(path, constants2.O_RDONLY | constants2.O_NONBLOCK);
|
|
3909
|
+
const fileStat = await fileHandle.stat();
|
|
3910
|
+
if (!fileStat.isFile())
|
|
3911
|
+
return;
|
|
3912
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE)
|
|
3913
|
+
return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
3914
|
+
isValid = true;
|
|
3915
|
+
return fileHandle;
|
|
3916
|
+
} catch {
|
|
3917
|
+
return;
|
|
3918
|
+
} finally {
|
|
3919
|
+
if (fileHandle && !isValid)
|
|
3920
|
+
await fileHandle.close().catch(() => {});
|
|
3921
|
+
}
|
|
3922
|
+
}
|
|
3923
|
+
async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
|
|
3924
|
+
const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
|
|
3925
|
+
if (fileHandle === undefined)
|
|
3926
|
+
return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3927
|
+
const openedFileHandle = fileHandle;
|
|
3038
3928
|
return new Promise((resolve) => {
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
stream
|
|
3045
|
-
|
|
3929
|
+
let finished = false;
|
|
3930
|
+
function destroyStreamAndResolve(stream) {
|
|
3931
|
+
if (finished)
|
|
3932
|
+
return;
|
|
3933
|
+
finished = true;
|
|
3934
|
+
stream?.destroy();
|
|
3935
|
+
openedFileHandle.close().then(resolve, resolve);
|
|
3936
|
+
}
|
|
3937
|
+
let stream;
|
|
3938
|
+
try {
|
|
3939
|
+
stream = openedFileHandle.createReadStream({
|
|
3940
|
+
autoClose: false,
|
|
3941
|
+
start: 0,
|
|
3942
|
+
end: MAX_CONTEXTLINES_FILE_SIZE - 1
|
|
3943
|
+
});
|
|
3944
|
+
} catch {
|
|
3945
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3946
|
+
destroyStreamAndResolve();
|
|
3947
|
+
return;
|
|
3948
|
+
}
|
|
3949
|
+
let lineReaded;
|
|
3950
|
+
try {
|
|
3951
|
+
lineReaded = createInterface({
|
|
3952
|
+
input: stream
|
|
3953
|
+
});
|
|
3954
|
+
} catch {
|
|
3955
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3956
|
+
destroyStreamAndResolve(stream);
|
|
3957
|
+
return;
|
|
3046
3958
|
}
|
|
3047
3959
|
let lineNumber = 0;
|
|
3048
3960
|
let currentRangeIndex = 0;
|
|
3049
3961
|
const range = ranges[currentRangeIndex];
|
|
3050
3962
|
if (range === undefined)
|
|
3051
|
-
return void destroyStreamAndResolve();
|
|
3963
|
+
return void destroyStreamAndResolve(stream);
|
|
3052
3964
|
let rangeStart = range[0];
|
|
3053
3965
|
let rangeEnd = range[1];
|
|
3054
3966
|
function onStreamError() {
|
|
3055
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
3967
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3056
3968
|
lineReaded.close();
|
|
3057
3969
|
lineReaded.removeAllListeners();
|
|
3058
|
-
destroyStreamAndResolve();
|
|
3970
|
+
destroyStreamAndResolve(stream);
|
|
3059
3971
|
}
|
|
3060
3972
|
stream.on("error", onStreamError);
|
|
3061
3973
|
lineReaded.on("error", onStreamError);
|
|
3062
|
-
lineReaded.on("close", destroyStreamAndResolve);
|
|
3974
|
+
lineReaded.on("close", () => destroyStreamAndResolve(stream));
|
|
3063
3975
|
lineReaded.on("line", (line) => {
|
|
3064
3976
|
lineNumber++;
|
|
3065
3977
|
if (lineNumber < rangeStart)
|
|
@@ -3072,22 +3984,23 @@ function getContextLinesFromFile(path2, ranges, output) {
|
|
|
3072
3984
|
return;
|
|
3073
3985
|
}
|
|
3074
3986
|
currentRangeIndex++;
|
|
3075
|
-
const
|
|
3076
|
-
if (
|
|
3987
|
+
const range = ranges[currentRangeIndex];
|
|
3988
|
+
if (range === undefined) {
|
|
3077
3989
|
lineReaded.close();
|
|
3078
3990
|
lineReaded.removeAllListeners();
|
|
3079
3991
|
return;
|
|
3080
3992
|
}
|
|
3081
|
-
rangeStart =
|
|
3082
|
-
rangeEnd =
|
|
3993
|
+
rangeStart = range[0];
|
|
3994
|
+
rangeEnd = range[1];
|
|
3083
3995
|
}
|
|
3084
3996
|
});
|
|
3085
3997
|
});
|
|
3086
3998
|
}
|
|
3087
|
-
function addSourceContextToFrames(frames, cache) {
|
|
3999
|
+
function addSourceContextToFrames(frames, cache, basePath) {
|
|
3088
4000
|
for (const frame of frames)
|
|
3089
4001
|
if (frame.filename && frame.context_line === undefined && typeof frame.lineno == "number") {
|
|
3090
|
-
const
|
|
4002
|
+
const cacheKey = makeSourceCacheKey(frame.filename, basePath);
|
|
4003
|
+
const contents = cacheKey === undefined ? undefined : cache.get(cacheKey);
|
|
3091
4004
|
if (contents === undefined)
|
|
3092
4005
|
continue;
|
|
3093
4006
|
addContextToFrame(frame.lineno, frame, contents);
|
|
@@ -3120,8 +4033,8 @@ function clearLineContext(frame) {
|
|
|
3120
4033
|
delete frame.context_line;
|
|
3121
4034
|
delete frame.post_context;
|
|
3122
4035
|
}
|
|
3123
|
-
function shouldSkipContextLinesForFile(
|
|
3124
|
-
return
|
|
4036
|
+
function shouldSkipContextLinesForFile(path) {
|
|
4037
|
+
return path.startsWith("node:") || path.endsWith(".min.js") || path.endsWith(".min.cjs") || path.endsWith(".min.mjs") || path.startsWith("data:");
|
|
3125
4038
|
}
|
|
3126
4039
|
function shouldSkipContextLinesForFrame(frame) {
|
|
3127
4040
|
if (frame.lineno !== undefined && frame.lineno > MAX_CONTEXTLINES_LINENO)
|
|
@@ -3130,8 +4043,19 @@ function shouldSkipContextLinesForFrame(frame) {
|
|
|
3130
4043
|
return true;
|
|
3131
4044
|
return false;
|
|
3132
4045
|
}
|
|
3133
|
-
function
|
|
3134
|
-
|
|
4046
|
+
function makeSourceCacheKey(path, basePath) {
|
|
4047
|
+
if (isAbsolute(path))
|
|
4048
|
+
return JSON.stringify([
|
|
4049
|
+
null,
|
|
4050
|
+
path
|
|
4051
|
+
]);
|
|
4052
|
+
return basePath === undefined ? undefined : JSON.stringify([
|
|
4053
|
+
basePath,
|
|
4054
|
+
path
|
|
4055
|
+
]);
|
|
4056
|
+
}
|
|
4057
|
+
function rangeExistsInContentCache(cacheKey, range) {
|
|
4058
|
+
const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
|
|
3135
4059
|
if (contents === undefined)
|
|
3136
4060
|
return false;
|
|
3137
4061
|
for (let i = range[0];i <= range[1]; i++)
|
|
@@ -3209,8 +4133,8 @@ function snipLine(line, colno) {
|
|
|
3209
4133
|
return newLine;
|
|
3210
4134
|
}
|
|
3211
4135
|
|
|
3212
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
3213
|
-
import { isAbsolute, relative, sep as sep2 } from "node:path";
|
|
4136
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
|
|
4137
|
+
import { isAbsolute as isAbsolute2, relative, sep as sep2 } from "node:path";
|
|
3214
4138
|
function createRelativePathModifier(basePath = process.cwd()) {
|
|
3215
4139
|
const isWindows = sep2 === "\\";
|
|
3216
4140
|
const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
|
|
@@ -3218,17 +4142,17 @@ function createRelativePathModifier(basePath = process.cwd()) {
|
|
|
3218
4142
|
return async (frames) => {
|
|
3219
4143
|
for (const frame of frames)
|
|
3220
4144
|
if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
|
|
3221
|
-
if (
|
|
4145
|
+
if (isAbsolute2(frame.filename))
|
|
3222
4146
|
frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
|
|
3223
4147
|
}
|
|
3224
4148
|
return frames;
|
|
3225
4149
|
};
|
|
3226
4150
|
}
|
|
3227
4151
|
|
|
3228
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
3229
|
-
var version = "5.
|
|
4152
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/version.mjs
|
|
4153
|
+
var version = "5.51.1";
|
|
3230
4154
|
|
|
3231
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4155
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/types.mjs
|
|
3232
4156
|
var FeatureFlagError2 = {
|
|
3233
4157
|
ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
|
|
3234
4158
|
FLAG_MISSING: "flag_missing",
|
|
@@ -3236,7 +4160,7 @@ var FeatureFlagError2 = {
|
|
|
3236
4160
|
UNKNOWN_ERROR: "unknown_error"
|
|
3237
4161
|
};
|
|
3238
4162
|
|
|
3239
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4163
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
|
|
3240
4164
|
class FeatureFlagEvaluations {
|
|
3241
4165
|
constructor(init) {
|
|
3242
4166
|
this._host = init.host;
|
|
@@ -3252,10 +4176,10 @@ class FeatureFlagEvaluations {
|
|
|
3252
4176
|
this._accessed = init.accessed ?? new Set;
|
|
3253
4177
|
this._isSlice = init.isSlice ?? false;
|
|
3254
4178
|
}
|
|
3255
|
-
isEnabled(key) {
|
|
4179
|
+
isEnabled(key, options = {}) {
|
|
3256
4180
|
const flag = this._flags[key];
|
|
3257
4181
|
this._recordAccess(key);
|
|
3258
|
-
return flag?.enabled ?? false;
|
|
4182
|
+
return flag?.enabled ?? options.defaultValue ?? false;
|
|
3259
4183
|
}
|
|
3260
4184
|
getFlag(key) {
|
|
3261
4185
|
const flag = this._flags[key];
|
|
@@ -3345,6 +4269,8 @@ class FeatureFlagEvaluations {
|
|
|
3345
4269
|
$feature_flag_request_id: this._requestId,
|
|
3346
4270
|
$feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt
|
|
3347
4271
|
};
|
|
4272
|
+
if (flag?.hasExperiment !== undefined)
|
|
4273
|
+
properties.$feature_flag_has_experiment = flag.hasExperiment;
|
|
3348
4274
|
if (flag?.locallyEvaluated && this._flagDefinitionsLoadedAt !== undefined)
|
|
3349
4275
|
properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt;
|
|
3350
4276
|
const errors = [];
|
|
@@ -3367,7 +4293,7 @@ class FeatureFlagEvaluations {
|
|
|
3367
4293
|
}
|
|
3368
4294
|
}
|
|
3369
4295
|
|
|
3370
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4296
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
|
|
3371
4297
|
async function hashSHA1(text) {
|
|
3372
4298
|
const subtle = globalThis.crypto?.subtle;
|
|
3373
4299
|
if (!subtle)
|
|
@@ -3377,7 +4303,7 @@ async function hashSHA1(text) {
|
|
|
3377
4303
|
return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3378
4304
|
}
|
|
3379
4305
|
|
|
3380
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
4306
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
|
|
3381
4307
|
var SIXTY_SECONDS = 60000;
|
|
3382
4308
|
var LONG_SCALE = 1152921504606847000;
|
|
3383
4309
|
var NULL_VALUES_ALLOWED_OPERATORS = [
|
|
@@ -3394,22 +4320,23 @@ class ClientError extends Error {
|
|
|
3394
4320
|
Object.setPrototypeOf(this, ClientError.prototype);
|
|
3395
4321
|
}
|
|
3396
4322
|
}
|
|
4323
|
+
function setCustomErrorPrototype(error, constructor) {
|
|
4324
|
+
error.name = constructor.name;
|
|
4325
|
+
Error.captureStackTrace(error, constructor);
|
|
4326
|
+
Object.setPrototypeOf(error, constructor.prototype);
|
|
4327
|
+
}
|
|
3397
4328
|
|
|
3398
4329
|
class InconclusiveMatchError extends Error {
|
|
3399
4330
|
constructor(message) {
|
|
3400
4331
|
super(message);
|
|
3401
|
-
this
|
|
3402
|
-
Error.captureStackTrace(this, this.constructor);
|
|
3403
|
-
Object.setPrototypeOf(this, InconclusiveMatchError.prototype);
|
|
4332
|
+
setCustomErrorPrototype(this, InconclusiveMatchError);
|
|
3404
4333
|
}
|
|
3405
4334
|
}
|
|
3406
4335
|
|
|
3407
4336
|
class RequiresServerEvaluation extends Error {
|
|
3408
4337
|
constructor(message) {
|
|
3409
4338
|
super(message);
|
|
3410
|
-
this
|
|
3411
|
-
Error.captureStackTrace(this, this.constructor);
|
|
3412
|
-
Object.setPrototypeOf(this, RequiresServerEvaluation.prototype);
|
|
4339
|
+
setCustomErrorPrototype(this, RequiresServerEvaluation);
|
|
3413
4340
|
}
|
|
3414
4341
|
}
|
|
3415
4342
|
|
|
@@ -3418,6 +4345,7 @@ class FeatureFlagsPoller {
|
|
|
3418
4345
|
this.debugMode = false;
|
|
3419
4346
|
this.shouldBeginExponentialBackoff = false;
|
|
3420
4347
|
this.backOffCount = 0;
|
|
4348
|
+
this.pollerStopped = false;
|
|
3421
4349
|
this.pollingInterval = pollingInterval;
|
|
3422
4350
|
this.personalApiKey = personalApiKey;
|
|
3423
4351
|
this.featureFlags = [];
|
|
@@ -3433,6 +4361,7 @@ class FeatureFlagsPoller {
|
|
|
3433
4361
|
this.onError = options.onError;
|
|
3434
4362
|
this.customHeaders = customHeaders;
|
|
3435
4363
|
this.onLoad = options.onLoad;
|
|
4364
|
+
this.onMinimalFlagCalledEvents = options.onMinimalFlagCalledEvents;
|
|
3436
4365
|
this.cacheProvider = options.cacheProvider;
|
|
3437
4366
|
this.strictLocalEvaluation = options.strictLocalEvaluation ?? false;
|
|
3438
4367
|
this.loadFeatureFlags();
|
|
@@ -3630,6 +4559,7 @@ class FeatureFlagsPoller {
|
|
|
3630
4559
|
const flagFilters = flag.filters || {};
|
|
3631
4560
|
const flagConditions = flagFilters.groups || [];
|
|
3632
4561
|
const flagAggregation = flagFilters.aggregation_group_type_index;
|
|
4562
|
+
const earlyExitEnabled = flagFilters.early_exit ?? false;
|
|
3633
4563
|
const { groups, groupProperties } = evaluationContext;
|
|
3634
4564
|
let isInconclusive = false;
|
|
3635
4565
|
let result;
|
|
@@ -3653,12 +4583,15 @@ class FeatureFlagsPoller {
|
|
|
3653
4583
|
effectiveBucketingValue = groups[groupName];
|
|
3654
4584
|
}
|
|
3655
4585
|
}
|
|
3656
|
-
|
|
4586
|
+
const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
|
|
4587
|
+
if (matchResult === "match") {
|
|
3657
4588
|
const variantOverride = condition.variant;
|
|
3658
4589
|
const flagVariants = flagFilters.multivariate?.variants || [];
|
|
3659
4590
|
result = variantOverride && flagVariants.some((variant) => variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
|
|
3660
4591
|
break;
|
|
3661
4592
|
}
|
|
4593
|
+
if (earlyExitEnabled && matchResult === "out_of_rollout_bound")
|
|
4594
|
+
return false;
|
|
3662
4595
|
} catch (e) {
|
|
3663
4596
|
if (e instanceof RequiresServerEvaluation)
|
|
3664
4597
|
throw e;
|
|
@@ -3682,16 +4615,20 @@ class FeatureFlagsPoller {
|
|
|
3682
4615
|
for (const prop of condition.properties) {
|
|
3683
4616
|
const propertyType = prop.type;
|
|
3684
4617
|
let matches = false;
|
|
3685
|
-
|
|
4618
|
+
if (propertyType === "cohort") {
|
|
4619
|
+
const inCohort = await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext));
|
|
4620
|
+
matches = prop.operator === "not_in" ? !inCohort : inCohort;
|
|
4621
|
+
} else
|
|
4622
|
+
matches = propertyType === "flag" ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
|
|
3686
4623
|
if (!matches)
|
|
3687
|
-
return
|
|
4624
|
+
return "no_match";
|
|
3688
4625
|
}
|
|
3689
4626
|
if (rolloutPercentage == undefined)
|
|
3690
|
-
return
|
|
4627
|
+
return "match";
|
|
3691
4628
|
}
|
|
3692
4629
|
if (rolloutPercentage != null && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100)
|
|
3693
|
-
return
|
|
3694
|
-
return
|
|
4630
|
+
return "out_of_rollout_bound";
|
|
4631
|
+
return "match";
|
|
3695
4632
|
}
|
|
3696
4633
|
async getMatchingVariant(flag, bucketingValue) {
|
|
3697
4634
|
const hashValue = await _hash(flag.key, bucketingValue, "variant");
|
|
@@ -3722,6 +4659,7 @@ class FeatureFlagsPoller {
|
|
|
3722
4659
|
this.groupTypeMapping = flagData.groupTypeMapping;
|
|
3723
4660
|
this.cohorts = flagData.cohorts;
|
|
3724
4661
|
this.loadedSuccessfullyOnce = true;
|
|
4662
|
+
this.onMinimalFlagCalledEvents?.(flagData.minimalFlagCalledEvents === true);
|
|
3725
4663
|
}
|
|
3726
4664
|
warnAboutExperienceContinuityFlags(flags) {
|
|
3727
4665
|
if (this.strictLocalEvaluation)
|
|
@@ -3785,7 +4723,6 @@ class FeatureFlagsPoller {
|
|
|
3785
4723
|
clearTimeout(this.poller);
|
|
3786
4724
|
this.poller = undefined;
|
|
3787
4725
|
}
|
|
3788
|
-
this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
|
|
3789
4726
|
try {
|
|
3790
4727
|
let shouldFetch = true;
|
|
3791
4728
|
if (this.cacheProvider)
|
|
@@ -3813,17 +4750,18 @@ class FeatureFlagsPoller {
|
|
|
3813
4750
|
return;
|
|
3814
4751
|
case 401:
|
|
3815
4752
|
this.beginBackoff();
|
|
3816
|
-
throw new ClientError(`Your project key or
|
|
4753
|
+
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`);
|
|
3817
4754
|
case 402:
|
|
3818
4755
|
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");
|
|
3819
4756
|
this.featureFlags = [];
|
|
3820
4757
|
this.featureFlagsByKey = {};
|
|
3821
4758
|
this.groupTypeMapping = {};
|
|
3822
4759
|
this.cohorts = {};
|
|
4760
|
+
this.onMinimalFlagCalledEvents?.(false);
|
|
3823
4761
|
return;
|
|
3824
4762
|
case 403:
|
|
3825
4763
|
this.beginBackoff();
|
|
3826
|
-
throw new ClientError(`Your
|
|
4764
|
+
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`);
|
|
3827
4765
|
case 429:
|
|
3828
4766
|
this.beginBackoff();
|
|
3829
4767
|
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`);
|
|
@@ -3835,7 +4773,8 @@ class FeatureFlagsPoller {
|
|
|
3835
4773
|
const flagData = {
|
|
3836
4774
|
flags: responseJson.flags ?? [],
|
|
3837
4775
|
groupTypeMapping: responseJson.group_type_mapping || {},
|
|
3838
|
-
cohorts: responseJson.cohorts || {}
|
|
4776
|
+
cohorts: responseJson.cohorts || {},
|
|
4777
|
+
minimalFlagCalledEvents: responseJson.minimal_flag_called_events === true
|
|
3839
4778
|
};
|
|
3840
4779
|
this.updateFlagState(flagData);
|
|
3841
4780
|
this.flagDefinitionsLoadedAt = Date.now();
|
|
@@ -3856,6 +4795,9 @@ class FeatureFlagsPoller {
|
|
|
3856
4795
|
} catch (err) {
|
|
3857
4796
|
if (err instanceof ClientError)
|
|
3858
4797
|
this.onError?.(err);
|
|
4798
|
+
} finally {
|
|
4799
|
+
if (!this.pollerStopped)
|
|
4800
|
+
this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
|
|
3859
4801
|
}
|
|
3860
4802
|
}
|
|
3861
4803
|
getPersonalApiKeyRequestOptions(method = "GET", etag) {
|
|
@@ -3871,7 +4813,7 @@ class FeatureFlagsPoller {
|
|
|
3871
4813
|
headers
|
|
3872
4814
|
};
|
|
3873
4815
|
}
|
|
3874
|
-
_requestFeatureFlagDefinitions() {
|
|
4816
|
+
async _requestFeatureFlagDefinitions() {
|
|
3875
4817
|
const url = `${this.host}/flags/definitions?token=${this.projectApiKey}&send_cohorts`;
|
|
3876
4818
|
const options = this.getPersonalApiKeyRequestOptions("GET", this.flagsEtag);
|
|
3877
4819
|
let abortTimeout = null;
|
|
@@ -3882,23 +4824,49 @@ class FeatureFlagsPoller {
|
|
|
3882
4824
|
}, this.timeout);
|
|
3883
4825
|
options.signal = controller.signal;
|
|
3884
4826
|
}
|
|
4827
|
+
const clearAbortTimeout = () => clearTimeout(abortTimeout);
|
|
3885
4828
|
try {
|
|
3886
4829
|
const fetch1 = this.fetch;
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
4830
|
+
const res = await fetch1(url, options);
|
|
4831
|
+
if (res.status !== 200) {
|
|
4832
|
+
clearAbortTimeout();
|
|
4833
|
+
return res;
|
|
4834
|
+
}
|
|
4835
|
+
return {
|
|
4836
|
+
status: res.status,
|
|
4837
|
+
headers: res.headers,
|
|
4838
|
+
body: res.body,
|
|
4839
|
+
text: async () => {
|
|
4840
|
+
try {
|
|
4841
|
+
return await res.text();
|
|
4842
|
+
} finally {
|
|
4843
|
+
clearAbortTimeout();
|
|
4844
|
+
}
|
|
4845
|
+
},
|
|
4846
|
+
json: async () => {
|
|
4847
|
+
try {
|
|
4848
|
+
return await res.json();
|
|
4849
|
+
} finally {
|
|
4850
|
+
clearAbortTimeout();
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
};
|
|
4854
|
+
} catch (err) {
|
|
4855
|
+
clearAbortTimeout();
|
|
4856
|
+
throw err;
|
|
3890
4857
|
}
|
|
3891
4858
|
}
|
|
3892
4859
|
async stopPoller(timeoutMs = 30000) {
|
|
4860
|
+
this.pollerStopped = true;
|
|
3893
4861
|
clearTimeout(this.poller);
|
|
4862
|
+
this.poller = undefined;
|
|
3894
4863
|
if (this.cacheProvider)
|
|
3895
4864
|
try {
|
|
3896
4865
|
const shutdownResult = this.cacheProvider.shutdown();
|
|
3897
4866
|
if (shutdownResult instanceof Promise)
|
|
3898
|
-
await
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
]);
|
|
4867
|
+
await raceWithTimeout(shutdownResult, timeoutMs, () => {
|
|
4868
|
+
throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
|
|
4869
|
+
});
|
|
3902
4870
|
} catch (err) {
|
|
3903
4871
|
this.onError?.(new Error(`Error during cache shutdown: ${err}`));
|
|
3904
4872
|
}
|
|
@@ -3926,21 +4894,21 @@ function matchProperty(property, propertyValues, warnFunction) {
|
|
|
3926
4894
|
warnFunction(`Property ${key} cannot have a value of null/undefined with the ${operator} operator`);
|
|
3927
4895
|
return false;
|
|
3928
4896
|
}
|
|
3929
|
-
function computeExactMatch(
|
|
3930
|
-
if (Array.isArray(
|
|
3931
|
-
return
|
|
3932
|
-
return String(
|
|
4897
|
+
function computeExactMatch(value, overrideValue) {
|
|
4898
|
+
if (Array.isArray(value))
|
|
4899
|
+
return value.map((val) => String(val).toLowerCase()).includes(String(overrideValue).toLowerCase());
|
|
4900
|
+
return String(value).toLowerCase() === String(overrideValue).toLowerCase();
|
|
3933
4901
|
}
|
|
3934
|
-
function compare(lhs, rhs,
|
|
3935
|
-
if (
|
|
4902
|
+
function compare(lhs, rhs, operator) {
|
|
4903
|
+
if (operator === "gt")
|
|
3936
4904
|
return lhs > rhs;
|
|
3937
|
-
if (
|
|
4905
|
+
if (operator === "gte")
|
|
3938
4906
|
return lhs >= rhs;
|
|
3939
|
-
if (
|
|
4907
|
+
if (operator === "lt")
|
|
3940
4908
|
return lhs < rhs;
|
|
3941
|
-
if (
|
|
4909
|
+
if (operator === "lte")
|
|
3942
4910
|
return lhs <= rhs;
|
|
3943
|
-
throw new Error(`Invalid operator: ${
|
|
4911
|
+
throw new Error(`Invalid operator: ${operator}`);
|
|
3944
4912
|
}
|
|
3945
4913
|
switch (operator) {
|
|
3946
4914
|
case "exact":
|
|
@@ -3953,6 +4921,14 @@ function matchProperty(property, propertyValues, warnFunction) {
|
|
|
3953
4921
|
return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
3954
4922
|
case "not_icontains":
|
|
3955
4923
|
return !String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
4924
|
+
case "starts_with":
|
|
4925
|
+
return String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
|
|
4926
|
+
case "not_starts_with":
|
|
4927
|
+
return !String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
|
|
4928
|
+
case "ends_with":
|
|
4929
|
+
return String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
|
|
4930
|
+
case "not_ends_with":
|
|
4931
|
+
return !String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
|
|
3956
4932
|
case "regex":
|
|
3957
4933
|
return isValidRegex(String(value)) && String(overrideValue).match(String(value)) !== null;
|
|
3958
4934
|
case "not_regex":
|
|
@@ -4279,19 +5255,75 @@ function relativeDateParseForFeatureFlagMatching(value) {
|
|
|
4279
5255
|
}
|
|
4280
5256
|
}
|
|
4281
5257
|
|
|
4282
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5258
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
|
|
5259
|
+
var UNHANDLED_REJECTION_OPTION_NAMES = [
|
|
5260
|
+
"--unhandled-rejections",
|
|
5261
|
+
"--unhandled_rejections"
|
|
5262
|
+
];
|
|
5263
|
+
var UNHANDLED_REJECTION_MODES = new Set([
|
|
5264
|
+
"throw",
|
|
5265
|
+
"strict",
|
|
5266
|
+
"warn",
|
|
5267
|
+
"warn-with-error-code",
|
|
5268
|
+
"none"
|
|
5269
|
+
]);
|
|
5270
|
+
var STARTUP_EXEC_ARGV = [
|
|
5271
|
+
...globalThis.process?.execArgv ?? []
|
|
5272
|
+
];
|
|
5273
|
+
var STARTUP_NODE_OPTIONS = globalThis.process?.env?.NODE_OPTIONS;
|
|
5274
|
+
function splitNodeOptions(nodeOptions) {
|
|
5275
|
+
const args = [];
|
|
5276
|
+
let current = "";
|
|
5277
|
+
let isInString = false;
|
|
5278
|
+
for (let index = 0;index < nodeOptions.length; index++) {
|
|
5279
|
+
const character = nodeOptions[index];
|
|
5280
|
+
if (character === "\\" && isInString && index + 1 < nodeOptions.length)
|
|
5281
|
+
current += nodeOptions[++index];
|
|
5282
|
+
else if (character !== " " || isInString)
|
|
5283
|
+
if (character === '"')
|
|
5284
|
+
isInString = !isInString;
|
|
5285
|
+
else
|
|
5286
|
+
current += character;
|
|
5287
|
+
else if (current) {
|
|
5288
|
+
args.push(current);
|
|
5289
|
+
current = "";
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
if (current)
|
|
5293
|
+
args.push(current);
|
|
5294
|
+
return args;
|
|
5295
|
+
}
|
|
5296
|
+
function findUnhandledRejectionMode(args) {
|
|
5297
|
+
let mode;
|
|
5298
|
+
for (let index = 0;index < args.length; index++) {
|
|
5299
|
+
const argument = args[index];
|
|
5300
|
+
const optionName = UNHANDLED_REJECTION_OPTION_NAMES.find((name) => argument === name || argument.startsWith(`${name}=`));
|
|
5301
|
+
if (!optionName)
|
|
5302
|
+
continue;
|
|
5303
|
+
const value = argument === optionName ? args[++index] : argument.slice(optionName.length + 1);
|
|
5304
|
+
if (UNHANDLED_REJECTION_MODES.has(value))
|
|
5305
|
+
mode = value;
|
|
5306
|
+
}
|
|
5307
|
+
return mode;
|
|
5308
|
+
}
|
|
5309
|
+
function getUnhandledRejectionMode(execArgv = STARTUP_EXEC_ARGV, nodeOptions = STARTUP_NODE_OPTIONS) {
|
|
5310
|
+
return findUnhandledRejectionMode(execArgv) ?? findUnhandledRejectionMode(splitNodeOptions(nodeOptions ?? "")) ?? "throw";
|
|
5311
|
+
}
|
|
5312
|
+
var STARTUP_UNHANDLED_REJECTION_MODE = getUnhandledRejectionMode();
|
|
5313
|
+
function captureUncaughtException(captureFn, error, origin) {
|
|
5314
|
+
captureFn(error, {
|
|
5315
|
+
mechanism: {
|
|
5316
|
+
type: origin === "unhandledRejection" ? "onunhandledrejection" : "onuncaughtexception",
|
|
5317
|
+
handled: false
|
|
5318
|
+
}
|
|
5319
|
+
});
|
|
5320
|
+
}
|
|
4283
5321
|
function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
|
|
4284
5322
|
let calledFatalError = false;
|
|
4285
|
-
return Object.assign((error) => {
|
|
5323
|
+
return Object.assign((error, origin) => {
|
|
4286
5324
|
const userProvidedListenersCount = global.process.listeners("uncaughtException").filter((listener) => listener.name !== "domainUncaughtExceptionClear" && listener._posthogErrorHandler !== true).length;
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
mechanism: {
|
|
4290
|
-
type: "onuncaughtexception",
|
|
4291
|
-
handled: false
|
|
4292
|
-
}
|
|
4293
|
-
});
|
|
4294
|
-
if (!calledFatalError && processWouldExit) {
|
|
5325
|
+
captureUncaughtException(captureFn, error, origin);
|
|
5326
|
+
if (!calledFatalError && userProvidedListenersCount === 0) {
|
|
4295
5327
|
calledFatalError = true;
|
|
4296
5328
|
onFatalFn(error);
|
|
4297
5329
|
}
|
|
@@ -4299,29 +5331,38 @@ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
|
|
|
4299
5331
|
_posthogErrorHandler: true
|
|
4300
5332
|
});
|
|
4301
5333
|
}
|
|
4302
|
-
function addUncaughtExceptionListener(captureFn, onFatalFn) {
|
|
4303
|
-
globalThis.process
|
|
5334
|
+
function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
|
|
5335
|
+
const process2 = globalThis.process;
|
|
5336
|
+
if (!process2)
|
|
5337
|
+
return;
|
|
5338
|
+
if (mode === "strict")
|
|
5339
|
+
return void process2.on("uncaughtExceptionMonitor", (error, origin) => captureUncaughtException(captureFn, error, origin));
|
|
5340
|
+
process2.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
|
|
4304
5341
|
}
|
|
4305
|
-
function addUnhandledRejectionListener(captureFn) {
|
|
4306
|
-
globalThis.process
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
5342
|
+
function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
|
|
5343
|
+
const process2 = globalThis.process;
|
|
5344
|
+
if (!process2 || mode === "throw" || mode === "strict" || mode === "warn-with-error-code")
|
|
5345
|
+
return;
|
|
5346
|
+
process2.on("unhandledRejection", (reason) => {
|
|
5347
|
+
captureFn(reason, {
|
|
5348
|
+
mechanism: {
|
|
5349
|
+
type: "onunhandledrejection",
|
|
5350
|
+
handled: false
|
|
5351
|
+
}
|
|
5352
|
+
});
|
|
5353
|
+
});
|
|
4312
5354
|
}
|
|
4313
5355
|
|
|
4314
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5356
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
|
|
4315
5357
|
var SHUTDOWN_TIMEOUT = 2000;
|
|
4316
5358
|
|
|
4317
|
-
class
|
|
5359
|
+
class error_tracking_ErrorTracking {
|
|
4318
5360
|
constructor(client, options, _logger) {
|
|
4319
5361
|
this.client = client;
|
|
4320
5362
|
this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
|
|
4321
5363
|
this._logger = _logger;
|
|
4322
5364
|
this._rateLimiter = new BucketedRateLimiter({
|
|
4323
|
-
|
|
4324
|
-
bucketSize: 10,
|
|
5365
|
+
...resolveExceptionRateLimiterConfig(options),
|
|
4325
5366
|
refillInterval: 1e4,
|
|
4326
5367
|
_logger: this._logger
|
|
4327
5368
|
});
|
|
@@ -4336,6 +5377,9 @@ class ErrorTracking {
|
|
|
4336
5377
|
};
|
|
4337
5378
|
const exceptionProperties = builder.buildFromUnknown(error, hint);
|
|
4338
5379
|
exceptionProperties.$exception_list = await builder.modifyFrames(exceptionProperties.$exception_list);
|
|
5380
|
+
const injectedReleaseId = getInjectedReleaseId();
|
|
5381
|
+
if (injectedReleaseId)
|
|
5382
|
+
properties.$release_id = injectedReleaseId;
|
|
4339
5383
|
return {
|
|
4340
5384
|
event: "$exception",
|
|
4341
5385
|
distinctId,
|
|
@@ -4354,8 +5398,8 @@ class ErrorTracking {
|
|
|
4354
5398
|
}
|
|
4355
5399
|
onException(exception, hint) {
|
|
4356
5400
|
this.client.addPendingPromise((async () => {
|
|
4357
|
-
if (!
|
|
4358
|
-
const eventMessage = await
|
|
5401
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(exception)) {
|
|
5402
|
+
const eventMessage = await error_tracking_ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
|
|
4359
5403
|
const exceptionProperties = eventMessage.properties;
|
|
4360
5404
|
const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
|
|
4361
5405
|
const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
|
|
@@ -4363,14 +5407,14 @@ class ErrorTracking {
|
|
|
4363
5407
|
return void this._logger.info("Skipping exception capture because of client rate limiting.", {
|
|
4364
5408
|
exception: exceptionType
|
|
4365
5409
|
});
|
|
4366
|
-
return this.client.
|
|
5410
|
+
return this.client._capturePreparedEvent(eventMessage, false);
|
|
4367
5411
|
}
|
|
4368
5412
|
})());
|
|
4369
5413
|
}
|
|
4370
5414
|
async onFatalError(exception) {
|
|
4371
5415
|
console.error(exception);
|
|
4372
5416
|
await this.client.shutdown(SHUTDOWN_TIMEOUT);
|
|
4373
|
-
process.exit(1);
|
|
5417
|
+
globalThis.process.exit(1);
|
|
4374
5418
|
}
|
|
4375
5419
|
isEnabled() {
|
|
4376
5420
|
return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
|
|
@@ -4380,7 +5424,7 @@ class ErrorTracking {
|
|
|
4380
5424
|
}
|
|
4381
5425
|
}
|
|
4382
5426
|
|
|
4383
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5427
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/storage-memory.mjs
|
|
4384
5428
|
class PostHogMemoryStorage {
|
|
4385
5429
|
getProperty(key) {
|
|
4386
5430
|
return this._memoryStorage[key];
|
|
@@ -4393,7 +5437,452 @@ class PostHogMemoryStorage {
|
|
|
4393
5437
|
}
|
|
4394
5438
|
}
|
|
4395
5439
|
|
|
4396
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
5440
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/config.mjs
|
|
5441
|
+
function isCaptureMode(value) {
|
|
5442
|
+
return value === "v0" || value === "v1";
|
|
5443
|
+
}
|
|
5444
|
+
function resolveCaptureMode() {
|
|
5445
|
+
const envMode = typeof process != "undefined" ? process.env?.POSTHOG_CAPTURE_MODE : undefined;
|
|
5446
|
+
return isCaptureMode(envMode) ? envMode : "v0";
|
|
5447
|
+
}
|
|
5448
|
+
|
|
5449
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/routing.mjs
|
|
5450
|
+
var AI_EVENT_PREFIX = "$ai_";
|
|
5451
|
+
var ANALYTICS_ROUTE = "analytics";
|
|
5452
|
+
var AI_ROUTE = "ai";
|
|
5453
|
+
function isLegacyOnlyEvent(message) {
|
|
5454
|
+
return typeof message.event == "string" && message.event.startsWith(AI_EVENT_PREFIX);
|
|
5455
|
+
}
|
|
5456
|
+
|
|
5457
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/errors.mjs
|
|
5458
|
+
class CaptureV1Error extends Error {
|
|
5459
|
+
constructor({ requestId, drops, retryExhausted, cause }) {
|
|
5460
|
+
super(CaptureV1Error.buildMessage(requestId, drops, retryExhausted, cause)), this.name = "CaptureV1Error";
|
|
5461
|
+
this.requestId = requestId;
|
|
5462
|
+
this.drops = drops;
|
|
5463
|
+
this.retryExhausted = retryExhausted;
|
|
5464
|
+
this.cause = cause;
|
|
5465
|
+
}
|
|
5466
|
+
static buildMessage(requestId, drops, retryExhausted, cause) {
|
|
5467
|
+
let message = `Capture V1 batch ${requestId} did not fully deliver: ${drops.length} dropped, ${retryExhausted.length} undelivered`;
|
|
5468
|
+
if (cause instanceof Error)
|
|
5469
|
+
message += ` (${cause.message})`;
|
|
5470
|
+
return message;
|
|
5471
|
+
}
|
|
5472
|
+
}
|
|
5473
|
+
|
|
5474
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/transform.mjs
|
|
5475
|
+
function coerceBool(value) {
|
|
5476
|
+
if (typeof value == "boolean")
|
|
5477
|
+
return value;
|
|
5478
|
+
if (typeof value == "number")
|
|
5479
|
+
return value !== 0;
|
|
5480
|
+
if (typeof value == "string") {
|
|
5481
|
+
const normalized = value.trim().toLowerCase();
|
|
5482
|
+
if (normalized === "true" || normalized === "1")
|
|
5483
|
+
return true;
|
|
5484
|
+
if (normalized === "false" || normalized === "0")
|
|
5485
|
+
return false;
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5488
|
+
function coerceString(value) {
|
|
5489
|
+
return typeof value == "string" ? value : undefined;
|
|
5490
|
+
}
|
|
5491
|
+
var OPTION_SENTINELS = [
|
|
5492
|
+
{
|
|
5493
|
+
property: "$cookieless_mode",
|
|
5494
|
+
optionKey: "cookieless_mode",
|
|
5495
|
+
coerce: coerceBool
|
|
5496
|
+
},
|
|
5497
|
+
{
|
|
5498
|
+
property: "$ignore_sent_at",
|
|
5499
|
+
optionKey: "disable_skew_correction",
|
|
5500
|
+
coerce: coerceBool
|
|
5501
|
+
},
|
|
5502
|
+
{
|
|
5503
|
+
property: "$process_person_profile",
|
|
5504
|
+
optionKey: "process_person_profile",
|
|
5505
|
+
coerce: coerceBool
|
|
5506
|
+
},
|
|
5507
|
+
{
|
|
5508
|
+
property: "$product_tour_id",
|
|
5509
|
+
optionKey: "product_tour_id",
|
|
5510
|
+
coerce: coerceString
|
|
5511
|
+
}
|
|
5512
|
+
];
|
|
5513
|
+
var TOPLEVEL_SENTINELS = [
|
|
5514
|
+
{
|
|
5515
|
+
property: "$session_id",
|
|
5516
|
+
field: "session_id"
|
|
5517
|
+
},
|
|
5518
|
+
{
|
|
5519
|
+
property: "$window_id",
|
|
5520
|
+
field: "window_id"
|
|
5521
|
+
}
|
|
5522
|
+
];
|
|
5523
|
+
function isRecord2(value) {
|
|
5524
|
+
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
5525
|
+
}
|
|
5526
|
+
function toRfc3339(timestamp) {
|
|
5527
|
+
if (typeof timestamp == "string") {
|
|
5528
|
+
const asDate = new Date(timestamp);
|
|
5529
|
+
if (Number.isNaN(asDate.getTime()))
|
|
5530
|
+
return new Date().toISOString();
|
|
5531
|
+
const normalized = asDate.toISOString();
|
|
5532
|
+
const fractionalSeconds = timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1];
|
|
5533
|
+
return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
|
|
5534
|
+
}
|
|
5535
|
+
if (timestamp instanceof Date)
|
|
5536
|
+
return Number.isNaN(timestamp.getTime()) ? new Date().toISOString() : timestamp.toISOString();
|
|
5537
|
+
const asDate = timestamp == null ? new Date : new Date(timestamp);
|
|
5538
|
+
return Number.isNaN(asDate.getTime()) ? new Date().toISOString() : asDate.toISOString();
|
|
5539
|
+
}
|
|
5540
|
+
function relocateInto(properties, key, value) {
|
|
5541
|
+
if (value !== undefined && !(key in properties))
|
|
5542
|
+
properties[key] = value;
|
|
5543
|
+
}
|
|
5544
|
+
function buildV1Event(message) {
|
|
5545
|
+
const sourceProperties = isRecord2(message.properties) ? message.properties : {};
|
|
5546
|
+
const properties = {
|
|
5547
|
+
...sourceProperties
|
|
5548
|
+
};
|
|
5549
|
+
const options = {};
|
|
5550
|
+
for (const { property, optionKey, coerce } of OPTION_SENTINELS)
|
|
5551
|
+
if (property in properties) {
|
|
5552
|
+
const coerced = coerce(properties[property]);
|
|
5553
|
+
if (coerced !== undefined)
|
|
5554
|
+
options[optionKey] = coerced;
|
|
5555
|
+
delete properties[property];
|
|
5556
|
+
}
|
|
5557
|
+
const topLevel = {};
|
|
5558
|
+
for (const { property, field } of TOPLEVEL_SENTINELS)
|
|
5559
|
+
if (property in properties) {
|
|
5560
|
+
const value = properties[property];
|
|
5561
|
+
if (typeof value == "string")
|
|
5562
|
+
topLevel[field] = value;
|
|
5563
|
+
delete properties[property];
|
|
5564
|
+
}
|
|
5565
|
+
delete properties.$lib;
|
|
5566
|
+
delete properties.$lib_version;
|
|
5567
|
+
relocateInto(properties, "$set", message.$set);
|
|
5568
|
+
relocateInto(properties, "$set_once", message.$set_once);
|
|
5569
|
+
return {
|
|
5570
|
+
event: String(message.event ?? ""),
|
|
5571
|
+
uuid: String(message.uuid ?? ""),
|
|
5572
|
+
distinct_id: String(message.distinct_id ?? ""),
|
|
5573
|
+
timestamp: toRfc3339(message.timestamp),
|
|
5574
|
+
...topLevel,
|
|
5575
|
+
options,
|
|
5576
|
+
properties
|
|
5577
|
+
};
|
|
5578
|
+
}
|
|
5579
|
+
function buildV1Batch(messages, { createdAt, historicalMigration }) {
|
|
5580
|
+
const batch = {
|
|
5581
|
+
created_at: createdAt,
|
|
5582
|
+
batch: messages.map(buildV1Event)
|
|
5583
|
+
};
|
|
5584
|
+
if (historicalMigration)
|
|
5585
|
+
batch.historical_migration = true;
|
|
5586
|
+
return batch;
|
|
5587
|
+
}
|
|
5588
|
+
|
|
5589
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/sender.mjs
|
|
5590
|
+
var V1_ANALYTICS_PATH = "/i/v1/analytics/events";
|
|
5591
|
+
var DEFAULT_MAX_BACKOFF_MS = 30000;
|
|
5592
|
+
var RETRYABLE_STATUSES = new Set([
|
|
5593
|
+
408,
|
|
5594
|
+
500,
|
|
5595
|
+
502,
|
|
5596
|
+
503,
|
|
5597
|
+
504
|
|
5598
|
+
]);
|
|
5599
|
+
|
|
5600
|
+
class V1CaptureSender {
|
|
5601
|
+
constructor(config, hooks) {
|
|
5602
|
+
this.config = config;
|
|
5603
|
+
this.maxBackoffMs = config.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
5604
|
+
this.fetchFn = hooks.fetch;
|
|
5605
|
+
this.onError = hooks.onError;
|
|
5606
|
+
this.now = hooks.now ?? Date.now;
|
|
5607
|
+
this.sleep = hooks.sleep ?? ((ms) => new Promise((resolve) => safeSetTimeout(resolve, ms)));
|
|
5608
|
+
this.generateRequestId = hooks.generateRequestId ?? uuidv7;
|
|
5609
|
+
this.compress = hooks.compress ?? gzipCompress;
|
|
5610
|
+
}
|
|
5611
|
+
async sendV1Batch(messages) {
|
|
5612
|
+
if (messages.length === 0)
|
|
5613
|
+
return;
|
|
5614
|
+
const requestId = this.generateRequestId();
|
|
5615
|
+
const createdAt = new Date(this.now()).toISOString();
|
|
5616
|
+
const { batch } = buildV1Batch(messages, {
|
|
5617
|
+
createdAt,
|
|
5618
|
+
historicalMigration: this.config.historicalMigration
|
|
5619
|
+
});
|
|
5620
|
+
const url = `${this.config.host}${V1_ANALYTICS_PATH}`;
|
|
5621
|
+
const drops = [];
|
|
5622
|
+
let pending = batch;
|
|
5623
|
+
const maxAttempts = Math.max(1, this.config.maxAttempts);
|
|
5624
|
+
for (let attempt = 1;attempt <= maxAttempts; attempt++) {
|
|
5625
|
+
const isLastAttempt = attempt === maxAttempts;
|
|
5626
|
+
const payload = safeJsonStringify({
|
|
5627
|
+
created_at: createdAt,
|
|
5628
|
+
...this.config.historicalMigration ? {
|
|
5629
|
+
historical_migration: true
|
|
5630
|
+
} : {},
|
|
5631
|
+
batch: pending
|
|
5632
|
+
});
|
|
5633
|
+
let captureAttempt;
|
|
5634
|
+
let retryDelayMs;
|
|
5635
|
+
try {
|
|
5636
|
+
captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
|
|
5637
|
+
const { response, signal } = captureAttempt;
|
|
5638
|
+
const { status } = response;
|
|
5639
|
+
if (status < 200 || status >= 300)
|
|
5640
|
+
if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
5641
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
5642
|
+
await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(() => {});
|
|
5643
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
5644
|
+
} else {
|
|
5645
|
+
const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
|
|
5646
|
+
return this.surfaceBatchFailure(requestId, drops, pending, httpError);
|
|
5647
|
+
}
|
|
5648
|
+
else {
|
|
5649
|
+
let parsed;
|
|
5650
|
+
try {
|
|
5651
|
+
parsed = await captureAttempt.waitFor(this.parseResponse(response));
|
|
5652
|
+
} catch (error) {
|
|
5653
|
+
if (signal.aborted)
|
|
5654
|
+
throw error;
|
|
5655
|
+
return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
|
|
5656
|
+
}
|
|
5657
|
+
const retryable = this.classify(pending, parsed, drops);
|
|
5658
|
+
if (retryable.length === 0)
|
|
5659
|
+
return this.surfacePartialDrops(requestId, drops);
|
|
5660
|
+
if (isLastAttempt)
|
|
5661
|
+
return void this.onError(new CaptureV1Error({
|
|
5662
|
+
requestId,
|
|
5663
|
+
drops,
|
|
5664
|
+
retryExhausted: retryable.map((event) => event.uuid)
|
|
5665
|
+
}));
|
|
5666
|
+
pending = retryable;
|
|
5667
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
5668
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
5669
|
+
}
|
|
5670
|
+
} catch (transportError) {
|
|
5671
|
+
if (captureAttempt && !captureAttempt.signal.aborted)
|
|
5672
|
+
throw transportError;
|
|
5673
|
+
if (isLastAttempt)
|
|
5674
|
+
return this.surfaceBatchFailure(requestId, drops, pending, transportError);
|
|
5675
|
+
retryDelayMs = this.backoffDelay(attempt);
|
|
5676
|
+
} finally {
|
|
5677
|
+
captureAttempt?.cleanup();
|
|
5678
|
+
}
|
|
5679
|
+
if (retryDelayMs !== undefined)
|
|
5680
|
+
await this.sleep(retryDelayMs);
|
|
5681
|
+
}
|
|
5682
|
+
}
|
|
5683
|
+
async sendOnce(url, payload, attempt, requestId) {
|
|
5684
|
+
const headers = this.buildHeaders(attempt, requestId);
|
|
5685
|
+
let body = payload;
|
|
5686
|
+
if (this.config.compressionEnabled) {
|
|
5687
|
+
const compressed = await this.compress(payload, this.config.isDebug);
|
|
5688
|
+
if (compressed !== null) {
|
|
5689
|
+
body = compressed;
|
|
5690
|
+
headers["Content-Encoding"] = "gzip";
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
const controller = new AbortController;
|
|
5694
|
+
let timeoutPhase = "waiting for response headers";
|
|
5695
|
+
let timer;
|
|
5696
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
5697
|
+
timer = safeSetTimeout(() => {
|
|
5698
|
+
const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
|
|
5699
|
+
timeoutError.name = "AbortError";
|
|
5700
|
+
reject(timeoutError);
|
|
5701
|
+
controller.abort(timeoutError);
|
|
5702
|
+
}, this.config.requestTimeoutMs);
|
|
5703
|
+
});
|
|
5704
|
+
try {
|
|
5705
|
+
const fetchPromise = this.fetchFn(url, {
|
|
5706
|
+
method: "POST",
|
|
5707
|
+
headers,
|
|
5708
|
+
body,
|
|
5709
|
+
signal: controller.signal
|
|
5710
|
+
});
|
|
5711
|
+
let responseAccepted = false;
|
|
5712
|
+
fetchPromise.then((lateResponse) => {
|
|
5713
|
+
if (controller.signal.aborted && !responseAccepted)
|
|
5714
|
+
this.cancelBody(lateResponse);
|
|
5715
|
+
}).catch(() => {});
|
|
5716
|
+
const response = await Promise.race([
|
|
5717
|
+
fetchPromise,
|
|
5718
|
+
deadline
|
|
5719
|
+
]);
|
|
5720
|
+
responseAccepted = true;
|
|
5721
|
+
timeoutPhase = "while reading the response body";
|
|
5722
|
+
let cleanedUp = false;
|
|
5723
|
+
let cancellation;
|
|
5724
|
+
const cancelBody = () => cancellation ??= this.cancelBody(response);
|
|
5725
|
+
return {
|
|
5726
|
+
response,
|
|
5727
|
+
signal: controller.signal,
|
|
5728
|
+
waitFor: (operation) => Promise.race([
|
|
5729
|
+
operation,
|
|
5730
|
+
deadline
|
|
5731
|
+
]),
|
|
5732
|
+
cancelBody,
|
|
5733
|
+
cleanup: () => {
|
|
5734
|
+
if (cleanedUp)
|
|
5735
|
+
return;
|
|
5736
|
+
cleanedUp = true;
|
|
5737
|
+
clearTimeout(timer);
|
|
5738
|
+
if (controller.signal.aborted)
|
|
5739
|
+
cancelBody();
|
|
5740
|
+
}
|
|
5741
|
+
};
|
|
5742
|
+
} catch (error) {
|
|
5743
|
+
clearTimeout(timer);
|
|
5744
|
+
throw error;
|
|
5745
|
+
}
|
|
5746
|
+
}
|
|
5747
|
+
buildHeaders(attempt, requestId) {
|
|
5748
|
+
const sdkInfo = `${this.config.libraryId}/${this.config.libraryVersion}`;
|
|
5749
|
+
const headers = {
|
|
5750
|
+
"Content-Type": "application/json",
|
|
5751
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
5752
|
+
"PostHog-Sdk-Info": sdkInfo,
|
|
5753
|
+
"PostHog-Attempt": String(attempt),
|
|
5754
|
+
"PostHog-Request-Id": requestId,
|
|
5755
|
+
"PostHog-Request-Timestamp": new Date(this.now()).toISOString()
|
|
5756
|
+
};
|
|
5757
|
+
if (this.config.userAgent)
|
|
5758
|
+
headers["User-Agent"] = this.config.userAgent;
|
|
5759
|
+
return headers;
|
|
5760
|
+
}
|
|
5761
|
+
classify(pending, parsed, drops) {
|
|
5762
|
+
const results = parsed.results ?? {};
|
|
5763
|
+
const retryable = [];
|
|
5764
|
+
for (const event of pending) {
|
|
5765
|
+
const result = results[event.uuid];
|
|
5766
|
+
if (result) {
|
|
5767
|
+
if (result.result === "drop")
|
|
5768
|
+
drops.push({
|
|
5769
|
+
uuid: event.uuid,
|
|
5770
|
+
details: result.details ?? undefined
|
|
5771
|
+
});
|
|
5772
|
+
else if (result.result === "retry")
|
|
5773
|
+
retryable.push(event);
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5776
|
+
return retryable;
|
|
5777
|
+
}
|
|
5778
|
+
backoffDelay(attempt, retryAfterMs) {
|
|
5779
|
+
const exponential = Math.min(this.config.initialRetryDelayMs * 2 ** (attempt - 1), this.maxBackoffMs);
|
|
5780
|
+
if (retryAfterMs === undefined)
|
|
5781
|
+
return exponential;
|
|
5782
|
+
return Math.max(exponential, Math.min(retryAfterMs, this.maxBackoffMs));
|
|
5783
|
+
}
|
|
5784
|
+
parseRetryAfter(response) {
|
|
5785
|
+
const raw = response.headers?.get("Retry-After");
|
|
5786
|
+
if (!raw)
|
|
5787
|
+
return;
|
|
5788
|
+
const trimmed = raw.trim();
|
|
5789
|
+
if (/^\d+$/.test(trimmed)) {
|
|
5790
|
+
const seconds = parseInt(trimmed, 10);
|
|
5791
|
+
return Number.isFinite(seconds) && seconds > 0 ? 1000 * seconds : undefined;
|
|
5792
|
+
}
|
|
5793
|
+
const dateMs = Date.parse(trimmed);
|
|
5794
|
+
if (Number.isNaN(dateMs))
|
|
5795
|
+
return;
|
|
5796
|
+
const delta = dateMs - this.now();
|
|
5797
|
+
return delta > 0 ? delta : undefined;
|
|
5798
|
+
}
|
|
5799
|
+
async parseResponse(response) {
|
|
5800
|
+
const text = await response.text();
|
|
5801
|
+
const parsed = JSON.parse(text);
|
|
5802
|
+
if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
|
|
5803
|
+
throw new Error("unexpected response shape");
|
|
5804
|
+
const results = parsed.results;
|
|
5805
|
+
if (results !== undefined && (typeof results != "object" || results === null || Array.isArray(results)))
|
|
5806
|
+
throw new Error("unexpected results shape");
|
|
5807
|
+
return {
|
|
5808
|
+
results: results ?? {}
|
|
5809
|
+
};
|
|
5810
|
+
}
|
|
5811
|
+
async buildHttpError(response, status, waitFor) {
|
|
5812
|
+
let bodyText = "";
|
|
5813
|
+
try {
|
|
5814
|
+
bodyText = (await waitFor(response.text())).slice(0, 512);
|
|
5815
|
+
} catch {}
|
|
5816
|
+
const suffix = bodyText ? `: ${bodyText}` : "";
|
|
5817
|
+
return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
|
|
5818
|
+
}
|
|
5819
|
+
surfaceBatchFailure(requestId, drops, pending, cause) {
|
|
5820
|
+
this.onError(new CaptureV1Error({
|
|
5821
|
+
requestId,
|
|
5822
|
+
drops,
|
|
5823
|
+
retryExhausted: pending.map((event) => event.uuid),
|
|
5824
|
+
cause
|
|
5825
|
+
}));
|
|
5826
|
+
}
|
|
5827
|
+
surfacePartialDrops(requestId, drops) {
|
|
5828
|
+
if (drops.length > 0)
|
|
5829
|
+
this.onError(new CaptureV1Error({
|
|
5830
|
+
requestId,
|
|
5831
|
+
drops,
|
|
5832
|
+
retryExhausted: []
|
|
5833
|
+
}));
|
|
5834
|
+
}
|
|
5835
|
+
async cancelBody(response) {
|
|
5836
|
+
try {
|
|
5837
|
+
await response.body?.cancel();
|
|
5838
|
+
} catch {}
|
|
5839
|
+
}
|
|
5840
|
+
}
|
|
5841
|
+
|
|
5842
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/routing.mjs
|
|
5843
|
+
var AI_CAPTURE_ROUTE = "ai-capture";
|
|
5844
|
+
var AI_CAPTURE_ENDPOINT_PATH = "/i/v0/ai/batch/";
|
|
5845
|
+
var AI_MAX_EVENT_BYTES = 8388608;
|
|
5846
|
+
var AI_BATCH_TARGET_BYTES = 5242880;
|
|
5847
|
+
|
|
5848
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/batching.mjs
|
|
5849
|
+
var encoder = new TextEncoder;
|
|
5850
|
+
function eventByteSize(message) {
|
|
5851
|
+
return encoder.encode(safeJsonStringify(message)).length;
|
|
5852
|
+
}
|
|
5853
|
+
function partitionAiBatch(messages, maxEventBytes = AI_MAX_EVENT_BYTES, targetBatchBytes = AI_BATCH_TARGET_BYTES) {
|
|
5854
|
+
const batches = [];
|
|
5855
|
+
const dropped = [];
|
|
5856
|
+
let current = [];
|
|
5857
|
+
let currentBytes = 0;
|
|
5858
|
+
for (const message of messages) {
|
|
5859
|
+
if (message === undefined)
|
|
5860
|
+
continue;
|
|
5861
|
+
const bytes = eventByteSize(message);
|
|
5862
|
+
if (bytes > maxEventBytes) {
|
|
5863
|
+
dropped.push({
|
|
5864
|
+
event: typeof message.event == "string" ? message.event : "unknown",
|
|
5865
|
+
bytes
|
|
5866
|
+
});
|
|
5867
|
+
continue;
|
|
5868
|
+
}
|
|
5869
|
+
if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
|
|
5870
|
+
batches.push(current);
|
|
5871
|
+
current = [];
|
|
5872
|
+
currentBytes = 0;
|
|
5873
|
+
}
|
|
5874
|
+
current.push(message);
|
|
5875
|
+
currentBytes += bytes;
|
|
5876
|
+
}
|
|
5877
|
+
if (current.length > 0)
|
|
5878
|
+
batches.push(current);
|
|
5879
|
+
return {
|
|
5880
|
+
batches,
|
|
5881
|
+
dropped
|
|
5882
|
+
};
|
|
5883
|
+
}
|
|
5884
|
+
|
|
5885
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/client.mjs
|
|
4397
5886
|
var MINIMUM_POLLING_INTERVAL = 100;
|
|
4398
5887
|
var THIRTY_SECONDS = 30000;
|
|
4399
5888
|
var MAX_CACHE_SIZE = 50000;
|
|
@@ -4418,6 +5907,12 @@ function normalizeHost(value) {
|
|
|
4418
5907
|
const normalizedValue = typeof value == "string" ? value.trim() : "";
|
|
4419
5908
|
return normalizedValue || DEFAULT_NODE_HOST;
|
|
4420
5909
|
}
|
|
5910
|
+
function normalizeUnsetPersonProperties(value) {
|
|
5911
|
+
const propertyNames = Array.isArray(value) ? value : [
|
|
5912
|
+
value
|
|
5913
|
+
];
|
|
5914
|
+
return propertyNames.filter((propertyName) => typeof propertyName == "string" && propertyName.trim().length > 0);
|
|
5915
|
+
}
|
|
4421
5916
|
function buildFlagEventProperties(flagValues) {
|
|
4422
5917
|
if (!flagValues)
|
|
4423
5918
|
return {};
|
|
@@ -4435,11 +5930,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4435
5930
|
const normalizedApiKey = normalizeApiKey(apiKey);
|
|
4436
5931
|
const normalizedOptions = {
|
|
4437
5932
|
...options,
|
|
5933
|
+
maxQueueSize: options.maxQueueSize ?? 1e4,
|
|
5934
|
+
flushInterval: options.flushInterval ?? 5000,
|
|
4438
5935
|
host: normalizeHost(options.host),
|
|
4439
|
-
personalApiKey: normalizePersonalApiKey(options.personalApiKey)
|
|
5936
|
+
personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
|
|
4440
5937
|
};
|
|
4441
|
-
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage;
|
|
5938
|
+
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage, this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
|
|
4442
5939
|
this.options = normalizedOptions;
|
|
5940
|
+
this.captureMode = resolveCaptureMode();
|
|
5941
|
+
this.enableFullAiCapture = normalizedOptions.enableFullAiCapture === true;
|
|
4443
5942
|
this.context = this.initializeContext();
|
|
4444
5943
|
this.options.featureFlagsPollingInterval = typeof normalizedOptions.featureFlagsPollingInterval == "number" ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
4445
5944
|
if (typeof normalizedOptions.waitUntilDebounceMs == "number")
|
|
@@ -4464,21 +5963,24 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4464
5963
|
onLoad: (count) => {
|
|
4465
5964
|
this._events.emit("localEvaluationFlagsLoaded", count);
|
|
4466
5965
|
},
|
|
5966
|
+
onMinimalFlagCalledEvents: (enabled) => {
|
|
5967
|
+
this._minimalFlagCalledEvents = enabled;
|
|
5968
|
+
},
|
|
4467
5969
|
customHeaders: this.getCustomHeaders(),
|
|
4468
5970
|
cacheProvider: normalizedOptions.flagDefinitionCacheProvider,
|
|
4469
5971
|
strictLocalEvaluation: normalizedOptions.strictLocalEvaluation
|
|
4470
5972
|
});
|
|
4471
5973
|
}
|
|
4472
|
-
this.errorTracking = new
|
|
5974
|
+
this.errorTracking = new error_tracking_ErrorTracking(this, normalizedOptions, this._logger);
|
|
4473
5975
|
this.distinctIdHasSentFlagCalls = {};
|
|
4474
5976
|
this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
|
|
4475
5977
|
}
|
|
4476
|
-
enqueue(type, message, options) {
|
|
4477
|
-
super.enqueue(type, message, options);
|
|
5978
|
+
enqueue(type, message, options, explicitRoute) {
|
|
5979
|
+
super.enqueue(type, message, options, explicitRoute);
|
|
4478
5980
|
this.scheduleDebouncedFlush();
|
|
4479
5981
|
}
|
|
4480
5982
|
async flush() {
|
|
4481
|
-
const flushPromise =
|
|
5983
|
+
const flushPromise = this.flushWithPendingPromises();
|
|
4482
5984
|
const waitUntil = this.options.waitUntil;
|
|
4483
5985
|
if (waitUntil && !this._waitUntilCycle)
|
|
4484
5986
|
try {
|
|
@@ -4531,7 +6033,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4531
6033
|
async resolveWaitUntilFlush() {
|
|
4532
6034
|
const resolve = this._consumeWaitUntilCycle();
|
|
4533
6035
|
try {
|
|
4534
|
-
await
|
|
6036
|
+
await this.flushWithPendingPromises();
|
|
4535
6037
|
} catch {} finally {
|
|
4536
6038
|
resolve?.();
|
|
4537
6039
|
}
|
|
@@ -4545,12 +6047,103 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4545
6047
|
fetch(url, options) {
|
|
4546
6048
|
return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
|
|
4547
6049
|
}
|
|
6050
|
+
getQueueRouteKey(message) {
|
|
6051
|
+
return this.captureMode === "v1" && isLegacyOnlyEvent(message) ? AI_ROUTE : ANALYTICS_ROUTE;
|
|
6052
|
+
}
|
|
6053
|
+
persistedQueueKeyForRoute(route) {
|
|
6054
|
+
if (route === AI_CAPTURE_ROUTE)
|
|
6055
|
+
return types_PostHogPersistedProperty.AiCaptureQueue;
|
|
6056
|
+
return route === AI_ROUTE ? types_PostHogPersistedProperty.AiQueue : types_PostHogPersistedProperty.Queue;
|
|
6057
|
+
}
|
|
6058
|
+
getActiveQueueRoutes() {
|
|
6059
|
+
const routes = this.captureMode === "v1" ? [
|
|
6060
|
+
ANALYTICS_ROUTE,
|
|
6061
|
+
AI_ROUTE
|
|
6062
|
+
] : [
|
|
6063
|
+
ANALYTICS_ROUTE
|
|
6064
|
+
];
|
|
6065
|
+
if (this._aiCaptureRouteActive)
|
|
6066
|
+
routes.push(AI_CAPTURE_ROUTE);
|
|
6067
|
+
return routes;
|
|
6068
|
+
}
|
|
6069
|
+
getBatchEndpointPath(route) {
|
|
6070
|
+
return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
|
|
6071
|
+
}
|
|
6072
|
+
async sendBatch(batchMessages, retryOptions, route = ANALYTICS_ROUTE) {
|
|
6073
|
+
if (route === AI_CAPTURE_ROUTE)
|
|
6074
|
+
return this.sendAiCaptureBatch(batchMessages, retryOptions);
|
|
6075
|
+
if (this.captureMode !== "v1" || route === AI_ROUTE)
|
|
6076
|
+
return super.sendBatch(batchMessages, retryOptions, route);
|
|
6077
|
+
const v1Events = batchMessages.filter((message) => message !== undefined);
|
|
6078
|
+
await this.getV1Sender().sendV1Batch(v1Events);
|
|
6079
|
+
}
|
|
6080
|
+
async sendAiCaptureBatch(batchMessages, retryOptions) {
|
|
6081
|
+
const { batches, dropped } = partitionAiBatch(batchMessages);
|
|
6082
|
+
for (const { event, bytes } of dropped) {
|
|
6083
|
+
const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
|
|
6084
|
+
this._logger.error(message);
|
|
6085
|
+
this._events.emit("error", new Error(message));
|
|
6086
|
+
}
|
|
6087
|
+
for (const batch of batches)
|
|
6088
|
+
await this.sendAiSubBatch(batch, retryOptions);
|
|
6089
|
+
}
|
|
6090
|
+
async sendAiSubBatch(batch, retryOptions) {
|
|
6091
|
+
try {
|
|
6092
|
+
await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE);
|
|
6093
|
+
} catch (err) {
|
|
6094
|
+
if (!isPostHogFetchContentTooLargeError(err))
|
|
6095
|
+
throw err;
|
|
6096
|
+
if (batch.length === 1) {
|
|
6097
|
+
const [event] = batch;
|
|
6098
|
+
const eventName = typeof event.event == "string" ? event.event : "unknown";
|
|
6099
|
+
const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
|
|
6100
|
+
this._logger.error(message);
|
|
6101
|
+
this._events.emit("error", new Error(message));
|
|
6102
|
+
return;
|
|
6103
|
+
}
|
|
6104
|
+
const mid = Math.ceil(batch.length / 2);
|
|
6105
|
+
await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
|
|
6106
|
+
await this.sendAiSubBatch(batch.slice(mid), retryOptions);
|
|
6107
|
+
}
|
|
6108
|
+
}
|
|
6109
|
+
getV1Sender() {
|
|
6110
|
+
if (!this._v1Sender)
|
|
6111
|
+
this._v1Sender = new V1CaptureSender({
|
|
6112
|
+
host: this.host,
|
|
6113
|
+
apiKey: this.apiKey,
|
|
6114
|
+
libraryId: this.getLibraryId(),
|
|
6115
|
+
libraryVersion: this.getLibraryVersion(),
|
|
6116
|
+
userAgent: this.getCustomUserAgent() || undefined,
|
|
6117
|
+
historicalMigration: this.historicalMigration,
|
|
6118
|
+
compressionEnabled: !this.disableCompression,
|
|
6119
|
+
requestTimeoutMs: this.requestTimeout,
|
|
6120
|
+
maxAttempts: (this.options.fetchRetryCount ?? 3) + 1,
|
|
6121
|
+
initialRetryDelayMs: this.options.fetchRetryDelay ?? 3000,
|
|
6122
|
+
isDebug: this.isDebug
|
|
6123
|
+
}, {
|
|
6124
|
+
fetch: (url, fetchOptions) => this.fetch(url, fetchOptions),
|
|
6125
|
+
onError: (error) => this._events.emit("error", error),
|
|
6126
|
+
compress: (payload) => this.compressPayload(payload)
|
|
6127
|
+
});
|
|
6128
|
+
return this._v1Sender;
|
|
6129
|
+
}
|
|
4548
6130
|
getLibraryVersion() {
|
|
4549
6131
|
return version;
|
|
4550
6132
|
}
|
|
6133
|
+
get metrics() {
|
|
6134
|
+
if (!this._metrics)
|
|
6135
|
+
this._metrics = new PostHogMetrics(this, resolveMetricsConfig(this.options.metrics), this._logger);
|
|
6136
|
+
return this._metrics;
|
|
6137
|
+
}
|
|
4551
6138
|
getCustomUserAgent() {
|
|
4552
6139
|
return `${this.getLibraryId()}/${this.getLibraryVersion()}`;
|
|
4553
6140
|
}
|
|
6141
|
+
getCommonEventProperties() {
|
|
6142
|
+
const commonProperties = super.getCommonEventProperties();
|
|
6143
|
+
if (this.options.isServer ?? true)
|
|
6144
|
+
commonProperties.$is_server = true;
|
|
6145
|
+
return commonProperties;
|
|
6146
|
+
}
|
|
4554
6147
|
enable() {
|
|
4555
6148
|
return super.optIn();
|
|
4556
6149
|
}
|
|
@@ -4561,33 +6154,69 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4561
6154
|
super.debug(enabled);
|
|
4562
6155
|
this.featureFlagsPoller?.debug(enabled);
|
|
4563
6156
|
}
|
|
4564
|
-
|
|
6157
|
+
_warnIfInvalidCapture(props, stringArgumentWarning, exceptionCaptureWarning) {
|
|
4565
6158
|
if (typeof props == "string")
|
|
4566
|
-
this._logger.warn(
|
|
6159
|
+
this._logger.warn(stringArgumentWarning);
|
|
4567
6160
|
if (props.event === "$exception" && !props._originatedFromCaptureException)
|
|
4568
|
-
this._logger.warn(
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
6161
|
+
this._logger.warn(exceptionCaptureWarning);
|
|
6162
|
+
}
|
|
6163
|
+
_sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
|
|
6164
|
+
return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options }) => {
|
|
6165
|
+
const captureOptions = {
|
|
6166
|
+
timestamp: options.timestamp,
|
|
6167
|
+
disableGeoip: options.disableGeoip,
|
|
6168
|
+
uuid: options.uuid
|
|
6169
|
+
};
|
|
6170
|
+
const message = {
|
|
6171
|
+
distinctId,
|
|
6172
|
+
event,
|
|
6173
|
+
properties: {
|
|
6174
|
+
...properties,
|
|
6175
|
+
...this.getCommonEventProperties()
|
|
6176
|
+
}
|
|
6177
|
+
};
|
|
6178
|
+
return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
|
|
6179
|
+
}).catch((err) => {
|
|
4574
6180
|
if (err)
|
|
4575
6181
|
console.error(err);
|
|
4576
6182
|
}));
|
|
4577
6183
|
}
|
|
6184
|
+
_capturePreparedEvent(props, immediate) {
|
|
6185
|
+
return this._sendPreparedEvent("capture", props, immediate);
|
|
6186
|
+
}
|
|
6187
|
+
capture(props) {
|
|
6188
|
+
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.");
|
|
6189
|
+
this._capturePreparedEvent(props, false);
|
|
6190
|
+
}
|
|
4578
6191
|
async captureImmediate(props) {
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
6192
|
+
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.");
|
|
6193
|
+
return this._capturePreparedEvent(props, true);
|
|
6194
|
+
}
|
|
6195
|
+
captureAi(props) {
|
|
6196
|
+
if (this.disabled)
|
|
6197
|
+
return;
|
|
6198
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
6199
|
+
this._sendPreparedAiEvent({
|
|
6200
|
+
...props,
|
|
6201
|
+
uuid
|
|
6202
|
+
}, false);
|
|
6203
|
+
return uuid;
|
|
6204
|
+
}
|
|
6205
|
+
async captureAiImmediate(props) {
|
|
6206
|
+
if (this.disabled)
|
|
6207
|
+
return;
|
|
6208
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
6209
|
+
await this._sendPreparedAiEvent({
|
|
6210
|
+
...props,
|
|
6211
|
+
uuid
|
|
6212
|
+
}, true);
|
|
6213
|
+
return uuid;
|
|
6214
|
+
}
|
|
6215
|
+
_sendPreparedAiEvent(props, immediate) {
|
|
6216
|
+
if (typeof props?.event == "string" && !props.event.startsWith("$ai_"))
|
|
6217
|
+
this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
|
|
6218
|
+
this._aiCaptureRouteActive = true;
|
|
6219
|
+
return this._sendPreparedEvent("capture", props, immediate, undefined, AI_CAPTURE_ROUTE);
|
|
4591
6220
|
}
|
|
4592
6221
|
identify({ distinctId, properties = {}, disableGeoip }) {
|
|
4593
6222
|
const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
|
|
@@ -4598,8 +6227,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4598
6227
|
$set_once: setOnceProps,
|
|
4599
6228
|
$anon_distinct_id: $anon_distinct_id ?? undefined
|
|
4600
6229
|
};
|
|
4601
|
-
|
|
6230
|
+
this._sendPreparedEvent("identify", {
|
|
6231
|
+
distinctId,
|
|
6232
|
+
event: "$identify",
|
|
6233
|
+
properties: eventProperties,
|
|
4602
6234
|
disableGeoip
|
|
6235
|
+
}, false, {
|
|
6236
|
+
includeContextProperties: false
|
|
4603
6237
|
});
|
|
4604
6238
|
}
|
|
4605
6239
|
async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
|
|
@@ -4611,18 +6245,65 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4611
6245
|
$set_once: setOnceProps,
|
|
4612
6246
|
$anon_distinct_id: $anon_distinct_id ?? undefined
|
|
4613
6247
|
};
|
|
4614
|
-
await
|
|
6248
|
+
await this._sendPreparedEvent("identify", {
|
|
6249
|
+
distinctId,
|
|
6250
|
+
event: "$identify",
|
|
6251
|
+
properties: eventProperties,
|
|
4615
6252
|
disableGeoip
|
|
6253
|
+
}, true, {
|
|
6254
|
+
includeContextProperties: false
|
|
6255
|
+
});
|
|
6256
|
+
}
|
|
6257
|
+
setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
|
|
6258
|
+
if (Object.keys(properties).length === 0 && Object.keys(propertiesOnce).length === 0)
|
|
6259
|
+
return;
|
|
6260
|
+
const eventProperties = {};
|
|
6261
|
+
if (Object.keys(properties).length > 0)
|
|
6262
|
+
eventProperties.$set = properties;
|
|
6263
|
+
if (Object.keys(propertiesOnce).length > 0)
|
|
6264
|
+
eventProperties.$set_once = propertiesOnce;
|
|
6265
|
+
this.capture({
|
|
6266
|
+
distinctId,
|
|
6267
|
+
event: "$set",
|
|
6268
|
+
properties: eventProperties
|
|
6269
|
+
});
|
|
6270
|
+
}
|
|
6271
|
+
unsetPersonProperties({ distinctId, properties }) {
|
|
6272
|
+
const propertyNames = normalizeUnsetPersonProperties(properties);
|
|
6273
|
+
if (propertyNames.length === 0)
|
|
6274
|
+
return;
|
|
6275
|
+
this.capture({
|
|
6276
|
+
distinctId,
|
|
6277
|
+
event: "$set",
|
|
6278
|
+
properties: {
|
|
6279
|
+
$unset: propertyNames
|
|
6280
|
+
}
|
|
4616
6281
|
});
|
|
4617
6282
|
}
|
|
4618
6283
|
alias(data) {
|
|
4619
|
-
|
|
6284
|
+
this._sendPreparedEvent("alias", {
|
|
6285
|
+
distinctId: data.distinctId,
|
|
6286
|
+
event: "$create_alias",
|
|
6287
|
+
properties: {
|
|
6288
|
+
distinct_id: data.distinctId,
|
|
6289
|
+
alias: data.alias
|
|
6290
|
+
},
|
|
4620
6291
|
disableGeoip: data.disableGeoip
|
|
6292
|
+
}, false, {
|
|
6293
|
+
includeContextProperties: false
|
|
4621
6294
|
});
|
|
4622
6295
|
}
|
|
4623
6296
|
async aliasImmediate(data) {
|
|
4624
|
-
await
|
|
6297
|
+
await this._sendPreparedEvent("alias", {
|
|
6298
|
+
distinctId: data.distinctId,
|
|
6299
|
+
event: "$create_alias",
|
|
6300
|
+
properties: {
|
|
6301
|
+
distinct_id: data.distinctId,
|
|
6302
|
+
alias: data.alias
|
|
6303
|
+
},
|
|
4625
6304
|
disableGeoip: data.disableGeoip
|
|
6305
|
+
}, true, {
|
|
6306
|
+
includeContextProperties: false
|
|
4626
6307
|
});
|
|
4627
6308
|
}
|
|
4628
6309
|
isLocalEvaluationReady() {
|
|
@@ -4677,7 +6358,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4677
6358
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
|
|
4678
6359
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4679
6360
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4680
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties);
|
|
6361
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, this.personPropertiesForLocalEvaluation(distinctId, personProperties), groupProperties);
|
|
4681
6362
|
if (onlyEvaluateLocally == undefined)
|
|
4682
6363
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
4683
6364
|
let result;
|
|
@@ -4688,6 +6369,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4688
6369
|
let flagId;
|
|
4689
6370
|
let flagVersion;
|
|
4690
6371
|
let flagReason;
|
|
6372
|
+
let flagHasExperiment;
|
|
4691
6373
|
const localEvaluationEnabled = this.featureFlagsPoller !== undefined;
|
|
4692
6374
|
if (localEvaluationEnabled) {
|
|
4693
6375
|
await this.featureFlagsPoller?.loadFeatureFlags();
|
|
@@ -4702,6 +6384,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4702
6384
|
const value = localResult.value;
|
|
4703
6385
|
flagId = flag.id;
|
|
4704
6386
|
flagReason = "Evaluated locally";
|
|
6387
|
+
flagHasExperiment = flag.has_experiment;
|
|
4705
6388
|
result = {
|
|
4706
6389
|
key,
|
|
4707
6390
|
enabled: value !== false,
|
|
@@ -4717,12 +6400,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4717
6400
|
}
|
|
4718
6401
|
}
|
|
4719
6402
|
if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
|
|
4720
|
-
const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6403
|
+
const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [
|
|
4721
6404
|
key
|
|
4722
6405
|
]);
|
|
4723
6406
|
if (flagsResponse === undefined)
|
|
4724
6407
|
featureFlagError = FeatureFlagError2.UNKNOWN_ERROR;
|
|
4725
6408
|
else {
|
|
6409
|
+
this._minimalFlagCalledEvents = flagsResponse.minimalFlagCalledEvents === true;
|
|
4726
6410
|
requestId = flagsResponse.requestId;
|
|
4727
6411
|
evaluatedAt = flagsResponse.evaluatedAt;
|
|
4728
6412
|
const errors = [];
|
|
@@ -4737,6 +6421,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4737
6421
|
flagId = flagDetail.metadata?.id;
|
|
4738
6422
|
flagVersion = flagDetail.metadata?.version;
|
|
4739
6423
|
flagReason = flagDetail.reason?.description ?? flagDetail.reason?.code;
|
|
6424
|
+
flagHasExperiment = flagDetail.metadata?.has_experiment;
|
|
4740
6425
|
let parsedPayload;
|
|
4741
6426
|
if (flagDetail.metadata?.payload !== undefined)
|
|
4742
6427
|
try {
|
|
@@ -4747,7 +6432,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4747
6432
|
result = {
|
|
4748
6433
|
key,
|
|
4749
6434
|
enabled: flagDetail.enabled,
|
|
4750
|
-
variant: flagDetail.variant,
|
|
6435
|
+
variant: flagDetail.variant ?? undefined,
|
|
4751
6436
|
payload: parsedPayload
|
|
4752
6437
|
};
|
|
4753
6438
|
}
|
|
@@ -4768,6 +6453,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4768
6453
|
$feature_flag_request_id: requestId,
|
|
4769
6454
|
$feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt
|
|
4770
6455
|
};
|
|
6456
|
+
if (flagHasExperiment !== undefined)
|
|
6457
|
+
properties.$feature_flag_has_experiment = flagHasExperiment;
|
|
4771
6458
|
if (flagWasLocallyEvaluated && this.featureFlagsPoller) {
|
|
4772
6459
|
const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt();
|
|
4773
6460
|
if (flagDefinitionsLoadedAt !== undefined)
|
|
@@ -4882,7 +6569,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4882
6569
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
4883
6570
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4884
6571
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4885
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
6572
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
|
|
4886
6573
|
if (onlyEvaluateLocally == undefined)
|
|
4887
6574
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
4888
6575
|
const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys);
|
|
@@ -4895,7 +6582,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4895
6582
|
fallbackToFlags = localEvaluationResult.fallbackToFlags;
|
|
4896
6583
|
}
|
|
4897
6584
|
if (fallbackToFlags && !onlyEvaluateLocally) {
|
|
4898
|
-
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6585
|
+
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
|
|
4899
6586
|
featureFlags = {
|
|
4900
6587
|
...featureFlags,
|
|
4901
6588
|
...remoteEvaluationResult.flags || {}
|
|
@@ -4943,9 +6630,10 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4943
6630
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
4944
6631
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4945
6632
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4946
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
6633
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
|
|
4947
6634
|
if (onlyEvaluateLocally == undefined)
|
|
4948
6635
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
6636
|
+
const requestedFlagKeys = flagKeys ? new Set(flagKeys) : undefined;
|
|
4949
6637
|
const records = {};
|
|
4950
6638
|
let requestId;
|
|
4951
6639
|
let evaluatedAt;
|
|
@@ -4964,14 +6652,17 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4964
6652
|
id: flagDef?.id,
|
|
4965
6653
|
version: undefined,
|
|
4966
6654
|
reason: "Evaluated locally",
|
|
4967
|
-
locallyEvaluated: true
|
|
6655
|
+
locallyEvaluated: true,
|
|
6656
|
+
hasExperiment: flagDef?.has_experiment
|
|
4968
6657
|
};
|
|
4969
6658
|
locallyEvaluatedKeys.add(key);
|
|
4970
6659
|
}
|
|
4971
|
-
const
|
|
6660
|
+
const requestedFlagMissingLocally = requestedFlagKeys !== undefined && Array.from(requestedFlagKeys).some((key) => this.featureFlagsPoller?.featureFlagsByKey[key] === undefined);
|
|
6661
|
+
const fallbackToFlags = localResult ? localResult.fallbackToFlags || requestedFlagMissingLocally : true;
|
|
4972
6662
|
if (fallbackToFlags && !onlyEvaluateLocally) {
|
|
4973
|
-
const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6663
|
+
const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
|
|
4974
6664
|
if (details) {
|
|
6665
|
+
this._minimalFlagCalledEvents = details.minimalFlagCalledEvents === true;
|
|
4975
6666
|
requestId = details.requestId;
|
|
4976
6667
|
evaluatedAt = details.evaluatedAt;
|
|
4977
6668
|
errorsWhileComputing = Boolean(details.errorsWhileComputingFlags);
|
|
@@ -4994,7 +6685,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4994
6685
|
id: detail.metadata?.id,
|
|
4995
6686
|
version: detail.metadata?.version,
|
|
4996
6687
|
reason: detail.reason?.description ?? detail.reason?.code,
|
|
4997
|
-
locallyEvaluated: false
|
|
6688
|
+
locallyEvaluated: false,
|
|
6689
|
+
hasExperiment: detail.metadata?.has_experiment
|
|
4998
6690
|
};
|
|
4999
6691
|
}
|
|
5000
6692
|
}
|
|
@@ -5014,7 +6706,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5014
6706
|
id: existing?.id,
|
|
5015
6707
|
version: existing?.version,
|
|
5016
6708
|
reason: existing?.reason,
|
|
5017
|
-
locallyEvaluated: existing?.locallyEvaluated ?? false
|
|
6709
|
+
locallyEvaluated: existing?.locallyEvaluated ?? false,
|
|
6710
|
+
hasExperiment: existing?.hasExperiment
|
|
5018
6711
|
};
|
|
5019
6712
|
}
|
|
5020
6713
|
if (this._payloadOverrides !== undefined)
|
|
@@ -5026,6 +6719,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5026
6719
|
payload
|
|
5027
6720
|
};
|
|
5028
6721
|
}
|
|
6722
|
+
if (requestedFlagKeys !== undefined) {
|
|
6723
|
+
for (const key of Object.keys(records))
|
|
6724
|
+
if (!requestedFlagKeys.has(key))
|
|
6725
|
+
delete records[key];
|
|
6726
|
+
}
|
|
5029
6727
|
return new FeatureFlagEvaluations({
|
|
5030
6728
|
host: this._getFeatureFlagEvaluationsHost(),
|
|
5031
6729
|
distinctId: resolvedDistinctId,
|
|
@@ -5039,6 +6737,9 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5039
6737
|
quotaLimited
|
|
5040
6738
|
});
|
|
5041
6739
|
}
|
|
6740
|
+
_shouldSendMinimalFlagCalledEvent(event, properties) {
|
|
6741
|
+
return event === "$feature_flag_called" && this._minimalFlagCalledEvents && properties.$feature_flag_has_experiment === false;
|
|
6742
|
+
}
|
|
5042
6743
|
_captureFlagCalledEventIfNeeded(params) {
|
|
5043
6744
|
const { distinctId, key, response, groups, disableGeoip, properties } = params;
|
|
5044
6745
|
const groupSuffix = groups && Object.keys(groups).length > 0 ? `_${JSON.stringify(Object.entries(groups).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0))}` : "";
|
|
@@ -5073,9 +6774,32 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5073
6774
|
return this._featureFlagEvaluationsHost;
|
|
5074
6775
|
}
|
|
5075
6776
|
groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
5076
|
-
|
|
6777
|
+
this._sendPreparedEvent("capture", {
|
|
6778
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
6779
|
+
event: "$groupidentify",
|
|
6780
|
+
properties: {
|
|
6781
|
+
$group_type: groupType,
|
|
6782
|
+
$group_key: groupKey,
|
|
6783
|
+
$group_set: properties || {}
|
|
6784
|
+
},
|
|
6785
|
+
disableGeoip
|
|
6786
|
+
}, false, {
|
|
6787
|
+
includeContextProperties: false
|
|
6788
|
+
});
|
|
6789
|
+
}
|
|
6790
|
+
async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
6791
|
+
await this._sendPreparedEvent("capture", {
|
|
6792
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
6793
|
+
event: "$groupidentify",
|
|
6794
|
+
properties: {
|
|
6795
|
+
$group_type: groupType,
|
|
6796
|
+
$group_key: groupKey,
|
|
6797
|
+
$group_set: properties || {}
|
|
6798
|
+
},
|
|
5077
6799
|
disableGeoip
|
|
5078
|
-
},
|
|
6800
|
+
}, true, {
|
|
6801
|
+
includeContextProperties: false
|
|
6802
|
+
});
|
|
5079
6803
|
}
|
|
5080
6804
|
async reloadFeatureFlags() {
|
|
5081
6805
|
await this.featureFlagsPoller?.loadFeatureFlags(true);
|
|
@@ -5147,12 +6871,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5147
6871
|
this.context?.enter(data, options);
|
|
5148
6872
|
}
|
|
5149
6873
|
async _shutdown(shutdownTimeoutMs) {
|
|
6874
|
+
const shutdownDeadlineMs = Date.now() + (shutdownTimeoutMs ?? 30000);
|
|
5150
6875
|
const resolve = this._consumeWaitUntilCycle();
|
|
5151
6876
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
5152
6877
|
this.errorTracking.shutdown();
|
|
6878
|
+
if (this._metrics) {
|
|
6879
|
+
await raceWithTimeout(this._metrics.flush().catch(() => {}), Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
6880
|
+
this._metrics.reset();
|
|
6881
|
+
}
|
|
5153
6882
|
try {
|
|
5154
|
-
return await super._shutdown(
|
|
6883
|
+
return await super._shutdown(Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
5155
6884
|
} finally {
|
|
6885
|
+
this.distinctIdHasSentFlagCalls = {};
|
|
5156
6886
|
resolve?.();
|
|
5157
6887
|
}
|
|
5158
6888
|
}
|
|
@@ -5247,7 +6977,6 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5247
6977
|
}
|
|
5248
6978
|
addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties) {
|
|
5249
6979
|
const allPersonProperties = {
|
|
5250
|
-
distinct_id: distinctId,
|
|
5251
6980
|
...personProperties || {}
|
|
5252
6981
|
};
|
|
5253
6982
|
const allGroupProperties = {};
|
|
@@ -5262,6 +6991,12 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5262
6991
|
allGroupProperties
|
|
5263
6992
|
};
|
|
5264
6993
|
}
|
|
6994
|
+
personPropertiesForLocalEvaluation(distinctId, personProperties) {
|
|
6995
|
+
return {
|
|
6996
|
+
distinct_id: distinctId,
|
|
6997
|
+
...personProperties || {}
|
|
6998
|
+
};
|
|
6999
|
+
}
|
|
5265
7000
|
createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties) {
|
|
5266
7001
|
return {
|
|
5267
7002
|
distinctId,
|
|
@@ -5272,21 +7007,21 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5272
7007
|
};
|
|
5273
7008
|
}
|
|
5274
7009
|
captureException(error, distinctId, additionalProperties, uuid, flags) {
|
|
5275
|
-
if (!
|
|
7010
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
5276
7011
|
const syntheticException = new Error("PostHog syntheticException");
|
|
5277
|
-
this.addPendingPromise(
|
|
7012
|
+
this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
5278
7013
|
syntheticException
|
|
5279
|
-
}, distinctId, additionalProperties).then((msg) => this.
|
|
7014
|
+
}, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
|
|
5280
7015
|
...msg,
|
|
5281
7016
|
uuid,
|
|
5282
7017
|
flags
|
|
5283
|
-
})));
|
|
7018
|
+
}, false)));
|
|
5284
7019
|
}
|
|
5285
7020
|
}
|
|
5286
7021
|
async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
|
|
5287
|
-
if (!
|
|
7022
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
5288
7023
|
const syntheticException = new Error("PostHog syntheticException");
|
|
5289
|
-
return this.addPendingPromise(
|
|
7024
|
+
return this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
5290
7025
|
syntheticException
|
|
5291
7026
|
}, distinctId, additionalProperties).then((msg) => this.captureImmediate({
|
|
5292
7027
|
...msg,
|
|
@@ -5295,24 +7030,31 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5295
7030
|
}
|
|
5296
7031
|
}
|
|
5297
7032
|
async prepareEventMessage(props) {
|
|
7033
|
+
return this._prepareEventMessage(props);
|
|
7034
|
+
}
|
|
7035
|
+
async _prepareEventMessage(props, options = {}) {
|
|
5298
7036
|
const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
|
|
5299
7037
|
const contextData = this.context?.get();
|
|
7038
|
+
const includeContextProperties = options.includeContextProperties ?? true;
|
|
5300
7039
|
let mergedDistinctId = distinctId || contextData?.distinctId;
|
|
5301
|
-
const mergedProperties = {
|
|
7040
|
+
const mergedProperties = includeContextProperties ? {
|
|
5302
7041
|
...this.props,
|
|
5303
7042
|
...contextData?.properties || {},
|
|
5304
7043
|
...properties || {}
|
|
7044
|
+
} : {
|
|
7045
|
+
...properties || {}
|
|
5305
7046
|
};
|
|
5306
7047
|
if (!mergedDistinctId) {
|
|
5307
7048
|
mergedDistinctId = uuidv7();
|
|
5308
7049
|
mergedProperties.$process_person_profile = false;
|
|
5309
7050
|
}
|
|
5310
|
-
if (contextData?.sessionId && !mergedProperties.$session_id)
|
|
7051
|
+
if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id)
|
|
5311
7052
|
mergedProperties.$session_id = contextData.sessionId;
|
|
7053
|
+
const finalProperties = this._shouldSendMinimalFlagCalledEvent(event, mergedProperties) ? minimizeFlagCalledEventProperties(mergedProperties) : mergedProperties;
|
|
5312
7054
|
const eventMessage = this._runBeforeSend({
|
|
5313
7055
|
distinctId: mergedDistinctId,
|
|
5314
7056
|
event,
|
|
5315
|
-
properties:
|
|
7057
|
+
properties: finalProperties,
|
|
5316
7058
|
groups,
|
|
5317
7059
|
flags,
|
|
5318
7060
|
sendFeatureFlags,
|
|
@@ -5336,12 +7078,14 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5336
7078
|
}
|
|
5337
7079
|
return {};
|
|
5338
7080
|
}).catch(() => ({})).then((additionalProperties) => {
|
|
5339
|
-
const
|
|
7081
|
+
const resolvedGroups = eventMessage.groups || groups;
|
|
7082
|
+
return {
|
|
5340
7083
|
...additionalProperties,
|
|
5341
7084
|
...eventMessage.properties || {},
|
|
5342
|
-
|
|
7085
|
+
...resolvedGroups !== undefined && Object.keys(resolvedGroups).length > 0 ? {
|
|
7086
|
+
$groups: resolvedGroups
|
|
7087
|
+
} : {}
|
|
5343
7088
|
};
|
|
5344
|
-
return props2;
|
|
5345
7089
|
});
|
|
5346
7090
|
if (eventMessage.event === "$pageview" && this.options.__preview_capture_bot_pageviews && typeof eventProperties.$raw_user_agent == "string") {
|
|
5347
7091
|
if (isBlockedUA(eventProperties.$raw_user_agent, this.options.custom_blocked_useragents || [])) {
|
|
@@ -5368,22 +7112,26 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5368
7112
|
beforeSend
|
|
5369
7113
|
];
|
|
5370
7114
|
let result = eventMessage;
|
|
5371
|
-
for (const fn of fns)
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
7115
|
+
for (const fn of fns)
|
|
7116
|
+
try {
|
|
7117
|
+
result = fn(result);
|
|
7118
|
+
if (!result) {
|
|
7119
|
+
this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
|
|
7120
|
+
return null;
|
|
7121
|
+
}
|
|
7122
|
+
if (!result.properties || Object.keys(result.properties).length === 0) {
|
|
7123
|
+
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
7124
|
+
this._logger.warn(message);
|
|
7125
|
+
}
|
|
7126
|
+
} catch (error) {
|
|
7127
|
+
this._logger.error(`Error in before_send function for event '${eventMessage.event}':`, error);
|
|
5375
7128
|
return null;
|
|
5376
7129
|
}
|
|
5377
|
-
if (!result.properties || Object.keys(result.properties).length === 0) {
|
|
5378
|
-
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
5379
|
-
this._logger.warn(message);
|
|
5380
|
-
}
|
|
5381
|
-
}
|
|
5382
7130
|
return result;
|
|
5383
7131
|
}
|
|
5384
7132
|
}
|
|
5385
7133
|
|
|
5386
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
7134
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/context/context.mjs
|
|
5387
7135
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5388
7136
|
|
|
5389
7137
|
class PostHogContext {
|
|
@@ -5414,7 +7162,22 @@ class PostHogContext {
|
|
|
5414
7162
|
}
|
|
5415
7163
|
}
|
|
5416
7164
|
|
|
5417
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
7165
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/gzip.node.mjs
|
|
7166
|
+
import { gzip } from "node:zlib";
|
|
7167
|
+
import { promisify } from "node:util";
|
|
7168
|
+
var gzipAsync = promisify(gzip);
|
|
7169
|
+
async function gzipCompress2(input, isDebug = true) {
|
|
7170
|
+
try {
|
|
7171
|
+
const compressed = await gzipAsync(input);
|
|
7172
|
+
return new Uint8Array(compressed);
|
|
7173
|
+
} catch (error) {
|
|
7174
|
+
if (isDebug)
|
|
7175
|
+
console.error("Failed to gzip compress data", error);
|
|
7176
|
+
return null;
|
|
7177
|
+
}
|
|
7178
|
+
}
|
|
7179
|
+
|
|
7180
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
|
|
5418
7181
|
var NAME = "posthog-node";
|
|
5419
7182
|
function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
|
|
5420
7183
|
"error"
|
|
@@ -5454,6 +7217,9 @@ function createEventProcessor(_posthog, { organization, projectId, prefix, sever
|
|
|
5454
7217
|
$sentry_exception_type: exceptions[0]?.type,
|
|
5455
7218
|
$sentry_tags: event.tags
|
|
5456
7219
|
};
|
|
7220
|
+
const injectedReleaseId = getInjectedReleaseId();
|
|
7221
|
+
if (injectedReleaseId)
|
|
7222
|
+
properties.$release_id = injectedReleaseId;
|
|
5457
7223
|
if (organization && projectId)
|
|
5458
7224
|
properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
|
|
5459
7225
|
if (sendExceptionsToPostHog)
|
|
@@ -5482,24 +7248,27 @@ class PostHogSentryIntegration {
|
|
|
5482
7248
|
};
|
|
5483
7249
|
}
|
|
5484
7250
|
}
|
|
5485
|
-
// ../../../node_modules/.bun/posthog-node@5.
|
|
7251
|
+
// ../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/entrypoints/index.node.mjs
|
|
5486
7252
|
class PostHog extends PostHogBackendClient {
|
|
5487
7253
|
getLibraryId() {
|
|
5488
7254
|
return "posthog-node";
|
|
5489
7255
|
}
|
|
7256
|
+
compressPayload(payload) {
|
|
7257
|
+
return gzipCompress2(payload, this.isDebug);
|
|
7258
|
+
}
|
|
5490
7259
|
initializeContext() {
|
|
5491
7260
|
return new PostHogContext;
|
|
5492
7261
|
}
|
|
5493
7262
|
createErrorPropertiesBuilder() {
|
|
5494
|
-
return new
|
|
5495
|
-
new
|
|
5496
|
-
new
|
|
5497
|
-
new
|
|
5498
|
-
new
|
|
5499
|
-
new
|
|
5500
|
-
],
|
|
7263
|
+
return new ErrorPropertiesBuilder([
|
|
7264
|
+
new EventCoercer,
|
|
7265
|
+
new ErrorCoercer,
|
|
7266
|
+
new ObjectCoercer,
|
|
7267
|
+
new StringCoercer,
|
|
7268
|
+
new PrimitiveCoercer
|
|
7269
|
+
], createStackParser("node:javascript", nodeStackLineParser), [
|
|
5501
7270
|
createModulerModifier(),
|
|
5502
|
-
addSourceContext,
|
|
7271
|
+
(frames) => addSourceContext(frames, undefined, this._logger),
|
|
5503
7272
|
createRelativePathModifier()
|
|
5504
7273
|
]);
|
|
5505
7274
|
}
|
|
@@ -5884,12 +7653,12 @@ function parseHookInput(raw) {
|
|
|
5884
7653
|
}
|
|
5885
7654
|
}
|
|
5886
7655
|
function isCodexSessionStartInput(value) {
|
|
5887
|
-
return
|
|
7656
|
+
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";
|
|
5888
7657
|
}
|
|
5889
7658
|
function isStringOrNull(value) {
|
|
5890
7659
|
return typeof value === "string" || value === null;
|
|
5891
7660
|
}
|
|
5892
|
-
function
|
|
7661
|
+
function isRecord3(value) {
|
|
5893
7662
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5894
7663
|
}
|
|
5895
7664
|
function readStdin() {
|