d00fe7bcd2
* Make `sendEmail` functions await email send success * Make tracking and email sending not throw on failure
27 lines
654 B
TypeScript
27 lines
654 B
TypeScript
import * as Amplitude from '@amplitude/node'
|
|
|
|
import { DEV_CONFIG } from '../../common/envs/dev'
|
|
import { PROD_CONFIG } from '../../common/envs/prod'
|
|
|
|
import { isProd, tryOrLogError } from './utils'
|
|
|
|
const key = isProd() ? PROD_CONFIG.amplitudeApiKey : DEV_CONFIG.amplitudeApiKey
|
|
|
|
const amp = Amplitude.init(key ?? '')
|
|
|
|
export const track = async (
|
|
userId: string,
|
|
eventName: string,
|
|
eventProperties?: any,
|
|
amplitudeProperties?: Partial<Amplitude.Event>
|
|
) => {
|
|
return await tryOrLogError(
|
|
amp.logEvent({
|
|
event_type: eventName,
|
|
user_id: userId,
|
|
event_properties: eventProperties,
|
|
...amplitudeProperties,
|
|
})
|
|
)
|
|
}
|