Skip to content

Commit 0586b00

Browse files
author
Fran Montiel
authored
Merge pull request #42 from bugfender/feature/setForceEnabled
Add setForceEnabled
2 parents 0f69b8c + 1bf3cc8 commit 0586b00

10 files changed

Lines changed: 62 additions & 43 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Bugfender.init({
7575
// logUIEvents: true,
7676
// registerErrorHandler: true,
7777
// deviceName: 'Anonymous',
78+
// maximumLocalStorageSize: 5 * 1024 * 1024, // Native specific
7879
// enableLogcatLogging: false, // Android specific
7980
// logBrowserEvents: true, // Web specific
8081
// build: '42', // Web specific

android/src/main/java/com/bugfender/react/RnBugfenderModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public void setForceEnabled(boolean value) {
6060
}
6161

6262
@ReactMethod
63-
public void setMaximumLocalStorageSize(Integer sizeInMB) {
64-
Bugfender.setMaximumLocalStorageSize(sizeInMB * 1024);
63+
public void setMaximumLocalStorageSize(Integer sizeInBytes) {
64+
Bugfender.setMaximumLocalStorageSize(sizeInBytes);
6565
}
6666

6767
@ReactMethod

example/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,10 @@ EXTERNAL SOURCES:
374374
SPEC CHECKSUMS:
375375
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
376376
BugfenderSDK: 210724a09aa05c9f6cdaea17af0fbbc2527a654d
377-
DoubleConversion: cde416483dac037923206447da6e1454df403714
377+
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
378378
FBLazyVector: 7b423f9e248eae65987838148c36eec1dbfe0b53
379-
FBReactNativeSpec: 6d79716602cbbf6e26cf9d2fd7ee8dedb15522ec
380-
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
379+
FBReactNativeSpec: 8b93999d104bfe2ee74eb6567e11e83dbd7e18bd
380+
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
381381
RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c
382382
RCTRequired: ec2ebc96b7bfba3ca5c32740f5a0c6a014a274d2
383383
RCTTypeSafety: 22567f31e67c3e088c7ac23ea46ab6d4779c0ea5
@@ -406,4 +406,4 @@ SPEC CHECKSUMS:
406406

407407
PODFILE CHECKSUM: bcb81b7a6d26c223b78881832d715df7e9686ab5
408408

409-
COCOAPODS: 1.11.2
409+
COCOAPODS: 1.11.3

example/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
2-
const blacklist = require('metro-config/src/defaults/blacklist');
2+
const blacklist = require('metro-config/src/defaults/exclusionList');
33
const escape = require('escape-string-regexp');
44
const pak = require('../package.json');
55

example/src/App.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22

3-
import { Button, Linking, StyleSheet, Text, View } from 'react-native';
4-
import { Bugfender, LogLevel, SDKOptionsBuilder } from '@bugfender/rn-bugfender';
3+
import {Button, Linking, StyleSheet, Text, View} from 'react-native';
4+
import {Bugfender, LogLevel, SDKOptionsBuilder} from '@bugfender/rn-bugfender';
55

66
export default function App() {
77

@@ -27,6 +27,7 @@ export default function App() {
2727
logBrowserEvents: true,
2828
})
2929
.native({
30+
maximumLocalStorageSize: 1024 * 1024,
3031
enableLogcatLogging: false,
3132
})
3233
.build()
@@ -94,7 +95,8 @@ export default function App() {
9495
throw new Error('Force crash' + 'Time: ' + hours + ':' + min + ':' + sec);
9596
}
9697

97-
function _onPressButton(): void {
98+
async function _onPressButton(): Promise<void> {
99+
98100
Bugfender.sendLog({
99101
level: LogLevel.Debug,
100102
tag: 'REACT',
@@ -196,6 +198,10 @@ export default function App() {
196198
Bugfender.getSessionURL().then((url) => console.log('Session url: %s', url));
197199

198200
Bugfender.forceSendOnce();
201+
202+
Bugfender.setForceEnabled(true);
203+
204+
Bugfender.setForceEnabled(false);
199205
}
200206

201207
function _onPressShowUserFeedback(): void {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
]
154154
},
155155
"dependencies": {
156-
"@bugfender/sdk": "^2.0.0",
156+
"@bugfender/sdk": "^2.1.0",
157157
"util": "^0.12.4"
158158
}
159159
}

src/bugfender.ts

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { NativeModules, Platform } from 'react-native';
2-
import type { ISDKOptions } from './types/sdk-options';
3-
import type { UserFeedbackOptions, UserFeedbackResult } from './user-feedback';
4-
import { DefaultUserFeedbackOptions } from './user-feedback';
5-
import type { DeviceKeyValue } from './types/device';
6-
import type { ILogEntry } from './types/log';
7-
import { StringFormatter } from './string-formatter';
8-
import { LogLevel } from "./types/log";
9-
import { OverrideConsoleMethods } from "./override-console-methods";
10-
import { PrintToConsole } from "./print-to-console";
11-
import { SDKOptions } from "./sdk-options";
1+
import {NativeModules, Platform} from 'react-native';
2+
import type {ISDKOptions} from './types/sdk-options';
3+
import type {UserFeedbackOptions, UserFeedbackResult} from './user-feedback';
4+
import {DefaultUserFeedbackOptions} from './user-feedback';
5+
import type {DeviceKeyValue} from './types/device';
6+
import type {ILogEntry} from './types/log';
7+
import {StringFormatter} from './string-formatter';
8+
import {LogLevel} from "./types/log";
9+
import {OverrideConsoleMethods} from "./override-console-methods";
10+
import {PrintToConsole} from "./print-to-console";
11+
import {SDKOptions} from "./sdk-options";
1212

1313
const LINKING_ERROR =
1414
`The package '@bugfender/rn-bugfender' doesn't seem to be linked. Make sure: \n\n` +
15-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
15+
Platform.select({ios: "- You have run 'pod install'\n", default: ''}) +
1616
'- You rebuilt the app after installing the package\n' +
1717
'- You are not using Expo managed workflow\n';
1818

@@ -38,41 +38,44 @@ class BugfenderClass {
3838
if (!this.initialized) {
3939
const validatedOptions = this.sdkOptions.init(options);
4040

41-
// Needs to be executed prior initialization
41+
// region before init
4242
if (typeof options.deviceName !== 'undefined') {
4343
RnBugfender.overrideDeviceName(options.deviceName);
4444
}
45-
46-
// Library initialization
47-
Platform.OS === 'ios'
48-
? RnBugfender.activateLogger(validatedOptions.appKey)
49-
: RnBugfender.init(validatedOptions.appKey, false);
50-
5145
if (typeof validatedOptions.apiURL !== 'undefined') {
5246
RnBugfender.setApiUrl(validatedOptions.apiURL);
5347
}
54-
5548
if (typeof validatedOptions.baseURL !== 'undefined') {
5649
RnBugfender.setBaseUrl(validatedOptions.baseURL);
5750
}
51+
// endregion before init
5852

53+
// region init
54+
Platform.OS === 'ios'
55+
? RnBugfender.activateLogger(validatedOptions.appKey)
56+
: RnBugfender.init(validatedOptions.appKey, validatedOptions.printToConsole ?? false);
57+
58+
if (validatedOptions.overrideConsoleMethods) {
59+
this.overrideConsoleMethods.init(this.stringFormatter);
60+
}
61+
62+
this.printToConsole.init(validatedOptions.printToConsole ?? true);
63+
// endregion init
64+
65+
// region after init
5966
if (validatedOptions.enableLogcatLogging) {
6067
RnBugfender.enableLogcatLogging();
6168
}
62-
6369
if (validatedOptions.logUIEvents) {
6470
RnBugfender.enableUIEventLogging();
6571
}
66-
6772
if (validatedOptions.registerErrorHandler) {
6873
RnBugfender.enableCrashReporting();
6974
}
70-
71-
if (validatedOptions.overrideConsoleMethods) {
72-
this.overrideConsoleMethods.init(this.stringFormatter);
73-
}
74-
75-
this.printToConsole.init(validatedOptions.printToConsole ?? true);
75+
RnBugfender.setMaximumLocalStorageSize(
76+
validatedOptions.maximumLocalStorageSize
77+
);
78+
// endregion after init
7679

7780
this.initialized = true;
7881
}
@@ -353,6 +356,11 @@ class BugfenderClass {
353356
this.printToConsole.info(`Force send once`);
354357
RnBugfender.forceSendOnce();
355358
}
359+
360+
public setForceEnabled(enabled: boolean): void {
361+
this.printToConsole.info(`Set force enabled set to ${enabled}`);
362+
RnBugfender.setForceEnabled(enabled);
363+
}
356364
}
357365

358366
export {

src/sdk-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class SDKOptions {
2828
logUIEvents: true,
2929
registerErrorHandler: true,
3030
enableLogcatLogging: false,
31+
maximumLocalStorageSize: 5 * 1024 * 1024,
3132
...options,
3233
};
3334
}

src/types/sdk-options.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface ISDKWebOptions {
2929
}
3030

3131
export interface ISDKNativeOptions {
32+
/** Set the maximum size to store local log files in bytes (Native specific). Range accepted is from 1 MB to 50 MB. Defaults to 5 MB. **/
33+
maximumLocalStorageSize?: number;
3234
/** Logs all logs written via Logcat (Android specific). Defaults to `false`. */
3335
enableLogcatLogging?: boolean;
3436
}
@@ -68,6 +70,7 @@ export class SDKOptionsBuilder {
6870
build: this.webOptions?.build,
6971
version: this.webOptions?.version,
7072
enableLogcatLogging: this.nativeOptions?.enableLogcatLogging,
73+
maximumLocalStorageSize: this.nativeOptions?.maximumLocalStorageSize,
7174
};
7275

7376
removeUndefinedAttributes(options);

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,10 +1073,10 @@
10731073
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
10741074
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
10751075

1076-
"@bugfender/sdk@^2.0.0":
1077-
version "2.0.0"
1078-
resolved "https://registry.yarnpkg.com/@bugfender/sdk/-/sdk-2.0.0.tgz#820bb1e8712ae8eb365d9638a222de87b006d9e4"
1079-
integrity sha512-JNf4QGkciXjvx5CU0PXyEXu5Z5c7AE5U4NyC9fFaDokwXkzI9gZT5kDMkCQgKD7OXh9QwqjUNBUsQZNBBoaXEw==
1076+
"@bugfender/sdk@^2.1.0":
1077+
version "2.1.0"
1078+
resolved "https://registry.yarnpkg.com/@bugfender/sdk/-/sdk-2.1.0.tgz#7447e14aaff15a6ea350b83428c2625afcaaa91b"
1079+
integrity sha512-IzixkqA/ltA4A/GmLNGeLcFKJwZmrwC9s3Q0K+DjUMoD1Eb6OXB8f3vVWAIVnbfP0zYWtxCbtMb77IFfyBXNvQ==
10801080
dependencies:
10811081
base-58 "0.0.1"
10821082
bowser "^2.11.0"

0 commit comments

Comments
 (0)