Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flagmint SDK Tester

A standalone tool for testing Flagmint's SDK protocol without writing code

Built for QA engineers, demos, and debugging


πŸ“‹ Overview

This app connects directly to your Flagmint API using the raw wire protocol (WebSocket or HTTP long-polling). It does not use any Flagmint SDK β€” this is intentional, so you're testing the server contract, not the SDK's interpretation of it.

Perfect for:

  • βœ… QA testing and validation
  • πŸ› Debugging feature flag behavior
  • 🎯 Testing targeting rules and context evaluation
  • πŸ”„ Verifying real-time updates
  • πŸ“Š Comparing WebSocket vs long-polling transport

πŸš€ Quick Start

Prerequisites

  • Option A: Node.js 16+ and npm
  • Option B: Docker and Docker Compose
  • A Flagmint API instance (local or remote)
  • A valid SDK key from your Flagmint environment

Installation

Option 1: Local Development (Node.js)

# Clone or download this repository
cd flagmint-sdk-tester

# Install dependencies
npm install

# Start the development server
npm run dev

Open http://localhost:5173 in your browser, paste your SDK key, and connect!

Option 2: Docker (Recommended for Consistency)

Using Docker Compose (Easiest):

# Development mode (with hot reload)
docker-compose up dev

# Production mode (optimized build)
docker-compose up prod

Using Docker directly:

# Development mode
docker build --target development -t flagmint-sdk-tester:dev .
docker run -p 5173:5173 -v $(pwd):/app -v /app/node_modules flagmint-sdk-tester:dev

# Production mode
docker build --target production -t flagmint-sdk-tester:prod .
docker run -p 3000:3000 flagmint-sdk-tester:prod

Access the application:

Build for Production (Local)

npm run build
npm run preview

✨ Features

πŸ”Œ Connection Management

  • Dual Transport Support β€” Switch between WebSocket and HTTP long-polling
  • Connection Status β€” Real-time visual indicators for connection state
  • Auto-reconnect β€” Graceful handling of disconnections

🎯 Context Evaluation

  • Visual Context Builder β€” Add/remove key-value pairs via UI
  • Context Presets β€” Quick setups for common scenarios:
    • Simple User β€” Basic { kind: 'user', key: '...' } context
    • Multi-Context β€” Complex { kind: 'multi', user: {...}, organization: {...} } structure
    • Empty β€” No context (tests default evaluation paths)
  • Nested Context Support β€” Use dot notation (e.g., user.key, organization.plan)
  • Type Inference β€” Automatically converts true, false, and numeric strings

🚩 Flag Display

  • Live Flag Values β€” See all flags with current values
  • Type Badges β€” Visual indicators for boolean, string, number, JSON, and null types
  • Real-Time Updates β€” Watch flags change instantly when modified in dashboard
  • Change History β€” Expand any flag to see its value history over time
  • Flag Search β€” Filter flags by name for large projects

πŸ“‘ Protocol Logging

  • Message Inspector β€” View raw WebSocket messages
  • Connection Events β€” Track connect, disconnect, and error events
  • Debug Mode β€” Toggle verbose logging for troubleshooting
  • Auto-scroll β€” Automatically follows latest log entries

πŸ“– Usage

Basic Workflow

  1. Configure Connection

    • Enter your API URL (e.g., http://localhost:3000)
    • Paste your SDK key
    • Choose transport: WebSocket (recommended) or long-polling
  2. Set Up Context

    • Use a preset or manually add context fields
    • Example user context:
      kind: user
      key: test-user-123
      country: US
      plan: pro
      
  3. Connect & Test

    • Click "Connect" β€” connection status will turn green
    • Click "Send Context" to evaluate flags with your context
    • All matching flags will appear in the Flags tab
  4. Verify Real-Time Updates

    • Open Flagmint dashboard in another tab
    • Toggle a flag value or targeting rule
    • Watch the tester update instantly (WebSocket)

Testing Scenarios

Test User Targeting

Context:
  kind: user
  key: alice@example.com
  email: alice@example.com
  plan: enterprise

Verify flags target based on email domain or plan level.

Test Multi-Context Evaluation

Context:
  kind: multi
  user.kind: user
  user.key: alice@example.com
  organization.kind: organization
  organization.key: acme-corp
  organization.plan: enterprise

Verify organization-level flags override user-level defaults.

Test Empty Context

Context: (empty)

Verify default fallback values are returned correctly.

QA Testing Checklist

  • Flag evaluates with correct default value
  • Flag respects user targeting rules
  • Flag respects multi-context targeting
  • Flag updates in real-time when changed in dashboard
  • WebSocket connection is stable (no disconnects)
  • Long-polling fallback works correctly
  • Empty context returns expected defaults
  • Custom context attributes are evaluated correctly
  • Change history accurately tracks flag value changes

πŸ—οΈ Project Structure

flagmint-sdk-tester/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.jsx         # React entry point
β”‚   β”œβ”€β”€ App.jsx          # Main app component (UI, state management)
β”‚   β”œβ”€β”€ connection.js    # Flagmint protocol client (WebSocket + long-polling)
β”‚   └── helpers.js       # Utilities (type helpers, presets, context builder)
β”œβ”€β”€ index.html           # HTML template
β”œβ”€β”€ package.json         # Dependencies and scripts
β”œβ”€β”€ vite.config.js       # Vite configuration
└── README.md            # This file

Key Files

  • connection.js β€” Raw protocol implementation. Handles WebSocket connections, long-polling, message parsing, and keep-alive pings.
  • helpers.js β€” Context building logic, type detection, and preset configurations.
  • App.jsx β€” Complete UI with connection panel, context builder, flag viewer, and log inspector.

πŸ”§ Configuration

API URL

Default: http://localhost:3000

Update in the UI or set via localStorage:

localStorage.setItem('fm_tester_url', 'https://your-api.com');

SDK Key

Stored securely in localStorage (input type=password). Never committed to version control.

CORS Configuration

If your Flagmint API runs on a different origin, ensure CORS allows:

Access-Control-Allow-Origin: http://localhost:5173
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization

πŸ› οΈ Tech Stack

  • React 19 β€” UI framework
  • Vite β€” Build tool and dev server
  • WebSocket API β€” Real-time communication
  • Fetch API β€” Long-polling fallback
  • Local Storage β€” Persistent configuration

No external dependencies for networking or UI β€” pure browser APIs.

πŸ› Troubleshooting

Connection Fails

  • βœ… Verify API URL is correct and reachable
  • βœ… Check API key is valid for the environment
  • βœ… Ensure API is running and healthy
  • βœ… Check CORS configuration (see browser console for errors)

No Flags Appear

  • βœ… Verify SDK key has access to flags
  • βœ… Check context matches targeting rules
  • βœ… Try empty context to see default values
  • βœ… Check Protocol Log tab for server responses

WebSocket Disconnects

  • βœ… Check API WebSocket endpoint is stable
  • βœ… Try long-polling transport as fallback
  • βœ… Verify no firewall/proxy blocking WebSocket connections
  • βœ… Check API logs for errors

Wrong Flag Values

  • βœ… Verify context structure matches expected format
  • βœ… Check targeting rules in Flagmint dashboard
  • βœ… Review change history to see if value recently updated
  • βœ… Enable Debug mode in Protocol Log to see evaluation details

🀝 Contributing

This is a testing tool for Flagmint SDK validation. Contributions welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/improvement)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/improvement)
  5. Open a Pull Request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ”— Related


Made with πŸ’œ for the Flagmint community

About

this is a Qa tool to flagmint Quality Assurance

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages