dd-trace 6.23.0 → 6.25.0
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/LICENSE-3rdparty.csv +0 -1
- package/ci/cypress/support.js +15 -1
- package/ci/init.js +2 -22
- package/ci/test-annotations.d.ts +5 -0
- package/ci/test-annotations.js +5 -0
- package/ci/vitest-no-worker-init-annotations.mjs +4 -0
- package/ci/vitest-no-worker-init-node-setup.mjs +22 -0
- package/ci/vitest-no-worker-init-runner-setup.mjs +7 -32
- package/ci/vitest-no-worker-init-setup.mjs +34 -12
- package/ci/vitest-no-worker-init-v5-setup.mjs +6 -0
- package/ext/exporters.js +1 -1
- package/index.d.ts +124 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/loader-hook.mjs +53 -0
- package/openfeature/exposure-hook.d.ts +66 -0
- package/openfeature/exposure-hook.js +5 -0
- package/package.json +19 -15
- package/packages/datadog-core/src/storage.js +1 -1
- package/packages/datadog-esbuild/index.js +78 -62
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +56 -19
- package/packages/datadog-instrumentations/src/cypress-config.js +163 -15
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +29 -20
- package/packages/datadog-instrumentations/src/grpc/server.js +23 -6
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +5 -1
- package/packages/datadog-instrumentations/src/helpers/graphql-jit-runtime.js +30 -8
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -8
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +18 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql-jit.js +3 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/react-router.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/typesafe.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +58 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.js +19 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +25 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/jest.js +265 -82
- package/packages/datadog-instrumentations/src/mariadb-bundle.js +69 -11
- package/packages/datadog-instrumentations/src/mariadb.js +13 -6
- package/packages/datadog-instrumentations/src/mocha/common.js +89 -8
- package/packages/datadog-instrumentations/src/mocha/main.js +11 -2
- package/packages/datadog-instrumentations/src/mocha/utils.js +58 -12
- package/packages/datadog-instrumentations/src/mocha/worker.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/oracledb.js +33 -0
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +81 -28
- package/packages/datadog-instrumentations/src/react-router.js +106 -0
- package/packages/datadog-instrumentations/src/typesafe.js +89 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +84 -48
- package/packages/datadog-instrumentations/src/vitest-main.js +26 -0
- package/packages/datadog-instrumentations/src/vitest-test-annotations.js +20 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +39 -17
- package/packages/datadog-instrumentations/src/vitest.js +10 -8
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cucumber/src/index.js +5 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +296 -55
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/lifecycle-owner.js +20 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +10 -0
- package/packages/datadog-plugin-cypress/src/retry-config-observer.js +281 -0
- package/packages/datadog-plugin-cypress/src/setup-handoff.js +125 -0
- package/packages/datadog-plugin-cypress/src/support.js +1217 -439
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-graphql/src/execute.js +2 -2
- package/packages/datadog-plugin-graphql/src/utils.js +5 -5
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-jest/src/index.js +25 -3
- package/packages/datadog-plugin-mocha/src/index.js +47 -6
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +21 -11
- package/packages/datadog-plugin-playwright/src/index.js +4 -0
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-react-router/src/index.js +118 -0
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-typesafe/src/index.js +17 -0
- package/packages/datadog-plugin-typesafe/src/tracing.js +31 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +8 -0
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/agent/info.js +2 -1
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -13
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +24 -18
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +16 -36
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -18
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +10 -15
- package/packages/dd-trace/src/ci-visibility/requests/route.js +44 -0
- package/packages/dd-trace/src/ci-visibility/telemetry-logs.js +5 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-annotations.js +72 -0
- package/packages/dd-trace/src/ci-visibility/test-declaration-annotations.js +170 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +10 -17
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +9 -3
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -2
- package/packages/dd-trace/src/config/index.js +111 -43
- package/packages/dd-trace/src/config/parsers.js +18 -1
- package/packages/dd-trace/src/config/supported-configurations.json +174 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/debugger/probe_sampler.js +6 -6
- package/packages/dd-trace/src/encode/0.4.js +2 -2
- package/packages/dd-trace/src/esm-module-load.js +58 -0
- package/packages/dd-trace/src/exporter.js +23 -15
- package/packages/dd-trace/src/exporters/agent/index.js +3 -1
- package/packages/dd-trace/src/exporters/agentless/index.js +3 -1
- package/packages/dd-trace/src/exporters/common/request.js +83 -50
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/exporters/llmobs/index.js +135 -0
- package/packages/dd-trace/src/exporters/log/index.js +4 -3
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +3 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/experiments/index.js +2 -3
- package/packages/dd-trace/src/llmobs/experiments/noop.js +5 -2
- package/packages/dd-trace/src/llmobs/index.js +13 -2
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +27 -10
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/typesafe/index.js +102 -0
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/prompts/cache.js +3 -1
- package/packages/dd-trace/src/llmobs/sdk.js +21 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +219 -12
- package/packages/dd-trace/src/llmobs/tagger.js +25 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -3
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +13 -2
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +68 -6
- package/packages/dd-trace/src/openfeature/configuration_source.js +41 -17
- package/packages/dd-trace/src/openfeature/debug-logging-hook.js +66 -3
- package/packages/dd-trace/src/openfeature/exposure-hook.js +185 -0
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +58 -14
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -3
- package/packages/dd-trace/src/openfeature/writers/base.js +63 -30
- package/packages/dd-trace/src/openfeature/writers/exposures.js +161 -1
- package/packages/dd-trace/src/openfeature/writers/flag-eval-evp-hook.js +5 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-aggregation.js +9 -4
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-payload.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/flag-evaluation-pii.js +2 -0
- package/packages/dd-trace/src/openfeature/writers/split-features.js +25 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +5 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +33 -13
- package/packages/dd-trace/src/otel-thread-ctx.js +72 -49
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +45 -14
- package/packages/dd-trace/src/plugins/index.js +9 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +273 -86
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +77 -50
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +90 -45
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +81 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +6 -3
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +48 -57
- package/packages/dd-trace/src/serverless.js +3 -2
- package/packages/dd-trace/src/span_processor.js +41 -9
- package/packages/dd-trace/src/span_stats.js +28 -2
- package/packages/dd-trace/src/startup-log.js +8 -5
- package/packages/dd-trace/src/tagger.js +7 -5
- package/packages/dd-trace/src/telemetry/dependencies.js +4 -0
- package/packages/dd-trace/src/telemetry/index.js +3 -0
- package/packages/dd-trace/src/telemetry/logs/index.js +21 -2
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +1 -0
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +10 -3
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/util.js +1 -1
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +4 -2
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/{@opentelemetry/resources → @datadog/flagging-core}/LICENSE +22 -2
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.d.ts +78 -0
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/index.js +1 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -19
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -650
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
- package/vendor/dist/@opentelemetry/resources/index.js +0 -1
|
@@ -118,7 +118,7 @@ class CypressPlugin extends Plugin {
|
|
|
118
118
|
payload.registered = true
|
|
119
119
|
// cypressPlugin.init expects the proxy tracer (with ._tracer._exporter),
|
|
120
120
|
// not the unwrapped internal tracer that this.tracer returns.
|
|
121
|
-
payload.configPromise = Promise.resolve(cypressPlugin.init(this._tracer, config))
|
|
121
|
+
payload.configPromise = Promise.resolve(cypressPlugin.init(this._tracer, config))
|
|
122
122
|
})
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Older manual support predates the shared installation marker. Its lifecycle
|
|
4
|
+
// still registers these two stable Datadog task hooks on the Mocha root.
|
|
5
|
+
function callsTask (hook, name) {
|
|
6
|
+
if (!hook || typeof hook.fn !== 'function') return false
|
|
7
|
+
// Keep string literals as single tokens and omit comments, so documentation
|
|
8
|
+
// or a quoted example cannot masquerade as an actual task invocation.
|
|
9
|
+
const tokens = Function.prototype.toString.call(hook.fn)
|
|
10
|
+
.match(/\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|[A-Za-z_$][\w$]*|[^\s]/g) || []
|
|
11
|
+
const code = tokens.filter(token => !token.startsWith('//') && !token.startsWith('/*'))
|
|
12
|
+
return code.some((token, index) => token === '.' && code[index + 1] === 'task' &&
|
|
13
|
+
code[index + 2] === '(' && (code[index + 3] === `"${name}"` || code[index + 3] === `'${name}'`))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = function hasCypressLifecycle (root) {
|
|
17
|
+
return Boolean(root && root._beforeAll && root._afterEach &&
|
|
18
|
+
root._beforeAll.some(hook => callsTask(hook, 'dd:testSuiteStart')) &&
|
|
19
|
+
root._afterEach.some(hook => callsTask(hook, 'dd:afterEach')))
|
|
20
|
+
}
|
|
@@ -12,6 +12,9 @@ const DD_CYPRESS_TASK_HANDLER = Symbol.for('dd-trace.cypress.task.handler')
|
|
|
12
12
|
const DD_CYPRESS_NOOP_TASK_HANDLER = Symbol.for('dd-trace.cypress.noop-task.handler')
|
|
13
13
|
|
|
14
14
|
const noopTask = {
|
|
15
|
+
'dd:testDeclarations': () => {
|
|
16
|
+
return null
|
|
17
|
+
},
|
|
15
18
|
'dd:testSuiteStart': () => {
|
|
16
19
|
return null
|
|
17
20
|
},
|
|
@@ -46,6 +49,13 @@ module.exports = function CypressPlugin (on, config) {
|
|
|
46
49
|
return config
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
// Browser retry intent must be observed before any user support code executes.
|
|
53
|
+
// Cypress 6's plugin process uses Node 12 and retains its existing manual path.
|
|
54
|
+
if (satisfies(config.version, '>=12.0.0')) {
|
|
55
|
+
const { installManualSupportFile } = require('../../datadog-instrumentations/src/cypress-config')
|
|
56
|
+
installManualSupportFile(config)
|
|
57
|
+
}
|
|
58
|
+
|
|
49
59
|
on('before:run', cypressPlugin.beforeRun.bind(cypressPlugin))
|
|
50
60
|
on('after:screenshot', cypressPlugin.getAfterScreenshotHandler())
|
|
51
61
|
const afterSpecHandler = cypressPlugin.afterSpec.bind(cypressPlugin)
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const observeSetupHandoff = require('./setup-handoff')
|
|
4
|
+
|
|
5
|
+
// Configuration inspection must not evaluate accessors before Cypress serializes them.
|
|
6
|
+
function snapshot (value, previous) {
|
|
7
|
+
if (!value || typeof value !== 'object') return value
|
|
8
|
+
const result = Array.isArray(value) ? [] : {}
|
|
9
|
+
for (const key of Object.keys(value)) {
|
|
10
|
+
const property = Object.getOwnPropertyDescriptor(value, key)
|
|
11
|
+
const entry = 'value' in property ? snapshot(property.value, previous?.[key]) : previous?.[key]
|
|
12
|
+
if (entry !== undefined) result[key] = entry
|
|
13
|
+
}
|
|
14
|
+
return result
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function snapshotMetadata (metadata) {
|
|
18
|
+
return metadata && { native: snapshot(metadata.native), observed: snapshot(metadata.observed) }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Observe user writes after plugin initialization without changing the config's identity.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} config
|
|
25
|
+
* @param {Function} onChange
|
|
26
|
+
* @param {{ nativeRetries: unknown, updateNative: Function, reconcileNative?: Function }} [options]
|
|
27
|
+
*/
|
|
28
|
+
module.exports = function observeRetryConfig (config, onChange, options) {
|
|
29
|
+
const descriptor = Object.getOwnPropertyDescriptor(config, 'retries')
|
|
30
|
+
if (!descriptor?.writable || !('value' in descriptor)) return
|
|
31
|
+
|
|
32
|
+
const initial = config.retries
|
|
33
|
+
let active = true
|
|
34
|
+
const roots = new WeakMap()
|
|
35
|
+
const targets = new WeakMap()
|
|
36
|
+
// Cypress keeps nested retry settings in first-level options objects.
|
|
37
|
+
const children = new WeakMap()
|
|
38
|
+
const unwrap = value => targets.get(value) || value
|
|
39
|
+
const rememberChild = (metadata, key, value) => {
|
|
40
|
+
const raw = unwrap(value)
|
|
41
|
+
if (!options || !raw || typeof raw !== 'object' || children.has(raw)) return
|
|
42
|
+
children.set(raw, { raw, native: metadata.native?.[key], observed: snapshot(raw) })
|
|
43
|
+
}
|
|
44
|
+
const refreshChild = (key, child) => {
|
|
45
|
+
if (!active || !options?.reconcileNative) return
|
|
46
|
+
child.native = options.reconcileNative(
|
|
47
|
+
{ [key]: child.native }, { [key]: child.observed }, { [key]: snapshot(child.raw, child.observed) }
|
|
48
|
+
)[key]
|
|
49
|
+
child.observed = snapshot(child.raw, child.observed)
|
|
50
|
+
}
|
|
51
|
+
const refreshNative = metadata => {
|
|
52
|
+
if (active && metadata && options?.reconcileNative) {
|
|
53
|
+
const actual = snapshot(metadata.raw, metadata.observed)
|
|
54
|
+
for (const key of Object.keys(actual)) {
|
|
55
|
+
const property = Object.getOwnPropertyDescriptor(metadata.raw, key)
|
|
56
|
+
const child = property && 'value' in property && children.get(unwrap(property.value))
|
|
57
|
+
if (child) {
|
|
58
|
+
refreshChild(key, child)
|
|
59
|
+
actual[key] = child.native
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
metadata.native = options.reconcileNative(metadata.native, metadata.observed, actual)
|
|
63
|
+
metadata.observed = snapshot(actual)
|
|
64
|
+
for (const key of Object.keys(metadata.raw)) {
|
|
65
|
+
const property = Object.getOwnPropertyDescriptor(metadata.raw, key)
|
|
66
|
+
if ('value' in property) rememberChild(metadata, key, property.value)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const refreshTarget = (metadata, path, target) => {
|
|
71
|
+
if (active && path.length === 1) {
|
|
72
|
+
const child = children.get(unwrap(target))
|
|
73
|
+
if (child) refreshChild(path[0], child)
|
|
74
|
+
}
|
|
75
|
+
refreshNative(metadata)
|
|
76
|
+
}
|
|
77
|
+
const notify = (value, path, metadata) => {
|
|
78
|
+
refreshNative(metadata)
|
|
79
|
+
let native
|
|
80
|
+
if (options) {
|
|
81
|
+
native = metadata ? metadata.native : options.updateNative(undefined, snapshot(value), [])
|
|
82
|
+
if (!metadata && value && typeof value === 'object') {
|
|
83
|
+
// A new root can select options already observed under another root.
|
|
84
|
+
for (const key of Object.keys(value)) {
|
|
85
|
+
const property = Object.getOwnPropertyDescriptor(value, key)
|
|
86
|
+
const child = property && 'value' in property && children.get(unwrap(property.value))
|
|
87
|
+
if (child) {
|
|
88
|
+
refreshChild(key, child)
|
|
89
|
+
native = options.updateNative(native, { [key]: child.native }, [key])
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const provenance = options && { retries: native }
|
|
95
|
+
onChange(value, path, provenance)
|
|
96
|
+
}
|
|
97
|
+
const initialMetadata = initial && typeof initial === 'object'
|
|
98
|
+
? {
|
|
99
|
+
raw: initial,
|
|
100
|
+
native: options?.nativeRetries,
|
|
101
|
+
proxies: new WeakMap(),
|
|
102
|
+
observed: options?.reconcileNative ? snapshot(initial) : undefined,
|
|
103
|
+
}
|
|
104
|
+
: undefined
|
|
105
|
+
if (initialMetadata) {
|
|
106
|
+
roots.set(initial, initialMetadata)
|
|
107
|
+
for (const key of Object.keys(initial)) {
|
|
108
|
+
const property = Object.getOwnPropertyDescriptor(initial, key)
|
|
109
|
+
if ('value' in property) rememberChild(initialMetadata, key, property.value)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const record = (metadata, path, target) => {
|
|
113
|
+
if (!active) return
|
|
114
|
+
if (options) {
|
|
115
|
+
const [key] = path
|
|
116
|
+
const child = path.length === 2 && children.get(unwrap(target))
|
|
117
|
+
if (child) {
|
|
118
|
+
refreshChild(key, child)
|
|
119
|
+
child.native = options.updateNative(
|
|
120
|
+
{ [key]: child.native }, { [key]: snapshot(child.raw, child.observed) }, path
|
|
121
|
+
)[key]
|
|
122
|
+
child.observed = snapshot(child.raw, child.observed)
|
|
123
|
+
// A saved options object can change while a different object is selected.
|
|
124
|
+
if (unwrap(Object.getOwnPropertyDescriptor(metadata.raw, key)?.value) !== child.raw) return
|
|
125
|
+
metadata.native = { ...metadata.native, [key]: child.native }
|
|
126
|
+
} else {
|
|
127
|
+
const restored = path.length === 1 && children.get(
|
|
128
|
+
unwrap(Object.getOwnPropertyDescriptor(metadata.raw, key)?.value)
|
|
129
|
+
)
|
|
130
|
+
if (restored) refreshChild(key, restored)
|
|
131
|
+
const actual = snapshot(metadata.raw, metadata.observed)
|
|
132
|
+
const supplied = restored ? { ...actual, [key]: restored.native } : actual
|
|
133
|
+
metadata.native = options.updateNative(metadata.native, supplied, path)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// A detached alias updates only its own provenance until that root is selected again.
|
|
137
|
+
const selected = Object.getOwnPropertyDescriptor(config, 'retries')?.value
|
|
138
|
+
if (metadata.raw === unwrap(selected)) notify(metadata.raw, path, metadata)
|
|
139
|
+
else refreshNative(metadata)
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @param {object} target
|
|
143
|
+
* @param {string|symbol} key
|
|
144
|
+
* @param {unknown} value
|
|
145
|
+
*/
|
|
146
|
+
const isSameObjectValue = (target, key, value) => {
|
|
147
|
+
const raw = unwrap(value)
|
|
148
|
+
const previous = Object.getOwnPropertyDescriptor(target, key)
|
|
149
|
+
return raw !== null && typeof raw === 'object' && previous &&
|
|
150
|
+
'value' in previous && raw === unwrap(previous.value)
|
|
151
|
+
}
|
|
152
|
+
const wrap = (value, metadata, path = []) => {
|
|
153
|
+
value = unwrap(value)
|
|
154
|
+
if (value === null || typeof value !== 'object') return value
|
|
155
|
+
if (path.length === 1 && options && !children.has(value)) {
|
|
156
|
+
refreshNative(metadata)
|
|
157
|
+
rememberChild(metadata, path[0], value)
|
|
158
|
+
}
|
|
159
|
+
if (metadata.proxies.has(value)) return metadata.proxies.get(value)
|
|
160
|
+
const proxy = new Proxy(value, {
|
|
161
|
+
get (target, key) {
|
|
162
|
+
const result = Reflect.get(target, key)
|
|
163
|
+
const property = Object.getOwnPropertyDescriptor(target, key)
|
|
164
|
+
// Frozen values must be returned unchanged to preserve Proxy invariants.
|
|
165
|
+
return property && !property.configurable && !property.writable && 'value' in property
|
|
166
|
+
? result
|
|
167
|
+
: wrap(result, metadata, [...path, key])
|
|
168
|
+
},
|
|
169
|
+
set (target, key, value) {
|
|
170
|
+
const sameObject = isSameObjectValue(target, key, value)
|
|
171
|
+
const result = Reflect.set(target, key, unwrap(value))
|
|
172
|
+
if (result) {
|
|
173
|
+
if (sameObject) refreshTarget(metadata, path, target)
|
|
174
|
+
else record(metadata, [...path, key], target)
|
|
175
|
+
}
|
|
176
|
+
return result
|
|
177
|
+
},
|
|
178
|
+
deleteProperty (target, key) {
|
|
179
|
+
const result = Reflect.deleteProperty(target, key)
|
|
180
|
+
if (result) record(metadata, [...path, key], target)
|
|
181
|
+
return result
|
|
182
|
+
},
|
|
183
|
+
defineProperty (target, key, property) {
|
|
184
|
+
const hasValue = 'value' in property
|
|
185
|
+
const sameObject = hasValue && isSameObjectValue(target, key, property.value)
|
|
186
|
+
const result = Reflect.defineProperty(target, key, property)
|
|
187
|
+
if (result) {
|
|
188
|
+
if (hasValue && !sameObject) record(metadata, [...path, key], target)
|
|
189
|
+
else refreshTarget(metadata, path, target)
|
|
190
|
+
}
|
|
191
|
+
return result
|
|
192
|
+
},
|
|
193
|
+
})
|
|
194
|
+
metadata.proxies.set(value, proxy)
|
|
195
|
+
targets.set(proxy, value)
|
|
196
|
+
return proxy
|
|
197
|
+
}
|
|
198
|
+
// Keep the native data descriptor: freeze/seal must retain JavaScript's own
|
|
199
|
+
// strict/sloppy write semantics. Fresh root replacements are reconciled by
|
|
200
|
+
// identity at the setup handoff; only injected objects need nested proxies.
|
|
201
|
+
config.retries = wrap(initial, initialMetadata)
|
|
202
|
+
|
|
203
|
+
// Cypress serializes the actual setupNodeEvents return value through this reply.
|
|
204
|
+
// Observing it before serialization also handles a fresh partial return when the
|
|
205
|
+
// manual plugin was loaded inside an already-running setup callback.
|
|
206
|
+
const stop = (reconcileCurrent = true) => {
|
|
207
|
+
if (active && reconcileCurrent) {
|
|
208
|
+
const retries = unwrap(config.retries)
|
|
209
|
+
notify(retries, [], retries && typeof retries === 'object' && roots.get(retries))
|
|
210
|
+
}
|
|
211
|
+
active = false
|
|
212
|
+
stopIpc?.()
|
|
213
|
+
const currentDescriptor = Object.getOwnPropertyDescriptor(config, 'retries')
|
|
214
|
+
if (currentDescriptor?.writable && targets.has(currentDescriptor.value)) {
|
|
215
|
+
config.retries = unwrap(currentDescriptor.value)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const stopIpc = observeSetupHandoff((returnedConfig, event, context) => {
|
|
219
|
+
try {
|
|
220
|
+
if (active && event === 'setupTestingType:reply') {
|
|
221
|
+
const property = returnedConfig && Object.getOwnPropertyDescriptor(returnedConfig, 'retries')
|
|
222
|
+
const retries = property?.enumerable ? returnedConfig.retries : undefined
|
|
223
|
+
const original = value => context?.originalFor(value) ?? value
|
|
224
|
+
const source = original(retries)
|
|
225
|
+
const raw = unwrap(source)
|
|
226
|
+
const cached = context?.snapshotFor(retries) ?? retries
|
|
227
|
+
const captured = context?.stateFor(cached)
|
|
228
|
+
const metadata = captured ? captured.root : raw && typeof raw === 'object' && roots.get(raw)
|
|
229
|
+
const actual = snapshot(cached, metadata?.observed)
|
|
230
|
+
let native = options && (metadata
|
|
231
|
+
? (options.reconcileNative
|
|
232
|
+
? options.reconcileNative(metadata.native, metadata.observed, actual)
|
|
233
|
+
: metadata.native)
|
|
234
|
+
: options.updateNative(undefined, actual, []))
|
|
235
|
+
if (options && actual && typeof actual === 'object') {
|
|
236
|
+
for (const key of Object.keys(actual)) {
|
|
237
|
+
const sourceChild = original(cached[key])
|
|
238
|
+
const rawChild = unwrap(sourceChild)
|
|
239
|
+
const capturedChild = context?.stateFor(cached[key])
|
|
240
|
+
const child = capturedChild
|
|
241
|
+
? capturedChild.child
|
|
242
|
+
: rawChild && typeof rawChild === 'object' && children.get(rawChild)
|
|
243
|
+
if (!child) continue
|
|
244
|
+
let childNative = options.reconcileNative
|
|
245
|
+
? options.reconcileNative(
|
|
246
|
+
{ [key]: child.native }, { [key]: child.observed }, { [key]: actual[key] }
|
|
247
|
+
)[key]
|
|
248
|
+
: child.native
|
|
249
|
+
if (context) {
|
|
250
|
+
for (const getterKey of context.getterKeys(cached[key])) {
|
|
251
|
+
childNative = options.updateNative(
|
|
252
|
+
{ [key]: childNative }, { [key]: actual[key] }, [key, getterKey]
|
|
253
|
+
)[key]
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
native = options.updateNative(native, { [key]: childNative }, [key])
|
|
257
|
+
}
|
|
258
|
+
if (context) {
|
|
259
|
+
for (const key of context.getterKeys(cached)) {
|
|
260
|
+
native = options.updateNative(native, actual, [key])
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
onChange(retries, [], options && { retries: native })
|
|
265
|
+
}
|
|
266
|
+
} finally {
|
|
267
|
+
// Later child-local writes cannot change the parent's serialized config.
|
|
268
|
+
stop(false)
|
|
269
|
+
}
|
|
270
|
+
}, unwrap, value => {
|
|
271
|
+
// Freeze provenance at this serialized occurrence. Later config getters can
|
|
272
|
+
// mutate the same retry object after its active value has already crossed IPC.
|
|
273
|
+
return { root: snapshotMetadata(roots.get(value)), child: snapshotMetadata(children.get(value)) }
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
isWatching: candidate => active && candidate === config,
|
|
278
|
+
stopIpc,
|
|
279
|
+
stop,
|
|
280
|
+
}
|
|
281
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Observe the actual setup serialization boundary without retaining ownership of process.send.
|
|
4
|
+
module.exports = function observeSetupHandoff (onHandoff, normalizeIdentity = value => value, captureIdentity) {
|
|
5
|
+
const originalSend = process.send
|
|
6
|
+
if (typeof originalSend !== 'function') return () => {}
|
|
7
|
+
let active = true
|
|
8
|
+
const stop = () => {
|
|
9
|
+
active = false
|
|
10
|
+
if (process.send === send) process.send = originalSend
|
|
11
|
+
}
|
|
12
|
+
const send = function (message) {
|
|
13
|
+
let forwardedArguments = arguments
|
|
14
|
+
if (active && (message?.event === 'setupTestingType:reply' || message?.event === 'setupTestingType:error')) {
|
|
15
|
+
try {
|
|
16
|
+
let wireConfig = message.event === 'setupTestingType:reply' && message.args?.[0]?.setupConfig
|
|
17
|
+
const snapshots = new WeakMap()
|
|
18
|
+
const originals = new WeakMap()
|
|
19
|
+
const getters = new WeakMap()
|
|
20
|
+
const states = new WeakMap()
|
|
21
|
+
const materialize = (value, propertyKey) => {
|
|
22
|
+
if (!value || typeof value !== 'object') return value
|
|
23
|
+
const identity = normalizeIdentity(value)
|
|
24
|
+
if (snapshots.has(identity)) return snapshots.get(identity)
|
|
25
|
+
const paths = new WeakMap()
|
|
26
|
+
const records = []
|
|
27
|
+
const occurrences = new WeakMap()
|
|
28
|
+
let holder
|
|
29
|
+
// JSON owns the traversal: earlier getters and toJSON methods can change
|
|
30
|
+
// later retry values. Observe the same values that will cross IPC once.
|
|
31
|
+
const serialized = JSON.stringify({ [propertyKey]: value }, function (key, current) {
|
|
32
|
+
if (!holder) holder = this
|
|
33
|
+
const path = this === holder ? [] : [...paths.get(this), key]
|
|
34
|
+
const property = Object.getOwnPropertyDescriptor(this, key)
|
|
35
|
+
if (property && !('value' in property)) occurrences.get(this)?.keys.add(key)
|
|
36
|
+
if (current && typeof current === 'object') {
|
|
37
|
+
const keys = new Set()
|
|
38
|
+
const names = Array.isArray(current) ? Object.getOwnPropertyNames(current) : Object.keys(current)
|
|
39
|
+
for (const name of names) {
|
|
40
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, name)
|
|
41
|
+
if (descriptor && !('value' in descriptor)) keys.add(name)
|
|
42
|
+
}
|
|
43
|
+
const original = normalizeIdentity(current)
|
|
44
|
+
const record = { path, original, keys, state: captureIdentity?.(original) }
|
|
45
|
+
paths.set(current, path)
|
|
46
|
+
occurrences.set(current, record)
|
|
47
|
+
records.push(record)
|
|
48
|
+
}
|
|
49
|
+
return current
|
|
50
|
+
})
|
|
51
|
+
const envelope = JSON.parse(serialized)
|
|
52
|
+
for (const { path, original, keys, state } of records) {
|
|
53
|
+
let snapshot = envelope
|
|
54
|
+
for (const key of path) snapshot = snapshot[key]
|
|
55
|
+
snapshots.set(original, snapshot)
|
|
56
|
+
if (snapshot && typeof snapshot === 'object') {
|
|
57
|
+
originals.set(snapshot, original)
|
|
58
|
+
snapshots.set(snapshot, snapshot)
|
|
59
|
+
getters.set(snapshot, keys)
|
|
60
|
+
states.set(snapshot, state)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return envelope[propertyKey]
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param {unknown} original
|
|
67
|
+
* @param {unknown} cached
|
|
68
|
+
*/
|
|
69
|
+
const selectOverrides = (original, cached) => {
|
|
70
|
+
if (!original || typeof original !== 'object' || !cached || typeof cached !== 'object') return cached
|
|
71
|
+
const prototype = Object.getPrototypeOf(original)
|
|
72
|
+
const source = originals.get(cached) || normalizeIdentity(cached)
|
|
73
|
+
if ((prototype !== Object.prototype && prototype !== null) || normalizeIdentity(original) === source ||
|
|
74
|
+
typeof Object.getOwnPropertyDescriptor(original, 'toJSON')?.value === 'function') return cached
|
|
75
|
+
// Keep partial-override membership, taking values from the occurrence already sent to Cypress.
|
|
76
|
+
return Object.fromEntries(Object.keys(original).flatMap(key => {
|
|
77
|
+
const property = Object.getOwnPropertyDescriptor(cached, key)
|
|
78
|
+
return property
|
|
79
|
+
? [[key, selectOverrides(Object.getOwnPropertyDescriptor(original, key).value, property.value)]]
|
|
80
|
+
: []
|
|
81
|
+
}))
|
|
82
|
+
}
|
|
83
|
+
if (wireConfig && typeof wireConfig === 'object') {
|
|
84
|
+
const cached = materialize(wireConfig, 'setupConfig')
|
|
85
|
+
if (cached !== wireConfig) {
|
|
86
|
+
const metadataKey = Symbol.for('dd-trace.cypress.returned-config')
|
|
87
|
+
const metadata = Object.getOwnPropertyDescriptor(wireConfig, metadataKey)
|
|
88
|
+
if (metadata && cached && typeof cached === 'object') {
|
|
89
|
+
Object.defineProperty(cached, metadataKey, metadata)
|
|
90
|
+
}
|
|
91
|
+
wireConfig = cached
|
|
92
|
+
forwardedArguments = [...arguments]
|
|
93
|
+
forwardedArguments[0] = {
|
|
94
|
+
...message,
|
|
95
|
+
args: [{ ...message.args[0], setupConfig: wireConfig }, ...message.args.slice(1)],
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const returnedConfig = wireConfig?.[Symbol.for('dd-trace.cypress.returned-config')] ?? wireConfig
|
|
100
|
+
const returnedDescriptor = returnedConfig && typeof returnedConfig === 'object' &&
|
|
101
|
+
Object.getOwnPropertyDescriptor(returnedConfig, 'retries')
|
|
102
|
+
let observedConfig
|
|
103
|
+
if (returnedDescriptor?.enumerable) {
|
|
104
|
+
const original = 'value' in returnedDescriptor ? returnedDescriptor.value : returnedConfig.retries
|
|
105
|
+
const wireRetry = wireConfig && typeof wireConfig === 'object' &&
|
|
106
|
+
Object.getOwnPropertyDescriptor(wireConfig, 'retries')
|
|
107
|
+
const wireValue = wireRetry && 'value' in wireRetry ? wireRetry.value : undefined
|
|
108
|
+
const cached = returnedConfig === wireConfig ? wireValue : selectOverrides(original, wireValue)
|
|
109
|
+
observedConfig = original === cached && 'value' in returnedDescriptor ? returnedConfig : { retries: cached }
|
|
110
|
+
}
|
|
111
|
+
onHandoff(observedConfig, message.event, {
|
|
112
|
+
originalFor: value => originals.get(value) || normalizeIdentity(value),
|
|
113
|
+
snapshotFor: value => snapshots.get(normalizeIdentity(value)) ?? value,
|
|
114
|
+
stateFor: value => states.get(normalizeIdentity(value)),
|
|
115
|
+
getterKeys: value => getters.get(normalizeIdentity(value)) || new Set(),
|
|
116
|
+
})
|
|
117
|
+
} finally {
|
|
118
|
+
stop()
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return originalSend.apply(this, forwardedArguments)
|
|
122
|
+
}
|
|
123
|
+
process.send = send
|
|
124
|
+
return stop
|
|
125
|
+
}
|