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,21 +1,6 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __returnValue = (v) => v;
|
|
3
|
-
function __exportSetter(name, newValue) {
|
|
4
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
-
}
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
set: __exportSetter.bind(all, name)
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
1
|
// ../../../../telemetry-core/src/activity-state.ts
|
|
17
|
-
import { existsSync, mkdirSync as
|
|
18
|
-
import { basename, join } from "node:path";
|
|
2
|
+
import { existsSync, mkdirSync as mkdirSync3, readFileSync } from "node:fs";
|
|
3
|
+
import { basename, join as join2 } from "node:path";
|
|
19
4
|
|
|
20
5
|
// ../../../../utils/src/atomic-write.ts
|
|
21
6
|
import {
|
|
@@ -23,9 +8,12 @@ import {
|
|
|
23
8
|
fsyncSync,
|
|
24
9
|
openSync,
|
|
25
10
|
renameSync,
|
|
11
|
+
rmSync,
|
|
26
12
|
unlinkSync,
|
|
27
13
|
writeFileSync
|
|
28
14
|
} from "node:fs";
|
|
15
|
+
import { randomUUID } from "node:crypto";
|
|
16
|
+
import { dirname } from "node:path";
|
|
29
17
|
var TOLERATED_FSYNC_CODES = new Set([
|
|
30
18
|
"EPERM",
|
|
31
19
|
"EACCES",
|
|
@@ -47,24 +35,36 @@ function tolerantFsyncSync(fileDescriptor, fsyncImpl) {
|
|
|
47
35
|
}
|
|
48
36
|
}
|
|
49
37
|
function writeFileAtomically(filePath, content, options = {}) {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
try {
|
|
54
|
-
tolerantFsyncSync(tempFileDescriptor, options.fsyncSync ?? fsyncSync);
|
|
55
|
-
} finally {
|
|
56
|
-
closeSync(tempFileDescriptor);
|
|
57
|
-
}
|
|
38
|
+
const platform = options.platform ?? process.platform;
|
|
39
|
+
const fsyncImpl = options.fsyncSync ?? fsyncSync;
|
|
40
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
58
41
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
writeFileSync(tempPath, content, "utf-8");
|
|
43
|
+
const tempFileDescriptor = openSync(tempPath, "r+");
|
|
44
|
+
try {
|
|
45
|
+
tolerantFsyncSync(tempFileDescriptor, fsyncImpl);
|
|
46
|
+
} finally {
|
|
47
|
+
closeSync(tempFileDescriptor);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
renameSync(tempPath, filePath);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
const isPermissionError = error instanceof Error && (error.message.includes("EPERM") || error.message.includes("EACCES"));
|
|
53
|
+
if (platform !== "win32" || !isPermissionError)
|
|
54
|
+
throw error;
|
|
63
55
|
unlinkSync(filePath);
|
|
64
56
|
renameSync(tempPath, filePath);
|
|
57
|
+
}
|
|
58
|
+
if (platform === "win32")
|
|
65
59
|
return;
|
|
60
|
+
const directoryFileDescriptor = openSync(dirname(filePath), "r");
|
|
61
|
+
try {
|
|
62
|
+
tolerantFsyncSync(directoryFileDescriptor, fsyncImpl);
|
|
63
|
+
} finally {
|
|
64
|
+
closeSync(directoryFileDescriptor);
|
|
66
65
|
}
|
|
67
|
-
|
|
66
|
+
} finally {
|
|
67
|
+
rmSync(tempPath, { force: true });
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -92,36 +92,82 @@ function resolveWritableDirectory(preferredDir, fallbackSuffix, osProvider) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// ../../../../telemetry-core/src/day-claim.ts
|
|
96
|
+
import { closeSync as closeSync2, mkdirSync as mkdirSync2, openSync as openSync2, readdirSync, rmSync as rmSync2 } from "node:fs";
|
|
97
|
+
import { join } from "node:path";
|
|
98
|
+
var CLAIM_PREFIX = "daily-active.";
|
|
99
|
+
var CLAIM_SUFFIX = ".claim";
|
|
100
|
+
function getTelemetryDayClaimFilePath(stateDir, dayUTC) {
|
|
101
|
+
return join(stateDir, `${CLAIM_PREFIX}${dayUTC}${CLAIM_SUFFIX}`);
|
|
102
|
+
}
|
|
103
|
+
function claimUtcDay(stateDir, dayUTC) {
|
|
104
|
+
try {
|
|
105
|
+
mkdirSync2(stateDir, { recursive: true });
|
|
106
|
+
closeSync2(openSync2(getTelemetryDayClaimFilePath(stateDir, dayUTC), "wx"));
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return error.code === "EEXIST" ? "already-claimed" : "unavailable";
|
|
109
|
+
}
|
|
110
|
+
pruneSupersededClaims(stateDir, dayUTC);
|
|
111
|
+
return "claimed";
|
|
112
|
+
}
|
|
113
|
+
function pruneSupersededClaims(stateDir, dayUTC) {
|
|
114
|
+
const currentClaim = `${CLAIM_PREFIX}${dayUTC}${CLAIM_SUFFIX}`;
|
|
115
|
+
let entries;
|
|
116
|
+
try {
|
|
117
|
+
entries = readdirSync(stateDir);
|
|
118
|
+
} catch {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
if (entry === currentClaim)
|
|
123
|
+
continue;
|
|
124
|
+
if (!entry.startsWith(CLAIM_PREFIX) || !entry.endsWith(CLAIM_SUFFIX))
|
|
125
|
+
continue;
|
|
126
|
+
try {
|
|
127
|
+
rmSync2(join(stateDir, entry), { force: true });
|
|
128
|
+
} catch {}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
95
132
|
// ../../../../telemetry-core/src/activity-state.ts
|
|
96
133
|
var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
|
|
134
|
+
var capturedDaysByStateDir = new Map;
|
|
97
135
|
function resolveTelemetryStateDir(product, options = {}) {
|
|
98
136
|
const dataDir = resolveXdgDataDir(product.cacheDirName, {
|
|
99
137
|
env: options.env,
|
|
100
138
|
osProvider: options.osProvider
|
|
101
139
|
});
|
|
102
|
-
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined :
|
|
140
|
+
const xdgStateDir = options.env?.XDG_DATA_HOME === undefined ? undefined : join2(options.env.XDG_DATA_HOME, product.cacheDirName);
|
|
103
141
|
if (dataDir === xdgStateDir || xdgStateDir === undefined && basename(dataDir) === product.cacheDirName) {
|
|
104
142
|
return dataDir;
|
|
105
143
|
}
|
|
106
|
-
return
|
|
144
|
+
return join2(dataDir, product.cacheDirName);
|
|
107
145
|
}
|
|
108
146
|
function getTelemetryActivityStateFilePath(stateDir) {
|
|
109
|
-
return
|
|
147
|
+
return join2(stateDir, POSTHOG_ACTIVITY_STATE_FILE);
|
|
110
148
|
}
|
|
111
149
|
function getDailyActiveCaptureState(input) {
|
|
112
|
-
const state = readPostHogActivityState(input.stateDir, input.diagnostics);
|
|
113
150
|
const dayUTC = getUtcDayString(input.now ?? new Date);
|
|
114
|
-
|
|
115
|
-
|
|
151
|
+
if (capturedDaysByStateDir.get(input.stateDir) === dayUTC) {
|
|
152
|
+
return { dayUTC, captureDaily: false };
|
|
153
|
+
}
|
|
154
|
+
const state = readPostHogActivityState(input.stateDir, input.diagnostics);
|
|
155
|
+
if (state.lastActiveDayUTC === dayUTC) {
|
|
156
|
+
capturedDaysByStateDir.set(input.stateDir, dayUTC);
|
|
157
|
+
return { dayUTC, captureDaily: false };
|
|
158
|
+
}
|
|
159
|
+
const claim = claimUtcDay(input.stateDir, dayUTC);
|
|
160
|
+
capturedDaysByStateDir.set(input.stateDir, dayUTC);
|
|
161
|
+
if (claim === "already-claimed") {
|
|
162
|
+
return { dayUTC, captureDaily: false };
|
|
163
|
+
}
|
|
164
|
+
if (claim === "claimed") {
|
|
116
165
|
writePostHogActivityState(input.stateDir, {
|
|
117
166
|
...state,
|
|
118
167
|
lastActiveDayUTC: dayUTC
|
|
119
168
|
}, input.diagnostics);
|
|
120
169
|
}
|
|
121
|
-
return {
|
|
122
|
-
dayUTC,
|
|
123
|
-
captureDaily
|
|
124
|
-
};
|
|
170
|
+
return { dayUTC, captureDaily: true };
|
|
125
171
|
}
|
|
126
172
|
function getUtcDayString(date) {
|
|
127
173
|
return date.toISOString().slice(0, 10);
|
|
@@ -154,7 +200,7 @@ function readPostHogActivityState(stateDir, diagnostics) {
|
|
|
154
200
|
function writePostHogActivityState(stateDir, nextState, diagnostics) {
|
|
155
201
|
const stateFilePath = getTelemetryActivityStateFilePath(stateDir);
|
|
156
202
|
try {
|
|
157
|
-
|
|
203
|
+
mkdirSync3(stateDir, { recursive: true });
|
|
158
204
|
writeFileAtomically(stateFilePath, `${JSON.stringify(nextState, null, 2)}
|
|
159
205
|
`);
|
|
160
206
|
} catch (error) {
|
|
@@ -173,19 +219,19 @@ var DEFAULT_POSTHOG_API_KEY = "phc_CFJhj5HyvA62QPhvyaUCtaq23aUfznnijg5VaaGkNk74"
|
|
|
173
219
|
var UNCONFIGURED_POSTHOG_API_KEY = "phc_REPLACE_ME_OMO_NATIVE";
|
|
174
220
|
|
|
175
221
|
// ../../../../telemetry-core/src/diagnostics.ts
|
|
176
|
-
import { appendFileSync, existsSync as existsSync2, mkdirSync as
|
|
177
|
-
import { join as
|
|
222
|
+
import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync2 } from "node:fs";
|
|
223
|
+
import { join as join3 } from "node:path";
|
|
178
224
|
var DIAGNOSTICS_FILE_NAME = "telemetry-diagnostics.jsonl";
|
|
179
225
|
var DIAGNOSTICS_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
180
226
|
var DIAGNOSTICS_MAX_BYTES = 256 * 1024;
|
|
181
227
|
function getTelemetryDiagnosticsFilePath(diagnosticsDir) {
|
|
182
|
-
return
|
|
228
|
+
return join3(diagnosticsDir, DIAGNOSTICS_FILE_NAME);
|
|
183
229
|
}
|
|
184
230
|
function writeTelemetryDiagnostic(input, options) {
|
|
185
231
|
const now = options.now ?? new Date;
|
|
186
232
|
try {
|
|
187
233
|
cleanupTelemetryDiagnostics({ diagnosticsDir: options.diagnosticsDir, now });
|
|
188
|
-
|
|
234
|
+
mkdirSync4(options.diagnosticsDir, { recursive: true });
|
|
189
235
|
appendFileSync(getTelemetryDiagnosticsFilePath(options.diagnosticsDir), `${JSON.stringify(toDiagnosticRecord(input, now))}
|
|
190
236
|
`, "utf-8");
|
|
191
237
|
} catch (error) {
|
|
@@ -334,8 +380,8 @@ function getTelemetryHost(env = process.env, defaultHost = DEFAULT_POSTHOG_HOST)
|
|
|
334
380
|
return env["POSTHOG_HOST"]?.trim() || defaultHost;
|
|
335
381
|
}
|
|
336
382
|
|
|
337
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
338
|
-
import { dirname, posix, sep } from "path";
|
|
383
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
384
|
+
import { dirname as dirname2, posix, sep } from "path";
|
|
339
385
|
function createModulerModifier() {
|
|
340
386
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
341
387
|
return async (frames) => {
|
|
@@ -344,7 +390,7 @@ function createModulerModifier() {
|
|
|
344
390
|
return frames;
|
|
345
391
|
};
|
|
346
392
|
}
|
|
347
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
393
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname2(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
|
|
348
394
|
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
349
395
|
return (filename) => {
|
|
350
396
|
if (!filename)
|
|
@@ -366,11 +412,11 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(proces
|
|
|
366
412
|
return decodedFile;
|
|
367
413
|
};
|
|
368
414
|
}
|
|
369
|
-
function normalizeWindowsPath(
|
|
370
|
-
return
|
|
415
|
+
function normalizeWindowsPath(path) {
|
|
416
|
+
return path.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
371
417
|
}
|
|
372
418
|
|
|
373
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
419
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
374
420
|
var normalizeFlagsResponse = (flagsResponse) => {
|
|
375
421
|
if ("flags" in flagsResponse) {
|
|
376
422
|
const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
|
|
@@ -440,8 +486,69 @@ var parsePayload = (response) => {
|
|
|
440
486
|
return response;
|
|
441
487
|
}
|
|
442
488
|
};
|
|
489
|
+
var MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES = [
|
|
490
|
+
"utm_source",
|
|
491
|
+
"utm_medium",
|
|
492
|
+
"utm_campaign",
|
|
493
|
+
"utm_content",
|
|
494
|
+
"utm_term",
|
|
495
|
+
"gad_source",
|
|
496
|
+
"mc_cid",
|
|
497
|
+
"gclid",
|
|
498
|
+
"gclsrc",
|
|
499
|
+
"dclid",
|
|
500
|
+
"gbraid",
|
|
501
|
+
"wbraid",
|
|
502
|
+
"fbclid",
|
|
503
|
+
"msclkid",
|
|
504
|
+
"twclid",
|
|
505
|
+
"li_fat_id",
|
|
506
|
+
"igshid",
|
|
507
|
+
"ttclid",
|
|
508
|
+
"rdt_cid",
|
|
509
|
+
"epik",
|
|
510
|
+
"qclid",
|
|
511
|
+
"sccid",
|
|
512
|
+
"irclid",
|
|
513
|
+
"_kx"
|
|
514
|
+
];
|
|
515
|
+
var MINIMAL_FLAG_CALLED_EVENT_PROPERTIES = [
|
|
516
|
+
"$feature_flag",
|
|
517
|
+
"$feature_flag_response",
|
|
518
|
+
"$feature_flag_has_experiment",
|
|
519
|
+
"$feature_flag_id",
|
|
520
|
+
"$feature_flag_version",
|
|
521
|
+
"$feature_flag_reason",
|
|
522
|
+
"$feature_flag_request_id",
|
|
523
|
+
"$feature_flag_evaluated_at",
|
|
524
|
+
"$feature_flag_error",
|
|
525
|
+
"locally_evaluated",
|
|
526
|
+
"$groups",
|
|
527
|
+
"$process_person_profile",
|
|
528
|
+
"$geoip_disable",
|
|
529
|
+
"$current_url",
|
|
530
|
+
"$pathname",
|
|
531
|
+
"$referring_domain",
|
|
532
|
+
...MINIMAL_FLAG_CALLED_EVENT_CAMPAIGN_PROPERTIES,
|
|
533
|
+
"$session_id",
|
|
534
|
+
"$window_id",
|
|
535
|
+
"$lib",
|
|
536
|
+
"$lib_version",
|
|
537
|
+
"$device_id",
|
|
538
|
+
"$is_server"
|
|
539
|
+
];
|
|
540
|
+
var minimizeFlagCalledEventProperties = (properties, transportKeys = []) => {
|
|
541
|
+
const minimal = {};
|
|
542
|
+
const copyKey = (key) => {
|
|
543
|
+
if (properties[key] !== undefined)
|
|
544
|
+
minimal[key] = properties[key];
|
|
545
|
+
};
|
|
546
|
+
MINIMAL_FLAG_CALLED_EVENT_PROPERTIES.forEach(copyKey);
|
|
547
|
+
transportKeys.forEach(copyKey);
|
|
548
|
+
return minimal;
|
|
549
|
+
};
|
|
443
550
|
|
|
444
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
551
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/types.mjs
|
|
445
552
|
var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedProperty) {
|
|
446
553
|
PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
|
|
447
554
|
PostHogPersistedProperty["DistinctId"] = "distinct_id";
|
|
@@ -456,6 +563,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
456
563
|
PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
|
|
457
564
|
PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
|
|
458
565
|
PostHogPersistedProperty["Queue"] = "queue";
|
|
566
|
+
PostHogPersistedProperty["AiQueue"] = "ai_queue";
|
|
567
|
+
PostHogPersistedProperty["AiCaptureQueue"] = "ai_capture_queue";
|
|
459
568
|
PostHogPersistedProperty["LogsQueue"] = "logs_queue";
|
|
460
569
|
PostHogPersistedProperty["OptedOut"] = "opted_out";
|
|
461
570
|
PostHogPersistedProperty["SessionId"] = "session_id";
|
|
@@ -466,6 +575,8 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
466
575
|
PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
|
|
467
576
|
PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
|
|
468
577
|
PostHogPersistedProperty["SessionReplay"] = "session_replay";
|
|
578
|
+
PostHogPersistedProperty["PushRegistered"] = "push_registered";
|
|
579
|
+
PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
|
|
469
580
|
PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
|
|
470
581
|
PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
|
|
471
582
|
PostHogPersistedProperty["Surveys"] = "surveys";
|
|
@@ -475,7 +586,7 @@ var types_PostHogPersistedProperty = /* @__PURE__ */ function(PostHogPersistedPr
|
|
|
475
586
|
return PostHogPersistedProperty;
|
|
476
587
|
}({});
|
|
477
588
|
|
|
478
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
589
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/gzip.mjs
|
|
479
590
|
function isGzipSupported() {
|
|
480
591
|
return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && typeof Response.prototype.blob == "function";
|
|
481
592
|
}
|
|
@@ -525,7 +636,7 @@ var validateNativeGzip = async (compressed, inputBytes) => {
|
|
|
525
636
|
async function gzipCompress(input, isDebug = true, options) {
|
|
526
637
|
try {
|
|
527
638
|
const inputBytes = new TextEncoder().encode(input);
|
|
528
|
-
const compressedStream = new CompressionStream("gzip");
|
|
639
|
+
const compressedStream = new globalThis.CompressionStream("gzip");
|
|
529
640
|
const writer = compressedStream.writable.getWriter();
|
|
530
641
|
const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
|
|
531
642
|
try {
|
|
@@ -549,7 +660,34 @@ async function gzipCompress(input, isDebug = true, options) {
|
|
|
549
660
|
}
|
|
550
661
|
}
|
|
551
662
|
|
|
552
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
663
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/json-utils.mjs
|
|
664
|
+
var MAX_JSON_SAFE_VALUE_DEPTH = 20;
|
|
665
|
+
var MAX_JSON_SAFE_VALUE_ITEMS = 1000;
|
|
666
|
+
var MAX_JSON_SAFE_VALUE_NODES = 1e4;
|
|
667
|
+
var CIRCULAR_VALUE = "[Circular]";
|
|
668
|
+
var TRUNCATED_VALUE = "[Truncated]";
|
|
669
|
+
var UNSERIALIZABLE_VALUE = "[Unserializable]";
|
|
670
|
+
var FUNCTION_VALUE = "[Function]";
|
|
671
|
+
var dateGetTime = Date.prototype.getTime;
|
|
672
|
+
var dateToISOString = Date.prototype.toISOString;
|
|
673
|
+
function sanitizeString(value) {
|
|
674
|
+
let output = "";
|
|
675
|
+
for (let index = 0;index < value.length; index++) {
|
|
676
|
+
const codeUnit = value.charCodeAt(index);
|
|
677
|
+
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
678
|
+
const nextCodeUnit = value.charCodeAt(index + 1);
|
|
679
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
680
|
+
output += value[index] + value[index + 1];
|
|
681
|
+
index++;
|
|
682
|
+
} else
|
|
683
|
+
output += "�";
|
|
684
|
+
} else
|
|
685
|
+
output += codeUnit >= 56320 && codeUnit <= 57343 ? "�" : value[index];
|
|
686
|
+
}
|
|
687
|
+
return output;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bot-detection.mjs
|
|
553
691
|
var DEFAULT_BLOCKED_UA_STRS = [
|
|
554
692
|
"amazonbot",
|
|
555
693
|
"amazonproductbot",
|
|
@@ -638,7 +776,31 @@ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
|
|
|
638
776
|
return uaLower.indexOf(blockedUaLower) !== -1;
|
|
639
777
|
});
|
|
640
778
|
};
|
|
641
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
779
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/string-utils.mjs
|
|
780
|
+
function safeJsonStringify(value) {
|
|
781
|
+
const ancestors = [];
|
|
782
|
+
return JSON.stringify(value, function(_key, replacementValue) {
|
|
783
|
+
if (typeof replacementValue == "bigint")
|
|
784
|
+
return replacementValue.toString();
|
|
785
|
+
if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
|
|
786
|
+
return;
|
|
787
|
+
if (replacementValue instanceof Error)
|
|
788
|
+
return {
|
|
789
|
+
name: replacementValue.name,
|
|
790
|
+
message: replacementValue.message,
|
|
791
|
+
stack: replacementValue.stack
|
|
792
|
+
};
|
|
793
|
+
if (replacementValue && typeof replacementValue == "object") {
|
|
794
|
+
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this)
|
|
795
|
+
ancestors.pop();
|
|
796
|
+
if (ancestors.includes(replacementValue))
|
|
797
|
+
return "[Circular]";
|
|
798
|
+
ancestors.push(replacementValue);
|
|
799
|
+
}
|
|
800
|
+
return replacementValue;
|
|
801
|
+
}) ?? "null";
|
|
802
|
+
}
|
|
803
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/type-utils.mjs
|
|
642
804
|
var nativeIsArray = Array.isArray;
|
|
643
805
|
var ObjProto = Object.prototype;
|
|
644
806
|
var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
|
|
@@ -650,16 +812,27 @@ var isObject = (x) => x === Object(x) && !isArray(x);
|
|
|
650
812
|
var isUndefined = (x) => x === undefined;
|
|
651
813
|
var isString = (x) => type_utils_toString.call(x) == "[object String]";
|
|
652
814
|
var isEmptyString = (x) => isString(x) && x.trim().length === 0;
|
|
815
|
+
var isNull = (x) => x === null;
|
|
816
|
+
var isNullish = (x) => isUndefined(x) || isNull(x);
|
|
653
817
|
var isNumber = (x) => type_utils_toString.call(x) == "[object Number]" && x === x;
|
|
654
|
-
var
|
|
818
|
+
var isBoolean = (x) => type_utils_toString.call(x) === "[object Boolean]";
|
|
655
819
|
function isPrimitive(value) {
|
|
656
820
|
return value === null || typeof value != "object";
|
|
657
821
|
}
|
|
658
822
|
function isBuiltin(candidate, className) {
|
|
659
823
|
return Object.prototype.toString.call(candidate) === `[object ${className}]`;
|
|
660
824
|
}
|
|
661
|
-
function
|
|
662
|
-
|
|
825
|
+
function isError(candidate) {
|
|
826
|
+
switch (Object.prototype.toString.call(candidate)) {
|
|
827
|
+
case "[object Error]":
|
|
828
|
+
case "[object Exception]":
|
|
829
|
+
case "[object DOMException]":
|
|
830
|
+
case "[object DOMError]":
|
|
831
|
+
case "[object WebAssembly.Exception]":
|
|
832
|
+
return true;
|
|
833
|
+
default:
|
|
834
|
+
return isInstanceOf(candidate, Error);
|
|
835
|
+
}
|
|
663
836
|
}
|
|
664
837
|
function isEvent(candidate) {
|
|
665
838
|
return typeof Event != "undefined" && isInstanceOf(candidate, Event);
|
|
@@ -675,7 +848,7 @@ function isInstanceOf(candidate, base) {
|
|
|
675
848
|
}
|
|
676
849
|
}
|
|
677
850
|
|
|
678
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
851
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/number-utils.mjs
|
|
679
852
|
function clampToRange(value, min, max, logger, fallbackValue) {
|
|
680
853
|
if (min > max) {
|
|
681
854
|
logger.warn("min cannot be greater than max.");
|
|
@@ -695,8 +868,16 @@ function clampToRange(value, min, max, logger, fallbackValue) {
|
|
|
695
868
|
return clampToRange(fallbackValue || max, min, max, logger);
|
|
696
869
|
}
|
|
697
870
|
|
|
698
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
871
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
|
|
699
872
|
var ONE_DAY_IN_MS = 86400000;
|
|
873
|
+
var DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE = 1;
|
|
874
|
+
var DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE = 10;
|
|
875
|
+
function resolveExceptionRateLimiterConfig(config = {}) {
|
|
876
|
+
return {
|
|
877
|
+
refillRate: config.exceptionRateLimiterRefillRate ?? config.__exceptionRateLimiterRefillRate ?? DEFAULT_EXCEPTION_RATE_LIMITER_REFILL_RATE,
|
|
878
|
+
bucketSize: config.exceptionRateLimiterBucketSize ?? config.__exceptionRateLimiterBucketSize ?? DEFAULT_EXCEPTION_RATE_LIMITER_BUCKET_SIZE
|
|
879
|
+
};
|
|
880
|
+
}
|
|
700
881
|
|
|
701
882
|
class BucketedRateLimiter {
|
|
702
883
|
constructor(options) {
|
|
@@ -739,7 +920,7 @@ class BucketedRateLimiter {
|
|
|
739
920
|
this._buckets = {};
|
|
740
921
|
}
|
|
741
922
|
}
|
|
742
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
923
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
|
|
743
924
|
/*! For license information please see uuidv7.mjs.LICENSE.txt */
|
|
744
925
|
var DIGITS = "0123456789abcdef";
|
|
745
926
|
|
|
@@ -917,33 +1098,45 @@ var defaultGenerator;
|
|
|
917
1098
|
var uuidv7 = () => uuidv7obj().toString();
|
|
918
1099
|
var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator)).generate();
|
|
919
1100
|
|
|
920
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1101
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/promise-queue.mjs
|
|
921
1102
|
class PromiseQueue {
|
|
922
1103
|
add(promise) {
|
|
923
1104
|
const promiseUUID = uuidv7();
|
|
924
|
-
|
|
1105
|
+
const id = ++this.nextId;
|
|
1106
|
+
this.promiseByIds[promiseUUID] = {
|
|
1107
|
+
id,
|
|
1108
|
+
promise
|
|
1109
|
+
};
|
|
925
1110
|
promise.catch(() => {}).finally(() => {
|
|
926
1111
|
delete this.promiseByIds[promiseUUID];
|
|
927
1112
|
});
|
|
928
1113
|
return promise;
|
|
929
1114
|
}
|
|
930
1115
|
async join() {
|
|
931
|
-
let promises = Object.values(this.promiseByIds);
|
|
1116
|
+
let promises = Object.values(this.promiseByIds).map((item) => item.promise);
|
|
932
1117
|
let length = promises.length;
|
|
933
1118
|
while (length > 0) {
|
|
934
1119
|
await Promise.all(promises);
|
|
935
|
-
promises = Object.values(this.promiseByIds);
|
|
1120
|
+
promises = Object.values(this.promiseByIds).map((item) => item.promise);
|
|
936
1121
|
length = promises.length;
|
|
937
1122
|
}
|
|
938
1123
|
}
|
|
1124
|
+
getPromises(ignoredPromises = [], maxId = this.nextId) {
|
|
1125
|
+
const ignoredPromiseSet = new Set(ignoredPromises);
|
|
1126
|
+
return Object.values(this.promiseByIds).filter((item) => item.id <= maxId && !ignoredPromiseSet.has(item.promise)).map((item) => item.promise);
|
|
1127
|
+
}
|
|
1128
|
+
get maxId() {
|
|
1129
|
+
return this.nextId;
|
|
1130
|
+
}
|
|
939
1131
|
get length() {
|
|
940
1132
|
return Object.keys(this.promiseByIds).length;
|
|
941
1133
|
}
|
|
942
1134
|
constructor() {
|
|
943
1135
|
this.promiseByIds = {};
|
|
1136
|
+
this.nextId = 0;
|
|
944
1137
|
}
|
|
945
1138
|
}
|
|
946
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1139
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/logger.mjs
|
|
947
1140
|
function createConsole(consoleLike = console) {
|
|
948
1141
|
const lockedMethods = {
|
|
949
1142
|
log: consoleLike.log.bind(consoleLike),
|
|
@@ -984,7 +1177,7 @@ var passThrough = (fn) => fn();
|
|
|
984
1177
|
function createLogger(prefix, maybeCall = passThrough) {
|
|
985
1178
|
return _createLogger(prefix, maybeCall, createConsole());
|
|
986
1179
|
}
|
|
987
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1180
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
|
|
988
1181
|
var MOBILE = "Mobile";
|
|
989
1182
|
var IOS = "iOS";
|
|
990
1183
|
var ANDROID = "Android";
|
|
@@ -1027,6 +1220,7 @@ var DUCKDUCKGO = "DuckDuckGo";
|
|
|
1027
1220
|
var PALE_MOON = "Pale Moon";
|
|
1028
1221
|
var WATERFOX = "Waterfox";
|
|
1029
1222
|
var BRAVE = "Brave";
|
|
1223
|
+
var GOOGLE_SEARCH_APP = "Google Search App";
|
|
1030
1224
|
var BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
|
|
1031
1225
|
var DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
|
|
1032
1226
|
var XBOX_REGEX = new RegExp(XBOX, "i");
|
|
@@ -1114,6 +1308,9 @@ var versionRegexes = {
|
|
|
1114
1308
|
[WATERFOX]: [
|
|
1115
1309
|
new RegExp(WATERFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1116
1310
|
],
|
|
1311
|
+
[GOOGLE_SEARCH_APP]: [
|
|
1312
|
+
new RegExp("GSA\\/" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1313
|
+
],
|
|
1117
1314
|
[INTERNET_EXPLORER]: [
|
|
1118
1315
|
new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX)
|
|
1119
1316
|
],
|
|
@@ -1273,8 +1470,15 @@ var osMatchers = [
|
|
|
1273
1470
|
]
|
|
1274
1471
|
];
|
|
1275
1472
|
|
|
1276
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1473
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/utils/index.mjs
|
|
1277
1474
|
var STRING_FORMAT = "utf8";
|
|
1475
|
+
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1476
|
+
function isValidUUID(value) {
|
|
1477
|
+
return typeof value == "string" && UUID_REGEX.test(value);
|
|
1478
|
+
}
|
|
1479
|
+
function getEventUuid(uuid, generateUuid) {
|
|
1480
|
+
return isValidUUID(uuid) ? uuid : generateUuid();
|
|
1481
|
+
}
|
|
1278
1482
|
function removeTrailingSlash(url) {
|
|
1279
1483
|
return url?.replace(/\/+$/, "");
|
|
1280
1484
|
}
|
|
@@ -1302,7 +1506,26 @@ function safeSetTimeout(fn, timeout) {
|
|
|
1302
1506
|
t?.unref && t?.unref();
|
|
1303
1507
|
return t;
|
|
1304
1508
|
}
|
|
1305
|
-
|
|
1509
|
+
async function raceWithTimeout(promise, timeoutMs, onTimeout) {
|
|
1510
|
+
let timeoutHandle;
|
|
1511
|
+
try {
|
|
1512
|
+
return await Promise.race([
|
|
1513
|
+
promise,
|
|
1514
|
+
new Promise((resolve, reject) => {
|
|
1515
|
+
timeoutHandle = safeSetTimeout(() => {
|
|
1516
|
+
try {
|
|
1517
|
+
onTimeout?.();
|
|
1518
|
+
resolve();
|
|
1519
|
+
} catch (error) {
|
|
1520
|
+
reject(error);
|
|
1521
|
+
}
|
|
1522
|
+
}, timeoutMs);
|
|
1523
|
+
})
|
|
1524
|
+
]);
|
|
1525
|
+
} finally {
|
|
1526
|
+
clearTimeout(timeoutHandle);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1306
1529
|
function allSettled(promises) {
|
|
1307
1530
|
return Promise.all(promises.map((p) => (p ?? Promise.resolve()).then((value) => ({
|
|
1308
1531
|
status: "fulfilled",
|
|
@@ -1313,7 +1536,7 @@ function allSettled(promises) {
|
|
|
1313
1536
|
}))));
|
|
1314
1537
|
}
|
|
1315
1538
|
|
|
1316
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1539
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/logs/logs-utils.mjs
|
|
1317
1540
|
var OTLP_SEVERITY_MAP = {
|
|
1318
1541
|
trace: {
|
|
1319
1542
|
text: "TRACE",
|
|
@@ -1341,7 +1564,570 @@ var OTLP_SEVERITY_MAP = {
|
|
|
1341
1564
|
}
|
|
1342
1565
|
};
|
|
1343
1566
|
var DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
|
|
1344
|
-
|
|
1567
|
+
var INT64_RANGE_LIMIT = 9223372036854776000;
|
|
1568
|
+
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
1569
|
+
function newState() {
|
|
1570
|
+
return {
|
|
1571
|
+
ancestors: new WeakSet,
|
|
1572
|
+
remainingNodes: MAX_JSON_SAFE_VALUE_NODES
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
function toOtlpKeyValueList(attrs, logger) {
|
|
1576
|
+
try {
|
|
1577
|
+
return encodeKeyValueList(attrs, logger, newState(), 0);
|
|
1578
|
+
} catch {
|
|
1579
|
+
return [];
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
function encodeAnyValue(value, logger, state, depth) {
|
|
1583
|
+
if (state.remainingNodes <= 0)
|
|
1584
|
+
return {
|
|
1585
|
+
stringValue: TRUNCATED_VALUE
|
|
1586
|
+
};
|
|
1587
|
+
state.remainingNodes--;
|
|
1588
|
+
if (isBoolean(value))
|
|
1589
|
+
return {
|
|
1590
|
+
boolValue: value
|
|
1591
|
+
};
|
|
1592
|
+
if (typeof value == "number") {
|
|
1593
|
+
if (!Number.isFinite(value))
|
|
1594
|
+
return {
|
|
1595
|
+
stringValue: String(value)
|
|
1596
|
+
};
|
|
1597
|
+
if (Number.isInteger(value)) {
|
|
1598
|
+
if (Number.isSafeInteger(value))
|
|
1599
|
+
return {
|
|
1600
|
+
intValue: String(value)
|
|
1601
|
+
};
|
|
1602
|
+
if (typeof BigInt == "undefined")
|
|
1603
|
+
return {
|
|
1604
|
+
stringValue: String(value)
|
|
1605
|
+
};
|
|
1606
|
+
const decimal = BigInt(value).toString();
|
|
1607
|
+
if (value >= INT64_RANGE_LIMIT || value < -INT64_RANGE_LIMIT) {
|
|
1608
|
+
logger?.debug(`Attribute ${decimal} is outside the int64 range; encoding it as a string`);
|
|
1609
|
+
return {
|
|
1610
|
+
stringValue: decimal
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
return {
|
|
1614
|
+
intValue: decimal
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
return {
|
|
1618
|
+
doubleValue: value
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
if (typeof value == "string")
|
|
1622
|
+
return {
|
|
1623
|
+
stringValue: sanitizeString(value)
|
|
1624
|
+
};
|
|
1625
|
+
if (typeof value == "function")
|
|
1626
|
+
return {
|
|
1627
|
+
stringValue: FUNCTION_VALUE
|
|
1628
|
+
};
|
|
1629
|
+
if (typeof value == "symbol")
|
|
1630
|
+
return {
|
|
1631
|
+
stringValue: String(value)
|
|
1632
|
+
};
|
|
1633
|
+
if (typeof value == "object" && value !== null) {
|
|
1634
|
+
if (state.ancestors.has(value))
|
|
1635
|
+
return {
|
|
1636
|
+
stringValue: CIRCULAR_VALUE
|
|
1637
|
+
};
|
|
1638
|
+
if (depth >= MAX_JSON_SAFE_VALUE_DEPTH)
|
|
1639
|
+
return {
|
|
1640
|
+
stringValue: TRUNCATED_VALUE
|
|
1641
|
+
};
|
|
1642
|
+
if (value instanceof Date) {
|
|
1643
|
+
const time = value.getTime();
|
|
1644
|
+
const iso = Number.isFinite(time) ? value.toISOString() : String(value);
|
|
1645
|
+
return {
|
|
1646
|
+
stringValue: typeof iso == "string" ? sanitizeString(iso) : String(iso)
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
state.ancestors.add(value);
|
|
1650
|
+
try {
|
|
1651
|
+
try {
|
|
1652
|
+
const toJSON = value.toJSON;
|
|
1653
|
+
if (typeof toJSON == "function")
|
|
1654
|
+
return encodeAnyValue(toJSON.call(value), logger, state, depth + 1);
|
|
1655
|
+
} catch {}
|
|
1656
|
+
if (isArray(value))
|
|
1657
|
+
return {
|
|
1658
|
+
arrayValue: {
|
|
1659
|
+
values: encodeArrayValues(value, logger, state, depth + 1)
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
return {
|
|
1663
|
+
kvlistValue: {
|
|
1664
|
+
values: encodeKeyValueList(value, logger, state, depth + 1)
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
} finally {
|
|
1668
|
+
state.ancestors.delete(value);
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
return {
|
|
1672
|
+
stringValue: sanitizeString(String(value))
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
function encodeArrayValues(values, logger, state, depth) {
|
|
1676
|
+
const result = [];
|
|
1677
|
+
const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
|
|
1678
|
+
let index = 0;
|
|
1679
|
+
for (;index < itemCount && state.remainingNodes > 0; index++)
|
|
1680
|
+
try {
|
|
1681
|
+
const element = index in values ? values[index] : undefined;
|
|
1682
|
+
if (isNullish(element))
|
|
1683
|
+
continue;
|
|
1684
|
+
result.push(encodeAnyValue(element, logger, state, depth));
|
|
1685
|
+
} catch {
|
|
1686
|
+
result.push({
|
|
1687
|
+
stringValue: UNSERIALIZABLE_VALUE
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
if (values.length > index)
|
|
1691
|
+
result.push({
|
|
1692
|
+
stringValue: TRUNCATED_VALUE
|
|
1693
|
+
});
|
|
1694
|
+
return result;
|
|
1695
|
+
}
|
|
1696
|
+
function encodeKeyValueList(attrs, logger, state, depth) {
|
|
1697
|
+
const result = [];
|
|
1698
|
+
for (const key in attrs)
|
|
1699
|
+
if (propertyIsEnumerable.call(attrs, key)) {
|
|
1700
|
+
if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
|
|
1701
|
+
logger?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");
|
|
1702
|
+
break;
|
|
1703
|
+
}
|
|
1704
|
+
try {
|
|
1705
|
+
const value = attrs[key];
|
|
1706
|
+
if (isNull(value) || isUndefined(value))
|
|
1707
|
+
continue;
|
|
1708
|
+
result.push({
|
|
1709
|
+
key: sanitizeString(key),
|
|
1710
|
+
value: encodeAnyValue(value, logger, state, depth)
|
|
1711
|
+
});
|
|
1712
|
+
} catch {
|
|
1713
|
+
result.push({
|
|
1714
|
+
key: sanitizeString(key),
|
|
1715
|
+
value: {
|
|
1716
|
+
stringValue: UNSERIALIZABLE_VALUE
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
return result;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs
|
|
1725
|
+
var DEFAULT_HISTOGRAM_BOUNDS = [
|
|
1726
|
+
0,
|
|
1727
|
+
5,
|
|
1728
|
+
10,
|
|
1729
|
+
25,
|
|
1730
|
+
50,
|
|
1731
|
+
75,
|
|
1732
|
+
100,
|
|
1733
|
+
250,
|
|
1734
|
+
500,
|
|
1735
|
+
750,
|
|
1736
|
+
1000,
|
|
1737
|
+
2500,
|
|
1738
|
+
5000,
|
|
1739
|
+
7500,
|
|
1740
|
+
1e4
|
|
1741
|
+
];
|
|
1742
|
+
function msToUnixNano(ms) {
|
|
1743
|
+
return String(ms) + "000000";
|
|
1744
|
+
}
|
|
1745
|
+
function seriesKey(type, name, unit, attributes) {
|
|
1746
|
+
let attrsKey = "";
|
|
1747
|
+
if (attributes) {
|
|
1748
|
+
const keys = Object.keys(attributes).sort();
|
|
1749
|
+
attrsKey = keys.map((k) => `${JSON.stringify(k)}:${JSON.stringify(attributes[k])}`).join(",");
|
|
1750
|
+
}
|
|
1751
|
+
return `${type}\x00${name}\x00${unit ?? ""}\x00${attrsKey}`;
|
|
1752
|
+
}
|
|
1753
|
+
function bucketIndexFor(value, bounds) {
|
|
1754
|
+
for (let i = 0;i < bounds.length; i++)
|
|
1755
|
+
if (value <= bounds[i])
|
|
1756
|
+
return i;
|
|
1757
|
+
return bounds.length;
|
|
1758
|
+
}
|
|
1759
|
+
function buildMetricsResourceAttributes(config, scopeName, scopeVersion) {
|
|
1760
|
+
return {
|
|
1761
|
+
...config.resourceAttributes,
|
|
1762
|
+
"service.name": config.serviceName || "unknown_service",
|
|
1763
|
+
...config.environment && {
|
|
1764
|
+
"deployment.environment": config.environment
|
|
1765
|
+
},
|
|
1766
|
+
...config.serviceVersion && {
|
|
1767
|
+
"service.version": config.serviceVersion
|
|
1768
|
+
},
|
|
1769
|
+
"telemetry.sdk.name": scopeName,
|
|
1770
|
+
"telemetry.sdk.version": scopeVersion
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVersion) {
|
|
1774
|
+
return {
|
|
1775
|
+
resourceMetrics: [
|
|
1776
|
+
{
|
|
1777
|
+
resource: {
|
|
1778
|
+
attributes: toOtlpKeyValueList(resourceAttributes)
|
|
1779
|
+
},
|
|
1780
|
+
scopeMetrics: [
|
|
1781
|
+
{
|
|
1782
|
+
scope: {
|
|
1783
|
+
name: scopeName,
|
|
1784
|
+
version: scopeVersion
|
|
1785
|
+
},
|
|
1786
|
+
metrics
|
|
1787
|
+
}
|
|
1788
|
+
]
|
|
1789
|
+
}
|
|
1790
|
+
]
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/config.mjs
|
|
1795
|
+
var DEFAULT_FLUSH_INTERVAL_MS = 1e4;
|
|
1796
|
+
var DEFAULT_MAX_SERIES_PER_FLUSH = 1000;
|
|
1797
|
+
function resolveMetricsConfig(config) {
|
|
1798
|
+
const resourceAttributes = config?.resourceAttributes;
|
|
1799
|
+
return {
|
|
1800
|
+
serviceName: resourceAttributes?.["service.name"] ?? config?.serviceName,
|
|
1801
|
+
serviceVersion: resourceAttributes?.["service.version"] ?? config?.serviceVersion,
|
|
1802
|
+
environment: resourceAttributes?.["deployment.environment"] ?? config?.environment,
|
|
1803
|
+
resourceAttributes,
|
|
1804
|
+
beforeSend: config?.beforeSend,
|
|
1805
|
+
flushIntervalMs: config?.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
|
|
1806
|
+
maxSeriesPerFlush: config?.maxSeriesPerFlush ?? DEFAULT_MAX_SERIES_PER_FLUSH
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/metrics/index.mjs
|
|
1811
|
+
var OTLP_TEMPORALITY_DELTA = 1;
|
|
1812
|
+
|
|
1813
|
+
class PostHogMetrics {
|
|
1814
|
+
constructor(_instance, _config, _logger) {
|
|
1815
|
+
this._instance = _instance;
|
|
1816
|
+
this._config = _config;
|
|
1817
|
+
this._logger = _logger;
|
|
1818
|
+
this._series = new Map;
|
|
1819
|
+
this._flushPromise = null;
|
|
1820
|
+
this._seriesCapWarned = false;
|
|
1821
|
+
this._typeByName = new Map;
|
|
1822
|
+
this._typeCollisionWarned = new Set;
|
|
1823
|
+
this._generation = 0;
|
|
1824
|
+
}
|
|
1825
|
+
count(name, value = 1, options) {
|
|
1826
|
+
this._capture({
|
|
1827
|
+
name,
|
|
1828
|
+
type: "count",
|
|
1829
|
+
value,
|
|
1830
|
+
unit: options?.unit,
|
|
1831
|
+
attributes: options?.attributes
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
gauge(name, value, options) {
|
|
1835
|
+
this._capture({
|
|
1836
|
+
name,
|
|
1837
|
+
type: "gauge",
|
|
1838
|
+
value,
|
|
1839
|
+
unit: options?.unit,
|
|
1840
|
+
attributes: options?.attributes
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
histogram(name, value, options) {
|
|
1844
|
+
this._capture({
|
|
1845
|
+
name,
|
|
1846
|
+
type: "histogram",
|
|
1847
|
+
value,
|
|
1848
|
+
unit: options?.unit,
|
|
1849
|
+
attributes: options?.attributes
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
flush() {
|
|
1853
|
+
const prev = this._flushPromise;
|
|
1854
|
+
const run = async () => {
|
|
1855
|
+
if (prev)
|
|
1856
|
+
await prev.catch(() => {});
|
|
1857
|
+
await this._doFlush();
|
|
1858
|
+
};
|
|
1859
|
+
const p = run().finally(() => {
|
|
1860
|
+
if (this._flushPromise === p)
|
|
1861
|
+
this._flushPromise = null;
|
|
1862
|
+
});
|
|
1863
|
+
this._flushPromise = p;
|
|
1864
|
+
return p;
|
|
1865
|
+
}
|
|
1866
|
+
drainWindow() {
|
|
1867
|
+
if (this._series.size === 0)
|
|
1868
|
+
return null;
|
|
1869
|
+
const window = this._series;
|
|
1870
|
+
this._series = new Map;
|
|
1871
|
+
this._seriesCapWarned = false;
|
|
1872
|
+
this._typeByName = new Map;
|
|
1873
|
+
this._typeCollisionWarned = new Set;
|
|
1874
|
+
return this._buildPayload(window);
|
|
1875
|
+
}
|
|
1876
|
+
reset() {
|
|
1877
|
+
this._generation++;
|
|
1878
|
+
this._clearFlushTimer();
|
|
1879
|
+
this._series = new Map;
|
|
1880
|
+
this._flushPromise = null;
|
|
1881
|
+
this._seriesCapWarned = false;
|
|
1882
|
+
this._typeByName = new Map;
|
|
1883
|
+
this._typeCollisionWarned = new Set;
|
|
1884
|
+
}
|
|
1885
|
+
_capture(sample) {
|
|
1886
|
+
if (this._instance.isDisabled || this._instance.optedOut)
|
|
1887
|
+
return;
|
|
1888
|
+
const filtered = this._runBeforeSend(sample);
|
|
1889
|
+
if (filtered === null)
|
|
1890
|
+
return;
|
|
1891
|
+
if (!filtered.name || typeof filtered.name != "string")
|
|
1892
|
+
return void this._logger.warn("Dropping metric with empty name");
|
|
1893
|
+
if (typeof filtered.value != "number" || !Number.isFinite(filtered.value))
|
|
1894
|
+
return void this._logger.warn(`Dropping metric '${filtered.name}': value must be a finite number`);
|
|
1895
|
+
if (filtered.type === "count" && filtered.value < 0)
|
|
1896
|
+
return void this._logger.warn(`Dropping count '${filtered.name}': counters are monotonic, value must be >= 0`);
|
|
1897
|
+
let attributes;
|
|
1898
|
+
let key;
|
|
1899
|
+
try {
|
|
1900
|
+
attributes = filtered.attributes ? {
|
|
1901
|
+
...filtered.attributes
|
|
1902
|
+
} : undefined;
|
|
1903
|
+
key = seriesKey(filtered.type, filtered.name, filtered.unit, attributes);
|
|
1904
|
+
} catch (e) {
|
|
1905
|
+
this._logger.warn(`Dropping metric '${filtered.name}': attributes could not be serialized`, e);
|
|
1906
|
+
return;
|
|
1907
|
+
}
|
|
1908
|
+
let state = this._series.get(key);
|
|
1909
|
+
if (!state) {
|
|
1910
|
+
if (!this._admitNewSeries())
|
|
1911
|
+
return;
|
|
1912
|
+
state = {
|
|
1913
|
+
name: filtered.name,
|
|
1914
|
+
type: filtered.type,
|
|
1915
|
+
unit: filtered.unit,
|
|
1916
|
+
attributes,
|
|
1917
|
+
windowStartMs: Date.now()
|
|
1918
|
+
};
|
|
1919
|
+
this._series.set(key, state);
|
|
1920
|
+
}
|
|
1921
|
+
const seenType = this._typeByName.get(filtered.name);
|
|
1922
|
+
if (seenType === undefined)
|
|
1923
|
+
this._typeByName.set(filtered.name, filtered.type);
|
|
1924
|
+
else if (seenType !== filtered.type && !this._typeCollisionWarned.has(filtered.name)) {
|
|
1925
|
+
this._typeCollisionWarned.add(filtered.name);
|
|
1926
|
+
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.`);
|
|
1927
|
+
}
|
|
1928
|
+
this._fold(state, filtered.value);
|
|
1929
|
+
this._armFlushTimer();
|
|
1930
|
+
}
|
|
1931
|
+
_admitNewSeries() {
|
|
1932
|
+
if (this._series.size < this._config.maxSeriesPerFlush)
|
|
1933
|
+
return true;
|
|
1934
|
+
if (!this._seriesCapWarned) {
|
|
1935
|
+
this._seriesCapWarned = true;
|
|
1936
|
+
this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`);
|
|
1937
|
+
}
|
|
1938
|
+
return false;
|
|
1939
|
+
}
|
|
1940
|
+
_fold(state, value) {
|
|
1941
|
+
switch (state.type) {
|
|
1942
|
+
case "count":
|
|
1943
|
+
state.total = (state.total ?? 0) + value;
|
|
1944
|
+
break;
|
|
1945
|
+
case "gauge":
|
|
1946
|
+
state.last = value;
|
|
1947
|
+
break;
|
|
1948
|
+
case "histogram": {
|
|
1949
|
+
if (!state.hist)
|
|
1950
|
+
state.hist = {
|
|
1951
|
+
count: 0,
|
|
1952
|
+
sum: 0,
|
|
1953
|
+
min: value,
|
|
1954
|
+
max: value,
|
|
1955
|
+
bucketCounts: new Array(DEFAULT_HISTOGRAM_BOUNDS.length + 1).fill(0)
|
|
1956
|
+
};
|
|
1957
|
+
const hist = state.hist;
|
|
1958
|
+
hist.count += 1;
|
|
1959
|
+
hist.sum += value;
|
|
1960
|
+
hist.min = Math.min(hist.min, value);
|
|
1961
|
+
hist.max = Math.max(hist.max, value);
|
|
1962
|
+
hist.bucketCounts[bucketIndexFor(value, DEFAULT_HISTOGRAM_BOUNDS)] += 1;
|
|
1963
|
+
break;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
_runBeforeSend(sample) {
|
|
1968
|
+
const beforeSend = this._config.beforeSend;
|
|
1969
|
+
if (!beforeSend)
|
|
1970
|
+
return sample;
|
|
1971
|
+
const fns = isArray(beforeSend) ? beforeSend : [
|
|
1972
|
+
beforeSend
|
|
1973
|
+
];
|
|
1974
|
+
let result = sample;
|
|
1975
|
+
for (const fn of fns)
|
|
1976
|
+
try {
|
|
1977
|
+
const next = fn(result);
|
|
1978
|
+
if (!next) {
|
|
1979
|
+
this._logger.info("Metric was rejected in beforeSend function");
|
|
1980
|
+
return null;
|
|
1981
|
+
}
|
|
1982
|
+
result = next;
|
|
1983
|
+
} catch (e) {
|
|
1984
|
+
this._logger.error("Error in beforeSend function for metric:", e);
|
|
1985
|
+
return null;
|
|
1986
|
+
}
|
|
1987
|
+
return result;
|
|
1988
|
+
}
|
|
1989
|
+
_armFlushTimer() {
|
|
1990
|
+
if (this._flushTimer)
|
|
1991
|
+
return;
|
|
1992
|
+
this._flushTimer = safeSetTimeout(() => {
|
|
1993
|
+
this._flushTimer = undefined;
|
|
1994
|
+
this.flush().catch((e) => {
|
|
1995
|
+
this._logger.error("Metrics flush failed:", e);
|
|
1996
|
+
});
|
|
1997
|
+
}, this._config.flushIntervalMs);
|
|
1998
|
+
}
|
|
1999
|
+
_clearFlushTimer() {
|
|
2000
|
+
if (this._flushTimer) {
|
|
2001
|
+
clearTimeout(this._flushTimer);
|
|
2002
|
+
this._flushTimer = undefined;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
async _doFlush() {
|
|
2006
|
+
if (this._series.size === 0)
|
|
2007
|
+
return;
|
|
2008
|
+
const window = this._series;
|
|
2009
|
+
this._series = new Map;
|
|
2010
|
+
this._seriesCapWarned = false;
|
|
2011
|
+
this._typeByName = new Map;
|
|
2012
|
+
this._typeCollisionWarned = new Set;
|
|
2013
|
+
const generation = this._generation;
|
|
2014
|
+
const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
|
|
2015
|
+
if (generation !== this._generation)
|
|
2016
|
+
return;
|
|
2017
|
+
switch (outcome.kind) {
|
|
2018
|
+
case "ok":
|
|
2019
|
+
return;
|
|
2020
|
+
case "retry-later":
|
|
2021
|
+
this._mergeWindowBack(window);
|
|
2022
|
+
this._armFlushTimer();
|
|
2023
|
+
return;
|
|
2024
|
+
case "too-large":
|
|
2025
|
+
this._logger.warn("Metrics batch exceeded the server size limit and was dropped");
|
|
2026
|
+
return;
|
|
2027
|
+
case "fatal":
|
|
2028
|
+
this._logger.error("Failed to send metrics batch:", outcome.error);
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
_buildPayload(window) {
|
|
2033
|
+
return buildOtlpMetricsPayload(this._buildMetrics(window), buildMetricsResourceAttributes(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion()), this._instance.getLibraryId(), this._instance.getLibraryVersion());
|
|
2034
|
+
}
|
|
2035
|
+
_buildMetrics(window) {
|
|
2036
|
+
const nowNano = msToUnixNano(Date.now());
|
|
2037
|
+
const byMetric = new Map;
|
|
2038
|
+
for (const state of window.values()) {
|
|
2039
|
+
const metricKey = seriesKey(state.type, state.name, state.unit, undefined);
|
|
2040
|
+
let metric = byMetric.get(metricKey);
|
|
2041
|
+
if (!metric) {
|
|
2042
|
+
metric = {
|
|
2043
|
+
name: state.name,
|
|
2044
|
+
...state.unit && {
|
|
2045
|
+
unit: state.unit
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
if (state.type === "count")
|
|
2049
|
+
metric.sum = {
|
|
2050
|
+
aggregationTemporality: OTLP_TEMPORALITY_DELTA,
|
|
2051
|
+
isMonotonic: true,
|
|
2052
|
+
dataPoints: []
|
|
2053
|
+
};
|
|
2054
|
+
else if (state.type === "gauge")
|
|
2055
|
+
metric.gauge = {
|
|
2056
|
+
dataPoints: []
|
|
2057
|
+
};
|
|
2058
|
+
else
|
|
2059
|
+
metric.histogram = {
|
|
2060
|
+
aggregationTemporality: OTLP_TEMPORALITY_DELTA,
|
|
2061
|
+
dataPoints: []
|
|
2062
|
+
};
|
|
2063
|
+
byMetric.set(metricKey, metric);
|
|
2064
|
+
}
|
|
2065
|
+
const attributes = toOtlpKeyValueList(state.attributes ?? {}, this._logger);
|
|
2066
|
+
const startNano = msToUnixNano(state.windowStartMs);
|
|
2067
|
+
if (state.type === "count") {
|
|
2068
|
+
const dp = {
|
|
2069
|
+
attributes,
|
|
2070
|
+
startTimeUnixNano: startNano,
|
|
2071
|
+
timeUnixNano: nowNano,
|
|
2072
|
+
asDouble: state.total ?? 0
|
|
2073
|
+
};
|
|
2074
|
+
metric.sum.dataPoints.push(dp);
|
|
2075
|
+
} else if (state.type === "gauge") {
|
|
2076
|
+
const dp = {
|
|
2077
|
+
attributes,
|
|
2078
|
+
timeUnixNano: nowNano,
|
|
2079
|
+
asDouble: state.last ?? 0
|
|
2080
|
+
};
|
|
2081
|
+
metric.gauge.dataPoints.push(dp);
|
|
2082
|
+
} else if (state.hist) {
|
|
2083
|
+
const dp = {
|
|
2084
|
+
attributes,
|
|
2085
|
+
startTimeUnixNano: startNano,
|
|
2086
|
+
timeUnixNano: nowNano,
|
|
2087
|
+
count: state.hist.count,
|
|
2088
|
+
sum: state.hist.sum,
|
|
2089
|
+
min: state.hist.min,
|
|
2090
|
+
max: state.hist.max,
|
|
2091
|
+
bucketCounts: state.hist.bucketCounts,
|
|
2092
|
+
explicitBounds: DEFAULT_HISTOGRAM_BOUNDS
|
|
2093
|
+
};
|
|
2094
|
+
metric.histogram.dataPoints.push(dp);
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return Array.from(byMetric.values());
|
|
2098
|
+
}
|
|
2099
|
+
_mergeWindowBack(window) {
|
|
2100
|
+
for (const [key, old] of window) {
|
|
2101
|
+
const current = this._series.get(key);
|
|
2102
|
+
if (!current) {
|
|
2103
|
+
if (this._admitNewSeries())
|
|
2104
|
+
this._series.set(key, old);
|
|
2105
|
+
continue;
|
|
2106
|
+
}
|
|
2107
|
+
current.windowStartMs = Math.min(current.windowStartMs, old.windowStartMs);
|
|
2108
|
+
switch (current.type) {
|
|
2109
|
+
case "count":
|
|
2110
|
+
current.total = (current.total ?? 0) + (old.total ?? 0);
|
|
2111
|
+
break;
|
|
2112
|
+
case "gauge":
|
|
2113
|
+
break;
|
|
2114
|
+
case "histogram":
|
|
2115
|
+
if (old.hist)
|
|
2116
|
+
if (current.hist) {
|
|
2117
|
+
current.hist.count += old.hist.count;
|
|
2118
|
+
current.hist.sum += old.hist.sum;
|
|
2119
|
+
current.hist.min = Math.min(current.hist.min, old.hist.min);
|
|
2120
|
+
current.hist.max = Math.max(current.hist.max, old.hist.max);
|
|
2121
|
+
for (let i = 0;i < current.hist.bucketCounts.length; i++)
|
|
2122
|
+
current.hist.bucketCounts[i] += old.hist.bucketCounts[i];
|
|
2123
|
+
} else
|
|
2124
|
+
current.hist = old.hist;
|
|
2125
|
+
break;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/eventemitter.mjs
|
|
1345
2131
|
class SimpleEventEmitter {
|
|
1346
2132
|
constructor() {
|
|
1347
2133
|
this.events = {};
|
|
@@ -1363,37 +2149,7 @@ class SimpleEventEmitter {
|
|
|
1363
2149
|
}
|
|
1364
2150
|
}
|
|
1365
2151
|
|
|
1366
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1367
|
-
var exports_error_tracking = {};
|
|
1368
|
-
__export(exports_error_tracking, {
|
|
1369
|
-
winjsStackLineParser: () => winjsStackLineParser,
|
|
1370
|
-
stripReservedExceptionStepFields: () => stripReservedExceptionStepFields,
|
|
1371
|
-
reverseAndStripFrames: () => reverseAndStripFrames,
|
|
1372
|
-
resolveExceptionStepsConfig: () => resolveExceptionStepsConfig,
|
|
1373
|
-
opera11StackLineParser: () => opera11StackLineParser,
|
|
1374
|
-
opera10StackLineParser: () => opera10StackLineParser,
|
|
1375
|
-
nodeStackLineParser: () => nodeStackLineParser,
|
|
1376
|
-
getUtf8ByteLength: () => getUtf8ByteLength,
|
|
1377
|
-
geckoStackLineParser: () => geckoStackLineParser,
|
|
1378
|
-
createStackParser: () => createStackParser,
|
|
1379
|
-
createDefaultStackParser: () => createDefaultStackParser,
|
|
1380
|
-
chromeStackLineParser: () => chromeStackLineParser,
|
|
1381
|
-
StringCoercer: () => StringCoercer,
|
|
1382
|
-
ReduceableCache: () => ReduceableCache,
|
|
1383
|
-
PromiseRejectionEventCoercer: () => PromiseRejectionEventCoercer,
|
|
1384
|
-
PrimitiveCoercer: () => PrimitiveCoercer,
|
|
1385
|
-
ObjectCoercer: () => ObjectCoercer,
|
|
1386
|
-
ExceptionStepsBuffer: () => ExceptionStepsBuffer,
|
|
1387
|
-
EventCoercer: () => EventCoercer,
|
|
1388
|
-
ErrorPropertiesBuilder: () => ErrorPropertiesBuilder,
|
|
1389
|
-
ErrorEventCoercer: () => ErrorEventCoercer,
|
|
1390
|
-
ErrorCoercer: () => ErrorCoercer,
|
|
1391
|
-
EXCEPTION_STEP_INTERNAL_FIELDS: () => EXCEPTION_STEP_INTERNAL_FIELDS,
|
|
1392
|
-
DOMExceptionCoercer: () => DOMExceptionCoercer,
|
|
1393
|
-
DEFAULT_EXCEPTION_STEPS_CONFIG: () => DEFAULT_EXCEPTION_STEPS_CONFIG
|
|
1394
|
-
});
|
|
1395
|
-
|
|
1396
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
|
|
2152
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
|
|
1397
2153
|
var parsedStackResults;
|
|
1398
2154
|
var lastKeysCount;
|
|
1399
2155
|
var cachedFilenameChunkIds;
|
|
@@ -1432,7 +2188,7 @@ function getFilenameToChunkIdMap(stackParser) {
|
|
|
1432
2188
|
return cachedFilenameChunkIds;
|
|
1433
2189
|
}
|
|
1434
2190
|
|
|
1435
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2191
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
|
|
1436
2192
|
var MAX_CAUSE_RECURSION = 4;
|
|
1437
2193
|
|
|
1438
2194
|
class ErrorPropertiesBuilder {
|
|
@@ -1536,11 +2292,11 @@ class ErrorPropertiesBuilder {
|
|
|
1536
2292
|
return context;
|
|
1537
2293
|
}
|
|
1538
2294
|
buildCoercingContext(mechanism, hint, depth = 0) {
|
|
1539
|
-
const coerce = (input,
|
|
1540
|
-
if (!(
|
|
2295
|
+
const coerce = (input, depth) => {
|
|
2296
|
+
if (!(depth <= MAX_CAUSE_RECURSION))
|
|
1541
2297
|
return;
|
|
1542
2298
|
{
|
|
1543
|
-
const ctx = this.buildCoercingContext(mechanism, hint,
|
|
2299
|
+
const ctx = this.buildCoercingContext(mechanism, hint, depth);
|
|
1544
2300
|
return this.applyCoercers(input, ctx);
|
|
1545
2301
|
}
|
|
1546
2302
|
};
|
|
@@ -1554,14 +2310,16 @@ class ErrorPropertiesBuilder {
|
|
|
1554
2310
|
return context;
|
|
1555
2311
|
}
|
|
1556
2312
|
}
|
|
1557
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2313
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
|
|
1558
2314
|
var UNKNOWN_FUNCTION = "?";
|
|
2315
|
+
var MASKED_URL_PREFIX = "webkit-masked-url://";
|
|
2316
|
+
var ANONYMOUS_FILENAME = "<anonymous>";
|
|
1559
2317
|
function createFrame(platform, filename, func, lineno, colno) {
|
|
1560
2318
|
const frame = {
|
|
1561
2319
|
platform,
|
|
1562
2320
|
filename,
|
|
1563
2321
|
function: func === "<anonymous>" ? UNKNOWN_FUNCTION : func,
|
|
1564
|
-
in_app:
|
|
2322
|
+
in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
|
|
1565
2323
|
};
|
|
1566
2324
|
if (!isUndefined(lineno))
|
|
1567
2325
|
frame.lineno = lineno;
|
|
@@ -1570,7 +2328,7 @@ function createFrame(platform, filename, func, lineno, colno) {
|
|
|
1570
2328
|
return frame;
|
|
1571
2329
|
}
|
|
1572
2330
|
|
|
1573
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2331
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
|
|
1574
2332
|
var extractSafariExtensionDetails = (func, filename) => {
|
|
1575
2333
|
const isSafariExtension = func.indexOf("safari-extension") !== -1;
|
|
1576
2334
|
const isSafariWebExtension = func.indexOf("safari-web-extension") !== -1;
|
|
@@ -1583,15 +2341,15 @@ var extractSafariExtensionDetails = (func, filename) => {
|
|
|
1583
2341
|
];
|
|
1584
2342
|
};
|
|
1585
2343
|
|
|
1586
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2344
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
|
|
1587
2345
|
var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
|
|
1588
2346
|
var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
|
|
1589
2347
|
var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
|
|
1590
2348
|
var chromeStackLineParser = (line, platform) => {
|
|
1591
2349
|
const noFnParts = chromeRegexNoFnName.exec(line);
|
|
1592
2350
|
if (noFnParts) {
|
|
1593
|
-
const [, filename,
|
|
1594
|
-
return createFrame(platform, filename, UNKNOWN_FUNCTION, +
|
|
2351
|
+
const [, filename, line, col] = noFnParts;
|
|
2352
|
+
return createFrame(platform, filename, UNKNOWN_FUNCTION, +line, +col);
|
|
1595
2353
|
}
|
|
1596
2354
|
const parts = chromeRegex.exec(line);
|
|
1597
2355
|
if (parts) {
|
|
@@ -1609,7 +2367,7 @@ var chromeStackLineParser = (line, platform) => {
|
|
|
1609
2367
|
}
|
|
1610
2368
|
};
|
|
1611
2369
|
|
|
1612
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2370
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
|
|
1613
2371
|
var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
|
|
1614
2372
|
var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
|
|
1615
2373
|
var geckoStackLineParser = (line, platform) => {
|
|
@@ -1632,28 +2390,12 @@ var geckoStackLineParser = (line, platform) => {
|
|
|
1632
2390
|
}
|
|
1633
2391
|
};
|
|
1634
2392
|
|
|
1635
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1636
|
-
var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
|
|
1637
|
-
var winjsStackLineParser = (line, platform) => {
|
|
1638
|
-
const parts = winjsRegex.exec(line);
|
|
1639
|
-
return parts ? createFrame(platform, parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined) : undefined;
|
|
1640
|
-
};
|
|
1641
|
-
|
|
1642
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
|
|
1643
|
-
var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
|
|
1644
|
-
var opera10StackLineParser = (line, platform) => {
|
|
1645
|
-
const parts = opera10Regex.exec(line);
|
|
1646
|
-
return parts ? createFrame(platform, parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
|
|
1647
|
-
};
|
|
1648
|
-
var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
|
|
1649
|
-
var opera11StackLineParser = (line, platform) => {
|
|
1650
|
-
const parts = opera11Regex.exec(line);
|
|
1651
|
-
return parts ? createFrame(platform, parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
|
|
1652
|
-
};
|
|
1653
|
-
|
|
1654
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
|
|
2393
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
|
|
1655
2394
|
var FILENAME_MATCH = /^\s*[-]{4,}$/;
|
|
1656
2395
|
var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
|
|
2396
|
+
var PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
|
|
2397
|
+
var PROMISE_INDEX = /^index \d+$/;
|
|
2398
|
+
var PROMISE_FRAME_FILENAME = "node:internal/promise";
|
|
1657
2399
|
var nodeStackLineParser = (line, platform) => {
|
|
1658
2400
|
const lineMatch = line.match(FULL_MATCH);
|
|
1659
2401
|
if (lineMatch) {
|
|
@@ -1696,6 +2438,8 @@ var nodeStackLineParser = (line, platform) => {
|
|
|
1696
2438
|
filename = filename.slice(1);
|
|
1697
2439
|
if (!filename && lineMatch[5] && !isNative)
|
|
1698
2440
|
filename = lineMatch[5];
|
|
2441
|
+
if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || ""))
|
|
2442
|
+
filename = PROMISE_FRAME_FILENAME;
|
|
1699
2443
|
return {
|
|
1700
2444
|
filename: filename ? decodeURI(filename) : undefined,
|
|
1701
2445
|
module: undefined,
|
|
@@ -1720,7 +2464,7 @@ function _parseIntOrUndefined(input) {
|
|
|
1720
2464
|
return parseInt(input || "", 10) || undefined;
|
|
1721
2465
|
}
|
|
1722
2466
|
|
|
1723
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2467
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
|
|
1724
2468
|
var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
|
|
1725
2469
|
var STACKTRACE_FRAME_LIMIT = 50;
|
|
1726
2470
|
function reverseAndStripFrames(stack) {
|
|
@@ -1765,48 +2509,20 @@ function createStackParser(platform, ...parsers) {
|
|
|
1765
2509
|
return reverseAndStripFrames(frames);
|
|
1766
2510
|
};
|
|
1767
2511
|
}
|
|
1768
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1769
|
-
class DOMExceptionCoercer {
|
|
1770
|
-
match(err) {
|
|
1771
|
-
return this.isDOMException(err) || this.isDOMError(err);
|
|
1772
|
-
}
|
|
1773
|
-
coerce(err, ctx) {
|
|
1774
|
-
const hasStack = isString(err.stack);
|
|
1775
|
-
return {
|
|
1776
|
-
type: this.getType(err),
|
|
1777
|
-
value: this.getValue(err),
|
|
1778
|
-
stack: hasStack ? err.stack : undefined,
|
|
1779
|
-
cause: err.cause ? ctx.next(err.cause) : undefined,
|
|
1780
|
-
synthetic: false
|
|
1781
|
-
};
|
|
1782
|
-
}
|
|
1783
|
-
getType(candidate) {
|
|
1784
|
-
return this.isDOMError(candidate) ? "DOMError" : "DOMException";
|
|
1785
|
-
}
|
|
1786
|
-
getValue(err) {
|
|
1787
|
-
const name = err.name || (this.isDOMError(err) ? "DOMError" : "DOMException");
|
|
1788
|
-
const message = err.message ? `${name}: ${err.message}` : name;
|
|
1789
|
-
return message;
|
|
1790
|
-
}
|
|
1791
|
-
isDOMException(err) {
|
|
1792
|
-
return isBuiltin(err, "DOMException");
|
|
1793
|
-
}
|
|
1794
|
-
isDOMError(err) {
|
|
1795
|
-
return isBuiltin(err, "DOMError");
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
|
|
2512
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
|
|
1799
2513
|
class ErrorCoercer {
|
|
1800
2514
|
match(err) {
|
|
1801
|
-
return
|
|
2515
|
+
return isError(err);
|
|
1802
2516
|
}
|
|
1803
2517
|
coerce(err, ctx) {
|
|
2518
|
+
const stack = this.getStack(err);
|
|
2519
|
+
const synthetic = stack === undefined;
|
|
1804
2520
|
return {
|
|
1805
2521
|
type: this.getType(err),
|
|
1806
2522
|
value: this.getMessage(err, ctx),
|
|
1807
|
-
stack:
|
|
2523
|
+
stack: stack ?? ctx.syntheticException?.stack,
|
|
1808
2524
|
cause: err.cause ? ctx.next(err.cause) : undefined,
|
|
1809
|
-
synthetic
|
|
2525
|
+
synthetic
|
|
1810
2526
|
};
|
|
1811
2527
|
}
|
|
1812
2528
|
getType(err) {
|
|
@@ -1822,25 +2538,7 @@ class ErrorCoercer {
|
|
|
1822
2538
|
return err.stacktrace || err.stack || undefined;
|
|
1823
2539
|
}
|
|
1824
2540
|
}
|
|
1825
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1826
|
-
class ErrorEventCoercer {
|
|
1827
|
-
constructor() {}
|
|
1828
|
-
match(err) {
|
|
1829
|
-
return isErrorEvent(err) && err.error != null;
|
|
1830
|
-
}
|
|
1831
|
-
coerce(err, ctx) {
|
|
1832
|
-
const exceptionLike = ctx.apply(err.error);
|
|
1833
|
-
if (!exceptionLike)
|
|
1834
|
-
return {
|
|
1835
|
-
type: "ErrorEvent",
|
|
1836
|
-
value: err.message,
|
|
1837
|
-
stack: ctx.syntheticException?.stack,
|
|
1838
|
-
synthetic: true
|
|
1839
|
-
};
|
|
1840
|
-
return exceptionLike;
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
|
|
2541
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
|
|
1844
2542
|
var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
|
|
1845
2543
|
|
|
1846
2544
|
class StringCoercer {
|
|
@@ -1870,7 +2568,7 @@ class StringCoercer {
|
|
|
1870
2568
|
];
|
|
1871
2569
|
}
|
|
1872
2570
|
}
|
|
1873
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2571
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/types.mjs
|
|
1874
2572
|
var severityLevels = [
|
|
1875
2573
|
"fatal",
|
|
1876
2574
|
"error",
|
|
@@ -1880,7 +2578,7 @@ var severityLevels = [
|
|
|
1880
2578
|
"debug"
|
|
1881
2579
|
];
|
|
1882
2580
|
|
|
1883
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2581
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
|
|
1884
2582
|
function extractExceptionKeysForMessage(err, maxLength = 40) {
|
|
1885
2583
|
const keys = Object.keys(err);
|
|
1886
2584
|
keys.sort();
|
|
@@ -1897,7 +2595,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
|
|
|
1897
2595
|
return "";
|
|
1898
2596
|
}
|
|
1899
2597
|
|
|
1900
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2598
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
|
|
1901
2599
|
class ObjectCoercer {
|
|
1902
2600
|
match(candidate) {
|
|
1903
2601
|
return typeof candidate == "object" && candidate !== null;
|
|
@@ -1909,13 +2607,16 @@ class ObjectCoercer {
|
|
|
1909
2607
|
return {
|
|
1910
2608
|
type: this.getType(candidate),
|
|
1911
2609
|
value: this.getValue(candidate),
|
|
1912
|
-
stack: ctx.syntheticException?.stack,
|
|
2610
|
+
stack: this.getStack(candidate) ?? ctx.syntheticException?.stack,
|
|
1913
2611
|
level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
|
|
1914
2612
|
synthetic: true
|
|
1915
2613
|
};
|
|
1916
2614
|
}
|
|
1917
2615
|
getType(err) {
|
|
1918
|
-
|
|
2616
|
+
if (isEvent(err))
|
|
2617
|
+
return err.constructor.name;
|
|
2618
|
+
const name = "name" in err ? err.name : undefined;
|
|
2619
|
+
return isString(name) && !isEmptyString(name) ? name : "Error";
|
|
1919
2620
|
}
|
|
1920
2621
|
getValue(err) {
|
|
1921
2622
|
if ("name" in err && typeof err.name == "string") {
|
|
@@ -1933,6 +2634,15 @@ class ObjectCoercer {
|
|
|
1933
2634
|
isSeverityLevel(x) {
|
|
1934
2635
|
return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
|
|
1935
2636
|
}
|
|
2637
|
+
getStack(candidate) {
|
|
2638
|
+
try {
|
|
2639
|
+
if (isString(candidate.stacktrace) && candidate.stacktrace.length > 0)
|
|
2640
|
+
return candidate.stacktrace;
|
|
2641
|
+
return isString(candidate.stack) && candidate.stack.length > 0 ? candidate.stack : undefined;
|
|
2642
|
+
} catch {
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
1936
2646
|
getErrorPropertyFromObject(obj) {
|
|
1937
2647
|
for (const prop in obj)
|
|
1938
2648
|
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
@@ -1950,7 +2660,7 @@ class ObjectCoercer {
|
|
|
1950
2660
|
}
|
|
1951
2661
|
}
|
|
1952
2662
|
}
|
|
1953
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2663
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
|
|
1954
2664
|
class EventCoercer {
|
|
1955
2665
|
match(err) {
|
|
1956
2666
|
return isEvent(err);
|
|
@@ -1965,7 +2675,7 @@ class EventCoercer {
|
|
|
1965
2675
|
};
|
|
1966
2676
|
}
|
|
1967
2677
|
}
|
|
1968
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2678
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
|
|
1969
2679
|
class PrimitiveCoercer {
|
|
1970
2680
|
match(candidate) {
|
|
1971
2681
|
return isPrimitive(candidate);
|
|
@@ -1979,43 +2689,7 @@ class PrimitiveCoercer {
|
|
|
1979
2689
|
};
|
|
1980
2690
|
}
|
|
1981
2691
|
}
|
|
1982
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
1983
|
-
class PromiseRejectionEventCoercer {
|
|
1984
|
-
match(err) {
|
|
1985
|
-
return isBuiltin(err, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(err);
|
|
1986
|
-
}
|
|
1987
|
-
isCustomEventWrappingRejection(err) {
|
|
1988
|
-
if (!isEvent(err))
|
|
1989
|
-
return false;
|
|
1990
|
-
try {
|
|
1991
|
-
const detail = err.detail;
|
|
1992
|
-
return detail != null && typeof detail == "object" && "reason" in detail;
|
|
1993
|
-
} catch {
|
|
1994
|
-
return false;
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
coerce(err, ctx) {
|
|
1998
|
-
const reason = this.getUnhandledRejectionReason(err);
|
|
1999
|
-
if (isPrimitive(reason))
|
|
2000
|
-
return {
|
|
2001
|
-
type: "UnhandledRejection",
|
|
2002
|
-
value: `Non-Error promise rejection captured with value: ${String(reason)}`,
|
|
2003
|
-
stack: ctx.syntheticException?.stack,
|
|
2004
|
-
synthetic: true
|
|
2005
|
-
};
|
|
2006
|
-
return ctx.apply(reason);
|
|
2007
|
-
}
|
|
2008
|
-
getUnhandledRejectionReason(error) {
|
|
2009
|
-
try {
|
|
2010
|
-
if ("reason" in error)
|
|
2011
|
-
return error.reason;
|
|
2012
|
-
if ("detail" in error && error.detail != null && typeof error.detail == "object" && "reason" in error.detail)
|
|
2013
|
-
return error.detail.reason;
|
|
2014
|
-
} catch {}
|
|
2015
|
-
return error;
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/utils.mjs
|
|
2692
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/utils.mjs
|
|
2019
2693
|
class ReduceableCache {
|
|
2020
2694
|
constructor(_maxSize) {
|
|
2021
2695
|
this._maxSize = _maxSize;
|
|
@@ -2032,184 +2706,82 @@ class ReduceableCache {
|
|
|
2032
2706
|
set(key, value) {
|
|
2033
2707
|
this._cache.set(key, value);
|
|
2034
2708
|
}
|
|
2035
|
-
reduce() {
|
|
2036
|
-
while (this._cache.size >= this._maxSize) {
|
|
2037
|
-
const value = this._cache.keys().next().value;
|
|
2038
|
-
if (value)
|
|
2039
|
-
this._cache.delete(value);
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.30.3/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
|
|
2044
|
-
var EXCEPTION_STEP_INTERNAL_FIELDS = {
|
|
2045
|
-
MESSAGE: "$message",
|
|
2046
|
-
TIMESTAMP: "$timestamp"
|
|
2047
|
-
};
|
|
2048
|
-
var RESERVED_EXCEPTION_STEP_KEYS = new Set([
|
|
2049
|
-
EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
|
|
2050
|
-
EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
|
|
2051
|
-
]);
|
|
2052
|
-
var DEFAULT_EXCEPTION_STEPS_CONFIG = {
|
|
2053
|
-
enabled: true,
|
|
2054
|
-
max_bytes: 32768
|
|
2055
|
-
};
|
|
2056
|
-
function resolveExceptionStepsConfig(config) {
|
|
2057
|
-
if (!config)
|
|
2058
|
-
return {
|
|
2059
|
-
...DEFAULT_EXCEPTION_STEPS_CONFIG
|
|
2060
|
-
};
|
|
2061
|
-
return {
|
|
2062
|
-
enabled: config.enabled ?? DEFAULT_EXCEPTION_STEPS_CONFIG.enabled,
|
|
2063
|
-
max_bytes: normalizePositiveInteger(config.max_bytes, DEFAULT_EXCEPTION_STEPS_CONFIG.max_bytes)
|
|
2064
|
-
};
|
|
2065
|
-
}
|
|
2066
|
-
function stripReservedExceptionStepFields(properties) {
|
|
2067
|
-
if (!properties)
|
|
2068
|
-
return {
|
|
2069
|
-
sanitizedProperties: {},
|
|
2070
|
-
droppedKeys: []
|
|
2071
|
-
};
|
|
2072
|
-
const droppedKeys = [];
|
|
2073
|
-
const sanitizedProperties = Object.keys(properties).reduce((acc, key) => {
|
|
2074
|
-
if (RESERVED_EXCEPTION_STEP_KEYS.has(key)) {
|
|
2075
|
-
droppedKeys.push(key);
|
|
2076
|
-
return acc;
|
|
2077
|
-
}
|
|
2078
|
-
acc[key] = properties[key];
|
|
2079
|
-
return acc;
|
|
2080
|
-
}, {});
|
|
2081
|
-
return {
|
|
2082
|
-
sanitizedProperties,
|
|
2083
|
-
droppedKeys
|
|
2084
|
-
};
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
class ExceptionStepsBuffer {
|
|
2088
|
-
constructor(config) {
|
|
2089
|
-
this._entries = [];
|
|
2090
|
-
this._totalBytes = 0;
|
|
2091
|
-
this._config = resolveExceptionStepsConfig(config);
|
|
2092
|
-
}
|
|
2093
|
-
setConfig(config) {
|
|
2094
|
-
this._config = resolveExceptionStepsConfig(config);
|
|
2095
|
-
this._trimToMaxBytes();
|
|
2096
|
-
}
|
|
2097
|
-
add(step) {
|
|
2098
|
-
const serialized = normalizeAndSerializeStep(step);
|
|
2099
|
-
if (!serialized)
|
|
2100
|
-
return;
|
|
2101
|
-
const bytes = getUtf8ByteLength(serialized.json);
|
|
2102
|
-
if (bytes > this._config.max_bytes)
|
|
2103
|
-
return;
|
|
2104
|
-
this._entries.push({
|
|
2105
|
-
step: serialized.step,
|
|
2106
|
-
bytes
|
|
2107
|
-
});
|
|
2108
|
-
this._totalBytes += bytes;
|
|
2109
|
-
this._trimToMaxBytes();
|
|
2110
|
-
}
|
|
2111
|
-
getAttachable() {
|
|
2112
|
-
return this._entries.map((e) => e.step);
|
|
2113
|
-
}
|
|
2114
|
-
clear() {
|
|
2115
|
-
this._entries = [];
|
|
2116
|
-
this._totalBytes = 0;
|
|
2117
|
-
}
|
|
2118
|
-
size() {
|
|
2119
|
-
return this._entries.length;
|
|
2120
|
-
}
|
|
2121
|
-
_trimToMaxBytes() {
|
|
2122
|
-
while (this._totalBytes > this._config.max_bytes && this._entries.length > 0) {
|
|
2123
|
-
const evicted = this._entries.shift();
|
|
2124
|
-
if (evicted)
|
|
2125
|
-
this._totalBytes -= evicted.bytes;
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
function normalizePositiveInteger(input, fallback) {
|
|
2130
|
-
if (!isNumber(input) || input === 1 / 0 || input === -1 / 0)
|
|
2131
|
-
return fallback;
|
|
2132
|
-
const normalized = Math.floor(input);
|
|
2133
|
-
if (normalized < 0)
|
|
2134
|
-
return fallback;
|
|
2135
|
-
return normalized;
|
|
2136
|
-
}
|
|
2137
|
-
function normalizeAndSerializeStep(step) {
|
|
2138
|
-
const json = safeStringify(step);
|
|
2139
|
-
if (!json)
|
|
2140
|
-
return;
|
|
2141
|
-
try {
|
|
2142
|
-
const parsed = JSON.parse(json);
|
|
2143
|
-
if (!isObject(parsed))
|
|
2144
|
-
return;
|
|
2145
|
-
const parsedStep = parsed;
|
|
2146
|
-
const message = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE];
|
|
2147
|
-
const timestamp = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP];
|
|
2148
|
-
if (!isString(message) || message.trim().length === 0)
|
|
2149
|
-
return;
|
|
2150
|
-
if (!isString(timestamp) && !isNumber(timestamp))
|
|
2151
|
-
return;
|
|
2152
|
-
return {
|
|
2153
|
-
step: parsedStep,
|
|
2154
|
-
json
|
|
2155
|
-
};
|
|
2156
|
-
} catch {
|
|
2157
|
-
return;
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
function safeStringify(value) {
|
|
2161
|
-
const seen = new WeakSet;
|
|
2162
|
-
try {
|
|
2163
|
-
return JSON.stringify(value, (_key, replacementValue) => {
|
|
2164
|
-
if (typeof replacementValue == "bigint")
|
|
2165
|
-
return replacementValue.toString();
|
|
2166
|
-
if (typeof replacementValue == "function" || typeof replacementValue == "symbol")
|
|
2167
|
-
return;
|
|
2168
|
-
if (replacementValue instanceof Date)
|
|
2169
|
-
return replacementValue.toISOString();
|
|
2170
|
-
if (replacementValue instanceof Error)
|
|
2171
|
-
return {
|
|
2172
|
-
name: replacementValue.name,
|
|
2173
|
-
message: replacementValue.message,
|
|
2174
|
-
stack: replacementValue.stack
|
|
2175
|
-
};
|
|
2176
|
-
if (replacementValue && typeof replacementValue == "object") {
|
|
2177
|
-
if (seen.has(replacementValue))
|
|
2178
|
-
return "[Circular]";
|
|
2179
|
-
seen.add(replacementValue);
|
|
2180
|
-
}
|
|
2181
|
-
return replacementValue;
|
|
2182
|
-
});
|
|
2183
|
-
} catch {
|
|
2184
|
-
return;
|
|
2709
|
+
reduce() {
|
|
2710
|
+
while (this._cache.size >= this._maxSize) {
|
|
2711
|
+
const value = this._cache.keys().next().value;
|
|
2712
|
+
if (value)
|
|
2713
|
+
this._cache.delete(value);
|
|
2714
|
+
}
|
|
2185
2715
|
}
|
|
2186
2716
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2717
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
|
|
2718
|
+
var EXCEPTION_STEP_INTERNAL_FIELDS = {
|
|
2719
|
+
MESSAGE: "$message",
|
|
2720
|
+
TIMESTAMP: "$timestamp"
|
|
2721
|
+
};
|
|
2722
|
+
var RESERVED_EXCEPTION_STEP_KEYS = new Set([
|
|
2723
|
+
EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
|
|
2724
|
+
EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
|
|
2725
|
+
]);
|
|
2726
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/error-tracking/release.mjs
|
|
2727
|
+
function getInjectedReleaseId() {
|
|
2728
|
+
const injected = globalThis._posthogReleaseId;
|
|
2729
|
+
return typeof injected == "string" && injected.length > 0 ? injected : undefined;
|
|
2199
2730
|
}
|
|
2200
|
-
// ../../../../../node_modules/.bun/@posthog+core@1.
|
|
2731
|
+
// ../../../../../node_modules/.bun/@posthog+core@1.48.9/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
|
|
2201
2732
|
class PostHogFetchHttpError extends Error {
|
|
2202
|
-
constructor(response, reqByteLength) {
|
|
2203
|
-
super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
|
|
2733
|
+
constructor(response, reqByteLength, responseBodyDeadline, abortController) {
|
|
2734
|
+
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;
|
|
2204
2735
|
}
|
|
2205
2736
|
get status() {
|
|
2206
2737
|
return this.response.status;
|
|
2207
2738
|
}
|
|
2739
|
+
get bodyReadTimedOut() {
|
|
2740
|
+
return this._bodyReadTimedOut;
|
|
2741
|
+
}
|
|
2208
2742
|
get text() {
|
|
2209
|
-
|
|
2743
|
+
if (!this.responseBodyTextPromise)
|
|
2744
|
+
if (Date.now() >= this.responseBodyDeadline) {
|
|
2745
|
+
this._bodyReadTimedOut = true;
|
|
2746
|
+
const timeoutError = new Error("Response body read timed out");
|
|
2747
|
+
timeoutError.name = "AbortError";
|
|
2748
|
+
this.cancelResponseBody(timeoutError);
|
|
2749
|
+
this.responseBodyTextPromise = Promise.reject(timeoutError);
|
|
2750
|
+
} else {
|
|
2751
|
+
const responseBodyTimeout = new Promise((_resolve, reject) => {
|
|
2752
|
+
this.responseBodyTimer = safeSetTimeout(() => {
|
|
2753
|
+
this._bodyReadTimedOut = true;
|
|
2754
|
+
const timeoutError = new Error("Response body read timed out");
|
|
2755
|
+
timeoutError.name = "AbortError";
|
|
2756
|
+
reject(timeoutError);
|
|
2757
|
+
this.cancelResponseBody(timeoutError);
|
|
2758
|
+
}, this.responseBodyDeadline - Date.now());
|
|
2759
|
+
});
|
|
2760
|
+
let responseBodyText;
|
|
2761
|
+
try {
|
|
2762
|
+
responseBodyText = Promise.resolve(this.response.text());
|
|
2763
|
+
} catch (error) {
|
|
2764
|
+
responseBodyText = Promise.reject(error);
|
|
2765
|
+
}
|
|
2766
|
+
this.responseBodyTextPromise = Promise.race([
|
|
2767
|
+
responseBodyText,
|
|
2768
|
+
responseBodyTimeout
|
|
2769
|
+
]).finally(() => clearTimeout(this.responseBodyTimer));
|
|
2770
|
+
}
|
|
2771
|
+
return this.responseBodyTextPromise;
|
|
2210
2772
|
}
|
|
2211
2773
|
get json() {
|
|
2212
|
-
return this.
|
|
2774
|
+
return this.text.then((text) => JSON.parse(text));
|
|
2775
|
+
}
|
|
2776
|
+
cancelResponseBody(reason) {
|
|
2777
|
+
clearTimeout(this.responseBodyTimer);
|
|
2778
|
+
if (!this.abortController.signal.aborted)
|
|
2779
|
+
this.abortController.abort(reason);
|
|
2780
|
+
(async () => {
|
|
2781
|
+
try {
|
|
2782
|
+
await this.response.body?.cancel();
|
|
2783
|
+
} catch {}
|
|
2784
|
+
})();
|
|
2213
2785
|
}
|
|
2214
2786
|
}
|
|
2215
2787
|
|
|
@@ -2220,12 +2792,20 @@ class PostHogFetchNetworkError extends Error {
|
|
|
2220
2792
|
} : {}), this.error = error, this.name = "PostHogFetchNetworkError";
|
|
2221
2793
|
}
|
|
2222
2794
|
}
|
|
2795
|
+
var applyCallerFeatureFlagOverrides = (target, callerProperties) => {
|
|
2796
|
+
for (const key of Object.keys(callerProperties))
|
|
2797
|
+
if (key.startsWith("$feature/") || key === "$active_feature_flags")
|
|
2798
|
+
target[key] = callerProperties[key];
|
|
2799
|
+
};
|
|
2223
2800
|
async function logFlushError(err) {
|
|
2224
2801
|
if (err instanceof PostHogFetchHttpError) {
|
|
2225
2802
|
let text = "";
|
|
2226
2803
|
try {
|
|
2227
2804
|
text = await err.text;
|
|
2228
|
-
} catch {
|
|
2805
|
+
} catch {
|
|
2806
|
+
if (err.bodyReadTimedOut)
|
|
2807
|
+
text = "<response body read timed out>";
|
|
2808
|
+
}
|
|
2229
2809
|
console.error(`Error while flushing PostHog: message=${err.message}, response body=${text}`, err);
|
|
2230
2810
|
} else
|
|
2231
2811
|
console.error("Error while flushing PostHog", err);
|
|
@@ -2237,9 +2817,28 @@ function isPostHogFetchError(err) {
|
|
|
2237
2817
|
function isPostHogFetchNetworkError(err) {
|
|
2238
2818
|
return err instanceof PostHogFetchNetworkError;
|
|
2239
2819
|
}
|
|
2820
|
+
function isRetryableFlagsFetchError(err) {
|
|
2821
|
+
if (err instanceof PostHogFetchHttpError)
|
|
2822
|
+
return err.status === 502 || err.status === 504;
|
|
2823
|
+
if (!(err instanceof PostHogFetchNetworkError))
|
|
2824
|
+
return false;
|
|
2825
|
+
const cause = err.error;
|
|
2826
|
+
const code = cause?.code ?? cause?.cause?.code;
|
|
2827
|
+
return code !== "ECONNREFUSED";
|
|
2828
|
+
}
|
|
2240
2829
|
function isPostHogFetchContentTooLargeError(err) {
|
|
2241
2830
|
return typeof err == "object" && err instanceof PostHogFetchHttpError && err.status === 413;
|
|
2242
2831
|
}
|
|
2832
|
+
function isPostHogFetchRetryableError(err) {
|
|
2833
|
+
if (err instanceof PostHogFetchHttpError)
|
|
2834
|
+
return err.status === 408 || err.status === 429 || err.status >= 500;
|
|
2835
|
+
return isPostHogFetchNetworkError(err);
|
|
2836
|
+
}
|
|
2837
|
+
function isPostHogEventProperties(value) {
|
|
2838
|
+
return value !== null && typeof value == "object" && !Array.isArray(value);
|
|
2839
|
+
}
|
|
2840
|
+
var DEFAULT_QUEUE_ROUTE = "default";
|
|
2841
|
+
|
|
2243
2842
|
class PostHogCoreStateless {
|
|
2244
2843
|
getErrorPropertiesBuilder() {
|
|
2245
2844
|
if (!this._errorPropertiesBuilder)
|
|
@@ -2256,6 +2855,9 @@ class PostHogCoreStateless {
|
|
|
2256
2855
|
}
|
|
2257
2856
|
constructor(apiKey, options = {}) {
|
|
2258
2857
|
this.flushPromise = null;
|
|
2858
|
+
this.pendingFlushPromise = null;
|
|
2859
|
+
this.flushPromises = new Set;
|
|
2860
|
+
this._dequeuedMessagesCount = 0;
|
|
2259
2861
|
this.shutdownPromise = null;
|
|
2260
2862
|
this.promiseQueue = new PromiseQueue;
|
|
2261
2863
|
this._events = new SimpleEventEmitter;
|
|
@@ -2278,10 +2880,11 @@ class PostHogCoreStateless {
|
|
|
2278
2880
|
this._retryOptions = {
|
|
2279
2881
|
retryCount: options.fetchRetryCount ?? 3,
|
|
2280
2882
|
retryDelay: options.fetchRetryDelay ?? 3000,
|
|
2281
|
-
retryCheck:
|
|
2883
|
+
retryCheck: isPostHogFetchRetryableError
|
|
2282
2884
|
};
|
|
2283
2885
|
this.requestTimeout = options.requestTimeout ?? 1e4;
|
|
2284
2886
|
this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3000;
|
|
2887
|
+
this.featureFlagsRequestMaxRetries = options.featureFlagsRequestMaxRetries ?? 1;
|
|
2285
2888
|
this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3000;
|
|
2286
2889
|
this.disableGeoip = options.disableGeoip ?? true;
|
|
2287
2890
|
this.disabled = (options.disabled ?? false) || missingApiKey;
|
|
@@ -2343,15 +2946,23 @@ class PostHogCoreStateless {
|
|
|
2343
2946
|
return this.disabled;
|
|
2344
2947
|
}
|
|
2345
2948
|
buildPayload(payload) {
|
|
2949
|
+
const userProperties = payload.properties || {};
|
|
2950
|
+
let properties = {
|
|
2951
|
+
...userProperties,
|
|
2952
|
+
...this.getCommonEventProperties()
|
|
2953
|
+
};
|
|
2954
|
+
applyCallerFeatureFlagOverrides(properties, userProperties);
|
|
2955
|
+
if (payload.event === "$feature_flag_called" && properties.$feature_flag_has_experiment === false && this.isMinimalFlagCalledEventsEnabled())
|
|
2956
|
+
properties = minimizeFlagCalledEventProperties(properties);
|
|
2346
2957
|
return {
|
|
2347
2958
|
distinct_id: payload.distinct_id,
|
|
2348
2959
|
event: payload.event,
|
|
2349
|
-
properties
|
|
2350
|
-
...payload.properties || {},
|
|
2351
|
-
...this.getCommonEventProperties()
|
|
2352
|
-
}
|
|
2960
|
+
properties
|
|
2353
2961
|
};
|
|
2354
2962
|
}
|
|
2963
|
+
isMinimalFlagCalledEventsEnabled() {
|
|
2964
|
+
return false;
|
|
2965
|
+
}
|
|
2355
2966
|
addPendingPromise(promise) {
|
|
2356
2967
|
return this.promiseQueue.add(promise);
|
|
2357
2968
|
}
|
|
@@ -2436,6 +3047,19 @@ class PostHogCoreStateless {
|
|
|
2436
3047
|
this.enqueue("capture", payload, options);
|
|
2437
3048
|
});
|
|
2438
3049
|
}
|
|
3050
|
+
async groupIdentifyStatelessImmediate(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
|
|
3051
|
+
const payload = this.buildPayload({
|
|
3052
|
+
distinct_id: distinctId || `$${groupType}_${groupKey}`,
|
|
3053
|
+
event: "$groupidentify",
|
|
3054
|
+
properties: {
|
|
3055
|
+
$group_type: groupType,
|
|
3056
|
+
$group_key: groupKey,
|
|
3057
|
+
$group_set: groupProperties || {},
|
|
3058
|
+
...eventProperties || {}
|
|
3059
|
+
}
|
|
3060
|
+
});
|
|
3061
|
+
await this.sendImmediate("capture", payload, options);
|
|
3062
|
+
}
|
|
2439
3063
|
async getRemoteConfig() {
|
|
2440
3064
|
await this._initPromise;
|
|
2441
3065
|
let host = this.host;
|
|
@@ -2452,8 +3076,11 @@ class PostHogCoreStateless {
|
|
|
2452
3076
|
}
|
|
2453
3077
|
};
|
|
2454
3078
|
return this.fetchWithRetry(url, fetchOptions, {
|
|
3079
|
+
type: "required",
|
|
3080
|
+
consume: (response) => response.json()
|
|
3081
|
+
}, {
|
|
2455
3082
|
retryCount: 0
|
|
2456
|
-
}, this.remoteConfigRequestTimeoutMs).
|
|
3083
|
+
}, this.remoteConfigRequestTimeoutMs).catch((error) => {
|
|
2457
3084
|
this._logger.error("Remote config could not be loaded", error);
|
|
2458
3085
|
this._events.emit("error", error);
|
|
2459
3086
|
});
|
|
@@ -2484,8 +3111,12 @@ class PostHogCoreStateless {
|
|
|
2484
3111
|
};
|
|
2485
3112
|
this._logger.info("Flags URL", url);
|
|
2486
3113
|
return this.fetchWithRetry(url, fetchOptions, {
|
|
2487
|
-
|
|
2488
|
-
|
|
3114
|
+
type: "required",
|
|
3115
|
+
consume: (response) => response.json()
|
|
3116
|
+
}, {
|
|
3117
|
+
retryCount: this.featureFlagsRequestMaxRetries,
|
|
3118
|
+
retryCheck: isRetryableFlagsFetchError
|
|
3119
|
+
}, this.featureFlagsRequestTimeoutMs).then((response) => ({
|
|
2489
3120
|
success: true,
|
|
2490
3121
|
response: normalizeFlagsResponse(response)
|
|
2491
3122
|
})).catch((error) => {
|
|
@@ -2585,9 +3216,9 @@ class PostHogCoreStateless {
|
|
|
2585
3216
|
}
|
|
2586
3217
|
async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
|
|
2587
3218
|
await this._initPromise;
|
|
2588
|
-
const extraPayload = {
|
|
2589
|
-
|
|
2590
|
-
|
|
3219
|
+
const extraPayload = {
|
|
3220
|
+
geoip_disable: disableGeoip ?? this.disableGeoip
|
|
3221
|
+
};
|
|
2591
3222
|
if (flagKeysToEvaluate)
|
|
2592
3223
|
extraPayload["flag_keys_to_evaluate"] = flagKeysToEvaluate;
|
|
2593
3224
|
const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
|
|
@@ -2624,15 +3255,18 @@ class PostHogCoreStateless {
|
|
|
2624
3255
|
"Content-Type": "application/json"
|
|
2625
3256
|
}
|
|
2626
3257
|
};
|
|
2627
|
-
const response = await this.fetchWithRetry(url, fetchOptions
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
3258
|
+
const response = await this.fetchWithRetry(url, fetchOptions, {
|
|
3259
|
+
type: "required",
|
|
3260
|
+
consume: (response) => {
|
|
3261
|
+
if (response.status !== 200 || !response.json) {
|
|
3262
|
+
const msg = `Surveys API could not be loaded: ${response.status}`;
|
|
3263
|
+
const error = new Error(msg);
|
|
3264
|
+
this._logger.error(error);
|
|
3265
|
+
this._events.emit("error", new Error(msg));
|
|
3266
|
+
return Promise.resolve(undefined);
|
|
3267
|
+
}
|
|
3268
|
+
return response.json();
|
|
2634
3269
|
}
|
|
2635
|
-
return response2.json();
|
|
2636
3270
|
}).catch((error) => {
|
|
2637
3271
|
this._logger.error("Surveys API could not be loaded", error);
|
|
2638
3272
|
this._events.emit("error", error);
|
|
@@ -2669,23 +3303,39 @@ class PostHogCoreStateless {
|
|
|
2669
3303
|
return message;
|
|
2670
3304
|
}
|
|
2671
3305
|
async flushStorage() {}
|
|
2672
|
-
|
|
3306
|
+
getQueueRouteKey(_message) {
|
|
3307
|
+
return DEFAULT_QUEUE_ROUTE;
|
|
3308
|
+
}
|
|
3309
|
+
persistedQueueKeyForRoute(_route) {
|
|
3310
|
+
return types_PostHogPersistedProperty.Queue;
|
|
3311
|
+
}
|
|
3312
|
+
getActiveQueueRoutes() {
|
|
3313
|
+
return [
|
|
3314
|
+
DEFAULT_QUEUE_ROUTE
|
|
3315
|
+
];
|
|
3316
|
+
}
|
|
3317
|
+
getRouteQueue(route) {
|
|
3318
|
+
return this.getPersistedProperty(this.persistedQueueKeyForRoute(route)) || [];
|
|
3319
|
+
}
|
|
3320
|
+
enqueue(type, _message, options, explicitRoute) {
|
|
2673
3321
|
this.wrap(() => {
|
|
2674
3322
|
if (this.optedOut)
|
|
2675
3323
|
return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
2676
|
-
let message = this.prepareMessage(
|
|
3324
|
+
let message = this.prepareMessage(_message, options);
|
|
2677
3325
|
message = this.processBeforeEnqueue(message);
|
|
2678
3326
|
if (message === null)
|
|
2679
3327
|
return;
|
|
2680
|
-
|
|
3328
|
+
message = this.normalizeMessage(message);
|
|
3329
|
+
const queueKey = this.persistedQueueKeyForRoute(explicitRoute ?? this.getQueueRouteKey(message));
|
|
3330
|
+
const queue = this.getPersistedProperty(queueKey) || [];
|
|
2681
3331
|
if (queue.length >= this.maxQueueSize) {
|
|
2682
3332
|
queue.shift();
|
|
2683
|
-
this._logger.
|
|
3333
|
+
this._logger.warn("Queue is full, the oldest event is dropped.");
|
|
2684
3334
|
}
|
|
2685
3335
|
queue.push({
|
|
2686
3336
|
message
|
|
2687
3337
|
});
|
|
2688
|
-
this.setPersistedProperty(
|
|
3338
|
+
this.setPersistedProperty(queueKey, queue);
|
|
2689
3339
|
this._events.emit(type, message);
|
|
2690
3340
|
if (queue.length >= this.flushAt)
|
|
2691
3341
|
this.flushBackground();
|
|
@@ -2693,61 +3343,63 @@ class PostHogCoreStateless {
|
|
|
2693
3343
|
this._flushTimer = safeSetTimeout(() => this.flushBackground(), this.flushInterval);
|
|
2694
3344
|
});
|
|
2695
3345
|
}
|
|
2696
|
-
async sendImmediate(type, _message, options) {
|
|
3346
|
+
async sendImmediate(type, _message, options, explicitRoute) {
|
|
2697
3347
|
if (this.disabled)
|
|
2698
3348
|
return void this._logger.warn("The client is disabled");
|
|
2699
3349
|
if (!this._isInitialized)
|
|
2700
3350
|
await this._initPromise;
|
|
2701
3351
|
if (this.optedOut)
|
|
2702
3352
|
return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
2703
|
-
let message = this.prepareMessage(
|
|
3353
|
+
let message = this.prepareMessage(_message, options);
|
|
2704
3354
|
message = this.processBeforeEnqueue(message);
|
|
2705
3355
|
if (message === null)
|
|
2706
3356
|
return;
|
|
2707
|
-
|
|
2708
|
-
api_key: this.apiKey,
|
|
2709
|
-
batch: [
|
|
2710
|
-
message
|
|
2711
|
-
],
|
|
2712
|
-
sent_at: currentISOTime()
|
|
2713
|
-
};
|
|
2714
|
-
if (this.historicalMigration)
|
|
2715
|
-
data.historical_migration = true;
|
|
2716
|
-
const payload = JSON.stringify(data);
|
|
2717
|
-
const url = `${this.host}/batch/`;
|
|
2718
|
-
const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
|
|
2719
|
-
const fetchOptions = {
|
|
2720
|
-
method: "POST",
|
|
2721
|
-
headers: {
|
|
2722
|
-
...this.getCustomHeaders(),
|
|
2723
|
-
"Content-Type": "application/json",
|
|
2724
|
-
...gzippedPayload !== null && {
|
|
2725
|
-
"Content-Encoding": "gzip"
|
|
2726
|
-
}
|
|
2727
|
-
},
|
|
2728
|
-
body: gzippedPayload || payload
|
|
2729
|
-
};
|
|
3357
|
+
message = this.normalizeMessage(message);
|
|
2730
3358
|
try {
|
|
2731
|
-
|
|
2732
|
-
|
|
3359
|
+
await this.sendBatch([
|
|
3360
|
+
message
|
|
3361
|
+
], undefined, explicitRoute ?? this.getQueueRouteKey(message));
|
|
2733
3362
|
} catch (err) {
|
|
2734
3363
|
this._events.emit("error", err);
|
|
2735
3364
|
}
|
|
2736
3365
|
}
|
|
2737
|
-
|
|
3366
|
+
normalizeMessage(message) {
|
|
3367
|
+
const { type: _type, library, library_version, ...sanitizedMessage } = message;
|
|
3368
|
+
let properties = isPostHogEventProperties(sanitizedMessage.properties) ? sanitizedMessage.properties : undefined;
|
|
3369
|
+
if (library !== undefined && properties?.$lib === undefined)
|
|
3370
|
+
properties = {
|
|
3371
|
+
...properties || {},
|
|
3372
|
+
$lib: library
|
|
3373
|
+
};
|
|
3374
|
+
if (library_version !== undefined && properties?.$lib_version === undefined)
|
|
3375
|
+
properties = {
|
|
3376
|
+
...properties || {},
|
|
3377
|
+
$lib_version: library_version
|
|
3378
|
+
};
|
|
3379
|
+
if (properties)
|
|
3380
|
+
sanitizedMessage.properties = properties;
|
|
3381
|
+
sanitizedMessage.uuid = getEventUuid(sanitizedMessage.uuid, uuidv7);
|
|
3382
|
+
return sanitizedMessage;
|
|
3383
|
+
}
|
|
3384
|
+
normalizeTimestampForWire(timestamp) {
|
|
3385
|
+
const parsedTimestamp = timestamp instanceof Date ? timestamp : typeof timestamp == "string" ? new Date(timestamp) : null;
|
|
3386
|
+
if (!parsedTimestamp || Number.isNaN(parsedTimestamp.getTime()))
|
|
3387
|
+
return timestamp;
|
|
3388
|
+
const normalized = parsedTimestamp.toISOString();
|
|
3389
|
+
const fractionalSeconds = typeof timestamp == "string" ? timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1] : undefined;
|
|
3390
|
+
return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
|
|
3391
|
+
}
|
|
3392
|
+
prepareMessage(_message, options) {
|
|
2738
3393
|
const message = {
|
|
2739
3394
|
..._message,
|
|
2740
|
-
type,
|
|
2741
|
-
library: this.getLibraryId(),
|
|
2742
|
-
library_version: this.getLibraryVersion(),
|
|
2743
3395
|
timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
|
|
2744
|
-
uuid: options?.uuid
|
|
3396
|
+
uuid: getEventUuid(options?.uuid, uuidv7)
|
|
2745
3397
|
};
|
|
2746
3398
|
const addGeoipDisableProperty = options?.disableGeoip ?? this.disableGeoip;
|
|
2747
3399
|
if (addGeoipDisableProperty) {
|
|
2748
|
-
if (!message.properties)
|
|
3400
|
+
if (!isPostHogEventProperties(message.properties))
|
|
2749
3401
|
message.properties = {};
|
|
2750
|
-
message
|
|
3402
|
+
message.properties["$geoip_disable"] = true;
|
|
2751
3403
|
}
|
|
2752
3404
|
if (message.distinctId) {
|
|
2753
3405
|
message.distinct_id = message.distinctId;
|
|
@@ -2762,21 +3414,64 @@ class PostHogCoreStateless {
|
|
|
2762
3414
|
}
|
|
2763
3415
|
}
|
|
2764
3416
|
flushBackground() {
|
|
3417
|
+
if (this.pendingFlushPromise)
|
|
3418
|
+
return;
|
|
2765
3419
|
this.flush().catch(async (err) => {
|
|
2766
3420
|
await logFlushError(err);
|
|
2767
3421
|
});
|
|
2768
3422
|
}
|
|
2769
|
-
async
|
|
3423
|
+
async waitForPendingPromises(maxPromiseId, ignoredPromises = []) {
|
|
3424
|
+
const ignoredPendingPromises = ignoredPromises.filter((promise) => !!promise);
|
|
3425
|
+
let iteration = 0;
|
|
3426
|
+
while (true) {
|
|
3427
|
+
const promises = this.promiseQueue.getPromises([
|
|
3428
|
+
...ignoredPendingPromises,
|
|
3429
|
+
...this.flushPromises
|
|
3430
|
+
], maxPromiseId);
|
|
3431
|
+
if (promises.length === 0)
|
|
3432
|
+
return;
|
|
3433
|
+
if (iteration > 0)
|
|
3434
|
+
this._logger.debug(`flush() re-checking ${promises.length} pending promise(s) before flushing`);
|
|
3435
|
+
await Promise.all(promises.map((promise) => promise.catch(() => {})));
|
|
3436
|
+
iteration++;
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
flushWithPendingPromises() {
|
|
3440
|
+
return this.flushInternal(true);
|
|
3441
|
+
}
|
|
3442
|
+
flush() {
|
|
3443
|
+
return this.flushInternal(false);
|
|
3444
|
+
}
|
|
3445
|
+
flushInternal(waitForPendingPromises) {
|
|
2770
3446
|
if (this.disabled)
|
|
2771
|
-
return;
|
|
2772
|
-
|
|
2773
|
-
this.
|
|
2774
|
-
|
|
3447
|
+
return Promise.resolve();
|
|
3448
|
+
if (!waitForPendingPromises && this.pendingFlushPromise)
|
|
3449
|
+
return this.pendingFlushPromise;
|
|
3450
|
+
const previousFlushPromise = this.flushPromise;
|
|
3451
|
+
const maxPromiseId = this.promiseQueue.maxId;
|
|
3452
|
+
const nextFlushPromise = Promise.resolve().then(() => {
|
|
3453
|
+
if (waitForPendingPromises)
|
|
3454
|
+
return this.waitForPendingPromises(maxPromiseId, [
|
|
3455
|
+
previousFlushPromise,
|
|
3456
|
+
nextFlushPromise
|
|
3457
|
+
]);
|
|
3458
|
+
}).then(() => allSettled([
|
|
3459
|
+
previousFlushPromise
|
|
3460
|
+
])).then(() => {
|
|
3461
|
+
if (this.pendingFlushPromise === nextFlushPromise)
|
|
3462
|
+
this.pendingFlushPromise = null;
|
|
3463
|
+
return this._flush();
|
|
3464
|
+
});
|
|
3465
|
+
this.pendingFlushPromise = nextFlushPromise;
|
|
2775
3466
|
this.flushPromise = nextFlushPromise;
|
|
3467
|
+
this.flushPromises.add(nextFlushPromise);
|
|
2776
3468
|
this.addPendingPromise(nextFlushPromise);
|
|
2777
3469
|
allSettled([
|
|
2778
3470
|
nextFlushPromise
|
|
2779
3471
|
]).then(() => {
|
|
3472
|
+
this.flushPromises.delete(nextFlushPromise);
|
|
3473
|
+
if (this.pendingFlushPromise === nextFlushPromise)
|
|
3474
|
+
this.pendingFlushPromise = null;
|
|
2780
3475
|
if (this.flushPromise === nextFlushPromise)
|
|
2781
3476
|
this.flushPromise = null;
|
|
2782
3477
|
});
|
|
@@ -2789,55 +3484,102 @@ class PostHogCoreStateless {
|
|
|
2789
3484
|
headers["User-Agent"] = customUserAgent;
|
|
2790
3485
|
return headers;
|
|
2791
3486
|
}
|
|
3487
|
+
compressPayload(payload) {
|
|
3488
|
+
return gzipCompress(payload, this.isDebug);
|
|
3489
|
+
}
|
|
3490
|
+
getBatchEndpointPath(_route) {
|
|
3491
|
+
return "/batch/";
|
|
3492
|
+
}
|
|
3493
|
+
async sendBatch(batchMessages, retryOptions, route = DEFAULT_QUEUE_ROUTE) {
|
|
3494
|
+
const data = {
|
|
3495
|
+
api_key: this.apiKey,
|
|
3496
|
+
batch: batchMessages.map((message) => {
|
|
3497
|
+
if (!message)
|
|
3498
|
+
return message;
|
|
3499
|
+
const timestamp = this.normalizeTimestampForWire(message.timestamp);
|
|
3500
|
+
return timestamp === message.timestamp ? message : {
|
|
3501
|
+
...message,
|
|
3502
|
+
timestamp
|
|
3503
|
+
};
|
|
3504
|
+
}),
|
|
3505
|
+
sent_at: currentISOTime()
|
|
3506
|
+
};
|
|
3507
|
+
if (this.historicalMigration)
|
|
3508
|
+
data.historical_migration = true;
|
|
3509
|
+
const payload = safeJsonStringify(data);
|
|
3510
|
+
const url = `${this.host}${this.getBatchEndpointPath(route)}`;
|
|
3511
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(payload);
|
|
3512
|
+
const fetchOptions = {
|
|
3513
|
+
method: "POST",
|
|
3514
|
+
headers: {
|
|
3515
|
+
...this.getCustomHeaders(),
|
|
3516
|
+
"Content-Type": "application/json",
|
|
3517
|
+
...gzippedPayload !== null && {
|
|
3518
|
+
"Content-Encoding": "gzip"
|
|
3519
|
+
}
|
|
3520
|
+
},
|
|
3521
|
+
body: gzippedPayload || payload
|
|
3522
|
+
};
|
|
3523
|
+
await this.fetchWithRetry(url, fetchOptions, {
|
|
3524
|
+
type: "successful-write"
|
|
3525
|
+
}, retryOptions);
|
|
3526
|
+
}
|
|
2792
3527
|
async _flush() {
|
|
2793
3528
|
this.clearFlushTimer();
|
|
2794
3529
|
await this._initPromise;
|
|
2795
|
-
|
|
2796
|
-
if (!
|
|
3530
|
+
const routes = this.getActiveQueueRoutes();
|
|
3531
|
+
if (!routes.some((route) => this.getRouteQueue(route).length > 0))
|
|
2797
3532
|
return;
|
|
2798
3533
|
const sentMessages = [];
|
|
3534
|
+
let firstError;
|
|
3535
|
+
for (const route of routes)
|
|
3536
|
+
try {
|
|
3537
|
+
await this._flushRoute(route, sentMessages);
|
|
3538
|
+
} catch (err) {
|
|
3539
|
+
if (firstError === undefined)
|
|
3540
|
+
firstError = err;
|
|
3541
|
+
}
|
|
3542
|
+
if (firstError !== undefined)
|
|
3543
|
+
throw firstError;
|
|
3544
|
+
this._events.emit("flush", sentMessages);
|
|
3545
|
+
}
|
|
3546
|
+
async _flushRoute(route, sentMessages) {
|
|
3547
|
+
const queueKey = this.persistedQueueKeyForRoute(route);
|
|
3548
|
+
let queue = this.getPersistedProperty(queueKey) || [];
|
|
3549
|
+
if (!queue.length)
|
|
3550
|
+
return;
|
|
2799
3551
|
const originalQueueLength = queue.length;
|
|
2800
|
-
|
|
3552
|
+
let sentFromRoute = 0;
|
|
3553
|
+
while (queue.length > 0 && sentFromRoute < originalQueueLength) {
|
|
2801
3554
|
const batchItems = queue.slice(0, this.maxBatchSize);
|
|
2802
|
-
const batchMessages = batchItems.map((item) => item.message);
|
|
3555
|
+
const batchMessages = batchItems.map((item) => item.message === undefined ? item.message : this.normalizeMessage(item.message));
|
|
2803
3556
|
const persistQueueChange = async () => {
|
|
2804
|
-
const refreshedQueue = this.getPersistedProperty(
|
|
2805
|
-
const
|
|
2806
|
-
|
|
3557
|
+
const refreshedQueue = this.getPersistedProperty(queueKey) || [];
|
|
3558
|
+
const remainingBatchItems = [
|
|
3559
|
+
...batchItems
|
|
3560
|
+
];
|
|
3561
|
+
const newQueue = refreshedQueue.filter((item) => {
|
|
3562
|
+
const itemUuid = item.message?.uuid;
|
|
3563
|
+
const batchItemIndex = remainingBatchItems.findIndex((batchItem) => batchItem === item || typeof itemUuid == "string" && itemUuid.length > 0 && batchItem.message?.uuid === itemUuid);
|
|
3564
|
+
if (batchItemIndex === -1)
|
|
3565
|
+
return true;
|
|
3566
|
+
remainingBatchItems.splice(batchItemIndex, 1);
|
|
3567
|
+
return false;
|
|
3568
|
+
});
|
|
3569
|
+
this.setPersistedProperty(queueKey, newQueue);
|
|
2807
3570
|
queue = newQueue;
|
|
3571
|
+
this._dequeuedMessagesCount += batchItems.length;
|
|
2808
3572
|
await this.flushStorage();
|
|
2809
3573
|
};
|
|
2810
|
-
const data = {
|
|
2811
|
-
api_key: this.apiKey,
|
|
2812
|
-
batch: batchMessages,
|
|
2813
|
-
sent_at: currentISOTime()
|
|
2814
|
-
};
|
|
2815
|
-
if (this.historicalMigration)
|
|
2816
|
-
data.historical_migration = true;
|
|
2817
|
-
const payload = JSON.stringify(data);
|
|
2818
|
-
const url = `${this.host}/batch/`;
|
|
2819
|
-
const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
|
|
2820
|
-
const fetchOptions = {
|
|
2821
|
-
method: "POST",
|
|
2822
|
-
headers: {
|
|
2823
|
-
...this.getCustomHeaders(),
|
|
2824
|
-
"Content-Type": "application/json",
|
|
2825
|
-
...gzippedPayload !== null && {
|
|
2826
|
-
"Content-Encoding": "gzip"
|
|
2827
|
-
}
|
|
2828
|
-
},
|
|
2829
|
-
body: gzippedPayload || payload
|
|
2830
|
-
};
|
|
2831
3574
|
const retryOptions = {
|
|
2832
3575
|
retryCheck: (err) => {
|
|
2833
3576
|
if (isPostHogFetchContentTooLargeError(err))
|
|
2834
3577
|
return false;
|
|
2835
|
-
return
|
|
3578
|
+
return isPostHogFetchRetryableError(err);
|
|
2836
3579
|
}
|
|
2837
3580
|
};
|
|
2838
3581
|
try {
|
|
2839
|
-
|
|
2840
|
-
await response.body?.cancel()?.catch(() => {});
|
|
3582
|
+
await this.sendBatch(batchMessages, retryOptions, route);
|
|
2841
3583
|
} catch (err) {
|
|
2842
3584
|
if (isPostHogFetchContentTooLargeError(err) && batchMessages.length > 1) {
|
|
2843
3585
|
this.maxBatchSize = Math.max(1, Math.floor(batchMessages.length / 2));
|
|
@@ -2851,8 +3593,8 @@ class PostHogCoreStateless {
|
|
|
2851
3593
|
}
|
|
2852
3594
|
await persistQueueChange();
|
|
2853
3595
|
sentMessages.push(...batchMessages);
|
|
3596
|
+
sentFromRoute += batchMessages.length;
|
|
2854
3597
|
}
|
|
2855
|
-
this._events.emit("flush", sentMessages);
|
|
2856
3598
|
}
|
|
2857
3599
|
async _sendLogsBatch(payload) {
|
|
2858
3600
|
if (this.disabled)
|
|
@@ -2862,7 +3604,7 @@ class PostHogCoreStateless {
|
|
|
2862
3604
|
};
|
|
2863
3605
|
const serialized = JSON.stringify(payload);
|
|
2864
3606
|
const url = `${this.host}/i/v1/logs?token=${encodeURIComponent(this.apiKey)}`;
|
|
2865
|
-
const gzippedPayload = this.disableCompression ? null : await
|
|
3607
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
2866
3608
|
const fetchOptions = {
|
|
2867
3609
|
method: "POST",
|
|
2868
3610
|
headers: {
|
|
@@ -2876,10 +3618,12 @@ class PostHogCoreStateless {
|
|
|
2876
3618
|
};
|
|
2877
3619
|
try {
|
|
2878
3620
|
await this.fetchWithRetry(url, fetchOptions, {
|
|
3621
|
+
type: "successful-write"
|
|
3622
|
+
}, {
|
|
2879
3623
|
retryCheck: (err) => {
|
|
2880
3624
|
if (isPostHogFetchContentTooLargeError(err))
|
|
2881
3625
|
return false;
|
|
2882
|
-
return
|
|
3626
|
+
return isPostHogFetchRetryableError(err);
|
|
2883
3627
|
}
|
|
2884
3628
|
});
|
|
2885
3629
|
return {
|
|
@@ -2901,41 +3645,155 @@ class PostHogCoreStateless {
|
|
|
2901
3645
|
};
|
|
2902
3646
|
}
|
|
2903
3647
|
}
|
|
2904
|
-
async
|
|
3648
|
+
async _sendMetricsBatch(payload) {
|
|
3649
|
+
if (this.disabled)
|
|
3650
|
+
return {
|
|
3651
|
+
kind: "fatal",
|
|
3652
|
+
error: new Error("The client is disabled")
|
|
3653
|
+
};
|
|
3654
|
+
const serialized = JSON.stringify(payload);
|
|
3655
|
+
const url = `${this.host}/i/v1/metrics?token=${encodeURIComponent(this.apiKey)}`;
|
|
3656
|
+
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
3657
|
+
const fetchOptions = {
|
|
3658
|
+
method: "POST",
|
|
3659
|
+
headers: {
|
|
3660
|
+
...this.getCustomHeaders(),
|
|
3661
|
+
"Content-Type": "application/json",
|
|
3662
|
+
...gzippedPayload !== null && {
|
|
3663
|
+
"Content-Encoding": "gzip"
|
|
3664
|
+
}
|
|
3665
|
+
},
|
|
3666
|
+
body: gzippedPayload || serialized
|
|
3667
|
+
};
|
|
3668
|
+
try {
|
|
3669
|
+
await this.fetchWithRetry(url, fetchOptions, {
|
|
3670
|
+
type: "successful-write"
|
|
3671
|
+
}, {
|
|
3672
|
+
retryCheck: (err) => {
|
|
3673
|
+
if (isPostHogFetchContentTooLargeError(err))
|
|
3674
|
+
return false;
|
|
3675
|
+
return isPostHogFetchRetryableError(err);
|
|
3676
|
+
}
|
|
3677
|
+
});
|
|
3678
|
+
return {
|
|
3679
|
+
kind: "ok"
|
|
3680
|
+
};
|
|
3681
|
+
} catch (err) {
|
|
3682
|
+
if (isPostHogFetchContentTooLargeError(err))
|
|
3683
|
+
return {
|
|
3684
|
+
kind: "too-large"
|
|
3685
|
+
};
|
|
3686
|
+
if (isPostHogFetchRetryableError(err))
|
|
3687
|
+
return {
|
|
3688
|
+
kind: "retry-later",
|
|
3689
|
+
error: err
|
|
3690
|
+
};
|
|
3691
|
+
return {
|
|
3692
|
+
kind: "fatal",
|
|
3693
|
+
error: err
|
|
3694
|
+
};
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
async fetchWithRetry(url, options, responseHandling, retryOptions, requestTimeout) {
|
|
2905
3698
|
const body = options.body ? options.body : "";
|
|
2906
3699
|
let reqByteLength = -1;
|
|
2907
3700
|
try {
|
|
2908
|
-
reqByteLength = body instanceof Blob ? body.size : Buffer.byteLength(body, STRING_FORMAT);
|
|
3701
|
+
reqByteLength = body instanceof Blob ? body.size : body instanceof Uint8Array ? body.byteLength : Buffer.byteLength(body, STRING_FORMAT);
|
|
2909
3702
|
} catch {
|
|
2910
3703
|
if (body instanceof Blob)
|
|
2911
3704
|
reqByteLength = body.size;
|
|
3705
|
+
else if (body instanceof Uint8Array)
|
|
3706
|
+
reqByteLength = body.byteLength;
|
|
2912
3707
|
else {
|
|
2913
3708
|
const encoded = new TextEncoder().encode(body);
|
|
2914
3709
|
reqByteLength = encoded.length;
|
|
2915
3710
|
}
|
|
2916
3711
|
}
|
|
3712
|
+
const retriableOptions = {
|
|
3713
|
+
...this._retryOptions,
|
|
3714
|
+
...retryOptions
|
|
3715
|
+
};
|
|
3716
|
+
let attempt = 0;
|
|
2917
3717
|
return await retriable(async () => {
|
|
3718
|
+
attempt++;
|
|
2918
3719
|
const ctrl = new AbortController;
|
|
2919
3720
|
const timeoutMs = requestTimeout ?? this.requestTimeout;
|
|
2920
|
-
const
|
|
2921
|
-
let
|
|
3721
|
+
const requestDeadline = Date.now() + timeoutMs;
|
|
3722
|
+
let timer;
|
|
3723
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
3724
|
+
timer = safeSetTimeout(() => {
|
|
3725
|
+
const timeoutError = new Error(`Request timed out after ${timeoutMs}ms`);
|
|
3726
|
+
timeoutError.name = "AbortError";
|
|
3727
|
+
reject(timeoutError);
|
|
3728
|
+
ctrl.abort(timeoutError);
|
|
3729
|
+
}, timeoutMs);
|
|
3730
|
+
});
|
|
3731
|
+
let res;
|
|
3732
|
+
let responseAccepted = false;
|
|
3733
|
+
let cancellation;
|
|
3734
|
+
const cancelBody = () => cancellation ??= (async () => {
|
|
3735
|
+
try {
|
|
3736
|
+
await res?.body?.cancel();
|
|
3737
|
+
} catch {}
|
|
3738
|
+
})();
|
|
2922
3739
|
try {
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
3740
|
+
let fetchPromise;
|
|
3741
|
+
try {
|
|
3742
|
+
fetchPromise = this.fetch(url, {
|
|
3743
|
+
signal: ctrl.signal,
|
|
3744
|
+
...options
|
|
3745
|
+
});
|
|
3746
|
+
} catch (e) {
|
|
3747
|
+
throw new PostHogFetchNetworkError(e);
|
|
3748
|
+
}
|
|
3749
|
+
fetchPromise.then((lateResponse) => {
|
|
3750
|
+
if (ctrl.signal.aborted && !responseAccepted)
|
|
3751
|
+
Promise.resolve(lateResponse.body?.cancel()).catch(() => {});
|
|
3752
|
+
}).catch(() => {});
|
|
3753
|
+
try {
|
|
3754
|
+
res = await Promise.race([
|
|
3755
|
+
fetchPromise,
|
|
3756
|
+
deadline
|
|
3757
|
+
]);
|
|
3758
|
+
responseAccepted = true;
|
|
3759
|
+
} catch (e) {
|
|
3760
|
+
throw new PostHogFetchNetworkError(e);
|
|
3761
|
+
}
|
|
3762
|
+
const isNoCors = options.mode === "no-cors";
|
|
3763
|
+
if (!isNoCors && (res.status < 200 || res.status >= 400))
|
|
3764
|
+
throw new PostHogFetchHttpError(res, reqByteLength, requestDeadline, ctrl);
|
|
3765
|
+
if (responseHandling.type === "successful-write") {
|
|
3766
|
+
try {
|
|
3767
|
+
await Promise.race([
|
|
3768
|
+
cancelBody(),
|
|
3769
|
+
deadline
|
|
3770
|
+
]);
|
|
3771
|
+
} catch {}
|
|
3772
|
+
return;
|
|
3773
|
+
}
|
|
3774
|
+
try {
|
|
3775
|
+
return await Promise.race([
|
|
3776
|
+
responseHandling.consume(res),
|
|
3777
|
+
deadline
|
|
3778
|
+
]);
|
|
3779
|
+
} catch (e) {
|
|
3780
|
+
if (ctrl.signal.aborted)
|
|
3781
|
+
throw new PostHogFetchNetworkError(e);
|
|
3782
|
+
throw e;
|
|
3783
|
+
}
|
|
2929
3784
|
} finally {
|
|
2930
3785
|
clearTimeout(timer);
|
|
3786
|
+
if (ctrl.signal.aborted && res)
|
|
3787
|
+
cancelBody();
|
|
2931
3788
|
}
|
|
2932
|
-
const isNoCors = options.mode === "no-cors";
|
|
2933
|
-
if (!isNoCors && (res.status < 200 || res.status >= 400))
|
|
2934
|
-
throw new PostHogFetchHttpError(res, reqByteLength);
|
|
2935
|
-
return res;
|
|
2936
3789
|
}, {
|
|
2937
|
-
...
|
|
2938
|
-
|
|
3790
|
+
...retriableOptions,
|
|
3791
|
+
retryCheck: (error) => {
|
|
3792
|
+
const shouldRetry = retriableOptions.retryCheck(error);
|
|
3793
|
+
if (shouldRetry && attempt <= retriableOptions.retryCount && error instanceof PostHogFetchHttpError)
|
|
3794
|
+
error.cancelResponseBody();
|
|
3795
|
+
return shouldRetry;
|
|
3796
|
+
}
|
|
2939
3797
|
});
|
|
2940
3798
|
}
|
|
2941
3799
|
async _shutdown(shutdownTimeoutMs = 30000) {
|
|
@@ -2948,12 +3806,17 @@ class PostHogCoreStateless {
|
|
|
2948
3806
|
try {
|
|
2949
3807
|
await this.promiseQueue.join();
|
|
2950
3808
|
while (true) {
|
|
2951
|
-
const
|
|
2952
|
-
if (
|
|
3809
|
+
const hasQueuedEvents = this.getActiveQueueRoutes().some((route) => this.getRouteQueue(route).length > 0);
|
|
3810
|
+
if (!hasQueuedEvents)
|
|
2953
3811
|
break;
|
|
3812
|
+
const dequeuedBeforeFlush = this._dequeuedMessagesCount;
|
|
2954
3813
|
await this.flush();
|
|
2955
3814
|
if (hasTimedOut)
|
|
2956
3815
|
break;
|
|
3816
|
+
if (this._dequeuedMessagesCount === dequeuedBeforeFlush) {
|
|
3817
|
+
this._logger.warn("Shutdown flush completed but did not send any queued events. Stopping drain to avoid a loop.");
|
|
3818
|
+
break;
|
|
3819
|
+
}
|
|
2957
3820
|
}
|
|
2958
3821
|
} catch (e) {
|
|
2959
3822
|
if (!isPostHogFetchError(e))
|
|
@@ -2961,21 +3824,12 @@ class PostHogCoreStateless {
|
|
|
2961
3824
|
await logFlushError(e);
|
|
2962
3825
|
}
|
|
2963
3826
|
};
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
hasTimedOut = true;
|
|
2971
|
-
reject("Timeout while shutting down PostHog. Some events may not have been sent.");
|
|
2972
|
-
}, shutdownTimeoutMs);
|
|
2973
|
-
}),
|
|
2974
|
-
doShutdown()
|
|
2975
|
-
]);
|
|
2976
|
-
} finally {
|
|
2977
|
-
clearTimeout(timeoutHandle);
|
|
2978
|
-
}
|
|
3827
|
+
return raceWithTimeout(doShutdown(), shutdownTimeoutMs, () => {
|
|
3828
|
+
this._logger.critical("Timeout while shutting down PostHog. Some events may not have been sent.", {
|
|
3829
|
+
shutdownTimeoutMs
|
|
3830
|
+
});
|
|
3831
|
+
hasTimedOut = true;
|
|
3832
|
+
});
|
|
2979
3833
|
}
|
|
2980
3834
|
async shutdown(shutdownTimeoutMs = 30000) {
|
|
2981
3835
|
if (this.shutdownPromise)
|
|
@@ -2987,21 +3841,30 @@ class PostHogCoreStateless {
|
|
|
2987
3841
|
return this.shutdownPromise;
|
|
2988
3842
|
}
|
|
2989
3843
|
}
|
|
2990
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
2991
|
-
import {
|
|
3844
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
|
|
3845
|
+
import { constants as constants2 } from "node:fs";
|
|
3846
|
+
import { open as promises_open } from "node:fs/promises";
|
|
3847
|
+
import { isAbsolute } from "node:path";
|
|
2992
3848
|
import { createInterface } from "node:readline";
|
|
2993
|
-
var LRU_FILE_CONTENTS_CACHE = new
|
|
2994
|
-
var LRU_FILE_CONTENTS_FS_READ_FAILED = new
|
|
3849
|
+
var LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
|
|
3850
|
+
var LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
|
|
2995
3851
|
var DEFAULT_LINES_OF_CONTEXT = 7;
|
|
2996
3852
|
var MAX_CONTEXTLINES_COLNO = 1000;
|
|
2997
3853
|
var MAX_CONTEXTLINES_LINENO = 1e4;
|
|
2998
|
-
|
|
3854
|
+
var MAX_CONTEXTLINES_FILE_SIZE = 10485760;
|
|
3855
|
+
async function addSourceContext(frames, openSourceFile = promises_open, logger) {
|
|
2999
3856
|
const filesToLines = {};
|
|
3857
|
+
let basePath;
|
|
3858
|
+
try {
|
|
3859
|
+
basePath = process.cwd();
|
|
3860
|
+
} catch {}
|
|
3000
3861
|
for (let i = frames.length - 1;i >= 0; i--) {
|
|
3001
3862
|
const frame = frames[i];
|
|
3002
3863
|
const filename = frame?.filename;
|
|
3003
3864
|
if (!frame || typeof filename != "string" || typeof frame.lineno != "number" || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame))
|
|
3004
3865
|
continue;
|
|
3866
|
+
if (!isAbsolute(filename) && basePath === undefined)
|
|
3867
|
+
continue;
|
|
3005
3868
|
const filesToLinesOutput = filesToLines[filename];
|
|
3006
3869
|
if (!filesToLinesOutput)
|
|
3007
3870
|
filesToLines[filename] = [];
|
|
@@ -3012,50 +3875,98 @@ async function addSourceContext(frames) {
|
|
|
3012
3875
|
return frames;
|
|
3013
3876
|
const readlinePromises = [];
|
|
3014
3877
|
for (const file of files) {
|
|
3015
|
-
|
|
3878
|
+
const cacheKey = makeSourceCacheKey(file, basePath);
|
|
3879
|
+
if (cacheKey === undefined)
|
|
3880
|
+
continue;
|
|
3881
|
+
if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(cacheKey))
|
|
3016
3882
|
continue;
|
|
3017
3883
|
const filesToLineRanges = filesToLines[file];
|
|
3018
3884
|
if (!filesToLineRanges)
|
|
3019
3885
|
continue;
|
|
3020
3886
|
filesToLineRanges.sort((a, b) => a - b);
|
|
3021
3887
|
const ranges = makeLineReaderRanges(filesToLineRanges);
|
|
3022
|
-
if (ranges.every((r) => rangeExistsInContentCache(
|
|
3888
|
+
if (ranges.every((r) => rangeExistsInContentCache(cacheKey, r)))
|
|
3023
3889
|
continue;
|
|
3024
|
-
const cache = emplace(LRU_FILE_CONTENTS_CACHE,
|
|
3025
|
-
readlinePromises.push(getContextLinesFromFile(file, ranges, cache));
|
|
3890
|
+
const cache = emplace(LRU_FILE_CONTENTS_CACHE, cacheKey, {});
|
|
3891
|
+
readlinePromises.push(getContextLinesFromFile(file, ranges, cache, cacheKey, openSourceFile, logger));
|
|
3026
3892
|
}
|
|
3027
3893
|
await Promise.all(readlinePromises).catch(() => {});
|
|
3028
3894
|
if (frames && frames.length > 0)
|
|
3029
|
-
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
|
|
3895
|
+
addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE, basePath);
|
|
3030
3896
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
3031
3897
|
return frames;
|
|
3032
3898
|
}
|
|
3033
|
-
function
|
|
3899
|
+
async function openRegularSourceFile(path, openSourceFile, logger) {
|
|
3900
|
+
let fileHandle;
|
|
3901
|
+
let isValid = false;
|
|
3902
|
+
try {
|
|
3903
|
+
fileHandle = await openSourceFile(path, constants2.O_RDONLY | constants2.O_NONBLOCK);
|
|
3904
|
+
const fileStat = await fileHandle.stat();
|
|
3905
|
+
if (!fileStat.isFile())
|
|
3906
|
+
return;
|
|
3907
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE)
|
|
3908
|
+
return void logger?.debug(`Skipping source context for oversized file ${path}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
3909
|
+
isValid = true;
|
|
3910
|
+
return fileHandle;
|
|
3911
|
+
} catch {
|
|
3912
|
+
return;
|
|
3913
|
+
} finally {
|
|
3914
|
+
if (fileHandle && !isValid)
|
|
3915
|
+
await fileHandle.close().catch(() => {});
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
async function getContextLinesFromFile(path, ranges, output, cacheKey, openSourceFile, logger) {
|
|
3919
|
+
const fileHandle = await openRegularSourceFile(path, openSourceFile, logger);
|
|
3920
|
+
if (fileHandle === undefined)
|
|
3921
|
+
return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3922
|
+
const openedFileHandle = fileHandle;
|
|
3034
3923
|
return new Promise((resolve) => {
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
stream
|
|
3041
|
-
|
|
3924
|
+
let finished = false;
|
|
3925
|
+
function destroyStreamAndResolve(stream) {
|
|
3926
|
+
if (finished)
|
|
3927
|
+
return;
|
|
3928
|
+
finished = true;
|
|
3929
|
+
stream?.destroy();
|
|
3930
|
+
openedFileHandle.close().then(resolve, resolve);
|
|
3931
|
+
}
|
|
3932
|
+
let stream;
|
|
3933
|
+
try {
|
|
3934
|
+
stream = openedFileHandle.createReadStream({
|
|
3935
|
+
autoClose: false,
|
|
3936
|
+
start: 0,
|
|
3937
|
+
end: MAX_CONTEXTLINES_FILE_SIZE - 1
|
|
3938
|
+
});
|
|
3939
|
+
} catch {
|
|
3940
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3941
|
+
destroyStreamAndResolve();
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
let lineReaded;
|
|
3945
|
+
try {
|
|
3946
|
+
lineReaded = createInterface({
|
|
3947
|
+
input: stream
|
|
3948
|
+
});
|
|
3949
|
+
} catch {
|
|
3950
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3951
|
+
destroyStreamAndResolve(stream);
|
|
3952
|
+
return;
|
|
3042
3953
|
}
|
|
3043
3954
|
let lineNumber = 0;
|
|
3044
3955
|
let currentRangeIndex = 0;
|
|
3045
3956
|
const range = ranges[currentRangeIndex];
|
|
3046
3957
|
if (range === undefined)
|
|
3047
|
-
return void destroyStreamAndResolve();
|
|
3958
|
+
return void destroyStreamAndResolve(stream);
|
|
3048
3959
|
let rangeStart = range[0];
|
|
3049
3960
|
let rangeEnd = range[1];
|
|
3050
3961
|
function onStreamError() {
|
|
3051
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
3962
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
3052
3963
|
lineReaded.close();
|
|
3053
3964
|
lineReaded.removeAllListeners();
|
|
3054
|
-
destroyStreamAndResolve();
|
|
3965
|
+
destroyStreamAndResolve(stream);
|
|
3055
3966
|
}
|
|
3056
3967
|
stream.on("error", onStreamError);
|
|
3057
3968
|
lineReaded.on("error", onStreamError);
|
|
3058
|
-
lineReaded.on("close", destroyStreamAndResolve);
|
|
3969
|
+
lineReaded.on("close", () => destroyStreamAndResolve(stream));
|
|
3059
3970
|
lineReaded.on("line", (line) => {
|
|
3060
3971
|
lineNumber++;
|
|
3061
3972
|
if (lineNumber < rangeStart)
|
|
@@ -3068,22 +3979,23 @@ function getContextLinesFromFile(path2, ranges, output) {
|
|
|
3068
3979
|
return;
|
|
3069
3980
|
}
|
|
3070
3981
|
currentRangeIndex++;
|
|
3071
|
-
const
|
|
3072
|
-
if (
|
|
3982
|
+
const range = ranges[currentRangeIndex];
|
|
3983
|
+
if (range === undefined) {
|
|
3073
3984
|
lineReaded.close();
|
|
3074
3985
|
lineReaded.removeAllListeners();
|
|
3075
3986
|
return;
|
|
3076
3987
|
}
|
|
3077
|
-
rangeStart =
|
|
3078
|
-
rangeEnd =
|
|
3988
|
+
rangeStart = range[0];
|
|
3989
|
+
rangeEnd = range[1];
|
|
3079
3990
|
}
|
|
3080
3991
|
});
|
|
3081
3992
|
});
|
|
3082
3993
|
}
|
|
3083
|
-
function addSourceContextToFrames(frames, cache) {
|
|
3994
|
+
function addSourceContextToFrames(frames, cache, basePath) {
|
|
3084
3995
|
for (const frame of frames)
|
|
3085
3996
|
if (frame.filename && frame.context_line === undefined && typeof frame.lineno == "number") {
|
|
3086
|
-
const
|
|
3997
|
+
const cacheKey = makeSourceCacheKey(frame.filename, basePath);
|
|
3998
|
+
const contents = cacheKey === undefined ? undefined : cache.get(cacheKey);
|
|
3087
3999
|
if (contents === undefined)
|
|
3088
4000
|
continue;
|
|
3089
4001
|
addContextToFrame(frame.lineno, frame, contents);
|
|
@@ -3116,8 +4028,8 @@ function clearLineContext(frame) {
|
|
|
3116
4028
|
delete frame.context_line;
|
|
3117
4029
|
delete frame.post_context;
|
|
3118
4030
|
}
|
|
3119
|
-
function shouldSkipContextLinesForFile(
|
|
3120
|
-
return
|
|
4031
|
+
function shouldSkipContextLinesForFile(path) {
|
|
4032
|
+
return path.startsWith("node:") || path.endsWith(".min.js") || path.endsWith(".min.cjs") || path.endsWith(".min.mjs") || path.startsWith("data:");
|
|
3121
4033
|
}
|
|
3122
4034
|
function shouldSkipContextLinesForFrame(frame) {
|
|
3123
4035
|
if (frame.lineno !== undefined && frame.lineno > MAX_CONTEXTLINES_LINENO)
|
|
@@ -3126,8 +4038,19 @@ function shouldSkipContextLinesForFrame(frame) {
|
|
|
3126
4038
|
return true;
|
|
3127
4039
|
return false;
|
|
3128
4040
|
}
|
|
3129
|
-
function
|
|
3130
|
-
|
|
4041
|
+
function makeSourceCacheKey(path, basePath) {
|
|
4042
|
+
if (isAbsolute(path))
|
|
4043
|
+
return JSON.stringify([
|
|
4044
|
+
null,
|
|
4045
|
+
path
|
|
4046
|
+
]);
|
|
4047
|
+
return basePath === undefined ? undefined : JSON.stringify([
|
|
4048
|
+
basePath,
|
|
4049
|
+
path
|
|
4050
|
+
]);
|
|
4051
|
+
}
|
|
4052
|
+
function rangeExistsInContentCache(cacheKey, range) {
|
|
4053
|
+
const contents = LRU_FILE_CONTENTS_CACHE.get(cacheKey);
|
|
3131
4054
|
if (contents === undefined)
|
|
3132
4055
|
return false;
|
|
3133
4056
|
for (let i = range[0];i <= range[1]; i++)
|
|
@@ -3205,8 +4128,8 @@ function snipLine(line, colno) {
|
|
|
3205
4128
|
return newLine;
|
|
3206
4129
|
}
|
|
3207
4130
|
|
|
3208
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
3209
|
-
import { isAbsolute, relative, sep as sep2 } from "path";
|
|
4131
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
|
|
4132
|
+
import { isAbsolute as isAbsolute2, relative, sep as sep2 } from "path";
|
|
3210
4133
|
function createRelativePathModifier(basePath = process.cwd()) {
|
|
3211
4134
|
const isWindows = sep2 === "\\";
|
|
3212
4135
|
const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
|
|
@@ -3214,17 +4137,17 @@ function createRelativePathModifier(basePath = process.cwd()) {
|
|
|
3214
4137
|
return async (frames) => {
|
|
3215
4138
|
for (const frame of frames)
|
|
3216
4139
|
if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
|
|
3217
|
-
if (
|
|
4140
|
+
if (isAbsolute2(frame.filename))
|
|
3218
4141
|
frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
|
|
3219
4142
|
}
|
|
3220
4143
|
return frames;
|
|
3221
4144
|
};
|
|
3222
4145
|
}
|
|
3223
4146
|
|
|
3224
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
3225
|
-
var version = "5.
|
|
4147
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/version.mjs
|
|
4148
|
+
var version = "5.51.1";
|
|
3226
4149
|
|
|
3227
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
4150
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/types.mjs
|
|
3228
4151
|
var FeatureFlagError2 = {
|
|
3229
4152
|
ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
|
|
3230
4153
|
FLAG_MISSING: "flag_missing",
|
|
@@ -3232,7 +4155,7 @@ var FeatureFlagError2 = {
|
|
|
3232
4155
|
UNKNOWN_ERROR: "unknown_error"
|
|
3233
4156
|
};
|
|
3234
4157
|
|
|
3235
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
4158
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
|
|
3236
4159
|
class FeatureFlagEvaluations {
|
|
3237
4160
|
constructor(init) {
|
|
3238
4161
|
this._host = init.host;
|
|
@@ -3248,10 +4171,10 @@ class FeatureFlagEvaluations {
|
|
|
3248
4171
|
this._accessed = init.accessed ?? new Set;
|
|
3249
4172
|
this._isSlice = init.isSlice ?? false;
|
|
3250
4173
|
}
|
|
3251
|
-
isEnabled(key) {
|
|
4174
|
+
isEnabled(key, options = {}) {
|
|
3252
4175
|
const flag = this._flags[key];
|
|
3253
4176
|
this._recordAccess(key);
|
|
3254
|
-
return flag?.enabled ?? false;
|
|
4177
|
+
return flag?.enabled ?? options.defaultValue ?? false;
|
|
3255
4178
|
}
|
|
3256
4179
|
getFlag(key) {
|
|
3257
4180
|
const flag = this._flags[key];
|
|
@@ -3341,6 +4264,8 @@ class FeatureFlagEvaluations {
|
|
|
3341
4264
|
$feature_flag_request_id: this._requestId,
|
|
3342
4265
|
$feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt
|
|
3343
4266
|
};
|
|
4267
|
+
if (flag?.hasExperiment !== undefined)
|
|
4268
|
+
properties.$feature_flag_has_experiment = flag.hasExperiment;
|
|
3344
4269
|
if (flag?.locallyEvaluated && this._flagDefinitionsLoadedAt !== undefined)
|
|
3345
4270
|
properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt;
|
|
3346
4271
|
const errors = [];
|
|
@@ -3363,7 +4288,7 @@ class FeatureFlagEvaluations {
|
|
|
3363
4288
|
}
|
|
3364
4289
|
}
|
|
3365
4290
|
|
|
3366
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
4291
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
|
|
3367
4292
|
async function hashSHA1(text) {
|
|
3368
4293
|
const subtle = globalThis.crypto?.subtle;
|
|
3369
4294
|
if (!subtle)
|
|
@@ -3373,7 +4298,7 @@ async function hashSHA1(text) {
|
|
|
3373
4298
|
return hashArray.map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3374
4299
|
}
|
|
3375
4300
|
|
|
3376
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
4301
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
|
|
3377
4302
|
var SIXTY_SECONDS = 60000;
|
|
3378
4303
|
var LONG_SCALE = 1152921504606847000;
|
|
3379
4304
|
var NULL_VALUES_ALLOWED_OPERATORS = [
|
|
@@ -3390,22 +4315,23 @@ class ClientError extends Error {
|
|
|
3390
4315
|
Object.setPrototypeOf(this, ClientError.prototype);
|
|
3391
4316
|
}
|
|
3392
4317
|
}
|
|
4318
|
+
function setCustomErrorPrototype(error, constructor) {
|
|
4319
|
+
error.name = constructor.name;
|
|
4320
|
+
Error.captureStackTrace(error, constructor);
|
|
4321
|
+
Object.setPrototypeOf(error, constructor.prototype);
|
|
4322
|
+
}
|
|
3393
4323
|
|
|
3394
4324
|
class InconclusiveMatchError extends Error {
|
|
3395
4325
|
constructor(message) {
|
|
3396
4326
|
super(message);
|
|
3397
|
-
this
|
|
3398
|
-
Error.captureStackTrace(this, this.constructor);
|
|
3399
|
-
Object.setPrototypeOf(this, InconclusiveMatchError.prototype);
|
|
4327
|
+
setCustomErrorPrototype(this, InconclusiveMatchError);
|
|
3400
4328
|
}
|
|
3401
4329
|
}
|
|
3402
4330
|
|
|
3403
4331
|
class RequiresServerEvaluation extends Error {
|
|
3404
4332
|
constructor(message) {
|
|
3405
4333
|
super(message);
|
|
3406
|
-
this
|
|
3407
|
-
Error.captureStackTrace(this, this.constructor);
|
|
3408
|
-
Object.setPrototypeOf(this, RequiresServerEvaluation.prototype);
|
|
4334
|
+
setCustomErrorPrototype(this, RequiresServerEvaluation);
|
|
3409
4335
|
}
|
|
3410
4336
|
}
|
|
3411
4337
|
|
|
@@ -3414,6 +4340,7 @@ class FeatureFlagsPoller {
|
|
|
3414
4340
|
this.debugMode = false;
|
|
3415
4341
|
this.shouldBeginExponentialBackoff = false;
|
|
3416
4342
|
this.backOffCount = 0;
|
|
4343
|
+
this.pollerStopped = false;
|
|
3417
4344
|
this.pollingInterval = pollingInterval;
|
|
3418
4345
|
this.personalApiKey = personalApiKey;
|
|
3419
4346
|
this.featureFlags = [];
|
|
@@ -3429,6 +4356,7 @@ class FeatureFlagsPoller {
|
|
|
3429
4356
|
this.onError = options.onError;
|
|
3430
4357
|
this.customHeaders = customHeaders;
|
|
3431
4358
|
this.onLoad = options.onLoad;
|
|
4359
|
+
this.onMinimalFlagCalledEvents = options.onMinimalFlagCalledEvents;
|
|
3432
4360
|
this.cacheProvider = options.cacheProvider;
|
|
3433
4361
|
this.strictLocalEvaluation = options.strictLocalEvaluation ?? false;
|
|
3434
4362
|
this.loadFeatureFlags();
|
|
@@ -3626,6 +4554,7 @@ class FeatureFlagsPoller {
|
|
|
3626
4554
|
const flagFilters = flag.filters || {};
|
|
3627
4555
|
const flagConditions = flagFilters.groups || [];
|
|
3628
4556
|
const flagAggregation = flagFilters.aggregation_group_type_index;
|
|
4557
|
+
const earlyExitEnabled = flagFilters.early_exit ?? false;
|
|
3629
4558
|
const { groups, groupProperties } = evaluationContext;
|
|
3630
4559
|
let isInconclusive = false;
|
|
3631
4560
|
let result;
|
|
@@ -3649,12 +4578,15 @@ class FeatureFlagsPoller {
|
|
|
3649
4578
|
effectiveBucketingValue = groups[groupName];
|
|
3650
4579
|
}
|
|
3651
4580
|
}
|
|
3652
|
-
|
|
4581
|
+
const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
|
|
4582
|
+
if (matchResult === "match") {
|
|
3653
4583
|
const variantOverride = condition.variant;
|
|
3654
4584
|
const flagVariants = flagFilters.multivariate?.variants || [];
|
|
3655
4585
|
result = variantOverride && flagVariants.some((variant) => variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
|
|
3656
4586
|
break;
|
|
3657
4587
|
}
|
|
4588
|
+
if (earlyExitEnabled && matchResult === "out_of_rollout_bound")
|
|
4589
|
+
return false;
|
|
3658
4590
|
} catch (e) {
|
|
3659
4591
|
if (e instanceof RequiresServerEvaluation)
|
|
3660
4592
|
throw e;
|
|
@@ -3678,16 +4610,20 @@ class FeatureFlagsPoller {
|
|
|
3678
4610
|
for (const prop of condition.properties) {
|
|
3679
4611
|
const propertyType = prop.type;
|
|
3680
4612
|
let matches = false;
|
|
3681
|
-
|
|
4613
|
+
if (propertyType === "cohort") {
|
|
4614
|
+
const inCohort = await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext));
|
|
4615
|
+
matches = prop.operator === "not_in" ? !inCohort : inCohort;
|
|
4616
|
+
} else
|
|
4617
|
+
matches = propertyType === "flag" ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
|
|
3682
4618
|
if (!matches)
|
|
3683
|
-
return
|
|
4619
|
+
return "no_match";
|
|
3684
4620
|
}
|
|
3685
4621
|
if (rolloutPercentage == undefined)
|
|
3686
|
-
return
|
|
4622
|
+
return "match";
|
|
3687
4623
|
}
|
|
3688
4624
|
if (rolloutPercentage != null && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100)
|
|
3689
|
-
return
|
|
3690
|
-
return
|
|
4625
|
+
return "out_of_rollout_bound";
|
|
4626
|
+
return "match";
|
|
3691
4627
|
}
|
|
3692
4628
|
async getMatchingVariant(flag, bucketingValue) {
|
|
3693
4629
|
const hashValue = await _hash(flag.key, bucketingValue, "variant");
|
|
@@ -3718,6 +4654,7 @@ class FeatureFlagsPoller {
|
|
|
3718
4654
|
this.groupTypeMapping = flagData.groupTypeMapping;
|
|
3719
4655
|
this.cohorts = flagData.cohorts;
|
|
3720
4656
|
this.loadedSuccessfullyOnce = true;
|
|
4657
|
+
this.onMinimalFlagCalledEvents?.(flagData.minimalFlagCalledEvents === true);
|
|
3721
4658
|
}
|
|
3722
4659
|
warnAboutExperienceContinuityFlags(flags) {
|
|
3723
4660
|
if (this.strictLocalEvaluation)
|
|
@@ -3781,7 +4718,6 @@ class FeatureFlagsPoller {
|
|
|
3781
4718
|
clearTimeout(this.poller);
|
|
3782
4719
|
this.poller = undefined;
|
|
3783
4720
|
}
|
|
3784
|
-
this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
|
|
3785
4721
|
try {
|
|
3786
4722
|
let shouldFetch = true;
|
|
3787
4723
|
if (this.cacheProvider)
|
|
@@ -3809,17 +4745,18 @@ class FeatureFlagsPoller {
|
|
|
3809
4745
|
return;
|
|
3810
4746
|
case 401:
|
|
3811
4747
|
this.beginBackoff();
|
|
3812
|
-
throw new ClientError(`Your project key or
|
|
4748
|
+
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`);
|
|
3813
4749
|
case 402:
|
|
3814
4750
|
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");
|
|
3815
4751
|
this.featureFlags = [];
|
|
3816
4752
|
this.featureFlagsByKey = {};
|
|
3817
4753
|
this.groupTypeMapping = {};
|
|
3818
4754
|
this.cohorts = {};
|
|
4755
|
+
this.onMinimalFlagCalledEvents?.(false);
|
|
3819
4756
|
return;
|
|
3820
4757
|
case 403:
|
|
3821
4758
|
this.beginBackoff();
|
|
3822
|
-
throw new ClientError(`Your
|
|
4759
|
+
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`);
|
|
3823
4760
|
case 429:
|
|
3824
4761
|
this.beginBackoff();
|
|
3825
4762
|
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`);
|
|
@@ -3831,7 +4768,8 @@ class FeatureFlagsPoller {
|
|
|
3831
4768
|
const flagData = {
|
|
3832
4769
|
flags: responseJson.flags ?? [],
|
|
3833
4770
|
groupTypeMapping: responseJson.group_type_mapping || {},
|
|
3834
|
-
cohorts: responseJson.cohorts || {}
|
|
4771
|
+
cohorts: responseJson.cohorts || {},
|
|
4772
|
+
minimalFlagCalledEvents: responseJson.minimal_flag_called_events === true
|
|
3835
4773
|
};
|
|
3836
4774
|
this.updateFlagState(flagData);
|
|
3837
4775
|
this.flagDefinitionsLoadedAt = Date.now();
|
|
@@ -3852,6 +4790,9 @@ class FeatureFlagsPoller {
|
|
|
3852
4790
|
} catch (err) {
|
|
3853
4791
|
if (err instanceof ClientError)
|
|
3854
4792
|
this.onError?.(err);
|
|
4793
|
+
} finally {
|
|
4794
|
+
if (!this.pollerStopped)
|
|
4795
|
+
this.poller = setTimeout(() => this.loadFeatureFlags(true), this.getPollingInterval());
|
|
3855
4796
|
}
|
|
3856
4797
|
}
|
|
3857
4798
|
getPersonalApiKeyRequestOptions(method = "GET", etag) {
|
|
@@ -3867,7 +4808,7 @@ class FeatureFlagsPoller {
|
|
|
3867
4808
|
headers
|
|
3868
4809
|
};
|
|
3869
4810
|
}
|
|
3870
|
-
_requestFeatureFlagDefinitions() {
|
|
4811
|
+
async _requestFeatureFlagDefinitions() {
|
|
3871
4812
|
const url = `${this.host}/flags/definitions?token=${this.projectApiKey}&send_cohorts`;
|
|
3872
4813
|
const options = this.getPersonalApiKeyRequestOptions("GET", this.flagsEtag);
|
|
3873
4814
|
let abortTimeout = null;
|
|
@@ -3878,23 +4819,49 @@ class FeatureFlagsPoller {
|
|
|
3878
4819
|
}, this.timeout);
|
|
3879
4820
|
options.signal = controller.signal;
|
|
3880
4821
|
}
|
|
4822
|
+
const clearAbortTimeout = () => clearTimeout(abortTimeout);
|
|
3881
4823
|
try {
|
|
3882
4824
|
const fetch1 = this.fetch;
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
4825
|
+
const res = await fetch1(url, options);
|
|
4826
|
+
if (res.status !== 200) {
|
|
4827
|
+
clearAbortTimeout();
|
|
4828
|
+
return res;
|
|
4829
|
+
}
|
|
4830
|
+
return {
|
|
4831
|
+
status: res.status,
|
|
4832
|
+
headers: res.headers,
|
|
4833
|
+
body: res.body,
|
|
4834
|
+
text: async () => {
|
|
4835
|
+
try {
|
|
4836
|
+
return await res.text();
|
|
4837
|
+
} finally {
|
|
4838
|
+
clearAbortTimeout();
|
|
4839
|
+
}
|
|
4840
|
+
},
|
|
4841
|
+
json: async () => {
|
|
4842
|
+
try {
|
|
4843
|
+
return await res.json();
|
|
4844
|
+
} finally {
|
|
4845
|
+
clearAbortTimeout();
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
};
|
|
4849
|
+
} catch (err) {
|
|
4850
|
+
clearAbortTimeout();
|
|
4851
|
+
throw err;
|
|
3886
4852
|
}
|
|
3887
4853
|
}
|
|
3888
4854
|
async stopPoller(timeoutMs = 30000) {
|
|
4855
|
+
this.pollerStopped = true;
|
|
3889
4856
|
clearTimeout(this.poller);
|
|
4857
|
+
this.poller = undefined;
|
|
3890
4858
|
if (this.cacheProvider)
|
|
3891
4859
|
try {
|
|
3892
4860
|
const shutdownResult = this.cacheProvider.shutdown();
|
|
3893
4861
|
if (shutdownResult instanceof Promise)
|
|
3894
|
-
await
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
]);
|
|
4862
|
+
await raceWithTimeout(shutdownResult, timeoutMs, () => {
|
|
4863
|
+
throw new Error(`Cache shutdown timeout after ${timeoutMs}ms`);
|
|
4864
|
+
});
|
|
3898
4865
|
} catch (err) {
|
|
3899
4866
|
this.onError?.(new Error(`Error during cache shutdown: ${err}`));
|
|
3900
4867
|
}
|
|
@@ -3922,21 +4889,21 @@ function matchProperty(property, propertyValues, warnFunction) {
|
|
|
3922
4889
|
warnFunction(`Property ${key} cannot have a value of null/undefined with the ${operator} operator`);
|
|
3923
4890
|
return false;
|
|
3924
4891
|
}
|
|
3925
|
-
function computeExactMatch(
|
|
3926
|
-
if (Array.isArray(
|
|
3927
|
-
return
|
|
3928
|
-
return String(
|
|
4892
|
+
function computeExactMatch(value, overrideValue) {
|
|
4893
|
+
if (Array.isArray(value))
|
|
4894
|
+
return value.map((val) => String(val).toLowerCase()).includes(String(overrideValue).toLowerCase());
|
|
4895
|
+
return String(value).toLowerCase() === String(overrideValue).toLowerCase();
|
|
3929
4896
|
}
|
|
3930
|
-
function compare(lhs, rhs,
|
|
3931
|
-
if (
|
|
4897
|
+
function compare(lhs, rhs, operator) {
|
|
4898
|
+
if (operator === "gt")
|
|
3932
4899
|
return lhs > rhs;
|
|
3933
|
-
if (
|
|
4900
|
+
if (operator === "gte")
|
|
3934
4901
|
return lhs >= rhs;
|
|
3935
|
-
if (
|
|
4902
|
+
if (operator === "lt")
|
|
3936
4903
|
return lhs < rhs;
|
|
3937
|
-
if (
|
|
4904
|
+
if (operator === "lte")
|
|
3938
4905
|
return lhs <= rhs;
|
|
3939
|
-
throw new Error(`Invalid operator: ${
|
|
4906
|
+
throw new Error(`Invalid operator: ${operator}`);
|
|
3940
4907
|
}
|
|
3941
4908
|
switch (operator) {
|
|
3942
4909
|
case "exact":
|
|
@@ -3949,6 +4916,14 @@ function matchProperty(property, propertyValues, warnFunction) {
|
|
|
3949
4916
|
return String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
3950
4917
|
case "not_icontains":
|
|
3951
4918
|
return !String(overrideValue).toLowerCase().includes(String(value).toLowerCase());
|
|
4919
|
+
case "starts_with":
|
|
4920
|
+
return String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
|
|
4921
|
+
case "not_starts_with":
|
|
4922
|
+
return !String(overrideValue).toLowerCase().startsWith(String(value).toLowerCase());
|
|
4923
|
+
case "ends_with":
|
|
4924
|
+
return String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
|
|
4925
|
+
case "not_ends_with":
|
|
4926
|
+
return !String(overrideValue).toLowerCase().endsWith(String(value).toLowerCase());
|
|
3952
4927
|
case "regex":
|
|
3953
4928
|
return isValidRegex(String(value)) && String(overrideValue).match(String(value)) !== null;
|
|
3954
4929
|
case "not_regex":
|
|
@@ -4275,19 +5250,75 @@ function relativeDateParseForFeatureFlagMatching(value) {
|
|
|
4275
5250
|
}
|
|
4276
5251
|
}
|
|
4277
5252
|
|
|
4278
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
5253
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
|
|
5254
|
+
var UNHANDLED_REJECTION_OPTION_NAMES = [
|
|
5255
|
+
"--unhandled-rejections",
|
|
5256
|
+
"--unhandled_rejections"
|
|
5257
|
+
];
|
|
5258
|
+
var UNHANDLED_REJECTION_MODES = new Set([
|
|
5259
|
+
"throw",
|
|
5260
|
+
"strict",
|
|
5261
|
+
"warn",
|
|
5262
|
+
"warn-with-error-code",
|
|
5263
|
+
"none"
|
|
5264
|
+
]);
|
|
5265
|
+
var STARTUP_EXEC_ARGV = [
|
|
5266
|
+
...globalThis.process?.execArgv ?? []
|
|
5267
|
+
];
|
|
5268
|
+
var STARTUP_NODE_OPTIONS = globalThis.process?.env?.NODE_OPTIONS;
|
|
5269
|
+
function splitNodeOptions(nodeOptions) {
|
|
5270
|
+
const args = [];
|
|
5271
|
+
let current = "";
|
|
5272
|
+
let isInString = false;
|
|
5273
|
+
for (let index = 0;index < nodeOptions.length; index++) {
|
|
5274
|
+
const character = nodeOptions[index];
|
|
5275
|
+
if (character === "\\" && isInString && index + 1 < nodeOptions.length)
|
|
5276
|
+
current += nodeOptions[++index];
|
|
5277
|
+
else if (character !== " " || isInString)
|
|
5278
|
+
if (character === '"')
|
|
5279
|
+
isInString = !isInString;
|
|
5280
|
+
else
|
|
5281
|
+
current += character;
|
|
5282
|
+
else if (current) {
|
|
5283
|
+
args.push(current);
|
|
5284
|
+
current = "";
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
if (current)
|
|
5288
|
+
args.push(current);
|
|
5289
|
+
return args;
|
|
5290
|
+
}
|
|
5291
|
+
function findUnhandledRejectionMode(args) {
|
|
5292
|
+
let mode;
|
|
5293
|
+
for (let index = 0;index < args.length; index++) {
|
|
5294
|
+
const argument = args[index];
|
|
5295
|
+
const optionName = UNHANDLED_REJECTION_OPTION_NAMES.find((name) => argument === name || argument.startsWith(`${name}=`));
|
|
5296
|
+
if (!optionName)
|
|
5297
|
+
continue;
|
|
5298
|
+
const value = argument === optionName ? args[++index] : argument.slice(optionName.length + 1);
|
|
5299
|
+
if (UNHANDLED_REJECTION_MODES.has(value))
|
|
5300
|
+
mode = value;
|
|
5301
|
+
}
|
|
5302
|
+
return mode;
|
|
5303
|
+
}
|
|
5304
|
+
function getUnhandledRejectionMode(execArgv = STARTUP_EXEC_ARGV, nodeOptions = STARTUP_NODE_OPTIONS) {
|
|
5305
|
+
return findUnhandledRejectionMode(execArgv) ?? findUnhandledRejectionMode(splitNodeOptions(nodeOptions ?? "")) ?? "throw";
|
|
5306
|
+
}
|
|
5307
|
+
var STARTUP_UNHANDLED_REJECTION_MODE = getUnhandledRejectionMode();
|
|
5308
|
+
function captureUncaughtException(captureFn, error, origin) {
|
|
5309
|
+
captureFn(error, {
|
|
5310
|
+
mechanism: {
|
|
5311
|
+
type: origin === "unhandledRejection" ? "onunhandledrejection" : "onuncaughtexception",
|
|
5312
|
+
handled: false
|
|
5313
|
+
}
|
|
5314
|
+
});
|
|
5315
|
+
}
|
|
4279
5316
|
function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
|
|
4280
5317
|
let calledFatalError = false;
|
|
4281
|
-
return Object.assign((error) => {
|
|
5318
|
+
return Object.assign((error, origin) => {
|
|
4282
5319
|
const userProvidedListenersCount = global.process.listeners("uncaughtException").filter((listener) => listener.name !== "domainUncaughtExceptionClear" && listener._posthogErrorHandler !== true).length;
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
mechanism: {
|
|
4286
|
-
type: "onuncaughtexception",
|
|
4287
|
-
handled: false
|
|
4288
|
-
}
|
|
4289
|
-
});
|
|
4290
|
-
if (!calledFatalError && processWouldExit) {
|
|
5320
|
+
captureUncaughtException(captureFn, error, origin);
|
|
5321
|
+
if (!calledFatalError && userProvidedListenersCount === 0) {
|
|
4291
5322
|
calledFatalError = true;
|
|
4292
5323
|
onFatalFn(error);
|
|
4293
5324
|
}
|
|
@@ -4295,29 +5326,38 @@ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
|
|
|
4295
5326
|
_posthogErrorHandler: true
|
|
4296
5327
|
});
|
|
4297
5328
|
}
|
|
4298
|
-
function addUncaughtExceptionListener(captureFn, onFatalFn) {
|
|
4299
|
-
globalThis.process
|
|
5329
|
+
function addUncaughtExceptionListener(captureFn, onFatalFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
|
|
5330
|
+
const process2 = globalThis.process;
|
|
5331
|
+
if (!process2)
|
|
5332
|
+
return;
|
|
5333
|
+
if (mode === "strict")
|
|
5334
|
+
return void process2.on("uncaughtExceptionMonitor", (error, origin) => captureUncaughtException(captureFn, error, origin));
|
|
5335
|
+
process2.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
|
|
4300
5336
|
}
|
|
4301
|
-
function addUnhandledRejectionListener(captureFn) {
|
|
4302
|
-
globalThis.process
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
5337
|
+
function addUnhandledRejectionListener(captureFn, mode = STARTUP_UNHANDLED_REJECTION_MODE) {
|
|
5338
|
+
const process2 = globalThis.process;
|
|
5339
|
+
if (!process2 || mode === "throw" || mode === "strict" || mode === "warn-with-error-code")
|
|
5340
|
+
return;
|
|
5341
|
+
process2.on("unhandledRejection", (reason) => {
|
|
5342
|
+
captureFn(reason, {
|
|
5343
|
+
mechanism: {
|
|
5344
|
+
type: "onunhandledrejection",
|
|
5345
|
+
handled: false
|
|
5346
|
+
}
|
|
5347
|
+
});
|
|
5348
|
+
});
|
|
4308
5349
|
}
|
|
4309
5350
|
|
|
4310
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
5351
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
|
|
4311
5352
|
var SHUTDOWN_TIMEOUT = 2000;
|
|
4312
5353
|
|
|
4313
|
-
class
|
|
5354
|
+
class error_tracking_ErrorTracking {
|
|
4314
5355
|
constructor(client, options, _logger) {
|
|
4315
5356
|
this.client = client;
|
|
4316
5357
|
this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
|
|
4317
5358
|
this._logger = _logger;
|
|
4318
5359
|
this._rateLimiter = new BucketedRateLimiter({
|
|
4319
|
-
|
|
4320
|
-
bucketSize: 10,
|
|
5360
|
+
...resolveExceptionRateLimiterConfig(options),
|
|
4321
5361
|
refillInterval: 1e4,
|
|
4322
5362
|
_logger: this._logger
|
|
4323
5363
|
});
|
|
@@ -4332,6 +5372,9 @@ class ErrorTracking {
|
|
|
4332
5372
|
};
|
|
4333
5373
|
const exceptionProperties = builder.buildFromUnknown(error, hint);
|
|
4334
5374
|
exceptionProperties.$exception_list = await builder.modifyFrames(exceptionProperties.$exception_list);
|
|
5375
|
+
const injectedReleaseId = getInjectedReleaseId();
|
|
5376
|
+
if (injectedReleaseId)
|
|
5377
|
+
properties.$release_id = injectedReleaseId;
|
|
4335
5378
|
return {
|
|
4336
5379
|
event: "$exception",
|
|
4337
5380
|
distinctId,
|
|
@@ -4350,8 +5393,8 @@ class ErrorTracking {
|
|
|
4350
5393
|
}
|
|
4351
5394
|
onException(exception, hint) {
|
|
4352
5395
|
this.client.addPendingPromise((async () => {
|
|
4353
|
-
if (!
|
|
4354
|
-
const eventMessage = await
|
|
5396
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(exception)) {
|
|
5397
|
+
const eventMessage = await error_tracking_ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
|
|
4355
5398
|
const exceptionProperties = eventMessage.properties;
|
|
4356
5399
|
const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
|
|
4357
5400
|
const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
|
|
@@ -4359,14 +5402,14 @@ class ErrorTracking {
|
|
|
4359
5402
|
return void this._logger.info("Skipping exception capture because of client rate limiting.", {
|
|
4360
5403
|
exception: exceptionType
|
|
4361
5404
|
});
|
|
4362
|
-
return this.client.
|
|
5405
|
+
return this.client._capturePreparedEvent(eventMessage, false);
|
|
4363
5406
|
}
|
|
4364
5407
|
})());
|
|
4365
5408
|
}
|
|
4366
5409
|
async onFatalError(exception) {
|
|
4367
5410
|
console.error(exception);
|
|
4368
5411
|
await this.client.shutdown(SHUTDOWN_TIMEOUT);
|
|
4369
|
-
process.exit(1);
|
|
5412
|
+
globalThis.process.exit(1);
|
|
4370
5413
|
}
|
|
4371
5414
|
isEnabled() {
|
|
4372
5415
|
return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
|
|
@@ -4376,7 +5419,7 @@ class ErrorTracking {
|
|
|
4376
5419
|
}
|
|
4377
5420
|
}
|
|
4378
5421
|
|
|
4379
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
5422
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/storage-memory.mjs
|
|
4380
5423
|
class PostHogMemoryStorage {
|
|
4381
5424
|
getProperty(key) {
|
|
4382
5425
|
return this._memoryStorage[key];
|
|
@@ -4389,7 +5432,452 @@ class PostHogMemoryStorage {
|
|
|
4389
5432
|
}
|
|
4390
5433
|
}
|
|
4391
5434
|
|
|
4392
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
5435
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/config.mjs
|
|
5436
|
+
function isCaptureMode(value) {
|
|
5437
|
+
return value === "v0" || value === "v1";
|
|
5438
|
+
}
|
|
5439
|
+
function resolveCaptureMode() {
|
|
5440
|
+
const envMode = typeof process != "undefined" ? process.env?.POSTHOG_CAPTURE_MODE : undefined;
|
|
5441
|
+
return isCaptureMode(envMode) ? envMode : "v0";
|
|
5442
|
+
}
|
|
5443
|
+
|
|
5444
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/routing.mjs
|
|
5445
|
+
var AI_EVENT_PREFIX = "$ai_";
|
|
5446
|
+
var ANALYTICS_ROUTE = "analytics";
|
|
5447
|
+
var AI_ROUTE = "ai";
|
|
5448
|
+
function isLegacyOnlyEvent(message) {
|
|
5449
|
+
return typeof message.event == "string" && message.event.startsWith(AI_EVENT_PREFIX);
|
|
5450
|
+
}
|
|
5451
|
+
|
|
5452
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/errors.mjs
|
|
5453
|
+
class CaptureV1Error extends Error {
|
|
5454
|
+
constructor({ requestId, drops, retryExhausted, cause }) {
|
|
5455
|
+
super(CaptureV1Error.buildMessage(requestId, drops, retryExhausted, cause)), this.name = "CaptureV1Error";
|
|
5456
|
+
this.requestId = requestId;
|
|
5457
|
+
this.drops = drops;
|
|
5458
|
+
this.retryExhausted = retryExhausted;
|
|
5459
|
+
this.cause = cause;
|
|
5460
|
+
}
|
|
5461
|
+
static buildMessage(requestId, drops, retryExhausted, cause) {
|
|
5462
|
+
let message = `Capture V1 batch ${requestId} did not fully deliver: ${drops.length} dropped, ${retryExhausted.length} undelivered`;
|
|
5463
|
+
if (cause instanceof Error)
|
|
5464
|
+
message += ` (${cause.message})`;
|
|
5465
|
+
return message;
|
|
5466
|
+
}
|
|
5467
|
+
}
|
|
5468
|
+
|
|
5469
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/transform.mjs
|
|
5470
|
+
function coerceBool(value) {
|
|
5471
|
+
if (typeof value == "boolean")
|
|
5472
|
+
return value;
|
|
5473
|
+
if (typeof value == "number")
|
|
5474
|
+
return value !== 0;
|
|
5475
|
+
if (typeof value == "string") {
|
|
5476
|
+
const normalized = value.trim().toLowerCase();
|
|
5477
|
+
if (normalized === "true" || normalized === "1")
|
|
5478
|
+
return true;
|
|
5479
|
+
if (normalized === "false" || normalized === "0")
|
|
5480
|
+
return false;
|
|
5481
|
+
}
|
|
5482
|
+
}
|
|
5483
|
+
function coerceString(value) {
|
|
5484
|
+
return typeof value == "string" ? value : undefined;
|
|
5485
|
+
}
|
|
5486
|
+
var OPTION_SENTINELS = [
|
|
5487
|
+
{
|
|
5488
|
+
property: "$cookieless_mode",
|
|
5489
|
+
optionKey: "cookieless_mode",
|
|
5490
|
+
coerce: coerceBool
|
|
5491
|
+
},
|
|
5492
|
+
{
|
|
5493
|
+
property: "$ignore_sent_at",
|
|
5494
|
+
optionKey: "disable_skew_correction",
|
|
5495
|
+
coerce: coerceBool
|
|
5496
|
+
},
|
|
5497
|
+
{
|
|
5498
|
+
property: "$process_person_profile",
|
|
5499
|
+
optionKey: "process_person_profile",
|
|
5500
|
+
coerce: coerceBool
|
|
5501
|
+
},
|
|
5502
|
+
{
|
|
5503
|
+
property: "$product_tour_id",
|
|
5504
|
+
optionKey: "product_tour_id",
|
|
5505
|
+
coerce: coerceString
|
|
5506
|
+
}
|
|
5507
|
+
];
|
|
5508
|
+
var TOPLEVEL_SENTINELS = [
|
|
5509
|
+
{
|
|
5510
|
+
property: "$session_id",
|
|
5511
|
+
field: "session_id"
|
|
5512
|
+
},
|
|
5513
|
+
{
|
|
5514
|
+
property: "$window_id",
|
|
5515
|
+
field: "window_id"
|
|
5516
|
+
}
|
|
5517
|
+
];
|
|
5518
|
+
function isRecord2(value) {
|
|
5519
|
+
return typeof value == "object" && value !== null && !Array.isArray(value);
|
|
5520
|
+
}
|
|
5521
|
+
function toRfc3339(timestamp) {
|
|
5522
|
+
if (typeof timestamp == "string") {
|
|
5523
|
+
const asDate = new Date(timestamp);
|
|
5524
|
+
if (Number.isNaN(asDate.getTime()))
|
|
5525
|
+
return new Date().toISOString();
|
|
5526
|
+
const normalized = asDate.toISOString();
|
|
5527
|
+
const fractionalSeconds = timestamp.match(/\.(\d+)(?:Z|[+-]\d{2}:?\d{2})?$/i)?.[1];
|
|
5528
|
+
return fractionalSeconds && fractionalSeconds.length > 3 ? normalized.replace(/\.\d{3}Z$/, `.${fractionalSeconds}Z`) : normalized;
|
|
5529
|
+
}
|
|
5530
|
+
if (timestamp instanceof Date)
|
|
5531
|
+
return Number.isNaN(timestamp.getTime()) ? new Date().toISOString() : timestamp.toISOString();
|
|
5532
|
+
const asDate = timestamp == null ? new Date : new Date(timestamp);
|
|
5533
|
+
return Number.isNaN(asDate.getTime()) ? new Date().toISOString() : asDate.toISOString();
|
|
5534
|
+
}
|
|
5535
|
+
function relocateInto(properties, key, value) {
|
|
5536
|
+
if (value !== undefined && !(key in properties))
|
|
5537
|
+
properties[key] = value;
|
|
5538
|
+
}
|
|
5539
|
+
function buildV1Event(message) {
|
|
5540
|
+
const sourceProperties = isRecord2(message.properties) ? message.properties : {};
|
|
5541
|
+
const properties = {
|
|
5542
|
+
...sourceProperties
|
|
5543
|
+
};
|
|
5544
|
+
const options = {};
|
|
5545
|
+
for (const { property, optionKey, coerce } of OPTION_SENTINELS)
|
|
5546
|
+
if (property in properties) {
|
|
5547
|
+
const coerced = coerce(properties[property]);
|
|
5548
|
+
if (coerced !== undefined)
|
|
5549
|
+
options[optionKey] = coerced;
|
|
5550
|
+
delete properties[property];
|
|
5551
|
+
}
|
|
5552
|
+
const topLevel = {};
|
|
5553
|
+
for (const { property, field } of TOPLEVEL_SENTINELS)
|
|
5554
|
+
if (property in properties) {
|
|
5555
|
+
const value = properties[property];
|
|
5556
|
+
if (typeof value == "string")
|
|
5557
|
+
topLevel[field] = value;
|
|
5558
|
+
delete properties[property];
|
|
5559
|
+
}
|
|
5560
|
+
delete properties.$lib;
|
|
5561
|
+
delete properties.$lib_version;
|
|
5562
|
+
relocateInto(properties, "$set", message.$set);
|
|
5563
|
+
relocateInto(properties, "$set_once", message.$set_once);
|
|
5564
|
+
return {
|
|
5565
|
+
event: String(message.event ?? ""),
|
|
5566
|
+
uuid: String(message.uuid ?? ""),
|
|
5567
|
+
distinct_id: String(message.distinct_id ?? ""),
|
|
5568
|
+
timestamp: toRfc3339(message.timestamp),
|
|
5569
|
+
...topLevel,
|
|
5570
|
+
options,
|
|
5571
|
+
properties
|
|
5572
|
+
};
|
|
5573
|
+
}
|
|
5574
|
+
function buildV1Batch(messages, { createdAt, historicalMigration }) {
|
|
5575
|
+
const batch = {
|
|
5576
|
+
created_at: createdAt,
|
|
5577
|
+
batch: messages.map(buildV1Event)
|
|
5578
|
+
};
|
|
5579
|
+
if (historicalMigration)
|
|
5580
|
+
batch.historical_migration = true;
|
|
5581
|
+
return batch;
|
|
5582
|
+
}
|
|
5583
|
+
|
|
5584
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/capture-v1/sender.mjs
|
|
5585
|
+
var V1_ANALYTICS_PATH = "/i/v1/analytics/events";
|
|
5586
|
+
var DEFAULT_MAX_BACKOFF_MS = 30000;
|
|
5587
|
+
var RETRYABLE_STATUSES = new Set([
|
|
5588
|
+
408,
|
|
5589
|
+
500,
|
|
5590
|
+
502,
|
|
5591
|
+
503,
|
|
5592
|
+
504
|
|
5593
|
+
]);
|
|
5594
|
+
|
|
5595
|
+
class V1CaptureSender {
|
|
5596
|
+
constructor(config, hooks) {
|
|
5597
|
+
this.config = config;
|
|
5598
|
+
this.maxBackoffMs = config.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
5599
|
+
this.fetchFn = hooks.fetch;
|
|
5600
|
+
this.onError = hooks.onError;
|
|
5601
|
+
this.now = hooks.now ?? Date.now;
|
|
5602
|
+
this.sleep = hooks.sleep ?? ((ms) => new Promise((resolve) => safeSetTimeout(resolve, ms)));
|
|
5603
|
+
this.generateRequestId = hooks.generateRequestId ?? uuidv7;
|
|
5604
|
+
this.compress = hooks.compress ?? gzipCompress;
|
|
5605
|
+
}
|
|
5606
|
+
async sendV1Batch(messages) {
|
|
5607
|
+
if (messages.length === 0)
|
|
5608
|
+
return;
|
|
5609
|
+
const requestId = this.generateRequestId();
|
|
5610
|
+
const createdAt = new Date(this.now()).toISOString();
|
|
5611
|
+
const { batch } = buildV1Batch(messages, {
|
|
5612
|
+
createdAt,
|
|
5613
|
+
historicalMigration: this.config.historicalMigration
|
|
5614
|
+
});
|
|
5615
|
+
const url = `${this.config.host}${V1_ANALYTICS_PATH}`;
|
|
5616
|
+
const drops = [];
|
|
5617
|
+
let pending = batch;
|
|
5618
|
+
const maxAttempts = Math.max(1, this.config.maxAttempts);
|
|
5619
|
+
for (let attempt = 1;attempt <= maxAttempts; attempt++) {
|
|
5620
|
+
const isLastAttempt = attempt === maxAttempts;
|
|
5621
|
+
const payload = safeJsonStringify({
|
|
5622
|
+
created_at: createdAt,
|
|
5623
|
+
...this.config.historicalMigration ? {
|
|
5624
|
+
historical_migration: true
|
|
5625
|
+
} : {},
|
|
5626
|
+
batch: pending
|
|
5627
|
+
});
|
|
5628
|
+
let captureAttempt;
|
|
5629
|
+
let retryDelayMs;
|
|
5630
|
+
try {
|
|
5631
|
+
captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
|
|
5632
|
+
const { response, signal } = captureAttempt;
|
|
5633
|
+
const { status } = response;
|
|
5634
|
+
if (status < 200 || status >= 300)
|
|
5635
|
+
if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
5636
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
5637
|
+
await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(() => {});
|
|
5638
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
5639
|
+
} else {
|
|
5640
|
+
const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
|
|
5641
|
+
return this.surfaceBatchFailure(requestId, drops, pending, httpError);
|
|
5642
|
+
}
|
|
5643
|
+
else {
|
|
5644
|
+
let parsed;
|
|
5645
|
+
try {
|
|
5646
|
+
parsed = await captureAttempt.waitFor(this.parseResponse(response));
|
|
5647
|
+
} catch (error) {
|
|
5648
|
+
if (signal.aborted)
|
|
5649
|
+
throw error;
|
|
5650
|
+
return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
|
|
5651
|
+
}
|
|
5652
|
+
const retryable = this.classify(pending, parsed, drops);
|
|
5653
|
+
if (retryable.length === 0)
|
|
5654
|
+
return this.surfacePartialDrops(requestId, drops);
|
|
5655
|
+
if (isLastAttempt)
|
|
5656
|
+
return void this.onError(new CaptureV1Error({
|
|
5657
|
+
requestId,
|
|
5658
|
+
drops,
|
|
5659
|
+
retryExhausted: retryable.map((event) => event.uuid)
|
|
5660
|
+
}));
|
|
5661
|
+
pending = retryable;
|
|
5662
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
5663
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
5664
|
+
}
|
|
5665
|
+
} catch (transportError) {
|
|
5666
|
+
if (captureAttempt && !captureAttempt.signal.aborted)
|
|
5667
|
+
throw transportError;
|
|
5668
|
+
if (isLastAttempt)
|
|
5669
|
+
return this.surfaceBatchFailure(requestId, drops, pending, transportError);
|
|
5670
|
+
retryDelayMs = this.backoffDelay(attempt);
|
|
5671
|
+
} finally {
|
|
5672
|
+
captureAttempt?.cleanup();
|
|
5673
|
+
}
|
|
5674
|
+
if (retryDelayMs !== undefined)
|
|
5675
|
+
await this.sleep(retryDelayMs);
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
async sendOnce(url, payload, attempt, requestId) {
|
|
5679
|
+
const headers = this.buildHeaders(attempt, requestId);
|
|
5680
|
+
let body = payload;
|
|
5681
|
+
if (this.config.compressionEnabled) {
|
|
5682
|
+
const compressed = await this.compress(payload, this.config.isDebug);
|
|
5683
|
+
if (compressed !== null) {
|
|
5684
|
+
body = compressed;
|
|
5685
|
+
headers["Content-Encoding"] = "gzip";
|
|
5686
|
+
}
|
|
5687
|
+
}
|
|
5688
|
+
const controller = new AbortController;
|
|
5689
|
+
let timeoutPhase = "waiting for response headers";
|
|
5690
|
+
let timer;
|
|
5691
|
+
const deadline = new Promise((_resolve, reject) => {
|
|
5692
|
+
timer = safeSetTimeout(() => {
|
|
5693
|
+
const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
|
|
5694
|
+
timeoutError.name = "AbortError";
|
|
5695
|
+
reject(timeoutError);
|
|
5696
|
+
controller.abort(timeoutError);
|
|
5697
|
+
}, this.config.requestTimeoutMs);
|
|
5698
|
+
});
|
|
5699
|
+
try {
|
|
5700
|
+
const fetchPromise = this.fetchFn(url, {
|
|
5701
|
+
method: "POST",
|
|
5702
|
+
headers,
|
|
5703
|
+
body,
|
|
5704
|
+
signal: controller.signal
|
|
5705
|
+
});
|
|
5706
|
+
let responseAccepted = false;
|
|
5707
|
+
fetchPromise.then((lateResponse) => {
|
|
5708
|
+
if (controller.signal.aborted && !responseAccepted)
|
|
5709
|
+
this.cancelBody(lateResponse);
|
|
5710
|
+
}).catch(() => {});
|
|
5711
|
+
const response = await Promise.race([
|
|
5712
|
+
fetchPromise,
|
|
5713
|
+
deadline
|
|
5714
|
+
]);
|
|
5715
|
+
responseAccepted = true;
|
|
5716
|
+
timeoutPhase = "while reading the response body";
|
|
5717
|
+
let cleanedUp = false;
|
|
5718
|
+
let cancellation;
|
|
5719
|
+
const cancelBody = () => cancellation ??= this.cancelBody(response);
|
|
5720
|
+
return {
|
|
5721
|
+
response,
|
|
5722
|
+
signal: controller.signal,
|
|
5723
|
+
waitFor: (operation) => Promise.race([
|
|
5724
|
+
operation,
|
|
5725
|
+
deadline
|
|
5726
|
+
]),
|
|
5727
|
+
cancelBody,
|
|
5728
|
+
cleanup: () => {
|
|
5729
|
+
if (cleanedUp)
|
|
5730
|
+
return;
|
|
5731
|
+
cleanedUp = true;
|
|
5732
|
+
clearTimeout(timer);
|
|
5733
|
+
if (controller.signal.aborted)
|
|
5734
|
+
cancelBody();
|
|
5735
|
+
}
|
|
5736
|
+
};
|
|
5737
|
+
} catch (error) {
|
|
5738
|
+
clearTimeout(timer);
|
|
5739
|
+
throw error;
|
|
5740
|
+
}
|
|
5741
|
+
}
|
|
5742
|
+
buildHeaders(attempt, requestId) {
|
|
5743
|
+
const sdkInfo = `${this.config.libraryId}/${this.config.libraryVersion}`;
|
|
5744
|
+
const headers = {
|
|
5745
|
+
"Content-Type": "application/json",
|
|
5746
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
5747
|
+
"PostHog-Sdk-Info": sdkInfo,
|
|
5748
|
+
"PostHog-Attempt": String(attempt),
|
|
5749
|
+
"PostHog-Request-Id": requestId,
|
|
5750
|
+
"PostHog-Request-Timestamp": new Date(this.now()).toISOString()
|
|
5751
|
+
};
|
|
5752
|
+
if (this.config.userAgent)
|
|
5753
|
+
headers["User-Agent"] = this.config.userAgent;
|
|
5754
|
+
return headers;
|
|
5755
|
+
}
|
|
5756
|
+
classify(pending, parsed, drops) {
|
|
5757
|
+
const results = parsed.results ?? {};
|
|
5758
|
+
const retryable = [];
|
|
5759
|
+
for (const event of pending) {
|
|
5760
|
+
const result = results[event.uuid];
|
|
5761
|
+
if (result) {
|
|
5762
|
+
if (result.result === "drop")
|
|
5763
|
+
drops.push({
|
|
5764
|
+
uuid: event.uuid,
|
|
5765
|
+
details: result.details ?? undefined
|
|
5766
|
+
});
|
|
5767
|
+
else if (result.result === "retry")
|
|
5768
|
+
retryable.push(event);
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
return retryable;
|
|
5772
|
+
}
|
|
5773
|
+
backoffDelay(attempt, retryAfterMs) {
|
|
5774
|
+
const exponential = Math.min(this.config.initialRetryDelayMs * 2 ** (attempt - 1), this.maxBackoffMs);
|
|
5775
|
+
if (retryAfterMs === undefined)
|
|
5776
|
+
return exponential;
|
|
5777
|
+
return Math.max(exponential, Math.min(retryAfterMs, this.maxBackoffMs));
|
|
5778
|
+
}
|
|
5779
|
+
parseRetryAfter(response) {
|
|
5780
|
+
const raw = response.headers?.get("Retry-After");
|
|
5781
|
+
if (!raw)
|
|
5782
|
+
return;
|
|
5783
|
+
const trimmed = raw.trim();
|
|
5784
|
+
if (/^\d+$/.test(trimmed)) {
|
|
5785
|
+
const seconds = parseInt(trimmed, 10);
|
|
5786
|
+
return Number.isFinite(seconds) && seconds > 0 ? 1000 * seconds : undefined;
|
|
5787
|
+
}
|
|
5788
|
+
const dateMs = Date.parse(trimmed);
|
|
5789
|
+
if (Number.isNaN(dateMs))
|
|
5790
|
+
return;
|
|
5791
|
+
const delta = dateMs - this.now();
|
|
5792
|
+
return delta > 0 ? delta : undefined;
|
|
5793
|
+
}
|
|
5794
|
+
async parseResponse(response) {
|
|
5795
|
+
const text = await response.text();
|
|
5796
|
+
const parsed = JSON.parse(text);
|
|
5797
|
+
if (typeof parsed != "object" || parsed === null || Array.isArray(parsed))
|
|
5798
|
+
throw new Error("unexpected response shape");
|
|
5799
|
+
const results = parsed.results;
|
|
5800
|
+
if (results !== undefined && (typeof results != "object" || results === null || Array.isArray(results)))
|
|
5801
|
+
throw new Error("unexpected results shape");
|
|
5802
|
+
return {
|
|
5803
|
+
results: results ?? {}
|
|
5804
|
+
};
|
|
5805
|
+
}
|
|
5806
|
+
async buildHttpError(response, status, waitFor) {
|
|
5807
|
+
let bodyText = "";
|
|
5808
|
+
try {
|
|
5809
|
+
bodyText = (await waitFor(response.text())).slice(0, 512);
|
|
5810
|
+
} catch {}
|
|
5811
|
+
const suffix = bodyText ? `: ${bodyText}` : "";
|
|
5812
|
+
return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
|
|
5813
|
+
}
|
|
5814
|
+
surfaceBatchFailure(requestId, drops, pending, cause) {
|
|
5815
|
+
this.onError(new CaptureV1Error({
|
|
5816
|
+
requestId,
|
|
5817
|
+
drops,
|
|
5818
|
+
retryExhausted: pending.map((event) => event.uuid),
|
|
5819
|
+
cause
|
|
5820
|
+
}));
|
|
5821
|
+
}
|
|
5822
|
+
surfacePartialDrops(requestId, drops) {
|
|
5823
|
+
if (drops.length > 0)
|
|
5824
|
+
this.onError(new CaptureV1Error({
|
|
5825
|
+
requestId,
|
|
5826
|
+
drops,
|
|
5827
|
+
retryExhausted: []
|
|
5828
|
+
}));
|
|
5829
|
+
}
|
|
5830
|
+
async cancelBody(response) {
|
|
5831
|
+
try {
|
|
5832
|
+
await response.body?.cancel();
|
|
5833
|
+
} catch {}
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5836
|
+
|
|
5837
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/routing.mjs
|
|
5838
|
+
var AI_CAPTURE_ROUTE = "ai-capture";
|
|
5839
|
+
var AI_CAPTURE_ENDPOINT_PATH = "/i/v0/ai/batch/";
|
|
5840
|
+
var AI_MAX_EVENT_BYTES = 8388608;
|
|
5841
|
+
var AI_BATCH_TARGET_BYTES = 5242880;
|
|
5842
|
+
|
|
5843
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/ai-capture/batching.mjs
|
|
5844
|
+
var encoder = new TextEncoder;
|
|
5845
|
+
function eventByteSize(message) {
|
|
5846
|
+
return encoder.encode(safeJsonStringify(message)).length;
|
|
5847
|
+
}
|
|
5848
|
+
function partitionAiBatch(messages, maxEventBytes = AI_MAX_EVENT_BYTES, targetBatchBytes = AI_BATCH_TARGET_BYTES) {
|
|
5849
|
+
const batches = [];
|
|
5850
|
+
const dropped = [];
|
|
5851
|
+
let current = [];
|
|
5852
|
+
let currentBytes = 0;
|
|
5853
|
+
for (const message of messages) {
|
|
5854
|
+
if (message === undefined)
|
|
5855
|
+
continue;
|
|
5856
|
+
const bytes = eventByteSize(message);
|
|
5857
|
+
if (bytes > maxEventBytes) {
|
|
5858
|
+
dropped.push({
|
|
5859
|
+
event: typeof message.event == "string" ? message.event : "unknown",
|
|
5860
|
+
bytes
|
|
5861
|
+
});
|
|
5862
|
+
continue;
|
|
5863
|
+
}
|
|
5864
|
+
if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
|
|
5865
|
+
batches.push(current);
|
|
5866
|
+
current = [];
|
|
5867
|
+
currentBytes = 0;
|
|
5868
|
+
}
|
|
5869
|
+
current.push(message);
|
|
5870
|
+
currentBytes += bytes;
|
|
5871
|
+
}
|
|
5872
|
+
if (current.length > 0)
|
|
5873
|
+
batches.push(current);
|
|
5874
|
+
return {
|
|
5875
|
+
batches,
|
|
5876
|
+
dropped
|
|
5877
|
+
};
|
|
5878
|
+
}
|
|
5879
|
+
|
|
5880
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/client.mjs
|
|
4393
5881
|
var MINIMUM_POLLING_INTERVAL = 100;
|
|
4394
5882
|
var THIRTY_SECONDS = 30000;
|
|
4395
5883
|
var MAX_CACHE_SIZE = 50000;
|
|
@@ -4414,6 +5902,12 @@ function normalizeHost(value) {
|
|
|
4414
5902
|
const normalizedValue = typeof value == "string" ? value.trim() : "";
|
|
4415
5903
|
return normalizedValue || DEFAULT_NODE_HOST;
|
|
4416
5904
|
}
|
|
5905
|
+
function normalizeUnsetPersonProperties(value) {
|
|
5906
|
+
const propertyNames = Array.isArray(value) ? value : [
|
|
5907
|
+
value
|
|
5908
|
+
];
|
|
5909
|
+
return propertyNames.filter((propertyName) => typeof propertyName == "string" && propertyName.trim().length > 0);
|
|
5910
|
+
}
|
|
4417
5911
|
function buildFlagEventProperties(flagValues) {
|
|
4418
5912
|
if (!flagValues)
|
|
4419
5913
|
return {};
|
|
@@ -4431,11 +5925,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4431
5925
|
const normalizedApiKey = normalizeApiKey(apiKey);
|
|
4432
5926
|
const normalizedOptions = {
|
|
4433
5927
|
...options,
|
|
5928
|
+
maxQueueSize: options.maxQueueSize ?? 1e4,
|
|
5929
|
+
flushInterval: options.flushInterval ?? 5000,
|
|
4434
5930
|
host: normalizeHost(options.host),
|
|
4435
|
-
personalApiKey: normalizePersonalApiKey(options.personalApiKey)
|
|
5931
|
+
personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
|
|
4436
5932
|
};
|
|
4437
|
-
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage;
|
|
5933
|
+
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage, this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
|
|
4438
5934
|
this.options = normalizedOptions;
|
|
5935
|
+
this.captureMode = resolveCaptureMode();
|
|
5936
|
+
this.enableFullAiCapture = normalizedOptions.enableFullAiCapture === true;
|
|
4439
5937
|
this.context = this.initializeContext();
|
|
4440
5938
|
this.options.featureFlagsPollingInterval = typeof normalizedOptions.featureFlagsPollingInterval == "number" ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
4441
5939
|
if (typeof normalizedOptions.waitUntilDebounceMs == "number")
|
|
@@ -4460,21 +5958,24 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4460
5958
|
onLoad: (count) => {
|
|
4461
5959
|
this._events.emit("localEvaluationFlagsLoaded", count);
|
|
4462
5960
|
},
|
|
5961
|
+
onMinimalFlagCalledEvents: (enabled) => {
|
|
5962
|
+
this._minimalFlagCalledEvents = enabled;
|
|
5963
|
+
},
|
|
4463
5964
|
customHeaders: this.getCustomHeaders(),
|
|
4464
5965
|
cacheProvider: normalizedOptions.flagDefinitionCacheProvider,
|
|
4465
5966
|
strictLocalEvaluation: normalizedOptions.strictLocalEvaluation
|
|
4466
5967
|
});
|
|
4467
5968
|
}
|
|
4468
|
-
this.errorTracking = new
|
|
5969
|
+
this.errorTracking = new error_tracking_ErrorTracking(this, normalizedOptions, this._logger);
|
|
4469
5970
|
this.distinctIdHasSentFlagCalls = {};
|
|
4470
5971
|
this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
|
|
4471
5972
|
}
|
|
4472
|
-
enqueue(type, message, options) {
|
|
4473
|
-
super.enqueue(type, message, options);
|
|
5973
|
+
enqueue(type, message, options, explicitRoute) {
|
|
5974
|
+
super.enqueue(type, message, options, explicitRoute);
|
|
4474
5975
|
this.scheduleDebouncedFlush();
|
|
4475
5976
|
}
|
|
4476
5977
|
async flush() {
|
|
4477
|
-
const flushPromise =
|
|
5978
|
+
const flushPromise = this.flushWithPendingPromises();
|
|
4478
5979
|
const waitUntil = this.options.waitUntil;
|
|
4479
5980
|
if (waitUntil && !this._waitUntilCycle)
|
|
4480
5981
|
try {
|
|
@@ -4527,7 +6028,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4527
6028
|
async resolveWaitUntilFlush() {
|
|
4528
6029
|
const resolve = this._consumeWaitUntilCycle();
|
|
4529
6030
|
try {
|
|
4530
|
-
await
|
|
6031
|
+
await this.flushWithPendingPromises();
|
|
4531
6032
|
} catch {} finally {
|
|
4532
6033
|
resolve?.();
|
|
4533
6034
|
}
|
|
@@ -4541,12 +6042,103 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4541
6042
|
fetch(url, options) {
|
|
4542
6043
|
return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
|
|
4543
6044
|
}
|
|
6045
|
+
getQueueRouteKey(message) {
|
|
6046
|
+
return this.captureMode === "v1" && isLegacyOnlyEvent(message) ? AI_ROUTE : ANALYTICS_ROUTE;
|
|
6047
|
+
}
|
|
6048
|
+
persistedQueueKeyForRoute(route) {
|
|
6049
|
+
if (route === AI_CAPTURE_ROUTE)
|
|
6050
|
+
return types_PostHogPersistedProperty.AiCaptureQueue;
|
|
6051
|
+
return route === AI_ROUTE ? types_PostHogPersistedProperty.AiQueue : types_PostHogPersistedProperty.Queue;
|
|
6052
|
+
}
|
|
6053
|
+
getActiveQueueRoutes() {
|
|
6054
|
+
const routes = this.captureMode === "v1" ? [
|
|
6055
|
+
ANALYTICS_ROUTE,
|
|
6056
|
+
AI_ROUTE
|
|
6057
|
+
] : [
|
|
6058
|
+
ANALYTICS_ROUTE
|
|
6059
|
+
];
|
|
6060
|
+
if (this._aiCaptureRouteActive)
|
|
6061
|
+
routes.push(AI_CAPTURE_ROUTE);
|
|
6062
|
+
return routes;
|
|
6063
|
+
}
|
|
6064
|
+
getBatchEndpointPath(route) {
|
|
6065
|
+
return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
|
|
6066
|
+
}
|
|
6067
|
+
async sendBatch(batchMessages, retryOptions, route = ANALYTICS_ROUTE) {
|
|
6068
|
+
if (route === AI_CAPTURE_ROUTE)
|
|
6069
|
+
return this.sendAiCaptureBatch(batchMessages, retryOptions);
|
|
6070
|
+
if (this.captureMode !== "v1" || route === AI_ROUTE)
|
|
6071
|
+
return super.sendBatch(batchMessages, retryOptions, route);
|
|
6072
|
+
const v1Events = batchMessages.filter((message) => message !== undefined);
|
|
6073
|
+
await this.getV1Sender().sendV1Batch(v1Events);
|
|
6074
|
+
}
|
|
6075
|
+
async sendAiCaptureBatch(batchMessages, retryOptions) {
|
|
6076
|
+
const { batches, dropped } = partitionAiBatch(batchMessages);
|
|
6077
|
+
for (const { event, bytes } of dropped) {
|
|
6078
|
+
const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
|
|
6079
|
+
this._logger.error(message);
|
|
6080
|
+
this._events.emit("error", new Error(message));
|
|
6081
|
+
}
|
|
6082
|
+
for (const batch of batches)
|
|
6083
|
+
await this.sendAiSubBatch(batch, retryOptions);
|
|
6084
|
+
}
|
|
6085
|
+
async sendAiSubBatch(batch, retryOptions) {
|
|
6086
|
+
try {
|
|
6087
|
+
await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE);
|
|
6088
|
+
} catch (err) {
|
|
6089
|
+
if (!isPostHogFetchContentTooLargeError(err))
|
|
6090
|
+
throw err;
|
|
6091
|
+
if (batch.length === 1) {
|
|
6092
|
+
const [event] = batch;
|
|
6093
|
+
const eventName = typeof event.event == "string" ? event.event : "unknown";
|
|
6094
|
+
const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
|
|
6095
|
+
this._logger.error(message);
|
|
6096
|
+
this._events.emit("error", new Error(message));
|
|
6097
|
+
return;
|
|
6098
|
+
}
|
|
6099
|
+
const mid = Math.ceil(batch.length / 2);
|
|
6100
|
+
await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
|
|
6101
|
+
await this.sendAiSubBatch(batch.slice(mid), retryOptions);
|
|
6102
|
+
}
|
|
6103
|
+
}
|
|
6104
|
+
getV1Sender() {
|
|
6105
|
+
if (!this._v1Sender)
|
|
6106
|
+
this._v1Sender = new V1CaptureSender({
|
|
6107
|
+
host: this.host,
|
|
6108
|
+
apiKey: this.apiKey,
|
|
6109
|
+
libraryId: this.getLibraryId(),
|
|
6110
|
+
libraryVersion: this.getLibraryVersion(),
|
|
6111
|
+
userAgent: this.getCustomUserAgent() || undefined,
|
|
6112
|
+
historicalMigration: this.historicalMigration,
|
|
6113
|
+
compressionEnabled: !this.disableCompression,
|
|
6114
|
+
requestTimeoutMs: this.requestTimeout,
|
|
6115
|
+
maxAttempts: (this.options.fetchRetryCount ?? 3) + 1,
|
|
6116
|
+
initialRetryDelayMs: this.options.fetchRetryDelay ?? 3000,
|
|
6117
|
+
isDebug: this.isDebug
|
|
6118
|
+
}, {
|
|
6119
|
+
fetch: (url, fetchOptions) => this.fetch(url, fetchOptions),
|
|
6120
|
+
onError: (error) => this._events.emit("error", error),
|
|
6121
|
+
compress: (payload) => this.compressPayload(payload)
|
|
6122
|
+
});
|
|
6123
|
+
return this._v1Sender;
|
|
6124
|
+
}
|
|
4544
6125
|
getLibraryVersion() {
|
|
4545
6126
|
return version;
|
|
4546
6127
|
}
|
|
6128
|
+
get metrics() {
|
|
6129
|
+
if (!this._metrics)
|
|
6130
|
+
this._metrics = new PostHogMetrics(this, resolveMetricsConfig(this.options.metrics), this._logger);
|
|
6131
|
+
return this._metrics;
|
|
6132
|
+
}
|
|
4547
6133
|
getCustomUserAgent() {
|
|
4548
6134
|
return `${this.getLibraryId()}/${this.getLibraryVersion()}`;
|
|
4549
6135
|
}
|
|
6136
|
+
getCommonEventProperties() {
|
|
6137
|
+
const commonProperties = super.getCommonEventProperties();
|
|
6138
|
+
if (this.options.isServer ?? true)
|
|
6139
|
+
commonProperties.$is_server = true;
|
|
6140
|
+
return commonProperties;
|
|
6141
|
+
}
|
|
4550
6142
|
enable() {
|
|
4551
6143
|
return super.optIn();
|
|
4552
6144
|
}
|
|
@@ -4557,33 +6149,69 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4557
6149
|
super.debug(enabled);
|
|
4558
6150
|
this.featureFlagsPoller?.debug(enabled);
|
|
4559
6151
|
}
|
|
4560
|
-
|
|
6152
|
+
_warnIfInvalidCapture(props, stringArgumentWarning, exceptionCaptureWarning) {
|
|
4561
6153
|
if (typeof props == "string")
|
|
4562
|
-
this._logger.warn(
|
|
6154
|
+
this._logger.warn(stringArgumentWarning);
|
|
4563
6155
|
if (props.event === "$exception" && !props._originatedFromCaptureException)
|
|
4564
|
-
this._logger.warn(
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
6156
|
+
this._logger.warn(exceptionCaptureWarning);
|
|
6157
|
+
}
|
|
6158
|
+
_sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
|
|
6159
|
+
return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options }) => {
|
|
6160
|
+
const captureOptions = {
|
|
6161
|
+
timestamp: options.timestamp,
|
|
6162
|
+
disableGeoip: options.disableGeoip,
|
|
6163
|
+
uuid: options.uuid
|
|
6164
|
+
};
|
|
6165
|
+
const message = {
|
|
6166
|
+
distinctId,
|
|
6167
|
+
event,
|
|
6168
|
+
properties: {
|
|
6169
|
+
...properties,
|
|
6170
|
+
...this.getCommonEventProperties()
|
|
6171
|
+
}
|
|
6172
|
+
};
|
|
6173
|
+
return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
|
|
6174
|
+
}).catch((err) => {
|
|
4570
6175
|
if (err)
|
|
4571
6176
|
console.error(err);
|
|
4572
6177
|
}));
|
|
4573
6178
|
}
|
|
6179
|
+
_capturePreparedEvent(props, immediate) {
|
|
6180
|
+
return this._sendPreparedEvent("capture", props, immediate);
|
|
6181
|
+
}
|
|
6182
|
+
capture(props) {
|
|
6183
|
+
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.");
|
|
6184
|
+
this._capturePreparedEvent(props, false);
|
|
6185
|
+
}
|
|
4574
6186
|
async captureImmediate(props) {
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
6187
|
+
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.");
|
|
6188
|
+
return this._capturePreparedEvent(props, true);
|
|
6189
|
+
}
|
|
6190
|
+
captureAi(props) {
|
|
6191
|
+
if (this.disabled)
|
|
6192
|
+
return;
|
|
6193
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
6194
|
+
this._sendPreparedAiEvent({
|
|
6195
|
+
...props,
|
|
6196
|
+
uuid
|
|
6197
|
+
}, false);
|
|
6198
|
+
return uuid;
|
|
6199
|
+
}
|
|
6200
|
+
async captureAiImmediate(props) {
|
|
6201
|
+
if (this.disabled)
|
|
6202
|
+
return;
|
|
6203
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
6204
|
+
await this._sendPreparedAiEvent({
|
|
6205
|
+
...props,
|
|
6206
|
+
uuid
|
|
6207
|
+
}, true);
|
|
6208
|
+
return uuid;
|
|
6209
|
+
}
|
|
6210
|
+
_sendPreparedAiEvent(props, immediate) {
|
|
6211
|
+
if (typeof props?.event == "string" && !props.event.startsWith("$ai_"))
|
|
6212
|
+
this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
|
|
6213
|
+
this._aiCaptureRouteActive = true;
|
|
6214
|
+
return this._sendPreparedEvent("capture", props, immediate, undefined, AI_CAPTURE_ROUTE);
|
|
4587
6215
|
}
|
|
4588
6216
|
identify({ distinctId, properties = {}, disableGeoip }) {
|
|
4589
6217
|
const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
|
|
@@ -4594,8 +6222,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4594
6222
|
$set_once: setOnceProps,
|
|
4595
6223
|
$anon_distinct_id: $anon_distinct_id ?? undefined
|
|
4596
6224
|
};
|
|
4597
|
-
|
|
6225
|
+
this._sendPreparedEvent("identify", {
|
|
6226
|
+
distinctId,
|
|
6227
|
+
event: "$identify",
|
|
6228
|
+
properties: eventProperties,
|
|
4598
6229
|
disableGeoip
|
|
6230
|
+
}, false, {
|
|
6231
|
+
includeContextProperties: false
|
|
4599
6232
|
});
|
|
4600
6233
|
}
|
|
4601
6234
|
async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
|
|
@@ -4607,18 +6240,65 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4607
6240
|
$set_once: setOnceProps,
|
|
4608
6241
|
$anon_distinct_id: $anon_distinct_id ?? undefined
|
|
4609
6242
|
};
|
|
4610
|
-
await
|
|
6243
|
+
await this._sendPreparedEvent("identify", {
|
|
6244
|
+
distinctId,
|
|
6245
|
+
event: "$identify",
|
|
6246
|
+
properties: eventProperties,
|
|
4611
6247
|
disableGeoip
|
|
6248
|
+
}, true, {
|
|
6249
|
+
includeContextProperties: false
|
|
6250
|
+
});
|
|
6251
|
+
}
|
|
6252
|
+
setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
|
|
6253
|
+
if (Object.keys(properties).length === 0 && Object.keys(propertiesOnce).length === 0)
|
|
6254
|
+
return;
|
|
6255
|
+
const eventProperties = {};
|
|
6256
|
+
if (Object.keys(properties).length > 0)
|
|
6257
|
+
eventProperties.$set = properties;
|
|
6258
|
+
if (Object.keys(propertiesOnce).length > 0)
|
|
6259
|
+
eventProperties.$set_once = propertiesOnce;
|
|
6260
|
+
this.capture({
|
|
6261
|
+
distinctId,
|
|
6262
|
+
event: "$set",
|
|
6263
|
+
properties: eventProperties
|
|
6264
|
+
});
|
|
6265
|
+
}
|
|
6266
|
+
unsetPersonProperties({ distinctId, properties }) {
|
|
6267
|
+
const propertyNames = normalizeUnsetPersonProperties(properties);
|
|
6268
|
+
if (propertyNames.length === 0)
|
|
6269
|
+
return;
|
|
6270
|
+
this.capture({
|
|
6271
|
+
distinctId,
|
|
6272
|
+
event: "$set",
|
|
6273
|
+
properties: {
|
|
6274
|
+
$unset: propertyNames
|
|
6275
|
+
}
|
|
4612
6276
|
});
|
|
4613
6277
|
}
|
|
4614
6278
|
alias(data) {
|
|
4615
|
-
|
|
6279
|
+
this._sendPreparedEvent("alias", {
|
|
6280
|
+
distinctId: data.distinctId,
|
|
6281
|
+
event: "$create_alias",
|
|
6282
|
+
properties: {
|
|
6283
|
+
distinct_id: data.distinctId,
|
|
6284
|
+
alias: data.alias
|
|
6285
|
+
},
|
|
4616
6286
|
disableGeoip: data.disableGeoip
|
|
6287
|
+
}, false, {
|
|
6288
|
+
includeContextProperties: false
|
|
4617
6289
|
});
|
|
4618
6290
|
}
|
|
4619
6291
|
async aliasImmediate(data) {
|
|
4620
|
-
await
|
|
6292
|
+
await this._sendPreparedEvent("alias", {
|
|
6293
|
+
distinctId: data.distinctId,
|
|
6294
|
+
event: "$create_alias",
|
|
6295
|
+
properties: {
|
|
6296
|
+
distinct_id: data.distinctId,
|
|
6297
|
+
alias: data.alias
|
|
6298
|
+
},
|
|
4621
6299
|
disableGeoip: data.disableGeoip
|
|
6300
|
+
}, true, {
|
|
6301
|
+
includeContextProperties: false
|
|
4622
6302
|
});
|
|
4623
6303
|
}
|
|
4624
6304
|
isLocalEvaluationReady() {
|
|
@@ -4673,7 +6353,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4673
6353
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
|
|
4674
6354
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4675
6355
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4676
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties);
|
|
6356
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, this.personPropertiesForLocalEvaluation(distinctId, personProperties), groupProperties);
|
|
4677
6357
|
if (onlyEvaluateLocally == undefined)
|
|
4678
6358
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
4679
6359
|
let result;
|
|
@@ -4684,6 +6364,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4684
6364
|
let flagId;
|
|
4685
6365
|
let flagVersion;
|
|
4686
6366
|
let flagReason;
|
|
6367
|
+
let flagHasExperiment;
|
|
4687
6368
|
const localEvaluationEnabled = this.featureFlagsPoller !== undefined;
|
|
4688
6369
|
if (localEvaluationEnabled) {
|
|
4689
6370
|
await this.featureFlagsPoller?.loadFeatureFlags();
|
|
@@ -4698,6 +6379,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4698
6379
|
const value = localResult.value;
|
|
4699
6380
|
flagId = flag.id;
|
|
4700
6381
|
flagReason = "Evaluated locally";
|
|
6382
|
+
flagHasExperiment = flag.has_experiment;
|
|
4701
6383
|
result = {
|
|
4702
6384
|
key,
|
|
4703
6385
|
enabled: value !== false,
|
|
@@ -4713,12 +6395,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4713
6395
|
}
|
|
4714
6396
|
}
|
|
4715
6397
|
if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
|
|
4716
|
-
const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6398
|
+
const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [
|
|
4717
6399
|
key
|
|
4718
6400
|
]);
|
|
4719
6401
|
if (flagsResponse === undefined)
|
|
4720
6402
|
featureFlagError = FeatureFlagError2.UNKNOWN_ERROR;
|
|
4721
6403
|
else {
|
|
6404
|
+
this._minimalFlagCalledEvents = flagsResponse.minimalFlagCalledEvents === true;
|
|
4722
6405
|
requestId = flagsResponse.requestId;
|
|
4723
6406
|
evaluatedAt = flagsResponse.evaluatedAt;
|
|
4724
6407
|
const errors = [];
|
|
@@ -4733,6 +6416,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4733
6416
|
flagId = flagDetail.metadata?.id;
|
|
4734
6417
|
flagVersion = flagDetail.metadata?.version;
|
|
4735
6418
|
flagReason = flagDetail.reason?.description ?? flagDetail.reason?.code;
|
|
6419
|
+
flagHasExperiment = flagDetail.metadata?.has_experiment;
|
|
4736
6420
|
let parsedPayload;
|
|
4737
6421
|
if (flagDetail.metadata?.payload !== undefined)
|
|
4738
6422
|
try {
|
|
@@ -4743,7 +6427,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4743
6427
|
result = {
|
|
4744
6428
|
key,
|
|
4745
6429
|
enabled: flagDetail.enabled,
|
|
4746
|
-
variant: flagDetail.variant,
|
|
6430
|
+
variant: flagDetail.variant ?? undefined,
|
|
4747
6431
|
payload: parsedPayload
|
|
4748
6432
|
};
|
|
4749
6433
|
}
|
|
@@ -4764,6 +6448,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4764
6448
|
$feature_flag_request_id: requestId,
|
|
4765
6449
|
$feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt
|
|
4766
6450
|
};
|
|
6451
|
+
if (flagHasExperiment !== undefined)
|
|
6452
|
+
properties.$feature_flag_has_experiment = flagHasExperiment;
|
|
4767
6453
|
if (flagWasLocallyEvaluated && this.featureFlagsPoller) {
|
|
4768
6454
|
const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt();
|
|
4769
6455
|
if (flagDefinitionsLoadedAt !== undefined)
|
|
@@ -4878,7 +6564,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4878
6564
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
4879
6565
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4880
6566
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4881
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
6567
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
|
|
4882
6568
|
if (onlyEvaluateLocally == undefined)
|
|
4883
6569
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
4884
6570
|
const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys);
|
|
@@ -4891,7 +6577,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4891
6577
|
fallbackToFlags = localEvaluationResult.fallbackToFlags;
|
|
4892
6578
|
}
|
|
4893
6579
|
if (fallbackToFlags && !onlyEvaluateLocally) {
|
|
4894
|
-
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6580
|
+
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
|
|
4895
6581
|
featureFlags = {
|
|
4896
6582
|
...featureFlags,
|
|
4897
6583
|
...remoteEvaluationResult.flags || {}
|
|
@@ -4939,9 +6625,10 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4939
6625
|
const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
4940
6626
|
personProperties = adjustedProperties.allPersonProperties;
|
|
4941
6627
|
groupProperties = adjustedProperties.allGroupProperties;
|
|
4942
|
-
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
|
|
6628
|
+
const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
|
|
4943
6629
|
if (onlyEvaluateLocally == undefined)
|
|
4944
6630
|
onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
|
|
6631
|
+
const requestedFlagKeys = flagKeys ? new Set(flagKeys) : undefined;
|
|
4945
6632
|
const records = {};
|
|
4946
6633
|
let requestId;
|
|
4947
6634
|
let evaluatedAt;
|
|
@@ -4960,14 +6647,17 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4960
6647
|
id: flagDef?.id,
|
|
4961
6648
|
version: undefined,
|
|
4962
6649
|
reason: "Evaluated locally",
|
|
4963
|
-
locallyEvaluated: true
|
|
6650
|
+
locallyEvaluated: true,
|
|
6651
|
+
hasExperiment: flagDef?.has_experiment
|
|
4964
6652
|
};
|
|
4965
6653
|
locallyEvaluatedKeys.add(key);
|
|
4966
6654
|
}
|
|
4967
|
-
const
|
|
6655
|
+
const requestedFlagMissingLocally = requestedFlagKeys !== undefined && Array.from(requestedFlagKeys).some((key) => this.featureFlagsPoller?.featureFlagsByKey[key] === undefined);
|
|
6656
|
+
const fallbackToFlags = localResult ? localResult.fallbackToFlags || requestedFlagMissingLocally : true;
|
|
4968
6657
|
if (fallbackToFlags && !onlyEvaluateLocally) {
|
|
4969
|
-
const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups,
|
|
6658
|
+
const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
|
|
4970
6659
|
if (details) {
|
|
6660
|
+
this._minimalFlagCalledEvents = details.minimalFlagCalledEvents === true;
|
|
4971
6661
|
requestId = details.requestId;
|
|
4972
6662
|
evaluatedAt = details.evaluatedAt;
|
|
4973
6663
|
errorsWhileComputing = Boolean(details.errorsWhileComputingFlags);
|
|
@@ -4990,7 +6680,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
4990
6680
|
id: detail.metadata?.id,
|
|
4991
6681
|
version: detail.metadata?.version,
|
|
4992
6682
|
reason: detail.reason?.description ?? detail.reason?.code,
|
|
4993
|
-
locallyEvaluated: false
|
|
6683
|
+
locallyEvaluated: false,
|
|
6684
|
+
hasExperiment: detail.metadata?.has_experiment
|
|
4994
6685
|
};
|
|
4995
6686
|
}
|
|
4996
6687
|
}
|
|
@@ -5010,7 +6701,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5010
6701
|
id: existing?.id,
|
|
5011
6702
|
version: existing?.version,
|
|
5012
6703
|
reason: existing?.reason,
|
|
5013
|
-
locallyEvaluated: existing?.locallyEvaluated ?? false
|
|
6704
|
+
locallyEvaluated: existing?.locallyEvaluated ?? false,
|
|
6705
|
+
hasExperiment: existing?.hasExperiment
|
|
5014
6706
|
};
|
|
5015
6707
|
}
|
|
5016
6708
|
if (this._payloadOverrides !== undefined)
|
|
@@ -5022,6 +6714,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5022
6714
|
payload
|
|
5023
6715
|
};
|
|
5024
6716
|
}
|
|
6717
|
+
if (requestedFlagKeys !== undefined) {
|
|
6718
|
+
for (const key of Object.keys(records))
|
|
6719
|
+
if (!requestedFlagKeys.has(key))
|
|
6720
|
+
delete records[key];
|
|
6721
|
+
}
|
|
5025
6722
|
return new FeatureFlagEvaluations({
|
|
5026
6723
|
host: this._getFeatureFlagEvaluationsHost(),
|
|
5027
6724
|
distinctId: resolvedDistinctId,
|
|
@@ -5035,6 +6732,9 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5035
6732
|
quotaLimited
|
|
5036
6733
|
});
|
|
5037
6734
|
}
|
|
6735
|
+
_shouldSendMinimalFlagCalledEvent(event, properties) {
|
|
6736
|
+
return event === "$feature_flag_called" && this._minimalFlagCalledEvents && properties.$feature_flag_has_experiment === false;
|
|
6737
|
+
}
|
|
5038
6738
|
_captureFlagCalledEventIfNeeded(params) {
|
|
5039
6739
|
const { distinctId, key, response, groups, disableGeoip, properties } = params;
|
|
5040
6740
|
const groupSuffix = groups && Object.keys(groups).length > 0 ? `_${JSON.stringify(Object.entries(groups).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0))}` : "";
|
|
@@ -5069,9 +6769,32 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5069
6769
|
return this._featureFlagEvaluationsHost;
|
|
5070
6770
|
}
|
|
5071
6771
|
groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
5072
|
-
|
|
6772
|
+
this._sendPreparedEvent("capture", {
|
|
6773
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
6774
|
+
event: "$groupidentify",
|
|
6775
|
+
properties: {
|
|
6776
|
+
$group_type: groupType,
|
|
6777
|
+
$group_key: groupKey,
|
|
6778
|
+
$group_set: properties || {}
|
|
6779
|
+
},
|
|
6780
|
+
disableGeoip
|
|
6781
|
+
}, false, {
|
|
6782
|
+
includeContextProperties: false
|
|
6783
|
+
});
|
|
6784
|
+
}
|
|
6785
|
+
async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
6786
|
+
await this._sendPreparedEvent("capture", {
|
|
6787
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
6788
|
+
event: "$groupidentify",
|
|
6789
|
+
properties: {
|
|
6790
|
+
$group_type: groupType,
|
|
6791
|
+
$group_key: groupKey,
|
|
6792
|
+
$group_set: properties || {}
|
|
6793
|
+
},
|
|
5073
6794
|
disableGeoip
|
|
5074
|
-
},
|
|
6795
|
+
}, true, {
|
|
6796
|
+
includeContextProperties: false
|
|
6797
|
+
});
|
|
5075
6798
|
}
|
|
5076
6799
|
async reloadFeatureFlags() {
|
|
5077
6800
|
await this.featureFlagsPoller?.loadFeatureFlags(true);
|
|
@@ -5143,12 +6866,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5143
6866
|
this.context?.enter(data, options);
|
|
5144
6867
|
}
|
|
5145
6868
|
async _shutdown(shutdownTimeoutMs) {
|
|
6869
|
+
const shutdownDeadlineMs = Date.now() + (shutdownTimeoutMs ?? 30000);
|
|
5146
6870
|
const resolve = this._consumeWaitUntilCycle();
|
|
5147
6871
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
5148
6872
|
this.errorTracking.shutdown();
|
|
6873
|
+
if (this._metrics) {
|
|
6874
|
+
await raceWithTimeout(this._metrics.flush().catch(() => {}), Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
6875
|
+
this._metrics.reset();
|
|
6876
|
+
}
|
|
5149
6877
|
try {
|
|
5150
|
-
return await super._shutdown(
|
|
6878
|
+
return await super._shutdown(Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
5151
6879
|
} finally {
|
|
6880
|
+
this.distinctIdHasSentFlagCalls = {};
|
|
5152
6881
|
resolve?.();
|
|
5153
6882
|
}
|
|
5154
6883
|
}
|
|
@@ -5243,7 +6972,6 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5243
6972
|
}
|
|
5244
6973
|
addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties) {
|
|
5245
6974
|
const allPersonProperties = {
|
|
5246
|
-
distinct_id: distinctId,
|
|
5247
6975
|
...personProperties || {}
|
|
5248
6976
|
};
|
|
5249
6977
|
const allGroupProperties = {};
|
|
@@ -5258,6 +6986,12 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5258
6986
|
allGroupProperties
|
|
5259
6987
|
};
|
|
5260
6988
|
}
|
|
6989
|
+
personPropertiesForLocalEvaluation(distinctId, personProperties) {
|
|
6990
|
+
return {
|
|
6991
|
+
distinct_id: distinctId,
|
|
6992
|
+
...personProperties || {}
|
|
6993
|
+
};
|
|
6994
|
+
}
|
|
5261
6995
|
createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties) {
|
|
5262
6996
|
return {
|
|
5263
6997
|
distinctId,
|
|
@@ -5268,21 +7002,21 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5268
7002
|
};
|
|
5269
7003
|
}
|
|
5270
7004
|
captureException(error, distinctId, additionalProperties, uuid, flags) {
|
|
5271
|
-
if (!
|
|
7005
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
5272
7006
|
const syntheticException = new Error("PostHog syntheticException");
|
|
5273
|
-
this.addPendingPromise(
|
|
7007
|
+
this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
5274
7008
|
syntheticException
|
|
5275
|
-
}, distinctId, additionalProperties).then((msg) => this.
|
|
7009
|
+
}, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
|
|
5276
7010
|
...msg,
|
|
5277
7011
|
uuid,
|
|
5278
7012
|
flags
|
|
5279
|
-
})));
|
|
7013
|
+
}, false)));
|
|
5280
7014
|
}
|
|
5281
7015
|
}
|
|
5282
7016
|
async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
|
|
5283
|
-
if (!
|
|
7017
|
+
if (!error_tracking_ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
5284
7018
|
const syntheticException = new Error("PostHog syntheticException");
|
|
5285
|
-
return this.addPendingPromise(
|
|
7019
|
+
return this.addPendingPromise(error_tracking_ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
5286
7020
|
syntheticException
|
|
5287
7021
|
}, distinctId, additionalProperties).then((msg) => this.captureImmediate({
|
|
5288
7022
|
...msg,
|
|
@@ -5291,24 +7025,31 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5291
7025
|
}
|
|
5292
7026
|
}
|
|
5293
7027
|
async prepareEventMessage(props) {
|
|
7028
|
+
return this._prepareEventMessage(props);
|
|
7029
|
+
}
|
|
7030
|
+
async _prepareEventMessage(props, options = {}) {
|
|
5294
7031
|
const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
|
|
5295
7032
|
const contextData = this.context?.get();
|
|
7033
|
+
const includeContextProperties = options.includeContextProperties ?? true;
|
|
5296
7034
|
let mergedDistinctId = distinctId || contextData?.distinctId;
|
|
5297
|
-
const mergedProperties = {
|
|
7035
|
+
const mergedProperties = includeContextProperties ? {
|
|
5298
7036
|
...this.props,
|
|
5299
7037
|
...contextData?.properties || {},
|
|
5300
7038
|
...properties || {}
|
|
7039
|
+
} : {
|
|
7040
|
+
...properties || {}
|
|
5301
7041
|
};
|
|
5302
7042
|
if (!mergedDistinctId) {
|
|
5303
7043
|
mergedDistinctId = uuidv7();
|
|
5304
7044
|
mergedProperties.$process_person_profile = false;
|
|
5305
7045
|
}
|
|
5306
|
-
if (contextData?.sessionId && !mergedProperties.$session_id)
|
|
7046
|
+
if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id)
|
|
5307
7047
|
mergedProperties.$session_id = contextData.sessionId;
|
|
7048
|
+
const finalProperties = this._shouldSendMinimalFlagCalledEvent(event, mergedProperties) ? minimizeFlagCalledEventProperties(mergedProperties) : mergedProperties;
|
|
5308
7049
|
const eventMessage = this._runBeforeSend({
|
|
5309
7050
|
distinctId: mergedDistinctId,
|
|
5310
7051
|
event,
|
|
5311
|
-
properties:
|
|
7052
|
+
properties: finalProperties,
|
|
5312
7053
|
groups,
|
|
5313
7054
|
flags,
|
|
5314
7055
|
sendFeatureFlags,
|
|
@@ -5332,12 +7073,14 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5332
7073
|
}
|
|
5333
7074
|
return {};
|
|
5334
7075
|
}).catch(() => ({})).then((additionalProperties) => {
|
|
5335
|
-
const
|
|
7076
|
+
const resolvedGroups = eventMessage.groups || groups;
|
|
7077
|
+
return {
|
|
5336
7078
|
...additionalProperties,
|
|
5337
7079
|
...eventMessage.properties || {},
|
|
5338
|
-
|
|
7080
|
+
...resolvedGroups !== undefined && Object.keys(resolvedGroups).length > 0 ? {
|
|
7081
|
+
$groups: resolvedGroups
|
|
7082
|
+
} : {}
|
|
5339
7083
|
};
|
|
5340
|
-
return props2;
|
|
5341
7084
|
});
|
|
5342
7085
|
if (eventMessage.event === "$pageview" && this.options.__preview_capture_bot_pageviews && typeof eventProperties.$raw_user_agent == "string") {
|
|
5343
7086
|
if (isBlockedUA(eventProperties.$raw_user_agent, this.options.custom_blocked_useragents || [])) {
|
|
@@ -5364,22 +7107,26 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
5364
7107
|
beforeSend
|
|
5365
7108
|
];
|
|
5366
7109
|
let result = eventMessage;
|
|
5367
|
-
for (const fn of fns)
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
7110
|
+
for (const fn of fns)
|
|
7111
|
+
try {
|
|
7112
|
+
result = fn(result);
|
|
7113
|
+
if (!result) {
|
|
7114
|
+
this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
|
|
7115
|
+
return null;
|
|
7116
|
+
}
|
|
7117
|
+
if (!result.properties || Object.keys(result.properties).length === 0) {
|
|
7118
|
+
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
7119
|
+
this._logger.warn(message);
|
|
7120
|
+
}
|
|
7121
|
+
} catch (error) {
|
|
7122
|
+
this._logger.error(`Error in before_send function for event '${eventMessage.event}':`, error);
|
|
5371
7123
|
return null;
|
|
5372
7124
|
}
|
|
5373
|
-
if (!result.properties || Object.keys(result.properties).length === 0) {
|
|
5374
|
-
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
5375
|
-
this._logger.warn(message);
|
|
5376
|
-
}
|
|
5377
|
-
}
|
|
5378
7125
|
return result;
|
|
5379
7126
|
}
|
|
5380
7127
|
}
|
|
5381
7128
|
|
|
5382
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
7129
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/context/context.mjs
|
|
5383
7130
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5384
7131
|
|
|
5385
7132
|
class PostHogContext {
|
|
@@ -5410,7 +7157,22 @@ class PostHogContext {
|
|
|
5410
7157
|
}
|
|
5411
7158
|
}
|
|
5412
7159
|
|
|
5413
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
7160
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/gzip.node.mjs
|
|
7161
|
+
import { gzip } from "node:zlib";
|
|
7162
|
+
import { promisify } from "node:util";
|
|
7163
|
+
var gzipAsync = promisify(gzip);
|
|
7164
|
+
async function gzipCompress2(input, isDebug = true) {
|
|
7165
|
+
try {
|
|
7166
|
+
const compressed = await gzipAsync(input);
|
|
7167
|
+
return new Uint8Array(compressed);
|
|
7168
|
+
} catch (error) {
|
|
7169
|
+
if (isDebug)
|
|
7170
|
+
console.error("Failed to gzip compress data", error);
|
|
7171
|
+
return null;
|
|
7172
|
+
}
|
|
7173
|
+
}
|
|
7174
|
+
|
|
7175
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
|
|
5414
7176
|
var NAME = "posthog-node";
|
|
5415
7177
|
function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
|
|
5416
7178
|
"error"
|
|
@@ -5450,6 +7212,9 @@ function createEventProcessor(_posthog, { organization, projectId, prefix, sever
|
|
|
5450
7212
|
$sentry_exception_type: exceptions[0]?.type,
|
|
5451
7213
|
$sentry_tags: event.tags
|
|
5452
7214
|
};
|
|
7215
|
+
const injectedReleaseId = getInjectedReleaseId();
|
|
7216
|
+
if (injectedReleaseId)
|
|
7217
|
+
properties.$release_id = injectedReleaseId;
|
|
5453
7218
|
if (organization && projectId)
|
|
5454
7219
|
properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
|
|
5455
7220
|
if (sendExceptionsToPostHog)
|
|
@@ -5478,24 +7243,27 @@ class PostHogSentryIntegration {
|
|
|
5478
7243
|
};
|
|
5479
7244
|
}
|
|
5480
7245
|
}
|
|
5481
|
-
// ../../../../../node_modules/.bun/posthog-node@5.
|
|
7246
|
+
// ../../../../../node_modules/.bun/posthog-node@5.51.1/node_modules/posthog-node/dist/entrypoints/index.node.mjs
|
|
5482
7247
|
class PostHog extends PostHogBackendClient {
|
|
5483
7248
|
getLibraryId() {
|
|
5484
7249
|
return "posthog-node";
|
|
5485
7250
|
}
|
|
7251
|
+
compressPayload(payload) {
|
|
7252
|
+
return gzipCompress2(payload, this.isDebug);
|
|
7253
|
+
}
|
|
5486
7254
|
initializeContext() {
|
|
5487
7255
|
return new PostHogContext;
|
|
5488
7256
|
}
|
|
5489
7257
|
createErrorPropertiesBuilder() {
|
|
5490
|
-
return new
|
|
5491
|
-
new
|
|
5492
|
-
new
|
|
5493
|
-
new
|
|
5494
|
-
new
|
|
5495
|
-
new
|
|
5496
|
-
],
|
|
7258
|
+
return new ErrorPropertiesBuilder([
|
|
7259
|
+
new EventCoercer,
|
|
7260
|
+
new ErrorCoercer,
|
|
7261
|
+
new ObjectCoercer,
|
|
7262
|
+
new StringCoercer,
|
|
7263
|
+
new PrimitiveCoercer
|
|
7264
|
+
], createStackParser("node:javascript", nodeStackLineParser), [
|
|
5497
7265
|
createModulerModifier(),
|
|
5498
|
-
addSourceContext,
|
|
7266
|
+
(frames) => addSourceContext(frames, undefined, this._logger),
|
|
5499
7267
|
createRelativePathModifier()
|
|
5500
7268
|
]);
|
|
5501
7269
|
}
|
|
@@ -5816,11 +7584,11 @@ function getPostHogDistinctIdForTesting(osProvider) {
|
|
|
5816
7584
|
return getTelemetryDistinctId(MACHINE_ID_PREFIX, osProvider);
|
|
5817
7585
|
}
|
|
5818
7586
|
export {
|
|
5819
|
-
|
|
5820
|
-
getPostHogDistinctId,
|
|
5821
|
-
getComponentVersion,
|
|
5822
|
-
createPluginPostHog,
|
|
5823
|
-
__createPluginPostHogForTesting,
|
|
7587
|
+
DEFAULT_POSTHOG_API_KEY,
|
|
5824
7588
|
DEFAULT_POSTHOG_HOST,
|
|
5825
|
-
|
|
7589
|
+
__createPluginPostHogForTesting,
|
|
7590
|
+
createPluginPostHog,
|
|
7591
|
+
getComponentVersion,
|
|
7592
|
+
getPostHogDistinctId,
|
|
7593
|
+
getPostHogDistinctIdForTesting
|
|
5826
7594
|
};
|