Skip to content

Commit

Permalink
setup crashlytics and toast for login errors
Browse files Browse the repository at this point in the history
  • Loading branch information
EtainLove committed Apr 17, 2021
1 parent f27445a commit d7af21d
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 10 deletions.
4 changes: 4 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: "com.android.application"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

import com.android.build.OutputFile

Expand Down Expand Up @@ -191,6 +192,9 @@ android {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
// firebaseCrashlytics {
// nativeSymbolUploadEnabled true
// }
}
}

Expand Down
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ buildscript {
dependencies {
classpath("com.android.tools.build:gradle:3.5.4")
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
15 changes: 15 additions & 0 deletions ios/PlaySteem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
8E38035A67EEEA1497A5F7DF /* [CP] Copy Pods Resources */,
A0250C0193C9428824F696EB /* [CP-User] [RNFB] Core Configuration */,
1C0244CB449E6D88F13379CD /* [CP-User] [RNFB] Crashlytics Configuration */,
);
buildRules = (
);
Expand Down Expand Up @@ -413,6 +414,20 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
1C0244CB449E6D88F13379CD /* [CP-User] [RNFB] Crashlytics Configuration */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}",
"$(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)",
);
name = "[CP-User] [RNFB] Crashlytics Configuration";
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/usr/bin/env bash\n#\n# Copyright (c) 2016-present Invertase Limited & Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this library except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nset -e\n\nif [[ ${PODS_ROOT} ]]; then\n echo \"info: Exec FirebaseCrashlytics Run from Pods\"\n \"${PODS_ROOT}/FirebaseCrashlytics/run\"\nelse\n echo \"info: Exec FirebaseCrashlytics Run from framework\"\n \"${PROJECT_DIR}/FirebaseCrashlytics.framework/run\"\nfi\n";
};
2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
19 changes: 19 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ PODS:
- FirebaseAuth (~> 6.9.2)
- Firebase/CoreOnly (6.34.0):
- FirebaseCore (= 6.10.4)
- Firebase/Crashlytics (6.34.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 4.6.2)
- Firebase/Firestore (6.34.0):
- Firebase/CoreOnly
- FirebaseFirestore (~> 1.19.0)
Expand All @@ -266,6 +269,12 @@ PODS:
- GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/Logger (~> 6.7)
- nanopb (~> 1.30906.0)
- FirebaseCrashlytics (4.6.2):
- FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.6)
- GoogleDataTransport (~> 7.2)
- nanopb (~> 1.30906.0)
- PromisesObjC (~> 1.2)
- FirebaseFirestore (1.19.0):
- abseil/algorithm (= 0.20200225.0)
- abseil/base (= 0.20200225.0)
Expand Down Expand Up @@ -673,6 +682,10 @@ PODS:
- Firebase/Auth (~> 6.34.0)
- React-Core
- RNFBApp
- RNFBCrashlytics (11.3.0):
- Firebase/Crashlytics (~> 6.34.0)
- React-Core
- RNFBApp
- RNFBFirestore (7.10.3):
- Firebase/Firestore (~> 6.34.0)
- React-Core
Expand Down Expand Up @@ -778,6 +791,7 @@ DEPENDENCIES:
- "RNDateTimePicker (from `../node_modules/@react-native-community/datetimepicker`)"
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
- "RNFBAuth (from `../node_modules/@react-native-firebase/auth`)"
- "RNFBCrashlytics (from `../node_modules/@react-native-firebase/crashlytics`)"
- "RNFBFirestore (from `../node_modules/@react-native-firebase/firestore`)"
- "RNFBFunctions (from `../node_modules/@react-native-firebase/functions`)"
- "RNFBMessaging (from `../node_modules/@react-native-firebase/messaging`)"
Expand All @@ -803,6 +817,7 @@ SPEC REPOS:
- FirebaseAuth
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseCrashlytics
- FirebaseFirestore
- FirebaseFunctions
- FirebaseInstallations
Expand Down Expand Up @@ -915,6 +930,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-firebase/app"
RNFBAuth:
:path: "../node_modules/@react-native-firebase/auth"
RNFBCrashlytics:
:path: "../node_modules/@react-native-firebase/crashlytics"
RNFBFirestore:
:path: "../node_modules/@react-native-firebase/firestore"
RNFBFunctions:
Expand Down Expand Up @@ -956,6 +973,7 @@ SPEC CHECKSUMS:
FirebaseAuth: c92d49ada7948d1a23466e3db17bc4c2039dddc3
FirebaseCore: d3a978a3cfa3240bf7e4ba7d137fdf5b22b628ec
FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1
FirebaseCrashlytics: 1a747c9cc084a24dc6d9511c991db1cd078154eb
FirebaseFirestore: 9b2f1b9b9a6f2f0b6fb7484b9e32ab7e39243554
FirebaseFunctions: 27518fdd14d8b3a849e2443f921cd1b471ab7acd
FirebaseInstallations: 466c7b4d1f58fe16707693091da253726a731ed2
Expand Down Expand Up @@ -1016,6 +1034,7 @@ SPEC CHECKSUMS:
RNDateTimePicker: 8a51a2216c307769e69ef827293d59549ab1ca23
RNFBApp: 804b98033f45c3a3e35b56de8c894f85ef5e4388
RNFBAuth: 8c4de7a59b563bd399993855aa61183e1f1be4bf
RNFBCrashlytics: 7365281039b8952ff1c8e9ff4e412abab9baec0b
RNFBFirestore: e21f4bcd634430775adca413a93ab995a34f743e
RNFBFunctions: b8b7aa8fa523df3c1f0bf7fce8aa74c5de5cd634
RNFBMessaging: 9287cbf850ed3524c9f915f5b3daaf1cfaabbf06
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@react-native-community/slider": "^3.0.3",
"@react-native-firebase/app": "^8.4.1",
"@react-native-firebase/auth": "^9.2.1",
"@react-native-firebase/crashlytics": "^11.3.0",
"@react-native-firebase/firestore": "^7.8.0",
"@react-native-firebase/functions": "^10.3.1",
"@react-native-firebase/messaging": "^7.8.4",
Expand Down
4 changes: 2 additions & 2 deletions src/constants/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const APP_ANDROID_VERSION = '0.9.7';
export const APP_ANDROID_VERSION = '0.9.8';
export const GOOGLEPLAY = '';
export const APP_IOS_VERSION = '0.9.7';
export const APP_IOS_VERSION = '0.9.8';
export const APPSTORE = '';
export const SOURCE_URL = 'https://github.com/EtainClub/playsteem';
export const TERMS_URL = 'https://playsteem.app/terms';
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
"button": "Consent and Login",
"signup_guide": "Create an account",
"login_error": "username or password is not correct",
"firebase_auth_error": "failed to signin firebase. {what}",
"firebase_create_doc_error": "failed to create doc on firebase. {what}",
"firebase_get_user_error": "failed to get user document. {what}",
"firebase_get_push_error": "failed to get push token. {what}",
"msg_username": "username does not exist",
"msg_password": "password is not valid",
"otp_error": "Code is not correct",
Expand Down
4 changes: 4 additions & 0 deletions src/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
"button": "동의하고 로그인",
"signup_guide": "계정 생성 하기",
"login_error": "계정이름이나 암호가 유효하지 않습니다.",
"firebase_auth_error": "Firebase 로그인 실패. {what}",
"firebase_create_doc_error": "Firebase doc 생성 실패. {what}",
"firebase_get_user_error": "Firebase 사용자 doc 가져오기 실패. {what}",
"firebase_get_push_error": "Firebase 푸시 토큰 가져오기 실패. {what}",
"msg_username": "존재하지 않는 계정이름입니다.",
"msg_password": "유효하지 않는 암호(키)입니다",
"otp_error": "인증코드 입력 에러",
Expand Down
2 changes: 1 addition & 1 deletion src/providers/steem/dsteemApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ export const fetchPostsSummary = async (
limit: limit,
start_permlink: startPostRef.permlink || undefined,
start_author: startPostRef.author || undefined,
truncate_body: TRUNCATE_BODY_LENGTH,
truncate_body: TRUNCATE_BODY_LENGTH, // @todo what if no trucate?
};

try {
Expand Down
47 changes: 40 additions & 7 deletions src/screens/login/container/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,22 @@ const Login = (props: Props): JSX.Element => {
await auth()
.signInAnonymously()
.then((result) => console.log('signed in firebase', result))
.catch((error) => console.log('failed to sign in firebase', error));
// create or update user db
_updateUserDB(username);
.catch((error) => {
setToastMessage(
intl.formatMessage({id: 'Login.firebase_auth_error'}, {what: error}),
);
console.log('failed to sign in firebase', error);
setLoading(false);
return;
});

try {
// create or update user db
_updateUserDB(username);
} catch (error) {
setLoading(false);
return;
}

//// fetch user data
// update followings which is required in fetching feed
Expand Down Expand Up @@ -155,9 +168,15 @@ const Login = (props: Props): JSX.Element => {
locale: settingsState.languages.locale,
})
.then(() => console.log('created user document'))
.catch((error) =>
console.log('failed to create a user document', error),
);
.catch((error) => {
setToastMessage(
intl.formatMessage(
{id: 'Login.firebase_create_doc_error'},
{what: error},
),
);
console.log('failed to create a user document', error);
});
} else {
console.log('user doc exists, username', _username);
// update push token
Expand All @@ -168,10 +187,24 @@ const Login = (props: Props): JSX.Element => {
AsyncStorage.setItem(StorageSchema.LOGIN_TOKEN, _username);
})
.catch((error) => {
setToastMessage(
intl.formatMessage(
{id: 'Login.firebase_get_user_error'},
{what: error},
),
);
console.log('failed to get user document', error);
});
})
.catch((error) => console.log('failed to get push token', error));
.catch((error) => {
setToastMessage(
intl.formatMessage(
{id: 'Login.firebase_get_push_error'},
{what: error},
),
);
console.log('failed to get push token', error);
});
};

//// render
Expand Down
36 changes: 36 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,13 @@
resolved "https://registry.yarnpkg.com/@react-native-firebase/auth/-/auth-9.3.5.tgz#4bd14b575a4cc33828e0b2d35b9b2c9c6a52d1ca"
integrity sha512-Z3ik2CASWFJ4YaMbuAMHY1DyBugv6BetPrz796zUIoEjNuAPUFOtYgGGhIcfBVLlj2W099fWgZUD1aKaOdHbwg==

"@react-native-firebase/crashlytics@^11.3.0":
version "11.3.0"
resolved "https://registry.yarnpkg.com/@react-native-firebase/crashlytics/-/crashlytics-11.3.0.tgz#7b8aa3a4711f361aa7bb248ebe2b35bfc4aff3d2"
integrity sha512-r17ZHJAEjoUVlyItJDb1hMqbViomr79GummGrzwCqKdy26tl/kz5oQsAS2QHFBpsrRWPfIRe9diJdJcC4jzDWw==
dependencies:
stacktrace-js "^2.0.0"

"@react-native-firebase/firestore@^7.8.0":
version "7.10.3"
resolved "https://registry.yarnpkg.com/@react-native-firebase/firestore/-/firestore-7.10.3.tgz#2f318e4f757ec42f81a976b1de8a55ab1d01561d"
Expand Down Expand Up @@ -7945,6 +7952,11 @@ source-map-url@^0.4.0:
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56"
integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==

[email protected]:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
integrity sha1-dc449SvwczxafwwRjYEzSiu19BI=

source-map@^0.5.0, source-map@^0.5.6:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
Expand Down Expand Up @@ -8023,6 +8035,13 @@ sshpk@^1.7.0:
safer-buffer "^2.0.2"
tweetnacl "~0.14.0"

stack-generator@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/stack-generator/-/stack-generator-2.0.5.tgz#fb00e5b4ee97de603e0773ea78ce944d81596c36"
integrity sha512-/t1ebrbHkrLrDuNMdeAcsvynWgoH/i4o8EGGfX7dEYDoTXOYVAkEpFdtshlvabzc6JlJ8Kf9YdFEoz7JkzGN9Q==
dependencies:
stackframe "^1.1.1"

stack-utils@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.4.tgz#4b600971dcfc6aed0cbdf2a8268177cc916c87c8"
Expand All @@ -8035,6 +8054,23 @@ stackframe@^1.1.1:
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.2.0.tgz#52429492d63c62eb989804c11552e3d22e779303"
integrity sha512-GrdeshiRmS1YLMYgzF16olf2jJ/IzxXY9lhKOskuVziubpTYcYqyOwYeJKzQkwy7uN0fYSsbsC4RQaXf9LCrYA==

stacktrace-gps@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/stacktrace-gps/-/stacktrace-gps-3.0.4.tgz#7688dc2fc09ffb3a13165ebe0dbcaf41bcf0c69a"
integrity sha512-qIr8x41yZVSldqdqe6jciXEaSCKw1U8XTXpjDuy0ki/apyTn/r3w9hDAAQOhZdxvsC93H+WwwEu5cq5VemzYeg==
dependencies:
source-map "0.5.6"
stackframe "^1.1.1"

stacktrace-js@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/stacktrace-js/-/stacktrace-js-2.0.2.tgz#4ca93ea9f494752d55709a081d400fdaebee897b"
integrity sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg==
dependencies:
error-stack-parser "^2.0.6"
stack-generator "^2.0.5"
stacktrace-gps "^3.0.4"

stacktrace-parser@^0.1.3:
version "0.1.10"
resolved "https://registry.yarnpkg.com/stacktrace-parser/-/stacktrace-parser-0.1.10.tgz#29fb0cae4e0d0b85155879402857a1639eb6051a"
Expand Down

0 comments on commit d7af21d

Please sign in to comment.