Frontend IntegrationWeb ObjectValidation

Validation

Before an event is sent, @usesophi/sophi-web-object runs client-side field validation; failures log a console.warn and the event is skipped without any network request.

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

RuleApplies to
page.type and page.url requiredpage_view / any envelope needing page
user.consent present; user.consent.gdpr_optin definedidentify
product.id, non-empty product.category_ids, and required display/pricing fieldsProduct-related events
basket.total number, basket.currency, non-empty basket.line_items; each line: product_id, currency, numeric line_total, quantity >= 1Basket-related events
At least one of listing.category_id, listing.slug, listing.search_querylisting_view
transaction.order_id, transaction.currency, numeric transaction.total, non-empty transaction.line_items; each line: product_id, currency, line_total, quantity >= 1purchase
sophi_object.page present when building an eventAny 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

ConventionDetail
Field namessnake_case in JSON
TimestampsEpoch seconds (integer)
CurrencyISO 4217
Language / localeBCP-47
PhoneE.164 with leading +
IDsYour source-system external IDs, not internal Sophi DB ids
custom bagsOptional Record<string, unknown> on each object type
event_type overridesophi_object.event_type or push({ event_type, ... })

On this page