Skip to content

feat: add service account support#275

Open
lajohn4747 wants to merge 20 commits into
masterfrom
johnla-multi-563-add-service-account-support-to-nodejs-sdk
Open

feat: add service account support#275
lajohn4747 wants to merge 20 commits into
masterfrom
johnla-multi-563-add-service-account-support-to-nodejs-sdk

Conversation

@lajohn4747

@lajohn4747 lajohn4747 commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Add service account support to the SDK so that endpoints such as import and feature flags can be validated through service accounts.

  • ServiceAccountCredentials class
  • Service accounts take precedence over deprecated API secret/key methods
  • Add deprecation notes for api secrets
  • Added tests

@linear-code

linear-code Bot commented Jun 16, 2026

Copy link
Copy Markdown

MULTI-563

@lajohn4747 lajohn4747 requested review from efahk and tylerjroach June 18, 2026 17:23
@lajohn4747 lajohn4747 marked this pull request as ready for review June 18, 2026 17:24
@lajohn4747 lajohn4747 requested a review from a team June 18, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class service account authentication support to the Mixpanel Node SDK, enabling authenticated use of endpoints like /import and server-side feature flags, while deprecating legacy API secret/key authentication.

Changes:

  • Introduces ServiceAccountCredentials (new module + export) and wires it into /import request auth + project_id handling.
  • Extends feature flags providers to accept optional credentials and use service-account Basic auth + project_id query param when provided.
  • Updates tests, examples, and README to document/recommend service accounts and adds deprecation warnings for secret/key.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/openfeature-server-provider/test/MixpanelProvider.test.ts Simplifies mock provider setup used by OpenFeature server provider tests.
packages/mixpanel/test/send_request.js Updates /import auth error expectation to match new message.
packages/mixpanel/test/import.js Adds service-account credential tests and deprecation-warning tests.
packages/mixpanel/test/flags/local_flags.js Adds a local flags test case for providing service account credentials.
packages/mixpanel/readme.md Documents service account authentication as the recommended approach and deprecates API secrets.
packages/mixpanel/lib/mixpanel-node.js Implements service-account auth for /import, adds deprecation warnings, propagates credentials to flags providers, and exports ServiceAccountCredentials.
packages/mixpanel/lib/mixpanel-node.d.ts Updates TS declarations to include ServiceAccountCredentials and credentials init config.
packages/mixpanel/lib/flags/utils.js Extends common flags query params to optionally include project_id.
packages/mixpanel/lib/flags/remote_flags.js Plumbs optional credentials through to the shared flags base provider.
packages/mixpanel/lib/flags/local_flags.js Plumbs optional credentials through to the shared flags base provider.
packages/mixpanel/lib/flags/flags.js Adds service-account auth/header/query behavior for feature flags requests.
packages/mixpanel/lib/credentials.js Adds the ServiceAccountCredentials implementation.
packages/mixpanel/example.js Updates example usage to prefer service accounts and marks API secret flow as deprecated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/mixpanel/lib/mixpanel-node.js Outdated
Comment thread packages/mixpanel/lib/credentials.js Outdated
Comment thread packages/mixpanel/test/import.js Outdated
Comment thread packages/mixpanel/test/flags/local_flags.js
@lajohn4747 lajohn4747 marked this pull request as draft June 30, 2026 22:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 6 comments.

Comment thread packages/mixpanel/lib/flags/local_flags.js
Comment thread packages/mixpanel/lib/flags/remote_flags.js
Comment thread packages/mixpanel/lib/flags/flags.js
Comment thread packages/mixpanel/test/send_request.js
Comment thread packages/mixpanel/test/flags/local_flags.js
Comment thread packages/mixpanel/test/flags/local_flags.js

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 16 changed files in this pull request and generated 2 comments.

Comment thread packages/mixpanel/lib/mixpanel-node.js
Comment thread packages/mixpanel/lib/flags/flags.js
@lajohn4747 lajohn4747 changed the title Add Service Account support feat: add service account support Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 16 changed files in this pull request and generated no new comments.

@lajohn4747 lajohn4747 marked this pull request as ready for review July 1, 2026 17:19

@tylerjroach tylerjroach left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secret is currently the only way to import, so on upgrade 100% of importing users get a logger.warn deprecation. Patch 13 fixed the earlier per-request spam so it now fires once per client at init — good. But in serverless / per-request-client setups that's once per cold start, and it hits api_key users too.

@lajohn4747 lajohn4747 requested a review from tylerjroach July 6, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants