I've just completed a migration of dev/test/prod environments to new projects to take advantage of simplified Id merge.
This tool was really helpful in giving us the confidence to attempt to do so and the project was successful over all but I did encounter a range of problems during this migration and I'll note them here for your info
I'm afraid I no longer have the log to share, but trying to migrate a Dashboard with "template_type": "Marketing KPI", failed; we instead used the UI to move it between the projects
diff --git a/endpoints.js b/endpoints.js
index 6884e72..34a9b09 100644
--- a/endpoints.js
+++ b/endpoints.js
@@ -105,8 +105,8 @@ exports.getInsightsReport = function (projectId, region = `US`) {
return `https://${getRegion(region)}mixpanel.com/api/2.0/insights?project_id=${projectId}`;
};
-exports.dataExport = function (start, end, region = `US`) {
- return `https://data.${region?.toLowerCase() === 'eu' ? "eu." : ""}mixpanel.com/api/2.0/export?from_date=${start}&to_date=${end}`;
+exports.dataExport = function (start, end, region = `US`, projectId) {
+ return `https://${region?.toLowerCase() === 'eu' ? "data-eu" : "data"}.mixpanel.com/api/2.0/export?project_id=${projectId}&from_date=${start}&to_date=${end}`;
};
exports.profileExport = function (projectId, region = `US`) {
diff --git a/utils.js b/utils.js
index 3a2eb30..cd02758 100644
--- a/utils.js
+++ b/utils.js
@@ -726,19 +726,17 @@ DATA EXPORT
exports.exportAllEvents = async function (source) {
const startDate = dayjs(source.start).format(dateFormat);
const endDate = dayjs(source.end).format(dateFormat);
- const url = URLs.dataExport(startDate, endDate, source?.region);
+ const url = URLs.dataExport(startDate, endDate, source?.region, source.project);
const file = path.resolve(`${source.localPath}/exports/events.ndjson`);
const writer = createWriteStream(file);
- const auth = Buffer.from(source.secret + '::').toString('base64');
const response = await fetch({
method: 'GET',
url,
headers: {
- Authorization: `Basic ${auth}`
+ Authorization: `${source.auth}`
},
responseType: 'stream'
});
-
response.data.pipe(writer);
//why can't i pass the fileName to resolve()
@@ -750,16 +748,15 @@ exports.exportAllEvents = async function (source) {
};
exports.exportAllProfiles = async function (source, target) {
- const auth = Buffer.from(source.secret + '::').toString('base64');
let iterations = 0;
let fileName = `people-${iterations}.json`;
let folder = path.resolve(`${source.localPath}/exports/profiles/`);
let file = path.resolve(`${folder}/${fileName}`);
let response = (await fetch({
method: 'POST',
- url: URLs.profileExport(source.projId, source?.region),
+ url: URLs.profileExport(source.project, source?.region),
headers: {
- Authorization: `Basic ${auth}`
+ Authorization: `${source.auth}`
},
})).data;
@@ -796,7 +793,7 @@ exports.exportAllProfiles = async function (source, target) {
response = (await fetch({
method: 'POST',
- url: URLs.profileExport(source.projId, source?.region),
+ url: URLs.profileExport(source.project, source?.region),
headers: {
Authorization: `Basic ${auth}`
},
@@ -1395,8 +1392,8 @@ const matchCustomEntities = async function (sourceCreds, sourceEntities, targetE
let sourceCohortList = [];
if (sourceCreds) {
- const { projId, workspace, auth, region } = sourceCreds;
- sourceCohortList = (await fetch(URLs.listCohorts(projId, workspace, region), {
+ const { project, workspace, auth, region } = sourceCreds;
+ sourceCohortList = (await fetch(URLs.listCohorts(project, workspace, region), {
method: `POST`,
headers: {
Authorization: auth
I've just completed a migration of dev/test/prod environments to new projects to take advantage of simplified Id merge.
This tool was really helpful in giving us the confidence to attempt to do so and the project was successful over all but I did encounter a range of problems during this migration and I'll note them here for your info
Failure to migrate events
I encountered 2 issues with migrating events
data.mixpanel.comtodata-eu.mixpanel.comFailure to migrate dashboards using template
I'm afraid I no longer have the log to share, but trying to migrate a Dashboard with
"template_type": "Marketing KPI",failed; we instead used the UI to move it between the projectsI was unable to use the
npxbased approach because of these issues and instead cloned the project and applied some local patches; see below