From 6c6f3b5e046e34c49dcbd718032511608474850d Mon Sep 17 00:00:00 2001 From: Emerson Pinheiro Date: Tue, 15 Mar 2022 16:07:32 -0300 Subject: [PATCH 1/8] refact: replaces hard-coded api url by API_URL env variable chore: add react-native-dotenv --- .env | 1 + babel.config.js | 10 +++++++++- data/meditations.ts | 21 +++++++++++---------- env.d.ts | 3 +++ package.json | 1 + yarn.lock | 12 ++++++++++++ 6 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 .env create mode 100644 env.d.ts diff --git a/.env b/.env new file mode 100644 index 0000000..8cc8bd2 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +API_URL=https://goofy-ritchie-dd0c3d.netlify.app \ No newline at end of file diff --git a/babel.config.js b/babel.config.js index 9010057..5ee1036 100644 --- a/babel.config.js +++ b/babel.config.js @@ -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', + }, + ], + ], } } diff --git a/data/meditations.ts b/data/meditations.ts index 9396003..e22fc41 100644 --- a/data/meditations.ts +++ b/data/meditations.ts @@ -1,4 +1,5 @@ import { ImageSourcePropType } from 'react-native' +import { API_URL } from 'react-native-dotenv' export interface Meditation { /* Unique id of the meditation */ @@ -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'), }, { @@ -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'), }, { @@ -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'), }, { @@ -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'), }, ] @@ -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'), }, { @@ -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'), }, { @@ -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'), }, ] @@ -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'), }, { @@ -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'), }, { @@ -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'), }, ] diff --git a/env.d.ts b/env.d.ts new file mode 100644 index 0000000..2ad1521 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,3 @@ +declare module 'react-native-dotenv' { + export const API_URL: string +} diff --git a/package.json b/package.json index bccd69a..0dab039 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,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", diff --git a/yarn.lock b/yarn.lock index 588fa8f..c094ad5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -13232,6 +13237,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" From a5a268fa3111b64670c2f58c519ef14c644ad8d8 Mon Sep 17 00:00:00 2001 From: Emerson Pinheiro Date: Tue, 15 Mar 2022 16:19:04 -0300 Subject: [PATCH 2/8] refact: adds UA to an env variable --- .env | 3 ++- env.d.ts | 1 + utils/analytics.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 8cc8bd2..57ecd08 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ -API_URL=https://goofy-ritchie-dd0c3d.netlify.app \ No newline at end of file +API_URL=https://goofy-ritchie-dd0c3d.netlify.app +UA=c53c4e54414340dc1e6feeb7fd95293c diff --git a/env.d.ts b/env.d.ts index 2ad1521..470c81f 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,3 +1,4 @@ declare module 'react-native-dotenv' { export const API_URL: string + export const UA: string } diff --git a/utils/analytics.ts b/utils/analytics.ts index 4cbf5ca..8912da0 100644 --- a/utils/analytics.ts +++ b/utils/analytics.ts @@ -1,9 +1,10 @@ import * as Amplitude from 'expo-analytics-amplitude' import { Platform } from 'react-native' +import { UA } from 'react-native-dotenv' export const initializeAnalytics = async () => { if (Platform.OS !== 'web') { - await Amplitude.initializeAsync('c53c4e54414340dc1e6feeb7fd95293c') + await Amplitude.initializeAsync(UA) } } From f459af20cae8f03e176b3b1e8f255a28016ed0e1 Mon Sep 17 00:00:00 2001 From: Adrian Carolli Date: Fri, 1 Apr 2022 18:59:06 -0400 Subject: [PATCH 3/8] feat: adds transparent tracking for iOS --- app.json | 10 +++++++++- package.json | 3 ++- utils/analytics.ts | 13 +++++++++++++ yarn.lock | 17 ++++++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/app.json b/app.json index b7dfe55..cf1dae0 100644 --- a/app.json +++ b/app.json @@ -36,6 +36,14 @@ }, "web": { "favicon": "./assets/images/favicon.png" - } + }, + "plugins": [ + [ + "expo-tracking-transparency", + { + "userTrackingPermission": "This identifier will be used to improve the user experience." + } + ] + ] } } diff --git a/package.json b/package.json index bccd69a..96c0394 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/utils/analytics.ts b/utils/analytics.ts index 4cbf5ca..b303493 100644 --- a/utils/analytics.ts +++ b/utils/analytics.ts @@ -1,13 +1,26 @@ import * as Amplitude from 'expo-analytics-amplitude' import { Platform } from 'react-native' +import { requestTrackingPermissionsAsync } from 'expo-tracking-transparency' export const initializeAnalytics = async () => { + if (Platform.OS === 'ios') { + const { status } = await requestTrackingPermissionsAsync() + if (status !== 'granted') { + return + } + } if (Platform.OS !== 'web') { await Amplitude.initializeAsync('c53c4e54414340dc1e6feeb7fd95293c') } } 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) } diff --git a/yarn.lock b/yarn.lock index 588fa8f..1a783d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7034,7 +7034,7 @@ 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== @@ -7042,6 +7042,14 @@ expo-file-system@~13.1.2, expo-file-system@~13.1.3: "@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" @@ -7125,6 +7133,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" From df26fad03881e2d3cfa074bac0db98c510f8de19 Mon Sep 17 00:00:00 2001 From: Adrian Carolli Date: Fri, 1 Apr 2022 19:00:09 -0400 Subject: [PATCH 4/8] chore: bump build number --- app.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index cf1dae0..3af439c 100644 --- a/app.json +++ b/app.json @@ -19,7 +19,7 @@ "assetBundlePatterns": ["**/*"], "ios": { "supportsTablet": true, - "buildNumber": "17", + "buildNumber": "18", "infoPlist": { "UIBackgroundModes": ["audio"] }, @@ -32,7 +32,7 @@ "backgroundColor": "#ffffff" }, "package": "com.meditation.heylinda", - "versionCode": 17 + "versionCode": 18 }, "web": { "favicon": "./assets/images/favicon.png" From fedd58a5ea5ebc8e9530a6a1e44c82a636d488bf Mon Sep 17 00:00:00 2001 From: Adrian Carolli Date: Fri, 8 Apr 2022 16:13:57 -0400 Subject: [PATCH 5/8] fix: transparency description for apple --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index 3af439c..7427536 100644 --- a/app.json +++ b/app.json @@ -41,7 +41,7 @@ [ "expo-tracking-transparency", { - "userTrackingPermission": "This identifier will be used to improve the user experience." + "userTrackingPermission": "This identifier will be used to deliver personalized ads to you." } ] ] From 56b343598efc3e062892023dfd208d079fc882ff Mon Sep 17 00:00:00 2001 From: Adrian Carolli Date: Fri, 8 Apr 2022 16:14:46 -0400 Subject: [PATCH 6/8] chore: bump build number and version code --- app.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index 7427536..fe2fba8 100644 --- a/app.json +++ b/app.json @@ -19,7 +19,7 @@ "assetBundlePatterns": ["**/*"], "ios": { "supportsTablet": true, - "buildNumber": "18", + "buildNumber": "19", "infoPlist": { "UIBackgroundModes": ["audio"] }, @@ -32,7 +32,7 @@ "backgroundColor": "#ffffff" }, "package": "com.meditation.heylinda", - "versionCode": 18 + "versionCode": 19 }, "web": { "favicon": "./assets/images/favicon.png" From 5fda80ccc93b8c7e82735e1c03cc0fd1c6d27f70 Mon Sep 17 00:00:00 2001 From: Emerson Pinheiro Date: Tue, 15 Mar 2022 16:07:32 -0300 Subject: [PATCH 7/8] refact: replaces hard-coded api url by API_URL env variable chore: add react-native-dotenv --- .env | 1 + babel.config.js | 10 +++++++++- data/meditations.ts | 21 +++++++++++---------- env.d.ts | 3 +++ package.json | 1 + yarn.lock | 12 ++++++++++++ 6 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 .env create mode 100644 env.d.ts diff --git a/.env b/.env new file mode 100644 index 0000000..8cc8bd2 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +API_URL=https://goofy-ritchie-dd0c3d.netlify.app \ No newline at end of file diff --git a/babel.config.js b/babel.config.js index 9010057..5ee1036 100644 --- a/babel.config.js +++ b/babel.config.js @@ -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', + }, + ], + ], } } diff --git a/data/meditations.ts b/data/meditations.ts index 9396003..e22fc41 100644 --- a/data/meditations.ts +++ b/data/meditations.ts @@ -1,4 +1,5 @@ import { ImageSourcePropType } from 'react-native' +import { API_URL } from 'react-native-dotenv' export interface Meditation { /* Unique id of the meditation */ @@ -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'), }, { @@ -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'), }, { @@ -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'), }, { @@ -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'), }, ] @@ -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'), }, { @@ -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'), }, { @@ -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'), }, ] @@ -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'), }, { @@ -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'), }, { @@ -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'), }, ] diff --git a/env.d.ts b/env.d.ts new file mode 100644 index 0000000..2ad1521 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,3 @@ +declare module 'react-native-dotenv' { + export const API_URL: string +} diff --git a/package.json b/package.json index 96c0394..ad4fd84 100644 --- a/package.json +++ b/package.json @@ -50,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", diff --git a/yarn.lock b/yarn.lock index 1a783d7..507e67d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -13247,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" From 274dd3b51e47e8a296343fe9868402fe4b0618ed Mon Sep 17 00:00:00 2001 From: Emerson Pinheiro Date: Tue, 15 Mar 2022 16:19:04 -0300 Subject: [PATCH 8/8] refact: adds UA to an env variable --- .env | 3 ++- env.d.ts | 1 + utils/analytics.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 8cc8bd2..57ecd08 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ -API_URL=https://goofy-ritchie-dd0c3d.netlify.app \ No newline at end of file +API_URL=https://goofy-ritchie-dd0c3d.netlify.app +UA=c53c4e54414340dc1e6feeb7fd95293c diff --git a/env.d.ts b/env.d.ts index 2ad1521..470c81f 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,3 +1,4 @@ declare module 'react-native-dotenv' { export const API_URL: string + export const UA: string } diff --git a/utils/analytics.ts b/utils/analytics.ts index b303493..d17b298 100644 --- a/utils/analytics.ts +++ b/utils/analytics.ts @@ -1,6 +1,7 @@ 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') { @@ -10,7 +11,7 @@ export const initializeAnalytics = async () => { } } if (Platform.OS !== 'web') { - await Amplitude.initializeAsync('c53c4e54414340dc1e6feeb7fd95293c') + await Amplitude.initializeAsync(UA) } }