|
|
@ -7,10 +7,6 @@ import * as querystring from 'querystring'; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: send webhook with payload without dep to AnalyticUnit
|
|
|
|
// TODO: send webhook with payload without dep to AnalyticUnit
|
|
|
|
export async function sendWebhook(analyticUnitName: string, segment: Segment) { |
|
|
|
export async function sendWebhook(analyticUnitName: string, segment: Segment) { |
|
|
|
if(HASTIC_WEBHOOK_URL === null) { |
|
|
|
|
|
|
|
throw new Error(`Can't send alert, HASTIC_WEBHOOK_URL is undefined`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const alert = { |
|
|
|
const alert = { |
|
|
|
analyticUnitName, |
|
|
|
analyticUnitName, |
|
|
|
from: segment.from, |
|
|
|
from: segment.from, |
|
|
@ -19,6 +15,10 @@ export async function sendWebhook(analyticUnitName: string, segment: Segment) { |
|
|
|
|
|
|
|
|
|
|
|
console.log(`Sending alert: ${JSON.stringify(alert)}`); |
|
|
|
console.log(`Sending alert: ${JSON.stringify(alert)}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(HASTIC_WEBHOOK_URL === null) { |
|
|
|
|
|
|
|
throw new Error(`Can't send alert, HASTIC_WEBHOOK_URL is undefined`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let payload; |
|
|
|
let payload; |
|
|
|
if(HASTIC_WEBHOOK_TYPE === 'application/json') { |
|
|
|
if(HASTIC_WEBHOOK_TYPE === 'application/json') { |
|
|
|
payload = JSON.stringify(alert); |
|
|
|
payload = JSON.stringify(alert); |
|
|
|