Repository navigation
feat(userale): add createUserAle() factory, opt-in PrivacyOptions, and replay/exporter hardening - #225
Open
brucearctor wants to merge 2 commits into
Open
feat(userale): add createUserAle() factory, opt-in PrivacyOptions, and replay/exporter hardening#225brucearctor wants to merge 2 commits into
brucearctor wants to merge 2 commits into
Conversation
brucearctor
force-pushed
the
feat/userale-factory-privacy-hardening
branch
from
November 27, 2026 19:47
e8f9d61 to
cf8c31a
Compare
brucearctor
marked this pull request as ready for review
November 27, 2026 19:54
eusouluizlacerda
approved these changes
Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createUserAle()factory & per-instance isolation (src/runtime.ts,src/packageLogs.ts,src/attachHandlers.ts,src/sendLogs.ts,src/replay/index.ts,src/configure.ts,src/getInitialSettings.ts,src/utils/index.ts,src/exporters/headers.ts):WeakMap), exporters, interval tracking, event handlers, and replay controllers into isolated closures percreateUserAle()instance and perflagon-userale/manualruntime while keeping backwards compatibility for legacy singleton APIs.PrivacyOptions,preset: "strict",lockPrivacy(), and configurableevents(src/privacy.ts,src/configure.ts,src/packageLogs.ts,src/attachHandlers.ts,src/types.d.ts):capturePageUrl,capturePageTitle,capturePageReferrer,captureHost,captureUserAgent,captureScreenRes,captureLocation,captureTargetRect,captureDetails,captureMicroTime,attachTraceContext,ignoreUntrustedEvents,domSelectorMode,allowlistSelector,allowedAttributes) andpreset: "strict"with zero global reads for disabled fields.Configuration.update()against shallow nested overwrites,__proto__/method pollution, and unescapedRegExpmatching ingetUserIdFromParams().lockPrivacy()/isPrivacyLocked()to prevent post-init tampering acrossoptions(),addCallbacks(),log(),packageCustomLog(),details(),registerExporter(), andstartSessionReplay(), plus dynamicevents[]handler rebinding viaAbortController.src/domUtils.ts,src/packageLogs.ts,src/attachHandlers.ts):<form><input name="closest|parentNode|id|attributes|...">cannot bypass redaction or ignore markers, walks across openShadowRoothosts, handlesSVGAnimatedString, enforces[data-userale-ignore]precedence overallowlistSelector, and reads rawallowedAttributesfrom the matched allowlist ancestor.src/replay/index.ts,src/exporters/*,proto/apache/flagon/userale/v1/log.proto,example/log.schema.json):ReplayRingBufferpreserves priorMeta(type 4) anchors oncheckout, addsmaxBytescap, fixesRageClickDetectorempty-target/null-location false positives, adds[data-userale-redact]parity /maskAllText/!config.onguard, and routes> 48 KiBreplay flushes through configured exporters.HttpJsonExportermeasures UTF-8 bytes and awaits keepalive chunks sequentially;createExporter()honors explicitexporterType(including"otel-sdk") overotlpEndpoint;OtlpJsonExporterrespects null minimized session fields andattachTraceContext: false;OtelSdkExporteromits empty values;ProtoJsonExporterguards non-finite numbers, omits emptylocation/screenResolution, preserves nativegoogle.protobuf.Structvalues, and addstargetRect,traceId/spanId,LOG_TYPE_MUTATION, andLOG_TYPE_REPLAYtolog.proto;log.schema.jsonfixes"maxmaximumi"->"maximum"and validates privacy-minimized,interval,mutation, andreplaylogs.products/userale/test/spec/04-package-site-demo.spec.ts):window.userale?.options?.().on === trueafter load so Playwright interactions do not race the 100ms autostart setup timer on fast headless runners.Closes #217
Verification
pnpm --dir packages/flagon-userale build,tsc --noEmit -p packages/flagon-userale/tsconfig.json, and strict external consumer.d.tscompile (--strict --moduleResolution bundler --module esnext --target es2022forbuild/mainandbuild/manual)pnpm lint:check(0errors) andpnpm format:check(Prettier clean)pnpm --dir packages/flagon-userale test --runInBand:13 passed, 13 totalsuites;147 passed, 147 totaltests (includingtest/spec/factory_and_privacy.spec.tsand expandedexporters.spec.ts/replay.spec.ts)buf lint,buf breaking --against ".git#branch=upstream/master", andbuf generate