Migration Modal Event Communication
The Anon modal uses a structured event system to communicate user interactions and modal state to the parent window when embedded as an iframe. Events are sent viawindow.postMessage and always include user and migration context.
Event Types & Payloads
All events have the following payload components:Unique identifier for the event
Always set to
"event"ISO 8601 timestamp of when the event was created
Event type. One of:
migration_modal.opened, migration_modal.completed, migration_modal.closed, migration_modal.failed, migration_modal_step.started, migration_modal_step.submitted, migration_modal_step.completed, migration_modal_step.failedEvent-specific data containing user and migration context
| Event Type | When Emitted | Data Provided |
|---|---|---|
migration_modal.opened | Modal first displayed | {} |
migration_modal.completed | Migration successfully started | {} |
migration_modal.closed | User exits before migration start | { "modal_step": "<string>" } |
migration_modal.failed | Unrecoverable error | { "modal_step": "<string>", "error_message": "<string>" } |
migration_modal_step.started | Step displayed to user | { "modal_step": "<string>" } |
migration_modal_step.submitted | User submitted step (intent) | { "modal_step": "<string>" } |
migration_modal_step.completed | Step processed successfully | { "modal_step": "<string>" } |
migration_modal_step.failed | Step failed (validation or system) | { "modal_step": "<string>", "error_message": "<string>" } |
Receiving Events in the Parent Window
To listen for modal events, add amessage event listener in your parent application. Always check the event source and type:
Event Flows
Below are typical event flows for different user and system scenarios.- Successful Migration
- Validation or Login Error
- Unrecoverable Error
Best Practices:
- Always verify the event source and origin.
- Use the event type and data to drive analytics, UI, or business logic.
- All events include
user_idandmigration_idfor context. - The event system deduplicates identical events within a 3-second window.