@servicetitan/journey 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__test-utils__/test-runtime.d.ts.map +1 -0
- package/dist/__test-utils__/test-runtime.js +47 -0
- package/dist/__test-utils__/test-runtime.js.map +1 -0
- package/dist/__tests__/core/ambient.test.d.ts.map +1 -0
- package/dist/__tests__/core/api.test.d.ts +2 -0
- package/dist/__tests__/core/api.test.d.ts.map +1 -0
- package/dist/__tests__/core/define-journey.test.d.ts.map +1 -0
- package/dist/__tests__/core/requests.test.d.ts.map +1 -0
- package/dist/__tests__/core/runtime.test.d.ts.map +1 -0
- package/dist/__tests__/core/step.test.d.ts.map +1 -0
- package/dist/__tests__/core/timeouts.test.d.ts.map +1 -0
- package/dist/__tests__/global.test.d.ts +3 -0
- package/dist/__tests__/global.test.d.ts.map +1 -0
- package/dist/__tests__/integrations/axios.test.d.ts.map +1 -0
- package/dist/__tests__/integrations/context.test.d.ts.map +1 -0
- package/dist/__tests__/integrations/expose-app-journey.test.d.ts.map +1 -0
- package/dist/__tests__/integrations/fetch.test.d.ts.map +1 -0
- package/dist/__tests__/integrations/jquery.test.d.ts.map +1 -0
- package/dist/__tests__/integrations/request-key.test.d.ts.map +1 -0
- package/dist/__tests__/integrations/scope.test.d.ts.map +1 -0
- package/dist/__tests__/sinks/console.test.d.ts +2 -0
- package/dist/__tests__/sinks/console.test.d.ts.map +1 -0
- package/dist/__tests__/sinks/datadog.test.d.ts.map +1 -0
- package/dist/__tests__/sinks/sinks.test.d.ts.map +1 -0
- package/dist/config.d.ts +8 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -13
- package/dist/config.js.map +1 -1
- package/dist/core/{registry.d.ts → api.d.ts} +2 -22
- package/dist/core/api.d.ts.map +1 -0
- package/dist/core/{registry.js → api.js} +13 -40
- package/dist/core/api.js.map +1 -0
- package/dist/core/endpoint-policy.d.ts.map +1 -0
- package/dist/core/endpoint-policy.js.map +1 -0
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/runtime.d.ts +35 -7
- package/dist/core/runtime.d.ts.map +1 -1
- package/dist/core/runtime.js +39 -5
- package/dist/core/runtime.js.map +1 -1
- package/dist/core/step-tag.d.ts +6 -0
- package/dist/core/step-tag.d.ts.map +1 -1
- package/dist/core/step-tag.js +7 -0
- package/dist/core/step-tag.js.map +1 -1
- package/dist/core/types.d.ts +3 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/global.d.ts +67 -0
- package/dist/global.d.ts.map +1 -0
- package/dist/global.js +116 -0
- package/dist/global.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/fetch.d.ts +3 -2
- package/dist/integrations/fetch.d.ts.map +1 -1
- package/dist/integrations/fetch.js.map +1 -1
- package/dist/integrations/jquery/index.d.ts +2 -2
- package/dist/integrations/jquery/index.d.ts.map +1 -1
- package/dist/integrations/jquery/index.js +3 -2
- package/dist/integrations/jquery/index.js.map +1 -1
- package/dist/integrations/react/scope.d.ts.map +1 -1
- package/dist/integrations/react/scope.js +3 -2
- package/dist/integrations/react/scope.js.map +1 -1
- package/dist/sinks/console.d.ts +11 -0
- package/dist/sinks/console.d.ts.map +1 -0
- package/dist/sinks/console.js +18 -0
- package/dist/sinks/console.js.map +1 -0
- package/dist/sinks/datadog.d.ts +12 -1
- package/dist/sinks/datadog.d.ts.map +1 -1
- package/dist/sinks/datadog.js +28 -7
- package/dist/sinks/datadog.js.map +1 -1
- package/package.json +2 -2
- package/src/{__mocks__ → __test-utils__}/test-runtime.ts +6 -2
- package/src/__tests__/config.test.ts +9 -12
- package/src/__tests__/{ambient.test.ts → core/ambient.test.ts} +8 -7
- package/src/__tests__/{registry.test.ts → core/api.test.ts} +30 -25
- package/src/__tests__/{define-journey.test.ts → core/define-journey.test.ts} +5 -4
- package/src/__tests__/{requests.test.ts → core/requests.test.ts} +12 -8
- package/src/__tests__/{runtime.test.ts → core/runtime.test.ts} +18 -18
- package/src/__tests__/{step.test.ts → core/step.test.ts} +16 -18
- package/src/__tests__/{timeouts.test.ts → core/timeouts.test.ts} +15 -10
- package/src/__tests__/global.test.ts +113 -0
- package/src/__tests__/{axios.test.ts → integrations/axios.test.ts} +46 -15
- package/src/__tests__/{context.test.tsx → integrations/context.test.tsx} +1 -1
- package/src/__tests__/{expose-app-journey.test.ts → integrations/expose-app-journey.test.ts} +2 -2
- package/src/__tests__/{fetch.test.ts → integrations/fetch.test.ts} +6 -6
- package/src/__tests__/{jquery.test.ts → integrations/jquery.test.ts} +49 -12
- package/src/__tests__/{request-key.test.ts → integrations/request-key.test.ts} +1 -1
- package/src/__tests__/{scope.test.tsx → integrations/scope.test.tsx} +4 -4
- package/src/__tests__/sinks/console.test.ts +98 -0
- package/src/__tests__/{datadog.test.ts → sinks/datadog.test.ts} +62 -5
- package/src/__tests__/{sinks.test.ts → sinks/sinks.test.ts} +13 -12
- package/src/config.ts +20 -12
- package/src/core/{registry.ts → api.ts} +12 -65
- package/src/core/index.ts +5 -14
- package/src/core/runtime.ts +56 -7
- package/src/core/step-tag.ts +9 -0
- package/src/core/types.ts +3 -1
- package/src/global.ts +196 -0
- package/src/index.ts +20 -7
- package/src/integrations/fetch.ts +2 -2
- package/src/integrations/jquery/index.ts +4 -9
- package/src/integrations/react/scope.tsx +3 -2
- package/src/sinks/console.ts +20 -0
- package/src/sinks/datadog.ts +31 -6
- package/dist/__mocks__/test-runtime.d.ts.map +0 -1
- package/dist/__tests__/ambient.test.d.ts.map +0 -1
- package/dist/__tests__/axios.test.d.ts.map +0 -1
- package/dist/__tests__/context.test.d.ts.map +0 -1
- package/dist/__tests__/datadog.test.d.ts.map +0 -1
- package/dist/__tests__/define-journey.test.d.ts.map +0 -1
- package/dist/__tests__/expose-app-journey.test.d.ts.map +0 -1
- package/dist/__tests__/fetch.test.d.ts.map +0 -1
- package/dist/__tests__/jquery.test.d.ts.map +0 -1
- package/dist/__tests__/registry.test.d.ts +0 -2
- package/dist/__tests__/registry.test.d.ts.map +0 -1
- package/dist/__tests__/request-key.test.d.ts.map +0 -1
- package/dist/__tests__/requests.test.d.ts.map +0 -1
- package/dist/__tests__/runtime.test.d.ts.map +0 -1
- package/dist/__tests__/scope.test.d.ts.map +0 -1
- package/dist/__tests__/sinks.test.d.ts.map +0 -1
- package/dist/__tests__/step.test.d.ts.map +0 -1
- package/dist/__tests__/timeouts.test.d.ts.map +0 -1
- package/dist/core/registry.d.ts.map +0 -1
- package/dist/core/registry.js.map +0 -1
- package/dist/endpoint-policy.d.ts.map +0 -1
- package/dist/endpoint-policy.js.map +0 -1
- /package/dist/{__mocks__ → __test-utils__}/test-runtime.d.ts +0 -0
- /package/dist/__tests__/{ambient.test.d.ts → core/ambient.test.d.ts} +0 -0
- /package/dist/__tests__/{define-journey.test.d.ts → core/define-journey.test.d.ts} +0 -0
- /package/dist/__tests__/{requests.test.d.ts → core/requests.test.d.ts} +0 -0
- /package/dist/__tests__/{runtime.test.d.ts → core/runtime.test.d.ts} +0 -0
- /package/dist/__tests__/{step.test.d.ts → core/step.test.d.ts} +0 -0
- /package/dist/__tests__/{timeouts.test.d.ts → core/timeouts.test.d.ts} +0 -0
- /package/dist/__tests__/{axios.test.d.ts → integrations/axios.test.d.ts} +0 -0
- /package/dist/__tests__/{context.test.d.ts → integrations/context.test.d.ts} +0 -0
- /package/dist/__tests__/{expose-app-journey.test.d.ts → integrations/expose-app-journey.test.d.ts} +0 -0
- /package/dist/__tests__/{fetch.test.d.ts → integrations/fetch.test.d.ts} +0 -0
- /package/dist/__tests__/{jquery.test.d.ts → integrations/jquery.test.d.ts} +0 -0
- /package/dist/__tests__/{request-key.test.d.ts → integrations/request-key.test.d.ts} +0 -0
- /package/dist/__tests__/{scope.test.d.ts → integrations/scope.test.d.ts} +0 -0
- /package/dist/__tests__/{datadog.test.d.ts → sinks/datadog.test.d.ts} +0 -0
- /package/dist/__tests__/{sinks.test.d.ts → sinks/sinks.test.d.ts} +0 -0
- /package/dist/{endpoint-policy.d.ts → core/endpoint-policy.d.ts} +0 -0
- /package/dist/{endpoint-policy.js → core/endpoint-policy.js} +0 -0
- /package/src/{endpoint-policy.ts → core/endpoint-policy.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineJourney,
|
|
3
|
-
firstOpenJourney,
|
|
4
3
|
journeyStep,
|
|
5
4
|
type JourneyDef,
|
|
6
5
|
type JourneyHandle,
|
|
@@ -8,12 +7,13 @@ import {
|
|
|
8
7
|
type JourneyStepTarget,
|
|
9
8
|
type StepHandle,
|
|
10
9
|
} from '../../core';
|
|
10
|
+
import { moduleRuntime } from '../../core/runtime';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Knockout / desktop-legacy bridge on `window.App.Journey`.
|
|
14
14
|
* Prefer `defineJourney` handles; `journeyStep` / `firstOpenJourney` cover multi-journey steps.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
interface AppJourneyApi {
|
|
17
17
|
defineJourney(def: JourneyDef): JourneyHandle;
|
|
18
18
|
journeyStep<T>(
|
|
19
19
|
journey: JourneyStepTarget,
|
|
@@ -43,7 +43,7 @@ export function exposeAppJourney(target: WindowWithAppJourney = window): AppJour
|
|
|
43
43
|
const api: AppJourneyApi = {
|
|
44
44
|
defineJourney,
|
|
45
45
|
journeyStep,
|
|
46
|
-
firstOpenJourney,
|
|
46
|
+
firstOpenJourney: names => moduleRuntime.firstOpenJourney(names),
|
|
47
47
|
};
|
|
48
48
|
target.App = target.App ?? {};
|
|
49
49
|
target.App.Journey = api;
|
|
@@ -54,9 +54,4 @@ export function exposeAppJourney(target: WindowWithAppJourney = window): AppJour
|
|
|
54
54
|
return api;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export {
|
|
58
|
-
instrumentJquery,
|
|
59
|
-
type JqueryAjaxSettings,
|
|
60
|
-
type JqueryStatic,
|
|
61
|
-
type JqueryXHR,
|
|
62
|
-
} from './instrument';
|
|
57
|
+
export { instrumentJquery, type JqueryStatic } from './instrument';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, type ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import { excludeJourney, setJourneyTags,
|
|
3
|
+
import { excludeJourney, setJourneyTags, type JourneyDef } from '../../core';
|
|
4
|
+
import { moduleRuntime } from '../../core/runtime';
|
|
4
5
|
import type { TagValue } from '../../core/types';
|
|
5
6
|
import { JourneyNameContext } from './context';
|
|
6
7
|
|
|
@@ -20,7 +21,7 @@ export function JourneyScope({
|
|
|
20
21
|
const { name } = def;
|
|
21
22
|
|
|
22
23
|
useEffect(() => {
|
|
23
|
-
startJourney(def);
|
|
24
|
+
moduleRuntime.startJourney(def);
|
|
24
25
|
if (tags) {
|
|
25
26
|
setJourneyTags(name, tags);
|
|
26
27
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isJourneyDebugEnabled } from '../global';
|
|
2
|
+
import type { JourneyEvent } from '../core/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Log a terminal journey to the browser console when debugging is enabled.
|
|
6
|
+
* No-op unless `__stJourney.enableDebugging()` / `enableJourneyDebugging()` was used
|
|
7
|
+
* (reload after enabling from DevTools).
|
|
8
|
+
*
|
|
9
|
+
* There is no reliable cross-browser API to detect an open DevTools console;
|
|
10
|
+
* use the explicit debug flag instead.
|
|
11
|
+
*/
|
|
12
|
+
export function sendToConsole(event: JourneyEvent): void {
|
|
13
|
+
if (!isJourneyDebugEnabled()) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const j = event.journey;
|
|
18
|
+
// eslint-disable-next-line no-console -- intentional debug sink
|
|
19
|
+
console.debug(`[journey] ${j.name} → ${j.outcome}`, j);
|
|
20
|
+
}
|
package/src/sinks/datadog.ts
CHANGED
|
@@ -1,24 +1,49 @@
|
|
|
1
1
|
import { datadogRum } from '@datadog/browser-rum';
|
|
2
2
|
|
|
3
|
+
import { getJourneyRumFallback, setJourneyRumFallback } from '../global';
|
|
3
4
|
import type { JourneyEvent, JourneyStepEvent, TagValue } from '../core/types';
|
|
4
5
|
|
|
5
6
|
const JOURNEY_ACTION = 'user_journey';
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
+
const DD_RUM_KEY = 'DD_RUM';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
function getDdRum(): typeof datadogRum | undefined {
|
|
11
|
+
return (globalThis as Record<string, unknown>)[DD_RUM_KEY] as typeof datadogRum | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Publish a RUM instance for MFE bundles to share — **only needed if
|
|
16
|
+
* `globalThis.DD_RUM` is not set**.
|
|
17
|
+
*
|
|
18
|
+
* Prefer exposing the initialized instance as `globalThis.DD_RUM` (ST host:
|
|
19
|
+
* `datadogGuard`). `sendToDatadog` resolves `DD_RUM` first, then `__stJourney.rum`
|
|
20
|
+
* (this fallback), then the bundle's imported `datadogRum`.
|
|
21
|
+
*
|
|
22
|
+
* Calling `setJourneyRum` while `globalThis.DD_RUM` is already set logs a warning —
|
|
23
|
+
* the call is redundant because `sendToDatadog` prefers `DD_RUM`.
|
|
24
|
+
*/
|
|
10
25
|
export function setJourneyRum(rum: unknown): void {
|
|
11
|
-
(
|
|
26
|
+
if (getDdRum()) {
|
|
27
|
+
// eslint-disable-next-line no-console -- soft-deprecate redundant bridge use
|
|
28
|
+
console.warn(
|
|
29
|
+
'[journey] setJourneyRum() is unnecessary when globalThis.DD_RUM is set — sendToDatadog already prefers DD_RUM'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
setJourneyRumFallback(rum);
|
|
12
33
|
}
|
|
13
34
|
|
|
14
35
|
function resolveRum(): typeof datadogRum {
|
|
15
|
-
const
|
|
36
|
+
const ddRum = getDdRum();
|
|
37
|
+
if (ddRum) {
|
|
38
|
+
return ddRum;
|
|
39
|
+
}
|
|
40
|
+
const shared = getJourneyRumFallback();
|
|
16
41
|
return (shared as typeof datadogRum | undefined) ?? datadogRum;
|
|
17
42
|
}
|
|
18
43
|
|
|
19
|
-
|
|
44
|
+
/** Match Datadog metric-tag value rules so RUM attributes / globals join derived SLO tags. */
|
|
20
45
|
const MAX_TAG_VALUE_LEN = 200;
|
|
21
|
-
function normalizeTagValue(value: string): string {
|
|
46
|
+
export function normalizeTagValue(value: string): string {
|
|
22
47
|
return value
|
|
23
48
|
.toLowerCase()
|
|
24
49
|
.replace(/[^a-z0-9_\-:./]/g, '_')
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-runtime.d.ts","sourceRoot":"","sources":["../../src/__mocks__/test-runtime.ts"],"names":[],"mappings":"AAGA,sDAAsD;AACtD,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,qDAAqD;AACrD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,OAE9C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,QAexD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ambient.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ambient.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axios.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/axios.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/context.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datadog.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/datadog.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-journey.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/define-journey.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expose-app-journey.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/expose-app-journey.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/fetch.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jquery.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/jquery.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/registry.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-key.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/request-key.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requests.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/requests.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/runtime.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scope.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/scope.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sinks.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/sinks.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"step.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/step.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeouts.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/timeouts.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACX,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC;AAE3C,uCAAuC;AACvC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAErE;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAEzD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,cAAc,GAAG,SAAS,EAChC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACnB,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAC/B,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxC,IAAI,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,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version":3,"sources":["../../src/core/registry.ts"],"sourcesContent":["import { defaultRuntime } from './runtime';\nimport type {\n JourneyDef,\n JourneyEvent,\n JourneyHandle,\n JourneySink,\n JourneyState,\n JourneyStepOptions,\n JourneyStepRef,\n JourneyStepTarget,\n StepHandle,\n TagValue,\n} from './types';\n\nexport type { JourneyHandle, JourneySink };\n\n/** Look up an open journey by name. */\nexport function getOpenJourney(name: string): JourneyState | undefined {\n return defaultRuntime.getOpenJourney(name);\n}\n\n/** First open journey among `names` (order preserved), or null. */\nexport function firstOpenJourney(names: readonly string[]): string | null {\n return defaultRuntime.firstOpenJourney(names);\n}\n\n/**\n * Active step for soft-ambient HTTP attribution, or null when 0 or 2+ steps are in flight\n * app-wide. Untagged traffic is attributed to that lone step even if unrelated — prefer\n * `step.tag()` when the page has background instrumented requests. Adapters call this when\n * a request has no explicit stamp.\n */\nexport function activeJourneyStep(): JourneyStepRef | null {\n return defaultRuntime.activeJourneyStep();\n}\n\n/**\n * Record a finished backend request against a captured step.\n * 5xx / network / slow (over threshold) mark Bad; 4xx is not counted. Fail-fast on breach.\n */\nexport function reportBackendRequest(\n step: JourneyStepRef | undefined,\n status: number | undefined,\n durationMs: number,\n requestKey: string\n): void {\n defaultRuntime.reportBackendRequest(step, status, durationMs, requestKey);\n}\n\n/**\n * Run one step of a named journey. Runs untraced (noop handle) when no matching journey is open.\n * `journey` may be a name, null, or an ordered candidate list.\n * Prefer `defineJourney(...).step` when you own the journey config.\n */\nexport async function journeyStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n): Promise<T> {\n return defaultRuntime.journeyStep(journey, stepName, fn, opts);\n}\n\n/**\n * journeyStep deferred by one microtask so a parent `<JourneyScope>` opens first\n * (React runs child mount effects before parent). Use for mount-effect steps only.\n */\nexport async function journeyMountStep<T>(\n journey: JourneyStepTarget,\n stepName: string,\n fn: (step: StepHandle) => T | Promise<T>,\n opts?: JourneyStepOptions\n): Promise<T> {\n return defaultRuntime.journeyMountStep(journey, stepName, fn, opts);\n}\n\n/** Replace the sink list (e.g. host bootstrap or tests). Pass `[]` to disable emission. */\nexport function setJourneySinks(next: readonly JourneySink[]): void {\n defaultRuntime.setSinks(next);\n}\n\n/** Append a sink alongside the current ones. */\nexport function addJourneySink(sink: JourneySink): void {\n defaultRuntime.addSink(sink);\n}\n\n/** Emit a terminal journey event to every configured sink. */\nexport function emitJourneyEvent(payload: JourneyEvent): void {\n defaultRuntime.emit(payload);\n}\n\n/** Merge custom tags onto an open journey. No-op if not open. Prefer `handle.setTags`. */\nexport function setJourneyTags(name: string | null, tags: Record<string, TagValue>): void {\n defaultRuntime.setJourneyTags(name, tags);\n}\n\n/** Begin a journey. Restarts (closes) an already-open journey of the same name. */\nexport function startJourney(def: JourneyDef): void {\n defaultRuntime.startJourney(def);\n}\n\n/** Fail-fast: record reason and emit immediately. Idempotent via `closed`. */\nexport function failJourneyNow(journey: JourneyState, reason: string): void {\n defaultRuntime.failJourneyNow(journey, reason);\n}\n\n/** Mark a named journey Bad for a custom reason (fail-fast). Prefer `handle.fail`. */\nexport function failJourney(name: string, reason: string): void {\n defaultRuntime.failJourney(name, reason);\n}\n\n/** Successful end. Outcome stays Bad if a breach already occurred. No-op when name is null. Prefer `handle.complete`. */\nexport function completeJourney(name: string | null, tags?: Record<string, TagValue>): void {\n defaultRuntime.completeJourney(name, tags);\n}\n\n/** User left before finishing. Stays Bad if a breach already occurred (breach-anchored). Prefer `handle.exclude`. */\nexport function excludeJourney(name: string): void {\n defaultRuntime.excludeJourney(name);\n}\n\n/** Turn a journey config into a handle with bound lifecycle methods. Preferred public API. */\nexport function defineJourney(def: JourneyDef): JourneyHandle {\n const ensureStarted = () => {\n if (!getOpenJourney(def.name)) {\n startJourney(def);\n }\n };\n\n const handle: JourneyHandle = {\n ...def,\n start(tags) {\n startJourney(def);\n if (tags) {\n setJourneyTags(def.name, tags);\n }\n },\n step(stepName, fn, opts) {\n ensureStarted();\n return journeyStep(def.name, stepName, fn, opts);\n },\n async mountStep(stepName, fn, opts) {\n // Defer so a parent <JourneyScope> opens first (child effects run before parent).\n await Promise.resolve();\n ensureStarted();\n return journeyStep(def.name, stepName, fn, opts);\n },\n complete(tags) {\n completeJourney(def.name, tags);\n },\n fail(reason) {\n failJourney(def.name, reason);\n },\n exclude() {\n excludeJourney(def.name);\n },\n setTags(tags) {\n setJourneyTags(def.name, tags);\n },\n };\n return handle;\n}\n"],"names":["defaultRuntime","getOpenJourney","name","firstOpenJourney","names","activeJourneyStep","reportBackendRequest","step","status","durationMs","requestKey","journeyStep","journey","stepName","fn","opts","journeyMountStep","setJourneySinks","next","setSinks","addJourneySink","sink","addSink","emitJourneyEvent","payload","emit","setJourneyTags","tags","startJourney","def","failJourneyNow","reason","failJourney","completeJourney","excludeJourney","defineJourney","ensureStarted","handle","start","mountStep","Promise","resolve","complete","fail","exclude","setTags"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAgB3C,qCAAqC,GACrC,OAAO,SAASC,eAAeC,IAAY;IACvC,OAAOF,eAAeC,cAAc,CAACC;AACzC;AAEA,iEAAiE,GACjE,OAAO,SAASC,iBAAiBC,KAAwB;IACrD,OAAOJ,eAAeG,gBAAgB,CAACC;AAC3C;AAEA;;;;;CAKC,GACD,OAAO,SAASC;IACZ,OAAOL,eAAeK,iBAAiB;AAC3C;AAEA;;;CAGC,GACD,OAAO,SAASC,qBACZC,IAAgC,EAChCC,MAA0B,EAC1BC,UAAkB,EAClBC,UAAkB;IAElBV,eAAeM,oBAAoB,CAACC,MAAMC,QAAQC,YAAYC;AAClE;AAEA;;;;CAIC,GACD,OAAO,eAAeC,YAClBC,OAA0B,EAC1BC,QAAgB,EAChBC,EAAwC,EACxCC,IAAyB;IAEzB,OAAOf,eAAeW,WAAW,CAACC,SAASC,UAAUC,IAAIC;AAC7D;AAEA;;;CAGC,GACD,OAAO,eAAeC,iBAClBJ,OAA0B,EAC1BC,QAAgB,EAChBC,E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,GACZ,cAAc,GAAG,SAAS,CAO5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/endpoint-policy.ts"],"sourcesContent":["/** Per-endpoint request policy (app-wide or per-journey). Longest matching prefix wins. */\nexport interface EndpointPolicy {\n /**\n * Path/host prefix against the request key (`\"/path\"` same-origin, `\"host/path\"` cross-domain).\n * Match requires an exact hit or a `/` boundary after the prefix — `/api/user` matches\n * `/api/user` and `/api/user/42`, but not `/api/user-preferences`. A trailing `/` on\n * `match` already supplies the boundary.\n */\n match: string;\n /** Custom slow-request threshold in ms; omit / 0 falls through. */\n timeoutMs?: number;\n /** When true, errors and slow responses never mark the journey Bad. */\n ignore?: boolean;\n}\n\n/** App-wide slow-request threshold fallback (not an axios abort). */\nexport interface AppRequestTimeouts {\n /** Fallback threshold when no endpoint or journey override applies. */\n defaultMs: number;\n /** App-wide endpoint overrides; journey-specific ones belong on JourneyDef.endpoints. */\n endpoints?: readonly EndpointPolicy[];\n}\n\n/** Copy sorted longest-match-first so lookup can return on the first hit. */\nexport function sortEndpointsByLongestMatch(\n endpoints: readonly EndpointPolicy[] | undefined\n): EndpointPolicy[] | undefined {\n if (endpoints == null) {\n return undefined;\n }\n if (endpoints.length <= 1) {\n return endpoints.length === 0 ? [] : [...endpoints];\n }\n return [...endpoints].sort((a, b) => b.match.length - a.match.length);\n}\n\n/**\n * True when `key` equals `match` or continues past a path boundary.\n * `/api/user` matches `/api/user` and `/api/user/42`, not `/api/user-preferences`.\n */\nfunction matchesEndpoint(key: string, match: string): boolean {\n if (!key.startsWith(match)) {\n return false;\n }\n if (match.endsWith('/')) {\n return true;\n }\n const next = key[match.length];\n return next === undefined || next === '/';\n}\n\n/**\n * Longest-prefix match of an endpoint list against a request key.\n * Expects `endpoints` sorted longest-match-first (see `sortEndpointsByLongestMatch`).\n */\nexport function longestEndpointMatch(\n endpoints: readonly EndpointPolicy[] | undefined,\n key: string\n): EndpointPolicy | undefined {\n for (const e of endpoints ?? []) {\n if (matchesEndpoint(key, e.match)) {\n return e;\n }\n }\n return undefined;\n}\n"],"names":["sortEndpointsByLongestMatch","endpoints","undefined","length","sort","a","b","match","matchesEndpoint","key","startsWith","endsWith","next","longestEndpointMatch","e"],"mappings":"AAAA,yFAAyF,GAuBzF,2EAA2E,GAC3E,OAAO,SAASA,4BACZC,SAAgD;IAEhD,IAAIA,aAAa,MAAM;QACnB,OAAOC;IACX;IACA,IAAID,UAAUE,MAAM,IAAI,GAAG;QACvB,OAAOF,UAAUE,MAAM,KAAK,IAAI,EAAE,GAAG;eAAIF;SAAU;IACvD;IACA,OAAO;WAAIA;KAAU,CAACG,IAAI,CAAC,CAACC,GAAGC,IAAMA,EAAEC,KAAK,CAACJ,MAAM,GAAGE,EAAEE,KAAK,CAACJ,MAAM;AACxE;AAEA;;;CAGC,GACD,SAASK,gBAAgBC,GAAW,EAAEF,KAAa;IAC/C,IAAI,CAACE,IAAIC,UAAU,CAACH,QAAQ;QACxB,OAAO;IACX;IACA,IAAIA,MAAMI,QAAQ,CAAC,MAAM;QACrB,OAAO;IACX;IACA,MAAMC,OAAOH,GAAG,CAACF,MAAMJ,MAAM,CAAC;IAC9B,OAAOS,SAASV,aAAaU,SAAS;AAC1C;AAEA;;;CAGC,GACD,OAAO,SAASC,qBACZZ,SAAgD,EAChDQ,GAAW;IAEX,KAAK,MAAMK,KAAKb,sBAAAA,uBAAAA,YAAa,EAAE,CAAE;QAC7B,IAAIO,gBAAgBC,KAAKK,EAAEP,KAAK,GAAG;YAC/B,OAAOO;QACX;IACJ;IACA,OAAOZ;AACX"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/__tests__/{expose-app-journey.test.d.ts → integrations/expose-app-journey.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|