feat(example): subscribe to form lifecycle events with debug modal#350
Merged
evan-masseau merged 1 commit intofeat/example-appfrom Apr 22, 2026
Merged
Conversation
Subscribe to Klaviyo.registerFormLifecycleHandler on mount in useForms so every shown/dismissed/CTA-click event is console.logged. Retain the event stream in a ring-buffer (capped at 100 entries, FIFO) in state and expose a FormLifecycleEventsModal (mirroring the GeofencesModal pattern) that renders a chronological log with per-event timestamps, formId/formName, and buttonLabel/deepLinkUrl for CTA-click events. Detail fields rendered via JSON.stringify so the modal doubles as a protocol inspector — documented valid empty strings show as "" rather than collapsing into a placeholder. Event keys are a monotonic id assigned at insertion so FlatList reconciler reuse is stable across prepends. FormsSection gets an ActionButton showing the running event count that opens the modal. Demonstrates the 2.4.0 registerFormLifecycleHandler API; subscribing unconditionally is safe — the SDK only emits events while forms are registered. Part of MAGE-464 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
dan-peluso
approved these changes
Apr 22, 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.
Description
Part 4 of 4 in the RN example-app overhaul chain for MAGE-464. Adds a live event log for
Klaviyo.registerFormLifecycleHandler— the new API introduced in RN SDK 2.4.0 — so integrators have a working reference implementation and a built-in protocol inspector for their QA sessions.Stacked on #345 (
ecm/example-app/4-native). This PR should be rebased ontofeat/example-app(or master, whichever is the eventual landing target) once #345 merges; the diff shown here is only the delta on top of that base.What changed
useForms— subscribes toregisterFormLifecycleHandleron mount (no toggle needed; SDK only emits while forms are registered). Stores events in a ring-buffer (FIFO, capped at 100) so a long QA session doesn't pin an ever-growing array.FormLifecycleEventsModal(new) — mirrors theGeofencesModalstructure. Renders aFlatListwith per-event timestamps,formId/formName, event type badge, andbuttonLabel/deepLinkUrlfor CTA-click events. Keys are a monotonic id assigned at insertion for stable FlatList reconciler reuse across prepends. Detail fields useJSON.stringifyso the modal functions as a protocol inspector —buttonLabel: ""renders as""rather than collapsing (the SDK documents empty-string as a valid value).FormsSection— newActionButtonshowing a live count of captured events that opens the modal.Due Diligence
Release/Versioning Considerations
PatchContains internal changes or backwards-compatible bug fixes.MinorContains changes to the public API.MajorContains breaking changes.Changelog / Code Overview
example/src/hooks/useForms.tsexample/src/components/FormLifecycleEventsModal.tsxexample/src/sections/FormsSection.tsxTest Plan
Here's how it looks


formId,formName, and timestampdismissedevent type badge appearsbuttonLabelanddeepLinkUrlare rendered (not collapsed), including whenbuttonLabelis an empty stringFormsSectiongoes to 0Related Issues/Tickets
Part of MAGE-464
Chained PR series:
🤖 Generated with Claude Code