Open koshevy opened 4 years ago
Hello! Besides error message, what else do you wanna have here? An error callback listener?
@haoliu-amp Hello! At least, I would like to get correct response (i.e. error response) in already existed callback-param passed to AmplitudeClient.prototype.logEvent:
amplitudeClient.logEvent(eventType, data, (code, status, details) => {
if (code === 200 && status === 'success') {
observer.next();
observer.complete();
return;
}
const reason = (details && details.reason) ? details.reason : 'Unknown reason';
const error = new Error([
`Event ${eventType} failed with data ${JSON.stringify(data)}.`,
`Code and status are: ${code}, ${status}.`,
`The reason is: ${reason}`,
].join(' '));
// I want to get it here, but this place never will be reached if event is wrong
observer.error(error);
});
So, this situation is related with #242. We can't handle error at sending and also we can't continue to use logEvent
. It all does work unstable — we cant controlling our work with statistics and can't be confident and can't make tests efficiently.
utils.validateProperties
brakes wrong events silently (https://github.com/amplitude/Amplitude-JavaScript/blob/v5.10.0/src/utils.js#L102). It only logs errors to console, but don't provide ability to catch this as an error.