-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (29 loc) · 778 Bytes
/
index.js
File metadata and controls
32 lines (29 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function composeWebhook (_event, { config }) {
const event = _event.event
if (event.startsWith('$')) {
// only process a specific set of custom events
if (!['$identify', '$groupidentify', '$set', '$unset', '$create_alias'].includes(event)) {
return null
}
}
// Ignore plugin events
if (event.startsWith('plugin')) {
return null
}
const auth = 'Basic ' + Buffer.from(`${config.publicKey}:${config.secret}`).toString('base64')
delete config.publicKey
delete config.secret
_event.config = config
return {
url: 'https://api.engage.so/posthog',
body: JSON.stringify(_event),
headers: {
'Content-Type': 'application/json',
Authorization: auth
},
method: 'POST'
}
}
module.exports = {
composeWebhook
}