Conversation
|
hmm we need docs for how to use it? also for this new sub-package, i think it's more appropriate to make it 100% ts native as well, can skip the complicated .d.ts and define all types inline |
c225f3f to
fa9572f
Compare
Implement an OpenFeature provider for the Mixpanel Node SDK as a separate package in openfeature-server-provider/. Wraps either LocalFeatureFlagsProvider or RemoteFeatureFlagsProvider via the shared getVariant() API. Key design decisions: - Uses Symbol sentinel for fallback detection (flag-not-found) - Context set globally via initialize(), per-evaluation context ignored - targetingKey has no special meaning - Handles both sync (local) and async (remote) providers via await - Reason codes: STATIC for success, ERROR for failures - Error codes: PROVIDER_NOT_READY, FLAG_NOT_FOUND, TYPE_MISMATCH - onClose() is a no-op - Returns default value on all errors Includes 32 tests covering all flag types, error cases, async providers, context handling, and edge cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds PROVIDER_NOT_READY tests for string, number, and object types (boolean was already covered), and SDK exception handling tests verifying that getVariant failures return defaults with error codes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge per-evaluation context on top of init context so callers can override or extend context at each flag evaluation, matching the OpenFeature specification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- shutdown() now delegates to underlying flags provider - Add areFlagsReady() to LocalFlagsProvider, check before evaluation - Return ErrorCode.GENERAL (not PROVIDER_NOT_READY) for exceptions - Add context value unwrapping with whole-number float→int conversion - Update tests for new error codes and add shutdown/readiness tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract shared _resolveTypedFlag helper to eliminate ~70 lines of duplicated type-checking across 4 resolve methods. Fix misplaced shutdown() that broke JSDoc association. Remove dead integer truncation code. Fix inconsistent snake_case naming and simplify null checks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove dangerous {value: X} unwrapping heuristic that silently destroyed
legitimate context data. Add Date-to-ISO-string conversion. Add await to
onClose shutdown. Update TypeScript declarations with optional methods.
Add files field to package.json. Add 6 context-building tests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Required by repo policy — actions must be pinned to full-length commit SHAs rather than version tags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Track openfeature-server-provider/package-lock.json so npm ci works in CI - Fix prettier formatting in test file Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
areFlagsReady() previously checked flagDefinitions.size > 0, which incorrectly reported "not ready" when the API returned an empty flags array. Now returns a promise that resolves after the first successful fetch, regardless of whether flags were returned. The OpenFeature provider awaits this promise during initialize() instead of using a simple boolean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MixpanelProvider.createLocal and createRemote accept a token and config, create the Mixpanel client internally, auto-start polling for local configs, and expose the client via the mixpanel property. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… flag not found Updates OpenFeature provider reason codes to match the updated spec: - Success: STATIC → TARGETING_MATCH - Flag not found: ERROR → DEFAULT Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…essages, fix CI - Add JSDoc comments to MixpanelProvider public methods - Bind @openfeature/server-sdk peer dependency to ^1.17.0 - Use npm test with coverage in CI openfeature job - Remove unnecessary article from type mismatch error messages - Fix areFlagsReady return type in index.d.ts (Promise<void>, not boolean) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move openfeature-server-provider to packages/ as an npm workspace - Convert all source and tests from JavaScript to TypeScript - Add README adapted from the Java OpenFeature provider - Bump main SDK version to 0.21.0 for shutdown method support - Add shutdown() and areFlagsReady() to flag provider type declarations - Add workspace scripts (test:all, build:workspaces) to root package.json - Exclude packages/ from main SDK npm tarball via .npmignore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fa9572f to
4da0720
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All publishable targets now live under packages/. The root becomes a private workspace orchestrator while the mixpanel npm package ships from packages/mixpanel/ with an explicit files allowlist. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| @@ -0,0 +1,17 @@ | |||
| { | |||
There was a problem hiding this comment.
i tsconfig and vitest thing should be on root dir
| @@ -0,0 +1,2 @@ | |||
| dist/ | |||
- Collapse CI into single job using npm run test:all + tsc --build from root; drop working-directory in favor of npm workspaces - Add root tsconfig.json solution file with project references to both packages; both package tsconfigs are now composite - Hoist .gitignore to repo root (adds dist/, *.tsbuildinfo); delete the per-package .gitignore - Bind mixpanel peerDep to ^0.21.0; devDep uses workspace (*) - Add --coverage to both packages' test scripts for parity - Add concise JSDoc to MixpanelProvider public methods Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both workspace test scripts now emit coverage-final.json; wire it up to codecov-action so PRs get a coverage delta comment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move vitest and @vitest/coverage-v8 to root devDependencies so both workspaces share a single version. Also drop typescript from the openfeature package (already in root). Per-package devDeps now contain only package-specific test helpers (nock, proxyquire for mixpanel; @openfeature/core, @openfeature/server-sdk, mixpanel workspace pin for openfeature-server-provider). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
We still need basically this file in the repo root, so that when people visit https://github.com/mixpanel/mixpanel-node they can get instructions for the Node.js SDK right in front of them. Maybe symlink from here (and add a brief section on the directory structure)
| "test": "vitest", | ||
| "test": "npm run test --workspaces --if-present", | ||
| "test:all": "npm run test --workspaces --if-present", | ||
| "build:workspaces": "npm run build --workspaces --if-present", |
There was a problem hiding this comment.
make it easier
| "build:workspaces": "npm run build --workspaces --if-present", | |
| "build": "npm run build --workspaces --if-present", | |
| "build:workspaces": "npm run build --workspaces --if-present", |
There was a problem hiding this comment.
(or maybe call these scripts tsc since that's what they really do in practice)
There was a problem hiding this comment.
(it also wouldn't be terrible if npm test ran the typechecker too)
| "node": ">=10.0" | ||
| }, | ||
| "scripts": { | ||
| "test": "vitest run --coverage" |
There was a problem hiding this comment.
let's get a build or tsc script in here too - npx tsc --build will fail if the example in tscheck/ is borked
- Add root readme.md symlink to packages/mixpanel/readme.md so the GitHub landing page shows SDK docs again - Add "Repository structure" section to packages/mixpanel/readme.md - Hoist `build` to root package.json; have `npm test` run tsc too - Add `tsc` script (tsc --build) at root - Add `build` script to packages/mixpanel; align openfeature provider to `tsc --build` - Update CI to use `npm test` (now covers typecheck) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Design
🤖 Generated with Claude Code