Skip to content

feat(importer): add MIXPANEL_DATA_RESIDENCY env var for EU/India data centers#360

Open
mraj602 wants to merge 2 commits intoOpenpanel-dev:mainfrom
mraj602:feat/mixpanel-data-residency
Open

feat(importer): add MIXPANEL_DATA_RESIDENCY env var for EU/India data centers#360
mraj602 wants to merge 2 commits intoOpenpanel-dev:mainfrom
mraj602:feat/mixpanel-data-residency

Conversation

@mraj602
Copy link
Copy Markdown

@mraj602 mraj602 commented May 5, 2026

Summary

Mixpanel hosts data in 3 regions (US, EU, India) with different base URLs. The importer was hardcoded to US endpoints, breaking imports for EU/India projects.

What changed

  • packages/importer/src/providers/mixpanel.tsMixpanelProvider reads MIXPANEL_DATA_RESIDENCY at startup and resolves both the export and engage API base URLs to the correct regional endpoints
  • .env.example — documented with default value
  • apps/public/content/docs/self-hosting/environment-variables.mdx — added to the environment variables reference

How it works

Value Export URL Engage URL
us (default) data.mixpanel.com mixpanel.com
eu data-eu.mixpanel.com eu.mixpanel.com
in data-in.mixpanel.com in.mixpanel.com

Defaults to us if unset — fully backwards compatible.

Test plan

  1. Set MIXPANEL_DATA_RESIDENCY=eu in the worker env
  2. Start a Mixpanel import for an EU-region project
  3. Confirm requests hit data-eu.mixpanel.com (check worker logs)
  4. Unset the var and confirm it falls back to data.mixpanel.com

Closes #359

Summary by CodeRabbit

  • New Features

    • Added Mixpanel data residency support so users can choose the data center for Mixpanel imports (US, EU, India).
  • Documentation

    • Added documentation and example for the new MIXPANEL_DATA_RESIDENCY environment variable, including default value and usage.

… centers

Mixpanel hosts data in 3 regions (US, EU, India) with different base URLs.
The importer was hardcoded to US endpoints, breaking imports for EU/India projects.

Adds MIXPANEL_DATA_RESIDENCY env var (us | eu | in, default: us) that resolves
both the export and engage API base URLs to the correct regional endpoints.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 5, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 756ff079-d950-49bd-b34f-45b8722e4ece

📥 Commits

Reviewing files that changed from the base of the PR and between 509bad8 and 24e97a8.

📒 Files selected for processing (1)
  • packages/importer/src/providers/mixpanel.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/importer/src/providers/mixpanel.ts

📝 Walkthrough

Walkthrough

Adds a Mixpanel data residency option: a new MIXPANEL_DATA_RESIDENCY env var (us | eu | in, default us) plus provider changes so Mixpanel importer uses region-specific base URLs instead of hardcoded US endpoints; docs and .env.example updated.

Changes

Mixpanel Data Residency Configuration

Layer / File(s) Summary
Configuration
.env.example
Added INTEGRATIONS section with MIXPANEL_DATA_RESIDENCY="us" and supported values (eu, in).
Documentation
apps/public/content/docs/self-hosting/environment-variables.mdx
Documented MIXPANEL_DATA_RESIDENCY (type: string, default: us, supported values table, example MIXPANEL_DATA_RESIDENCY=eu).
Core Implementation
packages/importer/src/providers/mixpanel.ts
Introduced static dataResidencyUrls map for us/eu/in; added private readonly residencyUrls resolved from process.env.MIXPANEL_DATA_RESIDENCY with fallback and warning for unknown values.
Control Flow / Endpoints
packages/importer/src/providers/mixpanel.ts
Replaced hardcoded endpoints with region-aware bases: event export uses ${this.residencyUrls.dataBase}/api/2.0/export; profile/engage uses ${this.residencyUrls.apiBase}/api/query/engage?....
Tests / Other
package.json (manifest change)
No behavioral tests added; package manifest noted as touched in minor updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibbled configs near and far,
A residency choice — US, EU, or INR!
Endpoints hop to the proper land,
No more hardcodes by my hand. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding MIXPANEL_DATA_RESIDENCY env var support for EU/India data centers in the importer.
Linked Issues check ✅ Passed The PR fully implements issue #359 requirements: adds MIXPANEL_DATA_RESIDENCY env var with us|eu|in values, switches both export and engage API URLs to regional endpoints, and maintains backwards compatibility.
Out of Scope Changes check ✅ Passed All changes are directly in scope: environment variable configuration, documentation updates, and provider implementation changes aligned with issue #359 objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/importer/src/providers/mixpanel.ts`:
- Around line 64-70: The getResidencyUrls() method currently silently falls back
to the US endpoints when process.env.MIXPANEL_DATA_RESIDENCY is unrecognized;
update getResidencyUrls (or move this logic into the MixpanelProvider
constructor/initializer if a logger instance is needed) to detect when the
chosen residency key is not present in MixpanelProvider.dataResidencyUrls and
emit a clear warning (use this.logger.warn when available, otherwise
console.warn) that includes the invalid env value and that the code is falling
back to "us"; keep the returned fallback behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3b8d15dd-7390-400d-a3de-a908a0552461

📥 Commits

Reviewing files that changed from the base of the PR and between 93ce274 and 509bad8.

📒 Files selected for processing (3)
  • .env.example
  • apps/public/content/docs/self-hosting/environment-variables.mdx
  • packages/importer/src/providers/mixpanel.ts

Comment thread packages/importer/src/providers/mixpanel.ts Outdated
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.

feat: support Mixpanel EU/India data residency for imports

2 participants