Skip to content

Event Protocol

This document defines the event data structure reported from SDK to Collector. It applies to all platform SDKs (H5, WeChat Mini Program, and future platforms).

Common Fields

Every event must include the following common fields:

FieldTypeRequiredDescription
eventIdstringYesUnique event identifier (UUID)
appKeystringYesUnique app identifier
platformstringYesPlatform: web / miniprogram / flutter
typestringYesEvent type: error / http / performance / breadcrumb
timestampnumberYesEvent timestamp in milliseconds
sessionIdstringYesSession identifier
anonymousIdstringYesAnonymous user identifier
sdkVersionstringYesSDK version
urlstringNoCurrent page URL (H5) or path (mini program)
userAgentstringNoUser agent string
breadcrumbsarrayNoAssociated breadcrumb list

Error Event (type: error)

json
{
  "eventId": "evt_xxx",
  "appKey": "web_abc123",
  "platform": "web",
  "type": "error",
  "timestamp": 1716192000000,
  "sessionId": "sess_xxx",
  "anonymousId": "anon_xxx",
  "sdkVersion": "0.1.0",
  "errorType": "js",
  "message": "Cannot read property 'foo' of undefined",
  "stack": "TypeError: ...\n    at foo (app.js:12:3)",
  "fingerprint": "js:abc123",
  "url": "https://example.com/page",
  "breadcrumbs": []
}

Error-specific Fields

FieldTypeDescription
errorTypestringError type: js / resource / promise / miniprogram
messagestringError message
stackstringStack trace
fingerprintstringError fingerprint for grouping identical errors
filenamestringError file (if available)
linenonumberLine number (if available)
colnonumberColumn number (if available)

Fingerprint Rules

fingerprint is used to aggregate identical errors into a single Issue:

  • JS errors: js:${hash(errorType + sanitized message + sanitized first stack line)}
  • Resource errors: resource:${hash(url)}
  • Promise errors: promise:${hash(message)}

Recommended hash: first 16 chars of MD5 or murmur3.

HTTP Event (type: http)

json
{
  "eventId": "evt_xxx",
  "appKey": "web_abc123",
  "platform": "web",
  "type": "http",
  "timestamp": 1716192000000,
  "sessionId": "sess_xxx",
  "anonymousId": "anon_xxx",
  "sdkVersion": "0.1.0",
  "method": "POST",
  "url": "https://api.example.com/users",
  "status": 500,
  "duration": 245,
  "success": false,
  "errorMessage": "Internal Server Error"
}

HTTP-specific Fields

FieldTypeDescription
methodstringHTTP method: GET / POST / PUT / DELETE etc.
urlstringRequest URL (sanitized)
statusnumberHTTP status code
durationnumberRequest duration in milliseconds
successbooleanWhether successful (status < 400)
errorMessagestringFailure reason (timeout, network error, etc.)

Performance Event (type: performance)

json
{
  "eventId": "evt_xxx",
  "appKey": "web_abc123",
  "platform": "web",
  "type": "performance",
  "timestamp": 1716192000000,
  "sessionId": "sess_xxx",
  "anonymousId": "anon_xxx",
  "sdkVersion": "0.1.0",
  "metricName": "LCP",
  "value": 1200,
  "rating": "good"
}

Performance-specific Fields

FieldTypeDescription
metricNamestringMetric name: LCP / FID / CLS / FCP / TTFB / INP
valuenumberMetric value
ratingstringRating: good / needs-improvement / poor

Breadcrumbs are usually attached to other events but can also be reported independently:

json
{
  "eventId": "evt_xxx",
  "appKey": "web_abc123",
  "platform": "web",
  "type": "breadcrumb",
  "timestamp": 1716192000000,
  "sessionId": "sess_xxx",
  "anonymousId": "anon_xxx",
  "sdkVersion": "0.1.0",
  "breadcrumbType": "navigation",
  "message": "User navigated to /checkout",
  "data": { "from": "/cart", "to": "/checkout" }
}
FieldTypeDescription
breadcrumbTypestringType: navigation / click / console / custom
messagestringDescription
dataobjectAdditional data

Batch Ingestion Format

SDKs report events in batches via POST /api/events/batch:

json
{
  "appKey": "web_abc123",
  "events": [
    { /* error event */ },
    { /* http event */ },
    { /* performance event */ }
  ]
}

Constraints:

  • events array must contain 1–50 items
  • Recommended batch interval: 3–5 seconds, or flush immediately at 10 items
  • On failure, keep events in local queue and retry with exponential backoff

Sanitization Rules

SDKs must sanitize the following before reporting:

Data LocationRule
URL queryRemove values for authorization, password, token, secret, cookie
HTTP bodyDo not report request body or response body
Stack traceRemove query parameters from URLs in frames
User infoUse business-provided userId or anonymous ID; do not collect real identity

Released under the MIT License.