Skip to content

Commit

Permalink
Fix issue when sending Amplitude events from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed Jun 22, 2021
1 parent 211932f commit d448b6d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/modules/core/amplitude/amplitudeServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ const amplitudeServerClient = init(process.env.NEXT_PUBLIC_AMPLITUDE_API_KEY, {
/**
* Sends an analytic event to Amplitude.
*
* @param eventType
* @param eventName
* @param userId
*
* @param props
* @see https://developers.amplitude.com/docs/nodejs
*/
export const logEvent = async (eventType: AMPLITUDE_EVENTS, userId: string, props: GenericObject = {}): Promise<void> => {
export const logEvent = async (eventName: AMPLITUDE_EVENTS, userId: string, props: GenericObject = {}): Promise<void> => {
try {
logger.info('Logging Amplitude event', eventType, userId, props);
logger.info(`Logging Amplitude event "${eventName}"${userId ? ` for user "${userId}"` : ''} with properties:`, props);

amplitudeServerClient.logEvent({
event_type: eventType,
user_id: userId,
event_type: eventName,
user_id: userId || '', // User id must be set (even if empty) for the event to be sent correctly
event_properties: {
'customer.ref': process.env.NEXT_PUBLIC_CUSTOMER_REF,
...props,
Expand Down

1 comment on commit d448b6d

@github-actions
Copy link

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.