Going Deeper
Life Cycle
How TheWebRatings initializes and works
Initialization
When you call TheWebRatings.init():
- Validates your API key
- Fetches your app info (name, etc.) from the backend
- Sets up styling (and custom colors if provided)
- Starts auto-prompt session tracking (if enabled)
- Emits
init:completeevent
This happens once when your page loads.
Opening the Widget
When a user triggers the review widget:
- Bottom sheet slides up with a loading state
- User identification happens automatically:
- Uses
currentUserif already created - Otherwise tries auto-detection (forms, localStorage, cookies, globals, URL params)
- If no user found, widget closes with an error
- Uses
- Existing review check - verifies if this user already submitted a review
Two User Paths
Path A: Existing Review Found
Shows the user their previous review:
- Rating displayed as stars
- Previous review text
- Submission date
- Edit button - update rating and review text
- Delete button - remove the review (with confirmation screen)
Path B: New Review
Steps through the review flow:
- Star rating step - tap a star to select (1–5), auto-advances on selection
- Review text step - write a review (20–1000 characters); submit button enabled when minimum met
- OTP step (first-time users) - verify email via 6-digit code
- Success screen - inline "Review published!" with Done button
Submission
When the user submits:
- Input is validated (rating selected + text ≥ 20 chars)
- User is created/identified if needed; OTP sent to email for new users
- The review is sent to your backend
- On success: Inline success screen shown; user clicks Done to close
- On error: The review is stored locally for retry later; error event emitted for your handling
Closing
Users can close the widget by:
- Clicking the X button
- Clicking outside the bottom sheet (backdrop)
- Clicking "Done" on the success/delete screen
The widget cannot be closed during submission or OTP verification.