@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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations/http-report.ts"],"sourcesContent":["import { MAX_ATTRIBUTED_REQUEST_KEYS } from '../core/limits';\nimport {\n isJourneyRequestPolicy,\n resolveRequestPolicy,\n type JourneyHttpPolicyContext,\n type JourneyRequestPolicy,\n} from '../core/request-policy';\nimport { reportBackendRequest } from '../core/api';\nimport { canRouteHttpToJourney, resolveJourneyEngine } from '../core/runtime';\nimport type { JourneyStepStamp } from '../core/step-tag';\nimport type { StepRecord } from '../core/types';\nimport type { JourneyTimedMeta } from './request-key';\n\nexport interface HttpCompleteReport {\n stamp: JourneyStepStamp | undefined;\n status?: number;\n durationMs: number;\n requestKey: string;\n aborted?: boolean;\n url?: string;\n method?: string;\n /** Per-request literal overrides from JourneyTimedMeta. */\n meta?: JourneyTimedMeta;\n /** Transport request (axios config, fetch input/init, jQuery settings). */\n request?: unknown;\n /** Transport response (axios response, fetch Response, jqXHR). */\n response?: unknown;\n /** Rejection reason when the transport failed. */\n error?: unknown;\n}\n\nfunction applyPolicy(\n policy: JourneyRequestPolicy,\n step: StepRecord,\n reason: string,\n status?: number\n): void {\n if (policy === 'continue') {\n return;\n }\n const journey = step.journey;\n if (!journey || journey.closed) {\n return;\n }\n const engine = resolveJourneyEngine(journey);\n if (policy === 'exclude') {\n engine.exclude();\n return;\n }\n // 'bad'\n step.outcome = 'bad';\n step.reason ??= reason;\n if (status !== undefined) {\n step.httpStatus = status;\n }\n engine.failJourney(reason);\n}\n\nfunction httpScoreReason(report: HttpCompleteReport): string {\n if (report.aborted) {\n return 'request-aborted';\n }\n const status = report.status;\n if (status !== undefined && status >= 400 && status < 500) {\n return 'request-client-error';\n }\n return 'request-error';\n}\n\n/**\n * Attribute a finished HTTP call: abort / 4xx policies, else 5xx+latency via reportBackendRequest.\n * Ignored endpoint prefixes never change the journey verdict.\n * 4xx with policy `'continue'` (default) still scores latency.\n */\nexport function onHttpComplete(report: HttpCompleteReport): void {\n const {\n stamp,\n status,\n durationMs,\n requestKey,\n aborted,\n url,\n method,\n meta,\n request,\n response,\n error,\n } = report;\n if (!stamp) {\n return;\n }\n const step = stamp.step;\n if (!step?.journey) {\n return;\n }\n /*\n * Unstamped foreign journeys (older package copies) cannot be closed from\n * this bundle — do not write onHttpAborted / step.outcome on them.\n */\n if (!canRouteHttpToJourney(step.journey)) {\n return;\n }\n const engine = resolveJourneyEngine(step.journey);\n\n if (meta?.ignore === true || stamp.ignore === true) {\n return;\n }\n\n if (aborted) {\n step.onHttpAborted = true;\n }\n\n if (requestKey) {\n step.attributedRequestKeys ??= [];\n if (\n step.attributedRequestKeys.length < MAX_ATTRIBUTED_REQUEST_KEYS &&\n !step.attributedRequestKeys.includes(requestKey)\n ) {\n step.attributedRequestKeys.push(requestKey);\n }\n }\n\n if (requestKey && engine.shouldIgnoreRequest(requestKey)) {\n return;\n }\n\n const ctx: JourneyHttpPolicyContext = {\n requestKey,\n status,\n aborted: aborted === true,\n url,\n method,\n journeyName: step.journey.name,\n stepName: step.name,\n };\n\n const score = stamp.score;\n if (score) {\n let policy: JourneyRequestPolicy | undefined;\n try {\n const scored = score({\n ...ctx,\n durationMs,\n request,\n response,\n error,\n });\n if (isJourneyRequestPolicy(scored)) {\n policy = scored;\n }\n } catch {\n policy = undefined;\n }\n if (policy !== undefined) {\n applyPolicy(policy, step, httpScoreReason(report), status);\n return;\n }\n }\n\n if (aborted) {\n const override = meta?.httpAbortedRequests;\n const policy = isJourneyRequestPolicy(override)\n ? override\n : resolveRequestPolicy(engine.getHttpAbortedRequestsPolicy(), 'continue', ctx);\n applyPolicy(policy, step, 'request-aborted');\n return;\n }\n\n if (status !== undefined && status >= 400 && status < 500) {\n const override = meta?.httpClientErrorRequests;\n const policy = isJourneyRequestPolicy(override)\n ? override\n : resolveRequestPolicy(engine.getHttpClientErrorRequestsPolicy(), 'continue', ctx);\n if (policy !== 'continue') {\n applyPolicy(policy, step, 'request-client-error', status);\n return;\n }\n // 'continue' does not count 4xx as an error; still score latency below.\n }\n\n reportBackendRequest(step, status, durationMs, requestKey);\n}\n\nexport { isAbortError, isCanceledError } from '../core/abort-error';\n"],"names":["MAX_ATTRIBUTED_REQUEST_KEYS","isJourneyRequestPolicy","resolveRequestPolicy","reportBackendRequest","canRouteHttpToJourney","resolveJourneyEngine","applyPolicy","policy","step","reason","status","journey","closed","engine","exclude","outcome","undefined","httpStatus","failJourney","httpScoreReason","report","aborted","onHttpComplete","stamp","durationMs","requestKey","url","method","meta","request","response","error","ignore","onHttpAborted","attributedRequestKeys","length","includes","push","shouldIgnoreRequest","ctx","journeyName","name","stepName","score","scored","override","httpAbortedRequests","getHttpAbortedRequestsPolicy","httpClientErrorRequests","getHttpClientErrorRequestsPolicy","isAbortError","isCanceledError"],"mappings":"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"}
@@ -1,12 +1,16 @@
1
1
  import { type JourneyDef, type JourneyHandle, type JourneyStepOptions, type JourneyStepTarget, type StepHandle } from '../../core';
2
2
  /**
3
3
  * Knockout / desktop-legacy bridge on `window.App.Journey`.
4
- * Prefer `defineJourney` handles; `journeyStep` / `firstOpenJourney` cover multi-journey steps.
4
+ * Prefer `defineJourney` handles; `journeyStep` / `firstOpenJourneyName` cover multi-journey steps.
5
+ * Use `getJourneyHandle(name)` when you need the handle from another module.
5
6
  */
6
- export interface AppJourneyApi {
7
- defineJourney(def: JourneyDef): JourneyHandle;
7
+ interface AppJourneyApi {
8
+ defineJourney(config: JourneyDef): JourneyHandle;
8
9
  journeyStep<T>(journey: JourneyStepTarget, stepName: string, fn: (step: StepHandle) => T | Promise<T>, opts?: JourneyStepOptions): Promise<T>;
9
- firstOpenJourney(names: readonly string[]): string | null;
10
+ /** First open journey **name** among candidates, or null. */
11
+ firstOpenJourneyName(names: readonly string[]): string | null;
12
+ /** `defineJourney` handle for an open name, or null. */
13
+ getJourneyHandle(name: string): JourneyHandle | null;
10
14
  }
11
15
  export type WindowWithAppJourney = Window & {
12
16
  App?: {
@@ -15,8 +19,8 @@ export type WindowWithAppJourney = Window & {
15
19
  };
16
20
  /**
17
21
  * Publish the Knockout bridge on window.App.Journey. Idempotent for the real window.
18
- * Optional `target` is for tests.
22
+ * Optional `target` is for tests. Never throws — logs and returns a usable API if publish fails.
19
23
  */
20
24
  export declare function exposeAppJourney(target?: WindowWithAppJourney): AppJourneyApi;
21
- export { instrumentJquery, type JqueryAjaxSettings, type JqueryStatic, type JqueryXHR, } from './instrument';
25
+ export { instrumentJquery, type JqueryStatic } from './instrument';
22
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/jquery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAClB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,aAAa,CAAC;IAC9C,WAAW,CAAC,CAAC,EACT,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,CAAC;IACd,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;CAC7D;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IACxC,GAAG,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,aAAa,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/D,CAAC;AAKF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,oBAA6B,GAAG,aAAa,CAiBrF;AAED,OAAO,EACH,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,SAAS,GACjB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/jquery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAClB,MAAM,YAAY,CAAC;AAGpB;;;;GAIG;AACH,UAAU,aAAa;IACnB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAAC;IACjD,WAAW,CAAC,CAAC,EACT,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,CAAC;IACd,6DAA6D;IAC7D,oBAAoB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9D,wDAAwD;IACxD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAAC;CACxD;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IACxC,GAAG,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,aAAa,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/D,CAAC;AAaF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,oBAA6B,GAAG,aAAa,CA6BrF;AAED,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC"}
@@ -1,24 +1,43 @@
1
- import { defineJourney, firstOpenJourney, journeyStep } from '../../core';
1
+ import { defineJourney, journeyStep } from '../../core';
2
+ import { moduleRuntime } from '../../core/runtime';
2
3
  let journeyExposed = false;
3
4
  let windowJourneyApi;
5
+ function handleForOpenJourney(name) {
6
+ const open = moduleRuntime.getOpenJourney(name);
7
+ if (!open) {
8
+ return null;
9
+ }
10
+ return defineJourney(open.config);
11
+ }
4
12
  /**
5
13
  * Publish the Knockout bridge on window.App.Journey. Idempotent for the real window.
6
- * Optional `target` is for tests.
14
+ * Optional `target` is for tests. Never throws — logs and returns a usable API if publish fails.
7
15
  */ export function exposeAppJourney(target = window) {
8
- var _target_App;
9
16
  if (journeyExposed && target === window && windowJourneyApi) {
10
17
  return windowJourneyApi;
11
18
  }
12
19
  const api = {
13
20
  defineJourney,
14
21
  journeyStep,
15
- firstOpenJourney
22
+ firstOpenJourneyName: (names)=>moduleRuntime.firstOpenJourneyName(names),
23
+ getJourneyHandle: handleForOpenJourney
16
24
  };
17
- target.App = (_target_App = target.App) !== null && _target_App !== void 0 ? _target_App : {};
18
- target.App.Journey = api;
19
- if (target === window) {
20
- journeyExposed = true;
21
- windowJourneyApi = api;
25
+ try {
26
+ var _target_App;
27
+ if (target == null || typeof target !== 'object' && typeof target !== 'function') {
28
+ // eslint-disable-next-line no-console -- soft-skip missing host window
29
+ console.warn('[journey] exposeAppJourney: skipped — missing');
30
+ return api;
31
+ }
32
+ target.App = (_target_App = target.App) !== null && _target_App !== void 0 ? _target_App : {};
33
+ target.App.Journey = Object.freeze(api);
34
+ if (target === window) {
35
+ journeyExposed = true;
36
+ windowJourneyApi = api;
37
+ }
38
+ } catch (err) {
39
+ // eslint-disable-next-line no-console -- soft-fail host wiring
40
+ console.error('[journey] exposeAppJourney failed', err);
22
41
  }
23
42
  return api;
24
43
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/integrations/jquery/index.ts"],"sourcesContent":["import {\n defineJourney,\n firstOpenJourney,\n journeyStep,\n type JourneyDef,\n type JourneyHandle,\n type JourneyStepOptions,\n type JourneyStepTarget,\n type StepHandle,\n} from '../../core';\n\n/**\n * Knockout / desktop-legacy bridge on `window.App.Journey`.\n * Prefer `defineJourney` handles; `journeyStep` / `firstOpenJourney` cover multi-journey steps.\n */\nexport interface AppJourneyApi {\n defineJourney(def: JourneyDef): JourneyHandle;\n journeyStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n firstOpenJourney(names: readonly string[]): string | null;\n}\n\nexport type WindowWithAppJourney = Window & {\n App?: { Journey?: AppJourneyApi } & Record<string, unknown>;\n};\n\nlet journeyExposed = false;\nlet windowJourneyApi: AppJourneyApi | undefined;\n\n/**\n * Publish the Knockout bridge on window.App.Journey. Idempotent for the real window.\n * Optional `target` is for tests.\n */\nexport function exposeAppJourney(target: WindowWithAppJourney = window): AppJourneyApi {\n if (journeyExposed && target === window && windowJourneyApi) {\n return windowJourneyApi;\n }\n\n const api: AppJourneyApi = {\n defineJourney,\n journeyStep,\n firstOpenJourney,\n };\n target.App = target.App ?? {};\n target.App.Journey = api;\n if (target === window) {\n journeyExposed = true;\n windowJourneyApi = api;\n }\n return api;\n}\n\nexport {\n instrumentJquery,\n type JqueryAjaxSettings,\n type JqueryStatic,\n type JqueryXHR,\n} from './instrument';\n"],"names":["defineJourney","firstOpenJourney","journeyStep","journeyExposed","windowJourneyApi","exposeAppJourney","target","window","api","App","Journey","instrumentJquery"],"mappings":"AAAA,SACIA,aAAa,EACbC,gBAAgB,EAChBC,WAAW,QAMR,aAAa;AAqBpB,IAAIC,iBAAiB;AACrB,IAAIC;AAEJ;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,SAA+BC,MAAM;QAUrDD;IATb,IAAIH,kBAAkBG,WAAWC,UAAUH,kBAAkB;QACzD,OAAOA;IACX;IAEA,MAAMI,MAAqB;QACvBR;QACAE;QACAD;IACJ;IACAK,OAAOG,GAAG,IAAGH,cAAAA,OAAOG,GAAG,cAAVH,yBAAAA,cAAc,CAAC;IAC5BA,OAAOG,GAAG,CAACC,OAAO,GAAGF;IACrB,IAAIF,WAAWC,QAAQ;QACnBJ,iBAAiB;QACjBC,mBAAmBI;IACvB;IACA,OAAOA;AACX;AAEA,SACIG,gBAAgB,QAIb,eAAe"}
1
+ {"version":3,"sources":["../../../src/integrations/jquery/index.ts"],"sourcesContent":["import {\n defineJourney,\n journeyStep,\n type JourneyDef,\n type JourneyHandle,\n type JourneyStepOptions,\n type JourneyStepTarget,\n type StepHandle,\n} from '../../core';\nimport { moduleRuntime } from '../../core/runtime';\n\n/**\n * Knockout / desktop-legacy bridge on `window.App.Journey`.\n * Prefer `defineJourney` handles; `journeyStep` / `firstOpenJourneyName` cover multi-journey steps.\n * Use `getJourneyHandle(name)` when you need the handle from another module.\n */\ninterface AppJourneyApi {\n defineJourney(config: JourneyDef): JourneyHandle;\n journeyStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n ): Promise<T>;\n /** First open journey **name** among candidates, or null. */\n firstOpenJourneyName(names: readonly string[]): string | null;\n /** `defineJourney` handle for an open name, or null. */\n getJourneyHandle(name: string): JourneyHandle | null;\n}\n\nexport type WindowWithAppJourney = Window & {\n App?: { Journey?: AppJourneyApi } & Record<string, unknown>;\n};\n\nlet journeyExposed = false;\nlet windowJourneyApi: AppJourneyApi | undefined;\n\nfunction handleForOpenJourney(name: string): JourneyHandle | null {\n const open = moduleRuntime.getOpenJourney(name);\n if (!open) {\n return null;\n }\n return defineJourney(open.config);\n}\n\n/**\n * Publish the Knockout bridge on window.App.Journey. Idempotent for the real window.\n * Optional `target` is for tests. Never throws — logs and returns a usable API if publish fails.\n */\nexport function exposeAppJourney(target: WindowWithAppJourney = window): AppJourneyApi {\n if (journeyExposed && target === window && windowJourneyApi) {\n return windowJourneyApi;\n }\n\n const api: AppJourneyApi = {\n defineJourney,\n journeyStep,\n firstOpenJourneyName: names => moduleRuntime.firstOpenJourneyName(names),\n getJourneyHandle: handleForOpenJourney,\n };\n\n try {\n if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {\n // eslint-disable-next-line no-console -- soft-skip missing host window\n console.warn('[journey] exposeAppJourney: skipped — missing');\n return api;\n }\n target.App = target.App ?? {};\n target.App.Journey = Object.freeze(api);\n if (target === window) {\n journeyExposed = true;\n windowJourneyApi = api;\n }\n } catch (err) {\n // eslint-disable-next-line no-console -- soft-fail host wiring\n console.error('[journey] exposeAppJourney failed', err);\n }\n return api;\n}\n\nexport { instrumentJquery, type JqueryStatic } from './instrument';\n"],"names":["defineJourney","journeyStep","moduleRuntime","journeyExposed","windowJourneyApi","handleForOpenJourney","name","open","getOpenJourney","config","exposeAppJourney","target","window","api","firstOpenJourneyName","names","getJourneyHandle","console","warn","App","Journey","Object","freeze","err","error","instrumentJquery"],"mappings":"AAAA,SACIA,aAAa,EACbC,WAAW,QAMR,aAAa;AACpB,SAASC,aAAa,QAAQ,qBAAqB;AAyBnD,IAAIC,iBAAiB;AACrB,IAAIC;AAEJ,SAASC,qBAAqBC,IAAY;IACtC,MAAMC,OAAOL,cAAcM,cAAc,CAACF;IAC1C,IAAI,CAACC,MAAM;QACP,OAAO;IACX;IACA,OAAOP,cAAcO,KAAKE,MAAM;AACpC;AAEA;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,SAA+BC,MAAM;IAClE,IAAIT,kBAAkBQ,WAAWC,UAAUR,kBAAkB;QACzD,OAAOA;IACX;IAEA,MAAMS,MAAqB;QACvBb;QACAC;QACAa,sBAAsBC,CAAAA,QAASb,cAAcY,oBAAoB,CAACC;QAClEC,kBAAkBX;IACtB;IAEA,IAAI;YAMaM;QALb,IAAIA,UAAU,QAAS,OAAOA,WAAW,YAAY,OAAOA,WAAW,YAAa;YAChF,uEAAuE;YACvEM,QAAQC,IAAI,CAAC;YACb,OAAOL;QACX;QACAF,OAAOQ,GAAG,IAAGR,cAAAA,OAAOQ,GAAG,cAAVR,yBAAAA,cAAc,CAAC;QAC5BA,OAAOQ,GAAG,CAACC,OAAO,GAAGC,OAAOC,MAAM,CAACT;QACnC,IAAIF,WAAWC,QAAQ;YACnBT,iBAAiB;YACjBC,mBAAmBS;QACvB;IACJ,EAAE,OAAOU,KAAK;QACV,+DAA+D;QAC/DN,QAAQO,KAAK,CAAC,qCAAqCD;IACvD;IACA,OAAOV;AACX;AAEA,SAASY,gBAAgB,QAA2B,eAAe"}
@@ -1,11 +1,14 @@
1
+ import { type JourneyTimedMeta } from '../request-key';
1
2
  export interface JqueryXHR {
2
3
  status: number;
3
- journeyStep?: unknown;
4
+ statusText?: string;
5
+ stamp?: unknown;
4
6
  journeyStart?: number;
5
7
  }
6
- export interface JqueryAjaxSettings {
8
+ export interface JqueryAjaxSettings extends JourneyTimedMeta {
7
9
  url?: string;
8
- journeyStep?: unknown;
10
+ type?: string;
11
+ method?: string;
9
12
  }
10
13
  export interface JqueryStatic {
11
14
  ajaxPrefilter(handler: (options: JqueryAjaxSettings, originalOptions: JqueryAjaxSettings, jqXHR: JqueryXHR) => void): void;
@@ -13,6 +16,12 @@ export interface JqueryStatic {
13
16
  ajaxComplete(handler: (event: unknown, jqXHR: JqueryXHR, settings: JqueryAjaxSettings) => void): void;
14
17
  };
15
18
  }
16
- /** Wire a jQuery static into the journey engine. Call once per $ (idempotent). Observation-only. */
17
- export declare function instrumentJquery($: JqueryStatic): void;
19
+ /** Resolve `globalThis.$`, then `globalThis.jQuery`. */
20
+ export declare function resolveGlobalJquery(): JqueryStatic | null | undefined;
21
+ /**
22
+ * Wire a jQuery static into the journey engine. Call once per $ (idempotent). Observation-only.
23
+ * Soft-skips when `$` is missing or not a real jQuery (no `ajaxPrefilter`) so hosts can pass `$` as-is.
24
+ * Returns a restore that disposes handlers (they no-op after restore).
25
+ */
26
+ export declare function instrumentJquery($: JqueryStatic | null | undefined): () => void;
18
27
  //# sourceMappingURL=instrument.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrument.d.ts","sourceRoot":"","sources":["../../../src/integrations/jquery/instrument.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IACzB,aAAa,CACT,OAAO,EAAE,CACL,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,kBAAkB,EACnC,KAAK,EAAE,SAAS,KACf,IAAI,GACV,IAAI,CAAC;IACR,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAClB,YAAY,CACR,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,KAAK,IAAI,GAClF,IAAI,CAAC;KACX,CAAC;CACL;AAoBD,oGAAoG;AACpG,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CA8BtD"}
1
+ {"version":3,"file":"instrument.d.ts","sourceRoot":"","sources":["../../../src/integrations/jquery/instrument.ts"],"names":[],"mappings":"AAQA,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGnE,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,MAAM,WAAW,YAAY;IACzB,aAAa,CACT,OAAO,EAAE,CACL,OAAO,EAAE,kBAAkB,EAC3B,eAAe,EAAE,kBAAkB,EACnC,KAAK,EAAE,SAAS,KACf,IAAI,GACV,IAAI,CAAC;IACR,CAAC,QAAQ,EAAE,QAAQ,GAAG;QAClB,YAAY,CACR,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,KAAK,IAAI,GAClF,IAAI,CAAC;KACX,CAAC;CACL;AA+BD,wDAAwD;AACxD,wBAAgB,mBAAmB,IAAI,YAAY,GAAG,IAAI,GAAG,SAAS,CAGrE;AAuBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,IAAI,CAiE/E"}
@@ -1,44 +1,126 @@
1
- import { activeJourneyStep, JourneyStepTag, reportBackendRequest, resolveJourneyStep } from '../../core';
1
+ import { resolveStamp } from '../../core';
2
+ import { adoptJourneyStepStamp } from '../../core/step-tag';
3
+ import { getInstrumentedJquerySet, registerInstrumentRecord } from '../../global';
4
+ import { onHttpComplete } from '../http-report';
2
5
  import { requestKey } from '../request-key';
3
- const instrumented = new WeakSet();
6
+ import { acceptInstrumentTarget } from '../soft-skip';
7
+ const jqueryStamps = new WeakMap();
4
8
  function reportTiming(jqXHR, settings) {
5
- var _jqXHR_journeyStart;
6
- const step = resolveJourneyStep(jqXHR.journeyStep);
7
- if (!step) {
9
+ var _jqueryStamps_get, _jqXHR_journeyStart, _settings_type;
10
+ const stamp = (_jqueryStamps_get = jqueryStamps.get(jqXHR)) !== null && _jqueryStamps_get !== void 0 ? _jqueryStamps_get : adoptJourneyStepStamp(jqXHR.stamp);
11
+ if (!stamp || stamp.ignore || settings.ignore === true) {
8
12
  return;
9
13
  }
10
14
  const start = (_jqXHR_journeyStart = jqXHR.journeyStart) !== null && _jqXHR_journeyStart !== void 0 ? _jqXHR_journeyStart : globalThis.performance.now();
15
+ const aborted = jqXHR.statusText === 'abort';
11
16
  // jQuery uses status 0 for network / abort failures — treat like a missing status.
12
- const status = jqXHR.status === 0 ? undefined : jqXHR.status;
13
- reportBackendRequest(step, status, globalThis.performance.now() - start, requestKey(settings.url, undefined, undefined));
17
+ const status = aborted || jqXHR.status === 0 ? undefined : jqXHR.status;
18
+ onHttpComplete({
19
+ stamp,
20
+ status,
21
+ durationMs: globalThis.performance.now() - start,
22
+ requestKey: requestKey(settings.url, undefined, undefined),
23
+ aborted,
24
+ url: settings.url,
25
+ method: (_settings_type = settings.type) !== null && _settings_type !== void 0 ? _settings_type : settings.method,
26
+ meta: settings,
27
+ request: settings,
28
+ response: jqXHR
29
+ });
30
+ }
31
+ function isJqueryStatic(value) {
32
+ return typeof value === 'function' && typeof value.ajaxPrefilter === 'function';
14
33
  }
15
- /** Wire a jQuery static into the journey engine. Call once per $ (idempotent). Observation-only. */ export function instrumentJquery($) {
16
- if (instrumented.has($)) {
34
+ /** Resolve `globalThis.$`, then `globalThis.jQuery`. */ export function resolveGlobalJquery() {
35
+ var _g_$;
36
+ const g = globalThis;
37
+ return (_g_$ = g.$) !== null && _g_$ !== void 0 ? _g_$ : g.jQuery;
38
+ }
39
+ /** Live record per $ — handlers look this up so restore+rewire does not stack prefilters. */ const jqueryLiveRecords = new WeakMap();
40
+ /** jQuery cannot unregister these; track each so a partial-wire retry does not stack. */ const jqueryPrefiltersInstalled = new WeakSet();
41
+ const jqueryCompletesInstalled = new WeakSet();
42
+ function stampAjax(jqXHR, options) {
43
+ var _jqXHR_stamp;
44
+ if (options.ignore === true) {
17
45
  return;
18
46
  }
19
- instrumented.add($);
20
- $.ajaxPrefilter((options, _originalOptions, jqXHR)=>{
21
- /*
22
- * Prefer explicit step.tag() (settings or XHR); else soft ambient.
23
- * Box ambient steps in JourneyStepTag — raw StepRecord is circular and blows jQuery deep-merge.
24
- */ if (!jqXHR.journeyStep) {
25
- const fromSettings = options.journeyStep;
26
- if (fromSettings) {
27
- jqXHR.journeyStep = fromSettings;
28
- } else {
29
- const step = activeJourneyStep();
30
- if (step) {
31
- jqXHR.journeyStep = new JourneyStepTag(step);
47
+ const stamp = resolveStamp((_jqXHR_stamp = jqXHR.stamp) !== null && _jqXHR_stamp !== void 0 ? _jqXHR_stamp : options.stamp);
48
+ if (stamp) {
49
+ jqueryStamps.set(jqXHR, stamp);
50
+ delete jqXHR.stamp;
51
+ delete options.stamp;
52
+ }
53
+ if (stamp && !stamp.ignore) {
54
+ jqXHR.journeyStart = globalThis.performance.now();
55
+ }
56
+ }
57
+ /**
58
+ * Wire a jQuery static into the journey engine. Call once per $ (idempotent). Observation-only.
59
+ * Soft-skips when `$` is missing or not a real jQuery (no `ajaxPrefilter`) so hosts can pass `$` as-is.
60
+ * Returns a restore that disposes handlers (they no-op after restore).
61
+ */ export function instrumentJquery($) {
62
+ const jquery = acceptInstrumentTarget('Jquery', $, isJqueryStatic);
63
+ const instrumented = getInstrumentedJquerySet();
64
+ if (!jquery || instrumented.has(jquery)) {
65
+ return ()=>{};
66
+ }
67
+ const key = jquery;
68
+ const record = {
69
+ disposed: false
70
+ };
71
+ try {
72
+ if (!jqueryPrefiltersInstalled.has(key)) {
73
+ jquery.ajaxPrefilter((options, _originalOptions, jqXHR)=>{
74
+ const current = jqueryLiveRecords.get(key);
75
+ if (!current || current.disposed) {
76
+ return;
32
77
  }
33
- }
78
+ stampAjax(jqXHR, options);
79
+ });
80
+ jqueryPrefiltersInstalled.add(key);
34
81
  }
35
- if (resolveJourneyStep(jqXHR.journeyStep)) {
36
- jqXHR.journeyStart = globalThis.performance.now();
82
+ if (!jqueryCompletesInstalled.has(key)) {
83
+ jquery(document).ajaxComplete((_event, jqXHR, settings)=>{
84
+ const current = jqueryLiveRecords.get(key);
85
+ if (!current || current.disposed) {
86
+ return;
87
+ }
88
+ reportTiming(jqXHR, settings);
89
+ });
90
+ jqueryCompletesInstalled.add(key);
37
91
  }
38
- });
39
- $(document).ajaxComplete((_event, jqXHR, settings)=>{
40
- reportTiming(jqXHR, settings);
41
- });
92
+ jqueryLiveRecords.set(key, record);
93
+ instrumented.add(key);
94
+ } catch (err) {
95
+ /*
96
+ * Keep per-handler installed flags so a retry cannot double-register
97
+ * prefilters. Restore deletes the shared instrumented slot so teardown /
98
+ * retry can finish whichever handler never succeeded.
99
+ */ record.disposed = true;
100
+ instrumented.add(key);
101
+ const restore = ()=>{
102
+ record.disposed = true;
103
+ if (jqueryLiveRecords.get(key) === record) {
104
+ jqueryLiveRecords.delete(key);
105
+ }
106
+ instrumented.delete(key);
107
+ };
108
+ record.restore = restore;
109
+ registerInstrumentRecord(record);
110
+ // eslint-disable-next-line no-console -- soft-fail host wiring
111
+ console.error('[journey] instrumentJquery failed', err);
112
+ return restore;
113
+ }
114
+ const restore = ()=>{
115
+ record.disposed = true;
116
+ if (jqueryLiveRecords.get(key) === record) {
117
+ jqueryLiveRecords.delete(key);
118
+ }
119
+ instrumented.delete(key);
120
+ };
121
+ record.restore = restore;
122
+ registerInstrumentRecord(record);
123
+ return restore;
42
124
  }
43
125
 
44
126
  //# sourceMappingURL=instrument.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/integrations/jquery/instrument.ts"],"sourcesContent":["import {\n activeJourneyStep,\n JourneyStepTag,\n reportBackendRequest,\n resolveJourneyStep,\n} from '../../core';\nimport { requestKey } from '../request-key';\n\nexport interface JqueryXHR {\n status: number;\n journeyStep?: unknown;\n journeyStart?: number;\n}\n\nexport interface JqueryAjaxSettings {\n url?: string;\n journeyStep?: unknown;\n}\n\nexport interface JqueryStatic {\n ajaxPrefilter(\n handler: (\n options: JqueryAjaxSettings,\n originalOptions: JqueryAjaxSettings,\n jqXHR: JqueryXHR\n ) => void\n ): void;\n (selector: Document): {\n ajaxComplete(\n handler: (event: unknown, jqXHR: JqueryXHR, settings: JqueryAjaxSettings) => void\n ): void;\n };\n}\n\nconst instrumented = new WeakSet<object>();\n\nfunction reportTiming(jqXHR: JqueryXHR, settings: JqueryAjaxSettings): void {\n const step = resolveJourneyStep(jqXHR.journeyStep);\n if (!step) {\n return;\n }\n const start = jqXHR.journeyStart ?? globalThis.performance.now();\n // jQuery uses status 0 for network / abort failures — treat like a missing status.\n const status = jqXHR.status === 0 ? undefined : jqXHR.status;\n reportBackendRequest(\n step,\n status,\n globalThis.performance.now() - start,\n requestKey(settings.url, undefined, undefined)\n );\n}\n\n/** Wire a jQuery static into the journey engine. Call once per $ (idempotent). Observation-only. */\nexport function instrumentJquery($: JqueryStatic): void {\n if (instrumented.has($ as object)) {\n return;\n }\n instrumented.add($ as object);\n\n $.ajaxPrefilter((options, _originalOptions, jqXHR) => {\n /*\n * Prefer explicit step.tag() (settings or XHR); else soft ambient.\n * Box ambient steps in JourneyStepTag raw StepRecord is circular and blows jQuery deep-merge.\n */\n if (!jqXHR.journeyStep) {\n const fromSettings = options.journeyStep;\n if (fromSettings) {\n jqXHR.journeyStep = fromSettings;\n } else {\n const step = activeJourneyStep();\n if (step) {\n jqXHR.journeyStep = new JourneyStepTag(step);\n }\n }\n }\n if (resolveJourneyStep(jqXHR.journeyStep)) {\n jqXHR.journeyStart = globalThis.performance.now();\n }\n });\n\n $(document).ajaxComplete((_event, jqXHR, settings) => {\n reportTiming(jqXHR, settings);\n });\n}\n"],"names":["activeJourneyStep","JourneyStepTag","reportBackendRequest","resolveJourneyStep","requestKey","instrumented","WeakSet","reportTiming","jqXHR","settings","step","journeyStep","start","journeyStart","globalThis","performance","now","status","undefined","url","instrumentJquery","$","has","add","ajaxPrefilter","options","_originalOptions","fromSettings","document","ajaxComplete","_event"],"mappings":"AAAA,SACIA,iBAAiB,EACjBC,cAAc,EACdC,oBAAoB,EACpBC,kBAAkB,QACf,aAAa;AACpB,SAASC,UAAU,QAAQ,iBAAiB;AA4B5C,MAAMC,eAAe,IAAIC;AAEzB,SAASC,aAAaC,KAAgB,EAAEC,QAA4B;QAKlDD;IAJd,MAAME,OAAOP,mBAAmBK,MAAMG,WAAW;IACjD,IAAI,CAACD,MAAM;QACP;IACJ;IACA,MAAME,SAAQJ,sBAAAA,MAAMK,YAAY,cAAlBL,iCAAAA,sBAAsBM,WAAWC,WAAW,CAACC,GAAG;IAC9D,mFAAmF;IACnF,MAAMC,SAAST,MAAMS,MAAM,KAAK,IAAIC,YAAYV,MAAMS,MAAM;IAC5Df,qBACIQ,MACAO,QACAH,WAAWC,WAAW,CAACC,GAAG,KAAKJ,OAC/BR,WAAWK,SAASU,GAAG,EAAED,WAAWA;AAE5C;AAEA,kGAAkG,GAClG,OAAO,SAASE,iBAAiBC,CAAe;IAC5C,IAAIhB,aAAaiB,GAAG,CAACD,IAAc;QAC/B;IACJ;IACAhB,aAAakB,GAAG,CAACF;IAEjBA,EAAEG,aAAa,CAAC,CAACC,SAASC,kBAAkBlB;QACxC;;;SAGC,GACD,IAAI,CAACA,MAAMG,WAAW,EAAE;YACpB,MAAMgB,eAAeF,QAAQd,WAAW;YACxC,IAAIgB,cAAc;gBACdnB,MAAMG,WAAW,GAAGgB;YACxB,OAAO;gBACH,MAAMjB,OAAOV;gBACb,IAAIU,MAAM;oBACNF,MAAMG,WAAW,GAAG,IAAIV,eAAeS;gBAC3C;YACJ;QACJ;QACA,IAAIP,mBAAmBK,MAAMG,WAAW,GAAG;YACvCH,MAAMK,YAAY,GAAGC,WAAWC,WAAW,CAACC,GAAG;QACnD;IACJ;IAEAK,EAAEO,UAAUC,YAAY,CAAC,CAACC,QAAQtB,OAAOC;QACrCF,aAAaC,OAAOC;IACxB;AACJ"}
1
+ {"version":3,"sources":["../../../src/integrations/jquery/instrument.ts"],"sourcesContent":["import { resolveStamp } from '../../core';\nimport { adoptJourneyStepStamp, type JourneyStepStamp } from '../../core/step-tag';\nimport {\n getInstrumentedJquerySet,\n registerInstrumentRecord,\n type InstrumentRecord,\n} from '../../global';\nimport { onHttpComplete } from '../http-report';\nimport { requestKey, type JourneyTimedMeta } from '../request-key';\nimport { acceptInstrumentTarget } from '../soft-skip';\n\nexport interface JqueryXHR {\n status: number;\n statusText?: string;\n stamp?: unknown;\n journeyStart?: number;\n}\n\nexport interface JqueryAjaxSettings extends JourneyTimedMeta {\n url?: string;\n type?: string;\n method?: string;\n}\n\nconst jqueryStamps = new WeakMap<object, JourneyStepStamp>();\n\nexport interface JqueryStatic {\n ajaxPrefilter(\n handler: (\n options: JqueryAjaxSettings,\n originalOptions: JqueryAjaxSettings,\n jqXHR: JqueryXHR\n ) => void\n ): void;\n (selector: Document): {\n ajaxComplete(\n handler: (event: unknown, jqXHR: JqueryXHR, settings: JqueryAjaxSettings) => void\n ): void;\n };\n}\n\nfunction reportTiming(jqXHR: JqueryXHR, settings: JqueryAjaxSettings): void {\n const stamp = jqueryStamps.get(jqXHR) ?? adoptJourneyStepStamp(jqXHR.stamp);\n if (!stamp || stamp.ignore || settings.ignore === true) {\n return;\n }\n const start = jqXHR.journeyStart ?? globalThis.performance.now();\n const aborted = jqXHR.statusText === 'abort';\n // jQuery uses status 0 for network / abort failures — treat like a missing status.\n const status = aborted || jqXHR.status === 0 ? undefined : jqXHR.status;\n onHttpComplete({\n stamp,\n status,\n durationMs: globalThis.performance.now() - start,\n requestKey: requestKey(settings.url, undefined, undefined),\n aborted,\n url: settings.url,\n method: settings.type ?? settings.method,\n meta: settings,\n request: settings,\n response: jqXHR,\n });\n}\n\nfunction isJqueryStatic(value: unknown): value is JqueryStatic {\n return (\n typeof value === 'function' && typeof (value as JqueryStatic).ajaxPrefilter === 'function'\n );\n}\n\n/** Resolve `globalThis.$`, then `globalThis.jQuery`. */\nexport function resolveGlobalJquery(): JqueryStatic | null | undefined {\n const g = globalThis as typeof globalThis & { $?: unknown; jQuery?: unknown };\n return (g.$ ?? g.jQuery) as JqueryStatic | null | undefined;\n}\n\n/** Live record per $ — handlers look this up so restore+rewire does not stack prefilters. */\nconst jqueryLiveRecords = new WeakMap<object, InstrumentRecord>();\n/** jQuery cannot unregister these; track each so a partial-wire retry does not stack. */\nconst jqueryPrefiltersInstalled = new WeakSet<object>();\nconst jqueryCompletesInstalled = new WeakSet<object>();\n\nfunction stampAjax(jqXHR: JqueryXHR, options: JqueryAjaxSettings): void {\n if (options.ignore === true) {\n return;\n }\n const stamp = resolveStamp(jqXHR.stamp ?? options.stamp);\n if (stamp) {\n jqueryStamps.set(jqXHR, stamp);\n delete jqXHR.stamp;\n delete options.stamp;\n }\n if (stamp && !stamp.ignore) {\n jqXHR.journeyStart = globalThis.performance.now();\n }\n}\n\n/**\n * Wire a jQuery static into the journey engine. Call once per $ (idempotent). Observation-only.\n * Soft-skips when `$` is missing or not a real jQuery (no `ajaxPrefilter`) so hosts can pass `$` as-is.\n * Returns a restore that disposes handlers (they no-op after restore).\n */\nexport function instrumentJquery($: JqueryStatic | null | undefined): () => void {\n const jquery = acceptInstrumentTarget('Jquery', $, isJqueryStatic);\n const instrumented = getInstrumentedJquerySet();\n if (!jquery || instrumented.has(jquery as object)) {\n return () => {};\n }\n\n const key = jquery as object;\n const record: InstrumentRecord = { disposed: false };\n\n try {\n if (!jqueryPrefiltersInstalled.has(key)) {\n jquery.ajaxPrefilter((options, _originalOptions, jqXHR) => {\n const current = jqueryLiveRecords.get(key);\n if (!current || current.disposed) {\n return;\n }\n stampAjax(jqXHR, options);\n });\n jqueryPrefiltersInstalled.add(key);\n }\n if (!jqueryCompletesInstalled.has(key)) {\n jquery(document).ajaxComplete((_event, jqXHR, settings) => {\n const current = jqueryLiveRecords.get(key);\n if (!current || current.disposed) {\n return;\n }\n reportTiming(jqXHR, settings);\n });\n jqueryCompletesInstalled.add(key);\n }\n jqueryLiveRecords.set(key, record);\n instrumented.add(key);\n } catch (err) {\n /*\n * Keep per-handler installed flags so a retry cannot double-register\n * prefilters. Restore deletes the shared instrumented slot so teardown /\n * retry can finish whichever handler never succeeded.\n */\n record.disposed = true;\n instrumented.add(key);\n const restore = () => {\n record.disposed = true;\n if (jqueryLiveRecords.get(key) === record) {\n jqueryLiveRecords.delete(key);\n }\n instrumented.delete(key);\n };\n record.restore = restore;\n registerInstrumentRecord(record);\n // eslint-disable-next-line no-console -- soft-fail host wiring\n console.error('[journey] instrumentJquery failed', err);\n return restore;\n }\n\n const restore = () => {\n record.disposed = true;\n if (jqueryLiveRecords.get(key) === record) {\n jqueryLiveRecords.delete(key);\n }\n instrumented.delete(key);\n };\n record.restore = restore;\n registerInstrumentRecord(record);\n return restore;\n}\n"],"names":["resolveStamp","adoptJourneyStepStamp","getInstrumentedJquerySet","registerInstrumentRecord","onHttpComplete","requestKey","acceptInstrumentTarget","jqueryStamps","WeakMap","reportTiming","jqXHR","settings","stamp","get","ignore","start","journeyStart","globalThis","performance","now","aborted","statusText","status","undefined","durationMs","url","method","type","meta","request","response","isJqueryStatic","value","ajaxPrefilter","resolveGlobalJquery","g","$","jQuery","jqueryLiveRecords","jqueryPrefiltersInstalled","WeakSet","jqueryCompletesInstalled","stampAjax","options","set","instrumentJquery","jquery","instrumented","has","key","record","disposed","_originalOptions","current","add","document","ajaxComplete","_event","err","restore","delete","console","error"],"mappings":"AAAA,SAASA,YAAY,QAAQ,aAAa;AAC1C,SAASC,qBAAqB,QAA+B,sBAAsB;AACnF,SACIC,wBAAwB,EACxBC,wBAAwB,QAErB,eAAe;AACtB,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,UAAU,QAA+B,iBAAiB;AACnE,SAASC,sBAAsB,QAAQ,eAAe;AAetD,MAAMC,eAAe,IAAIC;AAiBzB,SAASC,aAAaC,KAAgB,EAAEC,QAA4B;QAClDJ,mBAIAG,qBAWFC;IAfZ,MAAMC,SAAQL,oBAAAA,aAAaM,GAAG,CAACH,oBAAjBH,+BAAAA,oBAA2BN,sBAAsBS,MAAME,KAAK;IAC1E,IAAI,CAACA,SAASA,MAAME,MAAM,IAAIH,SAASG,MAAM,KAAK,MAAM;QACpD;IACJ;IACA,MAAMC,SAAQL,sBAAAA,MAAMM,YAAY,cAAlBN,iCAAAA,sBAAsBO,WAAWC,WAAW,CAACC,GAAG;IAC9D,MAAMC,UAAUV,MAAMW,UAAU,KAAK;IACrC,mFAAmF;IACnF,MAAMC,SAASF,WAAWV,MAAMY,MAAM,KAAK,IAAIC,YAAYb,MAAMY,MAAM;IACvElB,eAAe;QACXQ;QACAU;QACAE,YAAYP,WAAWC,WAAW,CAACC,GAAG,KAAKJ;QAC3CV,YAAYA,WAAWM,SAASc,GAAG,EAAEF,WAAWA;QAChDH;QACAK,KAAKd,SAASc,GAAG;QACjBC,MAAM,GAAEf,iBAAAA,SAASgB,IAAI,cAAbhB,4BAAAA,iBAAiBA,SAASe,MAAM;QACxCE,MAAMjB;QACNkB,SAASlB;QACTmB,UAAUpB;IACd;AACJ;AAEA,SAASqB,eAAeC,KAAc;IAClC,OACI,OAAOA,UAAU,cAAc,OAAO,AAACA,MAAuBC,aAAa,KAAK;AAExF;AAEA,sDAAsD,GACtD,OAAO,SAASC;QAEJC;IADR,MAAMA,IAAIlB;IACV,QAAQkB,OAAAA,EAAEC,CAAC,cAAHD,kBAAAA,OAAOA,EAAEE,MAAM;AAC3B;AAEA,2FAA2F,GAC3F,MAAMC,oBAAoB,IAAI9B;AAC9B,uFAAuF,GACvF,MAAM+B,4BAA4B,IAAIC;AACtC,MAAMC,2BAA2B,IAAID;AAErC,SAASE,UAAUhC,KAAgB,EAAEiC,OAA2B;QAIjCjC;IAH3B,IAAIiC,QAAQ7B,MAAM,KAAK,MAAM;QACzB;IACJ;IACA,MAAMF,QAAQZ,cAAaU,eAAAA,MAAME,KAAK,cAAXF,0BAAAA,eAAeiC,QAAQ/B,KAAK;IACvD,IAAIA,OAAO;QACPL,aAAaqC,GAAG,CAAClC,OAAOE;QACxB,OAAOF,MAAME,KAAK;QAClB,OAAO+B,QAAQ/B,KAAK;IACxB;IACA,IAAIA,SAAS,CAACA,MAAME,MAAM,EAAE;QACxBJ,MAAMM,YAAY,GAAGC,WAAWC,WAAW,CAACC,GAAG;IACnD;AACJ;AAEA;;;;CAIC,GACD,OAAO,SAAS0B,iBAAiBT,CAAkC;IAC/D,MAAMU,SAASxC,uBAAuB,UAAU8B,GAAGL;IACnD,MAAMgB,eAAe7C;IACrB,IAAI,CAAC4C,UAAUC,aAAaC,GAAG,CAACF,SAAmB;QAC/C,OAAO,KAAO;IAClB;IAEA,MAAMG,MAAMH;IACZ,MAAMI,SAA2B;QAAEC,UAAU;IAAM;IAEnD,IAAI;QACA,IAAI,CAACZ,0BAA0BS,GAAG,CAACC,MAAM;YACrCH,OAAOb,aAAa,CAAC,CAACU,SAASS,kBAAkB1C;gBAC7C,MAAM2C,UAAUf,kBAAkBzB,GAAG,CAACoC;gBACtC,IAAI,CAACI,WAAWA,QAAQF,QAAQ,EAAE;oBAC9B;gBACJ;gBACAT,UAAUhC,OAAOiC;YACrB;YACAJ,0BAA0Be,GAAG,CAACL;QAClC;QACA,IAAI,CAACR,yBAAyBO,GAAG,CAACC,MAAM;YACpCH,OAAOS,UAAUC,YAAY,CAAC,CAACC,QAAQ/C,OAAOC;gBAC1C,MAAM0C,UAAUf,kBAAkBzB,GAAG,CAACoC;gBACtC,IAAI,CAACI,WAAWA,QAAQF,QAAQ,EAAE;oBAC9B;gBACJ;gBACA1C,aAAaC,OAAOC;YACxB;YACA8B,yBAAyBa,GAAG,CAACL;QACjC;QACAX,kBAAkBM,GAAG,CAACK,KAAKC;QAC3BH,aAAaO,GAAG,CAACL;IACrB,EAAE,OAAOS,KAAK;QACV;;;;SAIC,GACDR,OAAOC,QAAQ,GAAG;QAClBJ,aAAaO,GAAG,CAACL;QACjB,MAAMU,UAAU;YACZT,OAAOC,QAAQ,GAAG;YAClB,IAAIb,kBAAkBzB,GAAG,CAACoC,SAASC,QAAQ;gBACvCZ,kBAAkBsB,MAAM,CAACX;YAC7B;YACAF,aAAaa,MAAM,CAACX;QACxB;QACAC,OAAOS,OAAO,GAAGA;QACjBxD,yBAAyB+C;QACzB,+DAA+D;QAC/DW,QAAQC,KAAK,CAAC,qCAAqCJ;QACnD,OAAOC;IACX;IAEA,MAAMA,UAAU;QACZT,OAAOC,QAAQ,GAAG;QAClB,IAAIb,kBAAkBzB,GAAG,CAACoC,SAASC,QAAQ;YACvCZ,kBAAkBsB,MAAM,CAACX;QAC7B;QACAF,aAAaa,MAAM,CAACX;IACxB;IACAC,OAAOS,OAAO,GAAGA;IACjBxD,yBAAyB+C;IACzB,OAAOS;AACX"}
@@ -1,6 +1,9 @@
1
1
  export declare const JourneyNameContext: import("react").Context<string | null>;
2
2
  /** Active journey name, or null outside a `<JourneyScope>` (steps run untraced). */
3
3
  export declare function useOptionalJourneyName(): string | null;
4
- /** Active journey name; throws outside a `<JourneyScope>`. */
4
+ /**
5
+ * Active journey name; throws outside a `<JourneyScope>`.
6
+ * Prefer {@link useOptionalJourneyName} when the shell may omit a scope.
7
+ */
5
8
  export declare function useJourneyName(): string;
6
9
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,wCAAqC,CAAC;AAErE,oFAAoF;AACpF,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAEtD;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,IAAI,MAAM,CAMvC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,wCAAqC,CAAC;AAErE,oFAAoF;AACpF,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAEtD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAMvC"}
@@ -3,7 +3,10 @@ export const JourneyNameContext = createContext(null);
3
3
  /** Active journey name, or null outside a `<JourneyScope>` (steps run untraced). */ export function useOptionalJourneyName() {
4
4
  return useContext(JourneyNameContext);
5
5
  }
6
- /** Active journey name; throws outside a `<JourneyScope>`. */ export function useJourneyName() {
6
+ /**
7
+ * Active journey name; throws outside a `<JourneyScope>`.
8
+ * Prefer {@link useOptionalJourneyName} when the shell may omit a scope.
9
+ */ export function useJourneyName() {
7
10
  const name = useContext(JourneyNameContext);
8
11
  if (!name) {
9
12
  throw new Error('useJourneyName must be used within a <JourneyScope>');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/integrations/react/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport const JourneyNameContext = createContext<string | null>(null);\n\n/** Active journey name, or null outside a `<JourneyScope>` (steps run untraced). */\nexport function useOptionalJourneyName(): string | null {\n return useContext(JourneyNameContext);\n}\n\n/** Active journey name; throws outside a `<JourneyScope>`. */\nexport function useJourneyName(): string {\n const name = useContext(JourneyNameContext);\n if (!name) {\n throw new Error('useJourneyName must be used within a <JourneyScope>');\n }\n return name;\n}\n"],"names":["createContext","useContext","JourneyNameContext","useOptionalJourneyName","useJourneyName","name","Error"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAElD,OAAO,MAAMC,qBAAqBF,cAA6B,MAAM;AAErE,kFAAkF,GAClF,OAAO,SAASG;IACZ,OAAOF,WAAWC;AACtB;AAEA,4DAA4D,GAC5D,OAAO,SAASE;IACZ,MAAMC,OAAOJ,WAAWC;IACxB,IAAI,CAACG,MAAM;QACP,MAAM,IAAIC,MAAM;IACpB;IACA,OAAOD;AACX"}
1
+ {"version":3,"sources":["../../../src/integrations/react/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport const JourneyNameContext = createContext<string | null>(null);\n\n/** Active journey name, or null outside a `<JourneyScope>` (steps run untraced). */\nexport function useOptionalJourneyName(): string | null {\n return useContext(JourneyNameContext);\n}\n\n/**\n * Active journey name; throws outside a `<JourneyScope>`.\n * Prefer {@link useOptionalJourneyName} when the shell may omit a scope.\n */\nexport function useJourneyName(): string {\n const name = useContext(JourneyNameContext);\n if (!name) {\n throw new Error('useJourneyName must be used within a <JourneyScope>');\n }\n return name;\n}\n"],"names":["createContext","useContext","JourneyNameContext","useOptionalJourneyName","useJourneyName","name","Error"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAElD,OAAO,MAAMC,qBAAqBF,cAA6B,MAAM;AAErE,kFAAkF,GAClF,OAAO,SAASG;IACZ,OAAOF,WAAWC;AACtB;AAEA;;;CAGC,GACD,OAAO,SAASE;IACZ,MAAMC,OAAOJ,WAAWC;IACxB,IAAI,CAACG,MAAM;QACP,MAAM,IAAIC,MAAM;IACpB;IACA,OAAOD;AACX"}
@@ -1,13 +1,24 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type JourneyDef } from '../../core';
3
3
  import type { TagValue } from '../../core/types';
4
+ type JourneyScopeDef = JourneyDef | {
5
+ config: JourneyDef;
6
+ };
4
7
  /**
5
8
  * Opens a journey while the subtree is mounted; Excludes on unmount.
6
- * Config (timeouts, endpoints, tags, …) is captured when the journey opens;
7
- * only a `name` change re-opens.
9
+ * `name` is the lifecycle key changing it excludes the previous instance
10
+ * and opens a new one. Other config fields and `tags` update the open instance
11
+ * in place (timeouts re-arm; they do not restart).
12
+ *
13
+ * Pass a {@link JourneyDef} (`<JourneyScope {...def}>`) or spread a handle
14
+ * (`<JourneyScope {...makeASaleJourney}>` reads `handle.config`).
15
+ *
16
+ * React 18 Strict Mode (development) remounts once: expect an `excluded` emission
17
+ * then a fresh open. Production single-mount does not.
8
18
  */
9
- export declare function JourneyScope({ tags, children, ...def }: JourneyDef & {
19
+ export declare function JourneyScope({ tags, children, ...rest }: JourneyScopeDef & {
10
20
  tags?: Record<string, TagValue>;
11
21
  children: ReactNode;
12
22
  }): import("react/jsx-runtime").JSX.Element;
23
+ export {};
13
24
  //# sourceMappingURL=scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/scope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAgD,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EACzB,IAAI,EACJ,QAAQ,EACR,GAAG,GAAG,EACT,EAAE,UAAU,GAAG;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,QAAQ,EAAE,SAAS,CAAC;CACvB,2CAaA"}
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/scope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,KAAK,eAAe,GAAG,UAAU,GAAG;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,EACzB,IAAI,EACJ,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,eAAe,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,QAAQ,EAAE,SAAS,CAAC;CACvB,2CAqDA"}
@@ -1,22 +1,61 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect } from 'react';
3
- import { excludeJourney, setJourneyTags, startJourney } from '../../core';
3
+ import { setJourneyTags } from '../../core';
4
+ import { moduleRuntime } from '../../core/runtime';
4
5
  import { JourneyNameContext } from './context';
6
+ import { stableEndpointKey, stableExpectedKey, stableTagsKey } from './stable-config-keys';
5
7
  /**
6
8
  * Opens a journey while the subtree is mounted; Excludes on unmount.
7
- * Config (timeouts, endpoints, tags, …) is captured when the journey opens;
8
- * only a `name` change re-opens.
9
- */ export function JourneyScope({ tags, children, ...def }) {
10
- const { name } = def;
9
+ * `name` is the lifecycle key changing it excludes the previous instance
10
+ * and opens a new one. Other config fields and `tags` update the open instance
11
+ * in place (timeouts re-arm; they do not restart).
12
+ *
13
+ * Pass a {@link JourneyDef} (`<JourneyScope {...def}>`) or spread a handle
14
+ * (`<JourneyScope {...makeASaleJourney}>` reads `handle.config`).
15
+ *
16
+ * React 18 Strict Mode (development) remounts once: expect an `excluded` emission
17
+ * then a fresh open. Production single-mount does not.
18
+ */ export function JourneyScope({ tags, children, ...rest }) {
19
+ const def = 'config' in rest ? rest.config : rest;
20
+ const { name, timeoutMs, stepTimeoutMs, slowRequestMs, endpoints, expected, service, team, group, maxSteps } = def;
21
+ const endpointKey = stableEndpointKey(endpoints);
22
+ const expectedKey = stableExpectedKey(expected);
23
+ const configTagsKey = stableTagsKey(def.tags);
24
+ useEffect(()=>{
25
+ moduleRuntime.startJourney(def);
26
+ const opened = moduleRuntime.getOpenJourney(name);
27
+ return ()=>{
28
+ if (opened) {
29
+ moduleRuntime.excludeJourney(opened);
30
+ }
31
+ };
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- name is the lifecycle key
33
+ }, [
34
+ name
35
+ ]);
11
36
  useEffect(()=>{
12
- startJourney(def);
13
37
  if (tags) {
14
38
  setJourneyTags(name, tags);
15
39
  }
16
- return ()=>excludeJourney(name);
17
- // eslint-disable-next-line react-hooks/exhaustive-deps -- freeze-on-mount; name is the lifecycle key
18
40
  }, [
19
- name
41
+ name,
42
+ tags
43
+ ]);
44
+ useEffect(()=>{
45
+ moduleRuntime.updateOpenJourney(def);
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- field-level live updates; name-change is the other effect
47
+ }, [
48
+ name,
49
+ timeoutMs,
50
+ stepTimeoutMs,
51
+ slowRequestMs,
52
+ endpointKey,
53
+ expectedKey,
54
+ service,
55
+ team,
56
+ group,
57
+ maxSteps,
58
+ configTagsKey
20
59
  ]);
21
60
  return /*#__PURE__*/ _jsx(JourneyNameContext.Provider, {
22
61
  value: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/integrations/react/scope.tsx"],"sourcesContent":["import { useEffect, type ReactNode } from 'react';\n\nimport { excludeJourney, setJourneyTags, startJourney, type JourneyDef } from '../../core';\nimport type { TagValue } from '../../core/types';\nimport { JourneyNameContext } from './context';\n\n/**\n * Opens a journey while the subtree is mounted; Excludes on unmount.\n * Config (timeouts, endpoints, tags, …) is captured when the journey opens;\n * only a `name` change re-opens.\n */\nexport function JourneyScope({\n tags,\n children,\n ...def\n}: JourneyDef & {\n tags?: Record<string, TagValue>;\n children: ReactNode;\n}) {\n const { name } = def;\n\n useEffect(() => {\n startJourney(def);\n if (tags) {\n setJourneyTags(name, tags);\n }\n return () => excludeJourney(name);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- freeze-on-mount; name is the lifecycle key\n }, [name]);\n\n return <JourneyNameContext.Provider value={name}>{children}</JourneyNameContext.Provider>;\n}\n"],"names":["useEffect","excludeJourney","setJourneyTags","startJourney","JourneyNameContext","JourneyScope","tags","children","def","name","Provider","value"],"mappings":";AAAA,SAASA,SAAS,QAAwB,QAAQ;AAElD,SAASC,cAAc,EAAEC,cAAc,EAAEC,YAAY,QAAyB,aAAa;AAE3F,SAASC,kBAAkB,QAAQ,YAAY;AAE/C;;;;CAIC,GACD,OAAO,SAASC,aAAa,EACzBC,IAAI,EACJC,QAAQ,EACR,GAAGC,KAIN;IACG,MAAM,EAAEC,IAAI,EAAE,GAAGD;IAEjBR,UAAU;QACNG,aAAaK;QACb,IAAIF,MAAM;YACNJ,eAAeO,MAAMH;QACzB;QACA,OAAO,IAAML,eAAeQ;IAC5B,qGAAqG;IACzG,GAAG;QAACA;KAAK;IAET,qBAAO,KAACL,mBAAmBM,QAAQ;QAACC,OAAOF;kBAAOF;;AACtD"}
1
+ {"version":3,"sources":["../../../src/integrations/react/scope.tsx"],"sourcesContent":["import { useEffect, type ReactNode } from 'react';\n\nimport { setJourneyTags, type JourneyDef } from '../../core';\nimport { moduleRuntime } from '../../core/runtime';\nimport type { TagValue } from '../../core/types';\nimport { JourneyNameContext } from './context';\nimport { stableEndpointKey, stableExpectedKey, stableTagsKey } from './stable-config-keys';\n\ntype JourneyScopeDef = JourneyDef | { config: JourneyDef };\n\n/**\n * Opens a journey while the subtree is mounted; Excludes on unmount.\n * `name` is the lifecycle key changing it excludes the previous instance\n * and opens a new one. Other config fields and `tags` update the open instance\n * in place (timeouts re-arm; they do not restart).\n *\n * Pass a {@link JourneyDef} (`<JourneyScope {...def}>`) or spread a handle\n * (`<JourneyScope {...makeASaleJourney}>` reads `handle.config`).\n *\n * React 18 Strict Mode (development) remounts once: expect an `excluded` emission\n * then a fresh open. Production single-mount does not.\n */\nexport function JourneyScope({\n tags,\n children,\n ...rest\n}: JourneyScopeDef & {\n tags?: Record<string, TagValue>;\n children: ReactNode;\n}) {\n const def: JourneyDef = 'config' in rest ? rest.config : rest;\n const {\n name,\n timeoutMs,\n stepTimeoutMs,\n slowRequestMs,\n endpoints,\n expected,\n service,\n team,\n group,\n maxSteps,\n } = def;\n const endpointKey = stableEndpointKey(endpoints);\n const expectedKey = stableExpectedKey(expected);\n const configTagsKey = stableTagsKey(def.tags);\n\n useEffect(() => {\n moduleRuntime.startJourney(def);\n const opened = moduleRuntime.getOpenJourney(name);\n return () => {\n if (opened) {\n moduleRuntime.excludeJourney(opened);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- name is the lifecycle key\n }, [name]);\n\n useEffect(() => {\n if (tags) {\n setJourneyTags(name, tags);\n }\n }, [name, tags]);\n\n useEffect(() => {\n moduleRuntime.updateOpenJourney(def);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- field-level live updates; name-change is the other effect\n }, [\n name,\n timeoutMs,\n stepTimeoutMs,\n slowRequestMs,\n endpointKey,\n expectedKey,\n service,\n team,\n group,\n maxSteps,\n configTagsKey,\n ]);\n\n return <JourneyNameContext.Provider value={name}>{children}</JourneyNameContext.Provider>;\n}\n"],"names":["useEffect","setJourneyTags","moduleRuntime","JourneyNameContext","stableEndpointKey","stableExpectedKey","stableTagsKey","JourneyScope","tags","children","rest","def","config","name","timeoutMs","stepTimeoutMs","slowRequestMs","endpoints","expected","service","team","group","maxSteps","endpointKey","expectedKey","configTagsKey","startJourney","opened","getOpenJourney","excludeJourney","updateOpenJourney","Provider","value"],"mappings":";AAAA,SAASA,SAAS,QAAwB,QAAQ;AAElD,SAASC,cAAc,QAAyB,aAAa;AAC7D,SAASC,aAAa,QAAQ,qBAAqB;AAEnD,SAASC,kBAAkB,QAAQ,YAAY;AAC/C,SAASC,iBAAiB,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ,uBAAuB;AAI3F;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,aAAa,EACzBC,IAAI,EACJC,QAAQ,EACR,GAAGC,MAIN;IACG,MAAMC,MAAkB,YAAYD,OAAOA,KAAKE,MAAM,GAAGF;IACzD,MAAM,EACFG,IAAI,EACJC,SAAS,EACTC,aAAa,EACbC,aAAa,EACbC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,IAAI,EACJC,KAAK,EACLC,QAAQ,EACX,GAAGX;IACJ,MAAMY,cAAcnB,kBAAkBa;IACtC,MAAMO,cAAcnB,kBAAkBa;IACtC,MAAMO,gBAAgBnB,cAAcK,IAAIH,IAAI;IAE5CR,UAAU;QACNE,cAAcwB,YAAY,CAACf;QAC3B,MAAMgB,SAASzB,cAAc0B,cAAc,CAACf;QAC5C,OAAO;YACH,IAAIc,QAAQ;gBACRzB,cAAc2B,cAAc,CAACF;YACjC;QACJ;IACA,oFAAoF;IACxF,GAAG;QAACd;KAAK;IAETb,UAAU;QACN,IAAIQ,MAAM;YACNP,eAAeY,MAAML;QACzB;IACJ,GAAG;QAACK;QAAML;KAAK;IAEfR,UAAU;QACNE,cAAc4B,iBAAiB,CAACnB;IAChC,oHAAoH;IACxH,GAAG;QACCE;QACAC;QACAC;QACAC;QACAO;QACAC;QACAL;QACAC;QACAC;QACAC;QACAG;KACH;IAED,qBAAO,KAACtB,mBAAmB4B,QAAQ;QAACC,OAAOnB;kBAAOJ;;AACtD"}
@@ -0,0 +1,6 @@
1
+ import type { EndpointPolicy } from '../../core/endpoint-policy';
2
+ import type { TagValue } from '../../core/types';
3
+ export declare function stableEndpointKey(endpoints?: readonly EndpointPolicy[]): string;
4
+ export declare function stableExpectedKey(expected?: readonly string[]): string;
5
+ export declare function stableTagsKey(tags?: Record<string, TagValue>): string;
6
+ //# sourceMappingURL=stable-config-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stable-config-keys.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/stable-config-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAU/E;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEtE;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAQrE"}
@@ -0,0 +1,21 @@
1
+ export function stableEndpointKey(endpoints) {
2
+ if (!(endpoints === null || endpoints === void 0 ? void 0 : endpoints.length)) {
3
+ return '';
4
+ }
5
+ return endpoints.map((endpoint)=>{
6
+ var _endpoint_slowRequestMs;
7
+ return `${endpoint.match}\0${(_endpoint_slowRequestMs = endpoint.slowRequestMs) !== null && _endpoint_slowRequestMs !== void 0 ? _endpoint_slowRequestMs : ''}\0${endpoint.ignore === true}`;
8
+ }).join('\n');
9
+ }
10
+ export function stableExpectedKey(expected) {
11
+ var _ref;
12
+ return (_ref = expected === null || expected === void 0 ? void 0 : expected.join('\0')) !== null && _ref !== void 0 ? _ref : '';
13
+ }
14
+ export function stableTagsKey(tags) {
15
+ if (!tags) {
16
+ return '';
17
+ }
18
+ return Object.keys(tags).sort().map((key)=>`${key}\0${String(tags[key])}`).join('\n');
19
+ }
20
+
21
+ //# sourceMappingURL=stable-config-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/integrations/react/stable-config-keys.ts"],"sourcesContent":["import type { EndpointPolicy } from '../../core/endpoint-policy';\nimport type { TagValue } from '../../core/types';\n\nexport function stableEndpointKey(endpoints?: readonly EndpointPolicy[]): string {\n if (!endpoints?.length) {\n return '';\n }\n return endpoints\n .map(\n endpoint =>\n `${endpoint.match}\\0${endpoint.slowRequestMs ?? ''}\\0${endpoint.ignore === true}`\n )\n .join('\\n');\n}\n\nexport function stableExpectedKey(expected?: readonly string[]): string {\n return expected?.join('\\0') ?? '';\n}\n\nexport function stableTagsKey(tags?: Record<string, TagValue>): string {\n if (!tags) {\n return '';\n }\n return Object.keys(tags)\n .sort()\n .map(key => `${key}\\0${String(tags[key])}`)\n .join('\\n');\n}\n"],"names":["stableEndpointKey","endpoints","length","map","endpoint","match","slowRequestMs","ignore","join","stableExpectedKey","expected","stableTagsKey","tags","Object","keys","sort","key","String"],"mappings":"AAGA,OAAO,SAASA,kBAAkBC,SAAqC;IACnE,IAAI,EAACA,sBAAAA,gCAAAA,UAAWC,MAAM,GAAE;QACpB,OAAO;IACX;IACA,OAAOD,UACFE,GAAG,CACAC,CAAAA;YAC0BA;eAAtB,GAAGA,SAASC,KAAK,CAAC,EAAE,GAAED,0BAAAA,SAASE,aAAa,cAAtBF,qCAAAA,0BAA0B,GAAG,EAAE,EAAEA,SAASG,MAAM,KAAK,MAAM;OAExFC,IAAI,CAAC;AACd;AAEA,OAAO,SAASC,kBAAkBC,QAA4B;;IAC1D,eAAOA,qBAAAA,+BAAAA,SAAUF,IAAI,CAAC,4CAAS;AACnC;AAEA,OAAO,SAASG,cAAcC,IAA+B;IACzD,IAAI,CAACA,MAAM;QACP,OAAO;IACX;IACA,OAAOC,OAAOC,IAAI,CAACF,MACdG,IAAI,GACJZ,GAAG,CAACa,CAAAA,MAAO,GAAGA,IAAI,EAAE,EAAEC,OAAOL,IAAI,CAACI,IAAI,GAAG,EACzCR,IAAI,CAAC;AACd"}
@@ -0,0 +1,11 @@
1
+ import { type JourneyHandle, type JourneyStepOptions, type StepHandle } from '../../core';
2
+ /**
3
+ * Run a step on the active `<JourneyScope>` journey, an explicit name, or a handle.
4
+ * A handle auto-starts when the journey is not open; a bare name does not.
5
+ *
6
+ * @example
7
+ * const runStep = useJourneyStep();
8
+ * await runStep('load', async step => { await api.get('/x', { stamp: step.stamp() }); });
9
+ */
10
+ export declare function useJourneyStep(journey?: string | JourneyHandle | null): <T>(stepName: string, fn: (step: StepHandle) => T | Promise<T>, opts?: JourneyStepOptions) => Promise<T>;
11
+ //# sourceMappingURL=use-journey-step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-journey-step.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/use-journey-step.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAClB,MAAM,YAAY,CAAC;AAGpB;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,IAK7D,CAAC,YACY,MAAM,MACZ,CAAC,IAAI,EAAE,UAAU,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,SACjC,kBAAkB,KAC1B,OAAO,CAAC,CAAC,CAAC,CAGpB"}