Search in sources :

Example 1 with AnalyticsProperties

use of com.amplifyframework.analytics.AnalyticsProperties 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));
}
Also used : AnalyticsProperties(com.amplifyframework.analytics.AnalyticsProperties) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) AWSPinpointUserProfile(com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile) UserProfile(com.amplifyframework.analytics.UserProfile) AWSPinpointUserProfile(com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile) Test(org.junit.Test)

Example 2 with AnalyticsProperties

use of com.amplifyframework.analytics.AnalyticsProperties in project amplify-android by aws-amplify.

the class AnalyticsPinpointInstrumentedTest method testIdentifyUserWithDefaultProfile.

/**
 * The {@link AnalyticsCategory#identifyUser(String, UserProfile)} method should set
 * an {@link EndpointProfile} on the Pinpoint {@link TargetingClient}, containing
 * all provided Amplify attributes.
 */
@Test
public void testIdentifyUserWithDefaultProfile() {
    UserProfile.Location location = getTestLocation();
    AnalyticsProperties properties = getEndpointProperties();
    UserProfile userProfile = UserProfile.builder().name("test-user").email("user@test.com").plan("test-plan").location(location).customProperties(properties).build();
    Amplify.Analytics.identifyUser("userId", userProfile);
    EndpointProfile endpointProfile = targetingClient.currentEndpoint();
    assertCommonEndpointProfileProperties(endpointProfile);
    assertNull(endpointProfile.getUser().getUserAttributes());
}
Also used : AnalyticsProperties(com.amplifyframework.analytics.AnalyticsProperties) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) AWSPinpointUserProfile(com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile) UserProfile(com.amplifyframework.analytics.UserProfile) Test(org.junit.Test)

Aggregations

EndpointProfile (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile)2 AnalyticsProperties (com.amplifyframework.analytics.AnalyticsProperties)2 UserProfile (com.amplifyframework.analytics.UserProfile)2 AWSPinpointUserProfile (com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile)2 Test (org.junit.Test)2