Skip to content

Commit

Permalink
Merge pull request #95 from wednesday-solutions/feat/eslint-and-growt…
Browse files Browse the repository at this point in the history
…hbook

Eslint fixes, dotenv and growthbook
  • Loading branch information
shamoilattaar-wednesday authored Aug 27, 2024
2 parents ca2ba1d + 8c11040 commit fd68baf
Show file tree
Hide file tree
Showing 18 changed files with 370 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .env
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"
15 changes: 7 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
const fs = require('fs');
const path = require('path');


const prettierOptions = JSON.parse(
fs.readFileSync(path.resolve(__dirname, '.prettierrc'), 'utf8'),
fs.readFileSync(path.resolve(__dirname, '.prettierrc'), 'utf8')
);
module.exports = {
root: true,
parser: 'babel-eslint',
extends: [
'airbnb',
'prettier',
'prettier',
'prettier/react',
'plugin:prettier/recommended',
'plugin:sonarjs/recommended',
Expand Down Expand Up @@ -54,13 +53,13 @@ module.exports = {
'import/no-unresolved': 0,
'import/prefer-default-export': 0,
'react/jsx-props-no-spreading': 0,
'camelcase': ['error', { 'properties': 'always', ignoreImports: false}],
camelcase: ['error', { properties: 'always', ignoreImports: false }],
indent: [
2,
2,
{
SwitchCase: 1,
},
SwitchCase: 1
}
],
'jsx-a11y/aria-props': 2,
'jsx-a11y/heading-has-content': 0,
Expand Down Expand Up @@ -120,7 +119,7 @@ module.exports = {
}
],
'no-shadow': 'error',
complexity: ['error', 10],
complexity: ['error', 2],
'no-empty': 'error',
'import/order': [
'error',
Expand Down Expand Up @@ -171,4 +170,4 @@ module.exports = {
}
}
}
};
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ buck-out/
web-build/
dist/
reports
coverage
coverage
.env.local
6 changes: 6 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

import { registerRootComponent } from 'expo';
import App from '@app/app';
import { SENTRY_DSN } from '@env';
import * as Sentry from '@sentry/react-native';

Sentry.init({
dsn: SENTRY_DSN
});

if (!window.Intl) {
new Promise(resolve => {
Expand Down
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInRelea
*/
def jscFlavor = 'org.webkit:android-jsc:+'

apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")
android {
ndkVersion rootProject.ext.ndkVersion

Expand Down Expand Up @@ -173,4 +174,4 @@ dependencies {
}

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
applyNativeModulesAppBuildGradle(project)
7 changes: 7 additions & 0 deletions android/sentry.properties
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/
12 changes: 11 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
},
"ios": {
"bundleIdentifier": "com.wednesdaysolutions.rntws"
}
},
"plugins": [
[
"@sentry/react-native/expo",
{
"url": "https://sentry.io/",
"project": "react-native",
"organization": "wednesday-solutions-5p"
}
]
]
}
}
4 changes: 3 additions & 1 deletion app/config/index.dev.js
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/`
};
4 changes: 3 additions & 1 deletion app/config/index.js
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
};
4 changes: 3 additions & 1 deletion app/config/index.production.js
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/`
};
64 changes: 64 additions & 0 deletions app/utils/growthbook.js
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);
}
}

/**
* 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);
}
}
11 changes: 11 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ module.exports = function(api = { cache: () => {} }) {
'@utils': './app/utils'
}
}
],
[
'module:react-native-dotenv',
{
moduleName: '@env',
path: '.env',
blacklist: null,
whitelist: null,
safe: false,
allowUndefined: true
}
]
]
};
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ SPEC CHECKSUMS:
RNReanimated: 8a4d86eb951a4a99d8e86266dc71d7735c0c30a9
RNScreens: b6b64d956af3715adbfe84808694ae82d3fec74f
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 805bf71192903b20fc14babe48080582fee65a80
Yoga: d17d2cc8105eed528474683b42e2ea310e1daf61

PODFILE CHECKSUM: 71a7eba1109c7de188217c03cf1824ab1d487aec

Expand Down
17 changes: 16 additions & 1 deletion ios/reactnativetemplatews.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
800E24972A6A228C8D4807E9 /* [CP] Copy Pods Resources */,
599D80DE15B63C654B8D3C08 /* [CP] Embed Pods Frameworks */,
598EDDAFCB7E43A189BDFC8C /* Upload Debug Symbols to Sentry */,
);
buildRules = (
);
Expand Down Expand Up @@ -219,7 +220,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\n source \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n# The project root by default is one level up from the ios directory\nexport PROJECT_ROOT=\"$PROJECT_DIR\"/..\n\nif [[ \"$CONFIGURATION\" = *Debug* ]]; then\n export SKIP_BUNDLING=1\nfi\nif [[ -z \"$ENTRY_FILE\" ]]; then\n # Set the entry JS file using the bundler's entry resolution.\n export ENTRY_FILE=\"$(\"$NODE_BINARY\" -e \"require('expo/scripts/resolveAppEntry')\" \"$PROJECT_ROOT\" ios relative | tail -n 1)\"\nfi\n\nif [[ -z \"$CLI_PATH\" ]]; then\n # Use Expo CLI\n export CLI_PATH=\"$(\"$NODE_BINARY\" --print \"require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })\")\"\nfi\nif [[ -z \"$BUNDLE_COMMAND\" ]]; then\n # Default Expo CLI command for bundling\n export BUNDLE_COMMAND=\"export:embed\"\nfi\n\n# Source .xcode.env.updates if it exists to allow\n# SKIP_BUNDLING to be unset if needed\nif [[ -f \"$PODS_ROOT/../.xcode.env.updates\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.updates\"\nfi\n# Source local changes to allow overrides\n# if needed\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"`\n\n";
shellScript = "if [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\n source \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n# The project root by default is one level up from the ios directory\nexport PROJECT_ROOT=\"$PROJECT_DIR\"/..\n\nif [[ \"$CONFIGURATION\" = *Debug* ]]; then\n export SKIP_BUNDLING=1\nfi\nif [[ -z \"$ENTRY_FILE\" ]]; then\n # Set the entry JS file using the bundler's entry resolution.\n export ENTRY_FILE=\"$(\"$NODE_BINARY\" -e \"require('expo/scripts/resolveAppEntry')\" \"$PROJECT_ROOT\" ios relative | tail -n 1)\"\nfi\n\nif [[ -z \"$CLI_PATH\" ]]; then\n # Use Expo CLI\n export CLI_PATH=\"$(\"$NODE_BINARY\" --print \"require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })\")\"\nfi\nif [[ -z \"$BUNDLE_COMMAND\" ]]; then\n # Default Expo CLI command for bundling\n export BUNDLE_COMMAND=\"export:embed\"\nfi\n\n# Source .xcode.env.updates if it exists to allow\n# SKIP_BUNDLING to be unset if needed\nif [[ -f \"$PODS_ROOT/../.xcode.env.updates\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.updates\"\nfi\n# Source local changes to allow overrides\n# if needed\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\n source \"$PODS_ROOT/../.xcode.env.local\"\nfi\n\n/bin/sh `\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\"` `\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"`\n\n";
};
08A4A3CD28434E44B6B9DE2E /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -306,6 +307,20 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-reactnativetemplatews/Pods-reactnativetemplatews-resources.sh\"\n";
showEnvVarsInLog = 0;
};
598EDDAFCB7E43A189BDFC8C /* Upload Debug Symbols to Sentry */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
name = "Upload Debug Symbols to Sentry";
inputPaths = (
);
outputPaths = (
);
shellPath = /bin/sh;
shellScript = "/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
7 changes: 7 additions & 0 deletions ios/sentry.properties
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/
4 changes: 2 additions & 2 deletions metro.config.js
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);
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
"dependencies": {
"@babel/polyfill": "7.12.1",
"@expo/webpack-config": "~19.0.1",
"@growthbook/growthbook": "^1.2.0",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/masked-view": "^0.1.11",
"@react-native/metro-config": "^0.75.0-main",
"@react-navigation/compat": "^5.3.15",
"@react-navigation/native": "^6.1.17",
"@react-navigation/stack": "^6.3.29",
"@sentry/react-native": "^5.30.0",
"apisauce": "^3.0.1",
"axios-mock-adapter": "^1.17.0",
"babel-plugin-module-resolver": "^5.0.0",
Expand Down Expand Up @@ -137,6 +139,7 @@
"prettier-eslint": "^9.0.0",
"prettier-standard": "^15.0.1",
"pretty-quick": "^1.11.1",
"react-native-dotenv": "^3.4.11",
"react-native-rename": "^3.2.14",
"react-test-renderer": "^18.2.0"
},
Expand Down
Loading

0 comments on commit fd68baf

Please sign in to comment.