Closed PrasannaLearnyst closed 6 years ago
@PrasannaLearnyst
Could you check if you have this message when the app is switched to background: https://github.com/aws-amplify/amplify-js/blob/master/packages/analytics/src/trackers/SessionTracker-rn.ts#L73
The credentials do get updated when the request is sent. The debug info you pasted is not an error message.
Why do you want to restore the UserId? Are you using your own? By default Amplify would use the identityId from the aws credentials as the UserId.
@powerful23 thanks for the reply
Could you check if you have this message when the app is switched to background No i'm unable to get "App has come to inactive/background, recording stop session"
The credentials do get updated when the request is sent. The debug info you pasted is not an error message. Yes, its not a error, i have checked Auth.ts. Its credentials are taken from storage and as per the docs the storage will be using asyncstorage in react native but its not done on app closed and reopen
After federated developer auth is success, the next app opens has to take the credentials from aws-amplify-federatedInfo its not taking from there.
please correct me if i'm wrong.
I need to send user related data to the pinpoint where it pushes to kinesis -> s3. Is there option to set global attributes where those attributes will be send with all events to pinpoint.
==== Amplify: "version": "1.1.6"
"dependencies": { "@aws-amplify/analytics": "^1.2.3", "@aws-amplify/api": "^1.0.17", "@aws-amplify/auth": "^1.2.6", "@aws-amplify/cache": "^1.0.15", "@aws-amplify/core": "^1.0.15", "@aws-amplify/interactions": "^1.0.15", "@aws-amplify/pubsub": "^1.0.15", "@aws-amplify/storage": "^1.0.15", "@aws-amplify/xr": "^0.1.5" }
Update: This is the things i'm doing on init
let credentials = await Auth.currentCredentials()
.catch(err => console.log(err));
on success/ fail
Amplify.configure({
Auth: {
identityPoolId: COGNITO_IDENTITY_POOL_ID,
mandatorySignIn: false,
region: REGION,
},
refreshHandlers: {
'developer': async () => {
await refreshToken();
}
},
AWSPinpoint: {
appId: MOBILE_ANALYTICS_APP_ID,
region: REGION,
mandatorySignIn: false,
autoSessionRecord: true
}
});
what is the recommended approach to configure because the session_start request is made before restore of credentials
i need to restore my federated developer credential on app restart
@PrasannaLearnyst I am not understanding how you are initing. The desired way is first configuring Amplify(by the way the configuration is not correct):
Amplify.configure({
Auth: {
identityPoolId: COGNITO_IDENTITY_POOL_ID,
mandatorySignIn: false,
region: REGION,
refreshHandlers: {
}
},
Analytics: {
AWSPinpoint: {
appId: MOBILE_ANALYTICS_APP_ID,
region: REGION,
autoSessionRecord: true
}
}
});
The library will automatically get a credentials(guest or authenticated based on whether you are signed in or not) before sending the start session event.
@powerful23
Sorry got it.
When i checked the AsyncStorage there are credentials, but the amplify when retrieve the credentials its getting error message as
{[DEBUG] 02:17.526 AuthClass - failed to get or parse item aws-amplify-federatedInfo: SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (
"SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (
@powerful23
In this file Auth.ts#L1012
you are getting the user details but its not stored in this key, rather its stored in key
aws-amplify-cachefederatedInfo
or
@MemoryStorage:aws-amplify-federatedInfo
can you please cross check once
@powerful23 Sorry,
The StorageHelper.getItem it will be taken from datastorage, for the datastorage the source is sync method of StorageHelper.
the sync is not called, how to make the data sync.
thanks
@powerful23 can you please provide me any guidance on this i'm importing all the classes from
import Amplify, { Auth, Analytics } from 'aws-amplify';
for react native do i need to import from any other package.
I have changed my config as you said
Amplify.configure({
Auth: {
identityPoolId: COGNITO_IDENTITY_POOL_ID,
mandatorySignIn: false,
region: REGION,
refreshHandlers: {
}
},
Analytics: {
AWSPinpoint: {
appId: MOBILE_ANALYTICS_APP_ID,
region: REGION,
autoSessionRecord: true
}
}
});
i've checked in cache the details persist, kindly help me in restore of credentials on app restart
@PrasannaLearnyst yes, the way you import is correct. We will test if stop session events are sent as expected.
@powerful23 no, the stop session events are not sent as expected
@powerful23
any update?
@PrasannaLearnyst confirmed. Will mark this as bug.
@powerful23 thanks
can you please review this pull request or whats the process of getting it reviewed.
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Configuration
=============
Describe the bug
The _session_start events are automatically pushed to pinpoint but unable to receive the _session_stop, do it need to send manually
AWS auth credentials are not getting updated on init
Error stack
[DEBUG] 05:39.335 AuthClass - failed to get or parse item aws-amplify-federatedInfo: SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>) at AuthClass.currentUserCredentials (blob:http://localhost:8081/...) at Credentials._keepAlive (blob:http://localhost:8081/...) at Credentials._pickupCredentials (blob:http://localhost:8081/...:86) at Credentials.get (blob:http://localhost:8081/...25) at AWSPinpointProvider._getCredentials (blob:http://localhost:8081/...:39) at AWSPinpointProvider.<anonymous> (blob:http://localhost:8081/...:151681:45) at step (blob:http://localhost:8081/...:151483:31) at Object.next (blob:http://localhost:8081/...:151413:24) at blob:http://localhost:8081/...:151385:75
Smartphone (please complete the following information):