From 90c1f7b45478538189193ae686647fdf0571c549 Mon Sep 17 00:00:00 2001 From: Jake Bolam Date: Sun, 27 Jan 2019 00:00:35 -0500 Subject: [PATCH] fix: ensure amplitude_api_key is set --- src/utils/Analytics.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/utils/Analytics.js b/src/utils/Analytics.js index e426c072..af7b4e60 100644 --- a/src/utils/Analytics.js +++ b/src/utils/Analytics.js @@ -3,13 +3,20 @@ const nodeFetch = require('node-fetch') const { URLSearchParams } = require('url') class Analytics { - constructor({ user, repo, owner, apiKey, log, funnelId }) { + constructor({ + user, + repo, + owner, + apiKey = process.env.AMPLITUDE_API_KEY, + log, + funnelId = uuid.v4(), + }) { this.user = user this.repo = repo this.owner = owner this.eventPromises = [] - this.funnel_id = funnelId || uuid.v4() - this.apiKey = apiKey || process.env.AMPLITUDE_API_KEY + this.funnelId = funnelId + this.apiKey = apiKey this.log = log } @@ -26,7 +33,7 @@ class Analytics { owner: this.owner, }, event_properties: { - funnel_id: this.funnel_id, + funnel_id: this.funnelId, ...metadata, }, }