Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev-v2.0.1 -> staging #110

Merged
merged 8 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 3 additions & 54 deletions Documentation/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ String extensionVersion = Identity.extensionVersion();

#### Kotlin

##### Syntax
```kotlin
fun extensionVersion(): String
```

##### Example
```kotlin
val extensionVersion = Identity.extensionVersion()
Expand Down Expand Up @@ -77,11 +72,6 @@ Identity.getExperienceCloudId(new AdobeCallback<String>() {

#### Kotlin

##### Syntax
```kotlin
fun getExperienceCloudId(callback: AdobeCallback<String>)
```

##### Example
```kotlin
Identity.getExperienceCloudId { id ->
Expand Down Expand Up @@ -118,11 +108,6 @@ Identity.getIdentities(new AdobeCallback<IdentityMap>() {

#### Kotlin

##### Syntax
```kotlin
fun getIdentities(callback: AdobeCallback<IdentityMap>)
```

##### Example
```kotlin
Identity.getIdentities { identityMap ->
Expand Down Expand Up @@ -170,11 +155,6 @@ Identity.getUrlVariables(new AdobeCallback<String>() {

#### Kotlin

##### Syntax
```kotlin
fun getUrlVariables(callback: AdobeCallback<String>)
```

##### Example
```kotlin
Identity.getUrlVariables { urlVariablesString ->
Expand Down Expand Up @@ -214,11 +194,6 @@ Identity.registerExtension();

#### Kotlin

##### Syntax
```kotlin
fun registerExtension()
```

##### Example
```kotlin
Identity.registerExtension()
Expand Down Expand Up @@ -253,11 +228,6 @@ Identity.removeIdentity(item, "Email");

#### Kotlin

##### Syntax
```kotlin
fun removeIdentity(item: IdentityItem, namespace: String)
```

##### Example
```kotlin
val item = IdentityItem("[email protected]")
Expand Down Expand Up @@ -360,12 +330,6 @@ public void onResume() {

#### Kotlin

##### Syntax
```kotlin
public fun setAdvertisingIdentifier(advertisingIdentifier: String)
```
- _advertisingIdentifier_ is an ID string that provides developers with a simple, standard system to continue to track ads throughout their apps.

##### Example
<details>
<summary><code>import ...</code></summary>
Expand Down Expand Up @@ -452,14 +416,8 @@ identityMap.addItem(item, "Email")
Identity.updateIdentities(identityMap);
```


#### Kotlin

##### Syntax
```kotlin
fun updateIdentities(identityMap: IdentityMap)
```

##### Example
```kotlin
val item = IdentityItem("[email protected]")
Expand All @@ -474,7 +432,7 @@ Identity.updateIdentities(identityMap)

### IdentityMap

Defines a map containing a set of end user identities, keyed on either namespace integration code or the namespace ID of the identity. The values of the map are an array, meaning that more than one identity of each namespace may be carried.
Defines a map containing a set of end user identities, keyed on either namespace integration code or the namespace ID of the identity. The values of the map are an array of [IdentityItem](#identityitem)s, meaning that more than one identity of each namespace may be carried. Each IdentityItem should have a valid, non-null and non-empty identifier, otherwise it will be ignored.

The format of the IdentityMap class is defined by the [XDM Identity Map Schema](https://github.com/adobe/xdm/blob/master/docs/reference/mixins/shared/identitymap.schema.md).

Expand Down Expand Up @@ -565,7 +523,7 @@ val hasNotIdentities = identityMap.isEmpty()

### IdentityItem

Defines an identity to be included in an [IdentityMap](#identitymap).
Defines an identity to be included in an [IdentityMap](#identitymap). IdentityItems may not have null or empty identifiers and are ignored when adding to an [IdentityMap](#identitymap) instance.

The format of the IdentityItem class is defined by the [XDM Identity Item Schema](https://github.com/adobe/xdm/blob/master/docs/reference/datatypes/identityitem.schema.md).

Expand Down Expand Up @@ -608,7 +566,7 @@ val primary = item.isPrimary

### AuthenticatedState

Defines the state an [Identity Item](#identityitem) is authenticated for.
Defines the state for which an [Identity Item](#identityitem) is authenticated.

The possible authenticated states are:

Expand All @@ -626,13 +584,4 @@ public enum AuthenticatedState {
AUTHENTICATED("authenticated"),
LOGGED_OUT("loggedOut");
}
```
#### Kotlin

```kotlin
enum class AuthenticatedState(val name: String) {
AMBIGUOUS("ambiguous"),
AUTHENTICATED("authenticated"),
LOGGED_OUT("loggedOut")
}
```
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ ci-publish-staging: clean build-release

ci-publish-main: clean build-release
(./code/gradlew -p code/${EXTENSION-LIBRARY-FOLDER-NAME} publishReleasePublicationToSonatypeRepository -Prelease)

# usage: update-version VERSION=9.9.9 CORE-VERSION=8.8.8
# usage: update-version VERSION=9.9.9
update-version:
@echo "Updating version to $(VERSION), Core version to $(CORE-VERSION)"
sed -i '' "s/[0-9]*\.[0-9]*\.[0-9]/$(VERSION)/g" ./code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/IdentityConstants.java
sed -i '' "s/\(moduleVersion=\)[0-9]*\.[0-9]*\.[0-9]/\1$(VERSION)/g" ./code/gradle.properties
@if [ -z "$(CORE-VERSION)" ]; then \
echo "CORE-VERSION was not provided, skipping"; \
else \
sed -i '' "s/\(mavenCoreVersion=\)[0-9]*\.[0-9]*\.[0-9]/\1$(CORE-VERSION)/g" ./code/gradle.properties; \
fi
4 changes: 3 additions & 1 deletion code/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ dependencies {

implementation "com.adobe.marketing.mobile:core:2.+"
implementation 'com.adobe.marketing.mobile:identity:2.+'
implementation 'com.adobe.marketing.mobile:edgeconsent:2.+'
implementation ('com.adobe.marketing.mobile:edgeconsent:2.+') {
transitive = false
}
implementation 'com.adobe.marketing.mobile:assurance:2.+'
implementation ('com.adobe.marketing.mobile:edge:2.+') {
transitive = false
Expand Down
4 changes: 2 additions & 2 deletions code/edgeidentity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ publishing {
url = 'https://developer.adobe.com/client-sdks'
licenses {
license {
name = 'Adobe Proprietary'
name = 'The Apache License, Version 2.0'
emdobrin marked this conversation as resolved.
Show resolved Hide resolved
}
}
developers {
Expand Down Expand Up @@ -225,4 +225,4 @@ tasks.withType(Test) {
testLogging {
showStandardStreams = true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static com.adobe.marketing.mobile.edge.identity.util.IdentityFunctionalTestUtil.*;
import static com.adobe.marketing.mobile.edge.identity.util.TestHelper.getXDMSharedStateFor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import com.adobe.marketing.mobile.edge.identity.util.MonitorExtension;
import com.adobe.marketing.mobile.edge.identity.util.TestHelper;
Expand Down Expand Up @@ -65,6 +66,28 @@ public void testOnBootUp_LoadsAllIdentitiesFromPreference() throws Exception {
Map<String, String> persistedMap = flattenMap(JSONUtils.toMap(new JSONObject(persistedJson)));
assertEquals(12, persistedMap.size()); // 3 for ECID and 3 for secondaryECID + 6
}

@Test
public void testOnBootUp_LoadsAllIdentitiesFromPreference_ignoresEmptyItems() throws Exception {
// test
setEdgeIdentityPersistence(
createXDMIdentityMap(
new TestItem("ECID", "primaryECID"),
new TestItem("UserId", "JohnDoe"),
new TestItem("UserId", ""), // empty Item id
new TestItem("UserId", null) // null Item id
)
);

registerExtensions(Arrays.asList(MonitorExtension.EXTENSION, Identity.EXTENSION), null);

// verify xdm shared state
Map<String, String> xdmSharedState = flattenMap(getXDMSharedStateFor(IdentityConstants.EXTENSION_NAME, 1000));
assertEquals(6, xdmSharedState.size()); // 3 for ECID and 3 UserId JohnDoe
assertEquals("primaryECID", xdmSharedState.get("identityMap.ECID[0].id"));
assertEquals("JohnDoe", xdmSharedState.get("identityMap.UserId[0].id"));
assertNull(xdmSharedState.get("identityMap.UserId[1].id"));
}
// --------------------------------------------------------------------------------------------
// All the other bootUp tests with to ECID is coded in IdentityECIDHandling
// --------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,36 @@ public void testGetIdentities() {
assertEquals(1, responseMap.getIdentityItemsForNamespace("ECID").size());
}

@Test
public void testGetIdentities_itemWithEmptyId_notAddedToMap() {
registerExtensions(Arrays.asList(MonitorExtension.EXTENSION, Identity.EXTENSION), null);

// setup
// update Identities through API
IdentityMap map = new IdentityMap();
map.addItem(new IdentityItem("[email protected]"), "Email");
map.addItem(new IdentityItem("[email protected]"), "Email");
map.addItem(new IdentityItem("zzzyyyxxx"), "UserId");
map.addItem(new IdentityItem(""), "UserId");
map.addItem(new IdentityItem("John Doe"), "UserName");
map.addItem(new IdentityItem(""), "EmptyNamespace");
Identity.updateIdentities(map);

// test
Map<String, Object> getIdentitiesResponse = getIdentitiesSync();
waitForThreads(2000);

// verify
IdentityMap responseMap = (IdentityMap) getIdentitiesResponse.get(
IdentityTestConstants.GetIdentitiesHelper.VALUE
);
assertEquals(4, responseMap.getNamespaces().size());
assertEquals(2, responseMap.getIdentityItemsForNamespace("Email").size());
assertEquals(1, responseMap.getIdentityItemsForNamespace("UserId").size());
assertEquals(1, responseMap.getIdentityItemsForNamespace("UserName").size());
assertEquals(1, responseMap.getIdentityItemsForNamespace("ECID").size());
}

@Test
public void testGetIdentities_nullCallback() {
registerExtensions(Arrays.asList(MonitorExtension.EXTENSION, Identity.EXTENSION), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class IdentityConstants {
static final String LOG_TAG = "EdgeIdentity";
static final String EXTENSION_NAME = "com.adobe.edge.identity";
static final String EXTENSION_FRIENDLY_NAME = "Edge Identity";
static final String EXTENSION_VERSION = "2.0.0";
static final String EXTENSION_VERSION = "2.0.1";

static final class Default {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ public final class IdentityItem {
private final boolean primary;

/**
* Creates a new {@link IdentityItem}
* Creates a new {@link IdentityItem}.
* An {@code IdentityItem} should not have an empty or null {@code id} value. An {@link IdentityMap}
* will reject {@code IdentityItem}s with null or empty identifiers.
*
*
* @param id id for the item; should not be null
* @param authenticatedState {@link AuthenticatedState} for the item; if none is provided {@link AuthenticatedState#AMBIGUOUS} is used as default
* @param primary primary flag for the item
* @throws IllegalArgumentException if id is null
* @throws IllegalArgumentException if {@code id} is null
*/
public IdentityItem(
@NonNull final String id,
Expand All @@ -62,8 +65,11 @@ public IdentityItem(
* Creates a new {@link IdentityItem} with default values
* {@code authenticatedState) is set to AMBIGUOUS
* (@code primary} is set to false
* An {@code IdentityItem} should not have an empty or null {@code id} value. An {@link IdentityMap}
* will reject {@code IdentityItem}s with null or empty identifiers.
*
* @param id the id for this {@link IdentityItem}; should not be null
* @throws IllegalArgumentException if {@code id} is null
*/
public IdentityItem(@NonNull final String id) {
this(id, AuthenticatedState.AMBIGUOUS, false);
Expand Down Expand Up @@ -193,7 +199,15 @@ static IdentityItem fromData(final Map<String, Object> data) {
return new IdentityItem(id, authenticatedState, primary);
} catch (final DataReaderException e) {
Log.debug(LOG_TAG, LOG_SOURCE, "Failed to create IdentityItem from data.");
return null;
} catch (final IllegalArgumentException e) {
Log.debug(
LOG_TAG,
LOG_SOURCE,
"Failed to create IdentityItem from data as 'id' is null. %s",
e.getLocalizedMessage()
);
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public List<String> getNamespaces() {
/**
* Add an identity item which is used to clearly distinguish entities that are interacting
* with digital experiences.
* An {@link IdentityItem} with an empty {@code id} is not allowed and is ignored.
*
* @param item {@link IdentityItem} to be added to the given {@code namespace}; should not be null
* @param namespace the namespace integration code or namespace ID of the identity; should not be null
Expand Down Expand Up @@ -152,6 +153,7 @@ public String toString() {
/**
* Add an identity item which is used to clearly distinguish entities that are interacting
* with digital experiences.
* An {@link IdentityItem} with an empty {@code id} is not allowed and is ignored.
*
* @param item {@link IdentityItem} to be added to the namespace
* @param namespace the namespace integration code or namespace ID of the identity
Expand All @@ -174,6 +176,7 @@ void addItem(final IdentityItem item, final String namespace, final boolean isFi
/**
* Merge the given map on to this {@link IdentityMap}. Any {@link IdentityItem} in map which shares the same
* namespace and id as an item in this {@code IdentityMap} will replace that {@code IdentityItem}.
* Any {@link IdentityItem}s with an empty {@code id} are not allowed and are ignored.
*
* @param map {@link IdentityMap} to be merged into this object
*/
Expand Down Expand Up @@ -313,6 +316,16 @@ static IdentityMap fromXDMMap(final Map<String, Object> map) {
// ========================================================================================

private void addItemToMap(final IdentityItem newItem, final String namespace, final boolean isFirstItem) {
if (StringUtils.isNullOrEmpty(newItem.getId())) {
Log.debug(
LOG_TAG,
LOG_SOURCE,
"Unable to add IdentityItem to IdentityMap with null or empty identifier value: %s",
newItem
);
return;
}

// check if namespace exists
final List<IdentityItem> itemList;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.adobe.marketing.mobile.util.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.charset.Charset;

class URLUtils {

Expand Down Expand Up @@ -54,9 +54,10 @@ static String generateURLVariablesPayload(final String ts, final String ecid, fi
// No need to encode
urlFragment.append("null");
} else {
urlFragment.append(URLEncoder.encode(theIdString, StandardCharsets.UTF_8.toString()));
urlFragment.append(URLEncoder.encode(theIdString, Charset.forName("UTF-8").name()));
}
} catch (UnsupportedEncodingException e) {
} catch (UnsupportedEncodingException | IllegalArgumentException e) {
urlFragment.append("null");
Log.debug(LOG_TAG, LOG_SOURCE, String.format("Failed to encode urlVariable string: %s", e));
}
return urlFragment.toString();
Expand Down
Loading