@haystackeditor/cli 0.15.27 → 0.15.29
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/README.md +13 -20
- package/dist/assets/hooks/agent-context/detect.ts +7 -7
- package/dist/assets/hooks/agent-context/parsers/claude.ts +1 -1
- package/dist/assets/hooks/scripts/commit-msg.sh +1 -3
- package/dist/assets/hooks/scripts/post-commit.sh +1 -3
- package/dist/assets/hooks/scripts/pre-push.sh +1 -4
- package/dist/assets/hooks/scripts/prepare-commit-msg.sh +1 -2
- package/dist/assets/telemetry/browser-runtime.js +668 -43
- package/dist/assets/telemetry/runtime.cjs +62 -68
- package/dist/commands/design-verify.d.ts +11 -3
- package/dist/commands/design-verify.js +147 -4
- package/dist/commands/hooks.d.ts +1 -5
- package/dist/commands/hooks.js +10 -112
- package/dist/commands/install-session-hooks.d.ts +2 -2
- package/dist/commands/install-session-hooks.js +71 -21
- package/dist/commands/mcp.js +1 -34
- package/dist/commands/pr.js +2 -7
- package/dist/commands/setup.d.ts +1 -2
- package/dist/commands/setup.js +18 -272
- package/dist/commands/submit.js +1 -2
- package/dist/commands/verify-hosted-mcp.js +12 -2
- package/dist/commands/verify-hosted-reproducibility.d.ts +1 -0
- package/dist/commands/verify-hosted-reproducibility.js +4 -1
- package/dist/commands/verify-hosted.d.ts +20 -0
- package/dist/commands/verify-hosted.js +119 -11
- package/dist/commands/verify-precompute.d.ts +19 -0
- package/dist/commands/verify-precompute.js +328 -0
- package/dist/index.js +45 -44
- package/dist/schema.d.ts +1 -2
- package/dist/schema.js +1 -2
- package/dist/triage/prompts.d.ts +0 -7
- package/dist/triage/prompts.js +0 -145
- package/dist/triage/runner.js +3 -22
- package/dist/triage/types.d.ts +1 -8
- package/dist/types.d.ts +8 -8
- package/dist/types.js +1 -1
- package/dist/utils/design-verifier-api.d.ts +71 -0
- package/dist/utils/design-verifier-api.js +96 -0
- package/dist/utils/design-verifier-result.d.ts +7 -2
- package/dist/utils/design-verifier-result.js +67 -21
- package/dist/utils/git.d.ts +5 -1
- package/dist/utils/git.js +19 -9
- package/dist/utils/github-api.js +11 -14
- package/dist/utils/hooks.d.ts +1 -15
- package/dist/utils/hooks.js +1 -127
- package/dist/utils/telemetry.d.ts +2 -0
- package/dist/utils/telemetry.js +81 -8
- package/package.json +2 -1
- package/schemas/cloud-verifier.v1.json +69 -3
- package/schemas/{pr.v2.json → pr.v3.json} +3 -12
- package/dist/commands/traces.d.ts +0 -48
- package/dist/commands/traces.js +0 -92
- package/dist/triage/traces.d.ts +0 -20
- package/dist/triage/traces.js +0 -311
- package/schemas/traces.v1.json +0 -53
|
@@ -18,6 +18,10 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
18
18
|
} catch (_) { return null; }
|
|
19
19
|
|
|
20
20
|
var MAX_EVENTS = 128;
|
|
21
|
+
var MAX_RUNTIME_SITE_MAPPINGS = 256;
|
|
22
|
+
var MAX_ACTION_SEGMENTS_PER_PAGE = 256;
|
|
23
|
+
var MAX_ACTION_SEGMENT_BYTES_PER_PAGE = 1024 * 1024;
|
|
24
|
+
var MAX_FALLBACK_DELIVERIES_IN_FLIGHT = 2;
|
|
21
25
|
var TRACE_HEADER = 'x-haystack-trace-id';
|
|
22
26
|
var ACTION_HEADER = 'x-haystack-action-id';
|
|
23
27
|
var COHORT_HEADER = 'x-haystack-cohort';
|
|
@@ -25,7 +29,13 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
25
29
|
var REQUEST_SITE_HEADER = 'x-haystack-request-site-id';
|
|
26
30
|
var nativeFunctionToString = Function.prototype.toString;
|
|
27
31
|
var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
32
|
+
var nativeGetOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
|
|
28
33
|
var nativeGetPrototypeOf = Object.getPrototypeOf;
|
|
34
|
+
var nativeObjectCreate = Object.create;
|
|
35
|
+
var nativeDefineProperties = Object.defineProperties;
|
|
36
|
+
var nativeDefineProperty = Object.defineProperty;
|
|
37
|
+
var nativeObjectPrototype = Object.prototype;
|
|
38
|
+
var nativeObjectKeys = Object.keys;
|
|
29
39
|
var nativeHasOwnProperty = Object.prototype.hasOwnProperty;
|
|
30
40
|
var nativeReflectApply = Reflect.apply.bind(Reflect);
|
|
31
41
|
var nativeReflectConstruct = Reflect.construct.bind(Reflect);
|
|
@@ -78,7 +88,13 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
78
88
|
var pagehideInstalled = false;
|
|
79
89
|
var nativeArrayIsArray = Array.isArray;
|
|
80
90
|
var active = null;
|
|
91
|
+
var directProbeContext = null;
|
|
92
|
+
var overlapQuarantine = false;
|
|
81
93
|
var recorderDisabled = false;
|
|
94
|
+
var actionSegmentsAttempted = 0;
|
|
95
|
+
var actionSegmentBytesAttempted = 0;
|
|
96
|
+
var fallbackDeliveriesInFlight = 0;
|
|
97
|
+
var fallbackDeliveryUnavailable = false;
|
|
82
98
|
var runtimeActions = Object.create(null);
|
|
83
99
|
var runtimeSites = Object.create(null);
|
|
84
100
|
var assignedCohort = null;
|
|
@@ -101,6 +117,34 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
101
117
|
// in successful records; recorder failures must never affect the app.
|
|
102
118
|
}
|
|
103
119
|
|
|
120
|
+
function omit(context) {
|
|
121
|
+
if (!context || context.saturated) return;
|
|
122
|
+
context.omittedEvents++;
|
|
123
|
+
// Omission accounting is telemetry work too. Once its bounded budget is
|
|
124
|
+
// exhausted, all later probes in this action become lossy pass-throughs.
|
|
125
|
+
if (context.omittedEvents >= MAX_EVENTS) context.saturated = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function saturate(context) {
|
|
129
|
+
if (!context || context.saturated) return;
|
|
130
|
+
omit(context);
|
|
131
|
+
context.saturated = true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function admitProbe(context) {
|
|
135
|
+
if (!context || context.saturated) return false;
|
|
136
|
+
if (!overlapQuarantine || directProbeContext === context) return true;
|
|
137
|
+
// JavaScript does not expose a portable async-context owner. After one
|
|
138
|
+
// genuine overlap, a token-only late probe could belong to either root.
|
|
139
|
+
// Keep exact action boundaries and captured continuations, but disclose at
|
|
140
|
+
// most one omitted ambiguous probe per later action instead of guessing.
|
|
141
|
+
if (!context.quarantineProbeOmitted) {
|
|
142
|
+
context.quarantineProbeOmitted = true;
|
|
143
|
+
omit(context);
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
104
148
|
function ownDataValue(name) {
|
|
105
149
|
return safeHostData(name);
|
|
106
150
|
}
|
|
@@ -176,6 +220,21 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
176
220
|
return null;
|
|
177
221
|
}
|
|
178
222
|
|
|
223
|
+
function safeContractPrototypeMethod(receiver, name) {
|
|
224
|
+
try {
|
|
225
|
+
var cursor = nativeGetPrototypeOf(receiver);
|
|
226
|
+
for (var depth = 0; cursor && depth < 12; depth++) {
|
|
227
|
+
var descriptor = nativeGetOwnPropertyDescriptor(cursor, name);
|
|
228
|
+
if (descriptor) {
|
|
229
|
+
return nativeReflectApply(nativeHasOwnProperty, descriptor, ['value']) &&
|
|
230
|
+
typeof descriptor.value === 'function' ? descriptor.value : null;
|
|
231
|
+
}
|
|
232
|
+
cursor = nativeGetPrototypeOf(cursor);
|
|
233
|
+
}
|
|
234
|
+
} catch (_) { return null; }
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
|
|
179
238
|
function acquirePlatformCapabilities() {
|
|
180
239
|
if (platformCapabilitiesAcquired) return;
|
|
181
240
|
platformCapabilitiesAcquired = true;
|
|
@@ -352,7 +411,8 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
352
411
|
var conditionPairs = config[5];
|
|
353
412
|
var fetchPairs = config[6];
|
|
354
413
|
if (!nativeArrayIsArray(conditionPairs) || !nativeArrayIsArray(fetchPairs) ||
|
|
355
|
-
conditionPairs.length >
|
|
414
|
+
conditionPairs.length > MAX_RUNTIME_SITE_MAPPINGS ||
|
|
415
|
+
fetchPairs.length > MAX_RUNTIME_SITE_MAPPINGS) return false;
|
|
356
416
|
for (var compactConditionIndex = 0; compactConditionIndex < conditionPairs.length; compactConditionIndex++) {
|
|
357
417
|
var conditionPair = conditionPairs[compactConditionIndex];
|
|
358
418
|
if (!nativeArrayIsArray(conditionPair) || conditionPair.length !== 2 ||
|
|
@@ -364,6 +424,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
364
424
|
var fetchPair = fetchPairs[compactFetchIndex];
|
|
365
425
|
if (!nativeArrayIsArray(fetchPair) || fetchPair.length !== 3 ||
|
|
366
426
|
typeof fetchPair[0] !== 'string' || !/^f-[0-9a-f]{16}$/.test(fetchPair[0]) ||
|
|
427
|
+
(fetchPair[2] !== null && (typeof fetchPair[2] !== 'string' || !/^site-[0-9a-f]{24}$/.test(fetchPair[2]))) ||
|
|
367
428
|
compactFetches[fetchPair[0]] !== undefined) return false;
|
|
368
429
|
compactFetches[fetchPair[0]] = { requestSiteId: fetchPair[1], responseSiteId: fetchPair[2] };
|
|
369
430
|
}
|
|
@@ -393,7 +454,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
393
454
|
var fetchSites = config.fetchSites[fetchTokens[fetchIndex]];
|
|
394
455
|
if (!fetchSites) return false;
|
|
395
456
|
pendingSites.push([fetchSites.requestSiteId, 'request']);
|
|
396
|
-
pendingSites.push([fetchSites.responseSiteId, 'response']);
|
|
457
|
+
if (fetchSites.responseSiteId !== null) pendingSites.push([fetchSites.responseSiteId, 'response']);
|
|
397
458
|
}
|
|
398
459
|
var preparedSites = [];
|
|
399
460
|
var preparedIds = Object.create(null);
|
|
@@ -433,16 +494,25 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
433
494
|
|
|
434
495
|
function emit(siteId, kind, outcome, parentEventId) {
|
|
435
496
|
try {
|
|
436
|
-
if (!active) return null;
|
|
497
|
+
if (!active || active.saturated) return null;
|
|
498
|
+
if (kind === 'condition' && active.conditionEvents >= active.conditionEventLimit) {
|
|
499
|
+
if (!active.conditionBudgetOmitted) {
|
|
500
|
+
active.conditionBudgetOmitted = true;
|
|
501
|
+
omit(active);
|
|
502
|
+
}
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
437
505
|
var site = siteFor(siteId);
|
|
438
506
|
if (!site || site.actionId !== active.actionId || site.surface !== 'browser' ||
|
|
439
507
|
site.kind !== kind || !Array.isArray(site.allowedOutcomes) ||
|
|
440
508
|
site.allowedOutcomes.indexOf(outcome) === -1 || !trustedOutcome(outcome)) {
|
|
441
|
-
active
|
|
509
|
+
omit(active);
|
|
442
510
|
return null;
|
|
443
511
|
}
|
|
444
512
|
if (active.events.length >= MAX_EVENTS) {
|
|
445
|
-
|
|
513
|
+
// The event buffer is the observation budget. Do not repeatedly
|
|
514
|
+
// validate and count the unobserved tail of a hot customer loop.
|
|
515
|
+
saturate(active);
|
|
446
516
|
return null;
|
|
447
517
|
}
|
|
448
518
|
var eventId = 'browser-' + active.traceId + '-' + String(active.events.length + 1).padStart(4, '0');
|
|
@@ -455,6 +525,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
455
525
|
ordinal: active.events.length + 1,
|
|
456
526
|
};
|
|
457
527
|
active.events.push(event);
|
|
528
|
+
if (kind === 'condition') active.conditionEvents++;
|
|
458
529
|
active.parentEventId = eventId;
|
|
459
530
|
return eventId;
|
|
460
531
|
} catch (_) {
|
|
@@ -504,11 +575,13 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
504
575
|
if (!applicationFetch) throw new TypeError('fetch is not available');
|
|
505
576
|
var context = active;
|
|
506
577
|
if (!context) return invokeApplicationFetch(applicationFetch, input, init, hasInit);
|
|
578
|
+
if (!admitProbe(context)) return invokeApplicationFetch(applicationFetch, input, init, hasInit);
|
|
579
|
+
if (context.saturated) return invokeApplicationFetch(applicationFetch, input, init, hasInit);
|
|
507
580
|
// Adding correlation headers necessarily converts a string into Request.
|
|
508
581
|
// That is invisible to the platform fetch but observable to an application
|
|
509
582
|
// wrapper. Never alter a later-installed/customer fetch wrapper.
|
|
510
583
|
if (!platformFetchCorrelationAllowed() || !initialFetchLooksNative || fetchImplementation !== nativeFetchFunction) {
|
|
511
|
-
context
|
|
584
|
+
omit(context);
|
|
512
585
|
return invokeApplicationFetch(applicationFetch, input, init, hasInit);
|
|
513
586
|
}
|
|
514
587
|
var fetchInput = input;
|
|
@@ -523,18 +596,18 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
523
596
|
// and disclose the missing continuation instead. Objects include Request
|
|
524
597
|
// and URL here: avoiding `instanceof` also avoids Proxy prototype traps.
|
|
525
598
|
if (typeof input !== 'string') {
|
|
526
|
-
context
|
|
599
|
+
omit(context);
|
|
527
600
|
return invokeApplicationFetch(applicationFetch, input, init, hasInit);
|
|
528
601
|
}
|
|
529
602
|
if (!nativeLocationHref || !nativeLocationOrigin || !nativeUrlConstructor ||
|
|
530
603
|
!nativeUrlCanParse || !nativeRequestConstructor || !nativeHeadersConstructor || !nativeUrlHrefGetter ||
|
|
531
604
|
!nativeRequestHeadersGetter || !nativeHeadersHas || !nativeHeadersGet || !nativeHeadersSet ||
|
|
532
605
|
!nativeResponseHeadersGetter || !nativeResponseOkGetter || !nativePromiseReject) {
|
|
533
|
-
context
|
|
606
|
+
omit(context);
|
|
534
607
|
return invokeApplicationFetch(applicationFetch, input, init, hasInit);
|
|
535
608
|
}
|
|
536
609
|
if (!nativeReflectApply(nativeUrlCanParse, nativeUrlConstructor, [input, nativeLocationHref])) {
|
|
537
|
-
context
|
|
610
|
+
omit(context);
|
|
538
611
|
return invokeApplicationFetch(applicationFetch, input, init, hasInit);
|
|
539
612
|
}
|
|
540
613
|
var urlValue = nativeReflectConstruct(nativeUrlConstructor, [input, nativeLocationHref]);
|
|
@@ -559,7 +632,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
559
632
|
// Existing application/distributed-tracing headers win. The already
|
|
560
633
|
// constructed native Request preserves their exact platform
|
|
561
634
|
// semantics without evaluating the original init twice.
|
|
562
|
-
context
|
|
635
|
+
omit(context);
|
|
563
636
|
fetchInput = request;
|
|
564
637
|
fetchInit = undefined;
|
|
565
638
|
} else {
|
|
@@ -583,7 +656,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
583
656
|
}
|
|
584
657
|
} catch (error) {
|
|
585
658
|
failOpen();
|
|
586
|
-
context
|
|
659
|
+
omit(context);
|
|
587
660
|
if (normalizedRequest) {
|
|
588
661
|
// Request conversion already completed. A later telemetry-only failure
|
|
589
662
|
// must still perform the application fetch exactly once.
|
|
@@ -601,7 +674,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
601
674
|
if (!requestParent) return result;
|
|
602
675
|
if (!nativePromiseThen || result === null ||
|
|
603
676
|
(typeof result !== 'object' && typeof result !== 'function')) {
|
|
604
|
-
context
|
|
677
|
+
omit(context);
|
|
605
678
|
scheduleFinish(context);
|
|
606
679
|
return result;
|
|
607
680
|
}
|
|
@@ -610,6 +683,10 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
610
683
|
nativeReflectApply(nativePromiseThen, result, [function (response) {
|
|
611
684
|
context.pendingFetches--;
|
|
612
685
|
if (context === active) {
|
|
686
|
+
if (context.saturated) {
|
|
687
|
+
scheduleFinish(context);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
613
690
|
try {
|
|
614
691
|
var responseHeaders = nativeReflectApply(nativeResponseHeadersGetter, response, []);
|
|
615
692
|
var serverParent = nativeReflectApply(nativeHeadersHas, responseHeaders, [PARENT_EVENT_HEADER])
|
|
@@ -617,7 +694,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
617
694
|
: null;
|
|
618
695
|
var safeServerParent = safeNodeResponseId(context.traceId, requestParent, serverParent);
|
|
619
696
|
if (serverParent !== null && safeServerParent === null) {
|
|
620
|
-
context
|
|
697
|
+
omit(context);
|
|
621
698
|
serverParent = null;
|
|
622
699
|
} else {
|
|
623
700
|
serverParent = safeServerParent;
|
|
@@ -629,7 +706,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
629
706
|
serverParent || requestParent,
|
|
630
707
|
);
|
|
631
708
|
} catch (_) {
|
|
632
|
-
context
|
|
709
|
+
omit(context);
|
|
633
710
|
failOpen();
|
|
634
711
|
}
|
|
635
712
|
scheduleFinish(context);
|
|
@@ -647,7 +724,7 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
647
724
|
}]);
|
|
648
725
|
} catch (_) {
|
|
649
726
|
context.pendingFetches--;
|
|
650
|
-
context
|
|
727
|
+
omit(context);
|
|
651
728
|
scheduleFinish(context);
|
|
652
729
|
failOpen();
|
|
653
730
|
}
|
|
@@ -656,45 +733,535 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
656
733
|
return result;
|
|
657
734
|
}
|
|
658
735
|
|
|
736
|
+
function axiosOmission(state) {
|
|
737
|
+
if (!state.omissionRecorded) {
|
|
738
|
+
state.omissionRecorded = true;
|
|
739
|
+
omit(state.context);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function cloneAxiosConfig(config) {
|
|
744
|
+
if (config === undefined || config === null) return {};
|
|
745
|
+
if (typeof config !== 'object' || nativeArrayIsArray(config)) return null;
|
|
746
|
+
if (nativeGetPrototypeOf(config) !== nativeObjectPrototype) return null;
|
|
747
|
+
var clone = {};
|
|
748
|
+
var keys = nativeObjectKeys(config);
|
|
749
|
+
for (var index = 0; index < keys.length; index++) {
|
|
750
|
+
var key = keys[index];
|
|
751
|
+
var descriptor = nativeGetOwnPropertyDescriptor(config, key);
|
|
752
|
+
if (!descriptor || !nativeReflectApply(nativeHasOwnProperty, descriptor, ['value'])) return null;
|
|
753
|
+
Object.defineProperty(clone, key, {
|
|
754
|
+
configurable: true, enumerable: true, writable: true, value: descriptor.value,
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
return clone;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
function axiosTransformList(owner, config) {
|
|
761
|
+
var descriptor = nativeGetOwnPropertyDescriptor(config, 'transformRequest');
|
|
762
|
+
var configured;
|
|
763
|
+
if (descriptor) {
|
|
764
|
+
if (!nativeReflectApply(nativeHasOwnProperty, descriptor, ['value'])) return null;
|
|
765
|
+
configured = descriptor.value;
|
|
766
|
+
} else {
|
|
767
|
+
var defaultsDescriptor = owner && nativeGetOwnPropertyDescriptor(owner, 'defaults');
|
|
768
|
+
if (!defaultsDescriptor || !nativeReflectApply(nativeHasOwnProperty, defaultsDescriptor, ['value']) ||
|
|
769
|
+
!defaultsDescriptor.value) return null;
|
|
770
|
+
var transformDescriptor = nativeGetOwnPropertyDescriptor(defaultsDescriptor.value, 'transformRequest');
|
|
771
|
+
if (!transformDescriptor || !nativeReflectApply(nativeHasOwnProperty, transformDescriptor, ['value'])) return null;
|
|
772
|
+
configured = transformDescriptor.value;
|
|
773
|
+
}
|
|
774
|
+
if (typeof configured === 'function') return [configured];
|
|
775
|
+
if (nativeArrayIsArray(configured)) {
|
|
776
|
+
var copy = [];
|
|
777
|
+
for (var index = 0; index < configured.length; index++) {
|
|
778
|
+
if (typeof configured[index] !== 'function') return null;
|
|
779
|
+
copy[index] = configured[index];
|
|
780
|
+
}
|
|
781
|
+
return copy;
|
|
782
|
+
}
|
|
783
|
+
if (configured === undefined || configured === null) return [];
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
function axiosResponseHeader(headers, name) {
|
|
788
|
+
if (!headers) return null;
|
|
789
|
+
var get = headers.get;
|
|
790
|
+
if (typeof get !== 'function') return null;
|
|
791
|
+
var value = nativeReflectApply(get, headers, [name]);
|
|
792
|
+
return typeof value === 'string' ? value : null;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function observeAxiosResult(result, state) {
|
|
796
|
+
if (!nativePromiseThen || result === null ||
|
|
797
|
+
(typeof result !== 'object' && typeof result !== 'function')) {
|
|
798
|
+
axiosOmission(state);
|
|
799
|
+
scheduleFinish(state.context);
|
|
800
|
+
return result;
|
|
801
|
+
}
|
|
802
|
+
state.context.pendingFetches++;
|
|
803
|
+
try {
|
|
804
|
+
nativeReflectApply(nativePromiseThen, result, [function (response) {
|
|
805
|
+
state.context.pendingFetches--;
|
|
806
|
+
if (state.context === active) {
|
|
807
|
+
if (state.context.saturated) {
|
|
808
|
+
scheduleFinish(state.context);
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
var requestParent = state.requestParents.length > 0
|
|
812
|
+
? state.requestParents[state.requestParents.length - 1]
|
|
813
|
+
: null;
|
|
814
|
+
if (!requestParent) {
|
|
815
|
+
axiosOmission(state);
|
|
816
|
+
} else {
|
|
817
|
+
try {
|
|
818
|
+
var serverParentValue = axiosResponseHeader(response && response.headers, PARENT_EVENT_HEADER);
|
|
819
|
+
var serverParent = safeNodeResponseId(state.context.traceId, requestParent, serverParentValue);
|
|
820
|
+
if (serverParentValue !== null && serverParent === null) axiosOmission(state);
|
|
821
|
+
var status = response && response.status;
|
|
822
|
+
emit(
|
|
823
|
+
state.sites.responseSiteId,
|
|
824
|
+
'response',
|
|
825
|
+
typeof status === 'number' && status >= 200 && status < 300 ? 'success' : 'error',
|
|
826
|
+
serverParent || requestParent,
|
|
827
|
+
);
|
|
828
|
+
} catch (_) { axiosOmission(state); failOpen(); }
|
|
829
|
+
}
|
|
830
|
+
scheduleFinish(state.context);
|
|
831
|
+
}
|
|
832
|
+
}, function (error) {
|
|
833
|
+
state.context.pendingFetches--;
|
|
834
|
+
if (state.context === active) {
|
|
835
|
+
var requestParent = state.requestParents.length > 0
|
|
836
|
+
? state.requestParents[state.requestParents.length - 1]
|
|
837
|
+
: null;
|
|
838
|
+
if (!requestParent) {
|
|
839
|
+
axiosOmission(state);
|
|
840
|
+
} else {
|
|
841
|
+
try {
|
|
842
|
+
var response = error && error.response;
|
|
843
|
+
var serverParentValue = response
|
|
844
|
+
? axiosResponseHeader(response.headers, PARENT_EVENT_HEADER)
|
|
845
|
+
: null;
|
|
846
|
+
var serverParent = response
|
|
847
|
+
? safeNodeResponseId(state.context.traceId, requestParent, serverParentValue)
|
|
848
|
+
: null;
|
|
849
|
+
if (serverParentValue !== null && serverParent === null) axiosOmission(state);
|
|
850
|
+
emit(
|
|
851
|
+
state.sites.responseSiteId,
|
|
852
|
+
'response',
|
|
853
|
+
response ? 'error' : 'network:error',
|
|
854
|
+
serverParent || requestParent,
|
|
855
|
+
);
|
|
856
|
+
} catch (_) { axiosOmission(state); failOpen(); }
|
|
857
|
+
}
|
|
858
|
+
scheduleFinish(state.context);
|
|
859
|
+
}
|
|
860
|
+
throw error;
|
|
861
|
+
}]);
|
|
862
|
+
} catch (_) {
|
|
863
|
+
state.context.pendingFetches--;
|
|
864
|
+
axiosOmission(state);
|
|
865
|
+
scheduleFinish(state.context);
|
|
866
|
+
failOpen();
|
|
867
|
+
}
|
|
868
|
+
return result;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function axiosAt(token, owner, callable, receiver, ownerProperty, configIndex, safeConfig, applicationArguments) {
|
|
872
|
+
if (!nativeArrayIsArray(applicationArguments) || typeof callable !== 'function') {
|
|
873
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
874
|
+
}
|
|
875
|
+
var context = active;
|
|
876
|
+
if (context && context.saturated) return nativeReflectApply(callable, receiver, applicationArguments);
|
|
877
|
+
if (context && !admitProbe(context)) return nativeReflectApply(callable, receiver, applicationArguments);
|
|
878
|
+
var sites = context && context.runtimeConfig && context.runtimeConfig.fetchSites[token];
|
|
879
|
+
if (!context || !sites) return nativeReflectApply(callable, receiver, applicationArguments);
|
|
880
|
+
if ((ownerProperty !== null && (typeof ownerProperty !== 'string' || ownerProperty.length === 0 ||
|
|
881
|
+
ownerProperty.length > 256 || ownerProperty === '__proto__' || ownerProperty === 'constructor' ||
|
|
882
|
+
ownerProperty === 'prototype')) || safeConfig !== true || !Number.isInteger(configIndex) ||
|
|
883
|
+
configIndex < 0 || configIndex > 8 ||
|
|
884
|
+
!platformFetchCorrelationAllowed()) {
|
|
885
|
+
omit(context);
|
|
886
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
887
|
+
}
|
|
888
|
+
var state = { context: context, sites: sites, requestParents: [], omissionRecorded: false };
|
|
889
|
+
var args = [];
|
|
890
|
+
var config;
|
|
891
|
+
try {
|
|
892
|
+
if (ownerProperty !== null) {
|
|
893
|
+
if ((typeof receiver !== 'object' || receiver === null) && typeof receiver !== 'function') {
|
|
894
|
+
axiosOmission(state);
|
|
895
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
896
|
+
}
|
|
897
|
+
var ownerDescriptor = nativeGetOwnPropertyDescriptor(receiver, ownerProperty);
|
|
898
|
+
if (!ownerDescriptor || !nativeReflectApply(nativeHasOwnProperty, ownerDescriptor, ['value']) ||
|
|
899
|
+
((typeof ownerDescriptor.value !== 'object' || ownerDescriptor.value === null) &&
|
|
900
|
+
typeof ownerDescriptor.value !== 'function')) {
|
|
901
|
+
axiosOmission(state);
|
|
902
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
903
|
+
}
|
|
904
|
+
owner = ownerDescriptor.value;
|
|
905
|
+
}
|
|
906
|
+
for (var argumentIndex = 0; argumentIndex < applicationArguments.length; argumentIndex++) {
|
|
907
|
+
args[argumentIndex] = applicationArguments[argumentIndex];
|
|
908
|
+
}
|
|
909
|
+
config = cloneAxiosConfig(args[configIndex]);
|
|
910
|
+
var transforms = config && axiosTransformList(owner, config);
|
|
911
|
+
if (!config || !transforms) {
|
|
912
|
+
axiosOmission(state);
|
|
913
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
914
|
+
}
|
|
915
|
+
transforms.push(function haystackAxiosRequestTransform(data, headers) {
|
|
916
|
+
if (context !== active) return data;
|
|
917
|
+
if (context.saturated) return data;
|
|
918
|
+
try {
|
|
919
|
+
var requestConfig = this;
|
|
920
|
+
var requestUrl = requestConfig && requestConfig.url;
|
|
921
|
+
var baseUrl = requestConfig && requestConfig.baseURL;
|
|
922
|
+
if (typeof requestUrl !== 'string' || (baseUrl !== undefined && baseUrl !== null && typeof baseUrl !== 'string') ||
|
|
923
|
+
!nativeLocationHref || !nativeLocationOrigin || !nativeUrlConstructor || !nativeUrlHrefGetter ||
|
|
924
|
+
!headers || typeof headers.has !== 'function' || typeof headers.set !== 'function') {
|
|
925
|
+
axiosOmission(state);
|
|
926
|
+
return data;
|
|
927
|
+
}
|
|
928
|
+
var resolvedBase = baseUrl
|
|
929
|
+
? nativeReflectApply(nativeUrlHrefGetter, nativeReflectConstruct(nativeUrlConstructor, [baseUrl, nativeLocationHref]), [])
|
|
930
|
+
: nativeLocationHref;
|
|
931
|
+
var resolvedUrl = nativeReflectApply(
|
|
932
|
+
nativeUrlHrefGetter,
|
|
933
|
+
nativeReflectConstruct(nativeUrlConstructor, [requestUrl, resolvedBase]),
|
|
934
|
+
[],
|
|
935
|
+
);
|
|
936
|
+
if (resolvedUrl !== nativeLocationOrigin && resolvedUrl.indexOf(nativeLocationOrigin + '/') !== 0) {
|
|
937
|
+
axiosOmission(state);
|
|
938
|
+
return data;
|
|
939
|
+
}
|
|
940
|
+
var reservedHeaders = [TRACE_HEADER, ACTION_HEADER, COHORT_HEADER, PARENT_EVENT_HEADER, REQUEST_SITE_HEADER, 'traceparent'];
|
|
941
|
+
for (var headerIndex = 0; headerIndex < reservedHeaders.length; headerIndex++) {
|
|
942
|
+
if (nativeReflectApply(headers.has, headers, [reservedHeaders[headerIndex]])) {
|
|
943
|
+
axiosOmission(state);
|
|
944
|
+
return data;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
var requestParent = emit(sites.requestSiteId, 'request', 'sent', context.inputEventId || undefined);
|
|
948
|
+
if (!requestParent) {
|
|
949
|
+
axiosOmission(state);
|
|
950
|
+
return data;
|
|
951
|
+
}
|
|
952
|
+
nativeReflectApply(headers.set, headers, [TRACE_HEADER, context.traceId]);
|
|
953
|
+
nativeReflectApply(headers.set, headers, [ACTION_HEADER, context.actionId]);
|
|
954
|
+
nativeReflectApply(headers.set, headers, [COHORT_HEADER, '' + context.cohortIndex]);
|
|
955
|
+
nativeReflectApply(headers.set, headers, [PARENT_EVENT_HEADER, requestParent]);
|
|
956
|
+
nativeReflectApply(headers.set, headers, [REQUEST_SITE_HEADER, sites.requestSiteId]);
|
|
957
|
+
nativeReflectApply(headers.set, headers, ['traceparent', traceparent(context.traceId)]);
|
|
958
|
+
state.requestParents.push(requestParent);
|
|
959
|
+
} catch (_) { axiosOmission(state); failOpen(); }
|
|
960
|
+
return data;
|
|
961
|
+
});
|
|
962
|
+
config.transformRequest = transforms;
|
|
963
|
+
while (args.length < configIndex) args.push(undefined);
|
|
964
|
+
args[configIndex] = config;
|
|
965
|
+
} catch (_) {
|
|
966
|
+
axiosOmission(state);
|
|
967
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
968
|
+
}
|
|
969
|
+
var result = nativeReflectApply(callable, receiver, args);
|
|
970
|
+
return observeAxiosResult(result, state);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
function oazapftsAt(token, owner, callable, safeOptions, applicationArguments) {
|
|
974
|
+
if (!nativeArrayIsArray(applicationArguments) || typeof callable !== 'function') {
|
|
975
|
+
return nativeReflectApply(callable, owner, applicationArguments);
|
|
976
|
+
}
|
|
977
|
+
var context = active;
|
|
978
|
+
if (context && context.saturated) return nativeReflectApply(callable, owner, applicationArguments);
|
|
979
|
+
if (context && !admitProbe(context)) return nativeReflectApply(callable, owner, applicationArguments);
|
|
980
|
+
var sites = context && context.runtimeConfig && context.runtimeConfig.fetchSites[token];
|
|
981
|
+
if (!context || !sites) return nativeReflectApply(callable, owner, applicationArguments);
|
|
982
|
+
if (safeOptions !== true || !platformFetchCorrelationAllowed() || !nativeFetchFunction) {
|
|
983
|
+
omit(context);
|
|
984
|
+
return nativeReflectApply(callable, owner, applicationArguments);
|
|
985
|
+
}
|
|
986
|
+
var args = [];
|
|
987
|
+
try {
|
|
988
|
+
for (var argumentIndex = 0; argumentIndex < applicationArguments.length; argumentIndex++) {
|
|
989
|
+
args[argumentIndex] = applicationArguments[argumentIndex];
|
|
990
|
+
}
|
|
991
|
+
var options = cloneAxiosConfig(args[1]);
|
|
992
|
+
if (!options || nativeGetOwnPropertyDescriptor(options, 'fetch')) {
|
|
993
|
+
omit(context);
|
|
994
|
+
return nativeReflectApply(callable, owner, applicationArguments);
|
|
995
|
+
}
|
|
996
|
+
Object.defineProperty(options, 'fetch', {
|
|
997
|
+
configurable: true,
|
|
998
|
+
enumerable: true,
|
|
999
|
+
writable: true,
|
|
1000
|
+
value: function haystackOazapftsFetch(input, init) {
|
|
1001
|
+
if (arguments.length > 2) {
|
|
1002
|
+
omit(context);
|
|
1003
|
+
return nativeReflectApply(nativeFetchFunction, undefined, arguments);
|
|
1004
|
+
}
|
|
1005
|
+
if (context !== active) {
|
|
1006
|
+
return invokeApplicationFetch(nativeFetchFunction, input, init, arguments.length >= 2);
|
|
1007
|
+
}
|
|
1008
|
+
return correlatedFetch(
|
|
1009
|
+
nativeFetchFunction,
|
|
1010
|
+
input,
|
|
1011
|
+
init,
|
|
1012
|
+
sites,
|
|
1013
|
+
arguments.length >= 2,
|
|
1014
|
+
);
|
|
1015
|
+
},
|
|
1016
|
+
});
|
|
1017
|
+
while (args.length < 1) args.push(undefined);
|
|
1018
|
+
args[1] = options;
|
|
1019
|
+
} catch (_) {
|
|
1020
|
+
omit(context);
|
|
1021
|
+
return nativeReflectApply(callable, owner, applicationArguments);
|
|
1022
|
+
}
|
|
1023
|
+
return nativeReflectApply(callable, owner, args);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
659
1026
|
function fetchAt(token, fetchImplementation, input, init) {
|
|
660
1027
|
if (arguments.length > 4) {
|
|
661
1028
|
var passthroughArguments = [];
|
|
662
1029
|
for (var argumentIndex = 2; argumentIndex < arguments.length; argumentIndex++) {
|
|
663
1030
|
passthroughArguments[argumentIndex - 2] = arguments[argumentIndex];
|
|
664
1031
|
}
|
|
665
|
-
if (active) active
|
|
1032
|
+
if (active) omit(active);
|
|
666
1033
|
return nativeReflectApply(fetchImplementation, undefined, passthroughArguments);
|
|
667
1034
|
}
|
|
668
1035
|
var hasInit = arguments.length >= 4;
|
|
669
1036
|
var context = active;
|
|
1037
|
+
if (context && context.saturated) {
|
|
1038
|
+
return invokeApplicationFetch(fetchImplementation, input, init, hasInit);
|
|
1039
|
+
}
|
|
1040
|
+
if (context && !admitProbe(context)) {
|
|
1041
|
+
return invokeApplicationFetch(fetchImplementation, input, init, hasInit);
|
|
1042
|
+
}
|
|
670
1043
|
var sites = context && context.runtimeConfig && context.runtimeConfig.fetchSites[token];
|
|
671
1044
|
if (context && !sites) return invokeApplicationFetch(fetchImplementation, input, init, hasInit);
|
|
672
1045
|
return correlatedFetch(fetchImplementation, input, init, sites, hasInit);
|
|
673
1046
|
}
|
|
674
1047
|
|
|
1048
|
+
function mergeAngularHttpContractOptions(options, headerPairs) {
|
|
1049
|
+
try {
|
|
1050
|
+
if (!options || typeof options !== 'object' || nativeGetPrototypeOf(options) !== nativeObjectPrototype ||
|
|
1051
|
+
typeof nativeGetOwnPropertyDescriptors !== 'function' || typeof nativeObjectCreate !== 'function' ||
|
|
1052
|
+
typeof nativeDefineProperties !== 'function' || typeof nativeDefineProperty !== 'function') return null;
|
|
1053
|
+
var descriptors = nativeGetOwnPropertyDescriptors(options);
|
|
1054
|
+
var headersDescriptor = descriptors && descriptors.headers;
|
|
1055
|
+
if (!headersDescriptor || !nativeReflectApply(nativeHasOwnProperty, headersDescriptor, ['value']) ||
|
|
1056
|
+
!headersDescriptor.value || typeof headersDescriptor.value !== 'object') return null;
|
|
1057
|
+
var headers = headersDescriptor.value;
|
|
1058
|
+
var has = safeContractPrototypeMethod(headers, 'has');
|
|
1059
|
+
var set = safeContractPrototypeMethod(headers, 'set');
|
|
1060
|
+
if (!has || !set) return null;
|
|
1061
|
+
for (var checkIndex = 0; checkIndex < headerPairs.length; checkIndex++) {
|
|
1062
|
+
var present = nativeReflectApply(has, headers, [headerPairs[checkIndex][0]]);
|
|
1063
|
+
if (present !== false) return null;
|
|
1064
|
+
}
|
|
1065
|
+
var nextHeaders = headers;
|
|
1066
|
+
var headersPrototype = nativeGetPrototypeOf(headers);
|
|
1067
|
+
for (var setIndex = 0; setIndex < headerPairs.length; setIndex++) {
|
|
1068
|
+
nextHeaders = nativeReflectApply(set, nextHeaders, headerPairs[setIndex]);
|
|
1069
|
+
if (!nextHeaders || typeof nextHeaders !== 'object' ||
|
|
1070
|
+
nativeGetPrototypeOf(nextHeaders) !== headersPrototype) return null;
|
|
1071
|
+
}
|
|
1072
|
+
var clone = nativeObjectCreate(nativeObjectPrototype);
|
|
1073
|
+
nativeDefineProperties(clone, descriptors);
|
|
1074
|
+
nativeDefineProperty(clone, 'headers', {
|
|
1075
|
+
configurable: headersDescriptor.configurable,
|
|
1076
|
+
enumerable: headersDescriptor.enumerable,
|
|
1077
|
+
writable: headersDescriptor.writable,
|
|
1078
|
+
value: nextHeaders,
|
|
1079
|
+
});
|
|
1080
|
+
return clone;
|
|
1081
|
+
} catch (_) { return null; }
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// Angular HttpClient returns a cold Observable. Observing that Observable
|
|
1085
|
+
// would either subscribe twice or replace the application value. Instead,
|
|
1086
|
+
// the compiler-authenticated call site adds the exact correlation headers
|
|
1087
|
+
// before Angular constructs the request. Existing options are admitted only
|
|
1088
|
+
// for a build-declared source/export contract and are copied without reading
|
|
1089
|
+
// application fields. The correlated Node continuation is the terminal HTTP
|
|
1090
|
+
// outcome for this transport, so no browser response is fabricated.
|
|
1091
|
+
function angularHttpAt(token, callable, receiver, method, applicationArguments, optionsAdapter) {
|
|
1092
|
+
if (!nativeArrayIsArray(applicationArguments) || typeof callable !== 'function') {
|
|
1093
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1094
|
+
}
|
|
1095
|
+
var context = active;
|
|
1096
|
+
if (context && context.saturated) return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1097
|
+
if (context && !admitProbe(context)) return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1098
|
+
var sites = context && context.runtimeConfig && context.runtimeConfig.fetchSites[token];
|
|
1099
|
+
if (!context || !sites) return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1100
|
+
var optionsIndex = method === 'delete' || method === 'get' || method === 'head' || method === 'options'
|
|
1101
|
+
? 1
|
|
1102
|
+
: method === 'patch' || method === 'post' || method === 'put'
|
|
1103
|
+
? 2
|
|
1104
|
+
: -1;
|
|
1105
|
+
var hasOptions = applicationArguments.length > optionsIndex;
|
|
1106
|
+
if (optionsIndex < 0 || !platformFetchCorrelationAllowed() ||
|
|
1107
|
+
(hasOptions && optionsAdapter !== 'angular-http-headers-set-v1') ||
|
|
1108
|
+
(!hasOptions && optionsAdapter !== null) || applicationArguments.length > optionsIndex + 1 ||
|
|
1109
|
+
typeof applicationArguments[0] !== 'string' ||
|
|
1110
|
+
!nativeLocationHref || !nativeLocationOrigin || !nativeUrlConstructor || !nativeUrlHrefGetter) {
|
|
1111
|
+
omit(context);
|
|
1112
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1113
|
+
}
|
|
1114
|
+
var args = [];
|
|
1115
|
+
try {
|
|
1116
|
+
var url = nativeReflectApply(
|
|
1117
|
+
nativeUrlHrefGetter,
|
|
1118
|
+
nativeReflectConstruct(nativeUrlConstructor, [applicationArguments[0], nativeLocationHref]),
|
|
1119
|
+
[],
|
|
1120
|
+
);
|
|
1121
|
+
if (url !== nativeLocationOrigin && url.indexOf(nativeLocationOrigin + '/') !== 0) {
|
|
1122
|
+
omit(context);
|
|
1123
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1124
|
+
}
|
|
1125
|
+
if (context.events.length >= MAX_EVENTS) {
|
|
1126
|
+
saturate(context);
|
|
1127
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1128
|
+
}
|
|
1129
|
+
var requestParent = 'browser-' + context.traceId + '-' + String(context.events.length + 1).padStart(4, '0');
|
|
1130
|
+
var headerPairs = [
|
|
1131
|
+
['x-haystack-trace-id', context.traceId],
|
|
1132
|
+
['x-haystack-action-id', context.actionId],
|
|
1133
|
+
['x-haystack-cohort', '' + context.cohortIndex],
|
|
1134
|
+
['x-haystack-parent-event-id', requestParent],
|
|
1135
|
+
['x-haystack-request-site-id', sites.requestSiteId],
|
|
1136
|
+
['traceparent', traceparent(context.traceId)],
|
|
1137
|
+
];
|
|
1138
|
+
for (var index = 0; index < applicationArguments.length; index++) args[index] = applicationArguments[index];
|
|
1139
|
+
if (hasOptions) {
|
|
1140
|
+
var merged = mergeAngularHttpContractOptions(applicationArguments[optionsIndex], headerPairs);
|
|
1141
|
+
if (!merged) {
|
|
1142
|
+
omit(context);
|
|
1143
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1144
|
+
}
|
|
1145
|
+
args[optionsIndex] = merged;
|
|
1146
|
+
} else {
|
|
1147
|
+
while (args.length < optionsIndex) args.push(undefined);
|
|
1148
|
+
args[optionsIndex] = { headers: {
|
|
1149
|
+
'x-haystack-trace-id': context.traceId,
|
|
1150
|
+
'x-haystack-action-id': context.actionId,
|
|
1151
|
+
'x-haystack-cohort': '' + context.cohortIndex,
|
|
1152
|
+
'x-haystack-parent-event-id': requestParent,
|
|
1153
|
+
'x-haystack-request-site-id': sites.requestSiteId,
|
|
1154
|
+
'traceparent': traceparent(context.traceId),
|
|
1155
|
+
} };
|
|
1156
|
+
}
|
|
1157
|
+
var emittedParent = emit(sites.requestSiteId, 'request', 'sent', context.inputEventId || undefined);
|
|
1158
|
+
if (emittedParent !== requestParent) {
|
|
1159
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1160
|
+
}
|
|
1161
|
+
} catch (_) {
|
|
1162
|
+
omit(context);
|
|
1163
|
+
failOpen();
|
|
1164
|
+
return nativeReflectApply(callable, receiver, applicationArguments);
|
|
1165
|
+
}
|
|
1166
|
+
return nativeReflectApply(callable, receiver, args);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
675
1169
|
function deliver(segment) {
|
|
676
1170
|
try {
|
|
1171
|
+
if (recorderDisabled) return false;
|
|
677
1172
|
var endpoint = configuredEndpoint || ownDataValue('__HAYSTACK_WEB_ATLAS_ENDPOINT__');
|
|
678
|
-
if (typeof endpoint !== 'string' || endpoint.length === 0)
|
|
1173
|
+
if (typeof endpoint !== 'string' || endpoint.length === 0) {
|
|
1174
|
+
recorderDisabled = true;
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
if (actionSegmentsAttempted >= MAX_ACTION_SEGMENTS_PER_PAGE ||
|
|
1178
|
+
actionSegmentBytesAttempted >= MAX_ACTION_SEGMENT_BYTES_PER_PAGE) {
|
|
1179
|
+
recorderDisabled = true;
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1182
|
+
actionSegmentsAttempted++;
|
|
679
1183
|
var body = nativeStringify(segment);
|
|
680
|
-
if (
|
|
681
|
-
|
|
682
|
-
|
|
1184
|
+
if (body.length > MAX_ACTION_SEGMENT_BYTES_PER_PAGE - actionSegmentBytesAttempted) {
|
|
1185
|
+
recorderDisabled = true;
|
|
1186
|
+
return false;
|
|
1187
|
+
}
|
|
1188
|
+
actionSegmentBytesAttempted += body.length;
|
|
1189
|
+
if (actionSegmentsAttempted >= MAX_ACTION_SEGMENTS_PER_PAGE ||
|
|
1190
|
+
actionSegmentBytesAttempted >= MAX_ACTION_SEGMENT_BYTES_PER_PAGE) recorderDisabled = true;
|
|
1191
|
+
if (nativeBeacon) {
|
|
1192
|
+
try { if (nativeBeacon(endpoint, body)) return true; } catch (_) { failOpen(); }
|
|
1193
|
+
}
|
|
1194
|
+
if (!nativeFetch || !configuredPlatformFetch || !initialFetchLooksNative ||
|
|
1195
|
+
!nativePromiseThen || fallbackDeliveryUnavailable ||
|
|
1196
|
+
fallbackDeliveriesInFlight >= MAX_FALLBACK_DELIVERIES_IN_FLIGHT) {
|
|
1197
|
+
// Backpressure is a terminal page-local telemetry condition. Dropping
|
|
1198
|
+
// later evidence is safer than letting a collector outage accumulate
|
|
1199
|
+
// customer-page requests, closures, or serialized trace bodies.
|
|
1200
|
+
recorderDisabled = true;
|
|
1201
|
+
return false;
|
|
1202
|
+
}
|
|
1203
|
+
fallbackDeliveriesInFlight++;
|
|
1204
|
+
var settled = false;
|
|
1205
|
+
var settleFallback = function (failed) {
|
|
1206
|
+
if (settled) return;
|
|
1207
|
+
settled = true;
|
|
1208
|
+
fallbackDeliveriesInFlight--;
|
|
1209
|
+
if (failed) {
|
|
1210
|
+
fallbackDeliveryUnavailable = true;
|
|
1211
|
+
recorderDisabled = true;
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
var delivery;
|
|
1215
|
+
try {
|
|
1216
|
+
delivery = nativeFetch(endpoint, {
|
|
683
1217
|
method: 'POST',
|
|
684
1218
|
body: body,
|
|
685
1219
|
keepalive: true,
|
|
686
1220
|
headers: { 'Content-Type': 'text/plain' },
|
|
687
1221
|
});
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
1222
|
+
} catch (_) {
|
|
1223
|
+
settleFallback(true);
|
|
1224
|
+
failOpen();
|
|
1225
|
+
return false;
|
|
1226
|
+
}
|
|
1227
|
+
if (delivery === null ||
|
|
1228
|
+
(typeof delivery !== 'object' && typeof delivery !== 'function')) {
|
|
1229
|
+
settleFallback(true);
|
|
1230
|
+
return false;
|
|
1231
|
+
}
|
|
1232
|
+
try {
|
|
1233
|
+
nativeReflectApply(nativePromiseThen, delivery, [
|
|
1234
|
+
function () { settleFallback(false); },
|
|
1235
|
+
function () { settleFallback(true); },
|
|
1236
|
+
]);
|
|
1237
|
+
} catch (_) {
|
|
1238
|
+
settleFallback(true);
|
|
1239
|
+
failOpen();
|
|
1240
|
+
return false;
|
|
693
1241
|
}
|
|
1242
|
+
return true;
|
|
694
1243
|
} catch (_) { failOpen(); }
|
|
695
1244
|
return false;
|
|
696
1245
|
}
|
|
697
1246
|
|
|
1247
|
+
function conditionEventLimit(sites) {
|
|
1248
|
+
// Action start and input consume two fixed slots. Reserve the output slot
|
|
1249
|
+
// plus one request and (when declared) response for every static fetch
|
|
1250
|
+
// site that can fit inside the hard action ceiling. Conditions use the
|
|
1251
|
+
// remainder and disclose one bounded omission if they exhaust it, rather
|
|
1252
|
+
// than starving higher-value continuations in ordinary actions. If the
|
|
1253
|
+
// static continuations alone exceed the ceiling, conditions receive no
|
|
1254
|
+
// slots and the existing whole-buffer cutoff remains the final bound.
|
|
1255
|
+
var reserved = 1;
|
|
1256
|
+
var tokens = nativeObjectKeys(sites.fetchSites);
|
|
1257
|
+
for (var index = 0; index < tokens.length; index++) {
|
|
1258
|
+
var fetchSites = sites.fetchSites[tokens[index]];
|
|
1259
|
+
reserved += fetchSites && fetchSites.responseSiteId !== null ? 2 : 1;
|
|
1260
|
+
}
|
|
1261
|
+
var available = MAX_EVENTS - 2 - reserved;
|
|
1262
|
+
return available > 0 ? available : 0;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
698
1265
|
function beginAction(actionId, sites) {
|
|
699
1266
|
try {
|
|
700
1267
|
if (active || recorderDisabled) return false;
|
|
@@ -716,6 +1283,12 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
716
1283
|
rootReturned: false,
|
|
717
1284
|
finishScheduled: false,
|
|
718
1285
|
runtimeConfig: sites,
|
|
1286
|
+
conditionOutcomeKeys: Object.create(null),
|
|
1287
|
+
conditionEvents: 0,
|
|
1288
|
+
conditionEventLimit: conditionEventLimit(sites),
|
|
1289
|
+
conditionBudgetOmitted: false,
|
|
1290
|
+
quarantineProbeOmitted: false,
|
|
1291
|
+
saturated: false,
|
|
719
1292
|
};
|
|
720
1293
|
emit(sites.actionSiteId, 'action-start', 'started', null);
|
|
721
1294
|
return true;
|
|
@@ -732,13 +1305,24 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
732
1305
|
var sites = runtimeActions[actionId];
|
|
733
1306
|
if (!sites) return nativeReflectApply(handler, this, arguments);
|
|
734
1307
|
if (active) {
|
|
735
|
-
// A
|
|
736
|
-
//
|
|
737
|
-
//
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
1308
|
+
// A synchronous root can finish in the same task that starts the next
|
|
1309
|
+
// user action, before its zero-delay cleanup callback has run. It has
|
|
1310
|
+
// no outstanding application work, so close it now and attribute the
|
|
1311
|
+
// new action normally. This is common with input followed immediately
|
|
1312
|
+
// by submit (autofill, keyboard submission, and fast automation).
|
|
1313
|
+
if (active.rootReturned && active.pendingFetches === 0) {
|
|
1314
|
+
endAction();
|
|
1315
|
+
} else {
|
|
1316
|
+
// A single global action cannot safely attribute probes from
|
|
1317
|
+
// overlapping roots. Close the older partial trace with an explicit
|
|
1318
|
+
// omission, then let the exact newer action become the root. Stable
|
|
1319
|
+
// identities still validate captured continuations. Token-only async
|
|
1320
|
+
// probes cannot carry a portable root owner, so direct-probe mode
|
|
1321
|
+
// stays enabled after the first overlap rather than guessing.
|
|
1322
|
+
omit(active);
|
|
1323
|
+
overlapQuarantine = true;
|
|
1324
|
+
endAction();
|
|
1325
|
+
}
|
|
742
1326
|
}
|
|
743
1327
|
var started = beginAction(actionId, sites);
|
|
744
1328
|
if (!started) return nativeReflectApply(handler, this, arguments);
|
|
@@ -746,12 +1330,16 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
746
1330
|
var inputEventId = emit(sites.inputSiteId, 'input-shape', shapeOutcome(arguments.length > 0 ? arguments[0] : undefined));
|
|
747
1331
|
if (context) context.inputEventId = inputEventId;
|
|
748
1332
|
var result;
|
|
1333
|
+
var previousDirectProbeContext = directProbeContext;
|
|
1334
|
+
directProbeContext = context;
|
|
749
1335
|
try {
|
|
750
1336
|
result = nativeReflectApply(handler, this, arguments);
|
|
751
1337
|
} catch (error) {
|
|
752
1338
|
if (context) context.rootReturned = true;
|
|
753
|
-
endAction();
|
|
1339
|
+
if (context === active) endAction();
|
|
754
1340
|
throw error;
|
|
1341
|
+
} finally {
|
|
1342
|
+
directProbeContext = previousDirectProbeContext;
|
|
755
1343
|
}
|
|
756
1344
|
|
|
757
1345
|
// Keep a real Promise-returning action open across awaits. We attach a
|
|
@@ -763,7 +1351,9 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
763
1351
|
try {
|
|
764
1352
|
nativeReflectApply(nativePromiseThen, result, [function (value) {
|
|
765
1353
|
if (context === active) {
|
|
766
|
-
|
|
1354
|
+
if (!context.saturated) {
|
|
1355
|
+
emit(sites.outputSiteId, 'output-shape', shapeOutcome(value), context.inputEventId || undefined);
|
|
1356
|
+
}
|
|
767
1357
|
context.rootReturned = true;
|
|
768
1358
|
scheduleFinish(context);
|
|
769
1359
|
}
|
|
@@ -780,8 +1370,10 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
780
1370
|
}
|
|
781
1371
|
if (!observesPromise) {
|
|
782
1372
|
if (context && !nativePromiseThen && result !== null &&
|
|
783
|
-
(typeof result === 'object' || typeof result === 'function')) context
|
|
784
|
-
|
|
1373
|
+
(typeof result === 'object' || typeof result === 'function')) omit(context);
|
|
1374
|
+
if (context === active && !context.saturated) {
|
|
1375
|
+
emit(sites.outputSiteId, 'output-shape', shapeOutcome(result), context && context.inputEventId || undefined);
|
|
1376
|
+
}
|
|
785
1377
|
if (context) {
|
|
786
1378
|
context.rootReturned = true;
|
|
787
1379
|
scheduleFinish(context);
|
|
@@ -794,12 +1386,34 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
794
1386
|
function conditionAt(token, value) {
|
|
795
1387
|
try {
|
|
796
1388
|
var context = active;
|
|
797
|
-
|
|
1389
|
+
if (context && !admitProbe(context)) return value;
|
|
1390
|
+
var siteId = context && !context.saturated && context.runtimeConfig && context.runtimeConfig.conditionSites[token];
|
|
798
1391
|
if (siteId) emit(siteId, 'condition', value ? 'boolean:true' : 'boolean:false', context.inputEventId || undefined);
|
|
799
1392
|
} catch (_) { failOpen(); }
|
|
800
1393
|
return value;
|
|
801
1394
|
}
|
|
802
1395
|
|
|
1396
|
+
// Loop and coarse-entry probes can execute many times in one action. Keep
|
|
1397
|
+
// the first observation of each fixed boolean outcome so they cannot crowd
|
|
1398
|
+
// the action's request/response evidence out of the bounded event buffer.
|
|
1399
|
+
function conditionOnceAt(token, value) {
|
|
1400
|
+
try {
|
|
1401
|
+
var context = active;
|
|
1402
|
+
if (context && !admitProbe(context)) return value;
|
|
1403
|
+
var siteId = context && !context.saturated && context.runtimeConfig && context.runtimeConfig.conditionSites[token];
|
|
1404
|
+
if (siteId) {
|
|
1405
|
+
var outcome = value ? 'boolean:true' : 'boolean:false';
|
|
1406
|
+
var key = siteId + '\0' + outcome;
|
|
1407
|
+
var seen = context.conditionOutcomeKeys;
|
|
1408
|
+
if (seen[key] !== true) {
|
|
1409
|
+
seen[key] = true;
|
|
1410
|
+
emit(siteId, 'condition', outcome, context.inputEventId || undefined);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
} catch (_) { failOpen(); }
|
|
1414
|
+
return value;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
803
1417
|
function endAction() {
|
|
804
1418
|
try {
|
|
805
1419
|
if (!active) return null;
|
|
@@ -829,19 +1443,30 @@ var __haystackWebAtlasModuleApi = (function installHaystackWebAtlas(host) {
|
|
|
829
1443
|
configure: configure,
|
|
830
1444
|
registerAction: registerAction,
|
|
831
1445
|
beginAction: beginAction,
|
|
832
|
-
inputShape: function (siteId, outcome) { emit(siteId, 'input-shape', outcome); },
|
|
833
|
-
condition: function (siteId, outcome) { emit(siteId, 'condition', outcome); },
|
|
1446
|
+
inputShape: function (siteId, outcome) { if (admitProbe(active)) emit(siteId, 'input-shape', outcome); },
|
|
1447
|
+
condition: function (siteId, outcome) { if (admitProbe(active)) emit(siteId, 'condition', outcome); },
|
|
834
1448
|
fetch: correlatedFetch,
|
|
835
1449
|
fetchAt: fetchAt,
|
|
1450
|
+
angularHttpAt: angularHttpAt,
|
|
1451
|
+
axiosAt: axiosAt,
|
|
1452
|
+
oazapftsAt: oazapftsAt,
|
|
836
1453
|
wrapAction: wrapAction,
|
|
837
1454
|
conditionAt: conditionAt,
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
1455
|
+
conditionOnceAt: conditionOnceAt,
|
|
1456
|
+
outputShape: function (siteId, outcome) { if (admitProbe(active)) emit(siteId, 'output-shape', outcome); },
|
|
1457
|
+
uiOutcome: function (siteId, outcome) { if (admitProbe(active)) emit(siteId, 'ui-outcome', outcome); },
|
|
1458
|
+
error: function (siteId, outcome) { if (admitProbe(active)) emit(siteId, 'error', outcome); },
|
|
841
1459
|
endAction: endAction,
|
|
842
1460
|
status: function () {
|
|
843
1461
|
return active
|
|
844
|
-
? {
|
|
1462
|
+
? {
|
|
1463
|
+
active: true,
|
|
1464
|
+
disabled: recorderDisabled,
|
|
1465
|
+
saturated: active.saturated,
|
|
1466
|
+
events: active.events.length,
|
|
1467
|
+
omittedEvents: active.omittedEvents,
|
|
1468
|
+
traceId: active.traceId,
|
|
1469
|
+
}
|
|
845
1470
|
: { active: false, disabled: recorderDisabled };
|
|
846
1471
|
},
|
|
847
1472
|
});
|