Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/plugins/plugin-mixpanel/src/MixpanelPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import group from './methods/group';
import alias from './methods/alias';
import track from './methods/track';

export const EU_SERVER = 'api.eu.mixpanel.com';
export const EU_SERVER = 'https://api-eu.mixpanel.com';
export const US_SERVER = 'https://api.mixpanel.com';
export class MixpanelPlugin extends DestinationPlugin {
type = PluginType.destination;
key = 'Mixpanel';
trackScreens = false;
serverURL = US_SERVER;
private mixpanel: Mixpanel | undefined;
private settings: SegmentMixpanelSettings | undefined;
private isInitialized = () =>
Expand All @@ -41,8 +43,11 @@ export class MixpanelPlugin extends DestinationPlugin {
if (mixpanelSettings.token.length === 0) {
return;
}
if (mixpanelSettings.enableEuropeanEndpoint === true) {
this.serverURL = EU_SERVER;
}
this.mixpanel = new Mixpanel(mixpanelSettings.token, false);
this.mixpanel.init().catch((error) => {
this.mixpanel.init(undefined, undefined, this.serverURL).catch((error) => {
this.analytics?.reportInternalError(
new SegmentError(
ErrorType.PluginError,
Expand All @@ -52,10 +57,6 @@ export class MixpanelPlugin extends DestinationPlugin {
);
});
this.settings = mixpanelSettings;

if (mixpanelSettings.enableEuropeanEndpoint === true) {
this.mixpanel?.setServerURL(EU_SERVER);
}
}

identify(event: IdentifyEventType) {
Expand Down