npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

poketto-sdk

v1.1.0

Published

Official SDK for Poketto feedback forms - easily submit form responses from your applications

Readme

Poketto SDK

Official JavaScript/TypeScript SDK for Poketto feedback forms. Easily submit form responses from your web applications, mobile apps, or server-side applications.

Installation

npm install poketto-sdk

Quick Start

import { PokettoClient } from 'poketto-sdk';

// Initialize the client
const client = new PokettoClient({
  apiKey: 'your-api-key'
});

// Submit a form response
await client.submitResponse('form-id', [
  { field_id: 'name', value: 'John Doe' },
  { field_id: 'email', value: '[email protected]' },
  { field_id: 'feedback', value: 'Great product!' }
]);

Features

  • TypeScript Support - Full type safety and IntelliSense
  • Auto Browser Detection - Automatically captures browser, OS, and device info
  • UTM Parameter Extraction - Automatically extracts marketing parameters
  • Retry Logic - Built-in retry mechanism for failed requests
  • Validation - Client-side validation for common errors
  • Multiple Formats - ES Modules, CommonJS, and UMD builds
  • Cross-Platform - Works in browsers, Node.js, React Native, and more

API Reference

PokettoClient

Constructor

new PokettoClient(config: PokettoSDKConfig, options?: PokettoSDKOptions)

Config Options:

  • apiKey (required): Your Poketto API key
  • timeout (optional): Request timeout in milliseconds (default: 10000)

SDK Options:

  • retries (optional): Number of retry attempts (default: 3)
  • retryDelay (optional): Delay between retries in milliseconds (default: 1000)
  • validateFields (optional): Enable client-side validation (default: true)

Methods

submitResponse(formId, fieldResponses, respondent?, options?)

Submit a form response with manual data.

await client.submitResponse(
  'form-123',
  [
    { field_id: 'name', value: 'John Doe' },
    { field_id: 'email', value: '[email protected]' }
  ],
  {
    name: 'John Doe',
    email: '[email protected]',
    metadata: { source: 'website' }
  }
);
submitResponseWithBrowserInfo(formId, fieldResponses, respondent?, options?)

Submit a form response with auto-detected browser information.

await client.submitResponseWithBrowserInfo(
  'form-123',
  [
    { field_id: 'feedback', value: 'Great service!' }
  ],
  {
    email: '[email protected]' // Optional respondent data
  }
);

Usage Examples

Basic Form Submission

import { PokettoClient } from 'poketto-sdk';

const client = new PokettoClient({ apiKey: 'your-api-key' });

try {
  const response = await client.submitResponse('form-id', [
    { field_id: 'rating', value: '5' },
    { field_id: 'comment', value: 'Excellent service!' }
  ]);
  
  console.log('Response submitted:', response.data.responseId);
} catch (error) {
  console.error('Submission failed:', error.message);
}

With Custom Respondent Data

await client.submitResponse(
  'feedback-form',
  [
    { field_id: 'satisfaction', value: 'very-satisfied' },
    { field_id: 'suggestions', value: 'Keep up the great work!' }
  ],
  {
    name: 'Jane Smith',
    email: '[email protected]',
    metadata: {
      customerType: 'premium',
      accountId: 'acc-123'
    }
  }
);

Auto-Detect Browser Info (Recommended for Web Apps)

// This automatically captures browser, OS, device info, UTM parameters, etc.
await client.submitResponseWithBrowserInfo(
  'survey-form',
  [
    { field_id: 'experience', value: 'positive' }
  ],
  {
    email: '[email protected]' // Optional additional data
  }
);

Helper Methods

// Create field responses from an object
const responses = PokettoClient.createFieldResponses({
  'name': 'John Doe',
  'email': '[email protected]',
  'rating': '5'
});

// Create a single field response
const response = PokettoClient.createFieldResponse('feedback', 'Great!');

Error Handling

import { PokettoError } from 'poketto-sdk';

try {
  await client.submitResponse('form-id', responses);
} catch (error) {
  if (error instanceof PokettoError) {
    console.error('Poketto Error:', {
      message: error.message,
      code: error.code,
      statusCode: error.statusCode,
      details: error.details
    });
  } else {
    console.error('Unknown error:', error);
  }
}

React Example

import React, { useState } from 'react';
import { PokettoClient } from 'poketto-sdk';

const client = new PokettoClient({ apiKey: 'your-api-key' });

function FeedbackForm() {
  const [feedback, setFeedback] = useState('');
  const [loading, setLoading] = useState(false);

  const handleSubmit = async (e: React.FormEvent) => {
    e.preventDefault();
    setLoading(true);

    try {
      await client.submitResponseWithBrowserInfo(
        'feedback-form-id',
        [{ field_id: 'feedback', value: feedback }]
      );
      alert('Thank you for your feedback!');
      setFeedback('');
    } catch (error) {
      alert('Failed to submit feedback. Please try again.');
    } finally {
      setLoading(false);
    }
  };

  return (
    <form onSubmit={handleSubmit}>
      <textarea
        value={feedback}
        onChange={(e) => setFeedback(e.target.value)}
        placeholder="Your feedback..."
        required
      />
      <button type="submit" disabled={loading}>
        {loading ? 'Submitting...' : 'Submit Feedback'}
      </button>
    </form>
  );
}

Node.js Example

const { PokettoClient } = require('poketto-sdk');

const client = new PokettoClient({
  apiKey: process.env.POKETTO_API_KEY
});

async function submitServerFeedback(userId, feedback) {
  try {
    const response = await client.submitResponse(
      'server-feedback-form',
      [
        { field_id: 'user_id', value: userId },
        { field_id: 'feedback', value: feedback }
      ],
      {
        metadata: {
          source: 'server',
          timestamp: new Date().toISOString()
        }
      }
    );
    
    return response.data.responseId;
  } catch (error) {
    console.error('Failed to submit feedback:', error);
    throw error;
  }
}

Configuration

Environment Variables

You can set your API key using environment variables:

POKETTO_API_KEY=your-api-key
const client = new PokettoClient({
  apiKey: process.env.POKETTO_API_KEY || 'fallback-key'
});

Custom Configuration

const client = new PokettoClient(
  {
    apiKey: 'your-api-key',
    timeout: 15000
  },
  {
    retries: 5,
    retryDelay: 2000,
    validateFields: true
  }
);

Types

The SDK includes full TypeScript definitions. Key types include:

  • PokettoClient - Main client class
  • FieldResponse - Individual field response
  • RespondentData - Respondent information
  • PokettoError - SDK-specific error class
  • BrowserInfo - Auto-detected browser information
  • UtmParams - UTM parameter extraction

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+
  • iOS Safari 12+
  • Android Chrome 60+

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

MIT License - see LICENSE file for details.

Support

  • 📧 Email: [email protected]
  • 📖 Documentation: https://docs.poketto.com
  • 🐛 Issues: https://github.com/poketto/poketto-sdk/issues