use of com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile in project amplify-android by aws-amplify.
the class AnalyticsPinpointInstrumentedTest method testIdentifyUserWithUserAtrributes.
/**
* {@link AWSPinpointUserProfile} extends {@link UserProfile} to include
* {@link AWSPinpointUserProfile#userAttributes} which is specific to Pinpoint. This test is very
* similar to testIdentifyUserWithDefaultProfile, but it adds user attributes in additional
* to the endpoint attributes.
*/
@Test
public void testIdentifyUserWithUserAtrributes() {
UserProfile.Location location = getTestLocation();
AnalyticsProperties properties = getEndpointProperties();
AnalyticsProperties userAttributes = getUserAttributes();
AWSPinpointUserProfile pinpointUserProfile = AWSPinpointUserProfile.builder().name("test-user").email("user@test.com").plan("test-plan").location(location).customProperties(properties).userAttributes(userAttributes).build();
Amplify.Analytics.identifyUser("userId", pinpointUserProfile);
EndpointProfile endpointProfile = targetingClient.currentEndpoint();
assertCommonEndpointProfileProperties(endpointProfile);
assertEquals("User attribute value", endpointProfile.getUser().getUserAttributes().get("SomeUserAttribute").get(0));
}
use of com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile in project amplify-android by aws-amplify.
the class AWSPinpointAnalyticsPlugin method identifyUser.
@Override
public void identifyUser(@NonNull String userId, @Nullable UserProfile userProfile) {
Objects.requireNonNull(userId);
EndpointProfile endpointProfile = targetingClient.currentEndpoint();
// Assign userId to the endpoint.
EndpointProfileUser user = new EndpointProfileUser();
user.setUserId(userId);
if (userProfile instanceof AWSPinpointUserProfile) {
AWSPinpointUserProfile pinpointUserProfile = (AWSPinpointUserProfile) userProfile;
if (pinpointUserProfile.getUserAttributes() != null) {
addUserAttributes(user, pinpointUserProfile.getUserAttributes());
}
}
endpointProfile.setUser(user);
// Add user-specific data to the endpoint
if (userProfile != null) {
addUserProfileToEndpoint(endpointProfile, userProfile);
}
// update endpoint
targetingClient.updateEndpointProfile(endpointProfile);
}
Aggregations