Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,34 @@ describe('initialization', () => {
expect(openSessionSpy).toHaveBeenCalled()
expect(logCustomEventSpy).toHaveBeenCalledWith('FIFA', { goat: 'deno' })
})

test('passes devicePropertyAllowlist to Braze SDK initialization', async () => {
const devicePropertyAllowlist = ['os', 'browser']
const [event] = await brazeDestination({
api_key: 'b_123',
endpoint: 'endpoint',
sdkVersion: '3.5',
doNotLoadFontAwesome: true,
devicePropertyAllowlist,
subscriptions: [
{
partnerAction: 'trackEvent',
name: 'Track Event',
enabled: true,
subscribe: 'type = "track"',
mapping: {
eventName: { '@path': '$.event' },
eventProperties: { '@path': '$.properties' }
}
}
]
})

const initializeSpy = jest.spyOn(destination, 'initialize')
await event.load(Context.system(), {} as Analytics)

// Check that the config passed to initialize contains the allowlist
const callArgs = initializeSpy.mock.calls[0][0]?.settings || {}
expect(callArgs.devicePropertyAllowlist).toEqual(devicePropertyAllowlist)
})
})
13 changes: 12 additions & 1 deletion packages/browser-destinations/destinations/braze/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,20 @@ export const destination: BrowserDestinationDefinition<Settings, BrazeDestinatio
// @ts-expect-error same as above.
subscriptions,
deferUntilIdentified,
devicePropertyAllowlist,
...expectedConfig
} = settings

type BrazeConfig = typeof expectedConfig & {
devicePropertyAllowlist?: string[]
}
const config: BrazeConfig = { ...expectedConfig }
if (Array.isArray(devicePropertyAllowlist)) {
if (devicePropertyAllowlist.some((item) => item.trim() !== '')) {
config.devicePropertyAllowlist = devicePropertyAllowlist
}
}

const version = sdkVersion ?? defaultVersion

resetUserCache()
Expand All @@ -351,7 +362,7 @@ export const destination: BrowserDestinationDefinition<Settings, BrazeDestinatio
if (
!client.instance.initialize(api_key, {
baseUrl: window.BRAZE_BASE_URL || endpoint,
...expectedConfig
...config
})
) {
return false
Expand Down
Loading