@servicetitan/journey 2.0.0 → 3.0.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 (233) hide show
  1. package/README.md +1 -1
  2. package/dist/__test-utils__/test-runtime.d.ts.map +1 -0
  3. package/dist/__test-utils__/test-runtime.js +54 -0
  4. package/dist/__test-utils__/test-runtime.js.map +1 -0
  5. package/dist/__tests__/core/ambient.test.d.ts.map +1 -0
  6. package/dist/__tests__/core/api.test.d.ts +2 -0
  7. package/dist/__tests__/core/api.test.d.ts.map +1 -0
  8. package/dist/__tests__/core/define-journey.test.d.ts.map +1 -0
  9. package/dist/__tests__/core/requests.test.d.ts.map +1 -0
  10. package/dist/__tests__/core/runtime.test.d.ts.map +1 -0
  11. package/dist/__tests__/core/sanitize.test.d.ts +2 -0
  12. package/dist/__tests__/core/sanitize.test.d.ts.map +1 -0
  13. package/dist/__tests__/core/step.test.d.ts.map +1 -0
  14. package/dist/__tests__/core/timeouts.test.d.ts.map +1 -0
  15. package/dist/__tests__/global.test.d.ts +3 -0
  16. package/dist/__tests__/global.test.d.ts.map +1 -0
  17. package/dist/__tests__/hardening.test.d.ts +2 -0
  18. package/dist/__tests__/hardening.test.d.ts.map +1 -0
  19. package/dist/__tests__/integrations/axios.test.d.ts.map +1 -0
  20. package/dist/__tests__/integrations/context.test.d.ts.map +1 -0
  21. package/dist/__tests__/integrations/expose-app-journey.test.d.ts.map +1 -0
  22. package/dist/__tests__/integrations/fetch.test.d.ts.map +1 -0
  23. package/dist/__tests__/integrations/host-mfe.test.d.ts +2 -0
  24. package/dist/__tests__/integrations/host-mfe.test.d.ts.map +1 -0
  25. package/dist/__tests__/integrations/jquery.test.d.ts.map +1 -0
  26. package/dist/__tests__/integrations/request-key.test.d.ts.map +1 -0
  27. package/dist/__tests__/integrations/scope.test.d.ts.map +1 -0
  28. package/dist/__tests__/integrations/use-journey-step.test.d.ts +2 -0
  29. package/dist/__tests__/integrations/use-journey-step.test.d.ts.map +1 -0
  30. package/dist/__tests__/sinks/console.test.d.ts +2 -0
  31. package/dist/__tests__/sinks/console.test.d.ts.map +1 -0
  32. package/dist/__tests__/sinks/datadog.test.d.ts.map +1 -0
  33. package/dist/__tests__/sinks/sinks.test.d.ts.map +1 -0
  34. package/dist/config.d.ts +61 -13
  35. package/dist/config.d.ts.map +1 -1
  36. package/dist/config.js +98 -29
  37. package/dist/config.js.map +1 -1
  38. package/dist/core/abort-error.d.ts +4 -0
  39. package/dist/core/abort-error.d.ts.map +1 -0
  40. package/dist/core/abort-error.js +22 -0
  41. package/dist/core/abort-error.js.map +1 -0
  42. package/dist/core/api.d.ts +43 -0
  43. package/dist/core/api.d.ts.map +1 -0
  44. package/dist/core/api.js +122 -0
  45. package/dist/core/api.js.map +1 -0
  46. package/dist/{endpoint-policy.d.ts → core/endpoint-policy.d.ts} +14 -4
  47. package/dist/core/endpoint-policy.d.ts.map +1 -0
  48. package/dist/core/endpoint-policy.js +70 -0
  49. package/dist/core/endpoint-policy.js.map +1 -0
  50. package/dist/core/index.d.ts +6 -5
  51. package/dist/core/index.d.ts.map +1 -1
  52. package/dist/core/index.js +4 -3
  53. package/dist/core/index.js.map +1 -1
  54. package/dist/core/limits.d.ts +29 -0
  55. package/dist/core/limits.d.ts.map +1 -0
  56. package/dist/core/limits.js +63 -0
  57. package/dist/core/limits.js.map +1 -0
  58. package/dist/core/request-policy.d.ts +39 -0
  59. package/dist/core/request-policy.d.ts.map +1 -0
  60. package/dist/core/request-policy.js +18 -0
  61. package/dist/core/request-policy.js.map +1 -0
  62. package/dist/core/runtime.d.ts +95 -17
  63. package/dist/core/runtime.d.ts.map +1 -1
  64. package/dist/core/runtime.js +435 -124
  65. package/dist/core/runtime.js.map +1 -1
  66. package/dist/core/sanitize.d.ts +23 -0
  67. package/dist/core/sanitize.d.ts.map +1 -0
  68. package/dist/core/sanitize.js +143 -0
  69. package/dist/core/sanitize.js.map +1 -0
  70. package/dist/core/step-tag.d.ts +31 -6
  71. package/dist/core/step-tag.d.ts.map +1 -1
  72. package/dist/core/step-tag.js +62 -9
  73. package/dist/core/step-tag.js.map +1 -1
  74. package/dist/core/types.d.ts +76 -26
  75. package/dist/core/types.d.ts.map +1 -1
  76. package/dist/core/types.js +4 -1
  77. package/dist/core/types.js.map +1 -1
  78. package/dist/global.d.ts +145 -0
  79. package/dist/global.d.ts.map +1 -0
  80. package/dist/global.js +326 -0
  81. package/dist/global.js.map +1 -0
  82. package/dist/index.d.ts +9 -5
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +9 -5
  85. package/dist/index.js.map +1 -1
  86. package/dist/integrations/axios.d.ts +5 -1
  87. package/dist/integrations/axios.d.ts.map +1 -1
  88. package/dist/integrations/axios.js +146 -34
  89. package/dist/integrations/axios.js.map +1 -1
  90. package/dist/integrations/fetch.d.ts +6 -4
  91. package/dist/integrations/fetch.d.ts.map +1 -1
  92. package/dist/integrations/fetch.js +105 -26
  93. package/dist/integrations/fetch.js.map +1 -1
  94. package/dist/integrations/http-report.d.ts +27 -0
  95. package/dist/integrations/http-report.d.ts.map +1 -0
  96. package/dist/integrations/http-report.js +123 -0
  97. package/dist/integrations/http-report.js.map +1 -0
  98. package/dist/integrations/jquery/index.d.ts +10 -6
  99. package/dist/integrations/jquery/index.d.ts.map +1 -1
  100. package/dist/integrations/jquery/index.js +28 -9
  101. package/dist/integrations/jquery/index.js.map +1 -1
  102. package/dist/integrations/jquery/instrument.d.ts +14 -5
  103. package/dist/integrations/jquery/instrument.d.ts.map +1 -1
  104. package/dist/integrations/jquery/instrument.js +111 -29
  105. package/dist/integrations/jquery/instrument.js.map +1 -1
  106. package/dist/integrations/react/context.d.ts +4 -1
  107. package/dist/integrations/react/context.d.ts.map +1 -1
  108. package/dist/integrations/react/context.js +4 -1
  109. package/dist/integrations/react/context.js.map +1 -1
  110. package/dist/integrations/react/scope.d.ts +14 -3
  111. package/dist/integrations/react/scope.d.ts.map +1 -1
  112. package/dist/integrations/react/scope.js +48 -9
  113. package/dist/integrations/react/scope.js.map +1 -1
  114. package/dist/integrations/react/stable-config-keys.d.ts +6 -0
  115. package/dist/integrations/react/stable-config-keys.d.ts.map +1 -0
  116. package/dist/integrations/react/stable-config-keys.js +21 -0
  117. package/dist/integrations/react/stable-config-keys.js.map +1 -0
  118. package/dist/integrations/react/use-journey-step.d.ts +11 -0
  119. package/dist/integrations/react/use-journey-step.d.ts.map +1 -0
  120. package/dist/integrations/react/use-journey-step.js +19 -0
  121. package/dist/integrations/react/use-journey-step.js.map +1 -0
  122. package/dist/integrations/request-key.d.ts +8 -3
  123. package/dist/integrations/request-key.d.ts.map +1 -1
  124. package/dist/integrations/request-key.js +10 -9
  125. package/dist/integrations/request-key.js.map +1 -1
  126. package/dist/integrations/soft-skip.d.ts +7 -0
  127. package/dist/integrations/soft-skip.d.ts.map +1 -0
  128. package/dist/integrations/soft-skip.js +30 -0
  129. package/dist/integrations/soft-skip.js.map +1 -0
  130. package/dist/sinks/console.d.ts +11 -0
  131. package/dist/sinks/console.d.ts.map +1 -0
  132. package/dist/sinks/console.js +19 -0
  133. package/dist/sinks/console.js.map +1 -0
  134. package/dist/sinks/datadog.d.ts +12 -1
  135. package/dist/sinks/datadog.d.ts.map +1 -1
  136. package/dist/sinks/datadog.js +42 -25
  137. package/dist/sinks/datadog.js.map +1 -1
  138. package/package.json +2 -2
  139. package/src/{__mocks__ → __test-utils__}/test-runtime.ts +15 -4
  140. package/src/__tests__/config.test.ts +158 -42
  141. package/src/__tests__/{ambient.test.ts → core/ambient.test.ts} +23 -16
  142. package/src/__tests__/{registry.test.ts → core/api.test.ts} +35 -30
  143. package/src/__tests__/{define-journey.test.ts → core/define-journey.test.ts} +33 -15
  144. package/src/__tests__/{requests.test.ts → core/requests.test.ts} +61 -39
  145. package/src/__tests__/{runtime.test.ts → core/runtime.test.ts} +84 -37
  146. package/src/__tests__/core/sanitize.test.ts +69 -0
  147. package/src/__tests__/{step.test.ts → core/step.test.ts} +146 -52
  148. package/src/__tests__/{timeouts.test.ts → core/timeouts.test.ts} +83 -13
  149. package/src/__tests__/global.test.ts +154 -0
  150. package/src/__tests__/hardening.test.ts +613 -0
  151. package/src/__tests__/integrations/axios.test.ts +616 -0
  152. package/src/__tests__/{context.test.tsx → integrations/context.test.tsx} +1 -1
  153. package/src/__tests__/{expose-app-journey.test.ts → integrations/expose-app-journey.test.ts} +11 -5
  154. package/src/__tests__/{fetch.test.ts → integrations/fetch.test.ts} +159 -25
  155. package/src/__tests__/integrations/host-mfe.test.ts +548 -0
  156. package/src/__tests__/integrations/jquery.test.ts +539 -0
  157. package/src/__tests__/{request-key.test.ts → integrations/request-key.test.ts} +1 -1
  158. package/src/__tests__/integrations/scope.test.tsx +286 -0
  159. package/src/__tests__/integrations/use-journey-step.test.tsx +43 -0
  160. package/src/__tests__/sinks/console.test.ts +103 -0
  161. package/src/__tests__/{datadog.test.ts → sinks/datadog.test.ts} +109 -5
  162. package/src/__tests__/{sinks.test.ts → sinks/sinks.test.ts} +13 -12
  163. package/src/config.ts +173 -41
  164. package/src/core/abort-error.ts +24 -0
  165. package/src/core/api.ts +159 -0
  166. package/src/{endpoint-policy.ts → core/endpoint-policy.ts} +46 -4
  167. package/src/core/index.ts +16 -17
  168. package/src/core/limits.ts +73 -0
  169. package/src/core/request-policy.ts +66 -0
  170. package/src/core/runtime.ts +560 -137
  171. package/src/core/sanitize.ts +177 -0
  172. package/src/core/step-tag.ts +90 -11
  173. package/src/core/types.ts +82 -26
  174. package/src/global.ts +466 -0
  175. package/src/index.ts +31 -18
  176. package/src/integrations/axios.ts +183 -45
  177. package/src/integrations/fetch.ts +127 -41
  178. package/src/integrations/http-report.ts +184 -0
  179. package/src/integrations/jquery/index.ts +37 -18
  180. package/src/integrations/jquery/instrument.ts +126 -42
  181. package/src/integrations/react/context.ts +4 -1
  182. package/src/integrations/react/scope.tsx +61 -10
  183. package/src/integrations/react/stable-config-keys.ts +28 -0
  184. package/src/integrations/react/use-journey-step.ts +31 -0
  185. package/src/integrations/request-key.ts +18 -10
  186. package/src/integrations/soft-skip.ts +35 -0
  187. package/src/sinks/console.ts +21 -0
  188. package/src/sinks/datadog.ts +52 -33
  189. package/dist/__mocks__/test-runtime.d.ts.map +0 -1
  190. package/dist/__tests__/ambient.test.d.ts.map +0 -1
  191. package/dist/__tests__/axios.test.d.ts.map +0 -1
  192. package/dist/__tests__/context.test.d.ts.map +0 -1
  193. package/dist/__tests__/datadog.test.d.ts.map +0 -1
  194. package/dist/__tests__/define-journey.test.d.ts.map +0 -1
  195. package/dist/__tests__/expose-app-journey.test.d.ts.map +0 -1
  196. package/dist/__tests__/fetch.test.d.ts.map +0 -1
  197. package/dist/__tests__/jquery.test.d.ts.map +0 -1
  198. package/dist/__tests__/registry.test.d.ts +0 -2
  199. package/dist/__tests__/registry.test.d.ts.map +0 -1
  200. package/dist/__tests__/request-key.test.d.ts.map +0 -1
  201. package/dist/__tests__/requests.test.d.ts.map +0 -1
  202. package/dist/__tests__/runtime.test.d.ts.map +0 -1
  203. package/dist/__tests__/scope.test.d.ts.map +0 -1
  204. package/dist/__tests__/sinks.test.d.ts.map +0 -1
  205. package/dist/__tests__/step.test.d.ts.map +0 -1
  206. package/dist/__tests__/timeouts.test.d.ts.map +0 -1
  207. package/dist/core/registry.d.ts +0 -50
  208. package/dist/core/registry.d.ts.map +0 -1
  209. package/dist/core/registry.js +0 -102
  210. package/dist/core/registry.js.map +0 -1
  211. package/dist/endpoint-policy.d.ts.map +0 -1
  212. package/dist/endpoint-policy.js +0 -39
  213. package/dist/endpoint-policy.js.map +0 -1
  214. package/src/__tests__/axios.test.ts +0 -365
  215. package/src/__tests__/jquery.test.ts +0 -327
  216. package/src/__tests__/scope.test.tsx +0 -128
  217. package/src/core/registry.ts +0 -162
  218. /package/dist/{__mocks__ → __test-utils__}/test-runtime.d.ts +0 -0
  219. /package/dist/__tests__/{ambient.test.d.ts → core/ambient.test.d.ts} +0 -0
  220. /package/dist/__tests__/{define-journey.test.d.ts → core/define-journey.test.d.ts} +0 -0
  221. /package/dist/__tests__/{requests.test.d.ts → core/requests.test.d.ts} +0 -0
  222. /package/dist/__tests__/{runtime.test.d.ts → core/runtime.test.d.ts} +0 -0
  223. /package/dist/__tests__/{step.test.d.ts → core/step.test.d.ts} +0 -0
  224. /package/dist/__tests__/{timeouts.test.d.ts → core/timeouts.test.d.ts} +0 -0
  225. /package/dist/__tests__/{axios.test.d.ts → integrations/axios.test.d.ts} +0 -0
  226. /package/dist/__tests__/{context.test.d.ts → integrations/context.test.d.ts} +0 -0
  227. /package/dist/__tests__/{expose-app-journey.test.d.ts → integrations/expose-app-journey.test.d.ts} +0 -0
  228. /package/dist/__tests__/{fetch.test.d.ts → integrations/fetch.test.d.ts} +0 -0
  229. /package/dist/__tests__/{jquery.test.d.ts → integrations/jquery.test.d.ts} +0 -0
  230. /package/dist/__tests__/{request-key.test.d.ts → integrations/request-key.test.d.ts} +0 -0
  231. /package/dist/__tests__/{scope.test.d.ts → integrations/scope.test.d.ts} +0 -0
  232. /package/dist/__tests__/{datadog.test.d.ts → sinks/datadog.test.d.ts} +0 -0
  233. /package/dist/__tests__/{sinks.test.d.ts → sinks/sinks.test.d.ts} +0 -0
