Skip to content

Commit

Permalink
fix: No console.warn when amplitude key undefined (#217)
Browse files Browse the repository at this point in the history
* fix: No console.warn when amplitude key undefined

* Fix ts errors

* Use double quote
  • Loading branch information
amaury1093 committed Sep 23, 2019
1 parent 4715c44 commit aa65a31
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 44 deletions.
38 changes: 22 additions & 16 deletions App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,33 @@ if (Constants.manifest.extra.sentryPublicDsn) {
}
}

// Add Amplitude if available
if (Constants.manifest.extra.amplitudeApiKey) {
Amplitude.initialize(Constants.manifest.extra.amplitudeApiKey);
Amplitude.setUserProperties({
sisReleaseChannel: Constants.manifest.releaseChannel || 'development',
sisVersion: Constants.manifest.version
});
}

export function App () {
const [fontLoaded, setFontLoaded] = useState(false);
const [ready, setReady] = useState(false);
useEffect(() => {
Font.loadAsync({
'gotham-black': require('../assets/fonts/Gotham-Black.ttf'),
'gotham-book': require('../assets/fonts/Gotham-Book.ttf')
})
.then(() => setFontLoaded(true))
Promise.all([
Font.loadAsync({
'gotham-black': require('../assets/fonts/Gotham-Black.ttf'),
'gotham-book': require('../assets/fonts/Gotham-Book.ttf')
}),
// Add Amplitude if available
Constants.manifest.extra.amplitudeApiKey
? Amplitude.initialize(Constants.manifest.extra.amplitudeApiKey).then(
() => {
Amplitude.setUserProperties({
sisReleaseChannel:
Constants.manifest.releaseChannel || 'development',
sisVersion: Constants.manifest.version
});
}
)
: Promise.resolve()
])

.then(() => setReady(true))
.catch(console.error);
}, []);

return fontLoaded ? (
return ready ? (
<ErrorContextProvider>
<LocationContextProvider>
<ApiContextProvider>
Expand Down
5 changes: 4 additions & 1 deletion App/Screens/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ export function About (props: AboutProps) {
scrollIntoViewOptions={scrollViewOptions}
style={theme.withPadding}
>
<BackButton onPress={() => navigation.pop()} style={styles.backButton} />
<BackButton
onPress={() => navigation.goBack()}
style={styles.backButton}
/>

<View style={styles.section}>
<Text style={styles.h2}>
Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Details/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function Details (props: DetailsProps) {

return (
<View style={styles.container}>
<Header onBackClick={() => navigation.pop()} />
<Header onBackClick={() => navigation.goBack()} />
<View style={styles.mapContainer}>
{showMap && (
<MapView
Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function Search (props: SearchProps) {
return (
<View style={styles.container}>
<BackButton
onPress={() => props.navigation.pop()}
onPress={() => props.navigation.goBack()}
style={styles.backButton}
/>
<SearchHeader onChangeSearch={handleChangeSearch} search={search} />
Expand Down
5 changes: 5 additions & 0 deletions App/util/amplitude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Sh**t! I Smoke. If not, see <http://www.gnu.org/licenses/>.

import * as Amplitude from 'expo-analytics-amplitude';
import Constants from 'expo-constants';
import { useEffect } from 'react';

type AmplitudeEvent =
Expand Down Expand Up @@ -43,6 +44,10 @@ type AmplitudeEvent =
| 'ERROR_SCREEN_CHANGE_LOCATION_CLICK';

export function track (event: AmplitudeEvent, properties?: Record<string, any>) {
if (!Constants.manifest.extra.amplitudeApiKey) {
return;
}

properties
? Amplitude.logEventWithProperties(event, properties)
: Amplitude.logEvent(event);
Expand Down
1 change: 0 additions & 1 deletion app.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"algoliaApplicationId": "YOUR_KEY",
"amplitudeApiKey": "YOUR_KEY",
"githubUrl": "https://github.com/amaurymartiny/shoot-i-smoke",
"locationIqKey": "YOUR_KEY",
"sentryPublicDsn": "YOUR_KEY",
"waqiToken": "YOUR_KEY"
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@types/expo": "^32.0.13",
"@types/haversine": "^1.1.4",
"@types/i18n-js": "^3.0.1",
"@types/node": "^12.7.2",
"@types/node": "^12.7.5",
"@types/react-native": "^0.60.15",
"axios": "^0.19.0",
"date-fns": "^2.2.1",
Expand All @@ -35,7 +35,7 @@
"io-ts": "^2.0.1",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-gesture-handler": "~1.4.1",
"react-native-gesture-handler": "~1.3.0",
"react-native-maps": "^0.24.2",
"react-native-reanimated": "~1.2.0",
"react-native-scroll-into-view": "^1.0.3",
Expand Down Expand Up @@ -64,7 +64,7 @@
"eslint-plugin-standard": "^4.0.1",
"jest": "^24.9.0",
"jest-expo": "^35.0.0",
"ts-jest": "^24.0.2",
"ts-jest": "^24.1.0",
"typescript": "^3.6.3"
}
}
42 changes: 21 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1316,10 +1316,10 @@
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.136.tgz#413e85089046b865d960c9ff1d400e04c31ab60f"
integrity sha512-0GJhzBdvsW2RUccNHOBkabI8HZVdOXmXbXhuKlDEd5Vv12P7oAVGfomGp3Ne21o5D/qu1WmthlNKFaoZJJeErA==

"@types/node@^12.7.2":
version "12.7.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.2.tgz#c4e63af5e8823ce9cc3f0b34f7b998c2171f0c44"
integrity sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg==
"@types/node@^12.7.5":
version "12.7.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.5.tgz#e19436e7f8e9b4601005d73673b6dc4784ffcc2f"
integrity sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w==

"@types/prop-types@*":
version "15.7.1"
Expand Down Expand Up @@ -3693,11 +3693,6 @@ growly@^1.3.0:
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=

hammerjs@^2.0.8:
version "2.0.8"
resolved "https://registry.yarnpkg.com/hammerjs/-/hammerjs-2.0.8.tgz#04ef77862cff2bb79d30f7692095930222bf60f1"
integrity sha1-BO93hiz/K7edMPdpIJWTAiK/YPE=

handlebars@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67"
Expand Down Expand Up @@ -4985,6 +4980,11 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"

lodash.memoize@4.x:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=

lodash.pad@^4.1.0:
version "4.5.1"
resolved "https://registry.yarnpkg.com/lodash.pad/-/lodash.pad-4.5.1.tgz#4330949a833a7c8da22cc20f6a26c4d59debba70"
Expand Down Expand Up @@ -6332,7 +6332,7 @@ prompts@^2.2.1:
kleur "^3.0.3"
sisteransi "^1.0.3"

prop-types@>=15.6.1, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
prop-types@>=15.6.1, prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -6459,15 +6459,14 @@ react-native-branch@~3.0.1:
resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-3.0.1.tgz#5b07b61cbd290168cd3c3662e017ebe0f356d2ca"
integrity sha512-vbcYxPZlpF5f39GAEUF8kuGQqCNeD3E6zEdvtOq8oCGZunHXlWlKgAS6dgBKCvsHvXgHuMtpvs39VgOp8DaKig==

react-native-gesture-handler@~1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.4.1.tgz#c38d9e57637b95e221722a79f2bafac62e3aeb21"
integrity sha512-Ffcs+SbEbkGaal0CClYL+v7A9y4OA5G5lW01qrzjxaqASp5C8BfnWSKuqYKE00s6bLwE5L4xnlHkG0yIxAtbrQ==
react-native-gesture-handler@~1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.3.0.tgz#d0386f565928ccc1849537f03f2e37fd5f6ad43f"
integrity sha512-ASRFIXBuKRvqlmwkWJhV8yP2dTpvcqVrLNpd7FKVBFHYWr6SAxjGyO9Ik8w1lAxDhMlRP2IcJ9p9eq5X2WWeLQ==
dependencies:
hammerjs "^2.0.8"
hoist-non-react-statics "^2.3.1"
invariant "^2.2.4"
prop-types "^15.7.2"
invariant "^2.2.2"
prop-types "^15.5.10"

react-native-maps@*:
version "0.25.0"
Expand Down Expand Up @@ -7618,15 +7617,16 @@ truncate@^2.1.0:
resolved "https://registry.yarnpkg.com/truncate/-/truncate-2.1.0.tgz#391183563a25cffbd4d613a1d00ae5844c9e55d3"
integrity sha512-em3E3SUDONOjTBcZ36DTm3RvDded3IRU9rX32oHwwXNt3rJD5MVaFlJTQvs8tJoHRoeYP36OuQ1eL/Q7bNEWIQ==

ts-jest@^24.0.2:
version "24.0.2"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-24.0.2.tgz#8dde6cece97c31c03e80e474c749753ffd27194d"
integrity sha512-h6ZCZiA1EQgjczxq+uGLXQlNgeg02WWJBbeT8j6nyIBRQdglqbvzDoHahTEIiS6Eor6x8mK6PfZ7brQ9Q6tzHw==
ts-jest@^24.1.0:
version "24.1.0"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-24.1.0.tgz#2eaa813271a2987b7e6c3fefbda196301c131734"
integrity sha512-HEGfrIEAZKfu1pkaxB9au17b1d9b56YZSqz5eCVE8mX68+5reOvlM93xGOzzCREIov9mdH7JBG+s0UyNAqr0tQ==
dependencies:
bs-logger "0.x"
buffer-from "1.x"
fast-json-stable-stringify "2.x"
json5 "2.x"
lodash.memoize "4.x"
make-error "1.x"
mkdirp "0.x"
resolve "1.x"
Expand Down

0 comments on commit aa65a31

Please sign in to comment.