mixpanel / mixpanel-node

A node.js API for mixpanel
http://www.mixpanel.com
MIT License
477 stars 159 forks source link

Wrong documentation for EU data residency #178

Closed all-things-liquid closed 4 years ago

all-things-liquid commented 4 years ago

Hello,

I've encountered an issue when trying to change the host for EU data residency. The documentation suggests the following modification:

mixpanel.init(
  "YOUR_TOKEN",
  {
    host: "https://api-eu.mixpanel.com",
  },
);

This contradicts the code, where the default config is as follows:

const DEFAULT_CONFIG = {
    test: false,
    debug: false,
    verbose: false,
    host: 'api.mixpanel.com',
    protocol: 'https',
    path: '',
};

And more importantly, it is incompatible with the way metrics.set_config overrides the host, as it would mess up the result of the split call:

metrics.set_config = function(config) {
    Object.assign(metrics.config, config);
    if (config.host) {
        // Split host into host and port
        const [host, port] =  config.host.split(':');
        metrics.config.host = host;
        if (port) {
            metrics.config.port = Number(port);
        }
    }
};

I don't know if this is the right place to ask this, but could someone edit the documentation so that host becomes api-eu.mixpanel.com?

Thank you for your help

tdumitrescu commented 4 years ago

Thanks for pointing out! We'll get this fixed on the documentation site.

jordanmnunez commented 4 years ago

This has been fixed. Thanks again for sharing with us!