TypeScript icon, indicating that this package has built-in type declarations

    2.5.2 • Public • Published

    STATEWIZE Client SDK 🔍

    Used to report events to STATEWIZE.

    Official docs:


    1. Add package to your project (NodeJS / React / Anything JS)
    yarn add statewize-client-sdk


    npm install statewize-client-sdk
    1. Import and initialize (using the API key from your account)
    import {StatewizeClient} from 'statewize-client-sdk';
    const stwClient = new StatewizeClient(procee.env.YOUR_API_KEY);

    You can fetch your API key here.

    1. Download your journey integration map from the journey planner canvas

    1. Report events as and when required
    const {eventTrackingId} = await sdk.reportEvent({
      yourId: "Your Tracking ID",
      type: "started",
      slug: journeyMap.YOUR_STATE_NAME, // from step 3
      yourUserId: 'your-user-1',

    ... some time passes ...

    await sdk.reportEvent({
      type: "finisned",
      slug: journeyMap.YOUR_STATE_NAME, // from step 3
      yourUserId: 'your-user-1',
      output: {
        zim: 'zoom'


    You can include attachments with state events. Simply provide the attachments in the attachments array.

    Attachment types:

    1. Text
    2. JSON objects
    3. Files
    4. URLs


      await sdk.endState({
        yourId: `Your ID for this whole journey`,
        stateId: journeyMap.START_HERE, // from step 3 
        success: true,
        // optional
        trackingId: `Tracking ID received from startState (optional)`,
      // optional
        output: {
          someJsonData: true,
        // optional:
        attachments: [
                type: 'text',
                content: {content: `LOG: info: ${new Date().toISOString()} Selfie verification completed`}
                type: 'url',
                content: {url: ''}
                type: 'file',
                // You can also provide file from path instead of buffer.
                content: {buffer: Buffer.from("test-buffer"), fileName: 'test-text.txt'}

    Enriching user data

    You can provide additional user data for users that you track. We don't know who your users are, and we don't use their information for any purposes. But for your own logging purposes, if you're interested to attach some rich data about the users you track - you can do so using setUserData method.

    For example:

    await sdk.setUserData({yourUserId: 'user-1234', data: {something: 'important'}});

    Switching the execution id

    Let's say you've started tracking a journey using one id, but then you have another ID you'd like to use for this specific execution. For example, you may have started tracking an e-commerce order using an auto-generated ID on the marketing site, but now you'd like to use your own orderId - something you didn't have before - for the same execution.

    You can do that by calling:

    await sdk.switchId({oldId: 'your-old-id', newId: 'your-new-id'});

    Please be aware that execution IDs are unique, so the switch may fail if the ID is already used by you in another execution.

    For any questions and support, feel free to reach out to




    npm i statewize-client-sdk

    DownloadsWeekly Downloads






    Unpacked Size

    70.1 kB

    Total Files


    Last publish


    • justlev