Skip to content

Commit adb81ce

Browse files
committed
update webhook response to not return fields, return 200
1 parent 0a8b108 commit adb81ce

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

middleware/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ router.post('/', async function postEvents (req, res, next) {
4444
})
4545
}
4646

47-
return res.status(201).json(fields)
47+
return res.status(200).json({})
4848
})
4949

5050
module.exports = router

tests/rendering/events.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('POST /events', () => {
2020
csrfToken = $('meta[name="csrf-token"]').attr('content')
2121
nock('http://example.com')
2222
.post('/hydro')
23-
.reply(201, {})
23+
.reply(200, {})
2424
})
2525

2626
afterEach(() => {
@@ -74,7 +74,7 @@ describe('POST /events', () => {
7474
const pageExample = { ...baseExample, type: 'page' }
7575

7676
it('should record a page event', () =>
77-
checkEvent(pageExample, 201)
77+
checkEvent(pageExample, 200)
7878
)
7979

8080
it('should require a type', () =>
@@ -128,7 +128,7 @@ describe('POST /events', () => {
128128
...pageExample.context,
129129
page_event_id: baseExample.context.event_id
130130
}
131-
}, 201)
131+
}, 200)
132132
)
133133

134134
it('should not allow a honeypot token', () =>
@@ -295,7 +295,7 @@ describe('POST /events', () => {
295295
}
296296

297297
it('should record an exit event', () =>
298-
checkEvent(exitExample, 201)
298+
checkEvent(exitExample, 200)
299299
)
300300

301301
it('should exit_render_duration is a positive number', () =>
@@ -330,7 +330,7 @@ describe('POST /events', () => {
330330
}
331331

332332
it('should send a link event', () =>
333-
checkEvent(linkExample, 201)
333+
checkEvent(linkExample, 200)
334334
)
335335

336336
it('link_url is a required uri formatted string', () =>
@@ -347,15 +347,15 @@ describe('POST /events', () => {
347347
}
348348

349349
it('should record a search event', () =>
350-
checkEvent(searchExample, 201)
350+
checkEvent(searchExample, 200)
351351
)
352352

353353
it('search_query is required string', () =>
354354
checkEvent({ ...searchExample, search_query: undefined }, 400)
355355
)
356356

357357
it('search_context is optional string', () =>
358-
checkEvent({ ...searchExample, search_context: undefined }, 201)
358+
checkEvent({ ...searchExample, search_context: undefined }, 200)
359359
)
360360
})
361361

@@ -367,11 +367,11 @@ describe('POST /events', () => {
367367
}
368368

369369
it('should record a navigate event', () =>
370-
checkEvent(navigateExample, 201)
370+
checkEvent(navigateExample, 200)
371371
)
372372

373373
it('navigate_label is optional string', () =>
374-
checkEvent({ ...navigateExample, navigate_label: undefined }, 201)
374+
checkEvent({ ...navigateExample, navigate_label: undefined }, 200)
375375
)
376376
})
377377

@@ -385,7 +385,7 @@ describe('POST /events', () => {
385385
}
386386

387387
it('should record a survey event', () =>
388-
checkEvent(surveyExample, 201)
388+
checkEvent(surveyExample, 200)
389389
)
390390

391391
it('survey_vote is boolean', () =>
@@ -411,7 +411,7 @@ describe('POST /events', () => {
411411
}
412412

413413
it('should record an experiment event', () =>
414-
checkEvent(experimentExample, 201)
414+
checkEvent(experimentExample, 200)
415415
)
416416

417417
it('experiment_name is required string', () =>
@@ -423,7 +423,7 @@ describe('POST /events', () => {
423423
)
424424

425425
it('experiment_success is optional boolean', () =>
426-
checkEvent({ ...experimentExample, experiment_success: undefined }, 201)
426+
checkEvent({ ...experimentExample, experiment_success: undefined }, 200)
427427
)
428428
})
429429

@@ -436,7 +436,7 @@ describe('POST /events', () => {
436436
}
437437

438438
it('should record an redirect event', () =>
439-
checkEvent(redirectExample, 201)
439+
checkEvent(redirectExample, 200)
440440
)
441441

442442
it('redirect_from is required url', () =>
@@ -456,7 +456,7 @@ describe('POST /events', () => {
456456
}
457457

458458
it('should record an clipboard event', () =>
459-
checkEvent(clipboardExample, 201)
459+
checkEvent(clipboardExample, 200)
460460
)
461461

462462
it('clipboard_operation is required copy, paste, cut', () =>
@@ -471,7 +471,7 @@ describe('POST /events', () => {
471471
}
472472

473473
it('should record a print event', () =>
474-
checkEvent(printExample, 201)
474+
checkEvent(printExample, 200)
475475
)
476476
})
477477
})

0 commit comments

Comments
 (0)