Streakfox
SDKs

Web SDK

A preview JavaScript package for reading a member's streak. Not yet on npm.

Preview, not yet on npm. @streakdev/web isn't published, so installing it fails today. This page describes the preview API so you can plan for it.

What works today

What the package will do

The Web SDK reads progress for your own UI. It doesn't count actions. Counting stays on your server.

createClient(options)

import { createClient } from "@streakdev/web";

const client = createClient({ baseUrl: "https://api.streakfox.com" });
OptionWhat it does
baseUrlAPI endpoint. Defaults to https://api.streakfox.com.
aliasTokenShort-lived signed identity token. Needed before reward values are revealed.
adminTokenServer only. Required for aliasUser(). Never ship it to a browser.
headersExtra request headers.

client.getState(input)

Fetches a member's progress for one action.

const state = await client.getState({
  projectId: "YOUR_PROJECT_KEY",
  event: "YOUR_ACTION",
  userHash: "MEMBER_ID",
});

state.streak.current; // current streak or running total
state.streak.best; // best ever
state.week; // the last 7 days

projectId takes your project key. event takes your action. userHash is the member ID you count with.

client.aliasUserWithToken(input)

Links the browser's anonymous visitor to a signed-in member, using a short-lived token your server creates. See Connecting users.

await client.aliasUserWithToken({ projectId: "YOUR_PROJECT_KEY", token: tokenFromYourServer });

Repeating the same link is safe. Linking that visitor to a different member returns 409 ALIAS_IDENTITY_CONFLICT.

client.aliasUser(input)

The server-side version. It needs adminToken, so call it only from your server.

await client.aliasUser({
  projectId: "YOUR_PROJECT_KEY",
  anonymousId: "anon_visitor_id",
  userHash: "MEMBER_ID",
});

Next steps

On this page