Skip to content

Commit 90c1f7b

Browse files
committed
fix: ensure amplitude_api_key is set
1 parent 818d0ba commit 90c1f7b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/utils/Analytics.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ const nodeFetch = require('node-fetch')
33
const { URLSearchParams } = require('url')
44

55
class Analytics {
6-
constructor({ user, repo, owner, apiKey, log, funnelId }) {
6+
constructor({
7+
user,
8+
repo,
9+
owner,
10+
apiKey = process.env.AMPLITUDE_API_KEY,
11+
log,
12+
funnelId = uuid.v4(),
13+
}) {
714
this.user = user
815
this.repo = repo
916
this.owner = owner
1017
this.eventPromises = []
11-
this.funnel_id = funnelId || uuid.v4()
12-
this.apiKey = apiKey || process.env.AMPLITUDE_API_KEY
18+
this.funnelId = funnelId
19+
this.apiKey = apiKey
1320
this.log = log
1421
}
1522

@@ -26,7 +33,7 @@ class Analytics {
2633
owner: this.owner,
2734
},
2835
event_properties: {
29-
funnel_id: this.funnel_id,
36+
funnel_id: this.funnelId,
3037
...metadata,
3138
},
3239
}

0 commit comments

Comments
 (0)