Mixpanel Implementation

Hello everyone \o

I’m trying to implement the Mixpanel into Forest Admin but I have been running in circles for the past hour.

Expected behavior

Something similar to this:

Actual behavior

That’s my code, I feel the mapping is not quite correct, but I can’t find what would be the right value, tried already only “User”, “User.id”, “User.distinctid”, and had the same result above.

I can’t put console.log in any place that would be helpful.

integrations: {
      mixpanel: {
        apiKey: process.env.MIXPANEL_API_KEY,
        apiSecret: process.env.MIXPANEL_SECRET_KEY,
        mapping: ['User.email'],
        mixpanel: require('mixpanel-data-export')
      },
    },

Thanks in advance,
Isadora Rebelo

Hi @Isadora_Rebelo

Yes, please provide any relevant information in order to investigate.

Hi @Sliman_Medini!

Not sure what I could provide, at the documentation example it’s:

integrations: {
      mixpanel: {
        apiKey: process.env.MIXPANEL_API_KEY,
        apiSecret: process.env.MIXPANEL_SECRET_KEY,
        mapping: ['customers.email'],
        customProperties: ['Campaign Source', 'plan', 'tutorial complete'],
        mixpanel: require('mixpanel-data-export')
      },
    },

I’m pretty much tying to mimic it, but I don’t understand exactly what mapping would suggest:

In our example we will map the customers.email with the data coming from Mixpanel.

I have email on Mixpanel data, and on user Model, so I tried to map with this data.

Also, I have followed each step explained here https://docs.forestadmin.com/woodshop/how-tos/load-smart-fields-using-sequelizes-afterfind-hook , my entire middlewares/forestadmin.js is:

const chalk = require('chalk');
const path = require('path');
const Liana = require('forest-express-mongoose');
const mongoose = require('mongoose');

module.exports = async function (app) {
  app.use(await Liana.init({
    modelsDir: path.join(__dirname, '../models'),
    configDir: path.join(__dirname, '../forest'),
    envSecret: process.env.FOREST_ENV_SECRET,
    authSecret: process.env.FOREST_AUTH_SECRET,
    mongoose,
    integrations: {
      mixpanel: {
        apiKey: process.env.MIXPANEL_API_KEY,
        apiSecret: process.env.MIXPANEL_SECRET_KEY,
        mapping: ['User.email'],
        mixpanel: require('mixpanel-data-export')
      },
    },
  }));

  console.log(chalk.cyan('Your admin panel is available here: https://app.forestadmin.com/projects'));
};

package.json:

   "forest-express-mongoose": "^6.5.1",
    "forest-express-sequelize": "^6.5.0",
    "mixpanel-data-export": "^2.0.2",

Also on the explanation is:

Then, add the following code to your app.js file

But when you see the code shows

middlewares/forestadmin.js

Thanks!

I got a console log, looks the problem is on my plan on Mixpanel, not on Forest, thanks!

1 Like