feat: track Brave and UA (#4699)

* fix: track Brave from UA

* feat: track UA
This commit is contained in:
Zach Pomerantz 2022-09-22 13:42:33 -05:00 committed by GitHub
parent 397b9d423e
commit 45682ca59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 0 deletions

@ -33,6 +33,7 @@ export enum EventName {
export enum CUSTOM_USER_PROPERTIES { export enum CUSTOM_USER_PROPERTIES {
ALL_WALLET_ADDRESSES_CONNECTED = 'all_wallet_addresses_connected', ALL_WALLET_ADDRESSES_CONNECTED = 'all_wallet_addresses_connected',
ALL_WALLET_CHAIN_IDS = 'all_wallet_chain_ids', ALL_WALLET_CHAIN_IDS = 'all_wallet_chain_ids',
USER_AGENT = 'user_agent',
BROWSER = 'browser', BROWSER = 'browser',
DARK_MODE = 'is_dark_mode', DARK_MODE = 'is_dark_mode',
EXPERT_MODE = 'is_expert_mode', EXPERT_MODE = 'is_expert_mode',
@ -51,6 +52,7 @@ export enum BROWSER {
EDGE_CHROMIUM = 'Microsoft Edge (Chromium)', EDGE_CHROMIUM = 'Microsoft Edge (Chromium)',
CHROME = 'Google Chrome or Chromium', CHROME = 'Google Chrome or Chromium',
SAFARI = 'Apple Safari', SAFARI = 'Apple Safari',
BRAVE = 'Brave',
UNKNOWN = 'unknown', UNKNOWN = 'unknown',
} }

@ -130,6 +130,7 @@ export default function App() {
useEffect(() => { useEffect(() => {
sendAnalyticsEvent(EventName.APP_LOADED) sendAnalyticsEvent(EventName.APP_LOADED)
user.set(CUSTOM_USER_PROPERTIES.USER_AGENT, navigator.userAgent)
user.set(CUSTOM_USER_PROPERTIES.BROWSER, getBrowser()) user.set(CUSTOM_USER_PROPERTIES.BROWSER, getBrowser())
user.set(CUSTOM_USER_PROPERTIES.SCREEN_RESOLUTION_HEIGHT, window.screen.height) user.set(CUSTOM_USER_PROPERTIES.SCREEN_RESOLUTION_HEIGHT, window.screen.height)
user.set(CUSTOM_USER_PROPERTIES.SCREEN_RESOLUTION_WIDTH, window.screen.width) user.set(CUSTOM_USER_PROPERTIES.SCREEN_RESOLUTION_WIDTH, window.screen.width)

@ -15,6 +15,8 @@ export function getBrowser(): string {
// "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106" // "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106"
} else if (sUsrAg.indexOf('Trident') > -1) { } else if (sUsrAg.indexOf('Trident') > -1) {
return BROWSER.INTERNET_EXPLORER return BROWSER.INTERNET_EXPLORER
} else if (sUsrAg.indexOf('Brave') > -1) {
return BROWSER.BRAVE
// "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Zoom 3.6.0; wbx 1.0.0; rv:11.0) like Gecko" // "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Zoom 3.6.0; wbx 1.0.0; rv:11.0) like Gecko"
} else if (sUsrAg.indexOf('Edge') > -1) { } else if (sUsrAg.indexOf('Edge') > -1) {
return BROWSER.EDGE return BROWSER.EDGE