braze-inc / braze-web-sdk

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

[Bug]: getAllFeatureFlags returns undefined in some cases #153

Closed tommyokeefe closed 7 months ago

tommyokeefe commented 7 months ago

Braze Web SDK Version

4.8.3

Integration Method

NPM

Browser

Chrome

Steps To Reproduce

Using a specific User Agent (this one is the user agent from prerender.io) test the following:

Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 Prerender (+https://github.com/prerender/prerender)
import * as braze from '@braze/web-sdk';

const flags = braze.getAllFeatureFlags()

console.info('Braze feature flags`, flags);

Expected Behavior

Should return type FeatureFlag[] according to the docs - https://js.appboycdn.com/web-sdk/4.8/doc/classes/braze.featureflag.html

Actual Incorrect Behavior

Returns undefined

Verbose Logs

Braze: Initialization Options: {
  "baseUrl": "sdk.iad-03.braze.com",
  "allowUserSuppliedJavascript": true,
  "minimumIntervalBetweenTriggerActionsInSeconds": 1,
  "enableLogging": true
}
index.ts:163 Braze: Ignoring activity from crawler bot Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 Prerender (+https://github.com/prerender/prerender)

Additional Information

Seems like a simple type issue. I'm not sure why the user agent effects the return value, maybe it's something you're doing to differentiate bots from users?

justdavidtr commented 7 months ago

initialize returns false here because we detect that it is a crawler/bot. We do not want crawlers to populate the data coming into the SDKs.

If you want to allow crawlers through, I believe there is an option to enable it OPTIONS.ALLOW_CRAWLER_ACTIVITY

sircelsius commented 7 months ago

Hi @tommyokeefe thank you for reporting.

Given that this issue is 2 weeks old I will close it for now. Please re-open if you believe further action is required.