Search in sources :

Example 11 with EndpointProfile

use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile in project aws-sdk-android by aws-amplify.

the class TargetingClientTest method endpoint_globalAttributeAndMetricSpecific_doesNotOverrideLocalAttribute.

@Test
public void endpoint_globalAttributeAndMetricSpecific_doesNotOverrideLocalAttribute() {
    final List attrVals1 = Arrays.asList(new String[] { "attr1", "attr2" });
    final List attrVals2 = Arrays.asList(new String[] { "attr3", "attr4" });
    targetingClient.addAttribute("c", attrVals1);
    targetingClient.addMetric("metric", 3.0);
    final EndpointProfile endpointProfile = targetingClient.currentEndpoint().withAttribute("c", attrVals2).withMetric("metric", 1.0);
    assertThat(endpointProfile.getAttribute("c"), is(attrVals2));
    assertThat(endpointProfile.getMetric("metric"), is(1.0));
}
Also used : EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) List(java.util.List) Test(org.junit.Test)

Example 12 with EndpointProfile

use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile 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)

Example 13 with EndpointProfile

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

Aggregations

EndpointProfile (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile)13 Test (org.junit.Test)10 EndpointProfileUser (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser)3 AWSPinpointUserProfile (com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile)3 AnalyticsContextBuilder (com.amazonaws.mobileconnectors.pinpoint.analytics.utils.AnalyticsContextBuilder)2 MockDeviceDetails (com.amazonaws.mobileconnectors.pinpoint.internal.core.system.MockDeviceDetails)2 AnalyticsProperties (com.amplifyframework.analytics.AnalyticsProperties)2 UserProfile (com.amplifyframework.analytics.UserProfile)2 List (java.util.List)2 Locale (java.util.Locale)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 Before (org.junit.Before)2 NotificationManager (android.app.NotificationManager)1 Context (android.content.Context)1 PinpointContext (com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext)1 TargetingClient (com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient)1 EndpointProfileDemographic (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileDemographic)1 EndpointProfileLocation (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileLocation)1 UpdateEndpointRequest (com.amazonaws.services.pinpoint.model.UpdateEndpointRequest)1 MissingResourceException (java.util.MissingResourceException)1