Skip to content

UJ support#102

Open
e271828- wants to merge 14 commits intomasterfrom
journeylytics
Open

UJ support#102
e271828- wants to merge 14 commits intomasterfrom
journeylytics

Conversation

@e271828-
Copy link
Copy Markdown
Contributor

@e271828- e271828- commented Mar 26, 2026

User Journeys

Phase 1 implements the journey runtime and the first shippable automatic capture path.

Scope of work:
- add a shared journey runtime with bounded buffering, navigation registration, and consumer lifecycle gating
- install automatic app wrapping through AppRegistry.setWrapperComponentProvider using an internal wrapper component
- capture initial automatic touch events (tap and basic drag) from the wrapper and screen transitions from a registered navigation container
- migrate the captcha bridge from execute(opts) payload injection to Android-aligned setData(widgetId, payload) followed by execute(widgetId)
- add verifyParams support with precedence over deprecated rqdata/phone fields
- wire ConfirmHcaptcha and Hcaptcha into journey consumer lifecycle management
- add focused runtime and captcha integration tests and update affected snapshots

Review notes applied before commit:
- removed render-time mutation by switching payload reads to peek semantics
- fixed re-entry behavior so the current screen is emitted again when collection restarts on the same route
- kept the public surface limited to init/register plus verifyParams and userJourney for this phase
Phase 2 improves the quality of automatic touch capture without changing the public journey surface.

Scope of work:
- classify scroll-like motion during touch move so axis-dominant gestures emit ScrollView start/end events instead of being inferred only at gesture end
- keep the event volume intentionally sparse by emitting only start/end transitions, with no continuous drag or scroll stream
- upgrade identifier resolution so semantic metadata from nativeID, testID, or accessibilityLabel can replace numeric target tags when richer information becomes available mid-gesture
- expand journey runtime tests to cover scroll classification, identifier upgrades, and semantic-over-numeric precedence

Review notes applied before commit:
- kept phase scope limited to runtime and wrapper behavior only
- avoided introducing any new public API or diagnostics surface in this commit
- verified that the resulting wire shape still uses the existing Android-compatible event schema
Phase 3 adds the remaining runtime ergonomics and diagnostics around automatic journey collection.

Scope of work:
- allow initJourneyTracking to enable optional journey debug logging without affecting default production behavior
- add an optional runtime stats callback that reports buffer size, consumer count, capture state, wrapper installation state, and current route snapshot for diagnostics and tests
- export JourneyTrackingOptions and JourneyRuntimeStats typings for the public init surface
- add test coverage for diagnostics behavior and for the existing ConfirmHcaptcha stopEvents() lifecycle path

Review notes applied before commit:
- kept diagnostics opt-in and side-effect free unless explicitly enabled
- preserved the existing capture lifecycle semantics while exposing observability around them
- limited the public API expansion to typed init options rather than adding another control surface
…alive

This change fixes the timing and lifecycle issues in the automatic journey implementation.

Scope of work:
- remove mount-time verifyData baking from the WebView HTML config and switch the initial verification path to a ready-handshake model
- emit an internal ready signal after hcaptcha.render(...) and inject a fresh setData(widgetId, payload) + execute(widgetId) script from React Native when the widget is ready
- keep the reset path data-driven while avoiding an unnecessary widget reset on the initial verify path
- change the journey runtime so capture continues after init even when the active consumer count falls back to zero, preserving app-level history between captcha mounts
- tighten current-route re-emission so enable/disable churn does not accumulate duplicate appear events when the current screen is already buffered
- make ConfirmHcaptcha.stopEvents() clear the current journey buffer without shutting down global post-init capture
- add tests for ring-buffer overflow, peek vs drain semantics, post-consumer buffering, ready-time payload injection, and error/cancel buffer preservation
- update snapshots to reflect the new internal ready handshake and removal of baked verifyData from HTML

Review notes applied before commit:
- the initial verify path now matches the plan and Android semantics by building payloads at verification time rather than render time
- runtime capture semantics now consistently follow the once-at-init model described in V3
- tests cover the previously missing lifecycle and buffering cases that could regress silently
@e271828- e271828- requested a review from CAMOBAP March 26, 2026 14:50
Align the journey runtime with the behavior validated in the example app manual runs.

This change fixes three concrete issues in the shipping package:
- resolve semantic identifiers from the full synthetic React Native event before falling back to native numeric targets, so nativeID/testID/accessibilityLabel survive real touch capture on iOS and Android
- round captured touch coordinates to integers before emitting journey events
- stop assuming ReactNativeVersion.version exists when building debug info; read the RN version defensively from Platform.constants.reactNativeVersion and ignore invalid shapes instead of throwing

It also restores and expands test coverage around the affected paths:
- add pure unit coverage for buildVerifyData and buildDebugInfo
- add runtime tests for integer coordinates and synthetic-event identifier resolution
- add verify-payload tests that prove legacy rqdata/phone fields still reach the final setData payload
- refresh snapshots for the updated debug-info output

Validated with:
- npx jest __tests__/journey.test.js __tests__/buildVerifyData.test.js __tests__/Hcaptcha.test.js __tests__/ConfirmHcaptcha.test.js --runInBand
- npx eslint Hcaptcha.js journey/runtime.js journey/wrapper.js __tests__/journey.test.js __tests__/buildVerifyData.test.js __tests__/Hcaptcha.test.js __tests__/ConfirmHcaptcha.test.js
# Conflicts:
#	__tests__/__snapshots__/ConfirmHcaptcha.test.js.snap
#	__tests__/__snapshots__/Hcaptcha.test.js.snap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant