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

Staging to Main #120

Merged
merged 47 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2c8d87f
Get proposition call will be dispatched immediately if all scopes are…
ishwetansh Sep 10, 2024
57a05da
Updated test cases with mock base64 support
ishwetansh Sep 10, 2024
bbd5ca7
Added test cases for already cached proposition
ishwetansh Sep 24, 2024
b4d62cf
Fix: Checking inProgress Events
ishwetansh Sep 24, 2024
105569b
Merge branch 'dev-v3.1.0' into fix/getProposition
ishwetansh Sep 24, 2024
9af8803
Add: WIP Test for queuing get event after an update event with same d…
ishwetansh Sep 24, 2024
eeae29e
minor formatting
ishwetansh Sep 24, 2024
8d515b3
Add: Added a test case for testGetPropositions_ScopesFromEventIsUpdat…
ishwetansh Oct 8, 2024
96d4175
Add: Added test case for testGetPropositions_FewDecisionScopesNotInCa…
ishwetansh Oct 8, 2024
170c45a
Fix: Spotless applied
ishwetansh Oct 8, 2024
3bb0c89
Fix: Reduced the sleep time
ishwetansh Oct 8, 2024
564ff60
Fix: removed duplicate tests
ishwetansh Oct 8, 2024
548e512
Fix: test naming updated
ishwetansh Oct 8, 2024
2036225
Fix: updated log messages
ishwetansh Oct 8, 2024
745121b
Update config.yml
spoorthipujariadobe Oct 8, 2024
6126722
Add: Added two test cases - handleGetPropositions_invalidDecisionScop…
ishwetansh Oct 9, 2024
c938f9f
Fix: Code formatting
ishwetansh Oct 9, 2024
63e8eb5
Nit: event naming
ishwetansh Oct 9, 2024
6366537
Merge pull request #93 from ishwetansh/fix/getProposition
ishwetansh Oct 9, 2024
acfd77e
Change the type of offer score from int to double (#102)
ishita-gambhir-adobe Oct 10, 2024
a3203c3
documentation update for Offer Score datatype
ishita-gambhir-adobe Oct 10, 2024
9a84df9
update documentation for updatePropositionsWithCompletionHandler (#104)
ishita-gambhir-adobe Oct 15, 2024
334b393
Merge pull request #103 from ishita-gambhir-adobe/scoreDocUpdate
spoorthipujariadobe Oct 17, 2024
45651a8
Overloaded getPropositions and updatePropositions with new timeout ar…
siddique-adobe Nov 7, 2024
2b948f1
Propagated the changes to test app
siddique-adobe Nov 7, 2024
8d79c5a
Adding another overloaded method with no callback and no timeout
siddique-adobe Nov 11, 2024
715e898
Timeout propagated to handleUpdatePropositions from updatePropositions
siddique-adobe Nov 13, 2024
3ed034b
Removing the updatePropositions overload with timeout and without cal…
siddique-adobe Nov 14, 2024
34f1183
Adding the unit test for update proposition with timeout
siddique-adobe Nov 18, 2024
b9eff05
Adding the unit test for get proposition with timeout
siddique-adobe Nov 18, 2024
24722b8
Merge pull request #107 from siddique-adobe/MOB-22286
siddique-adobe Nov 20, 2024
6e7c78f
Updating version to 3.2.0.
navratan-soni Nov 20, 2024
353ddb9
Merge pull request #109 from adobe/version-3.2.0-update
navratan-soni Nov 20, 2024
f509060
Revert "Change the type of offer score from int to double (#102)"
siddique-adobe Nov 27, 2024
2c5fdce
Revert "documentation update for Offer Score datatype"
siddique-adobe Nov 27, 2024
c91c63a
Merge pull request #112 from adobe/revert-103-scoreDocUpdate
navratan-soni Nov 27, 2024
e1b427b
Merge pull request #111 from adobe/revert-102-fixDouble
navratan-soni Nov 27, 2024
660dd3d
Marking the updateProposition API without callback deprecated
siddique-adobe Nov 28, 2024
2fb1623
Changing the timeout scale of update proposition from milliseconds to…
siddique-adobe Nov 28, 2024
eb6b34d
Changing the timeout scale of get proposition from milliseconds to se…
siddique-adobe Nov 28, 2024
ab24d23
Updating the unit tests for the get and update timeout case accordingly
siddique-adobe Nov 28, 2024
208ec6c
spotless and checkStyle check failure fixes
siddique-adobe Nov 28, 2024
27517bd
add separate cache for preview propositions (#113)
ishita-gambhir-adobe Dec 2, 2024
4dad4d5
Merge pull request #114 from siddique-adobe/MOB-22521
navratan-soni Dec 2, 2024
86e3d0f
Updating version to 3.2.2.
siddique-adobe Dec 2, 2024
0ba6c42
Merge pull request #116 from adobe/version-3.2.2-update
navratan-soni Dec 6, 2024
632cba5
Merge pull request #118 from adobe/dev-v3.2.2
siddique-adobe Dec 6, 2024
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
58 changes: 58 additions & 0 deletions Documentation/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Refer to the [Getting Started Guide](getting-started.md).
- [onPropositionsUpdate](#onPropositionsUpdate)
- [resetIdentities](#resetIdentities)
- [updatePropositions](#updatePropositions)
- [updatePropositionsWithCompletionHandler](#updatePropositionsWithCompletionHandler)

## Public classes

Expand Down Expand Up @@ -184,6 +185,63 @@ Optimize.updatePropositions(decisionScopes,
});
```

## updatePropositionsWithCompletionHandler

This API dispatches an event for the Edge network extension to fetch decision propositions, for the provided decision scopes array, from the decisioning services enabled in the Experience Edge. The returned decision propositions are cached in-memory in the Optimize SDK extension and can be retrieved using `getPropositions` API.

> [!TIP]
> Completion callback passed to `updatePropositions` supports network timeout and fatal errors returned by edge network along with fetched propositions data. The SDK's internal retry mechanism handles the recoverable HTTP errors. As a result, recoverable HTTP errors are not returned through this callback.

### Java

#### Syntax

```java
public static void updatePropositions(final List<DecisionScope> decisionScopes,
final Map<String, Object> xdm,
final Map<String, Object> data,
final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback)
```

* _decisionScopes_ is a list of decision scopes for which propositions need updating.
* _xdm_ is a map containing additional xdm formatted data to be attached to the Experience Event.
* _data_ is a map containing additional freeform data to be attached to the Experience Event.
* _callback_ is an optional completion handler that is invoked at the completion of the edge request. `call` method is invoked with propositions map of type `Map<DecisionScope, OptimizeProposition>`. If the callback is an instance of `AdobeCallbackWithOptimizeError`, and if the operation times out or an error occurs in retrieving propositions, the `fail` method is invoked with the appropriate [AEPOptimizeError](https://developer.adobe.com/client-sdks/edge/adobe-journey-optimizer-decisioning/api-reference/#aepoptimizeerror). _Note:_ In certain cases, both the success and failure callbacks may be triggered. To handle these cases, ensure that your implementation checks for both successful propositions and errors within the callback, as both may be present simultaneously.

#### Example

```java
final DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2);
final DecisionScope decisionScope2 = new DecisionScope("myScope");

final List<DecisionScope> decisionScopes = new ArrayList<>();
decisionScopes.add(decisionScope1);
decisionScopes.add(decisionScope2);

Optimize.updatePropositions(decisionScopes,
new HashMap<String, Object>() {
{
put("xdmKey", "xdmValue");
}
},
new HashMap<String, Object>() {
{
put("dataKey", "dataValue");
}
},
new AdobeCallbackWithOptimizeError<Map<DecisionScope, OptimizeProposition>>() {
@Override
public void fail(AEPOptimizeError optimizeError) {
responseError = optimizeError;
}

@Override
public void call(Map<DecisionScope, OptimizeProposition> propositionsMap) {
responseMap = propositionsMap;
}
});
```

## Public classes

### DecisionScope
Expand Down
2 changes: 1 addition & 1 deletion code/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ org.gradle.caching=true
android.useAndroidX=true

moduleName=optimize
moduleVersion=3.1.0
moduleVersion=3.2.2

#Maven artifact
mavenRepoName=AdobeMobileOptimizeSdk
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class OptimizeTestConstants {

static final String EXTENSION_VERSION = "3.1.0";
static final String EXTENSION_VERSION = "3.2.2";
public static final String LOG_TAG = "OptimizeTest";
static final String CONFIG_DATA_STORE = "AdobeMobile_ConfigState";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ data class AEPOptimizeError(
return getAdobeErrorFromStatus(data[STATUS] as Int?)
}

@JvmStatic
fun getTimeoutError(): AEPOptimizeError {
return AEPOptimizeError(
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private Optimize() {}
* @param data {@code Map<String, Object>} containing additional free-form data to be sent in
* the personalization query request.
*/
@Deprecated
public static void updatePropositions(
@NonNull final List<DecisionScope> decisionScopes,
@Nullable final Map<String, Object> xdm,
Expand Down Expand Up @@ -88,6 +89,45 @@ public static void updatePropositions(
@Nullable final Map<String, Object> xdm,
@Nullable final Map<String, Object> data,
@Nullable final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
final double defaultTimeoutSeconds =
OptimizeConstants.EDGE_CONTENT_COMPLETE_RESPONSE_TIMEOUT;
updatePropositionsInternal(decisionScopes, xdm, data, defaultTimeoutSeconds, callback);
}

/**
* This API dispatches an Event for the Edge network extension to fetch decision propositions,
* for the provided decision scopes list, from the decisioning services enabled in the
* Experience Edge network.
*
* <p>The returned decision propositions are cached in-memory in the Optimize SDK extension and
* can be retrieved using {@link #getPropositions(List, double, AdobeCallback)} API.
*
* @param decisionScopes {@code List<DecisionScope>} containing scopes for which offers need to
* be updated.
* @param xdm {@code Map<String, Object>} containing additional XDM-formatted data to be sent in
* the personalization query request.
* @param data {@code Map<String, Object>} containing additional free-form data to be sent in
* the personalization query request.
* @param timeoutSeconds {@code Double} containing additional configurable timeout(seconds) to
* be sent in the personalization query request.
* @param callback {@code AdobeCallback<Map<DecisionScope, OptimizeProposition>>} which will be
* invoked when decision propositions are received from the Edge network.
*/
public static void updatePropositions(
@NonNull final List<DecisionScope> decisionScopes,
@Nullable final Map<String, Object> xdm,
@Nullable final Map<String, Object> data,
final double timeoutSeconds,
@Nullable final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
updatePropositionsInternal(decisionScopes, xdm, data, timeoutSeconds, callback);
}

private static void updatePropositionsInternal(
@NonNull final List<DecisionScope> decisionScopes,
@Nullable final Map<String, Object> xdm,
@Nullable final Map<String, Object> data,
final double timeoutSeconds,
@Nullable final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {

if (OptimizeUtils.isNullOrEmpty(decisionScopes)) {
Log.warning(
Expand Down Expand Up @@ -138,6 +178,10 @@ public static void updatePropositions(
eventData.put(OptimizeConstants.EventDataKeys.DATA, data);
}

long timeoutMillis = (long) (timeoutSeconds * OptimizeConstants.TIMEOUT_CONVERSION_FACTOR);

eventData.put(OptimizeConstants.EventDataKeys.TIMEOUT, timeoutMillis);

final Event event =
new Event.Builder(
OptimizeConstants.EventNames.UPDATE_PROPOSITIONS_REQUEST,
Expand All @@ -148,7 +192,7 @@ public static void updatePropositions(

MobileCore.dispatchEventWithResponseCallback(
event,
OptimizeConstants.EDGE_CONTENT_COMPLETE_RESPONSE_TIMEOUT,
timeoutMillis,
new AdobeCallbackWithError<Event>() {
@Override
public void fail(final AdobeError adobeError) {
Expand Down Expand Up @@ -236,6 +280,30 @@ public void call(final Event event) {
public static void getPropositions(
@NonNull final List<DecisionScope> decisionScopes,
@NonNull final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
final double defaultTimeoutSeconds = OptimizeConstants.GET_RESPONSE_CALLBACK_TIMEOUT;
getPropositionsInternal(decisionScopes, defaultTimeoutSeconds, callback);
}

/**
* This API retrieves the previously fetched propositions, for the provided decision scopes,
* from the in-memory extension propositions cache.
*
* @param decisionScopes {@code List<DecisionScope>} containing scopes for which offers need to
* be requested.
* @param callback {@code AdobeCallbackWithError<Map<DecisionScope, OptimizeProposition>>} which
* will be invoked when decision propositions are retrieved from the local cache.
*/
public static void getPropositions(
@NonNull final List<DecisionScope> decisionScopes,
final double timeoutSeconds,
@NonNull final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
getPropositionsInternal(decisionScopes, timeoutSeconds, callback);
}

private static void getPropositionsInternal(
@NonNull final List<DecisionScope> decisionScopes,
final double timeoutSeconds,
@NonNull final AdobeCallback<Map<DecisionScope, OptimizeProposition>> callback) {
if (OptimizeUtils.isNullOrEmpty(decisionScopes)) {
Log.warning(
OptimizeConstants.LOG_TAG,
Expand Down Expand Up @@ -282,11 +350,11 @@ public static void getPropositions(
.setEventData(eventData)
.build();

// Increased default response callback timeout to 10s to ensure prior update propositions
// requests have enough time to complete.
long timeoutMillis = (long) (timeoutSeconds * OptimizeConstants.TIMEOUT_CONVERSION_FACTOR);

MobileCore.dispatchEventWithResponseCallback(
event,
OptimizeConstants.GET_RESPONSE_CALLBACK_TIMEOUT,
timeoutMillis,
new AdobeCallbackWithError<Event>() {
@Override
public void fail(final AdobeError adobeError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

class OptimizeConstants {
static final String LOG_TAG = "Optimize";
static final String EXTENSION_VERSION = "3.1.0";
static final String EXTENSION_VERSION = "3.2.2";
static final String EXTENSION_NAME = "com.adobe.optimize";
static final String FRIENDLY_NAME = "Optimize";
static final long DEFAULT_RESPONSE_CALLBACK_TIMEOUT = 500L;
static final long GET_RESPONSE_CALLBACK_TIMEOUT = 10000L;
static final long EDGE_CONTENT_COMPLETE_RESPONSE_TIMEOUT = 10000L;
static final double GET_RESPONSE_CALLBACK_TIMEOUT = 10;
static final double EDGE_CONTENT_COMPLETE_RESPONSE_TIMEOUT = 10;
static final long TIMEOUT_CONVERSION_FACTOR = 1000;

static final String ACTIVITY_ID = "activityId";
static final String XDM_ACTIVITY_ID = "xdm:activityId";
Expand Down Expand Up @@ -64,6 +64,7 @@ static final class EventSource {
static final String NOTIFICATION = "com.adobe.eventSource.notification";
static final String EDGE_PERSONALIZATION_DECISIONS = "personalization:decisions";
static final String CONTENT_COMPLETE = "com.adobe.eventSource.contentComplete";
static final String DEBUG = "com.adobe.eventSource.debug";

private EventSource() {}
}
Expand All @@ -74,6 +75,7 @@ static final class EventDataKeys {
static final String DECISION_SCOPE_NAME = "name";
static final String XDM = "xdm";
static final String DATA = "data";
static final String TIMEOUT = "timeout";
static final String PROPOSITIONS = "propositions";
static final String RESPONSE_ERROR = "responseerror";
static final String PROPOSITION_INTERACTIONS = "propositioninteractions";
Expand Down
Loading
Loading