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

[MOB-22283] Exposing new API for generateDisplayXDM for batching multiple display propositions #3

Open
wants to merge 8 commits into
base: MOB-21475
Choose a base branch
from

Conversation

siddique-adobe
Copy link
Owner

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

@spoorthipujariadobe spoorthipujariadobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of things before I start the PR review:

  1. Please provide a description of what is being done in this PR and why
  2. CI jobs did not run for this PR. Please have a look to figure out why
  3. Why is this PR being raised in your forked repo? Please create it again https://github.com/adobe/aepsdk-optimize-android
  4. Please add docs, unit tests and functional tests for the new APIs you have introduced

private set
var characteristics: Map<String, String> = HashMap()
private set
var propositionReference: SoftReference<OptimizeProposition>? = null
Copy link

@spoorthipujariadobe spoorthipujariadobe Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a public API getProposition . With the way its refactored here, that method no longer exists, making this a breaking change.
We're also making propositionReference public when it was not before

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to do something like this to achieve parity

    @get:JvmName("getPropositionReference")
    @set:JvmName("setPropositionReference")
    internal var propositionReference: SoftReference<OptimizeProposition>? = null
    var proposition = propositionReference?.get()
        private set


/**
* Generates a map containing XDM formatted data for {@code Experience Event -
* OptimizeProposition Interactions} field group from this {@code OptimizeProposition} item.
Copy link

@spoorthipujariadobe spoorthipujariadobe Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here
...XDM formatted data for {@code Experience Event OptimizeProposition Interactions} field group from {@code Offer} list.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public static Map<String, Object> generateDisplayInteractionXdm(List<Offer> offers) {
return OptimizeUtils.generateInteractionXdm(
OptimizeConstants.JsonValues.EE_EVENT_TYPE_PROPOSITION_DISPLAY,
Objects.requireNonNull(toUniquePropositionsList(offers)));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Objects.requireNonNull would throw a null pointer exception if toUniquePropositionsList returns null, which would cause a RuntimeException and app will crash. Can we handle this gracefully? Either we can throw the exception so the app can handle it or we can do a null check for result of toUniquePropositionsList and fail fast without calling OptimizeUtils.generateInteractionXdm

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


internal object OfferExtension {
@JvmStatic
fun List<Offer>?.toUniquePropositionsList(): List<OptimizeProposition>? {
Copy link

@spoorthipujariadobe spoorthipujariadobe Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here in conjunction with OptimizeUtils.generateInteractionXdm doesn't achieve our goal. You're creating a list of proposition reference for the list of offers passed in. Then in OptimizeUtils.generateInteractionXdm you're adding all the offer ids in the proposition to the display events, rather only the ids of offer list that was passed to the API.
https://github.com/siddique-adobe/aepsdk-optimize-android/pull/3/files#diff-b90c589ff2ce5c066bb12f60a6b2ce62e77b4fede59cbe980f944bd99f45680dR288

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review this again, I've fixed the missing logic here @spoorthipujariadobe

@siddique-adobe siddique-adobe force-pushed the MOB-22283 branch 3 times, most recently from d8a8bd0 to 4039fc5 Compare November 13, 2024 06:55
* @return {@code Map<String, Object>} containing the XDM data for the proposition interaction.
* @see OptimizeUtils#generateInteractionXdm(String, List)
*/
public static Map<String, Object> generateDisplayInteractionXdm(List<Offer> offers) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add @Nullable annotation to the API signature

Copy link

@spoorthipujariadobe spoorthipujariadobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to add tests in the PR opened against the Optimize repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants