Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <BugfenderSDK/BugfenderSDK.h>
```

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
{
...
Expand All @@ -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
Expand Down Expand Up @@ -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();
```
2 changes: 2 additions & 0 deletions RNBugfender.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"$(PROJECT_DIR)",
"$(SRCDIR)/../../ios/Pods/BugfenderSDK",
"$(SRCDIR)/../../ios/Frameworks",
"$(PROJECT_DIR)/../../ios/Frameworks",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -251,6 +252,7 @@
"$(PROJECT_DIR)",
"$(SRCDIR)/../../ios/Pods/BugfenderSDK",
"$(SRCDIR)/../../ios/Frameworks",
"$(PROJECT_DIR)/../../ios/Frameworks",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
7 changes: 7 additions & 0 deletions RNBugfender/RNBugfender.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
14 changes: 13 additions & 1 deletion bugfender.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -98,5 +109,6 @@ export default {
enableUIEventLogging,
setMaximumLocalStorageSize,
forceSendOnce,
setForceEnabled
setForceEnabled,
deviceIdentifier
}
76 changes: 76 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"peerDependencies": {
"react-native": ">=0.27.2"
},
"types": "./index.d.ts",
"rnpm": {
"android": {
"sourceDir": "./android"
Expand Down