The Web Ratings
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:complete event

This happens once when your page loads.

Opening the Widget

When a user triggers the review widget:

  1. Bottom sheet slides up with a loading state
  2. User identification happens automatically:
    • Uses currentUser if already created
    • Otherwise tries auto-detection (forms, localStorage, cookies, globals, URL params)
    • If no user found, widget closes with an error
  3. 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:

  1. Star rating step - tap a star to select (1–5), auto-advances on selection
  2. Review text step - write a review (20–1000 characters); submit button enabled when minimum met
  3. OTP step (first-time users) - verify email via 6-digit code
  4. Success screen - inline "Review published!" with Done button

Submission

When the user submits:

  1. Input is validated (rating selected + text ≥ 20 chars)
  2. User is created/identified if needed; OTP sent to email for new users
  3. The review is sent to your backend
  4. On success: Inline success screen shown; user clicks Done to close
  5. 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.