Skip to content

Custom logger support

Latest
Compare
Choose a tag to compare
@tdumitrescu tdumitrescu released this 12 Sep 18:41
· 1 commit to master since this release

The library can now be initialized with a logger option to provide custom logging instead of the default console logging:

const bunyan = require(`bunyan`);
const mixpanel = Mixpanel.init(`<YOUR_TOKEN>`, {debug: true, logger: bunyan});

Any logger which implements the interface at https://github.com/mixpanel/mixpanel-node/blob/7f334f1d3f07e1c7783887b8090211614a26d5bc/lib/mixpanel-node.d.ts#L9-L15 will work:

export interface CustomLogger {
  trace(message?: any, ...optionalParams: any[]): void;
  debug(message?: any, ...optionalParams: any[]): void;
  info(message?: any, ...optionalParams: any[]): void;
  warn(message?: any, ...optionalParams: any[]): void;
  error(message?: any, ...optionalParams: any[]): void;
}

Support has also been dropped for the long-deprecated Mixpanel.Client() initializer.