Skip to content

Commit

Permalink
Record error events
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Nov 12, 2023
1 parent c14d2ae commit 3e13d1f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions app/redux/TransactionSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ function* broadcastOperation(
}
}
yield call(broadcastPayload, {payload})
let eventType = type.replace(/^([a-z])/, g => g.toUpperCase()).replace(/_([a-z])/g, g => g[1].toUpperCase());
if (eventType === 'Comment' && !op.parent_author) eventType = 'Post';
const page = eventType === 'Vote' ? `@${op.author}/${op.permlink}` : '';
serverApiRecordEvent(eventType, page);
} catch(error) {
console.error('TransactionSaga', error)
try {
serverApiRecordEvent('node_error/tx', JSON.stringify(operations) + ' ||| ' + error.toString())
} catch (err2) {
console.error('Cannot record tx error event:', err2)
}
if(errorCallback) errorCallback(error.toString())
}
}
Expand Down Expand Up @@ -222,6 +223,12 @@ function* broadcastPayload({payload: {operations, keys, username, hideErrors, su
console.error('TransactionSaga\tbroadcast', error)
// status: error

try {
serverApiRecordEvent('node_error/tx_broadcast', JSON.stringify(operations) + ' ||| ' + error.toString())
} catch (err2) {
console.error('Cannot record tx broadcast error event:', err2)
}

yield put(tr.actions.error({operations, error, hideErrors, errorCallback}))

for (const [type, operation] of operations) {
Expand Down
1 change: 0 additions & 1 deletion server/api/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default function useGeneralApi(app) {
const params = ctx.request.body;
const {csrf, type, value} = typeof(params) === 'string' ? JSON.parse(params) : params;
if (!ctx.checkCSRF(csrf)) return;
console.log('-- /record_event -->', ctx.session.uid, type, value);
const str_value = typeof value === 'string' ? value : JSON.stringify(value);
recordWebEvent(ctx, type, str_value);
ctx.body = JSON.stringify({status: 'ok'});
Expand Down
1 change: 1 addition & 0 deletions server/record_web_event.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export default function recordWebEvent(ctx, event_type, value) {
console.log('-- /record_event -->', event_type, value)
}

0 comments on commit 3e13d1f

Please sign in to comment.