Skip to main content

SDK Catalog

Mida provides server-side SDKs for all major languages and platforms. Each SDK exposes the same three core methods: getExperiment, setEvent, and isFeatureEnabled.

All SDKs are open source under the MIT license and hosted in the mida-so GitHub organization.


Available SDKs

Language / PlatformInstallGitHub
Node.jsnpm install mida-nodemida-so/mida-node
Pythonpip install mida-pythonmida-so/mida-python
PHPcomposer require mida-so/mida-phpmida-so/mida-php
Rubygem install mida-rubymida-so/mida-ruby
FlutterAdd to pubspec.yaml — see READMEmida-so/mida-flutter

Core API (all SDKs)

All SDKs share the same method names and argument shapes. Language-specific syntax varies — see each README for full examples.

Initialize

// Node.js
const Mida = require('mida-node');
const mida = new Mida('YOUR_PROJECT_KEY');

Create one instance per application, not per request.


getExperiment(experimentKey, distinctId)

Returns the variant name assigned to this user for the given experiment.

ArgumentTypeDescription
experimentKeystringThe experiment key from the dashboard
distinctIdstringA stable unique identifier for the user

Returns: 'Control', 'Variant 1', 'Variant 2', … or null if the user is not in the experiment (outside traffic allocation, targeting rules, etc.)

const variant = await mida.getExperiment('checkout-flow-v2', userId);

if (variant === 'Control') {
// original
} else if (variant === 'Variant 1') {
// treatment
}
null means not bucketed

Always handle the null / falsy case — the user may be outside the traffic split or the experiment may not be live yet.


setEvent(eventName, distinctId [, properties])

Records a conversion event for a user. The eventName must match the goal name configured in the Mida dashboard.

ArgumentTypeDescription
eventNamestringName of the event (must match the dashboard goal)
distinctIdstringSame stable user ID passed to getExperiment
propertiesobjectOptional. Include revenue, quantity, currency for purchase events
// Custom event
await mida.setEvent('signup_completed', userId);

// Purchase / revenue
await mida.setEvent('Purchase', userId, {
revenue: 49.99,
quantity: 1,
currency: 'USD'
});

isFeatureEnabled(featureKey [, distinctId])

Returns true or false for a feature flag. Useful for gradual rollouts and kill switches without a full A/B split.

const enabled = await mida.isFeatureEnabled('new-checkout', userId);

if (enabled) {
// show new checkout
}

setAttribute(distinctId, attributes)

Sets user attributes that can be used for targeting and segmentation in the dashboard.

await mida.setAttribute(userId, {
plan: 'pro',
country: 'US',
company: 'Acme Corp'
});

Using the same user ID everywhere

The distinctId is the bucketing key — Mida hashes it with the experiment key to deterministically assign a variant. Use the same value across all SDK calls for a user:

  • A database user ID (e.g. 42, or 'user_42') is the most stable choice
  • For anonymous visitors, generate a UUID on first visit and persist it (cookie, local storage, or session)
  • Do not use email addresses — they can change

Combining server-side bucketing with client-side goal tracking

If the conversion event happens on a webpage (e.g. a thank-you page after checkout), you can track it client-side through the Mida browser script instead of calling setEvent() from your server. Both approaches write to the same goal table and appear in the same dashboard results.


Self-hosted script

If you prefer to self-host the Mida frontend tracking script rather than loading it from cdn.mida.so, the source is available at mida-so/mida-script.


Need a language that's not listed?

Open an issue in the closest SDK repo or contact hello@mida.so. The bucketing algorithm is deterministic and straightforward to port — contributions are welcome.