Skip to content

Commit 1243281

Browse files
committed
fix: Add logging of errors from parsing meta
1 parent 264bbe8 commit 1243281

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/micro-analytics-cli/src/handler.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ function realtimeHandler(req, res) {
2525
}
2626

2727
async function readMeta(req) {
28-
if (await text(req)) {
28+
try {
2929
return (await json(req)).meta;
30+
} catch (error) {
31+
console.error('Failed parsing meta', error);
32+
return null;
3033
}
31-
return null;
3234
}
3335

3436
async function analyticsHandler(req, res) {
@@ -56,13 +58,16 @@ async function analyticsHandler(req, res) {
5658
if (pathname.length <= 1) {
5759
throw createError(400, 'Please include a path to a page.');
5860
}
61+
5962
if (req.method === 'OPTIONS') {
6063
res.setHeader('Access-Control-Allow-Headers', 'content-type');
6164
return send(res, 204);
6265
}
66+
6367
if (req.method !== 'GET' && req.method !== 'POST') {
6468
throw createError(400, 'Please make a GET or a POST request.');
6569
}
70+
6671
const shouldIncrement = String(query.inc) !== 'false';
6772
try {
6873
let meta;

0 commit comments

Comments
 (0)