@atrim/instrument-web 0.5.0-11e06b7-20251119014031 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atrim/instrument-web",
3
- "version": "0.5.0-11e06b7-20251119014031",
3
+ "version": "0.5.0",
4
4
  "description": "OpenTelemetry instrumentation for browsers with centralized YAML configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -82,10 +82,10 @@
82
82
  "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
83
83
  "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
84
84
  "clean": "rm -rf target",
85
- "publish:dev:version": "pnpm version $(node -p \"require('./package.json').version\")-$(git rev-parse --short HEAD)-$(date -u +%Y%m%d%H%M%S) --no-git-tag-version",
85
+ "publish:dev:version": "npm version $(git describe --tags --abbrev=0 | sed 's/^.*@//' | sed 's/^v//')-$(git rev-parse --short HEAD)-$(date -u +%Y%m%d%H%M%S) --no-git-tag-version",
86
86
  "publish:dev:save": "node -p \"require('./package.json').version\" > .version",
87
87
  "publish:dev:publish": "pnpm build && pnpm publish --tag dev --access public --no-git-checks",
88
- "publish:dev:reset": "pnpm version 0.5.0 --no-git-tag-version",
88
+ "publish:dev:reset": "npm version 0.1.0 --no-git-tag-version",
89
89
  "publish:dev": "pnpm publish:dev:version && pnpm publish:dev:save && pnpm publish:dev:publish && pnpm publish:dev:reset"
90
90
  }
91
91
  }
@@ -70,31 +70,6 @@ interface SdkInitializationOptions {
70
70
  * @default true
71
71
  */
72
72
  enableXhr?: boolean;
73
- /**
74
- * Control trace context propagation for cross-origin requests
75
- *
76
- * Determines which cross-origin requests receive W3C Trace Context headers
77
- * (traceparent, tracestate). Note: Backends must allow these headers in CORS
78
- * configuration or requests will fail with CORS errors.
79
- *
80
- * - 'all': Propagate to all cross-origin requests (may cause CORS errors)
81
- * - 'none': Never propagate trace headers
82
- * - 'same-origin': Only propagate to same-origin requests (default)
83
- * - Array of URL patterns: Custom propagation patterns (regex strings)
84
- *
85
- * @default 'same-origin'
86
- *
87
- * @example Propagate to specific API domains
88
- * ```typescript
89
- * propagateTraceContext: ['^https://api\\.myapp\\.com', '^http://localhost:300[0-9]']
90
- * ```
91
- *
92
- * @example Disable propagation (for debugging CORS issues)
93
- * ```typescript
94
- * propagateTraceContext: 'none'
95
- * ```
96
- */
97
- propagateTraceContext?: 'all' | 'none' | 'same-origin' | string[];
98
73
  }
