braze-inc / braze-web-sdk

Public repo for the Braze Web SDK
https://www.braze.com
Other
71 stars 25 forks source link

[Bug]: `subscribeToContentCardsUpdates` returning duplicate content cards with different IDs #137

Closed rfviolato closed 1 year ago

rfviolato commented 1 year ago

Braze Web SDK Version

4.6.1

Integration Method

NPM

Browser

Chrome, Firefox, Safari

Steps To Reproduce

The setup is written using redux-saga, so here's a reproducible example that is agnostic of libraries or frameworks being used:

// User logs in OR starts a session already authenticated
braze.changeUser('user-id'); // With the actual user's ID being passed-in
fetchContentCards();

async function fetchContentCards() {
   await braze.subscribeToContentCardsUpdates((contentCards) => { /* Callback that simply grabs `contentCards` and puts it into global state */ })
   await braze.openSession();
   await braze.requestContentCardsRefresh();
}

Expected Behavior

I'd like to see only one content card per content card campaign after logout and login with a different account/user.

Actual Incorrect Behavior

After I login with account A, logout, login with account B I see two of the same content card (they have all of the same content information but different ID, created and updated.

Since my application relies on this content card array returned by subscribeToContentCardsUpdates to display the cards in the UI, the user sees duplicate content cards with exact same content.

I have checked the raw data prior to any data normalisation or even storing it in the global state.

The SDK is initialised as the web-app starts, regardless of being logged in or logged out. Upon logout, no SDK method is executed.

Verbose Logs

Braze: Initialization Options: {
  "baseUrl": ""******",
  "doNotLoadFontAwesome": true,
  "sessionTimeoutInSeconds": 900,
  "enableLogging": true
}

Braze: Initialized for the Braze backend at "******" with API key "********".

Braze: Current user is already *********. Doing nothing.

Additional Information

Here's the duplicate content cards raw data returned by subscribeToContentCardsUpdates

[
    {
        "id": "NjNkYjcyOWJhNGMwYTEzZWE5NWRhZDA4XyRfY2M9NDA4Yzc5NzQtODQ2NC0wMjQxLTc0MzktZThmZDUzYzg4ZThlJm12PTYzZGI3MjliYTRjMGExM2VhOTVkYWNmNSZwaT1jbXA=",
        "viewed": false,
        "title": "",
        "imageUrl": null,
        "description": "...",
        "created": "2023-02-02T13:54:18.000Z",
        "updated": "2023-02-02T13:54:18.000Z",
        "categories": [],
        "expiresAt": "2023-02-16T23:00:00.000Z",
        "url": "...",
        "linkText": "Lees meer",
        "aspectRatio": 1,
        "extras": {
            "type": "warning",
            "screen": "web_TEST",
            "hasIcon": "true"
        },
        "pinned": true,
        "dismissible": false,
        "dismissed": false,
        "clicked": false,
        "isControl": false,
        "test": false,
        "lt": null,
        "Et": null,
        "Y": "ab-classic-card",
        "Z": true
    },
    {
        "id": "NjNkYjcyOWJhNGMwYTEzZWE5NWRhZDA4XyRfY2M9Y2RiNjQ2NmItMjcwNC05ZThiLTg2MDQtMDYyOWE5MzM5ZGJhJm12PTYzZGI3MjliYTRjMGExM2VhOTVkYWNmNSZwaT1jbXA=",
        "viewed": false,
        "title": "",
        "imageUrl": null,
        "description": "...",
        "created": "2023-02-02T13:53:08.000Z",
        "updated": "2023-02-02T13:53:08.000Z",
        "categories": [],
        "expiresAt": "2023-02-16T23:00:00.000Z",
        "url": "...",
        "linkText": "Lees meer",
        "aspectRatio": 1,
        "extras": {
            "type": "warning",
            "screen": "web_TEST",
            "hasIcon": "true"
        },
        "pinned": true,
        "dismissible": false,
        "dismissed": false,
        "clicked": false,
        "isControl": false,
        "test": false,
        "lt": null,
        "Et": null,
        "Y": "ab-classic-card",
        "Z": true
    }
]

Important to note:

davidbielik commented 1 year ago

Hi @rfviolato, is this content card triggered by a session start, a custom event, or a schedule? Most likely you are triggering the same card, and it has re-eligibility enabled in the Braze dashboard.

Since it'll take some more detail / screenshots of your Braze dashboard which may contain private information, can you please raise this with our tech support team to further assist? You can email relevant details (code samples, link to campaign, verbose logs) to support@braze.com

rfviolato commented 1 year ago

The campaign trigger is set to "Action-based delivery", and "Send This Campaign To Users Who" is set to "Start Session In Any App".

I have also checked the re-eligibility setting, and the "Allow users to become re-eligible to receive campaign" checkbox is not ticked.

I'll follow up via e-mail.

hannahlaek-wt commented 9 months ago

Can someone tell me what the issue was here? @rfviolato @davidbielik Thanks!

rfviolato commented 8 months ago

@hannahlaek-wt I got in touch with Braze's support and, at the time, it was hard to reproduce the issue because it turned out hard to reproduce, so the issue wasn't actually solved because I decided to wait for a different campaign to get in touch with support again.

Now I have moved to a different project, so I don't know if it still happens anymore.

hannahlaek-wt commented 8 months ago

@rfviolato Thank you for the info! @davidbielik Do you have any context -- i'm getting 2-3 of the same cards with different IDs and Braze is only being initialized once.

Screenshot 2024-01-09 at 2 08 13 PM
davidbielik commented 8 months ago

Hi @hannahlaek-wt most likely your Content Cards message has the re-eligibility setting enabled so that the card can be created multiple times (i.e. every session start a new copy is created).

It'd help to create a support ticket with Braze to narrow down and investigate the cause for you. If you have multiple cards (with different IDs) it's not going to be an SDK issue that can be answered here as easily.

hoangvh-bds commented 6 months ago

Hi @davidbielik , I also got this error:

I'm using "@braze/web-sdk": "4.7.0" I have 4 campaigns for user A and 1 campaign for user B. I'm using user A and see 4 campaigns. Then I open new tab, logout and login to user B. Try like it a few times. And the campaign receive from subscribeToContentCardsUpdates become 5. Event I refresh the page, I still get 5. It just update to true campaign when I clear localStorage. I checked userID from braze.getUser().getUserId() still work as expected

Do you have any idea or solution?

davidbielik commented 6 months ago

Hi @hoangvh-bds can you please email support@braze.com with relevant code samples and logs? They can help dig into campaign specifics.