Skip to content

Commit

Permalink
chore: remove tracking and export config variable to env file (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Saillard <gabriel@saillard.dev>
  • Loading branch information
Blightwidow and GitSquared committed Sep 27, 2023
1 parent 022aa7e commit f1cb2d5
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 1,293 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MAPBOX_ACCESS_TOKEN="xyz"
MAP_SERVICES_API_URL="https://valhalla1.openstreetmap.de"
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ If you're curious, feel free to dig around!

This is a basic managed expo app, and there are a few scripts in `package.json` that should help you find your way.

Secrets and API keys have been cut out of this release, and you might need to get new ones and put them in `app.config.ts` to succesfully build the app.
All removed secrets have been replaced with the `[CENSORED]` tag to easily identify where they're missing.

## Monitoring

The implementation contains leftovers of our monitoring and tracking solutions (UXCam, Sentry). The API keys related to those have been deleted from the source code, and the related accounts on the monitoring platforms have been closed.
You need to provide your own secrets to access the map through [Mapbox](https://docs.mapbox.com/help/getting-started/access-tokens/) and provide support for other map services like snap-to-road path tracing. Copy the `.env.example` file to `.env` and set them up there.

## Licensing
The untitled map app source code is shared under a Creative Commons [BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/) license.
Expand Down
34 changes: 3 additions & 31 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
resizeMode: 'cover',
backgroundColor: '#FFFFFF',
},
updates: {
fallbackToCacheTimeout: 0,
url: '[CENSORED]',
},
hooks: {
postPublish: [
{
file: 'sentry-expo/upload-sourcemaps',
config: {
organization: 'reality-co-open-source',
project: 'uma',
setCommits: true,
},
},
],
},
plugins: [
[
'expo-build-properties',
Expand All @@ -44,13 +28,6 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
},
},
],
'sentry-expo',
[
'expo-updates',
{
username: 'reality-co',
},
],
[
'expo-location',
{
Expand All @@ -68,7 +45,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
'@rnmapbox/maps',
{
RNMapboxMapsImpl: 'mapbox',
RNMapboxMapsDownloadToken: '[CENSORED]',
RNMapboxMapsDownloadToken: process.env.MAPBOX_ACCESS_TOKEN,
},
],
],
Expand Down Expand Up @@ -101,12 +78,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
],
},
extra: {
eas: {
projectId: '[CENSORED]',
},
mapServicesApiUrl: '[CENSORED]',
mapboxAccessToken: '[CENSORED]',
uxCamAppKey: '[CENSORED]',
sentryDsn: '[CENSORED]',
mapServicesApiUrl: process.env.MAP_SERVICES_API_URL,
mapboxAccessToken: process.env.MAPBOX_ACCESS_TOKEN,
},
})
36 changes: 1 addition & 35 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ import { InterTight_700Bold } from '@expo-google-fonts/inter-tight'
import { Lexend_400Regular, Lexend_500Medium } from '@expo-google-fonts/lexend'
import { safeBottomSheetViewScreenOptions } from '@lib/components/generic/SafeBottomSheetView'
import BackgroundLocationServiceController from '@lib/services/BackgroundLocationServiceController'
import { setupRoutingInstrumentation } from '@lib/services/monitoring'
import TracingCrawlerServiceProvider from '@lib/services/tracing-crawler/TracingCrawlerServiceProvider'
import WebWorkerThreadProvider from '@lib/services/web-worker/WebWorkerThreadProvider'
import DatabaseProvider, {
initializeDatabase,
} from '@lib/utils/DatabaseProvider'
import SettingsProvider from '@lib/utils/SettingsProvider'
import * as Font from 'expo-font'
import { SplashScreen, Stack, useRootNavigation } from 'expo-router'
import { SplashScreen, Stack } from 'expo-router'
import { StatusBar } from 'expo-status-bar'
import * as Updates from 'expo-updates'
import { useEffect, useState } from 'react'
import RNUxcam from 'react-native-ux-cam'

SplashScreen.preventAutoHideAsync()

Expand Down Expand Up @@ -61,37 +58,6 @@ export default function RootLayout() {
}
}, [appIsReady])

Updates.useUpdateEvents((e) => {
console.debug('eas update event', e)
})
useEffect(() => {
console.log('Expo updates status', {
channel: Updates.channel,
runtime: Updates.runtimeVersion,
})
}, [])

const navigation = useRootNavigation()

useEffect(() => {
if (navigation) {
setupRoutingInstrumentation(navigation)
}

const onStateChange = () => {
const screenName = navigation?.getCurrentRoute()?.name
if (!screenName) return

RNUxcam.tagScreenName(screenName)
}

navigation?.addListener('state', onStateChange)

return () => {
navigation?.removeListener('state', onStateChange)
}
}, [navigation])

if (!appIsReady) {
return null
}
Expand Down
5 changes: 1 addition & 4 deletions lib/components/DebugInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Text from '@lib/components/generic/Text'
import LocationPoint from '@lib/entities/LocationPoint'
import dataSource from '@lib/utils/data-source'
import Constants from 'expo-constants'
import * as Updates from 'expo-updates'
import { useEffect, useState } from 'react'
import { StyleSheet } from 'react-native'

