I have an app that the user can use anonymously or login via facebook. All are linked to Cognito. When using the app they call a lambda to save items they like. I use the unique cognito identity id to save these items in a DynamoDB table. This unique ID is supplied in the lambda event;
{
...,
event.requestContext.identity.cognitoIdentityId: 'ap-..
...
}
I am at a bit of a loss in how to resolve this scenario.
T1
The user logs in via Facebook and saves some items. They are saved in a DynamoDB table under say id ap-1. All good.
T2
User deletes the app and downloads again a month later. This time they skip login and are given anonymous access under id ap-2. They save some more items which are saved in DynamoDB under id ap-2.
T3
The user realises that they forgot to login via Facebook so they complete the Facebook login. As they have already logged in via Facebook before they will be issued id ap-1. This merges ap-2 into ap-1 and uses ap-1 for all requests. Now they will see all items saved from T1 but not from T2.
Is there any way to hook in to merge event here or something to handle updating the records? I couldn't find any documentation on it.