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));
}
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());
}
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);
}
Aggregations