-
Notifications
You must be signed in to change notification settings - Fork 25
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
Eslint fixes, dotenv and growthbook #95
Changes from all commits
87467a5
c9bd7c9
2855013
e451c07
ec00ffb
8c11040
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
JSON_PLACEHOLDER_API="https://jsonplaceholder.typicode.com" | ||
SIMPSONS_API="https://thesimpsonsquoteapi.glitch.me/" | ||
SENTRY_DSN= "https://0fbf25b4bfb443b7ae58aa4baf34460e@o4505374929584128.ingest.us.sentry.io/4505374931812352" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,4 +62,5 @@ buck-out/ | |
web-build/ | ||
dist/ | ||
reports | ||
coverage | ||
coverage | ||
.env.local |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
auth.token=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 | ||
|
||
defaults.org=wednesday-solutions-5p | ||
defaults.project=react-native | ||
|
||
defaults.url=https://sentry.io/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { JSON_PLACEHOLDER_API } from '@env'; | ||
|
||
export const Config = { | ||
API_URL: 'https://jsonplaceholder.typicode.com/users/' | ||
API_URL: `${JSON_PLACEHOLDER_API}/users/` | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { SIMPSONS_API } from '@env'; | ||
|
||
export const Config = { | ||
API_URL: 'https://thesimpsonsquoteapi.glitch.me/' | ||
API_URL: SIMPSONS_API | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { JSON_PLACEHOLDER_API } from '@env'; | ||
|
||
export const Config = { | ||
API_URL: 'https://jsonplaceholder.typicode.com/users/' | ||
API_URL: `${JSON_PLACEHOLDER_API}/users/` | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,64 @@ | ||||||||||||||||||||||||||||||||||
import { GrowthBook } from '@growthbook/growthbook'; | ||||||||||||||||||||||||||||||||||
import { GROWTH_BOOK_API_HOST, GROWTH_BOOK_CLIENT_KEY } from '@env'; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
let growthBookClient; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* creates an instance of the growthBook client | ||||||||||||||||||||||||||||||||||
* @returns growthBook client | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
export const createGrowthBookClient = userEmail => { | ||||||||||||||||||||||||||||||||||
const growthBook = new GrowthBook({ | ||||||||||||||||||||||||||||||||||
apiHost: GROWTH_BOOK_API_HOST, | ||||||||||||||||||||||||||||||||||
clientKey: GROWTH_BOOK_CLIENT_KEY, | ||||||||||||||||||||||||||||||||||
enableDevMode: true, | ||||||||||||||||||||||||||||||||||
subscribeToChanges: true | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
growthBook.setAttributes({ | ||||||||||||||||||||||||||||||||||
email: userEmail | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
return growthBook; | ||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* Function to get the GrowthBook client instance | ||||||||||||||||||||||||||||||||||
* @returns {GrowthBook} growthBook instance | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
export function getGrowthBookClient(email) { | ||||||||||||||||||||||||||||||||||
if (growthBookClient) { | ||||||||||||||||||||||||||||||||||
return growthBookClient; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
return createGrowthBookClient(email); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* Function to get growthBook feature | ||||||||||||||||||||||||||||||||||
* @param {String} email | ||||||||||||||||||||||||||||||||||
* @returns {Applicant} growthBook feature value | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
export async function getGrowthBookFeaturesData(name, email) { | ||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||
const growthBook = getGrowthBookClient(email); | ||||||||||||||||||||||||||||||||||
await growthBook.loadFeatures(); | ||||||||||||||||||||||||||||||||||
return growthBook.getFeatureValue(name); | ||||||||||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||||||||||
return new Error(error); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
Comment on lines
+41
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling in Instead of returning an Apply this diff to improve error handling: - return new Error(error);
+ throw error; Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please check this once There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shamoilattaar-wednesday, I've reviewed the suggestion to throw the error instead of returning a new |
||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
* Function to get growthBook feature | ||||||||||||||||||||||||||||||||||
* @param {String} name | ||||||||||||||||||||||||||||||||||
* @returns {Boolean} growthBook feature status | ||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||
export async function getGrowthBookFeatureFlag(name, email) { | ||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||
const growthBook = getGrowthBookClient(email); | ||||||||||||||||||||||||||||||||||
await growthBook.loadFeatures(); | ||||||||||||||||||||||||||||||||||
return growthBook.isOn(name); | ||||||||||||||||||||||||||||||||||
} catch (error) { | ||||||||||||||||||||||||||||||||||
return new Error(error); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
Comment on lines
+56
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling in Instead of returning an Apply this diff to improve error handling: - return new Error(error);
+ throw error; Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,7 @@ | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
auth.token=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 | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
defaults.org=wednesday-solutions-5p | ||||||||||||||||||||||||||||||
defaults.project=react-native | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
defaults.url=https://sentry.io/ | ||||||||||||||||||||||||||||||
Comment on lines
+1
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid hardcoding sensitive information. The auth token is hardcoded, which may pose a security risk. Consider using environment variables to manage sensitive information securely. Apply this diff to replace the hardcoded auth token with an environment variable: -auth.token=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
+auth.token=${SENTRY_AUTH_TOKEN} Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Learn more https://docs.expo.io/guides/customizing-metro | ||
const { getDefaultConfig } = require('@expo/metro-config'); | ||
const { getSentryExpoConfig } = require('@sentry/react-native/metro'); | ||
|
||
// eslint-disable-next-line fp/no-mutation | ||
module.exports = getDefaultConfig(__dirname); | ||
module.exports = getSentryExpoConfig(__dirname); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid hardcoding sensitive information.
The auth token is hardcoded, which may pose a security risk. Consider using environment variables to manage sensitive information securely.
Apply this diff to replace the hardcoded auth token with an environment variable:
Committable suggestion