1/* global braze */ 2const PAGE_VIEW_EVENT_NAME = 'page-view'; 3const BRAZE_INITIALIZED_EVENT_NAME = 'fool_braze_initialized'; 4class BrazeWrapper { 5 /* eslint-disable-line no-unused-vars */ 6 constructor(apiKey, baseUrl) { 7 let enableLogging = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 8 if (!apiKey || !baseUrl) { 9 throw new Error('Initializing Braze requires both apiKey and baseUrl.'); 10 } 11 this.apiKey = apiKey; 12 this.baseUrl = baseUrl; 13 this.enableLogging = enableLogging; 14 } 15 initializeForUser(userId) { 16 braze.initialize(this.apiKey, { 17 baseUrl: this.baseUrl, 18 enableLogging: this.enableLogging, 19 allowUserSuppliedJavascript: true, 20 minimumIntervalBetweenTriggerActionsInSeconds: 10 21 }); 22 if (userId) { 23 braze.changeUser(userId); 24 } 25 document.dispatchEvent(new CustomEvent(BRAZE_INITIALIZED_EVENT_NAME)); 26 braze.automaticallyShowInAppMessages(); 27 braze.openSession(); 28 } 29 logPageViewEvent(pagePath, pageName) { 30 braze.logCustomEvent(PAGE_VIEW_EVENT_NAME, { 31 page_name: pageName, 32 page_path: pagePath 33 }); 34 } 35}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.