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

@giftfeud/learning-bite-sdk

v1.8.44

Published

Official SDK for embedding GiftFeud learning bites in any application

Readme

@giftfeud/learning-bite-sdk

Official SDK for embedding GiftFeud learning bites in any application.

npm version License: MIT

🚀 Features

  • ✅ Complete Rendering - All content types (video, article, audio, questions)
  • ✅ Progress Tracking - Automatic backend synchronization
  • ✅ Answer Submission - Real-time answer saving
  • ✅ Theme Support - Respects campaign themes or custom styling
  • ✅ Mobile-Friendly - Touch gestures, swipe navigation
  • ✅ TypeScript - Full type definitions included
  • ✅ Framework Agnostic - Works with React, Vue, vanilla JS
  • ✅ Security - API key authentication, domain whitelisting

📦 Installation

npm install @giftfeud/learning-bite-sdk

🎯 Quick Start

Basic Usage

import { GiftFeudSDK } from '@giftfeud/learning-bite-sdk';

// Initialize SDK
const sdk = new GiftFeudSDK({
  apiKey: 'your-api-key',
  environment: 'production',
  userToken: 'user-auth-token', // For progress tracking
  debug: true, // Enable logging
});

// Load a learning bite
const learningBite = await sdk.loadLearningBite('share-token-123');

console.log(learningBite.title);
console.log(learningBite.slides.length);

With Progress Tracking

const sdk = new GiftFeudSDK({
  apiKey: 'your-api-key',
  userToken: 'user-auth-token',
});

// Load learning bite
const bite = await sdk.loadLearningBite('share-token-123');

// Start progress tracking
await sdk.startProgress(bite.id, 'campaign-id');

// Submit answers as user progresses
await sdk.submitAnswer(bite.id, 'slide-id', 5); // Rating scale answer

// Mark slides as completed
await sdk.completeSlide(bite.id, 'slide-id', 30); // 30 seconds

// Complete entire learning bite
await sdk.complete(bite.id, 180); // 180 seconds total

📚 API Reference

Constructor

new GiftFeudSDK(config: SDKConfig)

Config Options:

| Option | Type | Required | Description | |--------|------|----------|-------------| | apiKey | string | ✅ | Your GiftFeud API key | | userToken | string | ❌ | User's auth token for progress tracking | | environment | 'development' \| 'production' | ❌ | Environment (default: 'production') | | baseUrl | string | ❌ | Custom API URL | | domain | string | ❌ | Domain (auto-detected) | | debug | boolean | ❌ | Enable debug logging | | onError | (error: SDKError) => void | ❌ | Error handler |

Methods

loadLearningBite(shareToken: string, pin?: string): Promise<LearningBite>

Load a learning bite by its share token.

const bite = await sdk.loadLearningBite('share-token-123');

startProgress(learningElementId: string, campaignId?: string): Promise<any>

Start tracking progress for a learning bite.

await sdk.startProgress(bite.id, 'campaign-id');

submitAnswer(learningElementId: string, slideId: string, answer: any, campaignId?: string): Promise<any>

Submit user's answer to a question slide.

// Rating scale answer
await sdk.submitAnswer(bite.id, 'slide-1', 5);

// Multiple choice answer
await sdk.submitAnswer(bite.id, 'slide-2', ['option-a', 'option-b']);

// Text response
await sdk.submitAnswer(bite.id, 'slide-3', 'My answer here');

completeSlide(learningElementId: string, slideId: string, timeSpent: number, campaignId?: string): Promise<any>

Mark a slide as completed with time tracking.

await sdk.completeSlide(bite.id, 'slide-1', 45); // 45 seconds

complete(learningElementId: string, totalTime: number, score?: number, campaignId?: string): Promise<any>

Mark entire learning bite as completed.

await sdk.complete(bite.id, 180); // 180 seconds total

setUserToken(token: string | null): void

Update the user token (for authentication changes).

sdk.setUserToken('new-user-token');

🎨 Data Types

LearningBite

interface LearningBite {
  id: string;
  title: string;
  description?: string;
  slides: Slide[];
  timeLimitSeconds?: number;
  shareSettings?: ShareSettings;
}

Slide

interface Slide {
  id: string;
  type: 'intro' | 'content' | 'question';
  order: number;
  title?: string;
  description?: string;
  coverImage?: string;
  backgroundColor?: string;
  backgroundImage?: string;
  textColor?: string;
  useThemeColors?: boolean;
  useIntroBiteSettings?: boolean;
  contentType?: 'video' | 'article' | 'web_link' | 'audio';
  contentData?: any;
  question?: LearningQuestion;
}

LearningQuestion

interface LearningQuestion {
  id?: string;
  type: string; // 'RATING_SCALE', 'MULTIPLE_CHOICE', 'TEXT_RESPONSE', etc.
  questionText?: string;
  description?: string;
  options?: QuestionOption[];
  minValue?: number;
  maxValue?: number;
  leftLabel?: string;
  rightLabel?: string;
}

🔐 Getting an API Key

  1. Contact GiftFeud to request an API key
  2. Provide your domain(s) for whitelisting
  3. Receive your API key and secret
  4. Add to your environment variables:
GIFTFEUD_API_KEY=your-api-key

🎮 Framework Examples

React

import { useState, useEffect } from 'react';
import { GiftFeudSDK } from '@giftfeud/learning-bite-sdk';

function LearningBitePlayer({ shareToken, userToken }) {
  const [sdk] = useState(() => new GiftFeudSDK({
    apiKey: process.env.GIFTFEUD_API_KEY,
    userToken,
  }));
  
  const [bite, setBite] = useState(null);

  useEffect(() => {
    sdk.loadLearningBite(shareToken).then(setBite);
  }, [shareToken]);

  if (!bite) return <div>Loading...</div>;

  return (
    <div>
      <h1>{bite.title}</h1>
      {/* Render slides */}
    </div>
  );
}

Vanilla JavaScript

<script src="https://unpkg.com/@giftfeud/learning-bite-sdk"></script>
<script>
  const sdk = new GiftFeudSDK.GiftFeudSDK({
    apiKey: 'your-api-key',
    debug: true,
  });

  sdk.loadLearningBite('share-token-123').then(bite => {
    console.log('Loaded:', bite.title);
    // Render UI
  });
</script>

🐛 Error Handling

try {
  const bite = await sdk.loadLearningBite('invalid-token');
} catch (error) {
  if (error.code === 'AUTHORIZATION_FAILED') {
    console.error('Invalid API key');
  } else if (error.code === 'FETCH_FAILED') {
    console.error('Learning bite not found');
  }
}

🧪 Testing

Set environment: 'development' to test against local API:

const sdk = new GiftFeudSDK({
  apiKey: 'test-key',
  environment: 'development', // Points to localhost:3000
  debug: true,
});

📖 Complete Documentation

🤝 Support

📄 License

MIT © GiftFeud


Made with ❤️ by the GiftFeud team