Feature flags & remote config

TraceIQ Feature Flags give you deterministic rollouts, targeting segments, remote configuration, real-time debug testing, exposure tracking, and downstream impact analytics connected directly to your events, user timelines, and errors. Manage flags under Feature flags.

Product Philosophy: Feature flags in TraceIQ are not isolated switches. When an application evaluates a flag and exposes a user to a feature, TraceIQ records that exposure. You can then inspect the user's chronological timeline, monitor error spikes, and measure whether conversion improved between exposed and control users.

Deterministic & Sticky Rollout: Hashing uses SHA-256 over key:distinctId mapped into buckets 0–99. Raising a rollout from 25% → 50% guarantees that everyone already receiving the feature stays in, adding only new users.

1. JavaScript & TypeScript (Browser SDK):

ts
import { traceiq } from 'traceiq-sdk-js';

// Load flags once at initialization (or after identify)
await traceiq.loadFeatureFlags({ plan: 'premium', country: 'NG' });

// Check flag with deterministic sticky assignment
if (traceiq.flags.isEnabled('nuwell-new-add-meal')) {
  renderNewMealFlow(traceiq.flags.getPayload('nuwell-new-add-meal'));
}

2. React & Next.js:

tsx
import { useEffect, useState } from 'react';
import { traceiq } from 'traceiq-sdk-js';

export function AddMealButton() {
  const [useNewFlow, setUseNewFlow] = useState(false);

  useEffect(() => {
    void traceiq.loadFeatureFlags().then(() => {
      setUseNewFlow(traceiq.flags.isEnabled('nuwell-new-add-meal'));
    });
  }, []);

  if (useNewFlow) {
    return <NewAddMealModal config={traceiq.flags.getPayload('nuwell-new-add-meal')} />;
  }
  return <LegacyAddMealButton />;
}

3. Node.js (Server SDK):

ts
import { TraceIQ } from '@traceiq/node';

const traceiq = new TraceIQ({
  projectId: process.env.TRACEIQ_PROJECT_ID!,
  writeKey: process.env.TRACEIQ_WRITE_KEY!
});

// Server-side evaluation with safe fallback
const isEnabled = await traceiq.isFeatureEnabled('nuwell-new-add-meal', userId, {
  defaultValue: false,
  properties: { plan: 'premium', country: 'NG' },
  environment: 'production'
});

4. Python & Other Backend Services:

python
import requests

response = requests.post(
    "https://api.traceiq.run/v1/flags/evaluate",
    headers={"x-traceiq-write-key": WRITE_KEY, "Content-Type": "application/json"},
    json={
        "projectId": PROJECT_ID,
        "distinctId": user_id,
        "environment": "production",
        "properties": {"plan": "premium", "country": "NG"}
    }
)
data = response.json()
is_enabled = data.get("flags", {}).get("nuwell-new-add-meal", False)
payload = data.get("payloads", {}).get("nuwell-new-add-meal")

5. HTTP REST API:

bash
curl -X POST https://api.traceiq.run/v1/flags/evaluate \
  -H 'Content-Type: application/json' \
  -H 'x-traceiq-write-key: YOUR_PROJECT_WRITE_KEY' \
  -d '{
    "projectId": "YOUR_PROJECT_ID",
    "distinctId": "emmanuel",
    "environment": "production",
    "properties": { "plan": "premium", "country": "NG" }
  }'

Response:

json
{
  "flags": { "nuwell-new-add-meal": true },
  "payloads": { "nuwell-new-add-meal": { "dailyScanLimit": 5, "showVoiceInput": true } },
  "details": { "nuwell-new-add-meal": { "enabled": true, "reason": "matched_targeting_group_1", "revision": 3 } },
  "environment": "production"
}

Targeting Operators:

  • equals / does not equal — Exact matching for strings, numbers, or booleans.
  • contains / does not contain — Case-insensitive substring match (e.g. email contains "@traceiq.run").
  • greater than / less than — Numeric boundary comparisons (e.g. scanCount >= 5).
  • exists / does not exist — Tests whether a property trait is present on the user identity.
  • is one of — Matches comma-separated values (e.g. plan in "pro, enterprise, beta").
  • Targeting Groups (OR) — Create multiple groups where any matching group qualifies the user. Rules within a group are combined with AND.

Safe Kill Switch:

Disabling a flag instantly returns fallback/off values on future evaluations across all SDKs. Targeting rules, rollout percentage, remote configuration JSON, and historical telemetry are strictly preserved.