exponea / exponea-react-native-sdk

MIT License
8 stars 13 forks source link

fetchRecommendations returning an error or invalid data when called immediately after configuring the SDK #124

Closed dannyBies closed 2 months ago

dannyBies commented 2 months ago

Hi,

When I start my app I initialise the app like this::

console.log('Bloomreach configure start', format(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'"));
await Exponea.configure({
  projectToken: process.env.EXPO_PUBLIC_BLOOMREACH_PROJECT_ID,
  authorizationToken: process.env.EXPO_PUBLIC_BLOOMREACH_AUTHORIZATION_TOKEN,
  baseUrl: process.env.EXPO_PUBLIC_BLOOMREACH_URL,
  ios: {
   appGroup: '...',
  },
  defaultProperties: {
    app_name: process.env.EXPO_PUBLIC_APP_NAME,
  },
});
console.log('Bloomreach configure end', format(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'"));

After this I am fetching recommendations:

console.log('fetch recommendations start', format(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'"));
const recommendations = await Exponea.fetchRecommendations({
  id: process.env.EXPO_PUBLIC_BLOOMREACH_MOST_POPULAR_FEED_ID,
  size: 5,
  fillWithRandom: false,
});
console.log('fetch recommendations end', format(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'"), recommendations.length);

When I install the app for the first time and I immediately request data from the recommendation feed I consistently get the following output (includes retries): image

There have also been times when the feed returned an empty array instead of actual data (which does exist, as reloading the app would make this data appear) - this doesn't happen reliably though.

I assume this issue occurs due to the user not being fully created when trying to retrieve feed data, resulting into a 404 when this SDK calls the recommendation endpoint. I'm wondering if there is a way to know when Bloomreach is 'ready' to be used? I assumed waiting for configure would be enough for me to use any Bloomreach API but that doesn't seem to be the case.

roland-misica commented 2 months ago

Hi @dannyBies, thanks for reporting the issue, unfortunately, we cannot reproduce it. But we suspect your project setup might have some problems. Please contact bloomreach support directly to resolve the issue.

Regards