Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(analytics): correctly extract statusCode from failed request #5618

Merged
merged 6 commits into from Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/analytics/src/Providers/AWSPinpointProvider.ts
Expand Up @@ -431,8 +431,9 @@ export class AWSPinpointProvider implements AnalyticsProvider {

private async _handleEndpointUpdateFailure(failureData: EndpointFailureData) {
const { err, endpointObject } = failureData;
const { statusCode } = err;
logger.debug('updateEndpoint failed', err);
const statusCode = err.$metadata && err.$metadata.httpStatusCode;

logger.error('updateEndpoint failed', err);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoints seem to update successfully now, but this message is still in the log and is now throwing an error despite the success:

error message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, that's a regression introduced in this PR. Will restore it to logger.debug

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a similar problem with the 'Missing address' warning now turned into an error, but I noticed that your PR reverts that as well.

IMG_9535F2591BC3-1


switch (statusCode) {
case BAD_REQUEST_CODE:
Expand Down Expand Up @@ -482,6 +483,7 @@ export class AWSPinpointProvider implements AnalyticsProvider {

private _handleEndpointUpdateForbidden(failureData: EndpointFailureData) {
const { err, endpointObject } = failureData;

const { code, retryable } = err;

if (code !== EXPIRED_TOKEN_CODE && !retryable) {
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/src/Providers/EventBuffer.ts
Expand Up @@ -150,8 +150,8 @@ export default class EventsBuffer {
}

private _handlePutEventsFailure(err, eventMap: EventMap) {
logger.debug('_putEvents Failed:', err);
const { statusCode } = err;
logger.error('_putEvents Failed: ', err);
const statusCode = err.$metadata && err.$metadata.httpStatusCode;

if (RETRYABLE_CODES.includes(statusCode)) {
const retryableEvents = Object.values(eventMap);
Expand Down