FLAGSHIP

DEVELOPER
DOCUMENTATION

Get started in minutes. Comprehensive guides. API reference. Code examples.

QUICK START

1. Install SDK

npm install @flagship/sdk

Choose your language and install via npm, pip, gradle, or gem.

2. Initialize Client

const flagship = require('@flagship/sdk');
const client = flagship.initialize(API_KEY);

Get your API key from the dashboard.

3. Get Flag Value

const isEnabled = client.getFlag('my-feature', false);
if (isEnabled) { // show new feature }

Evaluate flags in your code with zero latency.

4. Track Events

client.track(userId, 'feature-used', { flag: 'my-feature' })'

Send events for experiments and analytics.

DOCUMENTATION GUIDES

Getting Started

  • → Installation
  • → Configuration
  • → Authentication
  • → Creating Flags

Core Concepts

  • → Feature Flags
  • → Targeting Rules
  • → Rollouts
  • → Experiments

Advanced Topics

  • → Caching Strategies
  • → Performance Tuning
  • → Custom Attributes
  • → Webhooks

Best Practices

  • → Rollout Strategies
  • → Testing Flags
  • → Analytics Setup
  • → Troubleshooting

CODE EXAMPLES

Feature Flag Evaluation

// JavaScript/TypeScript
const isEnabled = await flagship.getFlag(
  'new-dashboard',
  false
);

if (isEnabled) {
  showNewDashboard();
} else {
  showLegacyDashboard();
}

With User Context

// Include user attributes in flag evaluation
const isEnabled = await flagship.getFlag(
  'premium-feature',
  false,
  {
    userId: 'user-123',
    email: 'user@example.com',
    plan: 'enterprise'
  }
);

Tracking Events

// Track user events for analytics
flagship.trackEvent(userId, 'feature-used', {
  feature: 'new-dashboard',
  timestamp: Date.now(),
  duration: 1500
});

React Hooks

// React hook for flags
const MyComponent = () => {'{'}
  const isEnabled = useFlag('new-feature');

  return (
    {'<div>'}
      {isEnabled ?
        {'<NewFeature />'} :
        {'<LegacyFeature />'}
      }
    {'</div>'}
  );
}}

API REFERENCE

getFlag(flagKey, defaultValue, context?)

Returns the flag value for the given context.

Parameters:

• flagKey: string - The flag identifier

• defaultValue: any - Fallback if flag not found

• context?: object - User/organization attributes

Returns: Promise<any>

trackEvent(userId, eventName, properties?)

Sends an event for tracking and analytics.

Parameters:

• userId: string - User identifier

• eventName: string - Event name

• properties?: object - Event metadata

Returns: Promise<void>

getAllFlags(context?)

Returns all flag values for the given context.

Parameters:

• context?: object - User/organization attributes

Returns: Promise<Record<string, any>>