package/dist/global.js ADDED
@@ -0,0 +1,326 @@
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
+ /** Bump when shared bag shape / policy semantics change incompatibly. */ export const ST_JOURNEY_SCHEMA_VERSION = 2;
5
+ let warnedMissingSlowRequests = false;
6
+ let debugEnabledCache;
7
+ const MAX_INSTRUMENT_RECORDS = 32;
8
+ function storageFor(key) {
9
+ return key === JOURNEY_DEBUG_STORAGE_KEY ? globalThis.sessionStorage : globalThis.localStorage;
10
+ }
11
+ function readFlag(key) {
12
+ try {
13
+ var _storageFor;
14
+ return ((_storageFor = storageFor(key)) === null || _storageFor === void 0 ? void 0 : _storageFor.getItem(key)) === 'true';
15
+ } catch (unused) {
16
+ return false;
17
+ }
18
+ }
19
+ function writeFlag(key, on) {
20
+ try {
21
+ const storage = storageFor(key);
22
+ if (on) {
23
+ storage === null || storage === void 0 ? void 0 : storage.setItem(key, 'true');
24
+ } else {
25
+ storage === null || storage === void 0 ? void 0 : storage.removeItem(key);
26
+ }
27
+ } catch (unused) {
28
+ // ignore storage failures (privacy mode, non-browser)
29
+ }
30
+ }
31
+ /**
32
+ * Host default for journey wiring (e.g. RUM initialized). Stored on `__stJourney` so
33
+ * MFEs see the same value without importing Datadog. Call once after RUM init.
34
+ */ export function setJourneyDefaultEnabled(enabled) {
35
+ ensureGlobal().defaultEnabled = enabled === true;
36
+ }
37
+ /**
38
+ * True when the host default is on or force-enable is set
39
+ * (`st:journey:enabled` / `__stJourney.enable()`).
40
+ */ export function isJourneyEnabled() {
41
+ return ensureGlobal().defaultEnabled === true || readFlag(JOURNEY_ENABLED_STORAGE_KEY);
42
+ }
43
+ /** Set the force-enable flag. Reload after calling from DevTools. */ export function enableJourney() {
44
+ writeFlag(JOURNEY_ENABLED_STORAGE_KEY, true);
45
+ }
46
+ /** Clear the force-enable flag. Reload after calling from DevTools. */ export function disableJourney() {
47
+ writeFlag(JOURNEY_ENABLED_STORAGE_KEY, false);
48
+ }
49
+ /** True when `sessionStorage['st:journey:debug'] === 'true'`. */ export function isJourneyDebugEnabled() {
50
+ const next = readFlag(JOURNEY_DEBUG_STORAGE_KEY);
51
+ if (debugEnabledCache !== next) {
52
+ debugEnabledCache = next;
53
+ }
54
+ return debugEnabledCache;
55
+ }
56
+ /** Set the console-debug flag. Reload after calling from DevTools. */ export function enableJourneyDebugging() {
57
+ writeFlag(JOURNEY_DEBUG_STORAGE_KEY, true);
58
+ debugEnabledCache = true;
59
+ }
60
+ /** Clear the console-debug flag. Reload after calling from DevTools. */ export function disableJourneyDebugging() {
61
+ writeFlag(JOURNEY_DEBUG_STORAGE_KEY, false);
62
+ debugEnabledCache = false;
63
+ }
64
+ function hasRum() {
65
+ return globalThis.DD_RUM != null || getJourneyRumFallback() != null;
66
+ }
67
+ function snapshotOf(entry) {
68
+ if (entry == null || typeof entry !== 'object') {
69
+ return undefined;
70
+ }
71
+ const rec = entry;
72
+ try {
73
+ if (typeof rec.getSnapshot === 'function') {
74
+ var _rec_id, _withId_policyOverlay;
75
+ const snap = rec.getSnapshot();
76
+ const withId = snap.id ? snap : {
77
+ ...snap,
78
+ id: (_rec_id = rec.id) !== null && _rec_id !== void 0 ? _rec_id : ''
79
+ };
80
+ return {
81
+ ...withId,
82
+ policyOverlay: (_withId_policyOverlay = withId.policyOverlay) !== null && _withId_policyOverlay !== void 0 ? _withId_policyOverlay : {
83
+ slowRequests: false,
84
+ httpAbortedRequests: false,
85
+ httpClientErrorRequests: false,
86
+ autoAttributeRequests: false
87
+ }
88
+ };
89
+ }
90
+ if (typeof rec.getDebugSnapshot === 'function') {
91
+ return rec.getDebugSnapshot();
92
+ }
93
+ } catch (unused) {
94
+ return undefined;
95
+ }
96
+ return undefined;
97
+ }
98
+ function buildDebugState(runtimes) {
99
+ if (!isJourneyDebugEnabled()) {
100
+ return {
101
+ enabled: isJourneyEnabled(),
102
+ debug: false,
103
+ hasRum: hasRum(),
104
+ runtimes: []
105
+ };
106
+ }
107
+ return {
108
+ enabled: isJourneyEnabled(),
109
+ debug: true,
110
+ hasRum: hasRum(),
111
+ runtimes: runtimes.map(snapshotOf).filter((snap)=>snap != null)
112
+ };
113
+ }
114
+ function createEmptyPolicies() {
115
+ return {
116
+ slowRequestsConfigured: false,
117
+ httpAbortedRequests: 'continue',
118
+ httpClientErrorRequests: 'continue',
119
+ autoAttributeRequests: true,
120
+ locked: false
121
+ };
122
+ }
123
+ function ensureGlobal() {
124
+ var _ref;
125
+ const g = globalThis;
126
+ const existing = g[ST_JOURNEY_GLOBAL_KEY];
127
+ // Reuse when a prior load already installed the full surface (incl. enable).
128
+ if ((existing === null || existing === void 0 ? void 0 : existing.runtimeRegistrations) && typeof existing.enable === 'function') {
129
+ var _existing, _policies, _existing1, _instrumentedAxios, _existing2, _instrumentedFetch, _existing3, _instrumentedJquery, _existing4, _instrumentRecords;
130
+ if (existing.schemaVersion != null && existing.schemaVersion !== ST_JOURNEY_SCHEMA_VERSION) {
131
+ // eslint-disable-next-line no-console -- cross-bundle version skew
132
+ console.warn(`[journey] __stJourney.schemaVersion mismatch: bag=${existing.schemaVersion}, package=${ST_JOURNEY_SCHEMA_VERSION}`);
133
+ } else {
134
+ var _existing5, _schemaVersion;
135
+ (_schemaVersion = (_existing5 = existing).schemaVersion) !== null && _schemaVersion !== void 0 ? _schemaVersion : _existing5.schemaVersion = ST_JOURNEY_SCHEMA_VERSION;
136
+ }
137
+ (_policies = (_existing = existing).policies) !== null && _policies !== void 0 ? _policies : _existing.policies = createEmptyPolicies();
138
+ if (existing.policies.locked !== true && existing.policies.locked !== false) {
139
+ existing.policies.locked = false;
140
+ }
141
+ (_instrumentedAxios = (_existing1 = existing).instrumentedAxios) !== null && _instrumentedAxios !== void 0 ? _instrumentedAxios : _existing1.instrumentedAxios = new WeakSet();
142
+ (_instrumentedFetch = (_existing2 = existing).instrumentedFetch) !== null && _instrumentedFetch !== void 0 ? _instrumentedFetch : _existing2.instrumentedFetch = new WeakSet();
143
+ (_instrumentedJquery = (_existing3 = existing).instrumentedJquery) !== null && _instrumentedJquery !== void 0 ? _instrumentedJquery : _existing3.instrumentedJquery = new WeakSet();
144
+ (_instrumentRecords = (_existing4 = existing).instrumentRecords) !== null && _instrumentRecords !== void 0 ? _instrumentRecords : _existing4.instrumentRecords = [];
145
+ return existing;
146
+ }
147
+ const runtimes = (_ref = existing === null || existing === void 0 ? void 0 : existing.runtimeRegistrations) !== null && _ref !== void 0 ? _ref : [];
148
+ const api = {
149
+ rum: existing === null || existing === void 0 ? void 0 : existing.rum,
150
+ schemaVersion: ST_JOURNEY_SCHEMA_VERSION,
151
+ defaultEnabled: (existing === null || existing === void 0 ? void 0 : existing.defaultEnabled) === true,
152
+ runtimeRegistrations: runtimes,
153
+ policies: createEmptyPolicies(),
154
+ instrumentedAxios: new WeakSet(),
155
+ instrumentedFetch: new WeakSet(),
156
+ instrumentedJquery: new WeakSet(),
157
+ instrumentRecords: [],
158
+ enable: enableJourney,
159
+ disable: disableJourney,
160
+ isEnabled: isJourneyEnabled,
161
+ enableDebugging: enableJourneyDebugging,
162
+ disableDebugging: disableJourneyDebugging,
163
+ isDebugEnabled: isJourneyDebugEnabled,
164
+ getDebugState () {
165
+ return buildDebugState(api.runtimeRegistrations);
166
+ }
167
+ };
168
+ g[ST_JOURNEY_GLOBAL_KEY] = api;
169
+ return api;
170
+ }
171
+ /** @internal Shared policies bag. */ export function getSharedPolicies() {
172
+ return ensureGlobal().policies;
173
+ }
174
+ export function areSharedPoliciesLocked() {
175
+ return ensureGlobal().policies.locked === true;
176
+ }
177
+ function freezePolicies(policies) {
178
+ const next = {
179
+ ...policies,
180
+ locked: true
181
+ };
182
+ if (next.slowRequests) {
183
+ const endpoints = next.slowRequests.endpoints ? Object.freeze([
184
+ ...next.slowRequests.endpoints
185
+ ]) : next.slowRequests.endpoints;
186
+ next.slowRequests = Object.freeze({
187
+ ...next.slowRequests,
188
+ endpoints
189
+ });
190
+ }
191
+ return Object.freeze(next);
192
+ }
193
+ /**
194
+ * First writer: merge `patch` into the shared bag and freeze it.
195
+ * Returns false when already locked (caller should overlay locally instead).
196
+ */ export function seedSharedPolicies(patch) {
197
+ const api = ensureGlobal();
198
+ if (api.policies.locked) {
199
+ return false;
200
+ }
201
+ api.policies = freezePolicies({
202
+ ...api.policies,
203
+ ...patch
204
+ });
205
+ return true;
206
+ }
207
+ export function getAutoAttributeRequests() {
208
+ return ensureGlobal().policies.autoAttributeRequests !== false;
209
+ }
210
+ export function getHttpAbortedRequestsPolicy() {
211
+ return ensureGlobal().policies.httpAbortedRequests;
212
+ }
213
+ export function getHttpClientErrorRequestsPolicy() {
214
+ return ensureGlobal().policies.httpClientErrorRequests;
215
+ }
216
+ export function getSharedSlowRequests() {
217
+ return ensureGlobal().policies.slowRequests;
218
+ }
219
+ export function areSharedSlowRequestsConfigured() {
220
+ return ensureGlobal().policies.slowRequestsConfigured === true;
221
+ }
222
+ /** One-time warn when transports are wired without explicit slowRequests. */ export function warnIfSlowRequestsUnset() {
223
+ if (warnedMissingSlowRequests || areSharedSlowRequestsConfigured()) {
224
+ return;
225
+ }
226
+ warnedMissingSlowRequests = true;
227
+ // eslint-disable-next-line no-console -- host config guidance
228
+ console.warn('[journey] using default slowRequests.defaultMs=4000 — set configureJourney({ slowRequests }) to tune');
229
+ }
230
+ /** @internal Reset shared policies (tests / teardown). */ export function resetSharedPolicies() {
231
+ const api = ensureGlobal();
232
+ api.policies = createEmptyPolicies();
233
+ warnedMissingSlowRequests = false;
234
+ debugEnabledCache = undefined;
235
+ }
236
+ export function getInstrumentedAxiosSet() {
237
+ return ensureGlobal().instrumentedAxios;
238
+ }
239
+ export function getInstrumentedFetchSet() {
240
+ return ensureGlobal().instrumentedFetch;
241
+ }
242
+ export function getInstrumentedJquerySet() {
243
+ return ensureGlobal().instrumentedJquery;
244
+ }
245
+ export function registerInstrumentRecord(record) {
246
+ const api = ensureGlobal();
247
+ if (api.instrumentRecords.length >= MAX_INSTRUMENT_RECORDS) {
248
+ // eslint-disable-next-line no-console -- defensive cap for repeated instrumentation
249
+ console.warn('[journey] instrumentRecords cap reached — call teardownJourney()');
250
+ return;
251
+ }
252
+ api.instrumentRecords.push(record);
253
+ }
254
+ export function setFetchRestore(restore) {
255
+ ensureGlobal().fetchRestore = restore;
256
+ }
257
+ /**
258
+ * @internal Register this bundle's engine on `__stJourney` so DevTools can list
259
+ * every host/MFE copy on the page. Auto-assigns `runtime-N` when `runtime.id` is empty.
260
+ * Replaces an existing registration with the same id (HMR / test re-register).
261
+ */ export function registerJourneyRuntime(runtime, options) {
262
+ const bag = ensureGlobal();
263
+ if (runtime.id === '') {
264
+ runtime.id = `runtime-${bag.runtimeRegistrations.length + 1}`;
265
+ }
266
+ const entry = {
267
+ id: runtime.id,
268
+ getSnapshot: ()=>runtime.getDebugSnapshot(),
269
+ teardown: options === null || options === void 0 ? void 0 : options.teardown
270
+ };
271
+ const existing = bag.runtimeRegistrations.findIndex((reg)=>reg.id === runtime.id);
272
+ if (existing >= 0) {
273
+ bag.runtimeRegistrations[existing] = entry;
274
+ } else {
275
+ bag.runtimeRegistrations.push(entry);
276
+ }
277
+ }
278
+ /**
279
+ * @internal Store a fallback RUM instance on `__stJourney.rum` when `DD_RUM` is absent.
280
+ * Used by `setJourneyRum`.
281
+ */ export function setJourneyRumFallback(rum) {
282
+ ensureGlobal().rum = rum;
283
+ }
284
+ /** @internal Read `__stJourney.rum` (setJourneyRum fallback). */ export function getJourneyRumFallback() {
285
+ const existing = globalThis[ST_JOURNEY_GLOBAL_KEY];
286
+ return existing === null || existing === void 0 ? void 0 : existing.rum;
287
+ }
288
+ /**
289
+ * Dispose HTTP instrumentation hooks and reset registered engines that supplied a
290
+ * teardown callback. Intended for tests (e.g. afterEach). Prefer `resetJourney`
291
+ * when you only need this bundle's engine state.
292
+ */ export function teardownJourney() {
293
+ const api = ensureGlobal();
294
+ for (const record of api.instrumentRecords){
295
+ record.disposed = true;
296
+ try {
297
+ var _record_restore;
298
+ (_record_restore = record.restore) === null || _record_restore === void 0 ? void 0 : _record_restore.call(record);
299
+ } catch (unused) {
300
+ // ignore restore failures
301
+ }
302
+ }
303
+ api.instrumentRecords = [];
304
+ try {
305
+ var _api_fetchRestore;
306
+ (_api_fetchRestore = api.fetchRestore) === null || _api_fetchRestore === void 0 ? void 0 : _api_fetchRestore.call(api);
307
+ } catch (unused) {
308
+ // ignore
309
+ }
310
+ api.fetchRestore = undefined;
311
+ const kept = [];
312
+ for (const entry of api.runtimeRegistrations){
313
+ if (entry.teardown) {
314
+ try {
315
+ entry.teardown();
316
+ } catch (unused) {
317
+ // ignore
318
+ }
319
+ continue;
320
+ }
321
+ kept.push(entry);
322
+ }
323
+ api.runtimeRegistrations = kept;
324
+ }
325
+
326
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/global.ts"],"sourcesContent":["import type { SlowRequestConfig } from './core/endpoint-policy';\nimport { type RequestPolicyConfig } from './core/request-policy';\nimport 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\n/** Bump when shared bag shape / policy semantics change incompatibly. */\nexport const ST_JOURNEY_SCHEMA_VERSION = 2;\n\nexport interface JourneyDebugState {\n /** Host default or force-enable (`isJourneyEnabled()`). */\n enabled: boolean;\n /** Console-logging flag (`st:journey:debug`). */\n debug: boolean;\n hasRum: boolean;\n runtimes: JourneyRuntimeDebugSnapshot[];\n}\n\n/** Shared host policies visible to every package copy on the page. */\nexport interface JourneySharedPolicies {\n slowRequests?: SlowRequestConfig;\n /** Whether shared slowRequests were explicitly set via configureJourney. */\n slowRequestsConfigured: boolean;\n httpAbortedRequests: RequestPolicyConfig;\n httpClientErrorRequests: RequestPolicyConfig;\n autoAttributeRequests: boolean;\n /** True after the first configureJourney that set any shared policy knob. */\n locked: boolean;\n}\n\n/** DevTools registration — `{ id, getSnapshot }` so older package copies can still list runtimes. */\nexport interface RuntimeRegistration {\n id: string;\n getSnapshot: () => JourneyRuntimeDebugSnapshot;\n teardown?: () => void;\n}\n\n/** @internal Restore/dispose record for HTTP instrumentation. */\nexport interface InstrumentRecord {\n disposed: boolean;\n restore?: () => void;\n}\n\n/**\n * 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 /** Shared bag schema; mismatched copies warn but continue. */\n schemaVersion?: number;\n /** Host default enable (e.g. RUM active). Set via `setJourneyDefaultEnabled`. */\n defaultEnabled?: boolean;\n /** Shared configureJourney policies. */\n policies: JourneySharedPolicies;\n /**\n * Bundle runtimes registered for DevTools `getDebugState()`.\n * `{ id, getSnapshot }` so mixed package copies can list each other.\n */\n runtimeRegistrations: RuntimeRegistration[];\n /** @internal Cross-bundle instrumented axios/fetch/jquery targets. */\n instrumentedAxios: WeakSet<object>;\n instrumentedFetch: WeakSet<object>;\n instrumentedJquery: WeakSet<object>;\n /** @internal Active instrument records for teardown. */\n instrumentRecords: InstrumentRecord[];\n fetchRestore?: () => void;\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\nlet warnedMissingSlowRequests = false;\nlet debugEnabledCache: boolean | undefined;\nconst MAX_INSTRUMENT_RECORDS = 32;\n\nfunction storageFor(key: string): Storage | undefined {\n return key === JOURNEY_DEBUG_STORAGE_KEY ? globalThis.sessionStorage : globalThis.localStorage;\n}\n\nfunction readFlag(key: string): boolean {\n try {\n return storageFor(key)?.getItem(key) === 'true';\n } catch {\n return false;\n }\n}\n\nfunction writeFlag(key: string, on: boolean): void {\n try {\n const storage = storageFor(key);\n if (on) {\n storage?.setItem(key, 'true');\n } else {\n storage?.removeItem(key);\n }\n } catch {\n // ignore storage failures (privacy mode, non-browser)\n }\n}\n\n/**\n * Host default for journey wiring (e.g. RUM initialized). Stored on `__stJourney` so\n * MFEs see the same value without importing Datadog. Call once after RUM init.\n */\nexport function setJourneyDefaultEnabled(enabled: boolean): void {\n ensureGlobal().defaultEnabled = enabled === true;\n}\n\n/**\n * True when the host default is on or force-enable is set\n * (`st:journey:enabled` / `__stJourney.enable()`).\n */\nexport function isJourneyEnabled(): boolean {\n return ensureGlobal().defaultEnabled === true || 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 `sessionStorage['st:journey:debug'] === 'true'`. */\nexport function isJourneyDebugEnabled(): boolean {\n const next = readFlag(JOURNEY_DEBUG_STORAGE_KEY);\n if (debugEnabledCache !== next) {\n debugEnabledCache = next;\n }\n return debugEnabledCache;\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 debugEnabledCache = 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 debugEnabledCache = false;\n}\n\nfunction hasRum(): boolean {\n return (\n (globalThis as Record<string, unknown>).DD_RUM != null || getJourneyRumFallback() != null\n );\n}\n\nfunction snapshotOf(entry: unknown): JourneyRuntimeDebugSnapshot | undefined {\n if (entry == null || typeof entry !== 'object') {\n return undefined;\n }\n const rec = entry as {\n id?: string;\n getSnapshot?: () => JourneyRuntimeDebugSnapshot;\n getDebugSnapshot?: () => JourneyRuntimeDebugSnapshot;\n };\n try {\n if (typeof rec.getSnapshot === 'function') {\n const snap = rec.getSnapshot();\n const withId = snap.id ? snap : { ...snap, id: rec.id ?? '' };\n return {\n ...withId,\n policyOverlay: withId.policyOverlay ?? {\n slowRequests: false,\n httpAbortedRequests: false,\n httpClientErrorRequests: false,\n autoAttributeRequests: false,\n },\n };\n }\n if (typeof rec.getDebugSnapshot === 'function') {\n return rec.getDebugSnapshot();\n }\n } catch {\n return undefined;\n }\n return undefined;\n}\n\nfunction buildDebugState(runtimes: readonly unknown[]): 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\n .map(snapshotOf)\n .filter((snap): snap is JourneyRuntimeDebugSnapshot => snap != null),\n };\n}\n\nfunction createEmptyPolicies(): JourneySharedPolicies {\n return {\n slowRequestsConfigured: false,\n httpAbortedRequests: 'continue',\n httpClientErrorRequests: 'continue',\n autoAttributeRequests: true,\n locked: false,\n };\n}\n\nfunction ensureGlobal(): StJourneyGlobal {\n const g = globalThis as Record<string, unknown>;\n const existing = g[ST_JOURNEY_GLOBAL_KEY] as StJourneyGlobal | undefined;\n // Reuse when a prior load already installed the full surface (incl. enable).\n if (existing?.runtimeRegistrations && typeof existing.enable === 'function') {\n if (\n existing.schemaVersion != null &&\n existing.schemaVersion !== ST_JOURNEY_SCHEMA_VERSION\n ) {\n // eslint-disable-next-line no-console -- cross-bundle version skew\n console.warn(\n `[journey] __stJourney.schemaVersion mismatch: bag=${existing.schemaVersion}, package=${ST_JOURNEY_SCHEMA_VERSION}`\n );\n } else {\n existing.schemaVersion ??= ST_JOURNEY_SCHEMA_VERSION;\n }\n existing.policies ??= createEmptyPolicies();\n if (existing.policies.locked !== true && existing.policies.locked !== false) {\n existing.policies.locked = false;\n }\n existing.instrumentedAxios ??= new WeakSet();\n existing.instrumentedFetch ??= new WeakSet();\n existing.instrumentedJquery ??= new WeakSet();\n existing.instrumentRecords ??= [];\n return existing;\n }\n\n const runtimes: RuntimeRegistration[] = existing?.runtimeRegistrations ?? [];\n\n const api: StJourneyGlobal = {\n rum: existing?.rum,\n schemaVersion: ST_JOURNEY_SCHEMA_VERSION,\n defaultEnabled: existing?.defaultEnabled === true,\n runtimeRegistrations: runtimes,\n policies: createEmptyPolicies(),\n instrumentedAxios: new WeakSet(),\n instrumentedFetch: new WeakSet(),\n instrumentedJquery: new WeakSet(),\n instrumentRecords: [],\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/** @internal Shared policies bag. */\nexport function getSharedPolicies(): JourneySharedPolicies {\n return ensureGlobal().policies;\n}\n\nexport function areSharedPoliciesLocked(): boolean {\n return ensureGlobal().policies.locked === true;\n}\n\nfunction freezePolicies(policies: JourneySharedPolicies): JourneySharedPolicies {\n const next: JourneySharedPolicies = { ...policies, locked: true };\n if (next.slowRequests) {\n const endpoints = next.slowRequests.endpoints\n ? Object.freeze([...next.slowRequests.endpoints])\n : next.slowRequests.endpoints;\n next.slowRequests = Object.freeze({ ...next.slowRequests, endpoints });\n }\n return Object.freeze(next);\n}\n\n/**\n * First writer: merge `patch` into the shared bag and freeze it.\n * Returns false when already locked (caller should overlay locally instead).\n */\nexport function seedSharedPolicies(patch: Partial<Omit<JourneySharedPolicies, 'locked'>>): boolean {\n const api = ensureGlobal();\n if (api.policies.locked) {\n return false;\n }\n api.policies = freezePolicies({ ...api.policies, ...patch });\n return true;\n}\n\nexport function getAutoAttributeRequests(): boolean {\n return ensureGlobal().policies.autoAttributeRequests !== false;\n}\n\nexport function getHttpAbortedRequestsPolicy(): RequestPolicyConfig {\n return ensureGlobal().policies.httpAbortedRequests;\n}\n\nexport function getHttpClientErrorRequestsPolicy(): RequestPolicyConfig {\n return ensureGlobal().policies.httpClientErrorRequests;\n}\n\nexport function getSharedSlowRequests(): SlowRequestConfig | undefined {\n return ensureGlobal().policies.slowRequests;\n}\n\nexport function areSharedSlowRequestsConfigured(): boolean {\n return ensureGlobal().policies.slowRequestsConfigured === true;\n}\n\n/** One-time warn when transports are wired without explicit slowRequests. */\nexport function warnIfSlowRequestsUnset(): void {\n if (warnedMissingSlowRequests || areSharedSlowRequestsConfigured()) {\n return;\n }\n warnedMissingSlowRequests = true;\n // eslint-disable-next-line no-console -- host config guidance\n console.warn(\n '[journey] using default slowRequests.defaultMs=4000 — set configureJourney({ slowRequests }) to tune'\n );\n}\n\n/** @internal Reset shared policies (tests / teardown). */\nexport function resetSharedPolicies(): void {\n const api = ensureGlobal();\n api.policies = createEmptyPolicies();\n warnedMissingSlowRequests = false;\n debugEnabledCache = undefined;\n}\n\nexport function getInstrumentedAxiosSet(): WeakSet<object> {\n return ensureGlobal().instrumentedAxios;\n}\n\nexport function getInstrumentedFetchSet(): WeakSet<object> {\n return ensureGlobal().instrumentedFetch;\n}\n\nexport function getInstrumentedJquerySet(): WeakSet<object> {\n return ensureGlobal().instrumentedJquery;\n}\n\nexport function registerInstrumentRecord(record: InstrumentRecord): void {\n const api = ensureGlobal();\n if (api.instrumentRecords.length >= MAX_INSTRUMENT_RECORDS) {\n // eslint-disable-next-line no-console -- defensive cap for repeated instrumentation\n console.warn('[journey] instrumentRecords cap reached — call teardownJourney()');\n return;\n }\n api.instrumentRecords.push(record);\n}\n\nexport function setFetchRestore(restore: (() => void) | undefined): void {\n ensureGlobal().fetchRestore = restore;\n}\n\n/**\n * @internal Register this bundle's engine on `__stJourney` so DevTools can list\n * every host/MFE copy on the page. Auto-assigns `runtime-N` when `runtime.id` is empty.\n * Replaces an existing registration with the same id (HMR / test re-register).\n */\nexport function registerJourneyRuntime(\n runtime: JourneyRuntime,\n options?: { teardown?: () => void }\n): void {\n const bag = ensureGlobal();\n if (runtime.id === '') {\n (runtime as { id: string }).id = `runtime-${bag.runtimeRegistrations.length + 1}`;\n }\n const entry: RuntimeRegistration = {\n id: runtime.id,\n getSnapshot: () => runtime.getDebugSnapshot(),\n teardown: options?.teardown,\n };\n const existing = bag.runtimeRegistrations.findIndex(reg => reg.id === runtime.id);\n if (existing >= 0) {\n bag.runtimeRegistrations[existing] = entry;\n } else {\n bag.runtimeRegistrations.push(entry);\n }\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\n/**\n * Dispose HTTP instrumentation hooks and reset registered engines that supplied a\n * teardown callback. Intended for tests (e.g. afterEach). Prefer `resetJourney`\n * when you only need this bundle's engine state.\n */\nexport function teardownJourney(): void {\n const api = ensureGlobal();\n for (const record of api.instrumentRecords) {\n record.disposed = true;\n try {\n record.restore?.();\n } catch {\n // ignore restore failures\n }\n }\n api.instrumentRecords = [];\n try {\n api.fetchRestore?.();\n } catch {\n // ignore\n }\n api.fetchRestore = undefined;\n\n const kept: RuntimeRegistration[] = [];\n for (const entry of api.runtimeRegistrations) {\n if (entry.teardown) {\n try {\n entry.teardown();\n } catch {\n // ignore\n }\n continue;\n }\n kept.push(entry);\n }\n api.runtimeRegistrations = kept;\n}\n"],"names":["JOURNEY_ENABLED_STORAGE_KEY","JOURNEY_DEBUG_STORAGE_KEY","ST_JOURNEY_GLOBAL_KEY","ST_JOURNEY_SCHEMA_VERSION","warnedMissingSlowRequests","debugEnabledCache","MAX_INSTRUMENT_RECORDS","storageFor","key","globalThis","sessionStorage","localStorage","readFlag","getItem","writeFlag","on","storage","setItem","removeItem","setJourneyDefaultEnabled","enabled","ensureGlobal","defaultEnabled","isJourneyEnabled","enableJourney","disableJourney","isJourneyDebugEnabled","next","enableJourneyDebugging","disableJourneyDebugging","hasRum","DD_RUM","getJourneyRumFallback","snapshotOf","entry","undefined","rec","getSnapshot","withId","snap","id","policyOverlay","slowRequests","httpAbortedRequests","httpClientErrorRequests","autoAttributeRequests","getDebugSnapshot","buildDebugState","runtimes","debug","map","filter","createEmptyPolicies","slowRequestsConfigured","locked","g","existing","runtimeRegistrations","enable","schemaVersion","console","warn","policies","instrumentedAxios","WeakSet","instrumentedFetch","instrumentedJquery","instrumentRecords","api","rum","disable","isEnabled","enableDebugging","disableDebugging","isDebugEnabled","getDebugState","getSharedPolicies","areSharedPoliciesLocked","freezePolicies","endpoints","Object","freeze","seedSharedPolicies","patch","getAutoAttributeRequests","getHttpAbortedRequestsPolicy","getHttpClientErrorRequestsPolicy","getSharedSlowRequests","areSharedSlowRequestsConfigured","warnIfSlowRequestsUnset","resetSharedPolicies","getInstrumentedAxiosSet","getInstrumentedFetchSet","getInstrumentedJquerySet","registerInstrumentRecord","record","length","push","setFetchRestore","restore","fetchRestore","registerJourneyRuntime","runtime","options","bag","teardown","findIndex","reg","setJourneyRumFallback","teardownJourney","disposed","kept"],"mappings":"AAIA,iFAAiF,GACjF,OAAO,MAAMA,8BAA8B,qBAAqB;AAEhE,sEAAsE,GACtE,OAAO,MAAMC,4BAA4B,mBAAmB;AAE5D,yFAAyF,GACzF,OAAO,MAAMC,wBAAwB,cAAc;AAEnD,uEAAuE,GACvE,OAAO,MAAMC,4BAA4B,EAAE;AA6E3C,IAAIC,4BAA4B;AAChC,IAAIC;AACJ,MAAMC,yBAAyB;AAE/B,SAASC,WAAWC,GAAW;IAC3B,OAAOA,QAAQP,4BAA4BQ,WAAWC,cAAc,GAAGD,WAAWE,YAAY;AAClG;AAEA,SAASC,SAASJ,GAAW;IACzB,IAAI;YACOD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AAoB,CAACiD,SAAS,CAACC,CAAAA,MAAOA,IAAInE,EAAE,KAAK8D,QAAQ9D,EAAE;IAChF,IAAIgB,YAAY,GAAG;QACfgD,IAAI/C,oBAAoB,CAACD,SAAS,GAAGtB;IACzC,OAAO;QACHsE,IAAI/C,oBAAoB,CAACwC,IAAI,CAAC/D;IAClC;AACJ;AAEA;;;CAGC,GACD,OAAO,SAAS0E,sBAAsBvC,GAAY;IAC9ChD,eAAegD,GAAG,GAAGA;AACzB;AAEA,+DAA+D,GAC/D,OAAO,SAASrC;IACZ,MAAMwB,WAAW,AAAC/C,UAAsC,CAACP,sBAAsB;IAE/E,OAAOsD,qBAAAA,+BAAAA,SAAUa,GAAG;AACxB;AAEA;;;;CAIC,GACD,OAAO,SAASwC;IACZ,MAAMzC,MAAM/C;IACZ,KAAK,MAAM0E,UAAU3B,IAAID,iBAAiB,CAAE;QACxC4B,OAAOe,QAAQ,GAAG;QAClB,IAAI;gBACAf;aAAAA,kBAAAA,OAAOI,OAAO,cAAdJ,sCAAAA,qBAAAA;QACJ,EAAE,eAAM;QACJ,0BAA0B;QAC9B;IACJ;IACA3B,IAAID,iBAAiB,GAAG,EAAE;IAC1B,IAAI;YACAC;SAAAA,oBAAAA,IAAIgC,YAAY,cAAhBhC,wCAAAA,uBAAAA;IACJ,EAAE,eAAM;IACJ,SAAS;IACb;IACAA,IAAIgC,YAAY,GAAGjE;IAEnB,MAAM4E,OAA8B,EAAE;IACtC,KAAK,MAAM7E,SAASkC,IAAIX,oBAAoB,CAAE;QAC1C,IAAIvB,MAAMuE,QAAQ,EAAE;YAChB,IAAI;gBACAvE,MAAMuE,QAAQ;YAClB,EAAE,eAAM;YACJ,SAAS;YACb;YACA;QACJ;QACAM,KAAKd,IAAI,CAAC/D;IACd;IACAkC,IAAIX,oBAAoB,GAAGsD;AAC/B"}
package/dist/index.d.ts CHANGED
@@ -1,15 +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';
3
- export { configureJourney, type AppRequestTimeouts, type EndpointPolicy, type JourneyConfig, } from './config';
2
+ export { defineJourney, completeJourney, excludeJourney, failJourney, journeyStep, setJourneyTags, singleInFlightJourneyStep, resolveStamp, JourneyStepStamp, type JourneyDef, type JourneyHandle, type JourneyNameLike, type JourneyStepOptions, type JourneyStepTarget, type StepHandle, } from './core';
3
+ export { configureJourney, type JourneyConfig } from './config';
4
+ export type { EndpointPolicy, SlowRequestConfig } from './core/endpoint-policy';
5
+ export type { JourneyHttpPolicyContext, JourneyHttpScore, JourneyHttpScoreContext, JourneyRequestPolicy, JourneyStampOptions, RequestPolicyConfig, } from './core/request-policy';
4
6
  export type { JourneySink } from './core';
5
- /** Test helper — clears open journeys / ambient steps on the default engine. */
6
- export { resetJourney } from './core';
7
7
  export { instrumentAxios } from './integrations/axios';
8
8
  export { instrumentFetch } from './integrations/fetch';
9
9
  export { exposeAppJourney, instrumentJquery } from './integrations/jquery';
10
10
  export { requestKey, type JourneyTimedMeta } from './integrations/request-key';
11
- export { sendToDatadog, setJourneyRum } from './sinks/datadog';
11
+ export { onHttpComplete, type HttpCompleteReport } from './integrations/http-report';
12
+ export { disableJourney, disableJourneyDebugging, enableJourney, enableJourneyDebugging, isJourneyDebugEnabled, isJourneyEnabled, setJourneyDefaultEnabled, teardownJourney, } from './global';
13
+ export { sendToConsole } from './sinks/console';
14
+ export { normalizeTagValue, sendToDatadog, setJourneyRum } from './sinks/datadog';
12
15
  export type { JourneyEvent, JourneyStepEvent, TagValue } from './core';
13
16
  export { useJourneyName, useOptionalJourneyName } from './integrations/react/context';
14
17
  export { JourneyScope } from './integrations/react/scope';
18
+ export { useJourneyStep } from './integrations/react/use-journey-step';
15
19
  //# sourceMappingURL=index.d.ts.map
@@ -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,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,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,gFAAgF;AAChF,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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE/D,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,UAAU,CAAC;AAElB,OAAO,EAEH,aAAa,EAEb,eAAe,EAC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,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC"}
package/dist/index.js CHANGED
@@ -3,17 +3,21 @@
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
+ singleInFlightJourneyStep, resolveStamp, JourneyStepStamp } 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
11
  export { instrumentAxios } from './integrations/axios';
12
12
  export { instrumentFetch } from './integrations/fetch';
13
13
  export { exposeAppJourney, instrumentJquery } from './integrations/jquery';
14
14
  export { requestKey } from './integrations/request-key';
15
- export { sendToDatadog, setJourneyRum } from './sinks/datadog';
15
+ export { onHttpComplete } from './integrations/http-report';
16
+ export { disableJourney, disableJourneyDebugging, enableJourney, enableJourneyDebugging, isJourneyDebugEnabled, isJourneyEnabled, setJourneyDefaultEnabled, teardownJourney } from './global';
17
+ export { sendToConsole } from './sinks/console';
18
+ export { normalizeTagValue, sendToDatadog, setJourneyRum } from './sinks/datadog';
16
19
  export { useJourneyName, useOptionalJourneyName } from './integrations/react/context';
17
20
  export { JourneyScope } from './integrations/react/scope';
21
+ export { useJourneyStep } from './integrations/react/use-journey-step';
18
22
 
19
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*\n * Force-evaluate config so the default Datadog sink registers even when consumers only\n * import core APIs (defineJourney, etc.). Paired with package.json \"sideEffects\" for\n * config — otherwise bundlers with sideEffects:false would drop an unused re-export.\n */\nimport './config';\n\nexport {\n // Custom transport adapters only.\n activeJourneyStep,\n // Prefer defineJourney(...).complete/fail/… free helpers for name-from-context call sites.\n completeJourney,\n defineJourney,\n excludeJourney,\n failJourney,\n journeyStep,\n reportBackendRequest,\n resolveJourneyStep,\n setJourneyTags,\n JourneyStepTag,\n type JourneyDef,\n type JourneyHandle,\n type JourneyNameLike,\n type JourneyStepOptions,\n type JourneyStepRef,\n type JourneyStepTarget,\n type StepHandle,\n} from './core';\n\nexport {\n configureJourney,\n type AppRequestTimeouts,\n type EndpointPolicy,\n type JourneyConfig,\n} from './config';\n\nexport type { JourneySink } from './core';\n\n/** Test helper — clears open journeys / ambient steps on the default engine. */\nexport { resetJourney } from './core';\n\nexport { instrumentAxios } from './integrations/axios';\nexport { instrumentFetch } from './integrations/fetch';\nexport { exposeAppJourney, instrumentJquery } from './integrations/jquery';\nexport { requestKey, type JourneyTimedMeta } from './integrations/request-key';\nexport { sendToDatadog, setJourneyRum } from './sinks/datadog';\n\nexport type { JourneyEvent, JourneyStepEvent, TagValue } from './core';\n\nexport { useJourneyName, useOptionalJourneyName } from './integrations/react/context';\nexport { JourneyScope } from './integrations/react/scope';\n"],"names":["activeJourneyStep","completeJourney","defineJourney","excludeJourney","failJourney","journeyStep","reportBackendRequest","resolveJourneyStep","setJourneyTags","JourneyStepTag","configureJourney","resetJourney","instrumentAxios","instrumentFetch","exposeAppJourney","instrumentJquery","requestKey","sendToDatadog","setJourneyRum","useJourneyName","useOptionalJourneyName","JourneyScope"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,WAAW;AAElB,SACI,kCAAkC;AAClCA,iBAAiB,EACjB,6FAA6F;AAC7FC,eAAe,EACfC,aAAa,EACbC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,oBAAoB,EACpBC,kBAAkB,EAClBC,cAAc,EACdC,cAAc,QAQX,SAAS;AAEhB,SACIC,gBAAgB,QAIb,WAAW;AAIlB,8EAA8E,GAC9E,SAASC,YAAY,QAAQ,SAAS;AAEtC,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,wBAAwB;AAC3E,SAASC,UAAU,QAA+B,6BAA6B;AAC/E,SAASC,aAAa,EAAEC,aAAa,QAAQ,kBAAkB;AAI/D,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,+BAA+B;AACtF,SAASC,YAAY,QAAQ,6BAA6B"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*\n * Force-evaluate config so the default Datadog sink registers even when consumers only\n * import core APIs (defineJourney, etc.). Paired with package.json \"sideEffects\" for\n * config — otherwise bundlers with sideEffects:false would drop an unused re-export.\n */\nimport './config';\n\nexport {\n // Preferred app API.\n defineJourney,\n // Name-string lifecycle (prefer handle methods when you own the journey).\n completeJourney,\n excludeJourney,\n failJourney,\n journeyStep,\n setJourneyTags,\n // Custom transport adapters / request attribution.\n singleInFlightJourneyStep,\n resolveStamp,\n JourneyStepStamp,\n type JourneyDef,\n type JourneyHandle,\n type JourneyNameLike,\n type JourneyStepOptions,\n type JourneyStepTarget,\n type StepHandle,\n} from './core';\n\nexport { configureJourney, type JourneyConfig } from './config';\nexport type { EndpointPolicy, SlowRequestConfig } from './core/endpoint-policy';\nexport type {\n JourneyHttpPolicyContext,\n JourneyHttpScore,\n JourneyHttpScoreContext,\n JourneyRequestPolicy,\n JourneyStampOptions,\n RequestPolicyConfig,\n} from './core/request-policy';\n\nexport type { JourneySink } from './core';\n\nexport { instrumentAxios } from './integrations/axios';\nexport { instrumentFetch } from './integrations/fetch';\nexport { exposeAppJourney, instrumentJquery } from './integrations/jquery';\nexport { requestKey, type JourneyTimedMeta } from './integrations/request-key';\nexport { onHttpComplete, type HttpCompleteReport } from './integrations/http-report';\nexport {\n disableJourney,\n disableJourneyDebugging,\n enableJourney,\n enableJourneyDebugging,\n isJourneyDebugEnabled,\n isJourneyEnabled,\n setJourneyDefaultEnabled,\n teardownJourney,\n} from './global';\nexport { sendToConsole } from './sinks/console';\nexport { normalizeTagValue, sendToDatadog, setJourneyRum } from './sinks/datadog';\n\nexport type { JourneyEvent, JourneyStepEvent, TagValue } from './core';\n\nexport { useJourneyName, useOptionalJourneyName } from './integrations/react/context';\nexport { JourneyScope } from './integrations/react/scope';\nexport { useJourneyStep } from './integrations/react/use-journey-step';\n"],"names":["defineJourney","completeJourney","excludeJourney","failJourney","journeyStep","setJourneyTags","singleInFlightJourneyStep","resolveStamp","JourneyStepStamp","configureJourney","instrumentAxios","instrumentFetch","exposeAppJourney","instrumentJquery","requestKey","onHttpComplete","disableJourney","disableJourneyDebugging","enableJourney","enableJourneyDebugging","isJourneyDebugEnabled","isJourneyEnabled","setJourneyDefaultEnabled","teardownJourney","sendToConsole","normalizeTagValue","sendToDatadog","setJourneyRum","useJourneyName","useOptionalJourneyName","JourneyScope","useJourneyStep"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,WAAW;AAElB,SACI,qBAAqB;AACrBA,aAAa,EACb,0EAA0E;AAC1EC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,cAAc,EACd,mDAAmD;AACnDC,yBAAyB,EACzBC,YAAY,EACZC,gBAAgB,QAOb,SAAS;AAEhB,SAASC,gBAAgB,QAA4B,WAAW;AAahE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,wBAAwB;AAC3E,SAASC,UAAU,QAA+B,6BAA6B;AAC/E,SAASC,cAAc,QAAiC,6BAA6B;AACrF,SACIC,cAAc,EACdC,uBAAuB,EACvBC,aAAa,EACbC,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,wBAAwB,EACxBC,eAAe,QACZ,WAAW;AAClB,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,iBAAiB,EAAEC,aAAa,EAAEC,aAAa,QAAQ,kBAAkB;AAIlF,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,+BAA+B;AACtF,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,cAAc,QAAQ,wCAAwC"}
@@ -8,9 +8,11 @@ export interface AxiosLikeInstance {
8
8
  interceptors: {
9
9
  request: {
10
10
  use(onFulfilled: (config: any) => any): unknown;
11
+ eject?(id: unknown): void;
11
12
  };
12
13
  response: {
13
14
  use(onFulfilled: (response: any) => any, onRejected?: (error: any) => any): unknown;
15
+ eject?(id: unknown): void;
14
16
  };
15
17
  };
16
18
  }
@@ -18,6 +20,8 @@ export interface AxiosLikeInstance {
18
20
  * Wire an axios instance into the journey engine (observation-only).
19
21
  * Call once per instance (idempotent). Register any async request interceptors
20
22
  * (e.g. auth) before this call so this one runs first.
23
+ * Soft-skips when `instance` is missing or not axios-like — hosts can pass axios as-is.
24
+ * Returns a restore function that disposes handlers (they no-op after restore).
21
25
  */
22
- export declare function instrumentAxios(instance: AxiosLikeInstance): void;
26
+ export declare function instrumentAxios(instance: AxiosLikeInstance | null | undefined): () => void;
23
27
  //# sourceMappingURL=axios.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"axios.d.ts","sourceRoot":"","sources":["../../src/integrations/axios.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,YAAY,EAAE;QACV,OAAO,EAAE;YAAE,GAAG,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,GAAG,OAAO,CAAA;SAAE,CAAC;QAC7D,QAAQ,EAAE;YACN,GAAG,CAAC,WAAW,EAAE,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