Identify user
This API sends information about the current user to Amazon Pinpoint.
Additional information such as the user's name, email, location, and device can be included by specifying the UserProfile
. Custom attributes can also be included by setting UserProfile.customProperties
.
If the user was signed in through signIn you can retrieve the current user's ID as shown below:
import { identifyUser } from 'aws-amplify/analytics';import { getCurrentUser } from 'aws-amplify/auth';
const location = { latitude: 47.606209, longitude: -122.332069, postalCode: '98122', city: 'Seattle', region: 'WA', country: 'USA'};
const customProperties = { plan: ['plan'], phoneNumber: ['+11234567890'], age: ['25']};
const userProfile = { location, name: 'username', email: 'name@example.com', customProperties};
async function sendUserData() { const user = await getCurrentUser();
identifyUser({ userId: user.userId, userProfile });}