Validation
Before an event is sent, the SDK runs client-side checks on the relevant fields. Failures log console.warn and that event is skipped (nothing is sent).
Rules
| Rule | Applies to |
|---|---|
page.type and page.url required |
page_view / any envelope needing page |
user.consent present; user.consent.gdpr_optin defined |
identify |
product.id, non-empty product.category_ids, and required display/pricing fields |
Product-related events |
basket.total number, basket.currency, non-empty basket.line_items; each line: product_id, currency, numeric line_total, quantity >= 1 |
Basket-related events |
At least one of listing.category_id, listing.slug, listing.search_query |
listing_view |
transaction.order_id, transaction.currency, numeric transaction.total, non-empty transaction.line_items; each line: product_id, currency, line_total, quantity >= 1 |
purchase |
sophi_object.page present when building an event |
Any send |
For product payloads, required fields also include: name, url, product_image_url, taxonomy, currency, unit_price, unit_sale_price, in_stock (in addition to id and category_ids).
Conventions
| Convention | Detail |
|---|---|
| Field names | snake_case in JSON |
| Timestamps | Epoch seconds (integer) |
| Currency | ISO 4217 |
| Language / locale | BCP-47 |
| Phone | E.164 with leading + |
| IDs | Your source-system external IDs, not internal Sophi DB ids |
custom bags |
Optional Record<string, unknown> on each object type |
event_type override |
sophi_object.event_type or push({ event_type, ... }) |