Created
February 3, 2021 13:24
-
-
Save nitinhayaran/51e5c2d333fa6d63e8ef19cb3e501d79 to your computer and use it in GitHub Desktop.
smartLookEvent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smartlookClient from 'smartlook-client' | |
const SmartLookEvent = { | |
initialize: () => { | |
const isBotUserAgent = () => { | |
return ( | |
navigator && | |
navigator.userAgent && | |
/bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|prerender/i.test( | |
navigator.userAgent | |
) | |
); | |
}; | |
try { | |
console.log('going to initialize smartlook'); | |
if (!isBotUserAgent() && process.env.REACT_APP_smartlookProjectKey) { | |
console.log('SmartLook initialized'); | |
smartlookClient.init(process.env.REACT_APP_smartlookProjectKey); | |
} | |
} catch (e) { | |
console.log('smartlook error', e.message); | |
} | |
}, | |
}; | |
export default SmartLookEvent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment