@interfere/react 12.3.0 → 12.3.4

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 (97) hide show
  1. package/dist/{activity-Duhfgvxt.d.mts → activity-CShcwAW_.d.mts} +14 -4
  2. package/dist/activity-oYlZ5aa1.mjs +1 -0
  3. package/dist/{api-CMPV9rgU.d.mts → api-DSUjs8zG.d.mts} +4 -2
  4. package/dist/api-DvHT4Dyw.mjs +1 -0
  5. package/dist/click-span-gate-6dNMhjc7.mjs +1 -0
  6. package/dist/delivery-D9hzPDs9.mjs +1 -0
  7. package/dist/error-boundary.d.mts +1 -1
  8. package/dist/{errors-BfUmjgWO.mjs → errors-B8XYW4Q7.mjs} +1 -1
  9. package/dist/export-filter-Cixywxpu.mjs +1 -0
  10. package/dist/exporter-De0h9YP5.mjs +1 -0
  11. package/dist/index-DpkTHU1a.d.mts +4 -0
  12. package/dist/ingest-backoff-B1OeEV3h.mjs +1 -0
  13. package/dist/instrumentations-NN81kslu.mjs +1 -0
  14. package/dist/{instrumentations-D656I08h.d.mts → instrumentations-S-BCpguB.d.mts} +8 -9
  15. package/dist/internal/activity/activity.d.mts +2 -2
  16. package/dist/internal/activity/activity.mjs +1 -1
  17. package/dist/internal/capture/capture-boundary.d.mts +1 -1
  18. package/dist/internal/capture/capture.d.mts +1 -1
  19. package/dist/internal/clock/sent-at.d.mts +5 -0
  20. package/dist/internal/clock/sent-at.mjs +1 -0
  21. package/dist/internal/ingest-backoff/ingest-backoff.d.mts +12 -0
  22. package/dist/internal/ingest-backoff/ingest-backoff.mjs +1 -0
  23. package/dist/internal/kernel-registry.d.mts +1 -1
  24. package/dist/internal/kernel.d.mts +2 -2
  25. package/dist/internal/kernel.mjs +1 -1
  26. package/dist/internal/otel/export-filter.d.mts +12 -0
  27. package/dist/internal/otel/export-filter.mjs +1 -0
  28. package/dist/internal/otel/exporter.mjs +1 -1
  29. package/dist/internal/otel/index.d.mts +2 -2
  30. package/dist/internal/otel/index.mjs +1 -1
  31. package/dist/internal/otel/instrumentations/click-span-gate.d.mts +8 -0
  32. package/dist/internal/otel/instrumentations/click-span-gate.mjs +1 -0
  33. package/dist/internal/otel/instrumentations/instrumentations.d.mts +2 -2
  34. package/dist/internal/otel/instrumentations/instrumentations.mjs +1 -1
  35. package/dist/internal/otel/instrumentations/network-failure.d.mts +2 -0
  36. package/dist/internal/otel/instrumentations/network-failure.mjs +1 -0
  37. package/dist/internal/otel/provider.mjs +1 -1
  38. package/dist/internal/page-lifecycle/page-lifecycle.d.mts +2 -0
  39. package/dist/internal/page-lifecycle/page-lifecycle.mjs +1 -1
  40. package/dist/internal/plugins/plugin-runtime.d.mts +1 -1
  41. package/dist/internal/plugins/plugin-runtime.mjs +1 -1
  42. package/dist/internal/react-context.d.mts +1 -1
  43. package/dist/internal/third-party-hosts.d.mts +5 -5
  44. package/dist/internal/third-party-hosts.mjs +1 -1
  45. package/dist/internal/version.mjs +1 -1
  46. package/dist/internal/wrapper-singleton.d.mts +1 -1
  47. package/dist/internal/wrapper-singleton.mjs +1 -1
  48. package/dist/kernel-BVG-7Zau.mjs +1 -0
  49. package/dist/{loader-DIaWtHND.mjs → loader-CZ-5Z5A5.mjs} +1 -1
  50. package/dist/network-failure-DFMPEnXx.d.mts +19 -0
  51. package/dist/network-failure-GVLV_sUF.mjs +1 -0
  52. package/dist/{page-lifecycle-DTWqGlz2.mjs → page-lifecycle-rJEJNdKj.mjs} +1 -1
  53. package/dist/{plugin-runtime-B1oFO16q.mjs → plugin-runtime-DSj0FM1Q.mjs} +1 -1
  54. package/dist/plugins/device.d.mts +1 -1
  55. package/dist/plugins/errors.d.mts +1 -1
  56. package/dist/plugins/errors.mjs +1 -1
  57. package/dist/plugins/lib/loader.d.mts +1 -1
  58. package/dist/plugins/lib/loader.mjs +1 -1
  59. package/dist/plugins/lib/types.d.mts +1 -1
  60. package/dist/plugins/logs.d.mts +1 -1
  61. package/dist/plugins/page-events.d.mts +1 -1
  62. package/dist/plugins/rage-clicks.d.mts +1 -1
  63. package/dist/plugins/replay/index.d.mts +1 -1
  64. package/dist/plugins/replay/index.mjs +1 -1
  65. package/dist/plugins/replay/recorder/recorder.d.mts +1 -0
  66. package/dist/plugins/replay/recorder/recorder.mjs +1 -1
  67. package/dist/plugins/replay/upload/delivery.d.mts +5 -2
  68. package/dist/plugins/replay/upload/delivery.mjs +1 -1
  69. package/dist/plugins/replay/upload/upload.mjs +1 -1
  70. package/dist/provider-CElaujE6.mjs +1 -0
  71. package/dist/{provider-DIp7vkKd.d.mts → provider-D4QjZp3L.d.mts} +8 -6
  72. package/dist/provider.d.mts +1 -1
  73. package/dist/react-error-handler.d.mts +1 -1
  74. package/dist/recorder-C36qxD3q.mjs +1 -0
  75. package/dist/sent-at-CEM8UV3W.mjs +1 -0
  76. package/dist/session-retry-TrzzihIM.mjs +1 -0
  77. package/dist/third-party-hosts-CYOuLL_s.mjs +1 -0
  78. package/dist/tracking/api.d.mts +1 -1
  79. package/dist/tracking/api.mjs +1 -1
  80. package/dist/tracking/registration.fixture.d.mts +1 -1
  81. package/dist/tracking/registration.fixture.mjs +1 -1
  82. package/dist/tracking/session-retry.mjs +1 -1
  83. package/dist/upload-D55WVf_o.mjs +1 -0
  84. package/dist/{version-CU2o2z22.mjs → version-DusHm2Q4.mjs} +1 -1
  85. package/package.json +4 -3
  86. package/dist/activity-BYnL3bX-.mjs +0 -1
  87. package/dist/api-BUYnj5MA.mjs +0 -1
  88. package/dist/delivery-BXEtTvnO.mjs +0 -1
  89. package/dist/exporter-CcNtHR8L.mjs +0 -1
  90. package/dist/index-BZ_yQUGY.d.mts +0 -4
  91. package/dist/instrumentations-CY8NcP_M.mjs +0 -1
  92. package/dist/kernel-B0Q_aRde.mjs +0 -1
  93. package/dist/provider-DYb87tIb.mjs +0 -1
  94. package/dist/recorder-CM6Ae_0S.mjs +0 -1
  95. package/dist/session-retry-C2Uh7eZ6.mjs +0 -1
  96. package/dist/third-party-hosts-BoJNL3xG.mjs +0 -1
  97. package/dist/upload-BIh8Q5UQ.mjs +0 -1
@@ -1,9 +1,10 @@
1
1
  //#region src/internal/activity/activity.d.ts
2
+ /** Input-idle time after which the session pauses (replay stops recording); the session id is kept. */
2
3
  declare const IDLE_AFTER_MS: number;
4
+ /** Input gap after which the next input rotates to a new session id. */
3
5
  declare const EXPIRE_AFTER_MS: number;
4
6
  declare const MAX_AGE_MS: number;
5
7
  declare const CHECK_INTERVAL_MS: number;
