@servicetitan/journey 2.0.0 → 2.1.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.
Files changed (150) hide show
  1. package/dist/__test-utils__/test-runtime.d.ts.map +1 -0
  2. package/dist/__test-utils__/test-runtime.js +47 -0
  3. package/dist/__test-utils__/test-runtime.js.map +1 -0
  4. package/dist/__tests__/core/ambient.test.d.ts.map +1 -0
  5. package/dist/__tests__/core/api.test.d.ts +2 -0
  6. package/dist/__tests__/core/api.test.d.ts.map +1 -0
  7. package/dist/__tests__/core/define-journey.test.d.ts.map +1 -0
  8. package/dist/__tests__/core/requests.test.d.ts.map +1 -0
  9. package/dist/__tests__/core/runtime.test.d.ts.map +1 -0
  10. package/dist/__tests__/core/step.test.d.ts.map +1 -0
  11. package/dist/__tests__/core/timeouts.test.d.ts.map +1 -0
  12. package/dist/__tests__/global.test.d.ts +3 -0
  13. package/dist/__tests__/global.test.d.ts.map +1 -0
  14. package/dist/__tests__/integrations/axios.test.d.ts.map +1 -0
  15. package/dist/__tests__/integrations/context.test.d.ts.map +1 -0
  16. package/dist/__tests__/integrations/expose-app-journey.test.d.ts.map +1 -0
  17. package/dist/__tests__/integrations/fetch.test.d.ts.map +1 -0
  18. package/dist/__tests__/integrations/jquery.test.d.ts.map +1 -0
  19. package/dist/__tests__/integrations/request-key.test.d.ts.map +1 -0
  20. package/dist/__tests__/integrations/scope.test.d.ts.map +1 -0
  21. package/dist/__tests__/sinks/console.test.d.ts +2 -0
  22. package/dist/__tests__/sinks/console.test.d.ts.map +1 -0
  23. package/dist/__tests__/sinks/datadog.test.d.ts.map +1 -0
  24. package/dist/__tests__/sinks/sinks.test.d.ts.map +1 -0
  25. package/dist/config.d.ts +8 -4
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/config.js +19 -13
  28. package/dist/config.js.map +1 -1
  29. package/dist/core/{registry.d.ts → api.d.ts} +2 -22
  30. package/dist/core/api.d.ts.map +1 -0
  31. package/dist/core/{registry.js → api.js} +13 -40
  32. package/dist/core/api.js.map +1 -0
  33. package/dist/core/endpoint-policy.d.ts.map +1 -0
  34. package/dist/core/endpoint-policy.js.map +1 -0
  35. package/dist/core/index.d.ts +4 -4
  36. package/dist/core/index.d.ts.map +1 -1
  37. package/dist/core/index.js +3 -2
  38. package/dist/core/index.js.map +1 -1
  39. package/dist/core/runtime.d.ts +35 -7
  40. package/dist/core/runtime.d.ts.map +1 -1
  41. package/dist/core/runtime.js +39 -5
  42. package/dist/core/runtime.js.map +1 -1
  43. package/dist/core/step-tag.d.ts +6 -0
  44. package/dist/core/step-tag.d.ts.map +1 -1
  45. package/dist/core/step-tag.js +7 -0
  46. package/dist/core/step-tag.js.map +1 -1
  47. package/dist/core/types.d.ts +3 -1
  48. package/dist/core/types.d.ts.map +1 -1
  49. package/dist/core/types.js.map +1 -1
  50. package/dist/global.d.ts +67 -0
  51. package/dist/global.d.ts.map +1 -0
  52. package/dist/global.js +116 -0
  53. package/dist/global.js.map +1 -0
  54. package/dist/index.d.ts +8 -3
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +11 -5
  57. package/dist/index.js.map +1 -1
  58. package/dist/integrations/fetch.d.ts +3 -2
  59. package/dist/integrations/fetch.d.ts.map +1 -1
  60. package/dist/integrations/fetch.js.map +1 -1
  61. package/dist/integrations/jquery/index.d.ts +2 -2
  62. package/dist/integrations/jquery/index.d.ts.map +1 -1
  63. package/dist/integrations/jquery/index.js +3 -2
  64. package/dist/integrations/jquery/index.js.map +1 -1
  65. package/dist/integrations/react/scope.d.ts.map +1 -1
  66. package/dist/integrations/react/scope.js +3 -2
  67. package/dist/integrations/react/scope.js.map +1 -1
  68. package/dist/sinks/console.d.ts +11 -0
  69. package/dist/sinks/console.d.ts.map +1 -0
  70. package/dist/sinks/console.js +18 -0
  71. package/dist/sinks/console.js.map +1 -0
  72. package/dist/sinks/datadog.d.ts +12 -1
  73. package/dist/sinks/datadog.d.ts.map +1 -1
  74. package/dist/sinks/datadog.js +28 -7
  75. package/dist/sinks/datadog.js.map +1 -1
  76. package/package.json +2 -2
  77. package/src/{__mocks__ → __test-utils__}/test-runtime.ts +6 -2
  78. package/src/__tests__/config.test.ts +9 -12
  79. package/src/__tests__/{ambient.test.ts → core/ambient.test.ts} +8 -7
  80. package/src/__tests__/{registry.test.ts → core/api.test.ts} +30 -25
  81. package/src/__tests__/{define-journey.test.ts → core/define-journey.test.ts} +5 -4
  82. package/src/__tests__/{requests.test.ts → core/requests.test.ts} +12 -8
  83. package/src/__tests__/{runtime.test.ts → core/runtime.test.ts} +18 -18
  84. package/src/__tests__/{step.test.ts → core/step.test.ts} +16 -18
  85. package/src/__tests__/{timeouts.test.ts → core/timeouts.test.ts} +15 -10
  86. package/src/__tests__/global.test.ts +113 -0
  87. package/src/__tests__/{axios.test.ts → integrations/axios.test.ts} +46 -15
  88. package/src/__tests__/{context.test.tsx → integrations/context.test.tsx} +1 -1
  89. package/src/__tests__/{expose-app-journey.test.ts → integrations/expose-app-journey.test.ts} +2 -2
  90. package/src/__tests__/{fetch.test.ts → integrations/fetch.test.ts} +6 -6
  91. package/src/__tests__/{jquery.test.ts → integrations/jquery.test.ts} +49 -12
  92. package/src/__tests__/{request-key.test.ts → integrations/request-key.test.ts} +1 -1
  93. package/src/__tests__/{scope.test.tsx → integrations/scope.test.tsx} +4 -4
  94. package/src/__tests__/sinks/console.test.ts +98 -0
  95. package/src/__tests__/{datadog.test.ts → sinks/datadog.test.ts} +62 -5
  96. package/src/__tests__/{sinks.test.ts → sinks/sinks.test.ts} +13 -12
  97. package/src/config.ts +20 -12
  98. package/src/core/{registry.ts → api.ts} +12 -65
  99. package/src/core/index.ts +5 -14
  100. package/src/core/runtime.ts +56 -7
  101. package/src/core/step-tag.ts +9 -0
  102. package/src/core/types.ts +3 -1
  103. package/src/global.ts +196 -0
  104. package/src/index.ts +20 -7
  105. package/src/integrations/fetch.ts +2 -2
  106. package/src/integrations/jquery/index.ts +4 -9
  107. package/src/integrations/react/scope.tsx +3 -2
  108. package/src/sinks/console.ts +20 -0
  109. package/src/sinks/datadog.ts +31 -6
  110. package/dist/__mocks__/test-runtime.d.ts.map +0 -1
  111. package/dist/__tests__/ambient.test.d.ts.map +0 -1
  112. package/dist/__tests__/axios.test.d.ts.map +0 -1
  113. package/dist/__tests__/context.test.d.ts.map +0 -1
  114. package/dist/__tests__/datadog.test.d.ts.map +0 -1
  115. package/dist/__tests__/define-journey.test.d.ts.map +0 -1
  116. package/dist/__tests__/expose-app-journey.test.d.ts.map +0 -1
  117. package/dist/__tests__/fetch.test.d.ts.map +0 -1
  118. package/dist/__tests__/jquery.test.d.ts.map +0 -1
  119. package/dist/__tests__/registry.test.d.ts +0 -2
  120. package/dist/__tests__/registry.test.d.ts.map +0 -1
  121. package/dist/__tests__/request-key.test.d.ts.map +0 -1
  122. package/dist/__tests__/requests.test.d.ts.map +0 -1
  123. package/dist/__tests__/runtime.test.d.ts.map +0 -1
  124. package/dist/__tests__/scope.test.d.ts.map +0 -1
  125. package/dist/__tests__/sinks.test.d.ts.map +0 -1
  126. package/dist/__tests__/step.test.d.ts.map +0 -1
  127. package/dist/__tests__/timeouts.test.d.ts.map +0 -1
  128. package/dist/core/registry.d.ts.map +0 -1
  129. package/dist/core/registry.js.map +0 -1
  130. package/dist/endpoint-policy.d.ts.map +0 -1
  131. package/dist/endpoint-policy.js.map +0 -1
  132. /package/dist/{__mocks__ → __test-utils__}/test-runtime.d.ts +0 -0
  133. /package/dist/__tests__/{ambient.test.d.ts → core/ambient.test.d.ts} +0 -0
  134. /package/dist/__tests__/{define-journey.test.d.ts → core/define-journey.test.d.ts} +0 -0
  135. /package/dist/__tests__/{requests.test.d.ts → core/requests.test.d.ts} +0 -0
  136. /package/dist/__tests__/{runtime.test.d.ts → core/runtime.test.d.ts} +0 -0
  137. /package/dist/__tests__/{step.test.d.ts → core/step.test.d.ts} +0 -0
  138. /package/dist/__tests__/{timeouts.test.d.ts → core/timeouts.test.d.ts} +0 -0
  139. /package/dist/__tests__/{axios.test.d.ts → integrations/axios.test.d.ts} +0 -0
  140. /package/dist/__tests__/{context.test.d.ts → integrations/context.test.d.ts} +0 -0
  141. /package/dist/__tests__/{expose-app-journey.test.d.ts → integrations/expose-app-journey.test.d.ts} +0 -0
  142. /package/dist/__tests__/{fetch.test.d.ts → integrations/fetch.test.d.ts} +0 -0
  143. /package/dist/__tests__/{jquery.test.d.ts → integrations/jquery.test.d.ts} +0 -0
  144. /package/dist/__tests__/{request-key.test.d.ts → integrations/request-key.test.d.ts} +0 -0
  145. /package/dist/__tests__/{scope.test.d.ts → integrations/scope.test.d.ts} +0 -0
  146. /package/dist/__tests__/{datadog.test.d.ts → sinks/datadog.test.d.ts} +0 -0
  147. /package/dist/__tests__/{sinks.test.d.ts → sinks/sinks.test.d.ts} +0 -0
  148. /package/dist/{endpoint-policy.d.ts → core/endpoint-policy.d.ts} +0 -0
  149. /package/dist/{endpoint-policy.js → core/endpoint-policy.js} +0 -0
  150. /package/src/{endpoint-policy.ts → core/endpoint-policy.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { longestEndpointMatch, sortEndpointsByLongestMatch } from '../endpoint-policy';
1
+ import { longestEndpointMatch, sortEndpointsByLongestMatch } from './endpoint-policy';
2
2
  import { JourneyStepTag } from './step-tag';
3
3
  const DEFAULT_REQUEST_TIMEOUTS = {
4
4
  defaultMs: 4000,
@@ -198,6 +198,37 @@ function toName(target) {
198
198
  getOpenJourney (name) {
199
199
  return journeys.get(name);
200
200
  },
201
+ getDebugSnapshot () {
202
+ const active = api.activeJourneyStep();
203
+ return {
204
+ openJourneys: [
205
+ ...journeys.values()
206
+ ].map((journey)=>({
207
+ name: journey.name,
208
+ team: journey.team,
209
+ group: journey.group,
210
+ service: journey.service,
211
+ verdict: journey.verdict,
212
+ reason: journey.reason,
213
+ tags: {
214
+ ...journey.tags
215
+ },
216
+ stepsInFlight: getInFlightSteps(journey).map((step)=>step.name),
217
+ steps: journey.steps.map((step)=>({
218
+ name: step.name,
219
+ outcome: step.outcome,
220
+ durationMs: step.durationMs,
221
+ ...step.reason ? {
222
+ reason: step.reason
223
+ } : {}
224
+ }))
225
+ })),
226
+ activeStep: active ? {
227
+ journey: active.journey.name,
228
+ name: active.name
229
+ } : null
230
+ };
231
+ },
201
232
  firstOpenJourney (names) {
202
233
  for (const name of names){
203
234
  if (journeys.has(name)) {
@@ -389,13 +420,16 @@ function toName(target) {
389
420
  }
390
421
  /**
391
422
  * @internal Private — not part of the public package API.
392
- * Process-wide engine used by free helpers. App code does not need to touch this.
393
- */ export const defaultRuntime = createJourneyRuntime();
423
+ * Module-scoped engine used by free helpers. App code does not need to touch this.
424
+ * Each host/MFE bundle gets its own copy when the package is duplicated.
425
+ */ export const moduleRuntime = createJourneyRuntime();
394
426
  /**
395
- * Reset the default engine (open journeys, ambient steps, sinks, request thresholds).
427
+ * @internal Accidentally exported removing it is a breaking change, so it stays
428
+ * for compatibility. Not part of the supported public API.
429
+ * Reset the module engine (open journeys, ambient steps, sinks, request thresholds).
396
430
  * Intended for tests — call in `beforeEach` / `afterEach` instead of manual cleanup.
397
431
  */ export function resetJourney(options) {
398
- defaultRuntime.reset(options);
432
+ moduleRuntime.reset(options);
399
433
  }
400
434
 
401
435
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/runtime.ts"],"sourcesContent":["import {\n longestEndpointMatch,\n sortEndpointsByLongestMatch,\n type AppRequestTimeouts,\n} from '../endpoint-policy';\nimport { JourneyStepTag } from './step-tag';\nimport type {\n JourneyDef,\n JourneyEvent,\n JourneySink,\n JourneyState,\n JourneyStepEvent,\n JourneyStepOptions,\n JourneyStepRef,\n JourneyStepTarget,\n Outcome,\n StepHandle,\n StepRecord,\n TagValue,\n} from './types';\n\nconst DEFAULT_REQUEST_TIMEOUTS: AppRequestTimeouts = { defaultMs: 4_000, endpoints: [] };\n\nconst noopStep: StepHandle = {\n name: null,\n setAttribute() {},\n setTags() {},\n complete() {},\n fail() {},\n tag: () => ({}),\n};\n\nfunction toName(target: string | { readonly name: string }): string {\n return typeof target === 'string' ? target : target.name;\n}\n\n/** @internal Private — not part of the public package API. */\nexport interface JourneyRuntimeOptions {\n /** Initial sinks. Defaults to `[]` — package bootstrap installs Datadog on the default runtime. */\n sinks?: readonly JourneySink[];\n requestTimeouts?: AppRequestTimeouts;\n}\n\n/**\n * @internal Private — not part of the public package API.\n * Isolated journey engine (open journeys, ambient steps, sinks, request thresholds).\n * App code should keep using free helpers (`defineJourney`, `journeyStep`, …) — they\n * bind to the process default runtime. Prefer `resetJourney()` in tests.\n */\nexport interface JourneyRuntime {\n getRequestTimeouts(): AppRequestTimeouts;\n setRequestTimeouts(next: AppRequestTimeouts): void;\n\n setSinks(next: readonly JourneySink[]): void;\n addSink(sink: JourneySink): void;\n emit(payload: JourneyEvent): void;\n\n getOpenJourney(name: string): JourneyState | undefined;\n firstOpenJourney(names: readonly string[]): string | null;\n setJourneyTags(name: string | null, tags: Record<string, TagValue>): void;\n startJourney(def: JourneyDef): void;\n failJourneyNow(journey: JourneyState, reason: string): void;\n failJourney(name: string, reason: string): void;\n completeJourney(name: string | null, tags?: Record<string, TagValue>): void;\n excludeJourney(name: string): void;\n\n activeJourneyStep(): JourneyStepRef | null;\n journeyStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n journeyMountStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n\n reportBackendRequest(\n step: JourneyStepRef | undefined,\n status: number | undefined,\n durationMs: number,\n requestKey: string\n ): void;\n\n /** Close open journeys, clear ambient steps, restore default timeouts/sinks. */\n reset(options?: JourneyRuntimeOptions): void;\n}\n\n/**\n * @internal Private — not part of the public package API.\n * Build an isolated engine. Rarely needed — apps use the default via free helpers.\n */\nexport function createJourneyRuntime(options: JourneyRuntimeOptions = {}): JourneyRuntime {\n const journeys = new Map<string, JourneyState>();\n const inFlight = new Set<StepRecord>();\n let sinks: JourneySink[] = [...(options.sinks ?? [])];\n let requestTimeouts: AppRequestTimeouts = {\n defaultMs: options.requestTimeouts?.defaultMs ?? DEFAULT_REQUEST_TIMEOUTS.defaultMs,\n endpoints: sortEndpointsByLongestMatch(\n options.requestTimeouts?.endpoints ?? DEFAULT_REQUEST_TIMEOUTS.endpoints\n ),\n };\n\n function getInFlightSteps(journey: JourneyState): StepRecord[] {\n const out: StepRecord[] = [];\n for (const step of inFlight) {\n if (step.journey === journey) {\n out.push(step);\n }\n }\n return out;\n }\n\n function enterStep(step: StepRecord): void {\n inFlight.add(step);\n }\n\n function leaveStep(step: StepRecord): void {\n inFlight.delete(step);\n }\n\n function clearCountdown(journey: JourneyState): void {\n if (journey.timer != null) {\n clearTimeout(journey.timer);\n journey.timer = null;\n }\n }\n\n function emit(payload: JourneyEvent): void {\n for (const sink of sinks) {\n try {\n sink(payload);\n } catch {\n // One sinking throw must not block the remaining sinks.\n }\n }\n }\n\n function finish(journey: JourneyState, outcome: Outcome, reason?: string): void {\n if (journey.closed) {\n return;\n }\n journey.closed = true;\n journeys.delete(journey.name);\n clearCountdown(journey);\n\n for (const step of getInFlightSteps(journey)) {\n if (step.durationMs === 0) {\n step.durationMs = Math.round(globalThis.performance.now() - step.startedAt);\n }\n }\n\n let finalReason = journey.reason ?? reason;\n let finalOutcome = outcome;\n const durationMs = Math.round(globalThis.performance.now() - journey.startedAt);\n if (journey.timeoutMs > 0 && durationMs > journey.timeoutMs) {\n finalOutcome = 'bad';\n finalReason = finalReason ?? 'journey-timeout';\n }\n\n const steps: JourneyStepEvent[] = journey.steps.map(s => ({\n name: s.name,\n startMs: Math.round(s.startedAt - journey.startedAt),\n durationMs: s.durationMs,\n outcome: s.outcome,\n ...(s.reason ? { reason: s.reason } : {}),\n ...(s.httpStatus !== undefined ? { httpStatus: s.httpStatus } : {}),\n ...(Object.keys(s.attributes).length ? { attributes: s.attributes } : {}),\n }));\n\n emit({\n journey: {\n name: journey.name,\n team: journey.team,\n group: journey.group,\n service: journey.service,\n outcome: finalOutcome,\n ...(finalOutcome === 'bad' && finalReason ? { reason: finalReason } : {}),\n durationMs,\n steps,\n ...(journey.expected ? { expected: journey.expected } : {}),\n ...(Object.keys(journey.tags).length ? { tags: journey.tags } : {}),\n },\n });\n }\n\n function armCountdown(journey: JourneyState): void {\n if (journey.timeoutMs <= 0) {\n return;\n }\n journey.timer = setTimeout(() => {\n finish(journey, 'bad', 'journey-timeout');\n }, journey.timeoutMs);\n }\n\n function resolveRequestTimeoutMs(journey: JourneyState, key: string): number {\n const own = longestEndpointMatch(journey.endpoints, key);\n if (own?.timeoutMs) {\n return own.timeoutMs;\n }\n\n const app = longestEndpointMatch(requestTimeouts.endpoints, key);\n if (app?.timeoutMs) {\n return app.timeoutMs;\n }\n\n if (journey.requestTimeoutMs != null) {\n return journey.requestTimeoutMs;\n }\n\n return requestTimeouts.defaultMs;\n }\n\n function shouldIgnoreRequest(journey: JourneyState, key: string): boolean {\n const own = longestEndpointMatch(journey.endpoints, key);\n if (own) {\n return own.ignore === true;\n }\n return longestEndpointMatch(requestTimeouts.endpoints, key)?.ignore === true;\n }\n\n function resolveJourneyName(journey: JourneyStepTarget): string | null {\n if (journey == null) {\n return null;\n }\n if (typeof journey === 'string' || !Array.isArray(journey)) {\n return toName(journey as string | { readonly name: string });\n }\n return api.firstOpenJourney(journey.map(toName));\n }\n\n function createStepHandle(journeyName: string, step: StepRecord): StepHandle {\n return {\n name: journeyName,\n setAttribute(key, value) {\n step.attributes[key] = value;\n },\n setTags(tags) {\n api.setJourneyTags(journeyName, tags);\n },\n complete(tags) {\n api.completeJourney(journeyName, tags);\n },\n fail(reason) {\n api.failJourney(journeyName, reason);\n },\n // Box in JourneyStepTag — raw StepRecord is circular and blows jQuery/axios deep-merge.\n tag: () => ({ journeyStep: new JourneyStepTag(step) }),\n };\n }\n\n const api: JourneyRuntime = {\n getRequestTimeouts() {\n return requestTimeouts;\n },\n\n setRequestTimeouts(next) {\n requestTimeouts = {\n ...next,\n endpoints: sortEndpointsByLongestMatch(next.endpoints),\n };\n },\n\n setSinks(next) {\n sinks = [...next];\n },\n\n addSink(sink) {\n sinks.push(sink);\n },\n\n emit,\n\n getOpenJourney(name) {\n return journeys.get(name);\n },\n\n firstOpenJourney(names) {\n for (const name of names) {\n if (journeys.has(name)) {\n return name;\n }\n }\n return null;\n },\n\n setJourneyTags(name, tags) {\n const journey = name ? journeys.get(name) : undefined;\n if (journey) {\n Object.assign(journey.tags, tags);\n }\n },\n\n startJourney(def) {\n const existing = journeys.get(def.name);\n if (existing) {\n finish(existing, existing.verdict === 'bad' ? 'bad' : 'excluded');\n }\n\n const journey: JourneyState = {\n name: def.name,\n team: def.team,\n group: def.group,\n service: def.service,\n verdict: 'good',\n startedAt: globalThis.performance.now(),\n timeoutMs: def.timeoutMs ?? 0,\n stepTimeoutMs: def.stepTimeoutMs,\n reason: null,\n steps: [],\n expected: def.steps ? [...def.steps] : null,\n tags: { ...(def.tags ?? {}) },\n requestTimeoutMs: def.requestTimeoutMs,\n endpoints: sortEndpointsByLongestMatch(def.endpoints),\n timer: null,\n closed: false,\n };\n journeys.set(def.name, journey);\n armCountdown(journey);\n },\n\n failJourneyNow(journey, reason) {\n if (journey.closed) {\n return;\n }\n journey.verdict = 'bad';\n journey.reason ??= reason;\n finish(journey, 'bad');\n },\n\n failJourney(name, reason) {\n const journey = journeys.get(name);\n if (journey) {\n api.failJourneyNow(journey, reason);\n }\n },\n\n completeJourney(name, tags) {\n if (!name) {\n return;\n }\n if (tags) {\n api.setJourneyTags(name, tags);\n }\n const journey = journeys.get(name);\n if (journey) {\n finish(journey, journey.verdict === 'bad' ? 'bad' : 'good');\n }\n },\n\n excludeJourney(name) {\n const journey = journeys.get(name);\n if (journey) {\n finish(journey, journey.verdict === 'bad' ? 'bad' : 'excluded');\n }\n },\n\n activeJourneyStep() {\n if (inFlight.size !== 1) {\n return null;\n }\n return inFlight.values().next().value ?? null;\n },\n\n async journeyStep(journey, stepName, fn, opts) {\n const journeyName = resolveJourneyName(journey);\n const open = journeyName ? journeys.get(journeyName) : undefined;\n if (!open || !journeyName) {\n return fn(noopStep);\n }\n\n const step: StepRecord = {\n name: stepName,\n startedAt: globalThis.performance.now(),\n durationMs: 0,\n outcome: 'good',\n attributes: {},\n journey: open,\n };\n open.steps.push(step);\n\n const handle = createStepHandle(journeyName, step);\n\n const stepTimeoutMs = opts?.timeoutMs ?? open.stepTimeoutMs ?? 0;\n let timeoutTimer: ReturnType<typeof setTimeout> | null = null;\n if (stepTimeoutMs > 0) {\n timeoutTimer = setTimeout(() => {\n if (open.closed) {\n return;\n }\n step.outcome = 'bad';\n step.reason ??= 'step-timeout';\n step.attributes.timeout_ms ??= stepTimeoutMs;\n step.durationMs = Math.round(globalThis.performance.now() - step.startedAt);\n api.failJourneyNow(open, 'step-timeout');\n }, stepTimeoutMs);\n }\n\n enterStep(step);\n try {\n return await fn(handle);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n step.outcome = 'bad';\n step.reason ??= 'step-error';\n step.attributes.error ??= message;\n api.failJourneyNow(open, 'step-error');\n throw err;\n } finally {\n if (timeoutTimer != null) {\n clearTimeout(timeoutTimer);\n }\n if (step.durationMs === 0) {\n step.durationMs = Math.round(globalThis.performance.now() - step.startedAt);\n }\n leaveStep(step);\n }\n },\n\n async journeyMountStep(journey, stepName, fn, opts) {\n await Promise.resolve();\n return api.journeyStep(journey, stepName, fn, opts);\n },\n\n reportBackendRequest(step, status, durationMs, requestKey) {\n if (!step) {\n return;\n }\n const journey = step.journey;\n if (journey.closed) {\n return;\n }\n if (shouldIgnoreRequest(journey, requestKey)) {\n return;\n }\n\n const failed = status === undefined || status >= 500;\n const slow = durationMs > resolveRequestTimeoutMs(journey, requestKey);\n if (!failed && !slow) {\n return;\n }\n\n const category = failed ? 'request-error' : 'request-latency';\n\n step.outcome = 'bad';\n step.reason ??= category;\n if (failed && status !== undefined) {\n step.httpStatus = status;\n }\n\n api.failJourneyNow(journey, category);\n },\n\n reset(next = {}) {\n for (const journey of [...journeys.values()]) {\n clearCountdown(journey);\n journey.closed = true;\n }\n journeys.clear();\n inFlight.clear();\n sinks = [...(next.sinks ?? [])];\n requestTimeouts = {\n defaultMs: next.requestTimeouts?.defaultMs ?? DEFAULT_REQUEST_TIMEOUTS.defaultMs,\n endpoints: sortEndpointsByLongestMatch(\n next.requestTimeouts?.endpoints ?? DEFAULT_REQUEST_TIMEOUTS.endpoints\n ),\n };\n },\n };\n\n return api;\n}\n\n/**\n * @internal Private — not part of the public package API.\n * Process-wide engine used by free helpers. App code does not need to touch this.\n */\nexport const defaultRuntime: JourneyRuntime = createJourneyRuntime();\n\n/**\n * Reset the default engine (open journeys, ambient steps, sinks, request thresholds).\n * Intended for tests — call in `beforeEach` / `afterEach` instead of manual cleanup.\n */\nexport function resetJourney(options?: JourneyRuntimeOptions): void {\n defaultRuntime.reset(options);\n}\n"],"names":["longestEndpointMatch","sortEndpointsByLongestMatch","JourneyStepTag","DEFAULT_REQUEST_TIMEOUTS","defaultMs","endpoints","noopStep","name","setAttribute","setTags","complete","fail","tag","toName","target","createJourneyRuntime","options","journeys","Map","inFlight","Set","sinks","requestTimeouts","getInFlightSteps","journey","out","step","push","enterStep","add","leaveStep","delete","clearCountdown","timer","clearTimeout","emit","payload","sink","finish","outcome","reason","closed","durationMs","Math","round","globalThis","performance","now","startedAt","finalReason","finalOutcome","timeoutMs","steps","map","s","startMs","httpStatus","undefined","Object","keys","attributes","length","team","group","service","expected","tags","armCountdown","setTimeout","resolveRequestTimeoutMs","key","own","app","requestTimeoutMs","shouldIgnoreRequest","ignore","resolveJourneyName","Array","isArray","api","firstOpenJourney","createStepHandle","journeyName","value","setJourneyTags","completeJourney","failJourney","journeyStep","getRequestTimeouts","setRequestTimeouts","next","setSinks","addSink","getOpenJourney","get","names","has","assign","startJourney","def","existing","verdict","stepTimeoutMs","set","failJourneyNow","excludeJourney","activeJourneyStep","size","values","stepName","fn","opts","open","handle","timeoutTimer","timeout_ms","err","message","Error","String","error","journeyMountStep","Promise","resolve","reportBackendRequest","status","requestKey","failed","slow","category","reset","clear","defaultRuntime","resetJourney"],"mappings":"AAAA,SACIA,oBAAoB,EACpBC,2BAA2B,QAExB,qBAAqB;AAC5B,SAASC,cAAc,QAAQ,aAAa;AAgB5C,MAAMC,2BAA+C;IAAEC,WAAW;IAAOC,WAAW,EAAE;AAAC;AAEvF,MAAMC,WAAuB;IACzBC,MAAM;IACNC,iBAAgB;IAChBC,YAAW;IACXC,aAAY;IACZC,SAAQ;IACRC,KAAK,IAAO,CAAA,CAAC,CAAA;AACjB;AAEA,SAASC,OAAOC,MAA0C;IACtD,OAAO,OAAOA,WAAW,WAAWA,SAASA,OAAOP,IAAI;AAC5D;AAyDA;;;CAGC,GACD,OAAO,SAASQ,qBAAqBC,UAAiC,CAAC,CAAC;QAGpCA;QAEjBA,0BAEPA;IANR,MAAMC,WAAW,IAAIC;IACrB,MAAMC,WAAW,IAAIC;IACrB,IAAIC,QAAuB;YAAKL,iBAAAA,QAAQK,KAAK,cAAbL,4BAAAA,iBAAiB,EAAE;KAAE;IACrD,IAAIM,kBAAsC;QACtClB,SAAS,WAAEY,2BAAAA,QAAQM,eAAe,cAAvBN,+CAAAA,yBAAyBZ,SAAS,uCAAID,yBAAyBC,SAAS;QACnFC,WAAWJ,sCACPe,4BAAAA,QAAQM,eAAe,cAAvBN,gDAAAA,0BAAyBX,SAAS,yCAAIF,yBAAyBE,SAAS;IAEhF;IAEA,SAASkB,iBAAiBC,OAAqB;QAC3C,MAAMC,MAAoB,EAAE;QAC5B,KAAK,MAAMC,QAAQP,SAAU;YACzB,IAAIO,KAAKF,OAAO,KAAKA,SAAS;gBAC1BC,IAAIE,IAAI,CAACD;YACb;QACJ;QACA,OAAOD;IACX;IAEA,SAASG,UAAUF,IAAgB;QAC/BP,SAASU,GAAG,CAACH;IACjB;IAE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,GAAG;aACfb,UAAAA,CAAAA,QAAAA,MAAKc,MAAM,cAAXd,qBAAAA,UAAAA,MAAKc,MAAM,GAAKyF;YAChB,IAAIF,UAAUF,WAAWpE,WAAW;gBAChC/B,KAAK8B,UAAU,GAAGqE;YACtB;YAEA9C,IAAIyB,cAAc,CAAChF,SAASyG;QAChC;QAEAC,OAAMxC,OAAO,CAAC,CAAC;gBAOEA;gBAEEA,uBAEPA;YAVR,KAAK,MAAMlE,WAAW;mBAAIP,SAAS2F,MAAM;aAAG,CAAE;gBAC1C5E,eAAeR;gBACfA,QAAQiB,MAAM,GAAG;YACrB;YACAxB,SAASkH,KAAK;YACdhH,SAASgH,KAAK;YACd9G,QAAQ;oBAAKqE,cAAAA,KAAKrE,KAAK,cAAVqE,yBAAAA,cAAc,EAAE;aAAE;YAC/BpE,kBAAkB;gBACdlB,SAAS,WAAEsF,wBAAAA,KAAKpE,eAAe,cAApBoE,4CAAAA,sBAAsBtF,SAAS,uCAAID,yBAAyBC,SAAS;gBAChFC,WAAWJ,sCACPyF,yBAAAA,KAAKpE,eAAe,cAApBoE,6CAAAA,uBAAsBrF,SAAS,yCAAIF,yBAAyBE,SAAS;YAE7E;QACJ;IACJ;IAEA,OAAO0E;AACX;AAEA;;;CAGC,GACD,OAAO,MAAMqD,iBAAiCrH,uBAAuB;AAErE;;;CAGC,GACD,OAAO,SAASsH,aAAarH,OAA+B;IACxDoH,eAAeF,KAAK,CAAClH;AACzB"}
1
+ {"version":3,"sources":["../../src/core/runtime.ts"],"sourcesContent":["import {\n longestEndpointMatch,\n sortEndpointsByLongestMatch,\n type AppRequestTimeouts,\n} from './endpoint-policy';\nimport { JourneyStepTag } from './step-tag';\nimport type {\n JourneyDef,\n JourneyEvent,\n JourneySink,\n JourneyState,\n JourneyStepEvent,\n JourneyStepOptions,\n JourneyStepRef,\n JourneyStepTarget,\n Outcome,\n StepHandle,\n StepRecord,\n TagValue,\n} from './types';\n\nconst DEFAULT_REQUEST_TIMEOUTS: AppRequestTimeouts = { defaultMs: 4_000, endpoints: [] };\n\nconst noopStep: StepHandle = {\n name: null,\n setAttribute() {},\n setTags() {},\n complete() {},\n fail() {},\n tag: () => ({}),\n};\n\nfunction toName(target: string | { readonly name: string }): string {\n return typeof target === 'string' ? target : target.name;\n}\n\n/** @internal Private — not part of the public package API. */\nexport interface JourneyRuntimeOptions {\n /** Initial sinks. Defaults to `[]` — package bootstrap installs Datadog on the module runtime. */\n sinks?: readonly JourneySink[];\n requestTimeouts?: AppRequestTimeouts;\n}\n\n/** @internal Read-only snapshot for DevTools (`__stJourney.getDebugState`; empty unless debugging). */\nexport interface JourneyRuntimeDebugSnapshot {\n openJourneys: readonly {\n name: string;\n team: string;\n group: string;\n service: string;\n verdict: Outcome;\n reason: string | null;\n tags: Record<string, TagValue>;\n stepsInFlight: readonly string[];\n steps: readonly {\n name: string;\n outcome: 'good' | 'bad';\n durationMs: number;\n reason?: string;\n }[];\n }[];\n activeStep: { journey: string; name: string } | null;\n}\n\n/**\n * @internal Private — not part of the public package API.\n * Isolated journey engine (open journeys, ambient steps, sinks, request thresholds).\n * App code should keep using free helpers (`defineJourney`, `journeyStep`, …) — they\n * bind to the module runtime. Prefer `resetJourney()` in tests.\n */\nexport interface JourneyRuntime {\n getRequestTimeouts(): AppRequestTimeouts;\n setRequestTimeouts(next: AppRequestTimeouts): void;\n\n setSinks(next: readonly JourneySink[]): void;\n addSink(sink: JourneySink): void;\n emit(payload: JourneyEvent): void;\n\n getOpenJourney(name: string): JourneyState | undefined;\n /** @internal DevTools snapshot of open journeys / ambient step. */\n getDebugSnapshot(): JourneyRuntimeDebugSnapshot;\n firstOpenJourney(names: readonly string[]): string | null;\n setJourneyTags(name: string | null, tags: Record<string, TagValue>): void;\n startJourney(def: JourneyDef): void;\n failJourneyNow(journey: JourneyState, reason: string): void;\n failJourney(name: string, reason: string): void;\n completeJourney(name: string | null, tags?: Record<string, TagValue>): void;\n excludeJourney(name: string): void;\n\n activeJourneyStep(): JourneyStepRef | null;\n journeyStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n journeyMountStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n\n reportBackendRequest(\n step: JourneyStepRef | undefined,\n status: number | undefined,\n durationMs: number,\n requestKey: string\n ): void;\n\n /** Close open journeys, clear ambient steps, restore default timeouts/sinks. */\n reset(options?: JourneyRuntimeOptions): void;\n}\n\n/**\n * @internal Private — not part of the public package API.\n * Build an isolated engine. Rarely needed — apps use the default via free helpers.\n */\nexport function createJourneyRuntime(options: JourneyRuntimeOptions = {}): JourneyRuntime {\n const journeys = new Map<string, JourneyState>();\n const inFlight = new Set<StepRecord>();\n let sinks: JourneySink[] = [...(options.sinks ?? [])];\n let requestTimeouts: AppRequestTimeouts = {\n defaultMs: options.requestTimeouts?.defaultMs ?? DEFAULT_REQUEST_TIMEOUTS.defaultMs,\n endpoints: sortEndpointsByLongestMatch(\n options.requestTimeouts?.endpoints ?? DEFAULT_REQUEST_TIMEOUTS.endpoints\n ),\n };\n\n function getInFlightSteps(journey: JourneyState): StepRecord[] {\n const out: StepRecord[] = [];\n for (const step of inFlight) {\n if (step.journey === journey) {\n out.push(step);\n }\n }\n return out;\n }\n\n function enterStep(step: StepRecord): void {\n inFlight.add(step);\n }\n\n function leaveStep(step: StepRecord): void {\n inFlight.delete(step);\n }\n\n function clearCountdown(journey: JourneyState): void {\n if (journey.timer != null) {\n clearTimeout(journey.timer);\n journey.timer = null;\n }\n }\n\n function emit(payload: JourneyEvent): void {\n for (const sink of sinks) {\n try {\n sink(payload);\n } catch {\n // One sinking throw must not block the remaining sinks.\n }\n }\n }\n\n function finish(journey: JourneyState, outcome: Outcome, reason?: string): void {\n if (journey.closed) {\n return;\n }\n journey.closed = true;\n journeys.delete(journey.name);\n clearCountdown(journey);\n\n for (const step of getInFlightSteps(journey)) {\n if (step.durationMs === 0) {\n step.durationMs = Math.round(globalThis.performance.now() - step.startedAt);\n }\n }\n\n let finalReason = journey.reason ?? reason;\n let finalOutcome = outcome;\n const durationMs = Math.round(globalThis.performance.now() - journey.startedAt);\n if (journey.timeoutMs > 0 && durationMs > journey.timeoutMs) {\n finalOutcome = 'bad';\n finalReason = finalReason ?? 'journey-timeout';\n }\n\n const steps: JourneyStepEvent[] = journey.steps.map(s => ({\n name: s.name,\n startMs: Math.round(s.startedAt - journey.startedAt),\n durationMs: s.durationMs,\n outcome: s.outcome,\n ...(s.reason ? { reason: s.reason } : {}),\n ...(s.httpStatus !== undefined ? { httpStatus: s.httpStatus } : {}),\n ...(Object.keys(s.attributes).length ? { attributes: s.attributes } : {}),\n }));\n\n emit({\n journey: {\n name: journey.name,\n team: journey.team,\n group: journey.group,\n service: journey.service,\n outcome: finalOutcome,\n ...(finalOutcome === 'bad' && finalReason ? { reason: finalReason } : {}),\n durationMs,\n steps,\n ...(journey.expected ? { expected: journey.expected } : {}),\n ...(Object.keys(journey.tags).length ? { tags: journey.tags } : {}),\n },\n });\n }\n\n function armCountdown(journey: JourneyState): void {\n if (journey.timeoutMs <= 0) {\n return;\n }\n journey.timer = setTimeout(() => {\n finish(journey, 'bad', 'journey-timeout');\n }, journey.timeoutMs);\n }\n\n function resolveRequestTimeoutMs(journey: JourneyState, key: string): number {\n const own = longestEndpointMatch(journey.endpoints, key);\n if (own?.timeoutMs) {\n return own.timeoutMs;\n }\n\n const app = longestEndpointMatch(requestTimeouts.endpoints, key);\n if (app?.timeoutMs) {\n return app.timeoutMs;\n }\n\n if (journey.requestTimeoutMs != null) {\n return journey.requestTimeoutMs;\n }\n\n return requestTimeouts.defaultMs;\n }\n\n function shouldIgnoreRequest(journey: JourneyState, key: string): boolean {\n const own = longestEndpointMatch(journey.endpoints, key);\n if (own) {\n return own.ignore === true;\n }\n return longestEndpointMatch(requestTimeouts.endpoints, key)?.ignore === true;\n }\n\n function resolveJourneyName(journey: JourneyStepTarget): string | null {\n if (journey == null) {\n return null;\n }\n if (typeof journey === 'string' || !Array.isArray(journey)) {\n return toName(journey as string | { readonly name: string });\n }\n return api.firstOpenJourney(journey.map(toName));\n }\n\n function createStepHandle(journeyName: string, step: StepRecord): StepHandle {\n return {\n name: journeyName,\n setAttribute(key, value) {\n step.attributes[key] = value;\n },\n setTags(tags) {\n api.setJourneyTags(journeyName, tags);\n },\n complete(tags) {\n api.completeJourney(journeyName, tags);\n },\n fail(reason) {\n api.failJourney(journeyName, reason);\n },\n // Box in JourneyStepTag — raw StepRecord is circular and blows jQuery/axios deep-merge.\n tag: () => ({ journeyStep: new JourneyStepTag(step) }),\n };\n }\n\n const api: JourneyRuntime = {\n getRequestTimeouts() {\n return requestTimeouts;\n },\n\n setRequestTimeouts(next) {\n requestTimeouts = {\n ...next,\n endpoints: sortEndpointsByLongestMatch(next.endpoints),\n };\n },\n\n setSinks(next) {\n sinks = [...next];\n },\n\n addSink(sink) {\n sinks.push(sink);\n },\n\n emit,\n\n getOpenJourney(name) {\n return journeys.get(name);\n },\n\n getDebugSnapshot() {\n const active = api.activeJourneyStep();\n return {\n openJourneys: [...journeys.values()].map(journey => ({\n name: journey.name,\n team: journey.team,\n group: journey.group,\n service: journey.service,\n verdict: journey.verdict,\n reason: journey.reason,\n tags: { ...journey.tags },\n stepsInFlight: getInFlightSteps(journey).map(step => step.name),\n steps: journey.steps.map(step => ({\n name: step.name,\n outcome: step.outcome,\n durationMs: step.durationMs,\n ...(step.reason ? { reason: step.reason } : {}),\n })),\n })),\n activeStep: active ? { journey: active.journey.name, name: active.name } : null,\n };\n },\n\n firstOpenJourney(names) {\n for (const name of names) {\n if (journeys.has(name)) {\n return name;\n }\n }\n return null;\n },\n\n setJourneyTags(name, tags) {\n const journey = name ? journeys.get(name) : undefined;\n if (journey) {\n Object.assign(journey.tags, tags);\n }\n },\n\n startJourney(def) {\n const existing = journeys.get(def.name);\n if (existing) {\n finish(existing, existing.verdict === 'bad' ? 'bad' : 'excluded');\n }\n\n const journey: JourneyState = {\n name: def.name,\n team: def.team,\n group: def.group,\n service: def.service,\n verdict: 'good',\n startedAt: globalThis.performance.now(),\n timeoutMs: def.timeoutMs ?? 0,\n stepTimeoutMs: def.stepTimeoutMs,\n reason: null,\n steps: [],\n expected: def.steps ? [...def.steps] : null,\n tags: { ...(def.tags ?? {}) },\n requestTimeoutMs: def.requestTimeoutMs,\n endpoints: sortEndpointsByLongestMatch(def.endpoints),\n timer: null,\n closed: false,\n };\n journeys.set(def.name, journey);\n armCountdown(journey);\n },\n\n failJourneyNow(journey, reason) {\n if (journey.closed) {\n return;\n }\n journey.verdict = 'bad';\n journey.reason ??= reason;\n finish(journey, 'bad');\n },\n\n failJourney(name, reason) {\n const journey = journeys.get(name);\n if (journey) {\n api.failJourneyNow(journey, reason);\n }\n },\n\n completeJourney(name, tags) {\n if (!name) {\n return;\n }\n if (tags) {\n api.setJourneyTags(name, tags);\n }\n const journey = journeys.get(name);\n if (journey) {\n finish(journey, journey.verdict === 'bad' ? 'bad' : 'good');\n }\n },\n\n excludeJourney(name) {\n const journey = journeys.get(name);\n if (journey) {\n finish(journey, journey.verdict === 'bad' ? 'bad' : 'excluded');\n }\n },\n\n activeJourneyStep() {\n if (inFlight.size !== 1) {\n return null;\n }\n return inFlight.values().next().value ?? null;\n },\n\n async journeyStep(journey, stepName, fn, opts) {\n const journeyName = resolveJourneyName(journey);\n const open = journeyName ? journeys.get(journeyName) : undefined;\n if (!open || !journeyName) {\n return fn(noopStep);\n }\n\n const step: StepRecord = {\n name: stepName,\n startedAt: globalThis.performance.now(),\n durationMs: 0,\n outcome: 'good',\n attributes: {},\n journey: open,\n };\n open.steps.push(step);\n\n const handle = createStepHandle(journeyName, step);\n\n const stepTimeoutMs = opts?.timeoutMs ?? open.stepTimeoutMs ?? 0;\n let timeoutTimer: ReturnType<typeof setTimeout> | null = null;\n if (stepTimeoutMs > 0) {\n timeoutTimer = setTimeout(() => {\n if (open.closed) {\n return;\n }\n step.outcome = 'bad';\n step.reason ??= 'step-timeout';\n step.attributes.timeout_ms ??= stepTimeoutMs;\n step.durationMs = Math.round(globalThis.performance.now() - step.startedAt);\n api.failJourneyNow(open, 'step-timeout');\n }, stepTimeoutMs);\n }\n\n enterStep(step);\n try {\n return await fn(handle);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n step.outcome = 'bad';\n step.reason ??= 'step-error';\n step.attributes.error ??= message;\n api.failJourneyNow(open, 'step-error');\n throw err;\n } finally {\n if (timeoutTimer != null) {\n clearTimeout(timeoutTimer);\n }\n if (step.durationMs === 0) {\n step.durationMs = Math.round(globalThis.performance.now() - step.startedAt);\n }\n leaveStep(step);\n }\n },\n\n async journeyMountStep(journey, stepName, fn, opts) {\n await Promise.resolve();\n return api.journeyStep(journey, stepName, fn, opts);\n },\n\n reportBackendRequest(step, status, durationMs, requestKey) {\n if (!step) {\n return;\n }\n const journey = step.journey;\n if (journey.closed) {\n return;\n }\n if (shouldIgnoreRequest(journey, requestKey)) {\n return;\n }\n\n const failed = status === undefined || status >= 500;\n const slow = durationMs > resolveRequestTimeoutMs(journey, requestKey);\n if (!failed && !slow) {\n return;\n }\n\n const category = failed ? 'request-error' : 'request-latency';\n\n step.outcome = 'bad';\n step.reason ??= category;\n if (failed && status !== undefined) {\n step.httpStatus = status;\n }\n\n api.failJourneyNow(journey, category);\n },\n\n reset(next = {}) {\n for (const journey of [...journeys.values()]) {\n clearCountdown(journey);\n journey.closed = true;\n }\n journeys.clear();\n inFlight.clear();\n sinks = [...(next.sinks ?? [])];\n requestTimeouts = {\n defaultMs: next.requestTimeouts?.defaultMs ?? DEFAULT_REQUEST_TIMEOUTS.defaultMs,\n endpoints: sortEndpointsByLongestMatch(\n next.requestTimeouts?.endpoints ?? DEFAULT_REQUEST_TIMEOUTS.endpoints\n ),\n };\n },\n };\n\n return api;\n}\n\n/**\n * @internal Private — not part of the public package API.\n * Module-scoped engine used by free helpers. App code does not need to touch this.\n * Each host/MFE bundle gets its own copy when the package is duplicated.\n */\nexport const moduleRuntime: JourneyRuntime = createJourneyRuntime();\n\n/**\n * @internal Accidentally exported — removing it is a breaking change, so it stays\n * for compatibility. Not part of the supported public API.\n * Reset the module engine (open journeys, ambient steps, sinks, request thresholds).\n * Intended for tests — call in `beforeEach` / `afterEach` instead of manual cleanup.\n */\nexport function resetJourney(options?: JourneyRuntimeOptions): void {\n moduleRuntime.reset(options);\n}\n"],"names":["longestEndpointMatch","sortEndpointsByLongestMatch","JourneyStepTag","DEFAULT_REQUEST_TIMEOUTS","defaultMs","endpoints","noopStep","name","setAttribute","setTags","complete","fail","tag","toName","target","createJourneyRuntime","options","journeys","Map","inFlight","Set","sinks","requestTimeouts","getInFlightSteps","journey","out","step","push","enterStep","add","leaveStep","delete","clearCountdown","timer","clearTimeout","emit","payload","sink","finish","outcome","reason","closed","durationMs","Math","round","globalThis","performance","now","startedAt","finalReason","finalOutcome","timeoutMs","steps","map","s","startMs","httpStatus","undefined","Object","keys","attributes","length","team","group","service","expected","tags","armCountdown","setTimeout","resolveRequestTimeoutMs","key","own","app","requestTimeoutMs","shouldIgnoreRequest","ignore","resolveJourneyName","Array","isArray","api","firstOpenJourney","createStepHandle","journeyName","value","setJourneyTags","completeJourney","failJourney","journeyStep","getRequestTimeouts","setRequestTimeouts","next","setSinks","addSink","getOpenJourney","get","getDebugSnapshot","active","activeJourneyStep","openJourneys","values","verdict","stepsInFlight","activeStep","names","has","assign","startJourney","def","existing","stepTimeoutMs","set","failJourneyNow","excludeJourney","size","stepName","fn","opts","open","handle","timeoutTimer","timeout_ms","err","message","Error","String","error","journeyMountStep","Promise","resolve","reportBackendRequest","status","requestKey","failed","slow","category","reset","clear","moduleRuntime","resetJourney"],"mappings":"AAAA,SACIA,oBAAoB,EACpBC,2BAA2B,QAExB,oBAAoB;AAC3B,SAASC,cAAc,QAAQ,aAAa;AAgB5C,MAAMC,2BAA+C;IAAEC,WAAW;IAAOC,WAAW,EAAE;AAAC;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,cAApBoE,6CAAAA,uBAAsBrF,SAAS,yCAAIF,yBAAyBE,SAAS;YAE7E;QACJ;IACJ;IAEA,OAAO0E;AACX;AAEA;;;;CAIC,GACD,OAAO,MAAM0D,gBAAgC1H,uBAAuB;AAEpE;;;;;CAKC,GACD,OAAO,SAAS2H,aAAa1H,OAA+B;IACxDyH,cAAcF,KAAK,CAACvH;AACxB"}
@@ -10,6 +10,12 @@ import type { JourneyStepRef, StepRecord } from './types';
10
10
  export declare class JourneyStepTag {
11
11
  readonly step: StepRecord;
12
12
  constructor(step: StepRecord);
13
+ /**
14
+ * Circular by design (`step.journey.steps → step`) for mergeConfig/deep-merge
15
+ * safety. Prevent accidental `JSON.stringify` (e.g. AxiosError.toJSON() includes
16
+ * config by reference) elsewhere in the app from throwing "circular structure".
17
+ */
18
+ toJSON(): string;
13
19
  }
14
20
  /** Unwrap `step.tag().journeyStep` or a JourneyStepTag / StepRecord stamp. */
15
21
  export declare function resolveJourneyStep(value: unknown): JourneyStepRef | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"step-tag.d.ts","sourceRoot":"","sources":["../../src/core/step-tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;GAOG;AACH,qBAAa,cAAc;IACX,QAAQ,CAAC,IAAI,EAAE,UAAU;gBAAhB,IAAI,EAAE,UAAU;CACxC;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAQ7E"}
1
+ {"version":3,"file":"step-tag.d.ts","sourceRoot":"","sources":["../../src/core/step-tag.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;GAOG;AACH,qBAAa,cAAc;IACX,QAAQ,CAAC,IAAI,EAAE,UAAU;gBAAhB,IAAI,EAAE,UAAU;IAErC;;;;OAIG;IACH,MAAM,IAAI,MAAM;CAGnB;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAQ7E"}
@@ -17,6 +17,13 @@ function _define_property(obj, key, value) {
17
17
  * on ajax/axios options causes "Maximum call stack size exceeded". Class
18
18
  * instances are assigned by reference instead of recursed.
19
19
  */ export class JourneyStepTag {
20
+ /**
21
+ * Circular by design (`step.journey.steps → step`) for mergeConfig/deep-merge
22
+ * safety. Prevent accidental `JSON.stringify` (e.g. AxiosError.toJSON() includes
23
+ * config by reference) elsewhere in the app from throwing "circular structure".
24
+ */ toJSON() {
25
+ return '[JourneyStepTag]';
26
+ }
20
27
  constructor(step){
21
28
  _define_property(this, "step", void 0);
22
29
  this.step = step;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/step-tag.ts"],"sourcesContent":["import type { JourneyStepRef, StepRecord } from './types';\n\n/**\n * Non-plain wrapper for {@link StepHandle.tag}.\n *\n * jQuery `ajaxSetup` / axios `mergeConfig` deep-merge plain objects. A raw\n * {@link StepRecord} is circular (`step.journey.steps → step`), so putting it\n * on ajax/axios options causes \"Maximum call stack size exceeded\". Class\n * instances are assigned by reference instead of recursed.\n */\nexport class JourneyStepTag {\n constructor(readonly step: StepRecord) {}\n}\n\n/** Unwrap `step.tag().journeyStep` or a JourneyStepTag / StepRecord stamp. */\nexport function resolveJourneyStep(value: unknown): JourneyStepRef | undefined {\n if (value instanceof JourneyStepTag) {\n return value.step;\n }\n if (value && typeof value === 'object') {\n return value as JourneyStepRef;\n }\n return undefined;\n}\n"],"names":["JourneyStepTag","step","resolveJourneyStep","value","undefined"],"mappings":";;;;;;;;;;;AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA;IACT,YAAY,AAASC,IAAgB,CAAE;;aAAlBA,OAAAA;IAAmB;AAC5C;AAEA,4EAA4E,GAC5E,OAAO,SAASC,mBAAmBC,KAAc;IAC7C,IAAIA,iBAAiBH,gBAAgB;QACjC,OAAOG,MAAMF,IAAI;IACrB;IACA,IAAIE,SAAS,OAAOA,UAAU,UAAU;QACpC,OAAOA;IACX;IACA,OAAOC;AACX"}
1
+ {"version":3,"sources":["../../src/core/step-tag.ts"],"sourcesContent":["import type { JourneyStepRef, StepRecord } from './types';\n\n/**\n * Non-plain wrapper for {@link StepHandle.tag}.\n *\n * jQuery `ajaxSetup` / axios `mergeConfig` deep-merge plain objects. A raw\n * {@link StepRecord} is circular (`step.journey.steps → step`), so putting it\n * on ajax/axios options causes \"Maximum call stack size exceeded\". Class\n * instances are assigned by reference instead of recursed.\n */\nexport class JourneyStepTag {\n constructor(readonly step: StepRecord) {}\n\n /**\n * Circular by design (`step.journey.steps → step`) for mergeConfig/deep-merge\n * safety. Prevent accidental `JSON.stringify` (e.g. AxiosError.toJSON() includes\n * config by reference) elsewhere in the app from throwing \"circular structure\".\n */\n toJSON(): string {\n return '[JourneyStepTag]';\n }\n}\n\n/** Unwrap `step.tag().journeyStep` or a JourneyStepTag / StepRecord stamp. */\nexport function resolveJourneyStep(value: unknown): JourneyStepRef | undefined {\n if (value instanceof JourneyStepTag) {\n return value.step;\n }\n if (value && typeof value === 'object') {\n return value as JourneyStepRef;\n }\n return undefined;\n}\n"],"names":["JourneyStepTag","toJSON","step","resolveJourneyStep","value","undefined"],"mappings":";;;;;;;;;;;AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA;IAGT;;;;KAIC,GACDC,SAAiB;QACb,OAAO;IACX;IATA,YAAY,AAASC,IAAgB,CAAE;;aAAlBA,OAAAA;IAAmB;AAU5C;AAEA,4EAA4E,GAC5E,OAAO,SAASC,mBAAmBC,KAAc;IAC7C,IAAIA,iBAAiBJ,gBAAgB;QACjC,OAAOI,MAAMF,IAAI;IACrB;IACA,IAAIE,SAAS,OAAOA,UAAU,UAAU;QACpC,OAAOA;IACX;IACA,OAAOC;AACX"}
@@ -1,4 +1,4 @@
1
- import type { EndpointPolicy } from '../endpoint-policy';
1
+ import type { EndpointPolicy } from './endpoint-policy';
2
2
  /** Arbitrary tag values a developer can attach. */
3
3
  export type TagValue = string | number | boolean;
4
4
  /** Config for one journey — supplied by the caller (typically `<JourneyScope>` props). */
@@ -59,6 +59,7 @@ export interface JourneyStepOptions {
59
59
  /** Timeout for this step in ms; overrides journey stepTimeoutMs. Omit / 0 to disable. */
60
60
  timeoutMs?: number;
61
61
  }
62
+ /** @internal Engine open-journey record — not part of the supported public API. */
62
63
  export interface JourneyState {
63
64
  name: string;
64
65
  team: string;
@@ -82,6 +83,7 @@ export interface JourneyState {
82
83
  timer: ReturnType<typeof setTimeout> | null;
83
84
  closed: boolean;
84
85
  }
86
+ /** @internal Engine in-flight / completed step record — not part of the supported public API. */
85
87
  export interface StepRecord {
86
88
  name: string;
87
89
  startedAt: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,mDAAmD;AACnD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD,0FAA0F;AAC1F,MAAM,WAAW,UAAU;IACvB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,SAAS,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IACtC,uEAAuE;IACvE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B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C;CACL;AAED,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAExD,uGAAuG;AACvG,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC7C,oDAAoD;IACpD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IAC7C;;;OAGG;IACH,IAAI,CAAC,CAAC,EACF,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxC,IAAI,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,CAAC,EACP,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxC,IAAI,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,CAAC;IACd,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;CACjD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/types.ts"],"sourcesContent":["import type { EndpointPolicy } from '../endpoint-policy';\n\n/** Arbitrary tag values a developer can attach. */\nexport type TagValue = string | number | boolean;\n\n/** Config for one journey — supplied by the caller (typically `<JourneyScope>` props). */\nexport interface JourneyDef {\n /** Journey name — lifecycle key, event field, and concurrency map key. */\n name: string;\n /** Owner team (required tag). */\n team: string;\n /** Functional area, e.g. \"sales\" (required tag). */\n group: string;\n /** Business component label, e.g. \"checkout\" — not the Datadog RUM service. */\n service: string;\n /** Whole-journey budget in ms; omit / 0 to disable. */\n timeoutMs?: number;\n /** Default per-step timeout in ms; per-call option overrides. Omit / 0 to disable. */\n stepTimeoutMs?: number;\n /** Slow-request threshold for this journey; falls back to app-wide default. */\n requestTimeoutMs?: number;\n /** Per-endpoint overrides for this journey (longest prefix wins over app-wide). */\n endpoints?: readonly EndpointPolicy[];\n /** Optional expected step names (rides as `expected` on the event). */\n steps?: readonly string[];\n /** Custom tags on every event of this journey. */\n tags?: Record<string, TagValue>;\n}\n\nexport type Outcome = 'good' | 'bad' | 'excluded';\n\n/** Handle passed to each step function. */\nexport interface StepHandle {\n /** Resolved journey name for this step, or null if untraced. */\n readonly name: string | null;\n setAttribute(key: string, value: string | number | boolean): void;\n /** Journey-level tags without closing. */\n setTags(tags: Record<string, TagValue>): void;\n /** Apply optional tags then completeJourney. No-op if name is null. */\n complete(tags?: Record<string, TagValue>): void;\n /** Soft business Bad without throw. No-op if name is null. */\n fail(reason: string): void;\n /**\n * Bind this step to a request explicitly (spread into axios config / fetch init /\n * jQuery ajax settings). Needed when requests fire after an await or while steps\n * overlap — see docs soft ambient. Untraced (noop) steps omit `journeyStep`.\n *\n * The value is a non-plain {@link JourneyStepTag} so jQuery/axios deep-merge will\n * not recurse into the circular StepRecord graph.\n */\n tag(): { journeyStep?: unknown };\n}\n\n/** A journey name, or anything with a `name` (e.g. a JourneyHandle / JourneyDef). */\nexport type JourneyNameLike = string | { readonly name: string };\n\n/** First argument to journeyStep / journeyMountStep. */\nexport type JourneyStepTarget = JourneyNameLike | null | readonly JourneyNameLike[];\n\n/** Per-call options for journeyStep. */\nexport interface JourneyStepOptions {\n /** Timeout for this step in ms; overrides journey stepTimeoutMs. Omit / 0 to disable. */\n timeoutMs?: number;\n}\n\nexport interface JourneyState {\n name: string;\n team: string;\n group: string;\n service: string;\n verdict: Outcome;\n startedAt: number;\n timeoutMs: number;\n stepTimeoutMs?: number;\n /**\n * Why the journey closed as bad, else null.\n * Engine: request-error | request-latency | journey-timeout | step-timeout | step-error.\n * Also any custom business reason (e.g. call-not-associated).\n */\n reason: string | null;\n steps: StepRecord[];\n expected: string[] | null;\n tags: Record<string, TagValue>;\n requestTimeoutMs?: number;\n endpoints?: readonly EndpointPolicy[];\n timer: ReturnType<typeof setTimeout> | null;\n closed: boolean;\n}\n\nexport interface StepRecord {\n name: string;\n startedAt: number;\n durationMs: number;\n outcome: 'good' | 'bad';\n reason?: string;\n httpStatus?: number;\n attributes: Record<string, string | number | boolean>;\n journey: JourneyState;\n}\n\n/** Opaque handle to a step, captured at request initiation for response attribution. */\nexport type JourneyStepRef = StepRecord;\n\nexport interface JourneyStepEvent {\n name: string;\n /** Offset from the journey start, ms. */\n startMs: number;\n durationMs: number;\n outcome: 'good' | 'bad';\n reason?: string;\n httpStatus?: number;\n attributes?: Record<string, TagValue>;\n}\n\n/** Neutral journey event payload (journey-specific fields only; session context is host RUM globals). */\nexport interface JourneyEvent {\n journey: {\n name: string;\n team: string;\n group: string;\n service: string;\n outcome: Outcome;\n reason?: string;\n durationMs: number;\n steps: JourneyStepEvent[];\n expected?: string[];\n tags?: Record<string, TagValue>;\n };\n}\n\n/** Destination for a terminal journey event. */\nexport type JourneySink = (event: JourneyEvent) => void;\n\n/** Callable journey — config plus lifecycle helpers bound to `name`. Prefer this over free helpers. */\nexport interface JourneyHandle extends JourneyDef {\n /** Open this journey (restarts if already open). */\n start(tags?: Record<string, TagValue>): void;\n /**\n * Record a step. Opens the journey first when it isn't already open\n * (one-shot store actions); no-op start when a `<JourneyScope>` already opened it.\n */\n step<T>(\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n /**\n * Like `step`, deferred one microtask for mount-effect use under `<JourneyScope>`\n * (React runs child effects before parent). Also auto-starts if not already open.\n */\n mountStep<T>(\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n complete(tags?: Record<string, TagValue>): void;\n fail(reason: string): void;\n exclude(): void;\n setTags(tags: Record<string, TagValue>): void;\n}\n"],"names":[],"mappings":"AAqIA,qGAAqG,GACrG,WAyBC"}
1
+ {"version":3,"sources":["../../src/core/types.ts"],"sourcesContent":["import type { EndpointPolicy } from './endpoint-policy';\n\n/** Arbitrary tag values a developer can attach. */\nexport type TagValue = string | number | boolean;\n\n/** Config for one journey — supplied by the caller (typically `<JourneyScope>` props). */\nexport interface JourneyDef {\n /** Journey name — lifecycle key, event field, and concurrency map key. */\n name: string;\n /** Owner team (required tag). */\n team: string;\n /** Functional area, e.g. \"sales\" (required tag). */\n group: string;\n /** Business component label, e.g. \"checkout\" — not the Datadog RUM service. */\n service: string;\n /** Whole-journey budget in ms; omit / 0 to disable. */\n timeoutMs?: number;\n /** Default per-step timeout in ms; per-call option overrides. Omit / 0 to disable. */\n stepTimeoutMs?: number;\n /** Slow-request threshold for this journey; falls back to app-wide default. */\n requestTimeoutMs?: number;\n /** Per-endpoint overrides for this journey (longest prefix wins over app-wide). */\n endpoints?: readonly EndpointPolicy[];\n /** Optional expected step names (rides as `expected` on the event). */\n steps?: readonly string[];\n /** Custom tags on every event of this journey. */\n tags?: Record<string, TagValue>;\n}\n\nexport type Outcome = 'good' | 'bad' | 'excluded';\n\n/** Handle passed to each step function. */\nexport interface StepHandle {\n /** Resolved journey name for this step, or null if untraced. */\n readonly name: string | null;\n setAttribute(key: string, value: string | number | boolean): void;\n /** Journey-level tags without closing. */\n setTags(tags: Record<string, TagValue>): void;\n /** Apply optional tags then completeJourney. No-op if name is null. */\n complete(tags?: Record<string, TagValue>): void;\n /** Soft business Bad without throw. No-op if name is null. */\n fail(reason: string): void;\n /**\n * Bind this step to a request explicitly (spread into axios config / fetch init /\n * jQuery ajax settings). Needed when requests fire after an await or while steps\n * overlap — see docs soft ambient. Untraced (noop) steps omit `journeyStep`.\n *\n * The value is a non-plain {@link JourneyStepTag} so jQuery/axios deep-merge will\n * not recurse into the circular StepRecord graph.\n */\n tag(): { journeyStep?: unknown };\n}\n\n/** A journey name, or anything with a `name` (e.g. a JourneyHandle / JourneyDef). */\nexport type JourneyNameLike = string | { readonly name: string };\n\n/** First argument to journeyStep / journeyMountStep. */\nexport type JourneyStepTarget = JourneyNameLike | null | readonly JourneyNameLike[];\n\n/** Per-call options for journeyStep. */\nexport interface JourneyStepOptions {\n /** Timeout for this step in ms; overrides journey stepTimeoutMs. Omit / 0 to disable. */\n timeoutMs?: number;\n}\n\n/** @internal Engine open-journey record — not part of the supported public API. */\nexport interface JourneyState {\n name: string;\n team: string;\n group: string;\n service: string;\n verdict: Outcome;\n startedAt: number;\n timeoutMs: number;\n stepTimeoutMs?: number;\n /**\n * Why the journey closed as bad, else null.\n * Engine: request-error | request-latency | journey-timeout | step-timeout | step-error.\n * Also any custom business reason (e.g. call-not-associated).\n */\n reason: string | null;\n steps: StepRecord[];\n expected: string[] | null;\n tags: Record<string, TagValue>;\n requestTimeoutMs?: number;\n endpoints?: readonly EndpointPolicy[];\n timer: ReturnType<typeof setTimeout> | null;\n closed: boolean;\n}\n\n/** @internal Engine in-flight / completed step record — not part of the supported public API. */\nexport interface StepRecord {\n name: string;\n startedAt: number;\n durationMs: number;\n outcome: 'good' | 'bad';\n reason?: string;\n httpStatus?: number;\n attributes: Record<string, string | number | boolean>;\n journey: JourneyState;\n}\n\n/** Opaque handle to a step, captured at request initiation for response attribution. */\nexport type JourneyStepRef = StepRecord;\n\nexport interface JourneyStepEvent {\n name: string;\n /** Offset from the journey start, ms. */\n startMs: number;\n durationMs: number;\n outcome: 'good' | 'bad';\n reason?: string;\n httpStatus?: number;\n attributes?: Record<string, TagValue>;\n}\n\n/** Neutral journey event payload (journey-specific fields only; session context is host RUM globals). */\nexport interface JourneyEvent {\n journey: {\n name: string;\n team: string;\n group: string;\n service: string;\n outcome: Outcome;\n reason?: string;\n durationMs: number;\n steps: JourneyStepEvent[];\n expected?: string[];\n tags?: Record<string, TagValue>;\n };\n}\n\n/** Destination for a terminal journey event. */\nexport type JourneySink = (event: JourneyEvent) => void;\n\n/** Callable journey — config plus lifecycle helpers bound to `name`. Prefer this over free helpers. */\nexport interface JourneyHandle extends JourneyDef {\n /** Open this journey (restarts if already open). */\n start(tags?: Record<string, TagValue>): void;\n /**\n * Record a step. Opens the journey first when it isn't already open\n * (one-shot store actions); no-op start when a `<JourneyScope>` already opened it.\n */\n step<T>(\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n /**\n * Like `step`, deferred one microtask for mount-effect use under `<JourneyScope>`\n * (React runs child effects before parent). Also auto-starts if not already open.\n */\n mountStep<T>(\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n complete(tags?: Record<string, TagValue>): void;\n fail(reason: string): void;\n exclude(): void;\n setTags(tags: Record<string, TagValue>): void;\n}\n"],"names":[],"mappings":"AAuIA,qGAAqG,GACrG,WAyBC"}
@@ -0,0 +1,67 @@
1
+ import type { JourneyRuntime, JourneyRuntimeDebugSnapshot } from './core/runtime';
2
+ /** Force-enable journey host wiring outside go* hosts (`__stJourney.enable()`). */
3
+ export declare const JOURNEY_ENABLED_STORAGE_KEY = "st:journey:enabled";
4
+ /** Opt-in journey console logging (`__stJourney.enableDebugging()`). */
5
+ export declare const JOURNEY_DEBUG_STORAGE_KEY = "st:journey:debug";
6
+ /** @internal Shared cross-bundle bag on globalThis (`rum` fallback + DevTools helpers). */
7
+ export declare const ST_JOURNEY_GLOBAL_KEY = "__stJourney";
8
+ export interface JourneyDebugRuntimeEntry extends JourneyRuntimeDebugSnapshot {
9
+ id: string;
10
+ }
11
+ export interface JourneyDebugState {
12
+ /** Force-enable flag (`st:journey:enabled`). */
13
+ enabled: boolean;
14
+ /** Console-logging flag (`st:journey:debug`). */
15
+ debug: boolean;
16
+ hasRum: boolean;
17
+ runtimes: JourneyDebugRuntimeEntry[];
18
+ }
19
+ /**
20
+ * @internal Cross-bundle surface on `globalThis.__stJourney`.
21
+ * Prefer importing `isJourneyEnabled` / `isJourneyDebugEnabled` from the package in app code.
22
+ */
23
+ export interface StJourneyGlobal {
24
+ /**
25
+ * Fallback RUM instance from `setJourneyRum` when `globalThis.DD_RUM` is absent.
26
+ * Prefer `DD_RUM` (ST host: `datadogGuard`).
27
+ */
28
+ rum?: unknown;
29
+ enable(): void;
30
+ disable(): void;
31
+ isEnabled(): boolean;
32
+ enableDebugging(): void;
33
+ disableDebugging(): void;
34
+ isDebugEnabled(): boolean;
35
+ /**
36
+ * Open-journey snapshot for DevTools. Returns empty `runtimes` unless debugging
37
+ * is enabled (`enableDebugging()` / `st:journey:debug`).
38
+ */
39
+ getDebugState(): JourneyDebugState;
40
+ }
41
+ /** True when `localStorage['st:journey:enabled'] === 'true'` (force-on outside go*). */
42
+ export declare function isJourneyEnabled(): boolean;
43
+ /** Set the force-enable flag. Reload after calling from DevTools. */
44
+ export declare function enableJourney(): void;
45
+ /** Clear the force-enable flag. Reload after calling from DevTools. */
46
+ export declare function disableJourney(): void;
47
+ /** True when `localStorage['st:journey:debug'] === 'true'`. */
48
+ export declare function isJourneyDebugEnabled(): boolean;
49
+ /** Set the console-debug flag. Reload after calling from DevTools. */
50
+ export declare function enableJourneyDebugging(): void;
51
+ /** Clear the console-debug flag. Reload after calling from DevTools. */
52
+ export declare function disableJourneyDebugging(): void;
53
+ /**
54
+ * @internal Register this bundle's module runtime on `__stJourney` so DevTools can
55
+ * list every host/MFE engine copy on the page.
56
+ */
57
+ export declare function registerJourneyRuntime(runtime: JourneyRuntime): void;
58
+ /** @internal Ensure `__stJourney` exists (idempotent). */
59
+ export declare function installJourneyGlobal(): void;
60
+ /**
61
+ * @internal Store a fallback RUM instance on `__stJourney.rum` when `DD_RUM` is absent.
62
+ * Used by `setJourneyRum`.
63
+ */
64
+ export declare function setJourneyRumFallback(rum: unknown): void;
65
+ /** @internal Read `__stJourney.rum` (setJourneyRum fallback). */
66
+ export declare function getJourneyRumFallback(): unknown;
67
+ //# sourceMappingURL=global.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAElF,mFAAmF;AACnF,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAE5D,2FAA2F;AAC3F,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AAEnD,MAAM,WAAW,wBAAyB,SAAQ,2BAA2B;IACzE,EAAE,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAC9B,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,wBAAwB,EAAE,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IAChB,SAAS,IAAI,OAAO,CAAC;IACrB,eAAe,IAAI,IAAI,CAAC;IACxB,gBAAgB,IAAI,IAAI,CAAC;IACzB,cAAc,IAAI,OAAO,CAAC;IAC1B;;;OAGG;IACH,aAAa,IAAI,iBAAiB,CAAC;CACtC;AAkCD,wFAAwF;AACxF,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,qEAAqE;AACrE,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED,uEAAuE;AACvE,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,+DAA+D;AAC/D,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAED,wEAAwE;AACxE,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAyDD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAOpE;AAED,0DAA0D;AAC1D,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAExD;AAED,iEAAiE;AACjE,wBAAgB,qBAAqB,IAAI,OAAO,CAI/C"}
package/dist/global.js ADDED
@@ -0,0 +1,116 @@
1
+ /** Force-enable journey host wiring outside go* hosts (`__stJourney.enable()`). */ export const JOURNEY_ENABLED_STORAGE_KEY = 'st:journey:enabled';
2
+ /** Opt-in journey console logging (`__stJourney.enableDebugging()`). */ export const JOURNEY_DEBUG_STORAGE_KEY = 'st:journey:debug';
3
+ /** @internal Shared cross-bundle bag on globalThis (`rum` fallback + DevTools helpers). */ export const ST_JOURNEY_GLOBAL_KEY = '__stJourney';
4
+ let runtimeSeq = 0;
5
+ function readFlag(key) {
6
+ try {
7
+ var _globalThis_localStorage;
8
+ return ((_globalThis_localStorage = globalThis.localStorage) === null || _globalThis_localStorage === void 0 ? void 0 : _globalThis_localStorage.getItem(key)) === 'true';
9
+ } catch (unused) {
10
+ return false;
11
+ }
12
+ }
13
+ function writeFlag(key, on) {
14
+ try {
15
+ if (on) {
16
+ var _globalThis_localStorage;
17
+ (_globalThis_localStorage = globalThis.localStorage) === null || _globalThis_localStorage === void 0 ? void 0 : _globalThis_localStorage.setItem(key, 'true');
18
+ } else {
19
+ var _globalThis_localStorage1;
20
+ (_globalThis_localStorage1 = globalThis.localStorage) === null || _globalThis_localStorage1 === void 0 ? void 0 : _globalThis_localStorage1.removeItem(key);
21
+ }
22
+ } catch (unused) {
23
+ // ignore storage failures (privacy mode, non-browser)
24
+ }
25
+ }
26
+ /** True when `localStorage['st:journey:enabled'] === 'true'` (force-on outside go*). */ export function isJourneyEnabled() {
27
+ return readFlag(JOURNEY_ENABLED_STORAGE_KEY);
28
+ }
29
+ /** Set the force-enable flag. Reload after calling from DevTools. */ export function enableJourney() {
30
+ writeFlag(JOURNEY_ENABLED_STORAGE_KEY, true);
31
+ }
32
+ /** Clear the force-enable flag. Reload after calling from DevTools. */ export function disableJourney() {
33
+ writeFlag(JOURNEY_ENABLED_STORAGE_KEY, false);
34
+ }
35
+ /** True when `localStorage['st:journey:debug'] === 'true'`. */ export function isJourneyDebugEnabled() {
36
+ return readFlag(JOURNEY_DEBUG_STORAGE_KEY);
37
+ }
38
+ /** Set the console-debug flag. Reload after calling from DevTools. */ export function enableJourneyDebugging() {
39
+ writeFlag(JOURNEY_DEBUG_STORAGE_KEY, true);
40
+ }
41
+ /** Clear the console-debug flag. Reload after calling from DevTools. */ export function disableJourneyDebugging() {
42
+ writeFlag(JOURNEY_DEBUG_STORAGE_KEY, false);
43
+ }
44
+ function hasRum() {
45
+ return globalThis.DD_RUM != null || getJourneyRumFallback() != null;
46
+ }
47
+ function buildDebugState(runtimes) {
48
+ if (!isJourneyDebugEnabled()) {
49
+ return {
50
+ enabled: isJourneyEnabled(),
51
+ debug: false,
52
+ hasRum: hasRum(),
53
+ runtimes: []
54
+ };
55
+ }
56
+ return {
57
+ enabled: isJourneyEnabled(),
58
+ debug: true,
59
+ hasRum: hasRum(),
60
+ runtimes: runtimes.map((entry)=>({
61
+ id: entry.id,
62
+ ...entry.getSnapshot()
63
+ }))
64
+ };
65
+ }
66
+ function ensureGlobal() {
67
+ var _ref;
68
+ const g = globalThis;
69
+ const existing = g[ST_JOURNEY_GLOBAL_KEY];
70
+ // Reuse when a prior load already installed the full surface (incl. enable).
71
+ if ((existing === null || existing === void 0 ? void 0 : existing.runtimeRegistrations) && typeof existing.enable === 'function') {
72
+ return existing;
73
+ }
74
+ const runtimes = (_ref = existing === null || existing === void 0 ? void 0 : existing.runtimeRegistrations) !== null && _ref !== void 0 ? _ref : [];
75
+ const api = {
76
+ rum: existing === null || existing === void 0 ? void 0 : existing.rum,
77
+ runtimeRegistrations: runtimes,
78
+ enable: enableJourney,
79
+ disable: disableJourney,
80
+ isEnabled: isJourneyEnabled,
81
+ enableDebugging: enableJourneyDebugging,
82
+ disableDebugging: disableJourneyDebugging,
83
+ isDebugEnabled: isJourneyDebugEnabled,
84
+ getDebugState () {
85
+ return buildDebugState(api.runtimeRegistrations);
86
+ }
87
+ };
88
+ g[ST_JOURNEY_GLOBAL_KEY] = api;
89
+ return api;
90
+ }
91
+ /**
92
+ * @internal Register this bundle's module runtime on `__stJourney` so DevTools can
93
+ * list every host/MFE engine copy on the page.
94
+ */ export function registerJourneyRuntime(runtime) {
95
+ const globalApi = ensureGlobal();
96
+ const id = `runtime-${++runtimeSeq}`;
97
+ globalApi.runtimeRegistrations.push({
98
+ id,
99
+ getSnapshot: ()=>runtime.getDebugSnapshot()
100
+ });
101
+ }
102
+ /** @internal Ensure `__stJourney` exists (idempotent). */ export function installJourneyGlobal() {
103
+ ensureGlobal();
104
+ }
105
+ /**
106
+ * @internal Store a fallback RUM instance on `__stJourney.rum` when `DD_RUM` is absent.
107
+ * Used by `setJourneyRum`.
108
+ */ export function setJourneyRumFallback(rum) {
109
+ ensureGlobal().rum = rum;
110
+ }
111
+ /** @internal Read `__stJourney.rum` (setJourneyRum fallback). */ export function getJourneyRumFallback() {
112
+ const existing = globalThis[ST_JOURNEY_GLOBAL_KEY];
113
+ return existing === null || existing === void 0 ? void 0 : existing.rum;
114
+ }
115
+
116
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/global.ts"],"sourcesContent":["import type { JourneyRuntime, JourneyRuntimeDebugSnapshot } from './core/runtime';\n\n/** Force-enable journey host wiring outside go* hosts (`__stJourney.enable()`). */\nexport const JOURNEY_ENABLED_STORAGE_KEY = 'st:journey:enabled';\n\n/** Opt-in journey console logging (`__stJourney.enableDebugging()`). */\nexport const JOURNEY_DEBUG_STORAGE_KEY = 'st:journey:debug';\n\n/** @internal Shared cross-bundle bag on globalThis (`rum` fallback + DevTools helpers). */\nexport const ST_JOURNEY_GLOBAL_KEY = '__stJourney';\n\nexport interface JourneyDebugRuntimeEntry extends JourneyRuntimeDebugSnapshot {\n id: string;\n}\n\nexport interface JourneyDebugState {\n /** Force-enable flag (`st:journey:enabled`). */\n enabled: boolean;\n /** Console-logging flag (`st:journey:debug`). */\n debug: boolean;\n hasRum: boolean;\n runtimes: JourneyDebugRuntimeEntry[];\n}\n\n/**\n * @internal Cross-bundle surface on `globalThis.__stJourney`.\n * Prefer importing `isJourneyEnabled` / `isJourneyDebugEnabled` from the package in app code.\n */\nexport interface StJourneyGlobal {\n /**\n * Fallback RUM instance from `setJourneyRum` when `globalThis.DD_RUM` is absent.\n * Prefer `DD_RUM` (ST host: `datadogGuard`).\n */\n rum?: unknown;\n enable(): void;\n disable(): void;\n isEnabled(): boolean;\n enableDebugging(): void;\n disableDebugging(): void;\n isDebugEnabled(): boolean;\n /**\n * Open-journey snapshot for DevTools. Returns empty `runtimes` unless debugging\n * is enabled (`enableDebugging()` / `st:journey:debug`).\n */\n getDebugState(): JourneyDebugState;\n}\n\ninterface RuntimeRegistration {\n id: string;\n getSnapshot: () => JourneyRuntimeDebugSnapshot;\n}\n\ninterface StJourneyGlobalInternal extends StJourneyGlobal {\n /** @internal */\n runtimeRegistrations: RuntimeRegistration[];\n}\n\nlet runtimeSeq = 0;\n\nfunction readFlag(key: string): boolean {\n try {\n return globalThis.localStorage?.getItem(key) === 'true';\n } catch {\n return false;\n }\n}\n\nfunction writeFlag(key: string, on: boolean): void {\n try {\n if (on) {\n globalThis.localStorage?.setItem(key, 'true');\n } else {\n globalThis.localStorage?.removeItem(key);\n }\n } catch {\n // ignore storage failures (privacy mode, non-browser)\n }\n}\n\n/** True when `localStorage['st:journey:enabled'] === 'true'` (force-on outside go*). */\nexport function isJourneyEnabled(): boolean {\n return readFlag(JOURNEY_ENABLED_STORAGE_KEY);\n}\n\n/** Set the force-enable flag. Reload after calling from DevTools. */\nexport function enableJourney(): void {\n writeFlag(JOURNEY_ENABLED_STORAGE_KEY, true);\n}\n\n/** Clear the force-enable flag. Reload after calling from DevTools. */\nexport function disableJourney(): void {\n writeFlag(JOURNEY_ENABLED_STORAGE_KEY, false);\n}\n\n/** True when `localStorage['st:journey:debug'] === 'true'`. */\nexport function isJourneyDebugEnabled(): boolean {\n return readFlag(JOURNEY_DEBUG_STORAGE_KEY);\n}\n\n/** Set the console-debug flag. Reload after calling from DevTools. */\nexport function enableJourneyDebugging(): void {\n writeFlag(JOURNEY_DEBUG_STORAGE_KEY, true);\n}\n\n/** Clear the console-debug flag. Reload after calling from DevTools. */\nexport function disableJourneyDebugging(): void {\n writeFlag(JOURNEY_DEBUG_STORAGE_KEY, false);\n}\n\nfunction hasRum(): boolean {\n return (\n (globalThis as Record<string, unknown>).DD_RUM != null || getJourneyRumFallback() != null\n );\n}\n\nfunction buildDebugState(runtimes: RuntimeRegistration[]): JourneyDebugState {\n if (!isJourneyDebugEnabled()) {\n return {\n enabled: isJourneyEnabled(),\n debug: false,\n hasRum: hasRum(),\n runtimes: [],\n };\n }\n\n return {\n enabled: isJourneyEnabled(),\n debug: true,\n hasRum: hasRum(),\n runtimes: runtimes.map(entry => ({\n id: entry.id,\n ...entry.getSnapshot(),\n })),\n };\n}\n\nfunction ensureGlobal(): StJourneyGlobalInternal {\n const g = globalThis as Record<string, unknown>;\n const existing = g[ST_JOURNEY_GLOBAL_KEY] as StJourneyGlobalInternal | undefined;\n // Reuse when a prior load already installed the full surface (incl. enable).\n if (existing?.runtimeRegistrations && typeof existing.enable === 'function') {\n return existing;\n }\n\n const runtimes: RuntimeRegistration[] = existing?.runtimeRegistrations ?? [];\n\n const api: StJourneyGlobalInternal = {\n rum: existing?.rum,\n runtimeRegistrations: runtimes,\n enable: enableJourney,\n disable: disableJourney,\n isEnabled: isJourneyEnabled,\n enableDebugging: enableJourneyDebugging,\n disableDebugging: disableJourneyDebugging,\n isDebugEnabled: isJourneyDebugEnabled,\n getDebugState() {\n return buildDebugState(api.runtimeRegistrations);\n },\n };\n\n g[ST_JOURNEY_GLOBAL_KEY] = api;\n return api;\n}\n\n/**\n * @internal Register this bundle's module runtime on `__stJourney` so DevTools can\n * list every host/MFE engine copy on the page.\n */\nexport function registerJourneyRuntime(runtime: JourneyRuntime): void {\n const globalApi = ensureGlobal();\n const id = `runtime-${++runtimeSeq}`;\n globalApi.runtimeRegistrations.push({\n id,\n getSnapshot: () => runtime.getDebugSnapshot(),\n });\n}\n\n/** @internal Ensure `__stJourney` exists (idempotent). */\nexport function installJourneyGlobal(): void {\n ensureGlobal();\n}\n\n/**\n * @internal Store a fallback RUM instance on `__stJourney.rum` when `DD_RUM` is absent.\n * Used by `setJourneyRum`.\n */\nexport function setJourneyRumFallback(rum: unknown): void {\n ensureGlobal().rum = rum;\n}\n\n/** @internal Read `__stJourney.rum` (setJourneyRum fallback). */\nexport function getJourneyRumFallback(): unknown {\n const existing = (globalThis as Record<string, unknown>)[ST_JOURNEY_GLOBAL_KEY] as\n StJourneyGlobal | undefined;\n return existing?.rum;\n}\n"],"names":["JOURNEY_ENABLED_STORAGE_KEY","JOURNEY_DEBUG_STORAGE_KEY","ST_JOURNEY_GLOBAL_KEY","runtimeSeq","readFlag","key","globalThis","localStorage","getItem","writeFlag","on","setItem","removeItem","isJourneyEnabled","enableJourney","disableJourney","isJourneyDebugEnabled","enableJourneyDebugging","disableJourneyDebugging","hasRum","DD_RUM","getJourneyRumFallback","buildDebugState","runtimes","enabled","debug","map","entry","id","getSnapshot","ensureGlobal","g","existing","runtimeRegistrations","enable","api","rum","disable","isEnabled","enableDebugging","disableDebugging","isDebugEnabled","getDebugState","registerJourneyRuntime","runtime","globalApi","push","getDebugSnapshot","installJourneyGlobal","setJourneyRumFallback"],"mappings":"AAEA,iFAAiF,GACjF,OAAO,MAAMA,8BAA8B,qBAAqB;AAEhE,sEAAsE,GACtE,OAAO,MAAMC,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BC,IAAID,MAAMC,EAAE;gBACZ,GAAGD,MAAME,WAAW,EAAE;YAC1B,CAAA;IACJ;AACJ;AAEA,SAASC;;IACL,MAAMC,IAAIzB;IACV,MAAM0B,WAAWD,CAAC,CAAC7B,sBAAsB;IACzC,6EAA6E;IAC7E,IAAI8B,CAAAA,qBAAAA,+BAAAA,SAAUC,oBAAoB,KAAI,OAAOD,SAASE,MAAM,KAAK,YAAY;QACzE,OAAOF;IACX;IAEA,MAAMT,mBAAkCS,qBAAAA,+BAAAA,SAAUC,oBAAoB,uCAAI,EAAE;IAE5E,MAAME,MAA+B;QACjCC,GAAG,EAAEJ,qBAAAA,+BAAAA,SAAUI,GAAG;QAClBH,sBAAsBV;QACtBW,QAAQpB;QACRuB,SAAStB;QACTuB,WAAWzB;QACX0B,iBAAiBtB;QACjBuB,kBAAkBtB;QAClBuB,gBAAgBzB;QAChB0B;YACI,OAAOpB,gBAAgBa,IAAIF,oBAAoB;QACnD;IACJ;IAEAF,CAAC,CAAC7B,sBAAsB,GAAGiC;IAC3B,OAAOA;AACX;AAEA;;;CAGC,GACD,OAAO,SAASQ,uBAAuBC,OAAuB;IAC1D,MAAMC,YAAYf;IAClB,MAAMF,KAAK,CAAC,QAAQ,EAAE,EAAEzB,YAAY;IACpC0C,UAAUZ,oBAAoB,CAACa,IAAI,CAAC;QAChClB;QACAC,aAAa,IAAMe,QAAQG,gBAAgB;IAC/C;AACJ;AAEA,wDAAwD,GACxD,OAAO,SAASC;IACZlB;AACJ;AAEA;;;CAGC,GACD,OAAO,SAASmB,sBAAsBb,GAAY;IAC9CN,eAAeM,GAAG,GAAGA;AACzB;AAEA,+DAA+D,GAC/D,OAAO,SAASf;IACZ,MAAMW,WAAW,AAAC1B,UAAsC,CAACJ,sBAAsB;IAE/E,OAAO8B,qBAAAA,+BAAAA,SAAUI,GAAG;AACxB"}
package/dist/index.d.ts CHANGED
@@ -1,14 +1,19 @@
1
1
  import './config';
2
- export { activeJourneyStep, completeJourney, defineJourney, excludeJourney, failJourney, journeyStep, reportBackendRequest, resolveJourneyStep, setJourneyTags, JourneyStepTag, type JourneyDef, type JourneyHandle, type JourneyNameLike, type JourneyStepOptions, type JourneyStepRef, type JourneyStepTarget, type StepHandle, } from './core';
2
+ export { defineJourney, completeJourney, excludeJourney, failJourney, journeyStep, setJourneyTags, activeJourneyStep, reportBackendRequest, resolveJourneyStep, JourneyStepTag, type JourneyDef, type JourneyHandle, type JourneyNameLike, type JourneyStepOptions, type JourneyStepRef, type JourneyStepTarget, type StepHandle, } from './core';
3
3
  export { configureJourney, type AppRequestTimeouts, type EndpointPolicy, type JourneyConfig, } from './config';
4
4
  export type { JourneySink } from './core';
5
- /** Test helper — clears open journeys / ambient steps on the default engine. */
5
+ /**
6
+ * @internal Accidentally exported — removing it is a breaking change, so it stays
7
+ * for compatibility. Not part of the supported public API. Test helper only.
8
+ */
6
9
  export { resetJourney } from './core';
7
10
  export { instrumentAxios } from './integrations/axios';
8
11
  export { instrumentFetch } from './integrations/fetch';
9
12
  export { exposeAppJourney, instrumentJquery } from './integrations/jquery';
10
13
  export { requestKey, type JourneyTimedMeta } from './integrations/request-key';
11
- export { sendToDatadog, setJourneyRum } from './sinks/datadog';
14
+ export { disableJourney, disableJourneyDebugging, enableJourney, enableJourneyDebugging, isJourneyDebugEnabled, isJourneyEnabled, } from './global';
15
+ export { sendToConsole } from './sinks/console';
16
+ export { normalizeTagValue, sendToDatadog, setJourneyRum } from './sinks/datadog';
12
17
  export type { JourneyEvent, JourneyStepEvent, TagValue } from './core';
13
18
  export { useJourneyName, useOptionalJourneyName } from './integrations/react/context';
14
19
  export { JourneyScope } from './integrations/react/scope';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,UAAU,CAAC;AAElB,OAAO,EAEH,iBAAiB,EAEjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,kB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,iBAAiB,EACtB,KAAK,UAAU,GAClB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACH,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,aAAa,GACrB,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACH,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAElF,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -3,16 +3,22 @@
3
3
  * import core APIs (defineJourney, etc.). Paired with package.json "sideEffects" for
4
4
  * config — otherwise bundlers with sideEffects:false would drop an unused re-export.
5
5
  */ import './config';
6
- export { // Custom transport adapters only.
7
- activeJourneyStep, // Prefer defineJourney(...).complete/fail/… free helpers for name-from-context call sites.
8
- completeJourney, defineJourney, excludeJourney, failJourney, journeyStep, reportBackendRequest, resolveJourneyStep, setJourneyTags, JourneyStepTag } from './core';
6
+ export { // Preferred app API.
7
+ defineJourney, // Name-string lifecycle (prefer handle methods when you own the journey).
8
+ completeJourney, excludeJourney, failJourney, journeyStep, setJourneyTags, // Custom transport adapters / request attribution.
9
+ activeJourneyStep, reportBackendRequest, resolveJourneyStep, JourneyStepTag } from './core';
9
10
  export { configureJourney } from './config';
10
- /** Test helper — clears open journeys / ambient steps on the default engine. */ export { resetJourney } from './core';
11
+ /**
12
+ * @internal Accidentally exported — removing it is a breaking change, so it stays
13
+ * for compatibility. Not part of the supported public API. Test helper only.
14
+ */ export { resetJourney } from './core';
11
15
  export { instrumentAxios } from './integrations/axios';
12
16
  export { instrumentFetch } from './integrations/fetch';
13
17
  export { exposeAppJourney, instrumentJquery } from './integrations/jquery';
14
18
  export { requestKey } from './integrations/request-key';
15
- export { sendToDatadog, setJourneyRum } from './sinks/datadog';
19
+ export { disableJourney, disableJourneyDebugging, enableJourney, enableJourneyDebugging, isJourneyDebugEnabled, isJourneyEnabled } from './global';
20
+ export { sendToConsole } from './sinks/console';
21
+ export { normalizeTagValue, sendToDatadog, setJourneyRum } from './sinks/datadog';
16
22
  export { useJourneyName, useOptionalJourneyName } from './integrations/react/context';
17
23
  export { JourneyScope } from './integrations/react/scope';
18
24