From d448b6ddbb2fdd36a6e05d2d1a59790895d6f634 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Tue, 22 Jun 2021 12:56:51 +0200 Subject: [PATCH] Fix issue when sending Amplitude events from backend --- src/modules/core/amplitude/amplitudeServerClient.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/core/amplitude/amplitudeServerClient.ts b/src/modules/core/amplitude/amplitudeServerClient.ts index abf0cdb5..82c7bae7 100644 --- a/src/modules/core/amplitude/amplitudeServerClient.ts +++ b/src/modules/core/amplitude/amplitudeServerClient.ts @@ -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 => { +export const logEvent = async (eventName: AMPLITUDE_EVENTS, userId: string, props: GenericObject = {}): Promise => { 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,