99
74
  /**
100
75
  * Get the current SDK instance
@@ -4095,20 +4095,7 @@ var HttpFilteringConfigSchema = external_exports.object({
4095
4095
  // Patterns to ignore for incoming HTTP requests (string patterns only in YAML)
4096
4096
  ignore_incoming_paths: external_exports.array(external_exports.string()).optional(),
4097
4097
  // Require parent span for outgoing requests (prevents root spans for HTTP calls)
4098
- require_parent_for_outgoing_spans: external_exports.boolean().optional(),
4099
- // Trace context propagation configuration
4100
- // Controls which cross-origin requests receive W3C Trace Context headers (traceparent, tracestate)
4101
- propagate_trace_context: external_exports.object({
4102
- // Strategy for trace propagation
4103
- // - "all": Propagate to all cross-origin requests (may cause CORS errors)
4104
- // - "none": Never propagate trace headers
4105
- // - "same-origin": Only propagate to same-origin requests (default, safe)
4106
- // - "patterns": Propagate based on include_urls patterns
4107
- strategy: external_exports.enum(["all", "none", "same-origin", "patterns"]).default("same-origin"),
4108
- // URL patterns to include when strategy is "patterns"
4109
- // Supports regex patterns (e.g., "^https://api\\.myapp\\.com")
4110
- include_urls: external_exports.array(external_exports.string()).optional()
4111
- }).optional()
4098
+ require_parent_for_outgoing_spans: external_exports.boolean().optional()
4112
4099
  });
4113
4100
  var InstrumentationConfigSchema = external_exports.object({
4114
4101
  version: external_exports.string(),
@@ -4539,54 +4526,6 @@ var PatternSpanProcessor = class {
4539
4526
 
4540
4527
  // src/core/sdk-initializer.ts
4541
4528
  var sdkInstance = null;
4542
- function buildPropagateTraceUrls(options, config) {
4543
- const apiOption = options.propagateTraceContext;
4544
- const yamlStrategy = config?.http?.propagate_trace_context?.strategy;
4545
- const yamlIncludeUrls = config?.http?.propagate_trace_context?.include_urls;
4546
- let effectiveStrategy;
4547
- let patterns = [];
4548
- if (apiOption !== void 0) {
4549
- if (typeof apiOption === "string") {
4550
- effectiveStrategy = apiOption;
4551
- } else {
4552
- effectiveStrategy = "patterns";
4553
- patterns = apiOption;
4554
- }
4555
- } else if (yamlStrategy) {
4556
- effectiveStrategy = yamlStrategy;
4557
- if (effectiveStrategy === "patterns" && yamlIncludeUrls) {
4558
- patterns = yamlIncludeUrls;
4559
- }
4560
- } else {
4561
- effectiveStrategy = "same-origin";
4562
- }
4563
- switch (effectiveStrategy) {
4564
- case "all":
4565
- return [/.*/];
4566
- case "none":
4567
- case "same-origin":
4568
- return [];
4569
- case "patterns": {
4570
- const regexes = [];
4571
- for (const pattern of patterns) {
4572
- try {
4573
- regexes.push(new RegExp(pattern));
4574
- } catch (error) {
4575
- console.warn(
4576
- `[@atrim/instrument-web] Invalid trace propagation pattern: "${pattern}"`,
4577
- error
4578
- );
4579
- }
4580
- }
4581
- return regexes;
4582
- }
4583
- default:
4584
- console.warn(
4585
- `[@atrim/instrument-web] Unknown trace propagation strategy: "${effectiveStrategy}". Defaulting to same-origin only.`
4586
- );
4587
- return [];
4588
- }
4589
- }
4590
4529
  async function initializeSdk(options) {
4591
4530
  if (sdkInstance) {
4592
4531
  return sdkInstance;
@@ -4624,7 +4563,6 @@ async function initializeSdk(options) {
4624
4563
  "[@atrim/instrument-web] Missing http.ignore_outgoing_urls in instrumentation.yaml. Using default OTLP endpoint patterns only. Consider adding http filtering to your config for better control."
4625
4564
  );
4626
4565
  }
4627
- const propagateTraceUrls = buildPropagateTraceUrls(options, config);
4628
4566
  const exporterOptions = {};
4629
4567
  if (options.otlpEndpoint) {
4630
4568
  exporterOptions.endpoint = options.otlpEndpoint;
@@ -4656,16 +4594,15 @@ async function initializeSdk(options) {
4656
4594
  },
4657
4595
  "@opentelemetry/instrumentation-fetch": {
4658
4596
  enabled: options.enableFetch ?? true,
4659
- propagateTraceHeaderCorsUrls: propagateTraceUrls,
4660
- // Controlled by config/API
4597
+ propagateTraceHeaderCorsUrls: [/.*/],
4598
+ // Propagate to all origins
4661
4599
  clearTimingResources: true,
4662
4600
  ignoreUrls
4663
4601
  // Prevent self-instrumentation of OTLP exports
4664
4602
  },
4665
4603
  "@opentelemetry/instrumentation-xml-http-request": {
4666
4604
  enabled: options.enableXhr ?? true,
4667
- propagateTraceHeaderCorsUrls: propagateTraceUrls
4668
- // Controlled by config/API
4605
+ propagateTraceHeaderCorsUrls: [/.*/]
4669
4606
  }
4670
4607
  })
4671
4608
  ]