Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - env variables #149

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
API_URL=https://goofy-ritchie-dd0c3d.netlify.app
UA=c53c4e54414340dc1e6feeb7fd95293c
14 changes: 11 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"buildNumber": "17",
"buildNumber": "19",
"infoPlist": {
"UIBackgroundModes": ["audio"]
},
Expand All @@ -32,10 +32,18 @@
"backgroundColor": "#ffffff"
},
"package": "com.meditation.heylinda",
"versionCode": 17
"versionCode": 19
},
"web": {
"favicon": "./assets/images/favicon.png"
}
},
"plugins": [
[
"expo-tracking-transparency",
{
"userTrackingPermission": "This identifier will be used to deliver personalized ads to you."
}
]
]
}
}
10 changes: 9 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ module.exports = function (api) {
api.cache(true)
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
plugins: [
'react-native-reanimated/plugin',
[
'module:react-native-dotenv',
{
moduleName: 'react-native-dotenv',
},
],
],
}
}
21 changes: 11 additions & 10 deletions data/meditations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ImageSourcePropType } from 'react-native'
import { API_URL } from 'react-native-dotenv'

export interface Meditation {
/* Unique id of the meditation */
Expand Down Expand Up @@ -30,7 +31,7 @@ export const popular: Meditation[] = [
track: 0,
subtitle: 'Love and Peace',
time: 2,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/17.mp3',
uri: `${API_URL}/meditations/17.mp3`,
image: require('../assets/images/meditate6.jpg'),
},
{
Expand All @@ -40,7 +41,7 @@ export const popular: Meditation[] = [
track: 1,
subtitle: 'Busy At Work',
time: 5,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/1.mp3',
uri: `${API_URL}/meditations/1.mp3`,
image: require('../assets/images/meditate1.jpg'),
},
{
Expand All @@ -50,7 +51,7 @@ export const popular: Meditation[] = [
track: 2,
subtitle: 'Just Breath',
time: 5,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/2.mp3',
uri: `${API_URL}/meditations/2.mp3`,
image: require('../assets/images/meditate2.jpg'),
},
{
Expand All @@ -60,7 +61,7 @@ export const popular: Meditation[] = [
subtitle: 'Rise and Shine',
track: 3,
time: 5,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/3.mp3',
uri: `${API_URL}/meditations/3.mp3`,
image: require('../assets/images/meditate5.jpg'),
},
]
Expand All @@ -73,7 +74,7 @@ export const anxiety: Meditation[] = [
track: 4,
subtitle: 'Release Anxiety',
time: 10,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/4.mp3',
uri: `${API_URL}/meditations/4.mp3`,
image: require('../assets/images/meditate3.jpg'),
},
{
Expand All @@ -83,7 +84,7 @@ export const anxiety: Meditation[] = [
subtitle: 'Deep Relaxation',
track: 7,
time: 11,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/7.mp3',
uri: `${API_URL}/meditations/7.mp3`,
image: require('../assets/images/meditate4.jpg'),
},
{
Expand All @@ -93,7 +94,7 @@ export const anxiety: Meditation[] = [
subtitle: 'Get Some Rest',
track: 8,
time: 11,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/8.mp3',
uri: `${API_URL}/meditations/8.mp3`,
image: require('../assets/images/rocks.jpg'),
},
]
Expand All @@ -106,7 +107,7 @@ export const sleep: Meditation[] = [
subtitle: 'Wake Up Refreshed',
track: 5,
time: 8,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/5.mp3',
uri: `${API_URL}/meditations/5.mp3`,
image: require('../assets/images/tea.jpg'),
},
{
Expand All @@ -116,7 +117,7 @@ export const sleep: Meditation[] = [
subtitle: 'For Taking a Nap',
track: 6,
time: 28,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/6.mp3',
uri: `${API_URL}/meditations/6.mp3`,
image: require('../assets/images/sleep.jpg'),
},
{
Expand All @@ -126,7 +127,7 @@ export const sleep: Meditation[] = [
track: 12,
subtitle: 'Drift Off To Sleep',
time: 15,
uri: 'https://goofy-ritchie-dd0c3d.netlify.app/meditations/12.mp3',
uri: `${API_URL}/meditations/12.mp3`,
image: require('../assets/images/sleep2.jpg'),
},
]
Expand Down
4 changes: 4 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module 'react-native-dotenv' {
export const API_URL: string
export const UA: string
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
"expo-av": "~10.2.0",
"expo-blur": "~11.0.0",
"expo-constants": "~13.0.1",
"expo-file-system": "~13.1.2",
"expo-file-system": "~13.1.4",
"expo-font": "~10.0.4",
"expo-linking": "~3.0.0",
"expo-navigation-bar": "~1.1.1",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"expo-system-ui": "~1.1.0",
"expo-tracking-transparency": "~2.1.0",
"expo-web-browser": "~10.1.0",
"jest": "^26.6.3",
"patch-package": "^6.4.7",
Expand All @@ -49,6 +50,7 @@
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-calendars": "^1.1267.0",
"react-native-dotenv": "^3.3.1",
"react-native-gesture-handler": "~2.1.0",
"react-native-get-random-values": "~1.7.0",
"react-native-paper": "^4.9.2",
Expand Down
16 changes: 15 additions & 1 deletion utils/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import * as Amplitude from 'expo-analytics-amplitude'
import { Platform } from 'react-native'
import { requestTrackingPermissionsAsync } from 'expo-tracking-transparency'
import { UA } from 'react-native-dotenv'

export const initializeAnalytics = async () => {
if (Platform.OS === 'ios') {
const { status } = await requestTrackingPermissionsAsync()
if (status !== 'granted') {
return
}
}
if (Platform.OS !== 'web') {
await Amplitude.initializeAsync('c53c4e54414340dc1e6feeb7fd95293c')
await Amplitude.initializeAsync(UA)
}
}

export const logEvent = async (eventName: string) => {
if (Platform.OS === 'ios') {
const { status } = await requestTrackingPermissionsAsync()
if (status !== 'granted') {
return
}
}
if (Platform.OS !== 'web') {
await Amplitude.logEventAsync(eventName)
}
Expand Down
29 changes: 28 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6297,6 +6297,11 @@ dot-prop@^5.2.0:
dependencies:
is-obj "^2.0.0"

dotenv@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==

duplexer3@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2"
Expand Down Expand Up @@ -7034,14 +7039,22 @@ expo-error-recovery@~3.0.5:
resolved "https://registry.yarnpkg.com/expo-error-recovery/-/expo-error-recovery-3.0.5.tgz#1802b733e998606a8fcfb0abe6682c334319ef75"
integrity sha512-VM6OOecjt0aPu5/eCdGGJfNjvAZIemaQym0JF/+SA5IlLiPpEfbVCDTO/5yiS8Zb5fKpeABx+GCRmtfnFqvRRw==

expo-file-system@~13.1.2, expo-file-system@~13.1.3:
expo-file-system@~13.1.3:
version "13.1.3"
resolved "https://registry.yarnpkg.com/expo-file-system/-/expo-file-system-13.1.3.tgz#3ef5139d8add0bbd2b472b03f1ad5ebd954d6eb5"
integrity sha512-yh1LmxVvezoxwSAUWDRda36+nw96IQj4EgiYNbl6LK6Drtc/v5OhWl1vJG7oSYNhZ0zMwo1CSE4gC7h50ZldtQ==
dependencies:
"@expo/config-plugins" "^4.0.2"
uuid "^3.4.0"

expo-file-system@~13.1.4:
version "13.1.4"
resolved "https://registry.yarnpkg.com/expo-file-system/-/expo-file-system-13.1.4.tgz#08fc20d49b2182e1fd195d95c40cf7eddfe7bd91"
integrity sha512-/C2FKCzrdWuEt4m8Pzl9J4MhKgfU0denVLbqoKjidv8DnsLQrscFNlLhXuiooqWwsxB2OWAtGEVnPGJBWVuNEQ==
dependencies:
"@expo/config-plugins" "^4.0.2"
uuid "^3.4.0"

expo-font@~10.0.4, expo-font@~10.0.5:
version "10.0.5"
resolved "https://registry.yarnpkg.com/expo-font/-/expo-font-10.0.5.tgz#8010060ec5326b3b462f7a1ac6b232dc4d1a7317"
Expand Down Expand Up @@ -7125,6 +7138,13 @@ expo-system-ui@~1.1.0:
"@react-native/normalize-color" "^2.0.0"
debug "^4.3.2"

expo-tracking-transparency@~2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/expo-tracking-transparency/-/expo-tracking-transparency-2.1.0.tgz#74f44d660f0d0679fec556b3c76a22a930116e74"
integrity sha512-I63RxvM/gv/+1YlWaSA0wbBIZayPZ/fw2Ptg2NfPgFNYoEPBvCe+r7Ni3giODGsl3YEdPQyF1gJDr0/PO1QHsg==
dependencies:
"@expo/config-plugins" "^4.0.2"

expo-web-browser@~10.1.0:
version "10.1.1"
resolved "https://registry.yarnpkg.com/expo-web-browser/-/expo-web-browser-10.1.1.tgz#0fa74ac57605b8b2a30aee747c423ce3827fa183"
Expand Down Expand Up @@ -13232,6 +13252,13 @@ react-native-codegen@^0.0.6:
jscodeshift "^0.11.0"
nullthrows "^1.1.1"

react-native-dotenv@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-3.3.1.tgz#8f399cf28ca77d860d8e7f7323e439fa60a8ca0b"
integrity sha512-gAKXout1XCwCqJ3QPGoQAF2eRzOHgOnwg3x19z+ssow8bDIksJeKBqvoHDyGziVilAIP1J0bEC9Jf+VF8nFang==
dependencies:
dotenv "^10.0.0"

react-native-gesture-handler@~2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.1.1.tgz#1d417bc7b551ec76129ce09861b3a01622b4ef99"
Expand Down