@interfere/react 12.0.5 → 12.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -0
- package/dist/actionable-DOmVf_ib.mjs +1 -0
- package/dist/activity-D18VXGTn.mjs +1 -0
- package/dist/{activity-BfYxFVcK.d.mts → activity-Duhfgvxt.d.mts} +1 -1
- package/dist/{api-DEVCOKkJ.d.mts → api-CMPV9rgU.d.mts} +1 -1
- package/dist/api-DXmjUMZE.mjs +1 -0
- package/dist/api.mjs +1 -1
- package/dist/bot-YLSbnCeg.mjs +1 -0
- package/dist/buffer-BRn_kSm-.mjs +1 -0
- package/dist/capture-BV2RlsYg.mjs +1 -0
- package/dist/capture-boundary-Cz0jO-y5.mjs +1 -0
- package/dist/chunking-Dvs3f50A.d.mts +39 -0
- package/dist/chunking-qZffPbyY.mjs +2 -0
- package/dist/compressor-host-BAz6860r.d.mts +9 -0
- package/dist/compressor-host-CrKngamF.mjs +1 -0
- package/dist/config-Bm8myQlS.mjs +1 -0
- package/dist/config-CBqqY1AV.d.mts +29 -0
- package/dist/config-DapTbKhs.mjs +1 -0
- package/dist/{config-Rm-ct4K1.d.mts → config-Dyc09HCZ.d.mts} +2 -1
- package/dist/consent-COUmLJLD.mjs +1 -0
- package/dist/console-patch-WNKoLE7U.mjs +1 -0
- package/dist/delivery-DehIJWRh.mjs +1 -0
- package/dist/device-6T3DYkLD.mjs +1 -0
- package/dist/device-DRK7hhLi.mjs +1 -0
- package/dist/device-metadata-Ffi__vup.mjs +1 -0
- package/dist/{dist-ByNfzdQp.mjs → dist-Bcb677YG.mjs} +2 -2
- package/dist/environment-CoEXhF1a.mjs +1 -0
- package/dist/environment-_LKcAXKG.d.mts +9 -0
- package/dist/error-boundary.d.mts +1 -1
- package/dist/error-boundary.mjs +1 -1
- package/dist/errors-BDmCWb5z.mjs +1 -0
- package/dist/event-capabilities-Dd0Hoaq2.mjs +1 -0
- package/dist/exporter-3w57pctH.mjs +1 -0
- package/dist/exporter-logs-DS2AXWnV.mjs +1 -0
- package/dist/exporter-metrics-DZYqUo6_.mjs +1 -0
- package/dist/geo-D2wa9bGs.mjs +2 -0
- package/dist/global-DYq1Z4_H.mjs +1 -0
- package/dist/http-span-route-t2gig-KI.mjs +1 -0
- package/dist/hydration-BIp2cKhz.mjs +1 -0
- package/dist/index-DBsXraeJ.d.mts +4 -0
- package/dist/initial-navigation-YeK6UUHX.mjs +1 -0
- package/dist/{instrumentations-Bgm2EazU.d.mts → instrumentations-BuccMAMj.d.mts} +8 -1
- package/dist/instrumentations-CY8NcP_M.mjs +1 -0
- package/dist/internal/{activity.d.mts → activity/activity.d.mts} +1 -1
- package/dist/internal/activity/activity.mjs +1 -0
- package/dist/internal/browser-context.mjs +1 -1
- package/dist/internal/capture-boundary.d.mts +1 -1
- package/dist/internal/capture-boundary.mjs +1 -1
- package/dist/internal/capture.d.mts +1 -1
- package/dist/internal/capture.mjs +1 -1
- package/dist/internal/config.d.mts +2 -28
- package/dist/internal/config.mjs +1 -1
- package/dist/internal/consent.mjs +1 -1
- package/dist/internal/console-patch.mjs +1 -1
- package/dist/internal/device-metadata.d.mts +41 -0
- package/dist/internal/device-metadata.mjs +1 -0
- package/dist/internal/dom/actionable.d.mts +4 -13
- package/dist/internal/dom/actionable.mjs +1 -1
- package/dist/internal/dom/privacy.d.mts +2 -0
- package/dist/internal/dom/privacy.mjs +1 -0
- package/dist/internal/environment.d.mts +2 -0
- package/dist/internal/environment.mjs +1 -0
- package/dist/internal/event-capabilities.d.mts +3 -0
- package/dist/internal/event-capabilities.mjs +1 -0
- package/dist/internal/hydration.mjs +1 -1
- package/dist/internal/kernel-registry.d.mts +1 -1
- package/dist/internal/kernel-registry.mjs +1 -1
- package/dist/internal/kernel.d.mts +5 -3
- package/dist/internal/kernel.mjs +1 -1
- package/dist/internal/otel/exporter-logs.mjs +1 -1
- package/dist/internal/otel/exporter-metrics.mjs +1 -1
- package/dist/internal/otel/exporter.mjs +1 -1
- package/dist/internal/otel/http-span-route.mjs +1 -1
- package/dist/internal/otel/index.d.mts +3 -3
- package/dist/internal/otel/index.mjs +1 -1
- package/dist/internal/otel/initial-navigation.d.mts +1 -0
- package/dist/internal/otel/initial-navigation.mjs +1 -1
- package/dist/internal/otel/instrumentations.d.mts +1 -1
- package/dist/internal/otel/instrumentations.mjs +1 -1
- package/dist/internal/otel/navigation.mjs +1 -1
- package/dist/internal/otel/normalize-path.mjs +1 -1
- package/dist/internal/otel/page-scope-context-manager.mjs +1 -1
- package/dist/internal/otel/propagation.mjs +1 -1
- package/dist/internal/otel/provider.d.mts +1 -1
- package/dist/internal/otel/provider.mjs +1 -1
- package/dist/internal/otel/url-attrs.mjs +1 -1
- package/dist/internal/otel/web-vitals.mjs +1 -1
- package/dist/internal/{page-lifecycle.d.mts → page-lifecycle/page-lifecycle.d.mts} +1 -1
- package/dist/internal/page-lifecycle/page-lifecycle.mjs +1 -0
- package/dist/internal/plugins/plugin-runtime.d.mts +2 -0
- package/dist/internal/plugins/plugin-runtime.mjs +1 -0
- package/dist/internal/react-context.d.mts +1 -1
- package/dist/internal/react-context.mjs +1 -1
- package/dist/internal/server-digest.mjs +1 -1
- package/dist/internal/third-party-hosts.mjs +1 -1
- package/dist/internal/version.mjs +1 -1
- package/dist/internal/wrapper-singleton.d.mts +1 -1
- package/dist/internal/wrapper-singleton.mjs +1 -1
- package/dist/kernel-CwyJyyNf.mjs +1 -0
- package/dist/kernel-registry-6f-3VCIy.mjs +1 -0
- package/dist/loader-BGwWwN2n.mjs +1 -0
- package/dist/log-D6Ht--tv.mjs +1 -0
- package/dist/navigation-DwkvuhFR.mjs +1 -0
- package/dist/normalize-path-BChqP8pA.mjs +1 -0
- package/dist/page-events-config-CiJvdAaJ.d.mts +12 -0
- package/dist/{internal/page-lifecycle.mjs → page-lifecycle-BhSFqjlK.mjs} +1 -1
- package/dist/page-scope-context-manager-DhArvVJ_.mjs +1 -0
- package/dist/plugin-runtime-CnFVGbJw.mjs +1 -0
- package/dist/plugins/device.d.mts +1 -1
- package/dist/plugins/device.mjs +1 -1
- package/dist/plugins/errors.d.mts +1 -1
- package/dist/plugins/errors.mjs +1 -1
- package/dist/plugins/lib/loader.d.mts +1 -1
- package/dist/plugins/lib/loader.mjs +1 -1
- package/dist/plugins/lib/types.d.mts +1 -1
- package/dist/plugins/logs.d.mts +1 -1
- package/dist/plugins/logs.mjs +1 -1
- package/dist/plugins/page-events-config.d.mts +2 -0
- package/dist/plugins/page-events-config.mjs +1 -0
- package/dist/plugins/page-events.d.mts +1 -1
- package/dist/plugins/rage-clicks.d.mts +1 -1
- package/dist/plugins/rage-clicks.mjs +1 -1
- package/dist/plugins/replay/buffer.d.mts +1 -1
- package/dist/plugins/replay/buffer.mjs +1 -1
- package/dist/plugins/replay/chunking.d.mts +2 -38
- package/dist/plugins/replay/chunking.mjs +1 -2
- package/dist/plugins/replay/compressor-host.d.mts +2 -8
- package/dist/plugins/replay/compressor-host.mjs +1 -1
- package/dist/plugins/replay/config.d.mts +1 -1
- package/dist/plugins/replay/config.mjs +1 -1
- package/dist/plugins/replay/delivery.d.mts +4 -4
- package/dist/plugins/replay/delivery.mjs +1 -1
- package/dist/plugins/replay/index.d.mts +1 -1
- package/dist/plugins/replay/index.mjs +1 -1
- package/dist/plugins/replay/recorder.d.mts +1 -1
- package/dist/plugins/replay/recorder.mjs +1 -1
- package/dist/plugins/replay/redact-urls.d.mts +6 -0
- package/dist/plugins/replay/redact-urls.mjs +1 -0
- package/dist/plugins/replay/sequence.mjs +1 -1
- package/dist/plugins/replay/upload.d.mts +1 -1
- package/dist/plugins/replay/upload.mjs +1 -1
- package/dist/privacy-CPKosXDP.d.mts +31 -0
- package/dist/privacy-CRuL0X8r.mjs +1 -0
- package/dist/propagation-DVcqCu_E.mjs +1 -0
- package/dist/{provider-DWgb6tn9.d.mts → provider-C68KiG80.d.mts} +55 -39
- package/dist/provider-DlD5S0wG.mjs +1 -0
- package/dist/{provider-2LrbA-ld.d.mts → provider-VZtcX6ZS.d.mts} +4 -1
- package/dist/provider.d.mts +4 -3
- package/dist/provider.mjs +1 -1
- package/dist/react-context-c1uTUJfB.mjs +1 -0
- package/dist/react-error-handler.d.mts +1 -1
- package/dist/react-error-handler.mjs +1 -1
- package/dist/recorder-CM6Ae_0S.mjs +1 -0
- package/dist/redact-urls-CwFod9d4.mjs +1 -0
- package/dist/sequence-B4dYChb0.mjs +1 -0
- package/dist/server-digest-CzGdvjW1.mjs +1 -0
- package/dist/session-C30CtCVv.mjs +1 -0
- package/dist/session-retry-DJHvfDaO.mjs +1 -0
- package/dist/stringify-DvuHsAT4.mjs +1 -0
- package/dist/third-party-hosts-BoJNL3xG.mjs +1 -0
- package/dist/tracking/api.d.mts +1 -1
- package/dist/tracking/api.mjs +1 -1
- package/dist/tracking/device.mjs +1 -1
- package/dist/tracking/geo.mjs +1 -2
- package/dist/tracking/registration.fixture.d.mts +119 -109
- package/dist/tracking/registration.fixture.mjs +148 -26
- package/dist/tracking/session-retry.mjs +1 -1
- package/dist/tracking/session.mjs +1 -1
- package/dist/upload-BPaD3YcA.mjs +1 -0
- package/dist/url-attrs-BdcyE2n6.mjs +1 -0
- package/dist/util/bot.d.mts +1 -0
- package/dist/util/bot.mjs +1 -1
- package/dist/util/global.mjs +1 -1
- package/dist/util/log.mjs +1 -1
- package/dist/util/stringify.mjs +1 -1
- package/dist/{version-CsfyuVoF.mjs → version-B5O6bg5e.mjs} +1 -1
- package/dist/web-vitals-CxXDUgpl.mjs +1 -0
- package/package.json +7 -7
- package/dist/index-DvFfO2V9.d.mts +0 -4
- package/dist/internal/activity.mjs +0 -1
- package/dist/internal/plugin-runtime.d.mts +0 -2
- package/dist/internal/plugin-runtime.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{t as SessionRetry}from"../session-retry-DJHvfDaO.mjs";export{SessionRetry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as SessionManager}from"../session-C30CtCVv.mjs";export{SessionManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function uploadReplayChunk(target,sessionId,body,headers){let requestHeaders=new Headers(target.headers);target.publicKeyHeader&&requestHeaders.set(`x-interfere-public-key`,target.publicKeyHeader.apiKey);for(let[name,value]of Object.entries(headers))requestHeaders.set(name,value);return requestHeaders.set(`content-type`,`application/octet-stream`),fetch(new URL(`/v3/replay/upload/${encodeURIComponent(sessionId)}`,target.baseUrl),{method:`POST`,credentials:`omit`,headers:requestHeaders,body:new Blob([body]),signal:AbortSignal.timeout(target.timeoutInSeconds*1e3)})}export{uploadReplayChunk as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const ATTR_HTTP_ROUTE=`http.route`,ATTR_URL_FULL=`url.full`,ATTR_URL_PATH=`url.path`;function stampUrlAttrs(span,resolveRoute){if(typeof window>`u`)return;let{pathname}=globalThis.location,route=resolveRoute?.(pathname);span.setAttribute(ATTR_URL_PATH,route??pathname),span.setAttribute(ATTR_URL_FULL,globalThis.location.href),route&&span.setAttribute(ATTR_HTTP_ROUTE,route)}export{stampUrlAttrs as i,ATTR_URL_FULL as n,ATTR_URL_PATH as r,ATTR_HTTP_ROUTE as t};
|
package/dist/util/bot.d.mts
CHANGED
package/dist/util/bot.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as isBotUserAgent,t as classifyBrowserAutomation}from"../bot-YLSbnCeg.mjs";export{classifyBrowserAutomation,isBotUserAgent};
|
package/dist/util/global.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{n as getStringGlobal,r as setGlobal,t as getGlobal}from"../global-DYq1Z4_H.mjs";export{getGlobal,getStringGlobal,setGlobal};
|
package/dist/util/log.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{n as getLogLevel,r as setLogLevel,t as createLogger}from"../log-D6Ht--tv.mjs";export{createLogger,getLogLevel,setLogLevel};
|
package/dist/util/stringify.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{t as safeStringify}from"../stringify-DvuHsAT4.mjs";export{safeStringify};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var name=`@interfere/react`,version=`12.
|
|
1
|
+
var name=`@interfere/react`,version=`12.1.1`;const SDK_NAME=name,SDK_VERSION=version,PRODUCER_VERSION=`${SDK_NAME}@${SDK_VERSION}`;export{SDK_NAME as n,SDK_VERSION as r,PRODUCER_VERSION as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{omitUndefined}from"@interfere/helpers/omit-undefined";import{onCLS,onFCP,onINP,onLCP,onTTFB}from"web-vitals";const LOAD_VITALS=new Set([`TTFB`,`FCP`,`LCP`]);function captureWebVitals(input){if(typeof window>`u`)return;let{meter,resolveRoute,flush}=input,lcp=meter.createHistogram(`web_vitals.lcp`,{advice:{explicitBucketBoundaries:[.5,1,1.5,2,2.5,3,4,5,7.5,10]},description:`Largest Contentful Paint`,unit:`s`}),fcp=meter.createHistogram(`web_vitals.fcp`,{advice:{explicitBucketBoundaries:[.5,1,1.5,1.8,2,2.5,3,4,5,7.5]},description:`First Contentful Paint`,unit:`s`}),ttfb=meter.createHistogram(`web_vitals.ttfb`,{advice:{explicitBucketBoundaries:[.1,.2,.3,.5,.8,1,1.5,2,3,5]},description:`Time to First Byte`,unit:`s`}),inp=meter.createHistogram(`web_vitals.inp`,{advice:{explicitBucketBoundaries:[.05,.1,.15,.2,.3,.4,.5,.75,1,2]},description:`Interaction to Next Paint`,unit:`s`}),vitals={CLS:{histogram:meter.createHistogram(`web_vitals.cls`,{advice:{explicitBucketBoundaries:[.01,.025,.05,.075,.1,.15,.2,.25,.5,1]},description:`Cumulative Layout Shift`,unit:`1`}),toSeconds:!1},FCP:{histogram:fcp,toSeconds:!0},INP:{histogram:inp,toSeconds:!0},LCP:{histogram:lcp,toSeconds:!0},TTFB:{histogram:ttfb,toSeconds:!0}},received=new Set,flushed=!1;function report(metric){let entry=vitals[metric.name];if(entry===void 0)return;let value=entry.toSeconds?metric.value*.001:metric.value,{pathname}=globalThis.location,route=resolveRoute?.(pathname)??pathname;entry.histogram.record(value,omitUndefined({"url.path":route,"web_vital.rating":metric.rating||void 0,"web_vital.navigation_type":metric.navigationType||void 0})),!flushed&&LOAD_VITALS.has(metric.name)&&(received.add(metric.name),received.size===LOAD_VITALS.size&&(flushed=!0,flush().catch(()=>{})))}onLCP(report),onCLS(report),onINP(report),onTTFB(report),onFCP(report)}export{captureWebVitals as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interfere/react",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"description": "Client-side React SDK for Interfere. Error tracking, session replay, and analytics.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"error-tracking",
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@fingerprintjs/fingerprintjs": "^5.2.0",
|
|
96
96
|
"@interfere/constants": "^9.2.0",
|
|
97
|
-
"@interfere/helpers": "^9.2.
|
|
97
|
+
"@interfere/helpers": "^9.2.1",
|
|
98
98
|
"@interfere/javascript": "^0.2.1",
|
|
99
|
-
"@interfere/types": "^10.
|
|
99
|
+
"@interfere/types": "^10.3.0",
|
|
100
100
|
"@opentelemetry/api": "^1.9.1",
|
|
101
101
|
"@opentelemetry/api-logs": "^0.222.0",
|
|
102
102
|
"@opentelemetry/context-zone": "^2.11.0",
|
|
@@ -134,9 +134,9 @@
|
|
|
134
134
|
"@types/react": "19.2.18",
|
|
135
135
|
"@types/react-dom": "19.2.7",
|
|
136
136
|
"@vitejs/plugin-react": "^6.1.1",
|
|
137
|
-
"@vitest/browser": "5.0.
|
|
138
|
-
"@vitest/browser-playwright": "5.0.
|
|
139
|
-
"@vitest/coverage-v8": "5.0.
|
|
137
|
+
"@vitest/browser": "5.0.5",
|
|
138
|
+
"@vitest/browser-playwright": "5.0.5",
|
|
139
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
140
140
|
"babel-plugin-react-compiler": "1.0.0",
|
|
141
141
|
"fflate": "^0.8.3",
|
|
142
142
|
"msw": "^2.14.6",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"react-dom": "19.3.0",
|
|
146
146
|
"tsdown": "^0.23.0",
|
|
147
147
|
"typescript": "^7.0.2",
|
|
148
|
-
"vitest": "5.0.
|
|
148
|
+
"vitest": "5.0.5",
|
|
149
149
|
"vitest-browser-react": "2.3.0"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createLogger}from"../util/log.mjs";import{onPageShown}from"./page-lifecycle.mjs";const log=createLogger(`activity`),IDLE_AFTER_MS=3e5,EXPIRE_AFTER_MS=9e5,MAX_AGE_MS=864e5,CHECK_INTERVAL_MS=3e4,KEEPALIVE_THROTTLE_MS=1e3,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;paused=!1;lastActivityMs=0;keepaliveUntilMs=0;checkTimer=null;unsubscribeShown=null;pauseHandlers=new Set;resumeHandlers=new Set;onPause(handler){return subscribe(this.pauseHandlers,handler)}onResume(handler){return subscribe(this.resumeHandlers,handler)}start(session){if(this.checkTimer===null&&typeof globalThis.addEventListener==`function`){this.session=session,this.paused=!1,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.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.unsubscribeShown=null,this.session=null,this.paused=!1,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}poll=()=>{this.paused||(this.isOverMaxAge()||this.idleMs()>=3e5)&&(this.paused=!0,log.debug(`session paused`),fire(this.pauseHandlers,void 0))};onInput=()=>{let now=monotonicNow();if(this.isOverMaxAge()||now-this.lastActivityMs>=9e5){this.resume(now,`rotated`);return}if(this.paused){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.paused=!1,this.touch(now),this.session?.markActivity(),fire(this.resumeHandlers,reason)}touch(now){this.lastActivityMs=now,this.keepaliveUntilMs=now+KEEPALIVE_THROTTLE_MS}};export{ActivityMonitor,CHECK_INTERVAL_MS,EXPIRE_AFTER_MS,IDLE_AFTER_MS,KEEPALIVE_THROTTLE_MS,MAX_AGE_MS};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createLogger}from"../util/log.mjs";import{getPluginConsentCategory,hasConsentChanged,isConsentAllowed,resolveGrantedConsent}from"./consent.mjs";import devicePlugin from"../plugins/device.mjs";import errorsPlugin from"../plugins/errors.mjs";import{loadPlugin,resolveFeatures}from"../plugins/lib/loader.mjs";import{PLUGIN_MANIFEST}from"@interfere/types/sdk/plugins/manifest";const log=createLogger(`plugin-runtime`);var PluginRuntime=class{activeCleanups=new Map;pending=new Set;features=resolveFeatures();pluginConfigListeners=new Map;remoteConfig={};remoteConfigSettled=!1;consentState=null;configSettled=!1;replayConfig={};syncVersion=0;disposed=!1;context;hasInitialConsent;constructor(context,consent,remoteConfig={}){this.context=context,this.hasInitialConsent=consent!==void 0,this.consentState=consent===void 0?null:resolveGrantedConsent(consent),this.configSettled=this.hasInitialConsent,this.remoteConfig=remoteConfig}getConsent(){return this.consentState}getReplayConfig(){return this.replayConfig}applyProviderConfig(overrides,consent){let replay=overrides?.replay;this.features=resolveFeatures(overrides),this.replayConfig=typeof replay==`object`?replay:{},consent===void 0?this.hasInitialConsent||(this.consentState=null):this.consentState=resolveGrantedConsent(consent),this.configSettled=!0,this.sync()}setConsent(nextConsent){let nextState=resolveGrantedConsent(nextConsent);(!this.configSettled||hasConsentChanged(this.consentState,nextState))&&(this.consentState=nextState,this.configSettled=!0,this.sync())}resetConsent(){(!this.configSettled||hasConsentChanged(this.consentState,null))&&(this.consentState=null,this.configSettled=!0,this.sync())}applyRemoteConfig(config){this.remoteConfig=config,this.remoteConfigSettled=!0,this.emitPluginConfigState(),this.sync()}applyRemoteConfigDefaults(){this.remoteConfigSettled=!0,this.emitPluginConfigState(),this.sync()}start(){for(let[key,plugin]of[[`errors`,errorsPlugin],[`device`,devicePlugin]])if(this.shouldEnablePlugin(key)){let cleanup=plugin.setup(this.context);cleanup&&this.activeCleanups.set(key,cleanup)}this.sync()}async dispose(){this.disposed=!0,this.syncVersion+=1;for(let key of this.activeCleanups.keys())this.deactivate(key,`dispose`);await Promise.allSettled(this.pending)}shouldEnablePlugin(key){let category=getPluginConsentCategory(key);return category!==`necessary`&&!this.configSettled?!1:this.features[key]&&this.remoteConfig[key]!==!1&&isConsentAllowed(category,this.consentState)}getPluginConfigState(key){return this.remoteConfigSettled?this.remoteConfig[key]===!1?`disabled`:`enabled`:`pending`}subscribePluginConfigState(key,listener){let listeners=this.pluginConfigListeners.get(key)??new Set;return listeners.add(listener),this.pluginConfigListeners.set(key,listeners),(()=>{listeners.delete(listener),listeners.size===0&&this.pluginConfigListeners.delete(key)})}emitPluginConfigState(){for(let[key,listeners]of this.pluginConfigListeners){let state=this.getPluginConfigState(key);for(let listener of listeners)listener(state)}}teardownReason(key){let category=getPluginConsentCategory(key);return isConsentAllowed(category,this.consentState)?`disabled`:`consent-revoked`}deactivate(key,reason){let cleanup=this.activeCleanups.get(key);if(cleanup){try{cleanup(reason)}catch{log.warn(`cleanup failed for %s`,key)}this.activeCleanups.delete(key)}}async activate(key){if(this.activeCleanups.has(key)||!this.shouldEnablePlugin(key))return;let version=this.syncVersion,cleanup=await loadPlugin(key,this.context);if(cleanup){if(version!==this.syncVersion||!this.shouldEnablePlugin(key)){cleanup(this.teardownReason(key));return}this.activeCleanups.set(key,cleanup)}}sync(){if(!this.disposed){this.syncVersion+=1;for(let plugin of PLUGIN_MANIFEST){if(this.shouldEnablePlugin(plugin.name)){if(plugin.name===`errors`){if(!this.activeCleanups.has(`errors`)){let cleanup=errorsPlugin.setup(this.context);cleanup&&this.activeCleanups.set(`errors`,cleanup)}continue}let p=(async()=>{try{await this.activate(plugin.name)}catch{log.warn(`non-critical plugin loading failed`)}})();this.pending.add(p),(async()=>{await p,this.pending.delete(p)})();continue}this.deactivate(plugin.name,this.teardownReason(plugin.name))}}}};export{PluginRuntime};
|