$ show mixpanel/mixpanel-node
Mixpanel-node is a server-side SDK for Mixpanel analytics, providing event tracking, people and group profile management, and feature flag evaluation (local and remote). It includes an optional OpenFeature provider for standardized flag evaluation. The SDK is structured as an npm workspace with two packages: the core `mixpanel` library and `@mixpanel/openfeature-server-provider`. The codebase demonstrates solid engineering practices: clear module separation, comprehensive test coverage with vitest and nock, robust error handling, deprecation warnings, and service account authentication support. The feature flags subsystem includes custom json-logic operators for semver and datetime comparison, validated against cross-platform golden vectors. The OpenFeature provider correctly maps Mixpanel's fallback reasons to OpenFeature error codes. Dependencies are modern, and the project is actively maintained with automated CI/CD and release workflows.
The LLM identified 4 files worth highlighting for reuse:
Implements ServiceAccountCredentials class for server-to-server authentication. Validates inputs (type, non-empty), trims whitespace, caches base64-encoded auth string for reuse, and masks secret in toString(). Self-contained (depends only on Buffer) and could be extracted as a standalone credential helper for any HTTP service requiring basic auth with project ID.
Registers semver_compare and datetime_compare operators on json-logic-js. Implements full SemVer 2.0.0 comparison (including pre-release ordering, build metadata ignored, leading zero rejection, length caps). Datetime operator validates RFC 3339 format, calendar date existence, and converts to Unix seconds for comparison. Both operators are tested against golden vector files shared across Mixpanel SDKs, ensuring cross-platform parity. The module is isolated and could be reused in any json-logic-based evaluation system.
Provides frozen constants and factory functions for tagging feature flag evaluation results with source (local/remote/fallback) and fallback reason (FLAG_NOT_FOUND, MISSING_CONTEXT_KEY, NO_ROLLOUT_MATCH, BACKEND_ERROR). The withSource and asFallback helpers create shallow copies of variant objects with appropriate tags. This pattern is cleanly separated and could be extracted as a common result-type abstraction for any flag evaluation SDK.
Wraps Mixpanel's local or remote flags provider into an OpenFeature-compliant Provider. Handles initialization (awaiting flag definitions), context merging (global + per-evaluation), type checking (TYPE_MISMATCH), and maps fallback reasons to OpenFeature error codes (FLAG_NOT_FOUND, TARGETING_KEY_MISSING, GENERAL). Demonstrates a clean adapter pattern for integrating a vendor-specific flag evaluation system into OpenFeature's standardized API.