Verify your integration works correctly before going to production.
Sign up for the free plan and grab your public key from the dashboard under
API Keys — it works immediately and is safe to ship in client-side code. Use it
for local development and testing. Pass it to Tracio.init():
import { Tracio } from "@tracio/sdk"
const tracio = Tracio.init({ publicKey: "YOUR_PUBLIC_KEY" })const result = await tracio.getResult()console.log(result.visitorId, result.bot.detected)If you load the agent via the zero-build edge snippet, the same key works in the k query parameter:
<script src="https://edge.tracio.ai/s.js?k=YOUR_PUBLIC_KEY" async></script>Run this in the browser console of a page where the SDK is loaded to confirm it initializes and returns a result:
import { Tracio } from "@tracio/sdk"
const tracio = Tracio.init({ publicKey: "YOUR_PUBLIC_KEY" })const result = await tracio.getResult()console.assert(typeof result.visitorId === "string", "visitorId should be a string")console.assert(typeof result.bot.detected === "boolean", "bot.detected should be a boolean")console.log("Integration verified:", result.visitorId)In unit tests you typically do not want a real network call. Mock the Tracio module and assert that your code consumes getResult() correctly. With Vitest:
import { vi, test, expect } from "vitest"import { Tracio } from "@tracio/sdk"
vi.mock("@tracio/sdk", () => ({ Tracio: { init: () => ({ getResult: async () => ({ visitorId: "test-visitor-id", bot: { detected: false, confidence: 0 }, }), }), },}))
test("renders the visitor id", async () => { const tracio = Tracio.init({ publicKey: "YOUR_PUBLIC_KEY" }) const result = await tracio.getResult() expect(result.visitorId).toBe("test-visitor-id") expect(result.bot.detected).toBe(false)})You can also assert error handling by having the mocked getResult() reject with a TracioError.
To act on an identification result on your own server, receive it as a signed
webhook — each event is delivered to your endpoint with an
X-Tracio-Signature HMAC you can verify.