@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-runtime.d.ts","sourceRoot":"","sources":["../../src/__test-utils__/test-runtime.ts"],"names":[],"mappings":"AAOA,sDAAsD;AACtD,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,qDAAqD;AACrD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,OAE9C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,QAexD"}
@@ -0,0 +1,47 @@
1
+ import { resetJourney } from '../core/runtime';
2
+ import { sendToConsole } from '../sinks/console';
3
+ import { sendToDatadog } from '../sinks/datadog';
4
+ /** Package default sinks installed by `config.ts` bootstrap. */ const DEFAULT_SINKS = [
5
+ sendToDatadog,
6
+ sendToConsole
7
+ ];
8
+ /** Standard journey def used across engine suites. */ export const baseJourneyDef = {
9
+ name: 'journey-under-test',
10
+ team: 'platform',
11
+ group: 'test',
12
+ service: 'journey',
13
+ timeoutMs: 0
14
+ };
15
+ /** Last emitted journey payload from a sink mock. */ export function lastJourney(emitMock) {
16
+ return emitMock.mock.calls[emitMock.mock.calls.length - 1][0].journey;
17
+ }
18
+ /**
19
+ * Wire `emitMock` as the only sink and restore package defaults after each test.
20
+ * Call once at the top of a `describe` block.
21
+ */ export function useJourneyTestRuntime(emitMock) {
22
+ beforeEach(()=>{
23
+ resetJourney({
24
+ sinks: [
25
+ emitMock
26
+ ],
27
+ requestTimeouts: {
28
+ defaultMs: 4000,
29
+ endpoints: []
30
+ }
31
+ });
32
+ emitMock.mockClear();
33
+ });
34
+ afterEach(()=>{
35
+ resetJourney({
36
+ sinks: [
37
+ ...DEFAULT_SINKS
38
+ ],
39
+ requestTimeouts: {
40
+ defaultMs: 4000,
41
+ endpoints: []
42
+ }
43
+ });
44
+ });
45
+ }
46
+
47
+ //# sourceMappingURL=test-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/__test-utils__/test-runtime.ts"],"sourcesContent":["import { resetJourney } from '../core/runtime';\nimport { sendToConsole } from '../sinks/console';\nimport { sendToDatadog } from '../sinks/datadog';\n\n/** Package default sinks installed by `config.ts` bootstrap. */\nconst DEFAULT_SINKS = [sendToDatadog, sendToConsole] as const;\n\n/** Standard journey def used across engine suites. */\nexport const baseJourneyDef = {\n name: 'journey-under-test',\n team: 'platform',\n group: 'test',\n service: 'journey',\n timeoutMs: 0,\n} as const;\n\n/** Last emitted journey payload from a sink mock. */\nexport function lastJourney(emitMock: jest.Mock) {\n return emitMock.mock.calls[emitMock.mock.calls.length - 1][0].journey;\n}\n\n/**\n * Wire `emitMock` as the only sink and restore package defaults after each test.\n * Call once at the top of a `describe` block.\n */\nexport function useJourneyTestRuntime(emitMock: jest.Mock) {\n beforeEach(() => {\n resetJourney({\n sinks: [emitMock],\n requestTimeouts: { defaultMs: 4_000, endpoints: [] },\n });\n emitMock.mockClear();\n });\n\n afterEach(() => {\n resetJourney({\n sinks: [...DEFAULT_SINKS],\n requestTimeouts: { defaultMs: 4_000, endpoints: [] },\n });\n });\n}\n"],"names":["resetJourney","sendToConsole","sendToDatadog","DEFAULT_SINKS","baseJourneyDef","name","team","group","service","timeoutMs","lastJourney","emitMock","mock","calls","length","journey","useJourneyTestRuntime","beforeEach","sinks","requestTimeouts","defaultMs","endpoints","mockClear","afterEach"],"mappings":"AAAA,SAASA,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,aAAa,QAAQ,mBAAmB;AAEjD,8DAA8D,GAC9D,MAAMC,gBAAgB;IAACD;IAAeD;CAAc;AAEpD,oDAAoD,GACpD,OAAO,MAAMG,iBAAiB;IAC1BC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPC,SAAS;IACTC,WAAW;AACf,EAAW;AAEX,mDAAmD,GACnD,OAAO,SAASC,YAAYC,QAAmB;IAC3C,OAAOA,SAASC,IAAI,CAACC,KAAK,CAACF,SAASC,IAAI,CAACC,KAAK,CAACC,MAAM,GAAG,EAAE,CAAC,EAAE,CAACC,OAAO;AACzE;AAEA;;;CAGC,GACD,OAAO,SAASC,sBAAsBL,QAAmB;IACrDM,WAAW;QACPjB,aAAa;YACTkB,OAAO;gBAACP;aAAS;YACjBQ,iBAAiB;gBAAEC,WAAW;gBAAOC,WAAW,EAAE;YAAC;QACvD;QACAV,SAASW,SAAS;IACtB;IAEAC,UAAU;QACNvB,aAAa;YACTkB,OAAO;mBAAIf;aAAc;YACzBgB,iBAAiB;gBAAEC,WAAW;gBAAOC,WAAW,EAAE;YAAC;QACvD;IACJ;AACJ"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ambient.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/ambient.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/api.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-journey.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/define-journey.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/requests.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/runtime.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/step.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeouts.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/timeouts.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** @jest-environment jsdom */
2
+ import '../config';
3
+ //# sourceMappingURL=global.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/global.test.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integrations/axios.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integrations/context.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expose-app-journey.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integrations/expose-app-journey.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integrations/fetch.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jquery.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integrations/jquery.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-key.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integrations/request-key.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integrations/scope.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=console.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/sinks/console.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datadog.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/sinks/datadog.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sinks.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/sinks/sinks.test.ts"],"names":[],"mappings":""}
package/dist/config.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { type JourneySink } from './core/registry';
2
- import { type AppRequestTimeouts, type EndpointPolicy } from './endpoint-policy';
1
+ import type { JourneySink } from './core/types';
2
+ import { type AppRequestTimeouts, type EndpointPolicy } from './core/endpoint-policy';
3
3
  import { type AxiosLikeInstance } from './integrations/axios';
4
4
  import { type InstrumentFetchOptions } from './integrations/fetch';
5
5
  import { type JqueryStatic, type WindowWithAppJourney } from './integrations/jquery';
6
- export { longestEndpointMatch, sortEndpointsByLongestMatch } from './endpoint-policy';
7
6
  export type { AppRequestTimeouts, EndpointPolicy };
8
7
  /** Optional app-wide / per-bundle configuration. */
