From 3ca3faaefb2fe1b4a3702ba7fe839d2f865b660d Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev Date: Wed, 20 Jun 2018 15:38:15 +0400 Subject: [PATCH 1/3] Fix: updated frameworks folders path. --- RNBugfender.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RNBugfender.xcodeproj/project.pbxproj b/RNBugfender.xcodeproj/project.pbxproj index 94db457..fa6e529 100644 --- a/RNBugfender.xcodeproj/project.pbxproj +++ b/RNBugfender.xcodeproj/project.pbxproj @@ -236,6 +236,7 @@ "$(PROJECT_DIR)", "$(SRCDIR)/../../ios/Pods/BugfenderSDK", "$(SRCDIR)/../../ios/Frameworks", + "$(PROJECT_DIR)/../../ios/Frameworks", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -251,6 +252,7 @@ "$(PROJECT_DIR)", "$(SRCDIR)/../../ios/Pods/BugfenderSDK", "$(SRCDIR)/../../ios/Frameworks", + "$(PROJECT_DIR)/../../ios/Frameworks", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; From d062e3e5c4665529c410645ca3843fb3d7c68461 Mon Sep 17 00:00:00 2001 From: Rodrigo Landaeta Date: Tue, 7 Aug 2018 10:04:34 +1000 Subject: [PATCH 2/3] Allowed the wrapper to expose the device identifier generated by bugfender as well as introduced typescript type definitions. --- RNBugfender/RNBugfender.m | 7 ++ .../galmis/rnbugfender/RNBugfenderModule.java | 6 ++ bugfender.js | 14 +++- index.d.ts | 76 +++++++++++++++++++ package.json | 1 + 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/RNBugfender/RNBugfender.m b/RNBugfender/RNBugfender.m index 2f75832..5db49ed 100644 --- a/RNBugfender/RNBugfender.m +++ b/RNBugfender/RNBugfender.m @@ -52,4 +52,11 @@ @implementation RNBugfender [Bugfender setForceEnabled: enabled]; } +RCT_REMAP_METHOD(deviceIdentifier, + resolver:(RCTPromiseResolveBlock)resolve + rejecter:(RCTPromiseRejectBlock)reject) { + NSString *identifier = [Bugfender deviceIdentifier]; + resolve(identifier); +} + @end diff --git a/android/src/main/java/com/galmis/rnbugfender/RNBugfenderModule.java b/android/src/main/java/com/galmis/rnbugfender/RNBugfenderModule.java index aa9e981..abd8a87 100644 --- a/android/src/main/java/com/galmis/rnbugfender/RNBugfenderModule.java +++ b/android/src/main/java/com/galmis/rnbugfender/RNBugfenderModule.java @@ -2,6 +2,7 @@ import com.bugfender.sdk.Bugfender; import com.facebook.react.*; +import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; @@ -70,4 +71,9 @@ public void forceSendOnce(){ public void setForceEnabled(boolean value){ Bugfender.setForceEnabled(value); } + + @ReactMethod + public void deviceIdentifier(Promise promise) { + promise.resolve(Bugfender.getDeviceIdentifier()); + } } diff --git a/bugfender.js b/bugfender.js index d70b4dc..941e397 100644 --- a/bugfender.js +++ b/bugfender.js @@ -89,6 +89,17 @@ function setForceEnabled(enabled) { RNBugfender.setForceEnabled(enabled); } +/** + * Returns the device identifier used to identify the current device in the Bugfender website. + * This string can not be changed, but can be shown to the user or sent to your server, in order to keep a relationship between a Bugfender device and a user or some other important event in your application. + * + * The device identifier is constant while the application is installed in the device. + * @returns a promise with the device identifier generated by bugfender. + */ +function deviceIdentifier() { + return RNBugfender.deviceIdentifier(); +} + export default { activateLogger, info, @@ -98,5 +109,6 @@ export default { enableUIEventLogging, setMaximumLocalStorageSize, forceSendOnce, - setForceEnabled + setForceEnabled, + deviceIdentifier } diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..4a5c127 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,76 @@ +declare module "react-native-bugfender" { + /** + * Activates the Bugfender for a specific app. + * @param appToken The app token of the Bugfender application + * @param debug Android only . Indicates whether Bugfender needs to be displayed in Logcat + * @discussion This method needs to be called before any BFLog call, otherwise the `BFInvalidMethodCallException` exception will be thrown. + * @throws `NSInvalidArgumentException` if Bugfender has already been initialized + with a different app token. + **/ + export function activateLogger(key: string, debug?: boolean): void; + + /** + * BFLog(...): Default log. + **/ + export function info(key: string): void; + /** + * BFLogWarn(...): Warning log. + **/ + export function warning(key: string): void; + /** + * BFLogErr(...): Error log. + **/ + export function error(key: string): void; + /** + * Sends an issue + * @discussion Sending an issue forces the logs of the current session being sent + * to the server, and marks the session so that it is highlighted in the web console. + * @param title Short description of the issue. + * @param text Full details of the issue. Markdown format is accepted. + */ + + export function sendIssueWithTitle(key: string, text: string): void; + + /** + * Logs all actions performed and screen changes in the application, such as button touches, swipes and gestures. + */ + export function enableUIEventLogging(): void; + + /** + * Set the maximum space availalbe to store local logs. This value is represented in bytes. There's a limit of 50 MB. + **/ + export function maxLocalStorageSize(maxLocalStorageSize: number): void; + + /** + * Synchronizes all logs with the server once, regardless if this device is enabled or not. + * @discussion This method is useful when an error condition is detected and the logs should be sent to + * the server for analysis, regardless if the device is enabled in the Bugfender Console. + * + * Logs are synchronized only once. After that, the logs are again sent according to the enabled flag + * in the Bugfender Console. + * + * This command can be called anytime, and will take effect the next time the device is online. + */ + export function forceSendOnce(): void; + + /** + * Synchronizes all logs with the server all the time, regardless if this device is enabled or not. + * @discussion This method is useful when the logs should be sent to the server + * regardless if the device is enabled in the Bugfender Console. + * + * Logs are synchronized continuously while forceEnabled is active. + * + * This command can be called anytime, and will take effect the next time the device is online. + * @param enabled Whether logs should be sent regardless of the Bugfender Console settings. + */ + export function setForceEnabled(enabled: boolean): void; + + /** + * Returns the device identifier used to identify the current device in the Bugfender website. + * This string can not be changed, but can be shown to the user or sent to your server, in order to keep a relationship between a Bugfender device and a user or some other important event in your application. + * + * The device identifier is constant while the application is installed in the device. + * @returns a promise with the device identifier generated by bugfender. + */ + export function deviceIdentifier(): Promise; +} diff --git a/package.json b/package.json index bf40f81..998dc16 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "peerDependencies": { "react-native": ">=0.27.2" }, + "types": "./index.d.ts", "rnpm": { "android": { "sourceDir": "./android" From bba1b2beca2a05347ff809ecfe49efb40d2a3002 Mon Sep 17 00:00:00 2001 From: Rodrigo Landaeta Date: Tue, 7 Aug 2018 12:35:41 +1000 Subject: [PATCH 3/3] Extended the documentation to include deviceInformation and gave it a bit of format. --- README.md | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 14bec40..c430c53 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,35 @@ # react-native-bugfender -A wrapper around BugfenderSDK-iOS, bugfender docs https://github.com/bugfender/BugfenderSDK-iOS, +A wrapper around BugfenderSDK -sign up https://app.bugfender.com/signup?coupon-code=Q1UG5INPSD +Bugfender [iOS docs](https://github.com/bugfender/BugfenderSDK-iOS) or [Android docs](https://github.com/bugfender/BugfenderSDK-android-sample). -## Set up: +Sign up [here](https://app.bugfender.com/signup) -1. rnpm install react-native-bugfender +## Set up (iOS): -2. git clone https://github.com/bugfender/BugfenderSDK-iOS.git or just download the BugfenderSDK-iOS from https://github.com/bugfender/BugfenderSDK-iOS +1. Either `npm i react-native-bugfender` or `yarn add react-native-bugfender` -3. Drag BugfenderSDK.framework to react-native-bugfender folder. In most cases, it would be YOUR_PROJECT/node_modules/react-native-bugfender +2. Clone the bugfender sdk: `git clone https://github.com/bugfender/BugfenderSDK-iOS.git` or just download it from [BugfenderSDK-iOS](https://github.com/bugfender/BugfenderSDK-iOS) -4. Go to your Project > Your Target > General > Linked Frameworks and Libraries and either drag BugfenderSDK.framework there or press + >>> press Add Other... >>> select BugfenderSDK.framework from YOUR_PROJECT/node_modules/react-native-bugfender. Make sure you have SystemConfiguration.framework and MobileCoreServices.framework there as well. +3. Create a `Frameworks` folder in your `ios` project. -5. Go to Build Settings and search for "framework search path". Add the following item to it (select recursive): -$(PROJECT_DIR)/../node_modules/react-native-bugfender [recursive] +4. Drag `BugfenderSDK.framework` to the `Frameworks` folder. + +5. Go to your Project > Your Target > General > Linked Frameworks and Libraries and either drag `BugfenderSDK.framework` there or press + >>> press Add Other... >>> select BugfenderSDK.framework from `YOUR_PROJECT/ios/Frameworks`. Make sure you have `SystemConfiguration.framework` and `MobileCoreServices.framework` there as well. + +6. Go to Build Settings and search for "framework search path". Add the following item to it (select recursive): +`$(PROJECT_DIR)/../Frameworks` [recursive] 6. Make Bugfender available project-wide by adding the following line to the `.pch` file: -```objective-c +```objc #import ``` Get an API key from the [Bugfender console](https://app.bugfender.com/). In your `AppDelegate` call [activateLogger](http://cocoadocs.org/docsets/BugfenderSDK/0.3.9/Classes/Bugfender.html#//api/name/activateLogger:) when the application starts, like this: -```objective-c +```objc - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... @@ -35,14 +39,16 @@ Get an API key from the [Bugfender console](https://app.bugfender.com/). In your } ``` +## Setup (android) -## Usage: +Follow the instructions provided [here]( +https://github.com/bugfender/BugfenderSDK-android-sample) +## Usage: -```Javascript +```js import Bugfender from 'react-native-bugfender'; - /** * Activates the Bugfender for a specific app. * @param appToken The app token of the Bugfender application @@ -112,4 +118,11 @@ Bugfender.forceSendOnce(); * @param enabled Whether logs should be sent regardless of the Bugfender Console settings. */ Bugfender.setForceEnabled(enabled); + +/** + * Gets the bugfender device unique identifier + * @returns a promise with the device identifier + **/ + +let deviceId = await Bugfender.deviceIdentifier(); ```