SDK Integration
How to report events to STATEWIZE
Integrating with STATEWIZE is designed to be simple and quick;
- 1.
- 2.Download your journey integration map (available on the floating menu, on any journey page) 👀

4. Initialise the SDK:
import {StatewizeClient} from 'statewize-client-sdk';
const sdk = new StatewizeClient(procees.env.YOUR_TOKEN);
5. Report events (see below)
await sdk.startJourney({
journeySlug: 'your-journey-slug',
yourId: "Your ID used to track this journey",
yourUserId: "my-user-1234"
});
const {eventTrackingId} = await sdk.reportEvent({
yourId: "Your Tracking ID",
type: "started",
slug: journeyMap.YOUR_STATE_NAME, // from step 3
yourUserId: 'your-user-1',
});
await sdk.reportEvent({
eventTrackingId,
type: "finisned",
slug: journeyMap.YOUR_STATE_NAME, // from step 3
yourUserId: 'your-user-1'
});
await sdk.reportEvent({
parentEventTrackingId: eventTrackingId,
type: "finisned",
slug: journeyMap.YOUR_STATE_NAME, // from step 3
yourUserId: 'your-user-1'
});
await sdk.endJourney({
yourId: execId,
status: 'complete'
});
And that's it!
- 1.Reporting an event without starting a journey - is possible. If you do so - the relevant journey will be found, started, and then an event will be reported.
- 2.You don't have to split an event into
started
andfinished
- you can report it asfinished
on the first call - it's all up to you, however you'd like the tracking to take place. - 3.STATEWIZE allows you to use your own ID by providing a
yourId
field in various SDK methods. This can be helpful when you have a known ID which you'd like to maintain for subsequent journey tracking purposes, instead of persisting the ID returned from STATEWIZE. - 4.Environments - You can set your environment in the constructor of the
StatewizeClient
, as well as on thestartJourney
event. An environment can be any of the following: [development
,testing
,staging
,production
].
Last modified 1yr ago