Expand Down Expand Up @@ -39,9 +38,7 @@ export default function DebugInfo() {
'unknown'
}`}
{'\n'}
{`build ${Constants.expoConfig?.version ?? 'unknown'}-${(
Updates.createdAt ?? new Date()
).toISOString()}`}
{`build ${Constants.expoConfig?.version ?? 'unknown'}`}
{'\n'}
database: {dataSource.options.database}
{' / '}
Expand Down
3 changes: 0 additions & 3 deletions lib/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import {
backgroundLocationService,
backgroundLocationTaskName,
} from './background-location'
import { setupMonitoring } from './monitoring'

export function registerServices() {
setupMonitoring()

TaskManager.defineTask(backgroundLocationTaskName, backgroundLocationService)
setupAppWideEvents()
}
87 changes: 0 additions & 87 deletions lib/services/monitoring.ts

This file was deleted.

43 changes: 0 additions & 43 deletions lib/services/tracing-crawler/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ComputedFogShape from '@lib/entities/ComputedFogShape'
import ComputedWalkTrace from '@lib/entities/ComputedWalkTrace'
import * as Monitoring from '@lib/services/monitoring'
import ThreadBridgeEventBus from '@lib/services/web-worker/thread-bridge'
import dataSource from '@lib/utils/data-source'
import * as turf from '@turf/turf'
Expand Down Expand Up @@ -36,31 +35,17 @@ export default async function crawlTrace(
}> {
console.group('crawlTrace: start')
console.time('crawlTrace')
const crawlRunTransaction = Monitoring.startTransaction({
op: 'tracingCrawler.crawlLoop',
name: 'Tracing crawler crawl loop',
})

try {
// TARGET
console.time('crawlTrace: query')
const querySpan = crawlRunTransaction.startChild({
op: 'tracingCrawler.query',
})

const nextTraceState = await getNextTracingCrawlerState()

if (!nextTraceState) {
console.info('crawlTrace: no more points to trace')

console.timeEnd('crawlTrace: query')
console.timeEnd('crawlTrace')
console.groupEnd()
querySpan.setStatus(Monitoring.Status.Ok)
querySpan.finish()
crawlRunTransaction.setStatus(Monitoring.Status.Ok)
crawlRunTransaction.finish()

return { moreWorkAhead: false }
}

Expand All @@ -82,15 +67,9 @@ export default async function crawlTrace(
)

console.timeEnd('crawlTrace: query')
querySpan.setStatus(Monitoring.Status.Ok)
querySpan.finish()

// TRACE

console.time('crawlTrace: trace')
const traceSpan = crawlRunTransaction.startChild({
op: 'tracingCrawler.trace',
})

let fogShape: FogShapeGeometries
let walkTrace: WalkTraceGeometries
Expand Down Expand Up @@ -130,9 +109,6 @@ export default async function crawlTrace(
// EXPAND OR CREATE

console.time('crawlTrace: expand geometries')
const expandSpan = crawlRunTransaction.startChild({
op: 'tracingCrawler.expand',
})

fogShape = await workerThread.waitFor(
workerThread.submitJobRequest(ThreadedFnName.ExpandOrCreateFog, [
Expand All @@ -147,8 +123,6 @@ export default async function crawlTrace(
)

console.timeEnd('crawlTrace: expand geometries')
expandSpan.setStatus(Monitoring.Status.Ok)
expandSpan.finish()
}

const justDrawnPoint = latestUntracedPoint
Expand Down Expand Up @@ -189,16 +163,11 @@ export default async function crawlTrace(
}

console.timeEnd('crawlTrace: trace')
traceSpan.setStatus(Monitoring.Status.Ok)
traceSpan.finish()

// MERGE
// TODO: move from using tracing time to using geographical proximity to find geometries to merge

console.time('crawlTrace: merge geometries')
const mergeSpan = crawlRunTransaction.startChild({
op: 'tracingCrawler.merge',
})

let hasMergedFogShapes = false
let hasMergedWalkTraces = false
Expand Down Expand Up @@ -278,15 +247,10 @@ export default async function crawlTrace(
}

console.timeEnd('crawlTrace: merge geometries')
mergeSpan.setStatus(Monitoring.Status.Ok)
mergeSpan.finish()

// COMMIT

console.time('crawlTrace: write new state')
const commitSpan = crawlRunTransaction.startChild({
op: 'tracingCrawler.commit',
})

await dataSource
.transaction(async (entityManager) => {
Expand All @@ -303,26 +267,19 @@ export default async function crawlTrace(
})
.catch((error) => {
console.error('crawlTrace: error saving new state', error)
Monitoring.captureException(error)
})

console.timeEnd('crawlTrace: write new state')
commitSpan.setStatus(Monitoring.Status.Ok)
commitSpan.finish()

console.timeEnd('crawlTrace')
console.groupEnd()
crawlRunTransaction.setStatus(Monitoring.Status.Ok)
crawlRunTransaction.finish()

return {
moreWorkAhead: true,
cursorTime: justDrawnPoint.timestamp,
}
} catch (error) {
console.error('crawlTrace: error', error)
crawlRunTransaction.setStatus(Monitoring.Status.InternalError)
Monitoring.captureException(error)
}

return {
Expand Down
Loading

0 comments on commit f1cb2d5

Please sign in to comment.