Skip to content
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

Expose deviceIdentifier #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Allowed the wrapper to expose the device identifier generated by bugf…
…ender as well as

  introduced typescript type definitions.
  • Loading branch information
Rodrigo Landaeta committed Aug 7, 2018
commit d062e3e5c4665529c410645ca3843fb3d7c68461
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