mixpanel / mixpanel-node

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

Typescript error when using secret #227

Open penfold45 opened 11 months ago

penfold45 commented 11 months ago

In commit 600d6abee19aa83af7b2c43525d57fdc2b758ee7. InitConfig was updated as per bellow However secret is not listed here. I assume this was not intentional as the option is still defined in README.

Obviously now I have typescript issues


  export interface InitConfig {
  -  [key: string]: any;
  +  test: boolean;
  +  debug: boolean;
  +  verbose: boolean;
  +  host: string;
  +  protocol: string;
  +  path: string;
  +  keepAlive: boolean;
  +  geolocate: boolean;
  +  logger: CustomLogger;
  }
willemclarke commented 11 months ago

I have same issue as OP - basically for node-js SDK it seems the import method requires initialising Mixpanel with both project token and secret. Given the type of InitConfig was just Record<string, any> before is it just a matter of adding a secret: string to InitConfig?

As taken from readme:

var mixpanel_importer = Mixpanel.init('valid mixpanel token', {
    secret: 'valid api secret for project'
});

edit: I see theres currently an open PR for this exact issue: https://github.com/mixpanel/mixpanel-node/pull/225

edit: as a workaround, albeit not ideal - you can just typecast the config object

  this.mixpanel = Mixpanel.init(projectToken, {
        debug: true,
        secret: "YOUR_SECRET",
      } as unknown as Mixpanel.InitConfig);
austinpray-mixpanel commented 6 months ago

Seeing same thing image

library is aware that this config is needed: image

Will sling a PR to make this go away