File tree Expand file tree Collapse file tree 2 files changed +36
-36
lines changed
dotcom-rendering/src/lib/braze Expand file tree Collapse file tree 2 files changed +36
-36
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import * as braze from '@braze/web-sdk' ;
2
+ import { isUndefined , log } from '@guardian/libs' ;
3
+
4
+ const SDK_OPTIONS : braze . InitializationOptions = {
5
+ enableLogging : true ,
6
+ noCookies : true ,
7
+ baseUrl : 'https://sdk.fra-01.braze.eu/api/v3' ,
8
+ sessionTimeoutInSeconds : 1 ,
9
+ minimumIntervalBetweenTriggerActionsInSeconds : 0 ,
10
+ devicePropertyAllowlist : [ ] ,
11
+ } ;
12
+
13
+ const initialiseBraze = async ( apiKey : string ) : Promise < typeof braze > => {
14
+ const importedBraze = ( await import (
15
+ /* webpackChunkName: "braze-web-sdk-core" */ '@braze/web-sdk'
16
+ ) ) as unknown as typeof braze ;
17
+
18
+ importedBraze . setLogger ( ( message ) => log ( 'tx' , message ) ) ;
19
+ importedBraze . initialize ( apiKey , SDK_OPTIONS ) ;
20
+
21
+ return importedBraze ;
22
+ } ;
23
+
24
+ const getInitialisedBraze = ( ( ) => {
25
+ let cache : Promise < typeof braze > ;
26
+
27
+ return ( apiKey : string ) : Promise < typeof braze > => {
28
+ if ( isUndefined ( cache ) ) {
29
+ cache = initialiseBraze ( apiKey ) ;
30
+ }
31
+
32
+ return cache ;
33
+ } ;
34
+ } ) ( ) ;
35
+
36
+ export { getInitialisedBraze } ;
You can’t perform that action at this time.
0 commit comments