Skip to main content

Verification & Testing

Verification Scope

Run this checklist:

  • before production go-live
  • after changing integration code
  • after updating siteKey, domain, API URL, or mobile key

Currency rule: all verification payloads use SITE_CURRENCY placeholder; replace with your ISO-4217 uppercase site currency.

1) Runtime Identity Checks

CDN mode

console.log(window.Selwise);
console.log(window.Selwise?.siteKey);
console.log(window.Selwise?.apiUrl);
console.log(window.Selwise?.getVisitorId?.());
console.log(window.Selwise?.getSessionId?.());

npm mode

console.log(widget.siteKey);
console.log(widget.apiUrl);
console.log(widget.getSiteUserId());
console.log(widget.getVisitorId());
console.log(widget.getSessionId());

React Native mode

console.log(sdk.getVisitorId());
console.log(sdk.getSessionId());
console.log(sdk.getJourneyState());

Expected:

  • runtime instance exists
  • IDs are generated
  • environment config matches expected target

2) Network Checks

Expected requests:

EndpointMethodPurpose
/public/sites/:siteKey/configGETruntime configuration
/public/sites/:siteKey/events/batchPOSTevent ingestion
/public/sites/:siteKey/ordersPOSTorder ingestion

Optional fallback config requests:

  • /public/sites/:siteKey/tracking-config
  • /public/sites/:siteKey/campaigns
  • /public/sites/:siteKey/widgets

React Native Header Check

For RN requests verify:

  • x-selwise-api-key
  • x-selwise-client-platform
  • x-selwise-client-version

3) Event Probe (Track API)

CDN or npm:

runtime.track('product_view', {
entityType: 'product',
entityId: 'prod_verification_001',
metadata: {
productItemCode: 'prod_verification_001',
title: 'Verification Product',
},
});

React Native:

sdk.track('product_view', {
entityType: 'product',
entityId: 'prod_verification_001',
metadata: { productItemCode: 'prod_verification_001' },
});

await sdk.flush();

4) Data-Layer Probe

runtime.pushDataLayer({
event: 'add_to_cart',
basket: {
id: 'cart_verify_001',
currency: 'SITE_CURRENCY',
total: 99.9,
products: [{ sku: 'prod_verification_001', quantity: 1, price: 99.9 }],
},
});

console.log(runtime.getDataLayer());

RN note:

  • pushDataLayer() verifies local state behavior.
  • network ingestion still depends on track() + flush().

5) Order Probe

await runtime.trackOrder({
orderId: 'ORDER-VERIFY-001',
total: 99.9,
currency: 'SITE_CURRENCY',
items: [{ productItemCode: 'prod_verification_001', quantity: 1, unitPrice: 99.9 }],
});
console.log(runtime.getConsentState());
runtime.grantConsent({ analytics: true, marketing: true, preferences: true });
runtime.revokeConsent(['marketing']);

RN note:

  • consent write endpoints require mobile_write scope.

7) Event Family Probe Set

Validate at least one event from each family:

  • Page: page_view
  • Product: product_view
  • Cart: add_to_cart
  • Checkout: checkout_begin
  • Purchase: purchase or trackOrder
  • Search: search_query
  • User: user_login
  • Custom: custom_event

Canonical payloads:

8) React Native Offline/Retry Probe

  1. Disable network.
  2. Call sdk.track(...) multiple times.
  3. Call await sdk.flush() (expect queued retries).
  4. Re-enable network.
  5. Call await sdk.flush() again.
  6. Verify queued events are drained successfully.

9) Common Failures

  1. Runtime instance missing.
  • CDN script issue, npm client lifecycle issue, or RN init failure.
  1. Events missing in backend.
  • Invalid canonical payload, consent gating, or environment mismatch.
  1. Mobile auth failures.
  • API key missing/revoked/invalid scope.
  1. Duplicate events.
  • Multiple active runtime instances.

Go-Live Checklist

  • Runtime identity checks pass for selected platform.
  • Config endpoint returns expected payload.
  • Event and order probes hit backend successfully.
  • Consent state transitions are reflected in behavior.
  • RN header/scope checks validated (if mobile integration exists).
  • Single runtime instance pattern enforced.

Next