Amplify-js: `Analytics.record` will send request to localhost

Created on 26 Apr 2020  路  10Comments  路  Source: aws-amplify/amplify-js

Describe the bug
Analytics.record("xxx") will send request to localhost, instead of the AWS endpoint

To Reproduce
I followed the Web app analytics guide in Pinpoint -> All projects -> My App -> Settings -> Web app analytics.

Using following code:

import Analytics from '@aws-amplify/analytics';
import Auth from '@aws-amplify/auth';

const amplifyConfig = {
  Auth: {
    identityPoolId: 'dummy',
    region: 'us-west-2'
  }
}
//Initialize Amplify
Auth.configure(amplifyConfig);

const analyticsConfig = {
  AWSPinpoint: {
        // Amazon Pinpoint App Client ID
        appId: 'dummy',
        // Amazon service region
        region: 'us-west-2',
        mandatorySignIn: false,
  }
}

Analytics.configure(analyticsConfig)

//Record an event
Analytics.record('some-event-name');

And Analytics.record will send a fetch request to https://localhost/ with request payload {IdentityPoolId: "us-west-2:XXXXXXXXX"}

Expected behavior
Record should be send to aws pinpoint server, not localhost

What is Configured?
All configs are in the code snap

Additional context

Logs

[DEBUG] 43:34.873 AWSPinpointProvider - _public record {event: {鈥, provider: "AWSPinpoint"}
VM4289:9431 [DEBUG] 43:34.874 Credentials - getting credentials
VM4289:9431 [DEBUG] 43:34.874 Credentials - picking up credentials
VM4289:9431 [DEBUG] 43:34.875 Credentials - getting new cred promise
VM4289:9431 [DEBUG] 43:34.875 Credentials - checking if credentials exists and not expired
VM4289:9431 [DEBUG] 43:34.875 Credentials - need to get a new credential or refresh the existing one
VM4289:9431 [DEBUG] 43:34.876 AuthClass - Getting current user credentials
VM4289:9431 [DEBUG] 43:34.877 AuthClass - Getting current session
VM4289:9441 [DEBUG] 43:34.877 AuthClass - getting session failed undefined
VM4289:9431 [DEBUG] 43:34.878 Credentials - setting credentials for guest
Promise聽{<pending>}__proto__: Promise[[PromiseStatus]]: "pending"[[PromiseValue]]: undefined
VM4289:9441 [DEBUG] 44:37.982 Credentials - Failed to load credentials Promise聽{<rejected>: TypeError: Failed to fetch}
VM4289:9441 [DEBUG] 44:37.983 AWSPinpointProvider - set credentials for analytics TypeError: Failed to fetch
VM4289:9431 [DEBUG] 44:37.985 AWSPinpointProvider - init clients
VM4289:9441 [DEBUG] 44:37.985 AWSPinpointProvider - init clients with credentials {accessKeyId: undefined, sessionToken: undefined, secretAccessKey: undefined, identityId: undefined, authenticated: undefined}
VM4289:9441 [DEBUG] 44:37.995 EventsBuffer - Instantiating buffer with config: {bufferSize: 1000, flushSize: 100, flushInterval: 5000, resendLimit: 5, disabled: undefined,聽鈥
Analytics bug

Most helpful comment

We have figured out the root cause, aws_sdk version got upgraded on friday and the client versions that amplify-js are using is incompatible with the upgraded dependencies.

We are working with aws-sdk team to fix this as soon as possible

All 10 comments

I am also seeing this issue occur with Storage requests.
Screen Shot 2020-04-26 at 12 57 39 PM

I originally thought this was related to the host header deletion happening in #5508 , but I think if that were the problem it shouldn't be impacting the Analytics package.

I have been banging my head on this for half a day on storage request too..

We have figured out the root cause, aws_sdk version got upgraded on friday and the client versions that amplify-js are using is incompatible with the upgraded dependencies.

We are working with aws-sdk team to fix this as soon as possible

we have rolled back aws-sdk changes so this should be working fine again. Please delete your lock files and node_modules before trying again and let us know if that works.

The rollback is working for me. Thank you!

@abnerlee Can you confirm that the rollback has resolved your issue? Thanks ahead of time!

I hit the same issue with Storage.get and removing package-lock.json, removing node_modules and re-installing worked for me.

@sammartinez the rollback worked for me. thank you

Resolving issue as issue is fixed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

romainquellec picture romainquellec  路  3Comments

benevolentprof picture benevolentprof  路  3Comments

ldgarcia picture ldgarcia  路  3Comments

karlmosenbacher picture karlmosenbacher  路  3Comments

oste picture oste  路  3Comments