6
- declare const KEEPALIVE_THROTTLE_MS = 1000;
7
8
  interface ActivitySession {
8
9
  markActivity: () => void;
9
10
  reset: () => void;
@@ -11,26 +12,35 @@ interface ActivitySession {
11
12
  startedAt: () => number;
12
13
  }
13
14
  type SessionResumeReason = "idle" | "rotated";
15
+ type SessionPauseReason = "hidden" | "idle";
14
16
  type Handler<A> = (arg: A) => void;
15
17
  declare class ActivityMonitor {
16
18
  private session;
17
- private paused;
19
+ private pausedFor;
20
+ private lastPausedExceptionMs;
18
21
  private lastActivityMs;
19
22
  private keepaliveUntilMs;
20
23
  private checkTimer;
21
24
  private unsubscribeShown;
25
+ private unsubscribeHidden;
22
26
  private readonly pauseHandlers;
23
27
  private readonly resumeHandlers;
24
- onPause(handler: Handler<void>): () => void;
28
+ private readonly pausedExceptionHandlers;
29
+ onPause(handler: Handler<SessionPauseReason>): () => void;
30
+ onExceptionWhilePaused(handler: Handler<SessionPauseReason>): () => void;
31
+ /** Reports a recorded exception; fires `exceptionWhilePaused` when the session is paused, at most once per five minutes per pause. */
32
+ noteException(): void;
25
33
  onResume(handler: Handler<SessionResumeReason>): () => void;
26
34
  start(session: ActivitySession): void;
27
35
  stop(): void;
28
36
  private idleMs;
29
37
  private isOverMaxAge;
38
+ private pause;
39
+ private readonly onHidden;
30
40
  private readonly poll;
31
41
  private readonly onInput;
32
42
  private resume;
33
43
  private touch;
34
44
  }
35
45
  //#endregion
36
- export { IDLE_AFTER_MS as a, SessionResumeReason as c, EXPIRE_AFTER_MS as i, ActivitySession as n, KEEPALIVE_THROTTLE_MS as o, CHECK_INTERVAL_MS as r, MAX_AGE_MS as s, ActivityMonitor as t };
46
+ export { IDLE_AFTER_MS as a, SessionResumeReason as c, EXPIRE_AFTER_MS as i, ActivitySession as n, MAX_AGE_MS as o, CHECK_INTERVAL_MS as r, SessionPauseReason as s, ActivityMonitor as t };
@@ -0,0 +1 @@
1
+ import{t as createLogger}from"./log-D6Ht--tv.mjs";import{n as onPageHidden,r as onPageShown}from"./page-lifecycle-rJEJNdKj.mjs";const log=createLogger(`activity`),IDLE_AFTER_MS=3e5,EXPIRE_AFTER_MS=9e5,MAX_AGE_MS=864e5,CHECK_INTERVAL_MS=3e4,ACTIVITY_EVENTS=[`pointerdown`,`keydown`,`scroll`,`touchstart`,`mousemove`];function monotonicNow(){return typeof performance>`u`?Date.now():performance.now()}function subscribe(set,handler){return set.add(handler),(()=>{set.delete(handler)})}function fire(handlers,arg){for(let handler of handlers)try{handler(arg)}catch(error){log.warn(`activity handler threw: %s`,error instanceof Error?error.constructor.name:`UnknownError`)}}var ActivityMonitor=class{session=null;pausedFor=null;lastPausedExceptionMs=null;lastActivityMs=0;keepaliveUntilMs=0;checkTimer=null;unsubscribeShown=null;unsubscribeHidden=null;pauseHandlers=new Set;resumeHandlers=new Set;pausedExceptionHandlers=new Set;onPause(handler){return subscribe(this.pauseHandlers,handler)}onExceptionWhilePaused(handler){return subscribe(this.pausedExceptionHandlers,handler)}noteException(){if(this.pausedFor===null)return;let now=monotonicNow();this.lastPausedExceptionMs!==null&&now-this.lastPausedExceptionMs<3e5||(this.lastPausedExceptionMs=now,fire(this.pausedExceptionHandlers,this.pausedFor))}onResume(handler){return subscribe(this.resumeHandlers,handler)}start(session){if(this.checkTimer===null&&typeof globalThis.addEventListener==`function`){this.session=session,this.pausedFor=null,this.lastPausedExceptionMs=null,this.lastActivityMs=monotonicNow(),this.keepaliveUntilMs=0;for(let type of ACTIVITY_EVENTS)globalThis.addEventListener(type,this.onInput,{capture:!0,passive:!0});this.unsubscribeShown=onPageShown(this.onInput),this.unsubscribeHidden=onPageHidden(this.onHidden),this.checkTimer=setInterval(this.poll,CHECK_INTERVAL_MS)}}stop(){if(this.checkTimer!==null){clearInterval(this.checkTimer),this.checkTimer=null;for(let type of ACTIVITY_EVENTS)globalThis.removeEventListener(type,this.onInput,!0);this.unsubscribeShown?.(),this.unsubscribeHidden?.(),this.unsubscribeShown=null,this.unsubscribeHidden=null,this.session=null,this.pausedFor=null,this.lastPausedExceptionMs=null,this.lastActivityMs=0,this.keepaliveUntilMs=0}}idleMs(){return monotonicNow()-this.lastActivityMs}isOverMaxAge(){let startedAt=this.session?.startedAt()??0;return startedAt>0&&Date.now()-startedAt>=864e5}pause(reason){this.pausedFor===null&&(this.pausedFor=reason,this.lastPausedExceptionMs=null,log.debug(`session paused: %s`,reason),fire(this.pauseHandlers,reason))}onHidden=()=>{this.pause(`hidden`)};poll=()=>{this.pausedFor===null&&(this.isOverMaxAge()||this.idleMs()>=3e5)&&this.pause(`idle`)};onInput=()=>{let now=monotonicNow();if(this.isOverMaxAge()||now-this.lastActivityMs>=9e5){this.resume(now,`rotated`);return}if(this.pausedFor!==null){this.resume(now,`idle`);return}now<this.keepaliveUntilMs||(this.touch(now),this.session?.markActivity())};resume(now,reason){reason===`rotated`&&(log.debug(`resume after expiry → new session`),this.session?.reset()),this.pausedFor=null,this.lastPausedExceptionMs=null,this.touch(now),this.session?.markActivity(),fire(this.resumeHandlers,reason)}touch(now){this.lastActivityMs=now,this.keepaliveUntilMs=now+1e3}};export{MAX_AGE_MS as a,IDLE_AFTER_MS as i,CHECK_INTERVAL_MS as n,EXPIRE_AFTER_MS as r,ActivityMonitor as t};
@@ -1,4 +1,4 @@
1
- import { c as SessionResumeReason } from "./activity-Duhfgvxt.mjs";
1
+ import { c as SessionResumeReason, s as SessionPauseReason } from "./activity-CShcwAW_.mjs";
2
2
  import { t as DeviceManager } from "./device-vFtWy12y.mjs";
3
3
  import { t as GeoDetector } from "./geo-PDfIZY4L.mjs";
4
4
  import { InterfereClient } from "@interfere/javascript";
@@ -30,7 +30,9 @@ declare class SessionTracker {
30
30
  startDeviceIdentity(): void;
31
31
  discardDeviceIdentity(): void;
32
32
  private backfillIdentity;
33
- onSessionPause(handler: () => void): () => void;
33
+ onSessionPause(handler: (reason: SessionPauseReason) => void): () => void;
34
+ onSessionExceptionWhilePaused(handler: (reason: SessionPauseReason) => void): () => void;
35
+ noteException(): void;
34
36
  onSessionResume(handler: (reason: SessionResumeReason) => void): () => void;
35
37
  sessionId(): (string & import("zod").$brand<"SessionId">) | null;
36
38
  windowId(): string | null;
@@ -0,0 +1 @@
1
+ import{t as createLogger}from"./log-D6Ht--tv.mjs";import{t as ActivityMonitor}from"./activity-oYlZ5aa1.mjs";import{n as fetchIngest}from"./ingest-backoff-B1OeEV3h.mjs";import{t as DeviceManager}from"./device-DRK7hhLi.mjs";import{t as GeoDetector}from"./geo-D2wa9bGs.mjs";import{t as SessionManager}from"./session-C30CtCVv.mjs";import{t as SessionRetry}from"./session-retry-TrzzihIM.mjs";import{omitUndefined}from"@interfere/helpers/omit-undefined";import{InterfereClient,InterfereError}from"@interfere/javascript";const log=createLogger(`tracking`);function syncKey(sessionId,deviceId,fpHash){return`${sessionId}|${deviceId??``}|${fpHash??``}`}var SessionTracker=class{client;device;geo;mgr=null;activity=new ActivityMonitor;currentIdentity=null;identifiedSessionId=null;lastSyncedKey=null;inflightSyncKey=null;syncAttemptMs=0;generation=0;syncRetry=new SessionRetry;syncRetryKey=null;identityStarted=!1;constructor(opts){this.client=new InterfereClient({...opts.target,maxRetries:0,timeoutInSeconds:10,fetch:Object.assign(async(input,init)=>fetchIngest(async()=>(opts.fetcher??globalThis.fetch)(input,{...init,credentials:`omit`,keepalive:!0})),opts.fetcher??globalThis.fetch)}),this.device=opts.device??new DeviceManager,this.geo=opts.geo??new GeoDetector}start(){this.mgr=new SessionManager(id=>{this.onRotate(id)}),this.activity.start({markActivity:()=>{this.markActivity()},reset:()=>{this.rotateSession()},startedAt:()=>this.getSessionStartedAt()})}startDeviceIdentity(){this.identityStarted||(this.invalidateSync(),this.identityStarted=!0,this.device.init(),this.geo.detect(),this.backfillIdentity())}discardDeviceIdentity(){this.invalidateSync(),this.identityStarted=!1,this.device.clear(),this.geo.clear()}async backfillIdentity(){let gen=this.generation;if(await Promise.resolve(),gen!==this.generation||!this.identityStarted)return;let initialSessionId=this.mgr?.getSessionId()??null,initialFpHash=this.device.getFpHash();initialSessionId&&await this.syncSession(initialSessionId,this.device.getDeviceId(),initialFpHash);let fpHash=await this.device.whenFingerprintReady(),sessionId=this.mgr?.getSessionId()??null;gen===this.generation&&this.identityStarted&&sessionId&&fpHash!==initialFpHash&&this.syncSession(sessionId,this.device.getDeviceId(),fpHash)}onSessionPause(handler){return this.activity.onPause(handler)}onSessionExceptionWhilePaused(handler){return this.activity.onExceptionWhilePaused(handler)}noteException(){this.activity.noteException()}onSessionResume(handler){return this.activity.onResume(handler)}sessionId(){let id=this.mgr?.getSessionId()??null;return id&&this.ensureSynced(id),id}windowId(){return this.mgr?.getWindowId()??null}markActivity(){this.mgr?.markActivity()}getSessionStartedAt(){return this.mgr?.getSessionStartedAt()??0}getDeviceId(){return this.device.getDeviceId()}getFpHash(){return this.device.getFpHash()}getIdentity(){return this.currentIdentity}async identify(params){if(!this.mgr)return;let sessionId=this.mgr.getSessionId();if(this.identifiedSessionId===sessionId){log.debug(`skipped, already identified for session %s`,sessionId);return}this.currentIdentity=params,this.identifiedSessionId=sessionId;let gen=this.generation,[fpHash,country]=await Promise.all([this.device.whenFingerprintReady(),this.geo.detect()]),deviceId=this.device.getDeviceId();if(gen!==this.generation){this.identifiedSessionId=null;return}log.info(`POST session %s → identify`,sessionId),this.postIdentify(sessionId,omitUndefined({deviceId,fpHash,sessionId,...params,country:country||void 0}))}async postIdentify(sessionId,body){try{await this.client.sessions.identifySession(body)}catch{this.identifiedSessionId=null,log.warn(`identify failed for session %s`,sessionId)}}clearIdentity(){this.currentIdentity=null,this.identifiedSessionId=null}reset(){this.invalidateSync(),this.clearIdentity(),this.identityStarted&&this.device.reset(),this.mgr?.reset()}rotateSession(){this.mgr?.reset()}dispose(){this.activity.stop(),this.invalidateSync(),this.clearIdentity(),this.mgr=null}invalidateSync(){this.generation+=1,this.syncRetry.reset(),this.syncRetryKey=null,this.lastSyncedKey=null,this.inflightSyncKey=null,this.syncAttemptMs=0}currentSyncKey(){let sessionId=this.mgr?.sessionId;return sessionId?syncKey(sessionId,this.device.getDeviceId(),this.device.getFpHash()):null}ensureSynced(sessionId){let deviceId=this.device.getDeviceId(),fpHash=this.device.getFpHash(),key=syncKey(sessionId,deviceId,fpHash);this.lastSyncedKey!==key&&this.inflightSyncKey!==key&&(Date.now()-this.syncAttemptMs<5e3||this.syncSession(sessionId,deviceId,fpHash))}async syncSession(sessionId,deviceId,fpHash){let key=syncKey(sessionId,deviceId,fpHash);if(this.lastSyncedKey===key||this.inflightSyncKey===key)return;this.syncRetryKey!==key&&(this.syncRetry.reset(),this.syncRetryKey=key),this.syncRetry.cancel();let{generation}=this;this.inflightSyncKey=key,this.syncAttemptMs=Date.now();try{await this.client.sessions.createSession({sessionId,deviceId,fpHash}),generation===this.generation&&key===this.currentSyncKey()&&(this.lastSyncedKey=key,this.syncRetry.reset())}catch(error){log.warn(`session sync failed`),error instanceof InterfereError&&generation===this.generation&&key===this.currentSyncKey()&&this.syncRetry.schedule(error,()=>{let current=this.mgr?.sessionId;generation===this.generation&&current&&this.ensureSynced(current)})}finally{generation===this.generation&&this.inflightSyncKey===key&&(this.inflightSyncKey=null)}}async onRotate(sessionId){this.syncAttemptMs=Date.now();let gen=this.generation;try{await Promise.resolve();let fpHash=this.device.getFpHash(),deviceId=this.device.getDeviceId();if(gen!==this.generation)return;log.debug(`POST session %s (device=%s fp=%s)`,sessionId,deviceId??`pending`,fpHash??`none`),this.syncSession(sessionId,deviceId,fpHash)}catch{}}};export{SessionTracker as t};
@@ -0,0 +1 @@
1
+ const TEXT_ENTRY_INPUT_TYPES=new Set([`date`,`datetime-local`,`email`,`month`,`number`,`password`,`search`,`tel`,`text`,`time`,`url`,`week`]);function isTextEntry(element){return element instanceof HTMLTextAreaElement?!0:element instanceof HTMLInputElement?TEXT_ENTRY_INPUT_TYPES.has(element.type):element instanceof HTMLElement&&element.isContentEditable}function createClickSpanGate(){let previous;return element=>{let at=performance.now(),last=previous;if(previous={element,at},isTextEntry(element))return!1;if(last===void 0)return!0;let elapsed=at-last.at;return last.element===element&&elapsed<1e3?!1:!(last.element instanceof HTMLLabelElement&&last.element.control===element&&elapsed<100)}}export{createClickSpanGate as t};
@@ -0,0 +1 @@
1
+ import{t as createLogger}from"./log-D6Ht--tv.mjs";import{t as reserveKeepaliveBody}from"./keepalive-budget-DeafGnVZ.mjs";import{t as gzipForUnload}from"./unload-gzip-WX9FyWPs.mjs";import{t as uploadReplayChunk}from"./upload-D55WVf_o.mjs";import{omitUndefined}from"@interfere/helpers/omit-undefined";const log=createLogger(`replay`),REPLAY_TRACER_NAME=`@interfere/react/replay`,textEncoder=new TextEncoder,FATAL_STATUSES=new Set([401,403,413]);function classifyRejection(status){return status===409?`skipped`:FATAL_STATUSES.has(status)?`fatal`:`retryable`}async function prepareBody(compressor,rawBytes){if(!compressor.gzip)return{body:rawBytes,encoding:null,release:null};try{return{body:await compressor.gzip(rawBytes),encoding:`gzip`,release:null}}catch(error){return log.warn(`gzip failed for chunk; sending uncompressed: %o`,error),{body:rawBytes,encoding:null,release:null}}}function prepareUnloadBody(rawBytes){let rawRelease=reserveKeepaliveBody(rawBytes.byteLength);if(rawRelease)return{body:rawBytes,encoding:null,release:rawRelease};let compressed=gzipForUnload(rawBytes);return compressed?{body:compressed,encoding:`gzip`,release:reserveKeepaliveBody(compressed.byteLength)}:{body:rawBytes,encoding:null,release:null}}function encodeReplayMeta(chunk,payload){return btoa(JSON.stringify({activityCount:payload.activityCount,eventCount:payload.eventCount,firstTs:payload.firstTs,hasFullSnapshot:payload.hasFullSnapshot,lastTs:payload.lastTs,segmentId:chunk.segmentId,windowId:chunk.windowId}))}async function deliverChunk({ctx,chunk,target,compressor,payload,trigger,unload}){let sessionId=ctx.getSessionId();if(!sessionId)return`ok`;let rawBytes=textEncoder.encode(payload.bodyJson),uncompressedBytes=rawBytes.byteLength,prepared=unload?prepareUnloadBody(rawBytes):await prepareBody(compressor,rawBytes),headers={"x-replay-meta":encodeReplayMeta(chunk,payload)};prepared.encoding===`gzip`&&(headers[`content-encoding`]=`gzip`);let keepalive=prepared.release!==null,response;try{let upload=await uploadReplayChunk(target,sessionId,prepared.body,headers,{keepalive});if(!upload.ok)return await upload.body?.cancel(),classifyRejection(upload.status);response=await upload.json()}catch(error){return log.warn(`replay chunk upload failed: %o`,error),`retryable`}finally{prepared.release?.()}let objectKey=typeof response==`object`&&response&&`objectKey`in response&&typeof response.objectKey==`string`?response.objectKey:null;if(trigger===void 0&&!unload)return`ok`;let attributes=omitUndefined({"replay.chunk.size_bytes":uncompressedBytes,"replay.chunk.event_count":payload.eventCount,"replay.chunk.uri":objectKey||void 0,"replay.chunk.compressed_bytes":prepared.encoding===`gzip`?prepared.body.byteLength:void 0,"replay.chunk.first_event_ts":payload.firstTs??void 0,"replay.chunk.last_event_ts":payload.lastTs??void 0,"replay.chunk.trigger":trigger,"replay.chunk.unload":unload||void 0,"replay.chunk.keepalive":unload?keepalive:void 0});return ctx.getTracer(REPLAY_TRACER_NAME).startSpan(`replay.chunk`,{attributes}).end(),`ok`}export{deliverChunk as n,REPLAY_TRACER_NAME as t};
@@ -1,4 +1,4 @@
1
- import { a as InterfereContextValue, i as InterfereContext } from "./provider-DIp7vkKd.mjs";
1
+ import { a as InterfereContextValue, i as InterfereContext } from "./provider-D4QjZp3L.mjs";
2
2
  import { Component, ContextType, ErrorInfo, ReactNode } from "react";
3
3
  //#region src/error-boundary.d.ts
4
4
  export interface ErrorBoundaryProps {
@@ -1 +1 @@
1
- import{t as hasServerDigest}from"./server-digest-CzGdvjW1.mjs";import{t as hasEventListenerPair}from"./event-capabilities-Dd0Hoaq2.mjs";import{n as onConsoleCall}from"./console-patch-WNKoLE7U.mjs";import{t as THIRD_PARTY_IGNORE}from"./third-party-hosts-BoJNL3xG.mjs";import{MECHANISM_TYPE,isNonErrorException,toException}from"@interfere/types/sdk/errors";import{omitUndefined}from"@interfere/helpers/omit-undefined";function capture(ctx,opts){ctx.recordException(opts.error,omitUndefined({mechanism:opts.mechanism,fallbackFrames:opts.fallbackFrame&&!isNonErrorException(opts.error)?[opts.fallbackFrame]:void 0}))}function findErrorArg(args){return args.find(arg=>arg instanceof Error)??null}function resourceError(target){return target instanceof HTMLImageElement||target instanceof HTMLScriptElement?target.src?{tag:target.localName,url:target.src}:null:target instanceof HTMLLinkElement&&target.href?{tag:target.localName,url:target.href}:null}function isIgnoredResourceUrl(url){return THIRD_PARTY_IGNORE.some(pattern=>pattern.test(url))}function createResourceGate(){let seen=new Set,windowStart=0,windowCount=0;return(url=>{if(seen.has(url))return!1;let now=Date.now();return now-windowStart>6e4&&(windowStart=now,windowCount=0),windowCount>=20?!1:(seen.size>=100&&seen.clear(),seen.add(url),windowCount+=1,!0)})}function createRepeatGate(){let counts=new Map,windowStart=0;return(key=>{let now=Date.now();now-windowStart>6e4&&(windowStart=now,counts.clear());let count=counts.get(key)??0;return count>=5?!1:(counts.size>=100&&counts.clear(),counts.set(key,count+1),!0)})}const errorsPlugin={name:`errors`,setup(ctx){let originalOnError=globalThis.onerror,originalStackTraceLimit=Error.stackTraceLimit;Error.stackTraceLimit<50&&(Error.stackTraceLimit=50);let repeatGate=createRepeatGate();globalThis.onerror=(msg,source,line,col,error)=>{if(error instanceof Error&&!hasServerDigest(error)&&repeatGate(`${typeof msg==`string`?msg:msg.type}|${String(source)}|${String(line)}|${String(col)}`)){let fallbackFrame=typeof source==`string`?omitUndefined({file:source,id:`fallback-0`,line:typeof line==`number`?line:void 0,column:typeof col==`number`?col:void 0}):null;capture(ctx,omitUndefined({error,mechanism:{handled:!1,type:MECHANISM_TYPE.browser.onerror},fallbackFrame:fallbackFrame??void 0}))}return typeof originalOnError==`function`&&originalOnError.call(globalThis,msg,source,line,col,error)};let onUnhandledRejection=event=>{hasServerDigest(event.reason)||capture(ctx,{error:toException(event.reason),mechanism:omitUndefined({handled:!1,type:MECHANISM_TYPE.browser.onunhandledrejection,synthetic:event.reason instanceof Error?void 0:!0})})},cspReportsByDisposition={enforce:new Set,report:new Set},onSecurityPolicyViolation=event=>{let seenCspReports=cspReportsByDisposition[event.disposition],key=`${event.violatedDirective}|${event.blockedURI}`;seenCspReports.has(key)||seenCspReports.size>=5||(seenCspReports.add(key),capture(ctx,{error:{kind:`non-error`,serialized:{blockedURI:event.blockedURI,columnNumber:event.columnNumber,disposition:event.disposition,lineNumber:event.lineNumber,sourceFile:event.sourceFile,violatedDirective:event.violatedDirective},type:`SecurityPolicyViolation`,value:event.disposition===`report`?`CSP ${event.violatedDirective} reported ${event.blockedURI||`inline`} (report-only)`:`CSP ${event.violatedDirective} blocked ${event.blockedURI||`inline`}`},mechanism:{handled:event.disposition===`report`,type:MECHANISM_TYPE.browser.securityPolicyViolation}}))},resourceGate=createResourceGate(),onResourceError=event=>{let resource=resourceError(event.target);resource&&!isIgnoredResourceUrl(resource.url)&&resourceGate(resource.url)&&capture(ctx,{error:{kind:`non-error`,serialized:{url:resource.url},type:`ResourceLoadError`,value:`Failed to load ${resource.tag}: ${resource.url}`},mechanism:{handled:!1,type:MECHANISM_TYPE.browser.resourceError}})},supportsEventTarget=hasEventListenerPair(globalThis.addEventListener,globalThis.removeEventListener);supportsEventTarget&&(globalThis.addEventListener(`unhandledrejection`,onUnhandledRejection),globalThis.addEventListener(`securitypolicyviolation`,onSecurityPolicyViolation),globalThis.addEventListener(`error`,onResourceError,!0));let unsubscribeConsole=onConsoleCall((level,args)=>{if(level!==`error`)return;let error=findErrorArg(args);error&&!hasServerDigest(error)&&capture(ctx,{error,mechanism:{handled:!0,type:MECHANISM_TYPE.browser.consoleError}})});return()=>{Error.stackTraceLimit=originalStackTraceLimit,globalThis.onerror=originalOnError,supportsEventTarget&&(globalThis.removeEventListener(`unhandledrejection`,onUnhandledRejection),globalThis.removeEventListener(`securitypolicyviolation`,onSecurityPolicyViolation),globalThis.removeEventListener(`error`,onResourceError,!0)),unsubscribeConsole()}}};export{errorsPlugin as t};
1
+ import{t as hasServerDigest}from"./server-digest-CzGdvjW1.mjs";import{t as hasEventListenerPair}from"./event-capabilities-Dd0Hoaq2.mjs";import{n as onConsoleCall}from"./console-patch-WNKoLE7U.mjs";import{t as THIRD_PARTY_IGNORE}from"./third-party-hosts-CYOuLL_s.mjs";import{MECHANISM_TYPE,isNonErrorException,toException}from"@interfere/types/sdk/errors";import{omitUndefined}from"@interfere/helpers/omit-undefined";function capture(ctx,opts){ctx.recordException(opts.error,omitUndefined({mechanism:opts.mechanism,fallbackFrames:opts.fallbackFrame&&!isNonErrorException(opts.error)?[opts.fallbackFrame]:void 0}))}function findErrorArg(args){return args.find(arg=>arg instanceof Error)??null}function resourceError(target){return target instanceof HTMLImageElement||target instanceof HTMLScriptElement?target.src?{tag:target.localName,url:target.src}:null:target instanceof HTMLLinkElement&&target.href?{tag:target.localName,url:target.href}:null}function isIgnoredResourceUrl(url){return THIRD_PARTY_IGNORE.some(pattern=>pattern.test(url))}function createResourceGate(){let seen=new Set,windowStart=0,windowCount=0;return(url=>{if(seen.has(url))return!1;let now=Date.now();return now-windowStart>6e4&&(windowStart=now,windowCount=0),windowCount>=20?!1:(seen.size>=100&&seen.clear(),seen.add(url),windowCount+=1,!0)})}function createRepeatGate(){let counts=new Map,windowStart=0;return(key=>{let now=Date.now();now-windowStart>6e4&&(windowStart=now,counts.clear());let count=counts.get(key)??0;return count>=5?!1:(counts.size>=100&&counts.clear(),counts.set(key,count+1),!0)})}const errorsPlugin={name:`errors`,setup(ctx){let originalOnError=globalThis.onerror,originalStackTraceLimit=Error.stackTraceLimit;Error.stackTraceLimit<50&&(Error.stackTraceLimit=50);let repeatGate=createRepeatGate();globalThis.onerror=(msg,source,line,col,error)=>{if(error instanceof Error&&!hasServerDigest(error)&&repeatGate(`${typeof msg==`string`?msg:msg.type}|${String(source)}|${String(line)}|${String(col)}`)){let fallbackFrame=typeof source==`string`?omitUndefined({file:source,id:`fallback-0`,line:typeof line==`number`?line:void 0,column:typeof col==`number`?col:void 0}):null;capture(ctx,omitUndefined({error,mechanism:{handled:!1,type:MECHANISM_TYPE.browser.onerror},fallbackFrame:fallbackFrame??void 0}))}return typeof originalOnError==`function`&&originalOnError.call(globalThis,msg,source,line,col,error)};let onUnhandledRejection=event=>{hasServerDigest(event.reason)||capture(ctx,{error:toException(event.reason),mechanism:omitUndefined({handled:!1,type:MECHANISM_TYPE.browser.onunhandledrejection,synthetic:event.reason instanceof Error?void 0:!0})})},cspReportsByDisposition={enforce:new Set,report:new Set},onSecurityPolicyViolation=event=>{let seenCspReports=cspReportsByDisposition[event.disposition],key=`${event.violatedDirective}|${event.blockedURI}`;seenCspReports.has(key)||seenCspReports.size>=5||(seenCspReports.add(key),capture(ctx,{error:{kind:`non-error`,serialized:{blockedURI:event.blockedURI,columnNumber:event.columnNumber,disposition:event.disposition,lineNumber:event.lineNumber,sourceFile:event.sourceFile,violatedDirective:event.violatedDirective},type:`SecurityPolicyViolation`,value:event.disposition===`report`?`CSP ${event.violatedDirective} reported ${event.blockedURI||`inline`} (report-only)`:`CSP ${event.violatedDirective} blocked ${event.blockedURI||`inline`}`},mechanism:{handled:event.disposition===`report`,type:MECHANISM_TYPE.browser.securityPolicyViolation}}))},resourceGate=createResourceGate(),onResourceError=event=>{let resource=resourceError(event.target);resource&&!isIgnoredResourceUrl(resource.url)&&resourceGate(resource.url)&&capture(ctx,{error:{kind:`non-error`,serialized:{url:resource.url},type:`ResourceLoadError`,value:`Failed to load ${resource.tag}: ${resource.url}`},mechanism:{handled:!1,type:MECHANISM_TYPE.browser.resourceError}})},supportsEventTarget=hasEventListenerPair(globalThis.addEventListener,globalThis.removeEventListener);supportsEventTarget&&(globalThis.addEventListener(`unhandledrejection`,onUnhandledRejection),globalThis.addEventListener(`securitypolicyviolation`,onSecurityPolicyViolation),globalThis.addEventListener(`error`,onResourceError,!0));let unsubscribeConsole=onConsoleCall((level,args)=>{if(level!==`error`)return;let error=findErrorArg(args);error&&error.name!==`AbortError`&&!hasServerDigest(error)&&capture(ctx,{error,mechanism:{handled:!0,type:MECHANISM_TYPE.browser.consoleError}})});return()=>{Error.stackTraceLimit=originalStackTraceLimit,globalThis.onerror=originalOnError,supportsEventTarget&&(globalThis.removeEventListener(`unhandledrejection`,onUnhandledRejection),globalThis.removeEventListener(`securitypolicyviolation`,onSecurityPolicyViolation),globalThis.removeEventListener(`error`,onResourceError,!0)),unsubscribeConsole()}}};export{errorsPlugin as t};
@@ -0,0 +1 @@
1
+ import{hrTimeToMilliseconds}from"@opentelemetry/core";function shouldExportSpan(span){return!(span.instrumentationScope.name===`@opentelemetry/instrumentation-long-task`&&hrTimeToMilliseconds(span.duration)<500)}function carriesException(span){return span.events.some(event=>event.name===`exception`)}function createExportFilterProcessor(next){let flushScheduled=!1,flushSoon=()=>{flushScheduled||(flushScheduled=!0,queueMicrotask(()=>{flushScheduled=!1,next.forceFlush().catch(()=>{})}))};return{onStart:(span,parentContext)=>{next.onStart(span,parentContext)},onEnd:span=>{shouldExportSpan(span)&&(next.onEnd(span),carriesException(span)&&flushSoon())},forceFlush:async()=>next.forceFlush(),shutdown:async()=>next.shutdown()}}export{shouldExportSpan as n,createExportFilterProcessor as t};
@@ -0,0 +1 @@
1
+ import{t as isPageHidden}from"./page-lifecycle-rJEJNdKj.mjs";import{n as fetchIngest}from"./ingest-backoff-B1OeEV3h.mjs";import{n as stampSentAt}from"./sent-at-CEM8UV3W.mjs";import{t as reserveKeepaliveBody}from"./keepalive-budget-DeafGnVZ.mjs";import{t as PRODUCER_VERSION}from"./version-DusHm2Q4.mjs";import{t as IngestLogExporter}from"./exporter-logs-DS2AXWnV.mjs";import{t as IngestMetricExporter}from"./exporter-metrics-DZYqUo6_.mjs";import{toError}from"@interfere/types/sdk/errors";import{InterfereClient,InterfereError}from"@interfere/javascript";import{TELEMETRY_EXPORT_TIMEOUT_MS,retryTelemetry}from"@interfere/helpers/retry-telemetry";import{ExportResultCode}from"@opentelemetry/core";import{JsonTraceSerializer}from"@opentelemetry/otlp-transformer";import{z}from"zod";const INGEST_IGNORE_RE=/\/drain\/v1\/(?:traces|logs|metrics)(?:\?|$)/u,AUTH_INVALID_HALT_COOLDOWN_MS=3e5,HALT_MESSAGES={release_not_found:`ingest halted: the ingest endpoint does not recognize this build's release`,public_key_rejected:`ingest paused: the ingest endpoint rejected this page's public key`};let haltReason=null,authHaltExpiresAt=0,consecutiveAuthRejections=0;function resetIngestHalt(){haltReason=null,authHaltExpiresAt=0,consecutiveAuthRejections=0}function currentHaltReason(){return haltReason===`public_key_rejected`&&Date.now()>=authHaltExpiresAt&&(haltReason=null,consecutiveAuthRejections=2),haltReason}function isIngestHalted(){return currentHaltReason()!==null}const textEncoder=new TextEncoder;function detectUnacceptableExport(error){if(currentHaltReason()!==null||error.statusCode!==422&&error.statusCode!==401)return;let body=error.body;if(typeof body==`object`&&body&&`code`in body){if(error.statusCode===422&&body.code===`RELEASE_NOT_FOUND`){haltReason=`release_not_found`,console.warn(`[interfere] the ingest endpoint does not recognize this build's release. Telemetry export is disabled for this page load. Check that source-map upload and finalization succeeded and that build and runtime use the same surface key.`);return}if(error.statusCode===401&&body.code===`AUTH_PK_INVALID`){if(consecutiveAuthRejections+=1,consecutiveAuthRejections<3)return;haltReason=`public_key_rejected`,authHaltExpiresAt=Date.now()+AUTH_INVALID_HALT_COOLDOWN_MS,console.warn(`[interfere] the ingest endpoint rejected this page's public key ${consecutiveAuthRejections} times in a row — telemetry export is paused for ${AUTH_INVALID_HALT_COOLDOWN_MS/6e4} minutes, then retried once. Check that INTERFERE_PUBLIC_KEY matches an active surface; a deleted surface's key stays rejected until the page is rebuilt with the new key.`)}}}function makeSender(input,signal){let client=new InterfereClient({...input.clientOptions,maxRetries:0,timeoutInSeconds:TELEMETRY_EXPORT_TIMEOUT_MS/1e3,fetch:Object.assign(async(url,init)=>fetchIngest(async()=>{let body=init?.body,bytes=typeof body==`string`?textEncoder.encode(body).byteLength:0,release=reserveKeepaliveBody(bytes);try{return await retryTelemetry(async abortSignal=>globalThis.fetch(url,{...init,headers:stampSentAt(new Headers(init?.headers)),credentials:`omit`,keepalive:release!==null,signal:abortSignal}),init?.signal)}finally{release?.()}}),globalThis.fetch)});return((payload,resultCallback)=>{if(!payload||payload.byteLength===0){resultCallback({code:ExportResultCode.SUCCESS});return}let reason=currentHaltReason();if(reason!==null){resultCallback({code:ExportResultCode.FAILED,error:Error(HALT_MESSAGES[reason])});return}(async()=>{try{let body=z.record(z.string(),z.unknown()).parse(JSON.parse(new TextDecoder().decode(payload)));await client.drain.otlpExport({signal,body},{headers:{"x-interfere-producer-version":PRODUCER_VERSION}}),consecutiveAuthRejections=0,resultCallback({code:ExportResultCode.SUCCESS})}catch(error){error instanceof InterfereError&&detectUnacceptableExport(error),resultCallback({code:ExportResultCode.FAILED,error:toError(error)})}})()})}function serializedBytes(spans){return JsonTraceSerializer.serializeRequest(spans)?.byteLength??0}function splitForKeepalive(spans){let chunks=[],pending=[spans];for(let next=pending.pop();next;next=pending.pop()){if(next.length<=1||serializedBytes(next)<=28e3){chunks.push(next);continue}let middle=Math.ceil(next.length/2);pending.push(next.slice(middle),next.slice(0,middle))}return chunks}var IngestTraceExporter=class{send;constructor(send){this.send=send}export(spans,resultCallback){if(spans.length===0){resultCallback({code:ExportResultCode.SUCCESS});return}let chunks=isPageHidden()?splitForKeepalive(spans):[spans];if(chunks.length===1){this.send(JsonTraceSerializer.serializeRequest(spans),resultCallback);return}let pending=chunks.length,failure,settle=result=>{result.code!==ExportResultCode.SUCCESS&&(failure??=result),--pending,pending===0&&resultCallback(failure??{code:ExportResultCode.SUCCESS})};for(let chunk of chunks)this.send(JsonTraceSerializer.serializeRequest(chunk),settle)}async shutdown(){return Promise.resolve()}async forceFlush(){return Promise.resolve()}};function createTraceExporter(input){return new IngestTraceExporter(makeSender(input,`traces`))}function createMetricExporter(input,gatedResourceAttributes){return new IngestMetricExporter(makeSender(input,`metrics`),gatedResourceAttributes)}function createLogExporter(input){return new IngestLogExporter(makeSender(input,`logs`))}export{isIngestHalted as a,createTraceExporter as i,createLogExporter as n,resetIngestHalt as o,createMetricExporter as r,INGEST_IGNORE_RE as t};
@@ -0,0 +1,4 @@
1
+ import "./instrumentations-S-BCpguB.mjs";
2
+ import "./navigation-CkiV6lJY.mjs";
3
+ import "./provider-cUByhzgv.mjs";
4
+ import "./web-vitals-x8y70B5x.mjs";
@@ -0,0 +1 @@
1
+ let consecutiveFailures=0,blockedUntil=0;function resetIngestBackoff(){consecutiveFailures=0,blockedUntil=0}var IngestBackoffError=class extends Error{constructor(){super(`Interfere ingest is backing off after a network failure; request not sent`),this.name=`IngestBackoffError`}};function noteNetworkFailure(){Date.now()<blockedUntil||(consecutiveFailures+=1,blockedUntil=Date.now()+Math.min(5e3*2**(consecutiveFailures-1),6e5))}async function fetchIngest(send){if(Date.now()<blockedUntil)throw new IngestBackoffError;let response;try{response=await send()}catch(error){throw error instanceof TypeError&&noteNetworkFailure(),error}return consecutiveFailures=0,blockedUntil=0,response}export{fetchIngest as n,resetIngestBackoff as r,IngestBackoffError as t};
@@ -0,0 +1 @@
1
+ import{t as DEFAULT_PRIVACY_POLICY}from"./privacy-CRuL0X8r.mjs";import{t as THIRD_PARTY_IGNORE}from"./third-party-hosts-CYOuLL_s.mjs";import{n as describeActionable,r as isActionable}from"./actionable-DOmVf_ib.mjs";import{i as stampUrlAttrs,n as ATTR_URL_FULL,r as ATTR_URL_PATH}from"./url-attrs-BdcyE2n6.mjs";import{t as stampHttpSpanRoute}from"./http-span-route-t2gig-KI.mjs";import{t as createClickSpanGate}from"./click-span-gate-6dNMhjc7.mjs";import{n as settleFetchFailure,r as settleXhrFailure,t as createPageExitWatch}from"./network-failure-GVLV_sUF.mjs";import{MECHANISM_TYPE}from"@interfere/types/sdk/errors";import{omitUndefined}from"@interfere/helpers/omit-undefined";import{registerInstrumentations}from"@opentelemetry/instrumentation";import{BrowserNavigationInstrumentation,defaultSanitizeUrl}from"@opentelemetry/instrumentation-browser-navigation";import{DocumentLoadInstrumentation}from"@opentelemetry/instrumentation-document-load";import{FetchInstrumentation}from"@opentelemetry/instrumentation-fetch";import{LongTaskInstrumentation}from"@opentelemetry/instrumentation-long-task";import{UserInteractionInstrumentation}from"@opentelemetry/instrumentation-user-interaction";import{XMLHttpRequestInstrumentation}from"@opentelemetry/instrumentation-xml-http-request";import{getElementXPath}from"@opentelemetry/sdk-trace-web";const DEFAULT_FAILURE_RANGES=[[400,599]];function resolveFailureRanges(opt){if(opt===!1)return null;if(opt===void 0||opt===!0)return DEFAULT_FAILURE_RANGES;let codes=opt.statusCodes;return codes&&codes.length>0?codes:DEFAULT_FAILURE_RANGES}function createFailureGate(){let seen=new Set,windowStart=0,windowCount=0;return(key=>{if(seen.has(key))return!1;let now=Date.now();return now-windowStart>6e4&&(windowStart=now,windowCount=0),windowCount>=20?!1:(seen.size>=100&&seen.clear(),seen.add(key),windowCount+=1,!0)})}function failureKey(method,discriminator,url){let path;try{path=new URL(url).pathname}catch{path=url}return`${method} ${discriminator} ${path}`}function statusMatches(status,ranges){for(let range of ranges)if(typeof range==`number`){if(status===range)return!0}else if(status>=range[0]&&status<=range[1])return!0;return!1}function recordHttpFailure(span,status,method,url,mechanism){span.addEvent(`exception`,{"exception.message":`HTTP ${status} ${method} ${url}`,"exception.type":`HttpResponseError`,"interfere.exception.handled":!1,"interfere.exception.kind":`error`,"interfere.exception.mechanism":mechanism})}function maybeCaptureFetchFailure(span,result,failureRanges,method,url,gate){if(!failureRanges)return;let status=result?.status;typeof status!=`number`||status<=0||!statusMatches(status,failureRanges)||(!gate||gate(failureKey(method,status,url)))&&recordHttpFailure(span,status,method,url,MECHANISM_TYPE.browser.fetchFailedResponse)}function applyFetchSpanAttrs(span,request,result,failureRanges,pageExit,isTrackedUrl,resolveRoute,gate){let url=resolveFetchUrl(span,request,result);if(!url)return;let parsed;try{parsed=new URL(url)}catch{return}span.setAttribute(ATTR_URL_PATH,parsed.pathname);let tracked=isTrackedUrl(url),method=resolveFetchMethod(request);if(tracked){if(stampHttpSpanRoute(span,method,parsed.pathname,resolveRoute),isPrefetchRequest(request))return;result instanceof Response?maybeCaptureFetchFailure(span,result,failureRanges,method,url,gate):failureRanges&&settleFetchFailure(span,request,result,pageExit,method,url,()=>!gate||gate(failureKey(method,`network`,url)))}}function applyXhrSpanAttrs(span,xhr,failureRanges,pageExit,isTrackedUrl,gate,resolveRoute){let url=xhr.responseURL||spanUrlFull(span);if(!(url&&isTrackedUrl(url)))return;let parsed;try{parsed=new URL(url)}catch{return}let method=isReadableSpan(span)?String(span.attributes[`http.request.method`]??span.attributes[`http.method`]??`XHR`):`XHR`;if(span.setAttribute(ATTR_URL_PATH,parsed.pathname),stampHttpSpanRoute(span,method,parsed.pathname,resolveRoute),!failureRanges)return;let{status}=xhr;if(typeof status==`number`){if(status===0){settleXhrFailure(span,pageExit,url,()=>!gate||gate(failureKey(`XHR`,`network`,url)));return}statusMatches(status,failureRanges)&&(!gate||gate(failureKey(`XHR`,status,url)))&&recordHttpFailure(span,status,`XHR`,url,MECHANISM_TYPE.browser.xhrFailedResponse)}}function resolveFetchUrl(span,request,result){return responseUrl(result)??requestUrl(request)??spanUrlFull(span)}function isReadableSpan(span){return`attributes`in span}function spanUrlFull(span){if(!isReadableSpan(span))return null;let url=span.attributes[`url.full`]??span.attributes[`http.url`];return typeof url==`string`?url:null}function responseUrl(result){return result instanceof Response&&result.url?result.url:null}function requestUrl(request){return typeof request==`string`?request:readStringProp(request,`url`)??readStringProp(request,`href`)}function resolveFetchMethod(request){return readStringProp(request,`method`)??`GET`}function readStringProp(value,key){if(!(typeof value==`object`&&value&&key in value))return null;let prop=Reflect.get(value,key);return typeof prop==`string`?prop:null}const testOnlyApplyFetchSpanAttrs=applyFetchSpanAttrs,testOnlyApplyXhrSpanAttrs=applyXhrSpanAttrs,testOnlyResolveFailureRanges=resolveFailureRanges,testOnlyCreateFailureGate=createFailureGate,NEVER_MATCH=/^$/u,ESCAPE_RE=/[.*+?^${}()|[\]\\]/gu;function sameOriginPattern(){if(typeof window>`u`)return NEVER_MATCH;let{protocol,host}=globalThis.location;return RegExp(`^${protocol}//${host.replace(ESCAPE_RE,String.raw`\$&`)}`,`u`)}function stampInteractionAttrs(eventType,element,span,policy){let desc=describeActionable(element,policy);span.setAttribute(`ui.event_type`,eventType),span.setAttribute(`ui.target.tag`,desc.tag),desc.privacy&&(span.setAttribute(`ui.target.privacy`,desc.privacy),span.setAttribute(`target_xpath`,getElementXPath(element,!1))),desc.label&&span.setAttribute(`ui.target.label`,desc.label),desc.id&&span.setAttribute(`ui.target.id`,desc.id),desc.name&&span.setAttribute(`ui.target.name`,desc.name),desc.role&&span.setAttribute(`ui.target.role`,desc.role),desc.ariaLabel&&span.setAttribute(`ui.target.aria_label`,desc.ariaLabel),desc.text&&span.setAttribute(`ui.target.text`,desc.text)}const PREFETCH_HEADER_NAMES=[`next-router-prefetch`,`next-router-segment-prefetch`];function isPrefetchRequest(request){if(typeof request==`string`||request instanceof URL)return!1;let headers;try{headers=typeof Request<`u`&&request instanceof Request?request.headers:new Headers(request.headers)}catch{return!1}return PREFETCH_HEADER_NAMES.some(name=>headers.has(name))||headers.get(`purpose`)===`prefetch`||headers.get(`sec-purpose`)?.includes(`prefetch`)===!0}function escapeRegExp(value){return value.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`)}function apiHostToMatcher(host){return RegExp(`^https?://${escapeRegExp(host)}(:\\d+)?([/?#]|$)`,`u`)}function registerBundledInstrumentations(input){let{tracerProvider,loggerProvider,ignoreUrls,apiHosts=[],propagateContextUrls=[],privacyPolicy=DEFAULT_PRIVACY_POLICY,isInteractionCaptureEnabled=()=>!0,redactUrl=url=>url}=input,{resolveRoute}=input,origin=sameOriginPattern(),propagateMatchers=[...apiHosts.map(host=>apiHostToMatcher(host)),...propagateContextUrls],fetchIgnore=[...ignoreUrls,...THIRD_PARTY_IGNORE],failureRanges=resolveFailureRanges(input.captureFailedRequests),failureGate=createFailureGate(),pageExit=createPageExitWatch();function isTrackedUrl(url){return origin.test(url)||propagateMatchers.some(re=>re instanceof RegExp?re.test(url):url.includes(re))}let pageEventsEnabled=!1,admitClick=createClickSpanGate(),coreInstrumentations=[new FetchInstrumentation({applyCustomAttributesOnSpan:(span,request,result)=>{applyFetchSpanAttrs(span,request,result,failureRanges,pageExit,isTrackedUrl,resolveRoute,failureGate)},ignoreUrls:fetchIgnore,measureRequestSize:!0,propagateTraceHeaderCorsUrls:[origin,...propagateMatchers],requestHook:(span,request)=>{isPrefetchRequest(request)&&span.setAttribute(`http.request.prefetch`,!0)}}),new XMLHttpRequestInstrumentation({applyCustomAttributesOnSpan:(span,xhr)=>{applyXhrSpanAttrs(span,xhr,failureRanges,pageExit,isTrackedUrl,failureGate,resolveRoute)},ignoreUrls:fetchIgnore,propagateTraceHeaderCorsUrls:[origin,...propagateMatchers]}),new LongTaskInstrumentation({observerCallback:(span,info)=>{stampUrlAttrs(span,resolveRoute);let containerType=info.longtaskEntry.attribution[0]?.containerType;containerType&&span.setAttribute(`longtask.container_type`,containerType)}}),new UserInteractionInstrumentation({eventNames:[`click`,`submit`],shouldPreventSpanCreation:(eventType,element,span)=>!(pageEventsEnabled&&isInteractionCaptureEnabled())||eventType===`click`&&!(isActionable(element)&&admitClick(element))||(stampInteractionAttrs(eventType,element,span,privacyPolicy),stampUrlAttrs(span,resolveRoute),!1)})],pageEventsInstrumentations=[new DocumentLoadInstrumentation({applyCustomAttributesOnSpan:{resourceFetch:(span,entry)=>{let name=entry?.name;if(typeof name!=`string`)return;let url;try{url=new URL(name)}catch{return}let isCrossOrigin=typeof window<`u`&&url.origin!==globalThis.location.origin;span.updateName(isCrossOrigin?`resource: ${url.host}${url.pathname}`:`resource: ${url.pathname}`),span.setAttribute(ATTR_URL_FULL,name),span.setAttribute(ATTR_URL_PATH,url.pathname),span.setAttribute(`server.address`,url.host)}},enabled:!1}),new BrowserNavigationInstrumentation({enabled:!1,sanitizeUrl:url=>redactUrl(defaultSanitizeUrl(url))})],unregisterCore=registerInstrumentations(omitUndefined({tracerProvider,loggerProvider,instrumentations:coreInstrumentations})),unregisterPageEvents=null,setPageEventsEnabled=enabled=>{if(pageEventsEnabled=enabled,enabled){unregisterPageEvents??=registerInstrumentations(omitUndefined({tracerProvider,loggerProvider,instrumentations:pageEventsInstrumentations}));return}unregisterPageEvents?.(),unregisterPageEvents=null};return{dispose:()=>{setPageEventsEnabled(!1),unregisterCore(),pageExit.dispose()},setPageEventsEnabled}}export{testOnlyResolveFailureRanges as a,testOnlyCreateFailureGate as i,testOnlyApplyFetchSpanAttrs as n,testOnlyApplyXhrSpanAttrs as r,registerBundledInstrumentations as t};
@@ -1,11 +1,9 @@
1
1
  import { i as PrivacyPolicy } from "./privacy-CPKosXDP.mjs";
2
+ import { n as FetchSpanRequest, r as PageExitWatch, t as FetchError } from "./network-failure-DFMPEnXx.mjs";
2
3
  import { Span } from "@opentelemetry/api";
3
- import { FetchCustomAttributeFunction } from "@opentelemetry/instrumentation-fetch";
4
4
  import { WebTracerProvider } from "@opentelemetry/sdk-trace-web";
5
5
  import { LoggerProvider } from "@opentelemetry/sdk-logs";
6
6
  //#region src/internal/otel/instrumentations/instrumentations.d.ts
7
- type FetchError = Exclude<Parameters<FetchCustomAttributeFunction>[2], Response>;
8
- type FetchSpanRequest = Request | RequestInfo | RequestInit | URL;
9
7
  /**
10
8
  * Inclusive HTTP status range. `[400, 499]` matches every 4xx;
11
9
  * a bare number matches that exact code.
@@ -18,19 +16,20 @@ interface CaptureFailedRequestsOptions {
18
16
  /**
19
17
  * Promote tracked failed fetch/XHR responses to captured exception events.
20
18
  * On by default (same-origin 4xx + 5xx, deduped + rate-limited); `false`
21
- * disables, `{ statusCodes }` tunes the matched ranges.
19
+ * disables, `{ statusCodes }` tunes the matched ranges. Aborted and timed-out
20
+ * requests are not failures: their spans get `interfere.http.cancelled`.
21
+ * Transport failures are dropped when the page is hidden or unloaded
22
+ * within one second, since browsers fail in-flight requests on navigation.
22
23
  */
23
24
  type CaptureFailedRequestsOption = boolean | CaptureFailedRequestsOptions;
24
25
  declare function resolveFailureRanges(opt: CaptureFailedRequestsOption | undefined): readonly HttpStatusCodeRange[] | null;
25
26
  declare function createFailureGate(): (key: string) => boolean;
26
- declare function classifyNetworkError(message: string): "abort" | "network" | "timeout";
27
- declare function applyFetchSpanAttrs(span: Span, request: FetchSpanRequest, result: Response | FetchError, failureRanges: readonly HttpStatusCodeRange[] | null, isTrackedUrl: (url: string) => boolean, resolveRoute: ((pathname: string) => string | undefined) | undefined, gate?: (key: string) => boolean): void;
28
- declare function applyXhrSpanAttrs(span: Span, xhr: Pick<XMLHttpRequest, "responseURL" | "status">, failureRanges: readonly HttpStatusCodeRange[] | null, isTrackedUrl: (url: string) => boolean, gate?: (key: string) => boolean, resolveRoute?: (pathname: string) => string | undefined): void;
27
+ declare function applyFetchSpanAttrs(span: Span, request: FetchSpanRequest, result: Response | FetchError, failureRanges: readonly HttpStatusCodeRange[] | null, pageExit: PageExitWatch, isTrackedUrl: (url: string) => boolean, resolveRoute: ((pathname: string) => string | undefined) | undefined, gate?: (key: string) => boolean): void;
28
+ declare function applyXhrSpanAttrs(span: Span, xhr: Pick<XMLHttpRequest, "responseURL" | "status">, failureRanges: readonly HttpStatusCodeRange[] | null, pageExit: PageExitWatch, isTrackedUrl: (url: string) => boolean, gate?: (key: string) => boolean, resolveRoute?: (pathname: string) => string | undefined): void;
29
29
  declare const testOnlyApplyFetchSpanAttrs: typeof applyFetchSpanAttrs;
30
30
  declare const testOnlyApplyXhrSpanAttrs: typeof applyXhrSpanAttrs;
31
31
  declare const testOnlyResolveFailureRanges: typeof resolveFailureRanges;
32
32
  declare const testOnlyCreateFailureGate: typeof createFailureGate;
33
- declare const testOnlyClassifyNetworkError: typeof classifyNetworkError;
34
33
  interface InstrumentationsInput {
35
34
  /**
36
35
  * Hostnames the fetch + XHR instrumentations inject `traceparent` onto,
@@ -88,4 +87,4 @@ declare function registerBundledInstrumentations(input: InstrumentationsInput):
88
87
  setPageEventsEnabled: (enabled: boolean) => void;
89
88
  };
90
89
  //#endregion
91
- export { InstrumentationsInput as a, testOnlyApplyXhrSpanAttrs as c, testOnlyResolveFailureRanges as d, HttpStatusCodeRange as i, testOnlyClassifyNetworkError as l, CaptureFailedRequestsOption as n, registerBundledInstrumentations as o, CaptureFailedRequestsOptions as r, testOnlyApplyFetchSpanAttrs as s, BundledInstrumentations as t, testOnlyCreateFailureGate as u };
90
+ export { InstrumentationsInput as a, testOnlyApplyXhrSpanAttrs as c, HttpStatusCodeRange as i, testOnlyCreateFailureGate as l, CaptureFailedRequestsOption as n, registerBundledInstrumentations as o, CaptureFailedRequestsOptions as r, testOnlyApplyFetchSpanAttrs as s, BundledInstrumentations as t, testOnlyResolveFailureRanges as u };
@@ -1,2 +1,2 @@
1
- import { a as IDLE_AFTER_MS, c as SessionResumeReason, i as EXPIRE_AFTER_MS, n as ActivitySession, o as KEEPALIVE_THROTTLE_MS, r as CHECK_INTERVAL_MS, s as MAX_AGE_MS, t as ActivityMonitor } from "../../activity-Duhfgvxt.mjs";
2
- export { ActivityMonitor, ActivitySession, CHECK_INTERVAL_MS, EXPIRE_AFTER_MS, IDLE_AFTER_MS, KEEPALIVE_THROTTLE_MS, MAX_AGE_MS, SessionResumeReason };
1
+ import { a as IDLE_AFTER_MS, c as SessionResumeReason, i as EXPIRE_AFTER_MS, n as ActivitySession, o as MAX_AGE_MS, r as CHECK_INTERVAL_MS, s as SessionPauseReason, t as ActivityMonitor } from "../../activity-CShcwAW_.mjs";
2
+ export { ActivityMonitor, ActivitySession, CHECK_INTERVAL_MS, EXPIRE_AFTER_MS, IDLE_AFTER_MS, MAX_AGE_MS, SessionPauseReason, SessionResumeReason };
@@ -1 +1 @@
1
- import{a as KEEPALIVE_THROTTLE_MS,i as IDLE_AFTER_MS,n as CHECK_INTERVAL_MS,o as MAX_AGE_MS,r as EXPIRE_AFTER_MS,t as ActivityMonitor}from"../../activity-BYnL3bX-.mjs";export{ActivityMonitor,CHECK_INTERVAL_MS,EXPIRE_AFTER_MS,IDLE_AFTER_MS,KEEPALIVE_THROTTLE_MS,MAX_AGE_MS};
1
+ import{a as MAX_AGE_MS,i as IDLE_AFTER_MS,n as CHECK_INTERVAL_MS,r as EXPIRE_AFTER_MS,t as ActivityMonitor}from"../../activity-oYlZ5aa1.mjs";export{ActivityMonitor,CHECK_INTERVAL_MS,EXPIRE_AFTER_MS,IDLE_AFTER_MS,MAX_AGE_MS};
@@ -1,4 +1,4 @@
1
- import { a as InterfereContextValue, i as InterfereContext } from "../../provider-DIp7vkKd.mjs";
1
+ import { a as InterfereContextValue, i as InterfereContext } from "../../provider-D4QjZp3L.mjs";
2
2
  import { Component, ContextType, ReactNode } from "react";
3
3
  //#region src/internal/capture/capture-boundary.d.ts
4
4
  interface CaptureBoundaryProps {
@@ -1,4 +1,4 @@
1
- import { s as Kernel } from "../../provider-DIp7vkKd.mjs";
1
+ import { s as Kernel } from "../../provider-D4QjZp3L.mjs";
2
2
  import { ErrorMechanism } from "@interfere/types/sdk/plugins/payload/errors";
3
3
  //#region src/internal/capture/capture.d.ts
4
4
  /**
@@ -0,0 +1,5 @@
1
+ //#region src/internal/clock/sent-at.d.ts
2
+ export declare const SENT_AT_HEADER = "x-interfere-sent-at";
3
+ /** Stamps the device's current epoch milliseconds on an ingest request so the gateway can measure device clock skew; call once per attempt. */
4
+ export declare function stampSentAt(headers: Headers): Headers;
5
+ //#endregion
@@ -0,0 +1 @@
1
+ import{n as stampSentAt,t as SENT_AT_HEADER}from"../../sent-at-CEM8UV3W.mjs";export{SENT_AT_HEADER,stampSentAt};
@@ -0,0 +1,12 @@
1
+ //#region src/internal/ingest-backoff/ingest-backoff.d.ts
2
+ /** Test-only reset of the ingest network backoff. */
3
+ export declare function resetIngestBackoff(): void;
4
+ /** Rejection for an ingest request skipped because an earlier network failure is still backing off. */
5
+ export declare class IngestBackoffError extends Error {
6
+ constructor();
7
+ }
8
+ /**
9
+ * Sends one ingest request unless an earlier network failure is still backing off. A fetch rejection with a `TypeError` (no HTTP response: blocked, offline or unreachable) pauses every ingest request on the page for 5 s, doubling per consecutive failure up to 10 minutes. Any HTTP response clears the backoff.
10
+ */
11
+ export declare function fetchIngest(send: () => Promise<Response>): Promise<Response>;
12
+ //#endregion
@@ -0,0 +1 @@
1
+ import{n as fetchIngest,r as resetIngestBackoff,t as IngestBackoffError}from"../../ingest-backoff-B1OeEV3h.mjs";export{IngestBackoffError,fetchIngest,resetIngestBackoff};
@@ -1,4 +1,4 @@
1
- import { s as Kernel } from "../provider-DIp7vkKd.mjs";
1
+ import { s as Kernel } from "../provider-D4QjZp3L.mjs";
2
2
  //#region src/internal/kernel-registry.d.ts
3
3
  export declare function registerKernel(kernel: Kernel): void;
4
4
  export declare function unregisterKernel(kernel: Kernel): void;
@@ -1,6 +1,6 @@
1
1
  import { r as PrivacyOptions } from "../privacy-CPKosXDP.mjs";
2
- import { _ as readReleaseSlugFromGlobals, c as KernelConsent, d as KernelInternalOptions, f as KernelOptions, g as createKernel, h as buildSdkStack, l as KernelDevice, m as TracingOptions, p as KernelSession, s as Kernel, u as KernelIdentity } from "../provider-DIp7vkKd.mjs";
3
- import { i as HttpStatusCodeRange, n as CaptureFailedRequestsOption, r as CaptureFailedRequestsOptions } from "../instrumentations-D656I08h.mjs";
2
+ import { _ as readReleaseSlugFromGlobals, c as KernelConsent, d as KernelInternalOptions, f as KernelOptions, g as createKernel, h as buildSdkStack, l as KernelDevice, m as TracingOptions, p as KernelSession, s as Kernel, u as KernelIdentity } from "../provider-D4QjZp3L.mjs";
3
+ import { i as HttpStatusCodeRange, n as CaptureFailedRequestsOption, r as CaptureFailedRequestsOptions } from "../instrumentations-S-BCpguB.mjs";
4
4
  import { t as RecordExceptionOpts } from "../exception-span-zN1tvBdh.mjs";
5
5
  import { t as isEnabledByEnvironment } from "../environment-CtCFKD2N.mjs";
6
6
  export { type CaptureFailedRequestsOption, type CaptureFailedRequestsOptions, type HttpStatusCodeRange, Kernel, KernelConsent, KernelDevice, KernelIdentity, KernelInternalOptions, KernelOptions, KernelSession, type PrivacyOptions, type RecordExceptionOpts, TracingOptions, buildSdkStack, createKernel, isEnabledByEnvironment, readReleaseSlugFromGlobals };
@@ -1 +1 @@
1
- import{t as isEnabledByEnvironment}from"../environment-CoEXhF1a.mjs";import{i as readReleaseSlugFromGlobals,n as buildSdkStack,r as createKernel,t as Kernel}from"../kernel-B0Q_aRde.mjs";export{Kernel,buildSdkStack,createKernel,isEnabledByEnvironment,readReleaseSlugFromGlobals};
1
+ import{t as isEnabledByEnvironment}from"../environment-CoEXhF1a.mjs";import{i as readReleaseSlugFromGlobals,n as buildSdkStack,r as createKernel,t as Kernel}from"../kernel-BVG-7Zau.mjs";export{Kernel,buildSdkStack,createKernel,isEnabledByEnvironment,readReleaseSlugFromGlobals};
@@ -0,0 +1,12 @@
1
+ import { ReadableSpan, SpanProcessor } from "@opentelemetry/sdk-trace-base";
2
+ //#region src/internal/otel/export-filter.d.ts
3
+ /** Whether a finished span is worth exporting. Long tasks under 500 ms are dropped. */
4
+ export declare function shouldExportSpan(span: ReadableSpan): boolean;
5
+ /** Forwards only exportable spans to the wrapped export processor, and flushes it as soon as a span carrying an exception is queued. */
6
+ export declare function createExportFilterProcessor(next: SpanProcessor): {
7
+ onStart: (span: import("@opentelemetry/sdk-trace-base").Span, parentContext: import("@opentelemetry/api").Context) => void;
8
+ onEnd: (span: ReadableSpan) => void;
9
+ forceFlush: () => Promise<void>;
10
+ shutdown: () => Promise<void>;
11
+ };
12
+ //#endregion
@@ -0,0 +1 @@
1
+ import{n as shouldExportSpan,t as createExportFilterProcessor}from"../../export-filter-Cixywxpu.mjs";export{createExportFilterProcessor,shouldExportSpan};
@@ -1 +1 @@
1
- import{a as isIngestHalted,i as createTraceExporter,n as createLogExporter,o as resetIngestHalt,r as createMetricExporter,t as INGEST_IGNORE_RE}from"../../exporter-CcNtHR8L.mjs";export{INGEST_IGNORE_RE,createLogExporter,createMetricExporter,createTraceExporter,isIngestHalted,resetIngestHalt};
1
+ import{a as isIngestHalted,i as createTraceExporter,n as createLogExporter,o as resetIngestHalt,r as createMetricExporter,t as INGEST_IGNORE_RE}from"../../exporter-De0h9YP5.mjs";export{INGEST_IGNORE_RE,createLogExporter,createMetricExporter,createTraceExporter,isIngestHalted,resetIngestHalt};
@@ -1,7 +1,7 @@
1
- import { a as InstrumentationsInput, i as HttpStatusCodeRange, n as CaptureFailedRequestsOption, o as registerBundledInstrumentations, r as CaptureFailedRequestsOptions, t as BundledInstrumentations } from "../../instrumentations-D656I08h.mjs";
1
+ import { a as InstrumentationsInput, i as HttpStatusCodeRange, n as CaptureFailedRequestsOption, o as registerBundledInstrumentations, r as CaptureFailedRequestsOptions, t as BundledInstrumentations } from "../../instrumentations-S-BCpguB.mjs";
2
2
  import { a as seedPageScope, i as installNavigationScope, n as PAGE_SCOPE_MAX_AGE_MS, r as createPageScopeRotator, t as NavigationScopeInput } from "../../navigation-CkiV6lJY.mjs";
3
3
  import { t as readPropagationFromDocument } from "../../propagation-CssinKCy.mjs";
4
4
  import { n as OtelProviderInput, r as buildOtelProvider, t as OtelProviderHandle } from "../../provider-cUByhzgv.mjs";
5
5
  import { n as captureWebVitals } from "../../web-vitals-x8y70B5x.mjs";
6
- import "../../index-BZ_yQUGY.mjs";
6
+ import "../../index-DpkTHU1a.mjs";
7
7
  export { type BundledInstrumentations, type CaptureFailedRequestsOption, type CaptureFailedRequestsOptions, type HttpStatusCodeRange, type InstrumentationsInput, type NavigationScopeInput, type OtelProviderHandle, type OtelProviderInput, PAGE_SCOPE_MAX_AGE_MS, buildOtelProvider, captureWebVitals, createPageScopeRotator, installNavigationScope, readPropagationFromDocument, registerBundledInstrumentations, seedPageScope };
@@ -1 +1 @@
1
- import{t as registerBundledInstrumentations}from"../../instrumentations-CY8NcP_M.mjs";import{i as seedPageScope,n as createPageScopeRotator,r as installNavigationScope,t as PAGE_SCOPE_MAX_AGE_MS}from"../../navigation-DwkvuhFR.mjs";import{t as readPropagationFromDocument}from"../../propagation-DVcqCu_E.mjs";import{t as buildOtelProvider}from"../../provider-DYb87tIb.mjs";import{t as captureWebVitals}from"../../web-vitals-CxXDUgpl.mjs";export{PAGE_SCOPE_MAX_AGE_MS,buildOtelProvider,captureWebVitals,createPageScopeRotator,installNavigationScope,readPropagationFromDocument,registerBundledInstrumentations,seedPageScope};
1
+ import{t as registerBundledInstrumentations}from"../../instrumentations-NN81kslu.mjs";import{i as seedPageScope,n as createPageScopeRotator,r as installNavigationScope,t as PAGE_SCOPE_MAX_AGE_MS}from"../../navigation-DwkvuhFR.mjs";import{t as readPropagationFromDocument}from"../../propagation-DVcqCu_E.mjs";import{t as buildOtelProvider}from"../../provider-CElaujE6.mjs";import{t as captureWebVitals}from"../../web-vitals-CxXDUgpl.mjs";export{PAGE_SCOPE_MAX_AGE_MS,buildOtelProvider,captureWebVitals,createPageScopeRotator,installNavigationScope,readPropagationFromDocument,registerBundledInstrumentations,seedPageScope};
@@ -0,0 +1,8 @@
1
+ //#region src/internal/otel/instrumentations/click-span-gate.d.ts
2
+ /**
3
+ * Decides which actionable clicks become spans. Skips focusing a text field,
4
+ * the control click a `<label>` forwards, and repeat clicks on the same
5
+ * element within a second; rage clicks are recorded separately.
6
+ */
7
+ export declare function createClickSpanGate(): (element: Element) => boolean;
8
+ //#endregion
@@ -0,0 +1 @@
1
+ import{t as createClickSpanGate}from"../../../click-span-gate-6dNMhjc7.mjs";export{createClickSpanGate};
@@ -1,2 +1,2 @@
1
- import { a as InstrumentationsInput, c as testOnlyApplyXhrSpanAttrs, d as testOnlyResolveFailureRanges, i as HttpStatusCodeRange, l as testOnlyClassifyNetworkError, n as CaptureFailedRequestsOption, o as registerBundledInstrumentations, r as CaptureFailedRequestsOptions, s as testOnlyApplyFetchSpanAttrs, t as BundledInstrumentations, u as testOnlyCreateFailureGate } from "../../../instrumentations-D656I08h.mjs";
2
- export { BundledInstrumentations, CaptureFailedRequestsOption, CaptureFailedRequestsOptions, HttpStatusCodeRange, InstrumentationsInput, registerBundledInstrumentations, testOnlyApplyFetchSpanAttrs, testOnlyApplyXhrSpanAttrs, testOnlyClassifyNetworkError, testOnlyCreateFailureGate, testOnlyResolveFailureRanges };
1
+ import { a as InstrumentationsInput, c as testOnlyApplyXhrSpanAttrs, i as HttpStatusCodeRange, l as testOnlyCreateFailureGate, n as CaptureFailedRequestsOption, o as registerBundledInstrumentations, r as CaptureFailedRequestsOptions, s as testOnlyApplyFetchSpanAttrs, t as BundledInstrumentations, u as testOnlyResolveFailureRanges } from "../../../instrumentations-S-BCpguB.mjs";
2
+ export { BundledInstrumentations, CaptureFailedRequestsOption, CaptureFailedRequestsOptions, HttpStatusCodeRange, InstrumentationsInput, registerBundledInstrumentations, testOnlyApplyFetchSpanAttrs, testOnlyApplyXhrSpanAttrs, testOnlyCreateFailureGate, testOnlyResolveFailureRanges };
@@ -1 +1 @@
1
- import{a as testOnlyCreateFailureGate,i as testOnlyClassifyNetworkError,n as testOnlyApplyFetchSpanAttrs,o as testOnlyResolveFailureRanges,r as testOnlyApplyXhrSpanAttrs,t as registerBundledInstrumentations}from"../../../instrumentations-CY8NcP_M.mjs";export{registerBundledInstrumentations,testOnlyApplyFetchSpanAttrs,testOnlyApplyXhrSpanAttrs,testOnlyClassifyNetworkError,testOnlyCreateFailureGate,testOnlyResolveFailureRanges};
1
+ import{a as testOnlyResolveFailureRanges,i as testOnlyCreateFailureGate,n as testOnlyApplyFetchSpanAttrs,r as testOnlyApplyXhrSpanAttrs,t as registerBundledInstrumentations}from"../../../instrumentations-NN81kslu.mjs";export{registerBundledInstrumentations,testOnlyApplyFetchSpanAttrs,testOnlyApplyXhrSpanAttrs,testOnlyCreateFailureGate,testOnlyResolveFailureRanges};
@@ -0,0 +1,2 @@
1
+ import { a as settleFetchFailure, i as createPageExitWatch, n as FetchSpanRequest, o as settleXhrFailure, r as PageExitWatch, t as FetchError } from "../../../network-failure-DFMPEnXx.mjs";
2
+ export { FetchError, FetchSpanRequest, PageExitWatch, createPageExitWatch, settleFetchFailure, settleXhrFailure };
@@ -0,0 +1 @@
1
+ import{n as settleFetchFailure,r as settleXhrFailure,t as createPageExitWatch}from"../../../network-failure-GVLV_sUF.mjs";export{createPageExitWatch,settleFetchFailure,settleXhrFailure};
@@ -1 +1 @@
1
- import{t as buildOtelProvider}from"../../provider-DYb87tIb.mjs";export{buildOtelProvider};
1
+ import{t as buildOtelProvider}from"../../provider-CElaujE6.mjs";export{buildOtelProvider};
@@ -2,6 +2,8 @@
2
2
  type Handler = () => void;
3
3
  export declare function onPageHidden(handler: Handler): () => void;
4
4
  export declare function onPageShown(handler: Handler): () => void;
5
+ /** Whether the page is hidden, as tracked by the same `visibilitychange`, `pagehide` and `pageshow` signals the hidden and shown handlers use. */
6
+ export declare function isPageHidden(): boolean;
5
7
  /** Fires on `beforeunload`, before the browser commits the navigation; the page may still survive, so subscribers flush and keep running. */
6
8
  export declare function onPageUnloading(handler: Handler): () => void;
7
9
  /** Test hook — drops every handler and unbinds the listeners. */
@@ -1 +1 @@
1
- import{i as resetPageLifecycleForTests,n as onPageShown,r as onPageUnloading,t as onPageHidden}from"../../page-lifecycle-DTWqGlz2.mjs";export{onPageHidden,onPageShown,onPageUnloading,resetPageLifecycleForTests};
1
+ import{a as resetPageLifecycleForTests,i as onPageUnloading,n as onPageHidden,r as onPageShown,t as isPageHidden}from"../../page-lifecycle-rJEJNdKj.mjs";export{isPageHidden,onPageHidden,onPageShown,onPageUnloading,resetPageLifecycleForTests};
@@ -1,2 +1,2 @@
1
- import { v as PluginRuntime } from "../../provider-DIp7vkKd.mjs";
1
+ import { v as PluginRuntime } from "../../provider-D4QjZp3L.mjs";
2
2
  export { PluginRuntime };
@@ -1 +1 @@
1
- import{t as PluginRuntime}from"../../plugin-runtime-B1oFO16q.mjs";export{PluginRuntime};
1
+ import{t as PluginRuntime}from"../../plugin-runtime-DSj0FM1Q.mjs";export{PluginRuntime};
@@ -1,2 +1,2 @@
1
- import { a as InterfereContextValue, i as InterfereContext, o as NULL_CONTEXT_VALUE } from "../provider-DIp7vkKd.mjs";
1
+ import { a as InterfereContextValue, i as InterfereContext, o as NULL_CONTEXT_VALUE } from "../provider-D4QjZp3L.mjs";
2
2
  export { InterfereContext, InterfereContextValue, NULL_CONTEXT_VALUE };
@@ -1,10 +1,10 @@
1
1
  //#region src/internal/third-party-hosts.d.ts
2
2
  /**
3
- * Hosts/paths whose client-side fetch / XHR / resource loads we never
4
- * surface: common analytics / ads / auth / replay vendors that otherwise
5
- * turn into orphan-span and resource-error noise. Conservative and
6
- * customer-generic — app-specific noise belongs in the customer's own
7
- * `ignoreUrls` config, not hardcoded into a public SDK.
3
+ * Requests and resource loads the SDK never surfaces: analytics, ads,
4
+ * replay, monitoring and auth vendors that otherwise turn into orphan-span
5
+ * and resource-error noise. A vendor host matches itself and any subdomain;
6
+ * the path patterns catch vendors commonly proxied through the customer's
7
+ * own origin. App-specific noise belongs in `tracing.ignoreUrls`.
8
8
  *
9
9
  * Dependency-free on purpose so the error-only bundle can reuse it without
10
10
  * pulling in the OTel SDK that `internal/otel/*` carries.
@@ -1 +1 @@
1
- import{t as THIRD_PARTY_IGNORE}from"../third-party-hosts-BoJNL3xG.mjs";export{THIRD_PARTY_IGNORE};
1
+ import{t as THIRD_PARTY_IGNORE}from"../third-party-hosts-CYOuLL_s.mjs";export{THIRD_PARTY_IGNORE};
@@ -1 +1 @@
1
- import{n as SDK_NAME,r as SDK_VERSION,t as PRODUCER_VERSION}from"../version-CU2o2z22.mjs";export{PRODUCER_VERSION,SDK_NAME,SDK_VERSION};
1
+ import{n as SDK_NAME,r as SDK_VERSION,t as PRODUCER_VERSION}from"../version-DusHm2Q4.mjs";export{PRODUCER_VERSION,SDK_NAME,SDK_VERSION};
@@ -1,4 +1,4 @@
1
- import { f as KernelOptions, s as Kernel } from "../provider-DIp7vkKd.mjs";
1
+ import { f as KernelOptions, s as Kernel } from "../provider-D4QjZp3L.mjs";
2
2
  import { ConsentInput, ConsentState } from "@interfere/types/sdk/plugins/manifest";
3
3
  import { IdentifyParams } from "@interfere/types/sdk/identify";
4
4
  //#region src/internal/wrapper-singleton.d.ts
@@ -1 +1 @@
1
- import{t as createLogger}from"../log-D6Ht--tv.mjs";import{n as registerKernel,r as unregisterKernel}from"../kernel-registry-6f-3VCIy.mjs";import{n as isForceEnableActive,t as hasPublicKey}from"../config-VOyDjqS7.mjs";import{t as isEnabledByEnvironment}from"../environment-CoEXhF1a.mjs";import{r as createKernel}from"../kernel-B0Q_aRde.mjs";import{n as isBotUserAgent}from"../bot-YLSbnCeg.mjs";const log=createLogger(`init`);function createWrapperSingleton(input){let kernel=null,pending=null,listeners=new Set;function emit(){for(let listener of listeners)listener()}async function initKernel(internalOpts){try{let k=await createKernel({opts:internalOpts});return kernel=k,registerKernel(k),emit(),k}finally{pending=null}}return{async close(){if(!kernel)return;let previous=kernel;await previous.dispose(),kernel=null,unregisterKernel(previous),emit()},consent:{get:()=>kernel?.consent.get()??null,set:value=>kernel?.consent.set(value)},getKernel(){if(!kernel)throw Error(`Interfere SDK not initialized. Call init() from your ${input.initEntryName} entrypoint.`);return kernel},getKernelOrNull(){return kernel},identity:{clear:()=>kernel?.identity.clear(),get:()=>kernel?.identity.get()??null,set:async params=>kernel?.identity.set(params)??Promise.resolve()},async init(opts={}){return kernel||pending||(!(opts.enabled??isEnabledByEnvironment())||!isForceEnableActive()&&isBotUserAgent()?null:hasPublicKey()?(pending=initKernel({...opts,_wrapperVersions:[input.producerVersion]}),pending):(log.warn(`No public key is configured, so the SDK is disabled. Set INTERFERE_PUBLIC_KEY (VITE_INTERFERE_PUBLIC_KEY for Vite) on builds that should send telemetry.`),null))},subscribeToKernel(listener){return listeners.add(listener),(()=>{listeners.delete(listener)})}}}export{createWrapperSingleton};
1
+ import{t as createLogger}from"../log-D6Ht--tv.mjs";import{n as registerKernel,r as unregisterKernel}from"../kernel-registry-6f-3VCIy.mjs";import{n as isForceEnableActive,t as hasPublicKey}from"../config-VOyDjqS7.mjs";import{t as isEnabledByEnvironment}from"../environment-CoEXhF1a.mjs";import{r as createKernel}from"../kernel-BVG-7Zau.mjs";import{n as isBotUserAgent}from"../bot-YLSbnCeg.mjs";const log=createLogger(`init`);function createWrapperSingleton(input){let kernel=null,pending=null,listeners=new Set;function emit(){for(let listener of listeners)listener()}async function initKernel(internalOpts){try{let k=await createKernel({opts:internalOpts});return kernel=k,registerKernel(k),emit(),k}finally{pending=null}}return{async close(){if(!kernel)return;let previous=kernel;await previous.dispose(),kernel=null,unregisterKernel(previous),emit()},consent:{get:()=>kernel?.consent.get()??null,set:value=>kernel?.consent.set(value)},getKernel(){if(!kernel)throw Error(`Interfere SDK not initialized. Call init() from your ${input.initEntryName} entrypoint.`);return kernel},getKernelOrNull(){return kernel},identity:{clear:()=>kernel?.identity.clear(),get:()=>kernel?.identity.get()??null,set:async params=>kernel?.identity.set(params)??Promise.resolve()},async init(opts={}){return kernel||pending||(!(opts.enabled??isEnabledByEnvironment())||!isForceEnableActive()&&isBotUserAgent()?null:hasPublicKey()?(pending=initKernel({...opts,_wrapperVersions:[input.producerVersion]}),pending):(log.warn(`No public key is configured, so the SDK is disabled. Set INTERFERE_PUBLIC_KEY (VITE_INTERFERE_PUBLIC_KEY for Vite) on builds that should send telemetry.`),null))},subscribeToKernel(listener){return listeners.add(listener),(()=>{listeners.delete(listener)})}}}export{createWrapperSingleton};
@@ -0,0 +1 @@
1
+ import{t as createLogger}from"./log-D6Ht--tv.mjs";import{i as onPageUnloading,n as onPageHidden}from"./page-lifecycle-rJEJNdKj.mjs";import{t as SessionTracker}from"./api-DvHT4Dyw.mjs";import{n as getStringGlobal,t as getGlobal}from"./global-DYq1Z4_H.mjs";import{i as setIngestHost,r as resolveTargets}from"./config-VOyDjqS7.mjs";import{a as resolvePrivacyPolicy}from"./privacy-CRuL0X8r.mjs";import{t as PRODUCER_VERSION}from"./version-DusHm2Q4.mjs";import{t as INGEST_IGNORE_RE}from"./exporter-De0h9YP5.mjs";import{t as recordInitialNavigation}from"./initial-navigation-YeK6UUHX.mjs";import{n as recordExceptionOnSpan,r as startExceptionSpan,t as buildExceptionEventAttrs}from"./exception-span-B74fhBQb.mjs";import{t as PluginRuntime}from"./plugin-runtime-DSj0FM1Q.mjs";import{isNonErrorException,shouldDropBrowserExtensionNoise,shouldDropUnresolvableStack}from"@interfere/types/sdk/errors";import{trace}from"@opentelemetry/api";import{omitUndefined}from"@interfere/helpers/omit-undefined";import{InterfereClient}from"@interfere/javascript";import{releaseSlugSchema}from"@interfere/types/releases/slug";import{FORCE_ENABLE_GLOBAL,RELEASE_SLUG_GLOBAL,SDK_STACK_GLOBAL}from"@interfere/types/sdk/injected-globals";import{readBakedPlugins,remoteConfigInputSchema}from"@interfere/types/sdk/remote-config";import{SERVICE_NAME_GLOBAL}from"@interfere/types/sdk/service-name";import{redactUrl,resolveUrlRedaction}from"@interfere/types/sdk/url-redaction";const log=createLogger(`kernel`),REPLAY_UPLOAD_RE=/\/v3\/replay\/upload\//u;function buildSdkStack(wrapperVersions){return[...wrapperVersions??[],PRODUCER_VERSION]}var Kernel=class{consent;identity;device;session;privacyPolicy;urlRedaction;redactUrl=url=>redactUrl(url,this.urlRedaction);seen=new WeakSet;initialNavigationSeen=new Set;runtime=null;otel=null;otelDispose=null;otelControls=null;deviceInfoCaptureEnabled=!1;unsubscribePageHidden=null;unsubscribePageUnloading=null;tracker;constructor(tracker,privacy={}){this.tracker=tracker,this.privacyPolicy=resolvePrivacyPolicy(privacy),this.urlRedaction=resolveUrlRedaction(privacy.urls),this.consent={get:()=>this.requireRuntime().getConsent(),set:value=>{let runtime=this.requireRuntime();value===void 0?runtime.resetConsent():runtime.setConsent(value)}},this.identity={clear:()=>{this.tracker.reset()},get:()=>this.tracker.getIdentity(),set:async params=>this.tracker.identify(params)},this.device={getDeviceId:()=>this.tracker.getDeviceId(),getFpHash:()=>this.tracker.getFpHash()},this.session={getId:()=>this.tracker.sessionId(),getWindowId:()=>this.tracker.windowId()},this.unsubscribePageHidden=onPageHidden(()=>{this.flush().catch(()=>{})}),this.unsubscribePageUnloading=onPageUnloading(()=>{this.flush().catch(()=>{})})}attachRuntime(runtime){this.runtime=runtime}requireRuntime(){if(!this.runtime)throw Error(`Kernel runtime not attached. createKernel must call attachRuntime before any consent/dispose path runs.`);return this.runtime}getSessionId(){return this.tracker.sessionId()??``}getWindowId(){return this.tracker.windowId()??``}onSessionPause(handler){return this.tracker.onSessionPause(handler)}onSessionExceptionWhilePaused(handler){return this.tracker.onSessionExceptionWhilePaused(handler)}onSessionResume(handler){return this.tracker.onSessionResume(handler)}getPluginConfigState(key){return this.requireRuntime().getPluginConfigState(key)}getReplayConfig(){return this.requireRuntime().getReplayConfig()}isInteractionCaptureEnabled(){return this.requireRuntime().isInteractionCaptureEnabled()}subscribePluginConfigState(key,listener){return this.requireRuntime().subscribePluginConfigState(key,listener)}getTracer(name){return this.otel?.tracerProvider.getTracer(name)??trace.getTracer(name)}startPageEventsCapture(){let{otelControls:controls,otel}=this;return!controls||!otel?null:(controls.setPageEventsEnabled(!0),this.recordInitialNavigation(otel.loggerProvider),(()=>{controls.setPageEventsEnabled(!1)}))}startDeviceInfoCapture(){return this.tracker.startDeviceIdentity(),this.deviceInfoCaptureEnabled=!0,(reason=>{this.deviceInfoCaptureEnabled=!1,reason===`consent-revoked`&&this.tracker.discardDeviceIdentity()})}isDeviceInfoCaptureEnabled(){return this.deviceInfoCaptureEnabled}recordException(value,opts){if(!isNonErrorException(value)){if(this.seen.has(value))return;this.seen.add(value)}if(!isNonErrorException(value)){let stacks=[],current=value;for(let depth=0;current&&depth<5;depth+=1)current.stack&&stacks.push(current.stack),current=current.cause instanceof Error?current.cause:void 0;if(shouldDropBrowserExtensionNoise(stacks)||shouldDropUnresolvableStack(stacks))return}this.tracker.noteException();let attrs=buildExceptionEventAttrs(value,opts),active=trace.getActiveSpan();if(active?.isRecording()){recordExceptionOnSpan(active,value,attrs,opts.mechanism.handled);return}let tracer=this.otel?.tracerProvider.getTracer(`@interfere/react/exception`);if(!tracer)return;let span=startExceptionSpan(tracer,value);recordExceptionOnSpan(span,value,attrs,opts.mechanism.handled),span.end()}recordLog(input){this.otel&&this.otel.loggerProvider.getLogger(`@interfere/react`).emit(omitUndefined({body:input.body,severityNumber:input.severityNumber,severityText:input.severityText,attributes:input.attributes}))}recordInitialNavigation(loggerProvider){recordInitialNavigation({getSessionId:()=>this.session.getId(),getWindowId:()=>this.session.getWindowId(),loggerProvider,redactUrl:this.redactUrl,seen:this.initialNavigationSeen})}async flush(){this.otel&&await this.otel.flush()}attachOtel(handle,dispose,controls){this.otel=handle,this.otelDispose=dispose,this.otelControls=controls??null}syncProviderConfig(config){this.requireRuntime().applyProviderConfig(config.plugins,config.consent)}async dispose(){this.unsubscribePageHidden?.(),this.unsubscribePageHidden=null,this.unsubscribePageUnloading?.(),this.unsubscribePageUnloading=null,this.runtime&&await this.runtime.dispose(),this.tracker.dispose(),this.otelDispose?.(),this.otelDispose=null,this.otel&&=(await this.otel.shutdown(),null)}};async function createKernel(input={}){let{opts={}}=input,fetcher=opts.fetch??globalThis.fetch.bind(globalThis),remotePlugins=await resolveRemotePlugins(opts,fetcher),targets=resolveTargets(opts.apiHost);log.info(`ingest: %s`,targets.ingest.baseUrl),getGlobal(FORCE_ENABLE_GLOBAL)&&log.warn(`FORCE_ENABLE is active. Events will be dropped by production ingest. This should only be set during local development.`);let tracker=new SessionTracker({fetcher,target:targets.ingest});opts._wrapperVersions?.length&&Object.assign(globalThis,{[SDK_STACK_GLOBAL]:opts._wrapperVersions});let kernel=new Kernel(tracker,opts.privacy),runtime=new PluginRuntime(kernel,opts.consent,remotePlugins??{});if(kernel.attachRuntime(runtime),tracker.start(),runtime.start(),opts.tracing!==!1){let resolvedTracing={...typeof opts.tracing==`object`?opts.tracing:void 0},serviceName=opts.serviceName||getStringGlobal(SERVICE_NAME_GLOBAL);serviceName&&(resolvedTracing.serviceName=serviceName),opts.serviceNamespace!==void 0&&(resolvedTracing.serviceNamespace=opts.serviceNamespace),opts._internalAdditionalSpanProcessors&&(resolvedTracing.additionalSpanProcessors=opts._internalAdditionalSpanProcessors),opts._internalAdditionalLogRecordProcessors&&(resolvedTracing.additionalLogRecordProcessors=opts._internalAdditionalLogRecordProcessors),opts._internalAdditionalMetricReaders&&(resolvedTracing.additionalMetricReaders=opts._internalAdditionalMetricReaders),await wireOtel(kernel,targets,opts._wrapperVersions,resolvedTracing)}return remotePlugins?runtime.applyRemoteConfig(remotePlugins):runtime.applyRemoteConfigDefaults(),kernel}async function resolveRemotePlugins(opts,fetcher){let baked=readBakedPlugins();if(baked)return baked;let remoteConfig=await fetchRemoteConfig(resolveTargets(opts.apiHost).config,fetcher);return remoteConfig?.ingestUrl&&setIngestHost(remoteConfig.ingestUrl),remoteConfig?.plugins??null}async function wireOtel(kernel,targets,wrapperVersions,tracing){let{buildOtelProvider,captureWebVitals,createPageScopeRotator,installNavigationScope,PAGE_SCOPE_MAX_AGE_MS,readPropagationFromDocument,registerBundledInstrumentations,seedPageScope}=await import(`./internal/otel/index.mjs`),releaseSlug=readReleaseSlugFromGlobals(),handle=buildOtelProvider(omitUndefined({clientOptions:targets.ingest,getDeviceId:()=>kernel.device.getDeviceId(),getSessionId:()=>kernel.session.getId(),getPropagationSessionId:()=>kernel.consent.get()?.analytics===!1?null:kernel.session.getId(),isDeviceInfoEnabled:()=>kernel.isDeviceInfoCaptureEnabled(),releaseSlug,sdkStack:buildSdkStack(wrapperVersions),serviceName:tracing.serviceName||void 0,serviceNamespace:tracing.serviceNamespace,additionalSpanProcessors:[...tracing.spanProcessors??[],...tracing.additionalSpanProcessors??[]],additionalLogRecordProcessors:tracing.additionalLogRecordProcessors,additionalMetricReaders:tracing.additionalMetricReaders,urlRedaction:kernel.urlRedaction})),scopeSpanInput=omitUndefined({tracer:handle.tracerProvider.getTracer(`@interfere/react/navigation`),resolveRoute:tracing.resolveRoute}),extracted=readPropagationFromDocument();handle.contextManager.setPageScope(extracted??seedPageScope(scopeSpanInput)),handle.contextManager.setRotation(createPageScopeRotator(scopeSpanInput),PAGE_SCOPE_MAX_AGE_MS);let disposeNavigationScope=installNavigationScope({...scopeSpanInput,setPageScope:ctx=>{handle.contextManager.setPageScope(ctx)}}),instrumentations=registerBundledInstrumentations(omitUndefined({tracerProvider:handle.tracerProvider,loggerProvider:handle.loggerProvider,ignoreUrls:[INGEST_IGNORE_RE,`${targets.config.baseUrl}/v3/config`,`${targets.ingest.baseUrl}/v3/session`,REPLAY_UPLOAD_RE,...tracing.ignoreUrls??[]],apiHosts:tracing.apiHosts,propagateContextUrls:tracing.propagateContextUrls,resolveRoute:tracing.resolveRoute,captureFailedRequests:tracing.captureFailedRequests,redactUrl:kernel.redactUrl,privacyPolicy:kernel.privacyPolicy,isInteractionCaptureEnabled:()=>kernel.isInteractionCaptureEnabled()}));tracing.webVitals!==!1&&captureWebVitals(omitUndefined({flush:async()=>handle.flush(),meter:handle.meterProvider.getMeter(`@interfere/react/web-vitals`),resolveRoute:tracing.resolveRoute})),kernel.attachOtel(handle,()=>{disposeNavigationScope(),instrumentations.dispose()},{setPageEventsEnabled:instrumentations.setPageEventsEnabled})}async function fetchRemoteConfig(configTarget,fetcher){try{let client=new InterfereClient({...configTarget,fetch:Object.assign(async(url,init)=>fetcher(url,{...init,credentials:`omit`}),fetcher)});return remoteConfigInputSchema.parse(await client.config.getSdkConfig())}catch{return log.warn(`remote config fetch failed, using local defaults`),null}}function readReleaseSlugFromGlobals(){let value=getGlobal(RELEASE_SLUG_GLOBAL);return typeof value==`string`?releaseSlugSchema.parse(value):null}export{readReleaseSlugFromGlobals as i,buildSdkStack as n,createKernel as r,Kernel as t};
@@ -1 +1 @@
1
- import{t as createLogger}from"./log-D6Ht--tv.mjs";import{t as errorsPlugin}from"./errors-BfUmjgWO.mjs";import{PLUGIN_MANIFEST}from"@interfere/types/sdk/plugins/manifest";const log=createLogger(`plugins`),LOADERS={device:async()=>import(`./plugins/device.mjs`),errors:()=>errorsPlugin,logs:async()=>import(`./plugins/logs.mjs`),pageEvents:async()=>import(`./plugins/page-events.mjs`),rageClick:async()=>import(`./plugins/rage-clicks.mjs`),replay:async()=>import(`./plugins/replay/index.mjs`)},DEFAULTS=Object.fromEntries(PLUGIN_MANIFEST.map(p=>[p.name,p.defaultEnabled]));function resolveFeatures(overrides){if(!overrides)return{...DEFAULTS};let{pageEvents,replay,...rest}=overrides;return{...DEFAULTS,...rest,pageEvents:pageEvents===void 0?DEFAULTS.pageEvents:pageEvents!==!1,replay:replay===void 0?DEFAULTS.replay:replay!==!1}}function resolvePlugin(mod){return`default`in mod?mod.default:mod}async function loadPlugin(key,context){let loader=LOADERS[key];if(loader===void 0)return null;try{let cleanup=resolvePlugin(await loader()).setup(context);return log.debug(`loaded %s`,key),cleanup??null}catch{return log.error(`failed to load plugin %s`,key),null}}export{loadPlugin as n,resolveFeatures as r,LOADERS as t};
1
+ import{t as createLogger}from"./log-D6Ht--tv.mjs";import{t as errorsPlugin}from"./errors-B8XYW4Q7.mjs";import{PLUGIN_MANIFEST}from"@interfere/types/sdk/plugins/manifest";const log=createLogger(`plugins`),LOADERS={device:async()=>import(`./plugins/device.mjs`),errors:()=>errorsPlugin,logs:async()=>import(`./plugins/logs.mjs`),pageEvents:async()=>import(`./plugins/page-events.mjs`),rageClick:async()=>import(`./plugins/rage-clicks.mjs`),replay:async()=>import(`./plugins/replay/index.mjs`)},DEFAULTS=Object.fromEntries(PLUGIN_MANIFEST.map(p=>[p.name,p.defaultEnabled]));function resolveFeatures(overrides){if(!overrides)return{...DEFAULTS};let{pageEvents,replay,...rest}=overrides;return{...DEFAULTS,...rest,pageEvents:pageEvents===void 0?DEFAULTS.pageEvents:pageEvents!==!1,replay:replay===void 0?DEFAULTS.replay:replay!==!1}}function resolvePlugin(mod){return`default`in mod?mod.default:mod}async function loadPlugin(key,context){let loader=LOADERS[key];if(loader===void 0)return null;try{let cleanup=resolvePlugin(await loader()).setup(context);return log.debug(`loaded %s`,key),cleanup??null}catch{return log.error(`failed to load plugin %s`,key),null}}export{loadPlugin as n,resolveFeatures as r,LOADERS as t};
@@ -0,0 +1,19 @@
1
+ import { Span } from "@opentelemetry/api";
2
+ import { FetchCustomAttributeFunction } from "@opentelemetry/instrumentation-fetch";
3
+ //#region src/internal/otel/instrumentations/network-failure.d.ts
4
+ type FetchError = Exclude<Parameters<FetchCustomAttributeFunction>[2], Response>;
5
+ type FetchSpanRequest = Request | RequestInfo | RequestInit | URL;
6
+ interface PageExitWatch {
7
+ dispose: () => void;
8
+ leftSince: (time: number) => boolean;
9
+ }
10
+ declare function createPageExitWatch(): {
11
+ dispose: () => void;
12
+ leftSince: (time: number) => boolean;
13
+ };
14
+ /** Marks a cancelled fetch, or records its transport failure unless the page leaves within the hold. */
15
+ declare function settleFetchFailure(span: Span, request: FetchSpanRequest, error: FetchError, pageExit: PageExitWatch, method: string, url: string, admit: () => boolean): void;
16
+ /** Marks an aborted or timed-out XHR, or records its transport failure unless the page leaves within the hold. */
17
+ declare function settleXhrFailure(span: Span, pageExit: PageExitWatch, url: string, admit: () => boolean): void;
18
+ //#endregion
19
+ export { settleFetchFailure as a, createPageExitWatch as i, FetchSpanRequest as n, settleXhrFailure as o, PageExitWatch as r, FetchError as t };
@@ -0,0 +1 @@
1
+ import{t as safeStringify}from"./stringify-DvuHsAT4.mjs";import{MECHANISM_TYPE}from"@interfere/types/sdk/errors";const ATTR_HTTP_CANCELLED=`interfere.http.cancelled`;function createPageExitWatch(){let exitedAt=-1/0,onPageHide=()=>{exitedAt=Date.now()},onVisibilityChange=()=>{document.visibilityState===`hidden`&&(exitedAt=Date.now())};return globalThis.addEventListener(`pagehide`,onPageHide),document.addEventListener(`visibilitychange`,onVisibilityChange),{dispose:()=>{globalThis.removeEventListener(`pagehide`,onPageHide),document.removeEventListener(`visibilitychange`,onVisibilityChange)},leftSince:time=>exitedAt>=time||document.visibilityState===`hidden`}}function recordNetworkFailure(span,method,url,mechanism,cause){let message=`Network network ${method} ${url}`,chain=[{kind:`error`,mechanism:{handled:!1,type:mechanism},stack:``,type:`NetworkError`,value:message}];cause&&chain.push({kind:`error`,stack:``,type:cause.name,value:cause.message}),span.addEvent(`exception`,{"exception.message":message,"exception.type":`NetworkError`,"interfere.exception.chain":safeStringify(chain),"interfere.exception.handled":!1,"interfere.exception.kind":`error`,"interfere.exception.mechanism":mechanism,"interfere.exception.subtype":`network`})}function interceptSpanEnd(span,onEnd){let end=span.end.bind(span);span.end=endTime=>{onEnd(()=>{end(endTime)})}}function endAfterTransportHold(failedAt,pageExit,record,end){setTimeout(()=>{pageExit.leftSince(failedAt)||record(),end()},Math.max(0,failedAt+1e3-Date.now()))}function requestSignal(request){return request instanceof Request||request instanceof Object&&`signal`in request&&request.signal instanceof AbortSignal?request.signal:null}function fetchCancellation(request,error){let signal=requestSignal(request),name=error instanceof Error?error.name:void 0;return name===`TimeoutError`||signal?.aborted&&signal.reason instanceof Error&&signal.reason.name===`TimeoutError`?`timeout`:name===`AbortError`||signal?.aborted?`abort`:null}function isReadableSpan(span){return`events`in span}function xhrCancellation(span){return isReadableSpan(span)?span.events.some(event=>event.name===`timeout`)?`timeout`:span.events.some(event=>event.name===`abort`)?`abort`:null:null}function settleFetchFailure(span,request,error,pageExit,method,url,admit){let cancellation=fetchCancellation(request,error);if(cancellation){span.setAttribute(ATTR_HTTP_CANCELLED,cancellation);return}if(!(error instanceof Error))return;let failedAt=Date.now();interceptSpanEnd(span,end=>{endAfterTransportHold(failedAt,pageExit,()=>{admit()&&recordNetworkFailure(span,method,url,MECHANISM_TYPE.browser.fetchNetworkError,error)},end)})}function settleXhrFailure(span,pageExit,url,admit){let failedAt=Date.now();interceptSpanEnd(span,end=>{let cancellation=xhrCancellation(span);if(cancellation){span.setAttribute(ATTR_HTTP_CANCELLED,cancellation),end();return}endAfterTransportHold(failedAt,pageExit,()=>{admit()&&recordNetworkFailure(span,`XHR`,url,MECHANISM_TYPE.browser.xhrNetworkError,void 0)},end)})}export{settleFetchFailure as n,settleXhrFailure as r,createPageExitWatch as t};
@@ -1 +1 @@
1
- const hiddenHandlers=new Set,shownHandlers=new Set,unloadingHandlers=new Set;let installed=!1,hidden=!1;function fire(set){for(let handler of set)handler()}function documentHidden(){return globalThis.document?.visibilityState===`hidden`}function fireHidden(){hidden||(hidden=!0,fire(hiddenHandlers))}function fireShown(){hidden&&(hidden=!1,fire(shownHandlers))}function fireUnloading(){fire(unloadingHandlers)}function onVisibilityChange(){if(documentHidden()){fireHidden();return}fireShown()}function onPageShow(){documentHidden()||fireShown()}function install(){installed||typeof globalThis.addEventListener!=`function`||(installed=!0,hidden=documentHidden(),globalThis.addEventListener(`visibilitychange`,onVisibilityChange),globalThis.addEventListener(`pagehide`,fireHidden),globalThis.addEventListener(`pageshow`,onPageShow),globalThis.addEventListener(`beforeunload`,fireUnloading))}function onPageHidden(handler){return install(),hiddenHandlers.add(handler),(()=>{hiddenHandlers.delete(handler)})}function onPageShown(handler){return install(),shownHandlers.add(handler),(()=>{shownHandlers.delete(handler)})}function onPageUnloading(handler){return install(),unloadingHandlers.add(handler),(()=>{unloadingHandlers.delete(handler)})}function resetPageLifecycleForTests(){hiddenHandlers.clear(),shownHandlers.clear(),unloadingHandlers.clear(),installed&&typeof globalThis.removeEventListener==`function`&&(globalThis.removeEventListener(`visibilitychange`,onVisibilityChange),globalThis.removeEventListener(`pagehide`,fireHidden),globalThis.removeEventListener(`pageshow`,onPageShow),globalThis.removeEventListener(`beforeunload`,fireUnloading)),installed=!1,hidden=!1}export{resetPageLifecycleForTests as i,onPageShown as n,onPageUnloading as r,onPageHidden as t};
1
+ const hiddenHandlers=new Set,shownHandlers=new Set,unloadingHandlers=new Set;let installed=!1,hidden=!1;function fire(set){for(let handler of set)handler()}function documentHidden(){return globalThis.document?.visibilityState===`hidden`}function fireHidden(){hidden||(hidden=!0,fire(hiddenHandlers))}function fireShown(){hidden&&(hidden=!1,fire(shownHandlers))}function fireUnloading(){fire(unloadingHandlers)}function onVisibilityChange(){if(documentHidden()){fireHidden();return}fireShown()}function onPageShow(){documentHidden()||fireShown()}function install(){installed||typeof globalThis.addEventListener!=`function`||(installed=!0,hidden=documentHidden(),globalThis.addEventListener(`visibilitychange`,onVisibilityChange),globalThis.addEventListener(`pagehide`,fireHidden),globalThis.addEventListener(`pageshow`,onPageShow),globalThis.addEventListener(`beforeunload`,fireUnloading))}function onPageHidden(handler){return install(),hiddenHandlers.add(handler),(()=>{hiddenHandlers.delete(handler)})}function onPageShown(handler){return install(),shownHandlers.add(handler),(()=>{shownHandlers.delete(handler)})}function isPageHidden(){return install(),hidden}function onPageUnloading(handler){return install(),unloadingHandlers.add(handler),(()=>{unloadingHandlers.delete(handler)})}function resetPageLifecycleForTests(){hiddenHandlers.clear(),shownHandlers.clear(),unloadingHandlers.clear(),installed&&typeof globalThis.removeEventListener==`function`&&(globalThis.removeEventListener(`visibilitychange`,onVisibilityChange),globalThis.removeEventListener(`pagehide`,fireHidden),globalThis.removeEventListener(`pageshow`,onPageShow),globalThis.removeEventListener(`beforeunload`,fireUnloading)),installed=!1,hidden=!1}export{resetPageLifecycleForTests as a,onPageUnloading as i,onPageHidden as n,onPageShown as r,isPageHidden as t};