Skip to documentation
Coal Developer docs
User metricsAI integration guide
AI integration guideRead as Markdown

AI integration guide

Give your coding agent the right implementation path and the complete protocol context. Start with Events and metrics so it preserves the identities and reserved events required by the downstream metrics.

For AI coding tools

Use the Markdown version of this guide as context. It is the same maintained source as this page, including exact method names, limits, and protocol examples. The downloaded npm package includes guide.md, so an agent can read it offline.

Give your coding tool this instruction together with your app's actual consent and lifecycle code:

Integrate Coal's JavaScript event-collection SDK using its guide.
Initialize one instance after our consent flow permits collection.
Use the selected game's public ingestion key and the default hosted endpoint.
Override endpoint only for a local or separately hosted collector.
Await initialization. Track a small set of stable game actions.
Pair each progression outcome with its returned attempt ID.
Handle initialization failures and the SDK's onError diagnostics.
Verify offline retry/reload recovery and consent withdrawal.
Use the documented SDK download and public ingestion key.

Custom HTTP client prompt

Use the Direct API guide when implementing without the JavaScript SDK. Its Markdown version contains the exact wire contract; the complete reference includes shared concepts and verification guidance.

Implement a custom Coal HTTP client using POST /v1/events.
Use the game's public ingestion key in X-Coal-Ingestion-Key.
Use the endpoint and event envelope in the Direct API guide.
Own consent, persisted random installation identity, session state,
monotonic cumulative foreground time and progression attempt recovery.
Snapshot each event with a unique UUID and original UTC occurrence time.
Persist a bounded offline queue; retry unchanged events with backoff.
Remove events only after HTTP 200 acknowledges the submitted count.
Keep local test traffic separate from the production game scope.
Verify offline/restart recovery, reporting-off and background time.