exponea / exponea-react-native-sdk

MIT License
8 stars 13 forks source link

fetchConsents fetches consents in general, not what the customer consents #110

Closed zeraphie closed 10 months ago

zeraphie commented 10 months ago

I'm looking to fetch a customer's consents, and I saw the docs mentioning this exact circumstance, but when I looked at the response of the consent, and comparing it to what the customer had consented to there was no correlating value for it

Part of the json:

[
  {
    "id": "sms",
    "legitimateInterest": false,
    "sources": {
      "createdFromCRM": true,
      "imported": true,
      "privateAPI": true,
      "publicAPI": true,
      "trackedFromScenario": true
    },
    "translations": {
      "": [
        Object
      ]
    }
  },
  {
    "id": "email",
    "legitimateInterest": false,
    "sources": {
      "createdFromCRM": true,
      "imported": true,
      "privateAPI": true,
      "publicAPI": false,
      "trackedFromScenario": true
    },
    "translations": {
      "": [
        Object
      ]
    }
  },
]

I had a look at the android sdk and saw a similar function getConsents but it makes no mention of it being the customer's consents.

I'm expecting to use it as such:

Exponea.fetchConsents().then((consents) => {
  const sms = consents.find((consent) => consent.id === EXPONEA_CONSENT_CATEGORY.SMS);
  if(sms.consented){
    // do something
  }
});
adam1929 commented 10 months ago

Hi @zeraphie thank you for reporting. Consents are directly delivered from backend through SDK. If Backend does not send a consent (is denied/not granted to current customer), SDK will not return it as result too. I would like to help so please define your use case and expectations, we'll discuss it internally or help you how to achieve your goals. Thank you

zeraphie commented 10 months ago

I've tested this with a customer that has consented to some of the consents setup, but not others, and I want to show some ui if one of the consents setup has been consented to, but the response back (as above) has no correlating field to whether or not the customer has consented to it, it looks like the response is only for how the consent has been setup instead of what the customer consented to

I have 4 consents setup:

export enum EXPONEA_CONSENT_CATEGORY {
  MOBILE_PUSH = 'mobile push',
  SMS = 'sms',
  EMAIL = 'email',
  MARKETING_CONSENT = 'marketing',
}

In the bloomreach ui I can see that the customer has consented to MARKETING_CONSENT and MOBILE_PUSH, and the full response I receive from Exponea.fetchConsents is: (which returns all the consents, I'd be expecting just marketing and mobile push)

[
  {
    "id": "sms",
    "legitimateInterest": false,
    "sources": {
      "createdFromCRM": true,
      "imported": true,
      "privateAPI": true,
      "publicAPI": true,
      "trackedFromScenario": true
    },
    "translations": {
      "": [
        Object
      ]
    }
  },
  {
    "id": "email",
    "legitimateInterest": false,
    "sources": {
      "createdFromCRM": true,
      "imported": true,
      "privateAPI": true,
      "publicAPI": false,
      "trackedFromScenario": true
    },
    "translations": {
      "": [
        Object
      ]
    }
  },
  {
    "id": "mobile push",
    "legitimateInterest": false,
    "sources": {
      "createdFromCRM": true,
      "imported": true,
      "privateAPI": true,
      "publicAPI": true,
      "trackedFromScenario": true
    },
    "translations": {
      "": [
        Object
      ]
    }
  },
  {
    "id": "marketing",
    "legitimateInterest": false,
    "sources": {
      "createdFromCRM": true,
      "imported": true,
      "privateAPI": true,
      "publicAPI": true,
      "trackedFromScenario": true
    },
    "translations": {
      "": [
        Object
      ]
    }
  }
]

I'd expect something like a consented value to be there, the closest is legitimateInterest but I'm pretty sure that isn't desired in this case, nor does it actually reflect what the customer has consented to, below is how I'd wish to use it

Exponea.fetchConsents().then((consents) => {
  const marketingConsent = consents.find(
    (consent) => consent.id === EXPONEA_CONSENT_CATEGORY.MARKETING_CONSENT,
  );

  // this doesn't actually track consent...
  setHasMarketingConsent(marketingConsent?.legitimateInterest || false);
}
zeraphie commented 10 months ago

Any news about this issue?

adam1929 commented 10 months ago

Hi @zeraphie thank you for your validation and expectation notes. I validate with BE that response data are populated in scope of whole project and are not affected by current customer setup. Please ask your official support channel and rise this as feature request. Informations from this thread has been presented but feature requests needs to be requested through support channel directly. Thank you for understanding.