Skip to content

Commit 5c76279

Browse files
Renamed "initialiseAppboy" to "initialiseBraze"
1 parent c927019 commit 5c76279

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

dotcom-rendering/src/lib/braze/initialiseAppboy.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 };

0 commit comments

Comments
 (0)