braze-inc / braze-react-native-sdk

Public repo for the Braze React Native SDK
https://www.braze.com
Other
64 stars 84 forks source link

[Bug]: On android, calling `Braze.getContentCards` right after `Didomi.setUserStatusSets` returns a never-resolving promise #268

Open AmauryLiet opened 1 month ago

AmauryLiet commented 1 month ago

Which Platforms?

Android

Which React Native Version?

0.74.5

Which @braze/react-native-sdk SDK version?

11.0.0

Repro Rate

100% of the time, on release builds

Steps To Reproduce

NB: This is reproduced when using Braze & Didomi together, but the described erratic behaviour should be addressed regardless of Didomi implementation

import React, { useCallback, useEffect, useState } from 'react';
import Braze, { ContentCard } from '@braze/react-native-sdk';
import { Didomi, DidomiEventType } from '@didomi/react-native';
import { TouchableOpacity, View } from 'react-native';

const myVendors = ['my vendor id'];

export const App = () => {
  const enableCookies = useCallback(async () => {
    const currentUserStatus = await Didomi.getUserStatus();

    await Didomi.setUserStatusSets(
      currentUserStatus.purposes.consent.enabled,
      currentUserStatus.purposes.consent.disabled,
      currentUserStatus.purposes.legitimate_interest.enabled,
      currentUserStatus.purposes.legitimate_interest.disabled,
      [...currentUserStatus.vendors.consent.enabled, ...myVendors],
      currentUserStatus.vendors.consent.disabled,
      currentUserStatus.vendors.legitimate_interest.enabled,
      currentUserStatus.vendors.legitimate_interest.disabled
    );
  }, []);

  const [contentCards, setContentCards] = useState<ContentCard[]>([]);

  useEffect(() => {
    Didomi.addEventListener(DidomiEventType.CONSENT_CHANGED, async () => {
      const cards = await Braze.getContentCards();
      setContentCards(cards);
    });
  }, []);

  return (
    <View>
      <TouchableOpacity onPress={enableCookies} />
      {contentCards.map(renderCard)}
    </View>
  );
};

Expected Behavior

Braze.getContentCards() returns an array once cookies are enabled

Actual Incorrect Behavior

Braze.getContentCards() never resolves.

Regardless of Didomi integration, the call should return a value (error, empty array, filled array, ...) and not hang indefinitely

Verbose Logs

No response

Additional Information

No response

radixdev commented 1 month ago

Hi @AmauryLiet ,

  1. Can you provide verbose logs of a reproduction of the issue?
  2. What device were you testing on?
  3. What Braze Android SDK version did you reproduce the issue on?