-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from simonyiszk/analytics
feat: added analytics
- Loading branch information
Showing
14 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
EXPO_PUBLIC_API_BASE_URL= | ||
EXPO_PUBLIC_API_BASE_URL= | ||
EXPO_PUBLIC_DISABLE_ANALYTICS=true |
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import { View, ViewProps } from 'react-native'; | ||
|
||
import { usePageView } from '../../utils/analytics.utils'; | ||
import { cn } from '../../utils/common.utils'; | ||
|
||
export function Screen({ className, ...props }: ViewProps) { | ||
interface ScreenProps extends ViewProps { | ||
analyticsScreenName?: string; | ||
} | ||
|
||
export function Screen({ className, analyticsScreenName, ...props }: ScreenProps) { | ||
usePageView(analyticsScreenName); | ||
return <View className={cn('bg-slate-100 dark:bg-slate-900 h-full', className)} {...props} />; | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import Constants from 'expo-constants'; | ||
|
||
export const API_BASE_URL = Constants.expoConfig?.extra?.apiBaseUrl; | ||
export const DISABLE_ANALYTICS = Constants.expoConfig?.extra?.disableAnalytics; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import axios from 'axios'; | ||
|
||
import { DISABLE_ANALYTICS } from '../config/env.config'; | ||
|
||
export class AnalyticsService { | ||
static sendPageView(location: string) { | ||
const eventBody = { | ||
name: 'pageview', | ||
domain: 'konferenciapp.kir-dev.hu', | ||
url: 'com.kir-dev.konferenciapp://localhost/' + location, | ||
}; | ||
|
||
if (DISABLE_ANALYTICS) { | ||
console.debug('Analytics event', eventBody); | ||
} else { | ||
axios.post('https://visit.kir-dev.hu/api/event', eventBody).catch((error) => { | ||
console.error('Error during analytics event: ', error); | ||
}); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useEffect } from 'react'; | ||
|
||
import { AnalyticsService } from '../services/analytics.service'; | ||
|
||
export function usePageView(location?: string) { | ||
useEffect(() => { | ||
if (!location) return; | ||
AnalyticsService.sendPageView(location); | ||
}, []); | ||
} |