9
8
  export interface JourneyConfig {
@@ -12,7 +11,8 @@ export interface JourneyConfig {
12
11
  /**
13
12
  * Replace the sink list used when a journey finishes.
14
13
  * Only applied when provided — omit to leave the current list unchanged.
15
- * Package default is `[sendToDatadog]`; pass `[]` to disable emission.
14
+ * Package default is `[sendToDatadog, sendToConsole]`; pass `[]` to disable emission.
15
+ * `sendToConsole` is a no-op unless `localStorage['st:journey:debug'] === 'true'`.
16
16
  */
17
17
  sinks?: readonly JourneySink[];
18
18
  /**
@@ -38,5 +38,9 @@ export interface JourneyConfig {
38
38
  * Optional — call once at startup. Pass this bundle's own axios / `$` / fetch target.
39
39
  */
40
40
  export declare function configureJourney(config: JourneyConfig): void;
41
+ /**
42
+ * @internal Read the module runtime's app-wide request timeout config.
43
+ * Prefer `configureJourney({ requestTimeouts })` to set thresholds. Test / introspection only.
44
+ */
41
45
  export declare function getRequestTimeouts(): AppRequestTimeouts;
42
46
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAEH,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAGH,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC5B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACtF,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC;AAEnD,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC1B,yFAAyF;IACzF,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;I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sB5D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,kBAAkB,CAEvD"}
package/dist/config.js CHANGED
@@ -1,30 +1,33 @@
1
- import { defaultRuntime } from './core/runtime';
2
- import { setJourneySinks } from './core/registry';
3
- import { sortEndpointsByLongestMatch } from './endpoint-policy';
1
+ import { moduleRuntime } from './core/runtime';
2
+ import { installJourneyGlobal, registerJourneyRuntime } from './global';
3
+ import { sortEndpointsByLongestMatch } from './core/endpoint-policy';
4
4
  import { instrumentAxios } from './integrations/axios';
5
5
  import { instrumentFetch } from './integrations/fetch';
6
6
  import { exposeAppJourney, instrumentJquery } from './integrations/jquery';
7
+ import { sendToConsole } from './sinks/console';
7
8
  import { sendToDatadog } from './sinks/datadog';
8
- export { longestEndpointMatch, sortEndpointsByLongestMatch } from './endpoint-policy';
9
9
  /*
10
- * Default emission target. Kept as a module side effect so any import of this file
11
- * (see index.ts `import './config'`) installs Datadog. configureJourney only replaces
12
- * sinks when `sinks` is passed explicitly.
13
- */ setJourneySinks([
14
- sendToDatadog
10
+ * Default emission targets + `__stJourney` bag. Kept as a module side effect so any import
11
+ * of this file (see index.ts `import './config'`) installs Datadog, console, and
12
+ * `__stJourney`. configureJourney only replaces sinks when `sinks` is passed explicitly.
13
+ */ moduleRuntime.setSinks([
14
+ sendToDatadog,
15
+ sendToConsole
15
16
  ]);
17
+ installJourneyGlobal();
18
+ registerJourneyRuntime(moduleRuntime);
16
19
  /**
17
20
  * Apply bundle options: request thresholds, sinks, and/or HTTP / legacy wiring.
18
21
  * Optional — call once at startup. Pass this bundle's own axios / `$` / fetch target.
19
22
  */ export function configureJourney(config) {
20
23
  if (config.requestTimeouts !== undefined) {
21
- defaultRuntime.setRequestTimeouts({
24
+ moduleRuntime.setRequestTimeouts({
22
25
  ...config.requestTimeouts,
23
26
  endpoints: sortEndpointsByLongestMatch(config.requestTimeouts.endpoints)
24
27
  });
25
28
  }
26
29
  if (config.sinks !== undefined) {
27
- setJourneySinks(config.sinks);
30
+ moduleRuntime.setSinks(config.sinks);
28
31
  }
29
32
  if (config.axios !== undefined) {
30
33
  instrumentAxios(config.axios);
@@ -39,8 +42,11 @@ export { longestEndpointMatch, sortEndpointsByLongestMatch } from './endpoint-po
39
42
  exposeAppJourney(config.exposeAppJourney === true ? undefined : config.exposeAppJourney);
40
43
  }
41
44
  }
42
- export function getRequestTimeouts() {
43
- return defaultRuntime.getRequestTimeouts();
45
+ /**
46
+ * @internal Read the module runtime's app-wide request timeout config.
47
+ * Prefer `configureJourney({ requestTimeouts })` to set thresholds. Test / introspection only.
48
+ */ export function getRequestTimeouts() {
49
+ return moduleRuntime.getRequestTimeouts();
44
50
  }
45
51
 
46
52
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { defaultRuntime } from './core/runtime';\nimport { setJourneySinks, type JourneySink } from './core/registry';\nimport {\n sortEndpointsByLongestMatch,\n type AppRequestTimeouts,\n type EndpointPolicy,\n} from './endpoint-policy';\nimport { instrumentAxios, type AxiosLikeInstance } from './integrations/axios';\nimport { instrumentFetch, type InstrumentFetchOptions } from './integrations/fetch';\nimport {\n exposeAppJourney,\n instrumentJquery,\n type JqueryStatic,\n type WindowWithAppJourney,\n} from './integrations/jquery';\nimport { sendToDatadog } from './sinks/datadog';\n\nexport { longestEndpointMatch, sortEndpointsByLongestMatch } from './endpoint-policy';\nexport type { AppRequestTimeouts, EndpointPolicy };\n\n/** Optional app-wide / per-bundle configuration. */\nexport interface JourneyConfig {\n /** App-wide request-timeout fallback. Defaults to { defaultMs: 4000, endpoints: [] }. */\n requestTimeouts?: AppRequestTimeouts;\n /**\n * Replace the sink list used when a journey finishes.\n * Only applied when provided — omit to leave the current list unchanged.\n * Package default is `[sendToDatadog]`; pass `[]` to disable emission.\n */\n sinks?: readonly JourneySink[];\n /**\n * Wire this bundle's axios instance (host or MFE). Same as `instrumentAxios(axios)`.\n * Register any async request interceptors (e.g. auth) before `configureJourney`.\n */\n axios?: AxiosLikeInstance;\n /**\n * Wire fetch. `true` wraps `globalThis.fetch`; pass options for a scoped target / baseURL.\n * Same as `instrumentFetch(...)`.\n */\n fetch?: true | InstrumentFetchOptions;\n /** Wire this bundle's jQuery static. Same as `instrumentJquery($)`. */\n jquery?: JqueryStatic;\n /**\n * Publish `window.App.Journey` for Knockout / legacy hosts.\n * `true` uses the real window; pass a target object in tests.\n */\n exposeAppJourney?: boolean | WindowWithAppJourney;\n}\n\n/*\n * Default emission target. Kept as a module side effect so any import of this file\n * (see index.ts `import './config'`) installs Datadog. configureJourney only replaces\n * sinks when `sinks` is passed explicitly.\n */\nsetJourneySinks([sendToDatadog]);\n\n/**\n * Apply bundle options: request thresholds, sinks, and/or HTTP / legacy wiring.\n * Optional — call once at startup. Pass this bundle's own axios / `$` / fetch target.\n */\nexport function configureJourney(config: JourneyConfig): void {\n if (config.requestTimeouts !== undefined) {\n defaultRuntime.setRequestTimeouts({\n ...config.requestTimeouts,\n endpoints: sortEndpointsByLongestMatch(config.requestTimeouts.endpoints),\n });\n }\n if (config.sinks !== undefined) {\n setJourneySinks(config.sinks);\n }\n if (config.axios !== undefined) {\n instrumentAxios(config.axios);\n }\n if (config.fetch !== undefined) {\n instrumentFetch(config.fetch === true ? {} : config.fetch);\n }\n if (config.jquery !== undefined) {\n instrumentJquery(config.jquery);\n }\n if (config.exposeAppJourney) {\n exposeAppJourney(config.exposeAppJourney === true ? undefined : config.exposeAppJourney);\n }\n}\n\nexport function getRequestTimeouts(): AppRequestTimeouts {\n return defaultRuntime.getRequestTimeouts();\n}\n"],"names":["defaultRuntime","setJourneySinks","sortEndpointsByLongestMatch","instrumentAxios","instrumentFetch","exposeAppJourney","instrumentJquery","sendToDatadog","longestEndpointMatch","configureJourney","config","requestTimeouts","undefined","setRequestTimeouts","endpoints","sinks","axios","fetch","jquery","getRequestTimeouts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,iBAAiB;AAChD,SAASC,eAAe,QAA0B,kBAAkB;AACpE,SACIC,2BAA2B,QAGxB,oBAAoB;AAC3B,SAASC,eAAe,QAAgC,uBAAuB;AAC/E,SAASC,eAAe,QAAqC,uBAAuB;AACpF,SACIC,gBAAgB,EAChBC,gBAAgB,QAGb,wBAAwB;AAC/B,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,SAASC,oBAAoB,EAAEN,2BAA2B,QAAQ,oBAAoB;AAgCtF;;;;CAIC,GACDD,gBAAgB;IAACM;CAAc;AAE/B;;;CAGC,GACD,OAAO,SAASE,iBAAiBC,MAAqB;IAClD,IAAIA,OAAOC,eAAe,KAAKC,WAAW;QACtCZ,eAAea,kBAAkB,CAAC;YAC9B,GAAGH,OAAOC,eAAe;YACzBG,WAAWZ,4BAA4BQ,OAAOC,eAAe,CAACG,SAAS;QAC3E;IACJ;IACA,IAAIJ,OAAOK,KAAK,KAAKH,WAAW;QAC5BX,gBAAgBS,OAAOK,KAAK;IAChC;IACA,IAAIL,OAAOM,KAAK,KAAKJ,WAAW;QAC5BT,gBAAgBO,OAAOM,KAAK;IAChC;IACA,IAAIN,OAAOO,KAAK,KAAKL,WAAW;QAC5BR,gBAAgBM,OAAOO,KAAK,KAAK,OAAO,CAAC,IAAIP,OAAOO,KAAK;IAC7D;IACA,IAAIP,OAAOQ,MAAM,KAAKN,WAAW;QAC7BN,iBAAiBI,OAAOQ,MAAM;IAClC;IACA,IAAIR,OAAOL,gBAAgB,EAAE;QACzBA,iBAAiBK,OAAOL,gBAAgB,KAAK,OAAOO,YAAYF,OAAOL,gBAAgB;IAC3F;AACJ;AAEA,OAAO,SAASc;IACZ,OAAOnB,eAAemB,kBAAkB;AAC5C"}
1
+ {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { moduleRuntime } from './core/runtime';\nimport type { JourneySink } from './core/types';\nimport { installJourneyGlobal, registerJourneyRuntime } from './global';\nimport {\n sortEndpointsByLongestMatch,\n type AppRequestTimeouts,\n type EndpointPolicy,\n} from './core/endpoint-policy';\nimport { instrumentAxios, type AxiosLikeInstance } from './integrations/axios';\nimport { instrumentFetch, type InstrumentFetchOptions } from './integrations/fetch';\nimport {\n exposeAppJourney,\n instrumentJquery,\n type JqueryStatic,\n type WindowWithAppJourney,\n} from './integrations/jquery';\nimport { sendToConsole } from './sinks/console';\nimport { sendToDatadog } from './sinks/datadog';\n\nexport type { AppRequestTimeouts, EndpointPolicy };\n\n/** Optional app-wide / per-bundle configuration. */\nexport interface JourneyConfig {\n /** App-wide request-timeout fallback. Defaults to { defaultMs: 4000, endpoints: [] }. */\n requestTimeouts?: AppRequestTimeouts;\n /**\n * Replace the sink list used when a journey finishes.\n * Only applied when provided — omit to leave the current list unchanged.\n * Package default is `[sendToDatadog, sendToConsole]`; pass `[]` to disable emission.\n * `sendToConsole` is a no-op unless `localStorage['st:journey:debug'] === 'true'`.\n */\n sinks?: readonly JourneySink[];\n /**\n * Wire this bundle's axios instance (host or MFE). Same as `instrumentAxios(axios)`.\n * Register any async request interceptors (e.g. auth) before `configureJourney`.\n */\n axios?: AxiosLikeInstance;\n /**\n * Wire fetch. `true` wraps `globalThis.fetch`; pass options for a scoped target / baseURL.\n * Same as `instrumentFetch(...)`.\n */\n fetch?: true | InstrumentFetchOptions;\n /** Wire this bundle's jQuery static. Same as `instrumentJquery($)`. */\n jquery?: JqueryStatic;\n /**\n * Publish `window.App.Journey` for Knockout / legacy hosts.\n * `true` uses the real window; pass a target object in tests.\n */\n exposeAppJourney?: boolean | WindowWithAppJourney;\n}\n\n/*\n * Default emission targets + `__stJourney` bag. Kept as a module side effect so any import\n * of this file (see index.ts `import './config'`) installs Datadog, console, and\n * `__stJourney`. configureJourney only replaces sinks when `sinks` is passed explicitly.\n */\nmoduleRuntime.setSinks([sendToDatadog, sendToConsole]);\ninstallJourneyGlobal();\nregisterJourneyRuntime(moduleRuntime);\n\n/**\n * Apply bundle options: request thresholds, sinks, and/or HTTP / legacy wiring.\n * Optional — call once at startup. Pass this bundle's own axios / `$` / fetch target.\n */\nexport function configureJourney(config: JourneyConfig): void {\n if (config.requestTimeouts !== undefined) {\n moduleRuntime.setRequestTimeouts({\n ...config.requestTimeouts,\n endpoints: sortEndpointsByLongestMatch(config.requestTimeouts.endpoints),\n });\n }\n if (config.sinks !== undefined) {\n moduleRuntime.setSinks(config.sinks);\n }\n if (config.axios !== undefined) {\n instrumentAxios(config.axios);\n }\n if (config.fetch !== undefined) {\n instrumentFetch(config.fetch === true ? {} : config.fetch);\n }\n if (config.jquery !== undefined) {\n instrumentJquery(config.jquery);\n }\n if (config.exposeAppJourney) {\n exposeAppJourney(config.exposeAppJourney === true ? undefined : config.exposeAppJourney);\n }\n}\n\n/**\n * @internal Read the module runtime's app-wide request timeout config.\n * Prefer `configureJourney({ requestTimeouts })` to set thresholds. Test / introspection only.\n */\nexport function getRequestTimeouts(): AppRequestTimeouts {\n return moduleRuntime.getRequestTimeouts();\n}\n"],"names":["moduleRuntime","installJourneyGlobal","registerJourneyRuntime","sortEndpointsByLongestMatch","instrumentAxios","instrumentFetch","exposeAppJourney","instrumentJquery","sendToConsole","sendToDatadog","setSinks","configureJourney","config","requestTimeouts","undefined","setRequestTimeouts","endpoints","sinks","axios","fetch","jquery","getRequestTimeouts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,WAAW;AACxE,SACIC,2BAA2B,QAGxB,yBAAyB;AAChC,SAASC,eAAe,QAAgC,uBAAuB;AAC/E,SAASC,eAAe,QAAqC,uBAAuB;AACpF,SACIC,gBAAgB,EAChBC,gBAAgB,QAGb,wBAAwB;AAC/B,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,aAAa,QAAQ,kBAAkB;AAkChD;;;;CAIC,GACDT,cAAcU,QAAQ,CAAC;IAACD;IAAeD;CAAc;AACrDP;AACAC,uBAAuBF;AAEvB;;;CAGC,GACD,OAAO,SAASW,iBAAiBC,MAAqB;IAClD,IAAIA,OAAOC,eAAe,KAAKC,WAAW;QACtCd,cAAce,kBAAkB,CAAC;YAC7B,GAAGH,OAAOC,eAAe;YACzBG,WAAWb,4BAA4BS,OAAOC,eAAe,CAACG,SAAS;QAC3E;IACJ;IACA,IAAIJ,OAAOK,KAAK,KAAKH,WAAW;QAC5Bd,cAAcU,QAAQ,CAACE,OAAOK,KAAK;IACvC;IACA,IAAIL,OAAOM,KAAK,KAAKJ,WAAW;QAC5BV,gBAAgBQ,OAAOM,KAAK;IAChC;IACA,IAAIN,OAAOO,KAAK,KAAKL,WAAW;QAC5BT,gBAAgBO,OAAOO,KAAK,KAAK,OAAO,CAAC,IAAIP,OAAOO,KAAK;IAC7D;IACA,IAAIP,OAAOQ,MAAM,KAAKN,WAAW;QAC7BP,iBAAiBK,OAAOQ,MAAM;IAClC;IACA,IAAIR,OAAON,gBAAgB,EAAE;QACzBA,iBAAiBM,OAAON,gBAAgB,KAAK,OAAOQ,YAAYF,OAAON,gBAAgB;IAC3F;AACJ;AAEA;;;CAGC,GACD,OAAO,SAASe;IACZ,OAAOrB,cAAcqB,kBAAkB;AAC3C"}
@@ -1,9 +1,4 @@
1
- import type { JourneyDef, JourneyEvent, JourneyHandle, JourneySink, JourneyState, JourneyStepOptions, JourneyStepRef, JourneyStepTarget, StepHandle, TagValue } from './types';
2
- export type { JourneyHandle, JourneySink };
3
- /** Look up an open journey by name. */
4
- export declare function getOpenJourney(name: string): JourneyState | undefined;
5
- /** First open journey among `names` (order preserved), or null. */
6
- export declare function firstOpenJourney(names: readonly string[]): string | null;
1
+ import type { JourneyDef, JourneyHandle, JourneyStepOptions, JourneyStepRef, JourneyStepTarget, StepHandle, TagValue } from './types';
7
2
  /**
8
3
  * Active step for soft-ambient HTTP attribution, or null when 0 or 2+ steps are in flight
9
4
  * app-wide. Untagged traffic is attributed to that lone step even if unrelated — prefer
@@ -22,23 +17,8 @@ export declare function reportBackendRequest(step: JourneyStepRef | undefined, s
22
17
  * Prefer `defineJourney(...).step` when you own the journey config.
23
18
  */
24
19
  export declare function journeyStep<T>(journey: JourneyStepTarget, stepName: string, fn: (step: StepHandle) => T | Promise<T>, opts?: JourneyStepOptions): Promise<T>;
25
- /**
26
- * journeyStep deferred by one microtask so a parent `<JourneyScope>` opens first
27
- * (React runs child mount effects before parent). Use for mount-effect steps only.
28
- */
29
- export declare function journeyMountStep<T>(journey: JourneyStepTarget, stepName: string, fn: (step: StepHandle) => T | Promise<T>, opts?: JourneyStepOptions): Promise<T>;
30
- /** Replace the sink list (e.g. host bootstrap or tests). Pass `[]` to disable emission. */
31
- export declare function setJourneySinks(next: readonly JourneySink[]): void;
32
- /** Append a sink alongside the current ones. */
33
- export declare function addJourneySink(sink: JourneySink): void;
34
- /** Emit a terminal journey event to every configured sink. */
35
- export declare function emitJourneyEvent(payload: JourneyEvent): void;
36
20
  /** Merge custom tags onto an open journey. No-op if not open. Prefer `handle.setTags`. */
37
21
  export declare function setJourneyTags(name: string | null, tags: Record<string, TagValue>): void;
38
- /** Begin a journey. Restarts (closes) an already-open journey of the same name. */
39
- export declare function startJourney(def: JourneyDef): void;
40
- /** Fail-fast: record reason and emit immediately. Idempotent via `closed`. */
41
- export declare function failJourneyNow(journey: JourneyState, reason: string): void;
42
22
  /** Mark a named journey Bad for a custom reason (fail-fast). Prefer `handle.fail`. */
43
23
  export declare function failJourney(name: string, reason: string): void;
44
24
  /** Successful end. Outcome stays Bad if a breach already occurred. No-op when name is null. Prefer `handle.complete`. */
@@ -47,4 +27,4 @@ export declare function completeJourney(name: string | null, tags?: Record<strin
47
27
  export declare function excludeJourney(name: string): void;
48
28
  /** Turn a journey config into a handle with bound lifecycle methods. Preferred public API. */
49
29
  export declare function defineJourney(def: JourneyDef): JourneyHandle;
50
- //# sourceMappingURL=registry.d.ts.map
30
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/core/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACX,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAEzD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,cAAc,GAAG,SAAS,EAChC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACnB,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAC/B,OAAO,EAAE,iBAAiB,EAC1B,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,CAEZ;AAED,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAExF;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,yHAAyH;AACzH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAE1F;AAED,qHAAqH;AACrH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,aAAa,CAuC5D"}
@@ -1,76 +1,49 @@
1
- import { defaultRuntime } from './runtime';
2
- /** Look up an open journey by name. */ export function getOpenJourney(name) {
3
- return defaultRuntime.getOpenJourney(name);
4
- }
5
- /** First open journey among `names` (order preserved), or null. */ export function firstOpenJourney(names) {
6
- return defaultRuntime.firstOpenJourney(names);
7
- }
1
+ import { moduleRuntime } from './runtime';
8
2
  /**
9
3
  * Active step for soft-ambient HTTP attribution, or null when 0 or 2+ steps are in flight
10
4
  * app-wide. Untagged traffic is attributed to that lone step even if unrelated — prefer
11
5
  * `step.tag()` when the page has background instrumented requests. Adapters call this when
12
6
  * a request has no explicit stamp.
13
7
  */ export function activeJourneyStep() {
14
- return defaultRuntime.activeJourneyStep();
8
+ return moduleRuntime.activeJourneyStep();
15
9
  }
16
10
  /**
17
11
  * Record a finished backend request against a captured step.
18
12
  * 5xx / network / slow (over threshold) mark Bad; 4xx is not counted. Fail-fast on breach.
19
13
  */ export function reportBackendRequest(step, status, durationMs, requestKey) {
20
- defaultRuntime.reportBackendRequest(step, status, durationMs, requestKey);
14
+ moduleRuntime.reportBackendRequest(step, status, durationMs, requestKey);
21
15
  }
22
16
  /**
23
17
  * Run one step of a named journey. Runs untraced (noop handle) when no matching journey is open.
24
18
  * `journey` may be a name, null, or an ordered candidate list.
25
19
  * Prefer `defineJourney(...).step` when you own the journey config.
26
20
  */ export async function journeyStep(journey, stepName, fn, opts) {
27
- return defaultRuntime.journeyStep(journey, stepName, fn, opts);
28
- }
29
- /**
30
- * journeyStep deferred by one microtask so a parent `<JourneyScope>` opens first
31
- * (React runs child mount effects before parent). Use for mount-effect steps only.
32
- */ export async function journeyMountStep(journey, stepName, fn, opts) {
33
- return defaultRuntime.journeyMountStep(journey, stepName, fn, opts);
34
- }
35
- /** Replace the sink list (e.g. host bootstrap or tests). Pass `[]` to disable emission. */ export function setJourneySinks(next) {
36
- defaultRuntime.setSinks(next);
37
- }
38
- /** Append a sink alongside the current ones. */ export function addJourneySink(sink) {
39
- defaultRuntime.addSink(sink);
40
- }
41
- /** Emit a terminal journey event to every configured sink. */ export function emitJourneyEvent(payload) {
42
- defaultRuntime.emit(payload);
21
+ return moduleRuntime.journeyStep(journey, stepName, fn, opts);
43
22
  }
44
23
  /** Merge custom tags onto an open journey. No-op if not open. Prefer `handle.setTags`. */ export function setJourneyTags(name, tags) {
45
- defaultRuntime.setJourneyTags(name, tags);
46
- }
47
- /** Begin a journey. Restarts (closes) an already-open journey of the same name. */ export function startJourney(def) {
48
- defaultRuntime.startJourney(def);
49
- }
50
- /** Fail-fast: record reason and emit immediately. Idempotent via `closed`. */ export function failJourneyNow(journey, reason) {
51
- defaultRuntime.failJourneyNow(journey, reason);
24
+ moduleRuntime.setJourneyTags(name, tags);
52
25
  }
53
26
  /** Mark a named journey Bad for a custom reason (fail-fast). Prefer `handle.fail`. */ export function failJourney(name, reason) {
54
- defaultRuntime.failJourney(name, reason);
27
+ moduleRuntime.failJourney(name, reason);
55
28
  }
56
29
  /** Successful end. Outcome stays Bad if a breach already occurred. No-op when name is null. Prefer `handle.complete`. */ export function completeJourney(name, tags) {
57
- defaultRuntime.completeJourney(name, tags);
30
+ moduleRuntime.completeJourney(name, tags);
58
31
  }
59
32
  /** User left before finishing. Stays Bad if a breach already occurred (breach-anchored). Prefer `handle.exclude`. */ export function excludeJourney(name) {
60
- defaultRuntime.excludeJourney(name);
33
+ moduleRuntime.excludeJourney(name);
61
34
  }
62
35
  /** Turn a journey config into a handle with bound lifecycle methods. Preferred public API. */ export function defineJourney(def) {
63
36
  const ensureStarted = ()=>{
64
- if (!getOpenJourney(def.name)) {
65
- startJourney(def);
37
+ if (!moduleRuntime.getOpenJourney(def.name)) {
38
+ moduleRuntime.startJourney(def);
66
39
  }
67
40
  };
68
41
  const handle = {
69
42
  ...def,
70
43
  start (tags) {
71
- startJourney(def);
44
+ moduleRuntime.startJourney(def);
72
45
  if (tags) {
73
- setJourneyTags(def.name, tags);
46
+ moduleRuntime.setJourneyTags(def.name, tags);
74
47
  }
75
48
  },
76
49
  step (stepName, fn, opts) {
@@ -99,4 +72,4 @@ import { defaultRuntime } from './runtime';
99
72
  return handle;
100
73
  }
101
74
 
102
- //# sourceMappingURL=registry.js.map
75
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/api.ts"],"sourcesContent":["import { moduleRuntime } from './runtime';\nimport type {\n JourneyDef,\n JourneyHandle,\n JourneyStepOptions,\n JourneyStepRef,\n JourneyStepTarget,\n StepHandle,\n TagValue,\n} from './types';\n\n/**\n * Active step for soft-ambient HTTP attribution, or null when 0 or 2+ steps are in flight\n * app-wide. Untagged traffic is attributed to that lone step even if unrelated — prefer\n * `step.tag()` when the page has background instrumented requests. Adapters call this when\n * a request has no explicit stamp.\n */\nexport function activeJourneyStep(): JourneyStepRef | null {\n return moduleRuntime.activeJourneyStep();\n}\n\n/**\n * Record a finished backend request against a captured step.\n * 5xx / network / slow (over threshold) mark Bad; 4xx is not counted. Fail-fast on breach.\n */\nexport function reportBackendRequest(\n step: JourneyStepRef | undefined,\n status: number | undefined,\n durationMs: number,\n requestKey: string\n): void {\n moduleRuntime.reportBackendRequest(step, status, durationMs, requestKey);\n}\n\n/**\n * Run one step of a named journey. Runs untraced (noop handle) when no matching journey is open.\n * `journey` may be a name, null, or an ordered candidate list.\n * Prefer `defineJourney(...).step` when you own the journey config.\n */\nexport async function journeyStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n): Promise<T> {\n return moduleRuntime.journeyStep(journey, stepName, fn, opts);\n}\n\n/** Merge custom tags onto an open journey. No-op if not open. Prefer `handle.setTags`. */\nexport function setJourneyTags(name: string | null, tags: Record<string, TagValue>): void {\n moduleRuntime.setJourneyTags(name, tags);\n}\n\n/** Mark a named journey Bad for a custom reason (fail-fast). Prefer `handle.fail`. */\nexport function failJourney(name: string, reason: string): void {\n moduleRuntime.failJourney(name, reason);\n}\n\n/** Successful end. Outcome stays Bad if a breach already occurred. No-op when name is null. Prefer `handle.complete`. */\nexport function completeJourney(name: string | null, tags?: Record<string, TagValue>): void {\n moduleRuntime.completeJourney(name, tags);\n}\n\n/** User left before finishing. Stays Bad if a breach already occurred (breach-anchored). Prefer `handle.exclude`. */\nexport function excludeJourney(name: string): void {\n moduleRuntime.excludeJourney(name);\n}\n\n/** Turn a journey config into a handle with bound lifecycle methods. Preferred public API. */\nexport function defineJourney(def: JourneyDef): JourneyHandle {\n const ensureStarted = () => {\n if (!moduleRuntime.getOpenJourney(def.name)) {\n moduleRuntime.startJourney(def);\n }\n };\n\n const handle: JourneyHandle = {\n ...def,\n start(tags) {\n moduleRuntime.startJourney(def);\n if (tags) {\n moduleRuntime.setJourneyTags(def.name, tags);\n }\n },\n step(stepName, fn, opts) {\n ensureStarted();\n return journeyStep(def.name, stepName, fn, opts);\n },\n async mountStep(stepName, fn, opts) {\n // Defer so a parent <JourneyScope> opens first (child effects run before parent).\n await Promise.resolve();\n ensureStarted();\n return journeyStep(def.name, stepName, fn, opts);\n },\n complete(tags) {\n completeJourney(def.name, tags);\n },\n fail(reason) {\n failJourney(def.name, reason);\n },\n exclude() {\n excludeJourney(def.name);\n },\n setTags(tags) {\n setJourneyTags(def.name, tags);\n },\n };\n return handle;\n}\n"],"names":["moduleRuntime","activeJourneyStep","reportBackendRequest","step","status","durationMs","requestKey","journeyStep","journey","stepName","fn","opts","setJourneyTags","name","tags","failJourney","reason","completeJourney","excludeJourney","defineJourney","def","ensureStarted","getOpenJourney","startJourney","handle","start","mountStep","Promise","resolve","complete","fail","exclude","setTags"],"mappings":"AAAA,SAASA,aAAa,QAAQ,YAAY;AAW1C;;;;;CAKC,GACD,OAAO,SAASC;IACZ,OAAOD,cAAcC,iBAAiB;AAC1C;AAEA;;;CAGC,GACD,OAAO,SAASC,qBACZC,IAAgC,EAChCC,MAA0B,EAC1BC,UAAkB,EAClBC,UAAkB;IAElBN,cAAcE,oBAAoB,CAACC,MAAMC,QAAQC,YAAYC;AACjE;AAEA;;;;CAIC,GACD,OAAO,eAAeC,YAClBC,OAA0B,EAC1BC,QAAgB,EAChBC,EAAwC,EACxCC,IAAyB;IAEz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mB,SAAQlB,IAAI;YACRF,eAAeQ,IAAIP,IAAI,EAAEC;QAC7B;IACJ;IACA,OAAOU;AACX"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-policy.d.ts","sourceRoot":"","sources":["../../src/core/endpoint-policy.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,WAAW,cAAc;IAC3B;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IAC/B,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,SAAS,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CACzC;AAED,6EAA6E;AAC7E,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,GACjD,cAAc,EAAE,GAAG,SAAS,CAQ9B;AAiBD;;;GAGG;AACH,wBAAgB,oBAAoB,CAChC,SAAS,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,EAChD,GAAG,EAAE,MAAM,GACZ,cAAc,GAAG,SAAS,CAO5B"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/endpoint-policy.ts"],"sourcesContent":["/** Per-endpoint request policy (app-wide or per-journey). Longest matching prefix wins. */\nexport interface EndpointPolicy {\n /**\n * Path/host prefix against the request key (`\"/path\"` same-origin, `\"host/path\"` cross-domain).\n * Match requires an exact hit or a `/` boundary after the prefix — `/api/user` matches\n * `/api/user` and `/api/user/42`, but not `/api/user-preferences`. A trailing `/` on\n * `match` already supplies the boundary.\n */\n match: string;\n /** Custom slow-request threshold in ms; omit / 0 falls through. */\n timeoutMs?: number;\n /** When true, errors and slow responses never mark the journey Bad. */\n ignore?: boolean;\n}\n\n/** App-wide slow-request threshold fallback (not an axios abort). */\nexport interface AppRequestTimeouts {\n /** Fallback threshold when no endpoint or journey override applies. */\n defaultMs: number;\n /** App-wide endpoint overrides; journey-specific ones belong on JourneyDef.endpoints. */\n endpoints?: readonly EndpointPolicy[];\n}\n\n/** Copy sorted longest-match-first so lookup can return on the first hit. */\nexport function sortEndpointsByLongestMatch(\n endpoints: readonly EndpointPolicy[] | undefined\n): EndpointPolicy[] | undefined {\n if (endpoints == null) {\n return undefined;\n }\n if (endpoints.length <= 1) {\n return endpoints.length === 0 ? [] : [...endpoints];\n }\n return [...endpoints].sort((a, b) => b.match.length - a.match.length);\n}\n\n/**\n * True when `key` equals `match` or continues past a path boundary.\n * `/api/user` matches `/api/user` and `/api/user/42`, not `/api/user-preferences`.\n */\nfunction matchesEndpoint(key: string, match: string): boolean {\n if (!key.startsWith(match)) {\n return false;\n }\n if (match.endsWith('/')) {\n return true;\n }\n const next = key[match.length];\n return next === undefined || next === '/';\n}\n\n/**\n * Longest-prefix match of an endpoint list against a request key.\n * Expects `endpoints` sorted longest-match-first (see `sortEndpointsByLongestMatch`).\n */\nexport function longestEndpointMatch(\n endpoints: readonly EndpointPolicy[] | undefined,\n key: string\n): EndpointPolicy | undefined {\n for (const e of endpoints ?? []) {\n if (matchesEndpoint(key, e.match)) {\n return e;\n }\n }\n return undefined;\n}\n"],"names":["sortEndpointsByLongestMatch","endpoints","undefined","length","sort","a","b","match","matchesEndpoint","key","startsWith","endsWith","next","longestEndpointMatch","e"],"mappings":"AAAA,yFAAyF,GAuBzF,2EAA2E,GAC3E,OAAO,SAASA,4BACZC,SAAgD;IAEhD,IAAIA,aAAa,MAAM;QACnB,OAAOC;IACX;IACA,IAAID,UAAUE,MAAM,IAAI,GAAG;QACvB,OAAOF,UAAUE,MAAM,KAAK,IAAI,EAAE,GAAG;eAAIF;SAAU;IACvD;IACA,OAAO;WAAIA;KAAU,CAACG,IAAI,CAAC,CAACC,GAAGC,IAAMA,EAAEC,KAAK,CAACJ,MAAM,GAAGE,EAAEE,KAAK,CAACJ,MAAM;AACxE;AAEA;;;CAGC,GACD,SAASK,gBAAgBC,GAAW,EAAEF,KAAa;IAC/C,IAAI,CAACE,IAAIC,UAAU,CAACH,QAAQ;QACxB,OAAO;IACX;IACA,IAAIA,MAAMI,QAAQ,CAAC,MAAM;QACrB,OAAO;IACX;IACA,MAAMC,OAAOH,GAAG,CAACF,MAAMJ,MAAM,CAAC;IAC9B,OAAOS,SAASV,aAAaU,SAAS;AAC1C;AAEA;;;CAGC,GACD,OAAO,SAASC,qBACZZ,SAAgD,EAChDQ,GAAW;IAEX,KAAK,MAAMK,KAAKb,sBAAAA,uBAAAA,YAAa,EAAE,CAAE;QAC7B,IAAIO,gBAAgBC,KAAKK,EAAEP,KAAK,GAAG;YAC/B,OAAOO;QACX;IACJ;IACA,OAAOZ;AACX"}
@@ -1,6 +1,6 @@
1
- /** Core engine barrel — free helpers over the default runtime, plus handles and types. */
2
- export { activeJourneyStep, addJourneySink, completeJourney, defineJourney, emitJourneyEvent, excludeJourney, failJourney, firstOpenJourney, journeyMountStep, journeyStep, reportBackendRequest, setJourneySinks, setJourneyTags, startJourney, type JourneyHandle, type JourneySink, } from './registry';
3
- export { createJourneyRuntime, defaultRuntime, resetJourney, type JourneyRuntime, type JourneyRuntimeOptions, } from './runtime';
4
- export type { JourneyDef, JourneyEvent, JourneyNameLike, JourneyStepEvent, JourneyStepOptions, JourneyStepRef, JourneyStepTarget, StepHandle, TagValue, } from './types';
1
+ /** Core barrel — public free helpers, handles, and types. Engine lives in `./runtime`. */
2
+ export { activeJourneyStep, completeJourney, defineJourney, excludeJourney, failJourney, journeyStep, reportBackendRequest, setJourneyTags, } from './api';
3
+ export { resetJourney, } from './runtime';
4
+ export type { JourneyDef, JourneyEvent, JourneyHandle, JourneyNameLike, JourneySink, JourneyStepEvent, JourneyStepOptions, JourneyStepRef, JourneyStepTarget, StepHandle, TagValue, } from './types';
5
5
  export { JourneyStepTag, resolveJourneyStep } from './step-tag';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,WAAW,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACH,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC7B,MAAM,WAAW,CAAC;AACnB,YAAY,EACR,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,QAAQ,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,OAAO,EACH,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,cAAc,GACjB,MAAM,OAAO,CAAC;AACf,OAAO,EAEH,YAAY,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,QAAQ,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,5 +1,6 @@
1
- /** Core engine barrel — free helpers over the default runtime, plus handles and types. */ export { activeJourneyStep, addJourneySink, completeJourney, defineJourney, emitJourneyEvent, excludeJourney, failJourney, firstOpenJourney, journeyMountStep, journeyStep, reportBackendRequest, setJourneySinks, setJourneyTags, startJourney } from './registry';
2
- export { createJourneyRuntime, defaultRuntime, resetJourney } from './runtime';
1
+ /** Core barrel — public free helpers, handles, and types. Engine lives in `./runtime`. */ export { activeJourneyStep, completeJourney, defineJourney, excludeJourney, failJourney, journeyStep, reportBackendRequest, setJourneyTags } from './api';
2
+ export { // @internal accidentally public via package index; not a supported consumer API.
3
+ resetJourney } from './runtime';
3
4
  export { JourneyStepTag, resolveJourneyStep } from './step-tag';
4
5
 
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["/** Core engine barrel — free helpers over the default runtime, plus handles and types. */\n\nexport {\n activeJourneyStep,\n addJourneySink,\n completeJourney,\n defineJourney,\n emitJourneyEvent,\n excludeJourney,\n failJourney,\n firstOpenJourney,\n journeyMountStep,\n journeyStep,\n reportBackendRequest,\n setJourneySinks,\n setJourneyTags,\n startJourney,\n type JourneyHandle,\n type JourneySink,\n} from './registry';\nexport {\n createJourneyRuntime,\n defaultRuntime,\n resetJourney,\n type JourneyRuntime,\n type JourneyRuntimeOptions,\n} from './runtime';\nexport type {\n JourneyDef,\n JourneyEvent,\n JourneyNameLike,\n JourneyStepEvent,\n JourneyStepOptions,\n JourneyStepRef,\n JourneyStepTarget,\n StepHandle,\n TagValue,\n} from './types';\nexport { JourneyStepTag, resolveJourneyStep } from './step-tag';\n"],"names":["activeJourneyStep","addJourneySink","completeJourney","defineJourney","emitJourneyEvent","excludeJourney","failJourney","firstOpenJourney","journeyMountStep","journeyStep","reportBackendRequest","setJourneySinks","setJourneyTags","startJourney","createJourneyRuntime","defaultRuntime","resetJourney","JourneyStepTag","resolveJourneyStep"],"mappings":"AAAA,wFAAwF,GAExF,SACIA,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,WAAW,EACXC,gBAAgB,EAChBC,gBAAgB,EAChBC,WAAW,EACXC,oBAAoB,EACpBC,eAAe,EACfC,cAAc,EACdC,YAAY,QAGT,aAAa;AACpB,SACIC,oBAAoB,EACpBC,cAAc,EACdC,YAAY,QAGT,YAAY;AAYnB,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,aAAa"}
1
+ {"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["/** Core barrel — public free helpers, handles, and types. Engine lives in `./runtime`. */\n\nexport {\n activeJourneyStep,\n completeJourney,\n defineJourney,\n excludeJourney,\n failJourney,\n journeyStep,\n reportBackendRequest,\n setJourneyTags,\n} from './api';\nexport {\n // @internal — accidentally public via package index; not a supported consumer API.\n resetJourney,\n} from './runtime';\nexport type {\n JourneyDef,\n JourneyEvent,\n JourneyHandle,\n JourneyNameLike,\n JourneySink,\n JourneyStepEvent,\n JourneyStepOptions,\n JourneyStepRef,\n JourneyStepTarget,\n StepHandle,\n TagValue,\n} from './types';\nexport { JourneyStepTag, resolveJourneyStep } from './step-tag';\n"],"names":["activeJourneyStep","completeJourney","defineJourney","excludeJourney","failJourney","journeyStep","reportBackendRequest","setJourneyTags","resetJourney","JourneyStepTag","resolveJourneyStep"],"mappings":"AAAA,wFAAwF,GAExF,SACIA,iBAAiB,EACjBC,eAAe,EACfC,aAAa,EACbC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,oBAAoB,EACpBC,cAAc,QACX,QAAQ;AACf,SACI,mFAAmF;AACnFC,YAAY,QACT,YAAY;AAcnB,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,aAAa"}
@@ -1,16 +1,39 @@
1
- import { type AppRequestTimeouts } from '../endpoint-policy';
2
- import type { JourneyDef, JourneyEvent, JourneySink, JourneyState, JourneyStepOptions, JourneyStepRef, JourneyStepTarget, StepHandle, TagValue } from './types';
1
+ import { type AppRequestTimeouts } from './endpoint-policy';
2
+ import type { JourneyDef, JourneyEvent, JourneySink, JourneyState, JourneyStepOptions, JourneyStepRef, JourneyStepTarget, Outcome, StepHandle, TagValue } from './types';
3
3
  /** @internal Private — not part of the public package API. */
4
4
  export interface JourneyRuntimeOptions {
5
- /** Initial sinks. Defaults to `[]` — package bootstrap installs Datadog on the default runtime. */
5
+ /** Initial sinks. Defaults to `[]` — package bootstrap installs Datadog on the module runtime. */
6
6
  sinks?: readonly JourneySink[];
7
7
  requestTimeouts?: AppRequestTimeouts;
8
8
  }
9
+ /** @internal Read-only snapshot for DevTools (`__stJourney.getDebugState`; empty unless debugging). */
10
+ export interface JourneyRuntimeDebugSnapshot {
11
+ openJourneys: readonly {
12
+ name: string;
13
+ team: string;
14
+ group: string;
15
+ service: string;
16
+ verdict: Outcome;
17
+ reason: string | null;
18
+ tags: Record<string, TagValue>;
19
+ stepsInFlight: readonly string[];
20
+ steps: readonly {
21
+ name: string;
22
+ outcome: 'good' | 'bad';
23
+ durationMs: number;
24
+ reason?: string;
25
+ }[];
26
+ }[];
27
+ activeStep: {
28
+ journey: string;
29
+ name: string;
30
+ } | null;
31
+ }
9
32
  /**
10
33
  * @internal Private — not part of the public package API.
11
34
  * Isolated journey engine (open journeys, ambient steps, sinks, request thresholds).
12
35
  * App code should keep using free helpers (`defineJourney`, `journeyStep`, …) — they
13
- * bind to the process default runtime. Prefer `resetJourney()` in tests.
36
+ * bind to the module runtime. Prefer `resetJourney()` in tests.
14
37
  */
15
38
  export interface JourneyRuntime {
16
39
  getRequestTimeouts(): AppRequestTimeouts;
@@ -19,6 +42,8 @@ export interface JourneyRuntime {
19
42
  addSink(sink: JourneySink): void;
20
43
  emit(payload: JourneyEvent): void;
21
44
  getOpenJourney(name: string): JourneyState | undefined;
45
+ /** @internal DevTools snapshot of open journeys / ambient step. */
46
+ getDebugSnapshot(): JourneyRuntimeDebugSnapshot;
22
47
  firstOpenJourney(names: readonly string[]): string | null;
23
48
  setJourneyTags(name: string | null, tags: Record<string, TagValue>): void;
24
49
  startJourney(def: JourneyDef): void;
@@ -40,11 +65,14 @@ export interface JourneyRuntime {
40
65
  export declare function createJourneyRuntime(options?: JourneyRuntimeOptions): JourneyRuntime;
41
66
  /**
42
67
  * @internal Private — not part of the public package API.
43
- * Process-wide engine used by free helpers. App code does not need to touch this.
68
+ * Module-scoped engine used by free helpers. App code does not need to touch this.
69
+ * Each host/MFE bundle gets its own copy when the package is duplicated.
44
70
  */
45
- export declare const defaultRuntime: JourneyRuntime;
71
+ export declare const moduleRuntime: JourneyRuntime;
46
72
  /**
47
- * Reset the default engine (open journeys, ambient steps, sinks, request thresholds).
73
+ * @internal Accidentally exported removing it is a breaking change, so it stays
74
+ * for compatibility. Not part of the supported public API.
75
+ * Reset the module engine (open journeys, ambient steps, sinks, request thresholds).
48
76
  * Intended for tests — call in `beforeEach` / `afterEach` instead of manual cleanup.
49
77
  */
50
78
  export declare function resetJourney(options?: JourneyRuntimeOptions): void;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,kBAAkB,EAC1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACR,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EAEZ,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EAEjB,UAAU,EAEV,QAAQ,EACX,MAAM,SAAS,CAAC;AAiBjB,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IAClC,mGAAmG;IACnG,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,kBAAkB,CAAC;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,kBAAkB,IAAI,kBAAkB,CAAC;IACzC,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEnD,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,IAAI,CAAC;IAC7C,OAA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