Skip to content

Commit

Permalink
mixpanel-destination:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Aug 9, 2023
1 parent 6bfce45 commit b7331bf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libs/core-functions/src/functions/mixpanel-destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ const MixpanelDestination: JitsuFunction<AnalyticsServerEvent, MixpanelCredentia
const messages: HttpRequest[] = [];
if (event.type === "identify") {
if (!event.userId) {
const distinctId = `${event.anonymousId || event.traits?.email}`;
const distinctId = `${(event.anonymousId || event.traits?.email) ?? ""}`;
if (!distinctId) {
ctx.log.info(`No distinct id found for event ${JSON.stringify(event)}`);
} else if (ctx.props.enableAnonymousUserProfiles) {
messages.push(...setProfileMessage(distinctId as string, event, ctx.props));
messages.push(...setProfileMessage(distinctId, event, ctx.props));
}
if (event.anonymousId && event.traits?.email) {
messages.push(merge(`${event.anonymousId}`, `${event.traits.email}`, ctx.props));
Expand All @@ -214,15 +214,15 @@ const MixpanelDestination: JitsuFunction<AnalyticsServerEvent, MixpanelCredentia
messages.push(...setProfileMessage(`${event.userId}`, event, ctx.props));
}
if (ctx.props.sendIdentifyEvents) {
const distinctId = `${event.userId || event.traits?.email || event.anonymousId}`;
const distinctId = `${(event.userId || event.traits?.email || event.anonymousId) ?? ""}`;
if (distinctId) {
messages.push(trackEvent(distinctId, "Identify", event, ctx.props));
}
}
} else if (event.type === "group" && ctx.props.enableGroupAnalytics) {
messages.push(setGroupMessage(event, ctx.props));
} else if (event.type === "track") {
const distinctId = `${event.userId || event.anonymousId || event.traits?.email}`;
const distinctId = `${(event.userId || event.anonymousId || event.traits?.email) ?? ""}`;
if (!distinctId) {
ctx.log.info(`No distinct id found for event ${JSON.stringify(event)}`);
} else {
Expand All @@ -231,7 +231,7 @@ const MixpanelDestination: JitsuFunction<AnalyticsServerEvent, MixpanelCredentia
}
}
} else if (event.type === "page") {
const distinctId = `${event.userId || event.anonymousId || event.traits?.email}`;
const distinctId = `${(event.userId || event.anonymousId || event.traits?.email) ?? ""}`;
if (!distinctId) {
ctx.log.info(`No distinct id found for Page View event ${JSON.stringify(event)}`);
} else {
Expand Down

1 comment on commit b7331bf

@vercel
Copy link

@vercel vercel bot commented on b7331bf Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.