@bugfender/rn-bugfender 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RnBugfender.podspec +15 -0
- package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +117 -40
- package/android/gradle.properties +5 -0
- package/android/src/main/java/com/{bugfender/react → bugfender.react}/RnBugfenderModule.java +0 -0
- package/android/src/main/java/com/{bugfender/react → bugfender.react}/RnBugfenderPackage.java +0 -0
- package/ios/{RnBugfender.m → RnBugfender.mm} +16 -4
- package/ios/RnBugfender.xcodeproj/project.pbxproj +4 -17
- package/lib/commonjs/bugfender.js +14 -26
- package/lib/commonjs/bugfender.js.map +1 -1
- package/lib/commonjs/index.js +2 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +2 -2
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/override-console-methods.js +9 -9
- package/lib/commonjs/override-console-methods.js.map +1 -1
- package/lib/commonjs/sdk-options.js +5 -34
- package/lib/commonjs/sdk-options.js.map +1 -1
- package/lib/commonjs/types/sdk-options.js +2 -2
- package/lib/commonjs/types/sdk-options.js.map +1 -1
- package/lib/commonjs/user-feedback.js.map +1 -1
- package/lib/module/bugfender.js +12 -22
- package/lib/module/bugfender.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/override-console-methods.js +9 -9
- package/lib/module/override-console-methods.js.map +1 -1
- package/lib/module/sdk-options.js +5 -34
- package/lib/module/sdk-options.js.map +1 -1
- package/lib/module/types/sdk-options.js +2 -2
- package/lib/module/types/sdk-options.js.map +1 -1
- package/lib/module/user-feedback.js.map +1 -1
- package/lib/typescript/bugfender.d.ts +4 -6
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.web.d.ts +1 -1
- package/lib/typescript/override-console-methods.d.ts +1 -2
- package/lib/typescript/sdk-options.d.ts +2 -12
- package/lib/typescript/user-feedback.d.ts +2 -15
- package/package.json +26 -22
- package/src/bugfender.ts +11 -16
- package/src/index.tsx +1 -1
- package/src/index.web.tsx +1 -1
- package/src/override-console-methods.ts +8 -9
- package/src/sdk-options.ts +6 -35
- package/src/types/sdk-options.ts +2 -2
- package/src/user-feedback.ts +3 -16
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/lib/commonjs/print-to-console.js +0 -78
- package/lib/commonjs/print-to-console.js.map +0 -1
- package/lib/commonjs/string-formatter.js +0 -55
- package/lib/commonjs/string-formatter.js.map +0 -1
- package/lib/commonjs/types/device.js +0 -2
- package/lib/commonjs/types/device.js.map +0 -1
- package/lib/commonjs/types/log.js +0 -35
- package/lib/commonjs/types/log.js.map +0 -1
- package/lib/commonjs/utilities.js +0 -18
- package/lib/commonjs/utilities.js.map +0 -1
- package/lib/module/print-to-console.js +0 -67
- package/lib/module/print-to-console.js.map +0 -1
- package/lib/module/string-formatter.js +0 -45
- package/lib/module/string-formatter.js.map +0 -1
- package/lib/module/types/device.js +0 -2
- package/lib/module/types/device.js.map +0 -1
- package/lib/module/types/log.js +0 -24
- package/lib/module/types/log.js.map +0 -1
- package/lib/module/utilities.js +0 -11
- package/lib/module/utilities.js.map +0 -1
- package/lib/typescript/print-to-console.d.ts +0 -14
- package/lib/typescript/string-formatter.d.ts +0 -4
- package/lib/typescript/types/device.d.ts +0 -4
- package/lib/typescript/types/log.d.ts +0 -59
- package/lib/typescript/utilities.d.ts +0 -1
- package/src/print-to-console.ts +0 -67
- package/src/string-formatter.ts +0 -44
- package/src/types/device.ts +0 -4
- package/src/types/log.ts +0 -75
- package/src/utilities.ts +0 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { prepareOptions, validate } from "@bugfender/common";
|
|
4
4
|
export class SDKOptions {
|
|
5
5
|
constructor() {
|
|
6
6
|
_defineProperty(this, "rules", {
|
|
@@ -17,11 +17,10 @@ export class SDKOptions {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
init(options) {
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
removeUndefinedAttributes(options); // Set default values if needed
|
|
20
|
+
// Prepare options
|
|
21
|
+
options = prepareOptions(options); // Validate user provided options
|
|
22
|
+
|
|
23
|
+
validate(options, this.rules); // Set default values if needed
|
|
25
24
|
|
|
26
25
|
return {
|
|
27
26
|
overrideConsoleMethods: true,
|
|
@@ -34,33 +33,5 @@ export class SDKOptions {
|
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
validate(options) {
|
|
38
|
-
const urlValidator = new RegExp(/^http(s)?:\/\//i);
|
|
39
|
-
Object.entries(this.rules).forEach(_ref => {
|
|
40
|
-
let [key, rules] = _ref;
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
const value = options[key];
|
|
43
|
-
rules.forEach(rule => {
|
|
44
|
-
if (rule === 'required') {
|
|
45
|
-
if (typeof value === 'undefined') {
|
|
46
|
-
throw new Error(`Bugfender requires '${key}' option to initialize.`);
|
|
47
|
-
}
|
|
48
|
-
} else if (rule === 'string') {
|
|
49
|
-
if (!['string', 'undefined'].includes(typeof value)) {
|
|
50
|
-
throw new Error(`'${key}' option must be a string.`);
|
|
51
|
-
}
|
|
52
|
-
} else if (rule === 'url') {
|
|
53
|
-
if (typeof value !== 'undefined' && !urlValidator.test(value)) {
|
|
54
|
-
throw new Error(`'${key}' option must be a valid URL.`);
|
|
55
|
-
}
|
|
56
|
-
} else if (rule === 'boolean') {
|
|
57
|
-
if (!['boolean', 'undefined'].includes(typeof value)) {
|
|
58
|
-
throw new Error(`'${key}' option must be a boolean.`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
36
|
}
|
|
66
37
|
//# sourceMappingURL=sdk-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["prepareOptions","validate","SDKOptions","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logBrowserEvents","logUIEvents","registerErrorHandler","version","init","options","rules","enableLogcatLogging","maximumLocalStorageSize"],"sources":["sdk-options.ts"],"sourcesContent":["import type {ISDKOptions} from \"./types/sdk-options\";\nimport {prepareOptions, validate, ValidationRules} from \"@bugfender/common\";\n\nexport class SDKOptions {\n protected rules: ValidationRules = {\n appKey: ['required', 'string'],\n apiURL: ['string', 'url'],\n baseURL: ['string', 'url'],\n overrideConsoleMethods: ['boolean'],\n printToConsole: ['boolean'],\n logBrowserEvents: ['boolean'],\n logUIEvents: ['boolean'],\n registerErrorHandler: ['boolean'],\n version: ['string'],\n };\n\n public init(options: ISDKOptions): ISDKOptions {\n // Prepare options\n options = prepareOptions(options);\n\n // Validate user provided options\n validate(options, this.rules);\n\n // Set default values if needed\n return {\n overrideConsoleMethods: true,\n printToConsole: true,\n logUIEvents: true,\n registerErrorHandler: true,\n enableLogcatLogging: false,\n maximumLocalStorageSize: 5 * 1024 * 1024,\n ...options,\n };\n }\n}\n"],"mappings":";;AACA,SAAQA,cAAR,EAAwBC,QAAxB,QAAwD,mBAAxD;AAEA,OAAO,MAAMC,UAAN,CAAiB;EAAA;IAAA,+BACa;MACjCC,MAAM,EAAE,CAAC,UAAD,EAAa,QAAb,CADyB;MAEjCC,MAAM,EAAE,CAAC,QAAD,EAAW,KAAX,CAFyB;MAGjCC,OAAO,EAAE,CAAC,QAAD,EAAW,KAAX,CAHwB;MAIjCC,sBAAsB,EAAE,CAAC,SAAD,CAJS;MAKjCC,cAAc,EAAE,CAAC,SAAD,CALiB;MAMjCC,gBAAgB,EAAE,CAAC,SAAD,CANe;MAOjCC,WAAW,EAAE,CAAC,SAAD,CAPoB;MAQjCC,oBAAoB,EAAE,CAAC,SAAD,CARW;MASjCC,OAAO,EAAE,CAAC,QAAD;IATwB,CADb;EAAA;;EAafC,IAAI,CAACC,OAAD,EAAoC;IAC7C;IACAA,OAAO,GAAGb,cAAc,CAACa,OAAD,CAAxB,CAF6C,CAI7C;;IACAZ,QAAQ,CAACY,OAAD,EAAU,KAAKC,KAAf,CAAR,CAL6C,CAO7C;;IACA,OAAO;MACLR,sBAAsB,EAAE,IADnB;MAELC,cAAc,EAAE,IAFX;MAGLE,WAAW,EAAE,IAHR;MAILC,oBAAoB,EAAE,IAJjB;MAKLK,mBAAmB,EAAE,KALhB;MAMLC,uBAAuB,EAAE,IAAI,IAAJ,GAAW,IAN/B;MAOL,GAAGH;IAPE,CAAP;EASD;;AA9BqB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { removeUndefinedProperties } from '@bugfender/common';
|
|
4
4
|
export class SDKOptionsBuilder {
|
|
5
5
|
constructor(commonOptions) {
|
|
6
6
|
_defineProperty(this, "commonOptions", void 0);
|
|
@@ -40,7 +40,7 @@ export class SDKOptionsBuilder {
|
|
|
40
40
|
enableLogcatLogging: (_this$nativeOptions = this.nativeOptions) === null || _this$nativeOptions === void 0 ? void 0 : _this$nativeOptions.enableLogcatLogging,
|
|
41
41
|
maximumLocalStorageSize: (_this$nativeOptions2 = this.nativeOptions) === null || _this$nativeOptions2 === void 0 ? void 0 : _this$nativeOptions2.maximumLocalStorageSize
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
removeUndefinedProperties(options);
|
|
44
44
|
return options;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["removeUndefinedProperties","SDKOptionsBuilder","constructor","commonOptions","native","nativeOptions","web","webOptions","build","options","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logUIEvents","registerErrorHandler","deviceName","logBrowserEvents","version","enableLogcatLogging","maximumLocalStorageSize"],"sources":["sdk-options.ts"],"sourcesContent":["import {removeUndefinedProperties} from '@bugfender/common';\n\nexport interface ISDKCommonOptions {\n /** The app key to log into */\n appKey: string;\n /** Base URL to Bugfender API */\n apiURL?: string;\n /** Base URL to Bugfender web dashboard */\n baseURL?: string;\n /** Override default `window.console` so it also logs to Bugfender. Defaults to `true`. */\n overrideConsoleMethods?: boolean;\n /** Print also with `window.console` when Bugfender logging methods are called. Defaults to `true`. */\n printToConsole?: boolean;\n /** Register a handler for most common UI events to report them to Bugfender. Defaults to `true`. */\n logUIEvents?: boolean;\n /** Register error handler for uncaught errors that reports a crash to Bugfender. Defaults to `true`. */\n registerErrorHandler?: boolean;\n /** Sets the name for the device. If the Device Name is not set, then the platform standard device name will be automatically sent */\n deviceName?: string;\n}\n\nexport interface ISDKWebOptions {\n /** Register a handler for most common browser events to report them to Bugfender (Web specific). Defaults to `true`. */\n logBrowserEvents?: boolean;\n /** App build identifier (Web specific) */\n build?: string;\n /** App version identifier (Web specific) */\n version?: string;\n}\n\nexport interface ISDKNativeOptions {\n /** 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. **/\n maximumLocalStorageSize?: number;\n /** Logs all logs written via Logcat (Android specific). Defaults to `false`. */\n enableLogcatLogging?: boolean;\n}\n\nexport type ISDKOptions = ISDKCommonOptions & ISDKNativeOptions & ISDKWebOptions;\n\nexport class SDKOptionsBuilder {\n private commonOptions: ISDKCommonOptions;\n private nativeOptions?: ISDKNativeOptions;\n private webOptions?: ISDKWebOptions;\n\n constructor(commonOptions: ISDKCommonOptions) {\n this.commonOptions = commonOptions;\n }\n\n public native(nativeOptions: ISDKNativeOptions): SDKOptionsBuilder {\n this.nativeOptions = nativeOptions;\n return this;\n }\n\n public web(webOptions: ISDKWebOptions): SDKOptionsBuilder {\n this.webOptions = webOptions;\n return this;\n }\n\n public build(): ISDKOptions {\n const options: ISDKOptions = {\n appKey: this.commonOptions.appKey,\n apiURL: this.commonOptions.apiURL,\n baseURL: this.commonOptions.baseURL,\n overrideConsoleMethods: this.commonOptions.overrideConsoleMethods,\n printToConsole: this.commonOptions.printToConsole,\n logUIEvents: this.commonOptions.logUIEvents,\n registerErrorHandler: this.commonOptions.registerErrorHandler,\n deviceName: this.commonOptions.deviceName,\n logBrowserEvents: this.webOptions?.logBrowserEvents,\n build: this.webOptions?.build,\n version: this.webOptions?.version,\n enableLogcatLogging: this.nativeOptions?.enableLogcatLogging,\n maximumLocalStorageSize: this.nativeOptions?.maximumLocalStorageSize,\n };\n\n removeUndefinedProperties(options);\n\n return options;\n }\n}\n"],"mappings":";;AAAA,SAAQA,yBAAR,QAAwC,mBAAxC;AAuCA,OAAO,MAAMC,iBAAN,CAAwB;EAK7BC,WAAW,CAACC,aAAD,EAAmC;IAAA;;IAAA;;IAAA;;IAC5C,KAAKA,aAAL,GAAqBA,aAArB;EACD;;EAEMC,MAAM,CAACC,aAAD,EAAsD;IACjE,KAAKA,aAAL,GAAqBA,aAArB;IACA,OAAO,IAAP;EACD;;EAEMC,GAAG,CAACC,UAAD,EAAgD;IACxD,KAAKA,UAAL,GAAkBA,UAAlB;IACA,OAAO,IAAP;EACD;;EAEMC,KAAK,GAAgB;IAAA;;IAC1B,MAAMC,OAAoB,GAAG;MAC3BC,MAAM,EAAE,KAAKP,aAAL,CAAmBO,MADA;MAE3BC,MAAM,EAAE,KAAKR,aAAL,CAAmBQ,MAFA;MAG3BC,OAAO,EAAE,KAAKT,aAAL,CAAmBS,OAHD;MAI3BC,sBAAsB,EAAE,KAAKV,aAAL,CAAmBU,sBAJhB;MAK3BC,cAAc,EAAE,KAAKX,aAAL,CAAmBW,cALR;MAM3BC,WAAW,EAAE,KAAKZ,aAAL,CAAmBY,WANL;MAO3BC,oBAAoB,EAAE,KAAKb,aAAL,CAAmBa,oBAPd;MAQ3BC,UAAU,EAAE,KAAKd,aAAL,CAAmBc,UARJ;MAS3BC,gBAAgB,sBAAE,KAAKX,UAAP,qDAAE,iBAAiBW,gBATR;MAU3BV,KAAK,uBAAE,KAAKD,UAAP,sDAAE,kBAAiBC,KAVG;MAW3BW,OAAO,uBAAE,KAAKZ,UAAP,sDAAE,kBAAiBY,OAXC;MAY3BC,mBAAmB,yBAAE,KAAKf,aAAP,wDAAE,oBAAoBe,mBAZd;MAa3BC,uBAAuB,0BAAE,KAAKhB,aAAP,yDAAE,qBAAoBgB;IAblB,CAA7B;IAgBArB,yBAAyB,CAACS,OAAD,CAAzB;IAEA,OAAOA,OAAP;EACD;;AAvC4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["DefaultUserFeedbackOptions"],"sources":["user-feedback.ts"],"sourcesContent":["import type { UserFeedbackOptions as BaseUserFeebackOptions } from '@bugfender/common';\n\n/**\n * Options object for `Bugfender.getUserFeedback` with customised modal strings.\n */\nexport interface UserFeedbackOptions extends BaseUserFeebackOptions {\n /** Default `Please insert your feedback here and click send`. */\n hint?: string;\n /** Default: `Close`. This attribute is only used on iOS */\n closeLabel?: string;\n}\n\nexport class DefaultUserFeedbackOptions implements Required<UserFeedbackOptions> {\n public title = 'Feedback';\n public hint = 'Please insert your feedback here and click send';\n public subjectPlaceholder = 'Subject…';\n public feedbackPlaceholder = 'Your feedback…';\n public submitLabel = 'Send';\n public closeLabel = 'Close';\n}\n"],"mappings":";;AAEA;AACA;AACA;AAQA,OAAO,MAAMA,0BAAN,CAA0E;EAAA;IAAA,+BAChE,UADgE;;IAAA,8BAEjE,iDAFiE;;IAAA,4CAGnD,UAHmD;;IAAA,6CAIlD,gBAJkD;;IAAA,qCAK1D,MAL0D;;IAAA,oCAM3D,OAN2D;EAAA;;AAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { BugfenderFacade, DeviceKeyValue, LogEntry, UserFeedbackResult } from '@bugfender/common';
|
|
1
2
|
import type { ISDKOptions } from './types/sdk-options';
|
|
2
|
-
import type { UserFeedbackOptions
|
|
3
|
-
import type { DeviceKeyValue } from './types/device';
|
|
4
|
-
import type { ILogEntry } from './types/log';
|
|
3
|
+
import type { UserFeedbackOptions } from './user-feedback';
|
|
5
4
|
declare const RnBugfender: any;
|
|
6
|
-
declare class BugfenderClass {
|
|
7
|
-
private stringFormatter;
|
|
5
|
+
declare class BugfenderClass implements BugfenderFacade {
|
|
8
6
|
private overrideConsoleMethods;
|
|
9
7
|
private printToConsole;
|
|
10
8
|
private sdkOptions;
|
|
@@ -120,7 +118,7 @@ declare class BugfenderClass {
|
|
|
120
118
|
*
|
|
121
119
|
* @param log Log object that complies with `ILogEntry` interface.
|
|
122
120
|
*/
|
|
123
|
-
sendLog(log:
|
|
121
|
+
sendLog(log: LogEntry): void;
|
|
124
122
|
/**
|
|
125
123
|
* Send an issue.
|
|
126
124
|
*
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { StringFormatter } from "./string-formatter";
|
|
2
1
|
/**
|
|
3
2
|
* Overrides the `window.console` methods in order to execute the Bugfender equivalent logging
|
|
4
3
|
* methods while keeping the original browser functionality.
|
|
@@ -6,5 +5,5 @@ import type { StringFormatter } from "./string-formatter";
|
|
|
6
5
|
export declare class OverrideConsoleMethods {
|
|
7
6
|
protected window: Window;
|
|
8
7
|
constructor(window: Window);
|
|
9
|
-
init(
|
|
8
|
+
init(): void;
|
|
10
9
|
}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import type { ISDKOptions } from "./types/sdk-options";
|
|
2
|
+
import { ValidationRules } from "@bugfender/common";
|
|
2
3
|
export declare class SDKOptions {
|
|
3
|
-
protected rules:
|
|
4
|
-
appKey: string[];
|
|
5
|
-
apiURL: string[];
|
|
6
|
-
baseURL: string[];
|
|
7
|
-
overrideConsoleMethods: string[];
|
|
8
|
-
printToConsole: string[];
|
|
9
|
-
logBrowserEvents: string[];
|
|
10
|
-
logUIEvents: string[];
|
|
11
|
-
registerErrorHandler: string[];
|
|
12
|
-
version: string[];
|
|
13
|
-
};
|
|
4
|
+
protected rules: ValidationRules;
|
|
14
5
|
init(options: ISDKOptions): ISDKOptions;
|
|
15
|
-
protected validate(options: ISDKOptions): void;
|
|
16
6
|
}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
import type { UserFeedbackOptions as BaseUserFeebackOptions } from '@bugfender/common';
|
|
1
2
|
/**
|
|
2
3
|
* Options object for `Bugfender.getUserFeedback` with customised modal strings.
|
|
3
4
|
*/
|
|
4
|
-
export interface UserFeedbackOptions {
|
|
5
|
-
/** Default: `Feedback`. */
|
|
6
|
-
title?: string;
|
|
5
|
+
export interface UserFeedbackOptions extends BaseUserFeebackOptions {
|
|
7
6
|
/** Default `Please insert your feedback here and click send`. */
|
|
8
7
|
hint?: string;
|
|
9
|
-
/** Default: `Subject…`. */
|
|
10
|
-
subjectPlaceholder?: string;
|
|
11
|
-
/** Default: `Your feedback…`. */
|
|
12
|
-
feedbackPlaceholder?: string;
|
|
13
|
-
/** Default: `Send`. */
|
|
14
|
-
submitLabel?: string;
|
|
15
8
|
/** Default: `Close`. This attribute is only used on iOS */
|
|
16
9
|
closeLabel?: string;
|
|
17
10
|
}
|
|
@@ -23,9 +16,3 @@ export declare class DefaultUserFeedbackOptions implements Required<UserFeedback
|
|
|
23
16
|
submitLabel: string;
|
|
24
17
|
closeLabel: string;
|
|
25
18
|
}
|
|
26
|
-
export interface UserFeedbackResult {
|
|
27
|
-
/** `true` if the user has sent the feedback. `false` if she has closed the modal without sending it. */
|
|
28
|
-
isSent: boolean;
|
|
29
|
-
/** If the feedback was sent this will contain the Bugfender URL for the feedback. */
|
|
30
|
-
feedbackURL?: string;
|
|
31
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bugfender/rn-bugfender",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "React Native bindings for Bugfender SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"prepare": "bob build",
|
|
30
30
|
"release": "release-it",
|
|
31
31
|
"example": "yarn --cwd example",
|
|
32
|
-
"
|
|
33
|
-
"bootstrap": "yarn example && yarn && yarn pods"
|
|
32
|
+
"bootstrap": "yarn example && yarn && yarn example pods"
|
|
34
33
|
},
|
|
35
34
|
"keywords": [
|
|
36
35
|
"bugfender",
|
|
@@ -55,25 +54,29 @@
|
|
|
55
54
|
"registry": "https://registry.npmjs.org/"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@types/
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"eslint
|
|
68
|
-
"
|
|
69
|
-
"
|
|
57
|
+
"@arkweid/lefthook": "^0.7.7",
|
|
58
|
+
"@babel/eslint-parser": "^7.18.2",
|
|
59
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
60
|
+
"@react-native-community/eslint-config": "^3.0.2",
|
|
61
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
62
|
+
"@types/jest": "^28.1.2",
|
|
63
|
+
"@types/react": "~17.0.21",
|
|
64
|
+
"@types/react-native": "0.68.0",
|
|
65
|
+
"commitlint": "^17.0.2",
|
|
66
|
+
"eslint": "^8.4.1",
|
|
67
|
+
"eslint-config-prettier": "^8.5.0",
|
|
68
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
69
|
+
"jest": "^28.1.1",
|
|
70
70
|
"pod-install": "^0.1.0",
|
|
71
71
|
"prettier": "^2.0.5",
|
|
72
|
-
"react": "
|
|
73
|
-
"react-native": "0.
|
|
74
|
-
"react-native-builder-bob": "^0.18.
|
|
75
|
-
"release-it": "^
|
|
76
|
-
"typescript": "^4.
|
|
72
|
+
"react": "17.0.2",
|
|
73
|
+
"react-native": "0.68.2",
|
|
74
|
+
"react-native-builder-bob": "^0.18.3",
|
|
75
|
+
"release-it": "^15.0.0",
|
|
76
|
+
"typescript": "^4.5.2"
|
|
77
|
+
},
|
|
78
|
+
"resolutions": {
|
|
79
|
+
"@types/react": "17.0.21"
|
|
77
80
|
},
|
|
78
81
|
"peerDependencies": {
|
|
79
82
|
"react": "*",
|
|
@@ -110,6 +113,7 @@
|
|
|
110
113
|
},
|
|
111
114
|
"eslintConfig": {
|
|
112
115
|
"root": true,
|
|
116
|
+
"parser": "@babel/eslint-parser",
|
|
113
117
|
"extends": [
|
|
114
118
|
"@react-native-community",
|
|
115
119
|
"prettier"
|
|
@@ -153,7 +157,7 @@
|
|
|
153
157
|
]
|
|
154
158
|
},
|
|
155
159
|
"dependencies": {
|
|
156
|
-
"@bugfender/
|
|
157
|
-
"
|
|
160
|
+
"@bugfender/common": "1.0.0-alpha.5",
|
|
161
|
+
"@bugfender/sdk": "^2.1.0"
|
|
158
162
|
}
|
|
159
163
|
}
|
package/src/bugfender.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import { BugfenderFacade, DeviceKeyValue, LogEntry, LogLevel, PrintToConsole, UserFeedbackResult, format } from '@bugfender/common';
|
|
2
3
|
import type { ISDKOptions } from './types/sdk-options';
|
|
3
|
-
import type { UserFeedbackOptions
|
|
4
|
+
import type { UserFeedbackOptions } from './user-feedback';
|
|
4
5
|
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 { PrintToConsole } from './print-to-console';
|
|
10
6
|
import { SDKOptions } from './sdk-options';
|
|
11
7
|
|
|
12
8
|
const LINKING_ERROR =
|
|
@@ -26,8 +22,7 @@ const RnBugfender = NativeModules.RnBugfender
|
|
|
26
22
|
}
|
|
27
23
|
);
|
|
28
24
|
|
|
29
|
-
class BugfenderClass {
|
|
30
|
-
private stringFormatter = new StringFormatter();
|
|
25
|
+
class BugfenderClass implements BugfenderFacade {
|
|
31
26
|
private overrideConsoleMethods =
|
|
32
27
|
new (require('./override-console-methods').OverrideConsoleMethods)(window);
|
|
33
28
|
private printToConsole = new PrintToConsole(global.console);
|
|
@@ -56,7 +51,7 @@ class BugfenderClass {
|
|
|
56
51
|
: RnBugfender.init(validatedOptions.appKey, validatedOptions.printToConsole ?? false);
|
|
57
52
|
|
|
58
53
|
if (validatedOptions.overrideConsoleMethods) {
|
|
59
|
-
this.overrideConsoleMethods.init(
|
|
54
|
+
this.overrideConsoleMethods.init();
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
this.printToConsole.init(validatedOptions.printToConsole ?? true);
|
|
@@ -160,7 +155,7 @@ class BugfenderClass {
|
|
|
160
155
|
public log(...parameters: unknown[]): void {
|
|
161
156
|
this.printToConsole.log(...parameters);
|
|
162
157
|
|
|
163
|
-
let message =
|
|
158
|
+
let message = format([...parameters]);
|
|
164
159
|
RnBugfender.debug('', message);
|
|
165
160
|
}
|
|
166
161
|
|
|
@@ -179,7 +174,7 @@ class BugfenderClass {
|
|
|
179
174
|
public warn(...parameters: unknown[]): void {
|
|
180
175
|
this.printToConsole.warn(...parameters);
|
|
181
176
|
|
|
182
|
-
let message =
|
|
177
|
+
let message = format([...parameters]);
|
|
183
178
|
RnBugfender.warning('', message);
|
|
184
179
|
}
|
|
185
180
|
|
|
@@ -198,7 +193,7 @@ class BugfenderClass {
|
|
|
198
193
|
public error(...parameters: unknown[]): void {
|
|
199
194
|
this.printToConsole.error(...parameters);
|
|
200
195
|
|
|
201
|
-
let message =
|
|
196
|
+
let message = format([...parameters]);
|
|
202
197
|
RnBugfender.error('', message);
|
|
203
198
|
}
|
|
204
199
|
|
|
@@ -217,7 +212,7 @@ class BugfenderClass {
|
|
|
217
212
|
public trace(...parameters: unknown[]): void {
|
|
218
213
|
this.printToConsole.trace(...parameters);
|
|
219
214
|
|
|
220
|
-
let message =
|
|
215
|
+
let message = format([...parameters]);
|
|
221
216
|
RnBugfender.trace('', message);
|
|
222
217
|
}
|
|
223
218
|
|
|
@@ -236,7 +231,7 @@ class BugfenderClass {
|
|
|
236
231
|
public info(...parameters: unknown[]): void {
|
|
237
232
|
this.printToConsole.info(...parameters);
|
|
238
233
|
|
|
239
|
-
let message =
|
|
234
|
+
let message = format([...parameters]);
|
|
240
235
|
RnBugfender.info('', message);
|
|
241
236
|
}
|
|
242
237
|
|
|
@@ -255,7 +250,7 @@ class BugfenderClass {
|
|
|
255
250
|
public fatal(...parameters: unknown[]): void {
|
|
256
251
|
this.printToConsole.error(...parameters);
|
|
257
252
|
|
|
258
|
-
let message =
|
|
253
|
+
let message = format([...parameters]);
|
|
259
254
|
RnBugfender.fatal('', message);
|
|
260
255
|
}
|
|
261
256
|
|
|
@@ -274,7 +269,7 @@ class BugfenderClass {
|
|
|
274
269
|
*
|
|
275
270
|
* @param log Log object that complies with `ILogEntry` interface.
|
|
276
271
|
*/
|
|
277
|
-
public sendLog(log:
|
|
272
|
+
public sendLog(log: LogEntry): void {
|
|
278
273
|
this.printToConsole.printLog(log);
|
|
279
274
|
|
|
280
275
|
RnBugfender.log(
|
package/src/index.tsx
CHANGED
package/src/index.web.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import {format} from '@bugfender/common';
|
|
2
2
|
import {RnBugfender} from "./bugfender";
|
|
3
|
-
import type {StringFormatter} from "./string-formatter";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Overrides the `window.console` methods in order to execute the Bugfender equivalent logging
|
|
@@ -12,39 +11,39 @@ export class OverrideConsoleMethods {
|
|
|
12
11
|
) {
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
public init(
|
|
14
|
+
public init(): void {
|
|
16
15
|
|
|
17
16
|
(this.window as any).console = function (console: Console) {
|
|
18
17
|
return {
|
|
19
18
|
...console,
|
|
20
19
|
log: function (...parameters: unknown[]) {
|
|
21
20
|
console.log(...parameters);
|
|
22
|
-
let message =
|
|
21
|
+
let message = format([...parameters]);
|
|
23
22
|
RnBugfender.debug('', message);
|
|
24
23
|
},
|
|
25
24
|
debug: function (...parameters: unknown[]) {
|
|
26
25
|
console.debug(...parameters);
|
|
27
|
-
let message =
|
|
26
|
+
let message = format([...parameters]);
|
|
28
27
|
RnBugfender.debug('', message);
|
|
29
28
|
},
|
|
30
29
|
trace: function (...parameters: unknown[]) {
|
|
31
30
|
console.trace(...parameters);
|
|
32
|
-
let message =
|
|
31
|
+
let message = format([...parameters]);
|
|
33
32
|
RnBugfender.trace('', message);
|
|
34
33
|
},
|
|
35
34
|
info: function (...parameters: unknown[]) {
|
|
36
35
|
console.info(...parameters);
|
|
37
|
-
let message =
|
|
36
|
+
let message = format([...parameters]);
|
|
38
37
|
RnBugfender.info('', message);
|
|
39
38
|
},
|
|
40
39
|
warn: function (...parameters: unknown[]) {
|
|
41
40
|
console.warn(...parameters);
|
|
42
|
-
let message =
|
|
41
|
+
let message = format([...parameters]);
|
|
43
42
|
RnBugfender.warning('', message);
|
|
44
43
|
},
|
|
45
44
|
error: function (...parameters: unknown[]) {
|
|
46
45
|
console.error(...parameters);
|
|
47
|
-
let message =
|
|
46
|
+
let message = format([...parameters]);
|
|
48
47
|
RnBugfender.error('', message);
|
|
49
48
|
},
|
|
50
49
|
};
|
package/src/sdk-options.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {ISDKOptions} from "./types/sdk-options";
|
|
2
|
-
import {
|
|
2
|
+
import {prepareOptions, validate, ValidationRules} from "@bugfender/common";
|
|
3
3
|
|
|
4
4
|
export class SDKOptions {
|
|
5
|
-
protected rules = {
|
|
5
|
+
protected rules: ValidationRules = {
|
|
6
6
|
appKey: ['required', 'string'],
|
|
7
7
|
apiURL: ['string', 'url'],
|
|
8
8
|
baseURL: ['string', 'url'],
|
|
@@ -15,11 +15,11 @@ export class SDKOptions {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
public init(options: ISDKOptions): ISDKOptions {
|
|
18
|
-
//
|
|
19
|
-
|
|
18
|
+
// Prepare options
|
|
19
|
+
options = prepareOptions(options);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Validate user provided options
|
|
22
|
+
validate(options, this.rules);
|
|
23
23
|
|
|
24
24
|
// Set default values if needed
|
|
25
25
|
return {
|
|
@@ -32,33 +32,4 @@ export class SDKOptions {
|
|
|
32
32
|
...options,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
protected validate(options: ISDKOptions): void {
|
|
37
|
-
const urlValidator = new RegExp(/^http(s)?:\/\//i);
|
|
38
|
-
|
|
39
|
-
Object.entries(this.rules).forEach(([key, rules]) => {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
const value = options[key];
|
|
42
|
-
|
|
43
|
-
rules.forEach(rule => {
|
|
44
|
-
if (rule === 'required') {
|
|
45
|
-
if (typeof value === 'undefined') {
|
|
46
|
-
throw new Error(`Bugfender requires '${key}' option to initialize.`)
|
|
47
|
-
}
|
|
48
|
-
} else if (rule === 'string') {
|
|
49
|
-
if (!['string', 'undefined'].includes(typeof value)) {
|
|
50
|
-
throw new Error(`'${key}' option must be a string.`);
|
|
51
|
-
}
|
|
52
|
-
} else if (rule === 'url') {
|
|
53
|
-
if (typeof value !== 'undefined' && !urlValidator.test(value)) {
|
|
54
|
-
throw new Error(`'${key}' option must be a valid URL.`);
|
|
55
|
-
}
|
|
56
|
-
} else if (rule === 'boolean') {
|
|
57
|
-
if (!['boolean', 'undefined'].includes(typeof value)) {
|
|
58
|
-
throw new Error(`'${key}' option must be a boolean.`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
35
|
}
|
package/src/types/sdk-options.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {removeUndefinedProperties} from '@bugfender/common';
|
|
2
2
|
|
|
3
3
|
export interface ISDKCommonOptions {
|
|
4
4
|
/** The app key to log into */
|
|
@@ -73,7 +73,7 @@ export class SDKOptionsBuilder {
|
|
|
73
73
|
maximumLocalStorageSize: this.nativeOptions?.maximumLocalStorageSize,
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
removeUndefinedProperties(options);
|
|
77
77
|
|
|
78
78
|
return options;
|
|
79
79
|
}
|
package/src/user-feedback.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
+
import type { UserFeedbackOptions as BaseUserFeebackOptions } from '@bugfender/common';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Options object for `Bugfender.getUserFeedback` with customised modal strings.
|
|
3
5
|
*/
|
|
4
|
-
export interface UserFeedbackOptions {
|
|
5
|
-
/** Default: `Feedback`. */
|
|
6
|
-
title?: string;
|
|
6
|
+
export interface UserFeedbackOptions extends BaseUserFeebackOptions {
|
|
7
7
|
/** Default `Please insert your feedback here and click send`. */
|
|
8
8
|
hint?: string;
|
|
9
|
-
/** Default: `Subject…`. */
|
|
10
|
-
subjectPlaceholder?: string;
|
|
11
|
-
/** Default: `Your feedback…`. */
|
|
12
|
-
feedbackPlaceholder?: string;
|
|
13
|
-
/** Default: `Send`. */
|
|
14
|
-
submitLabel?: string;
|
|
15
9
|
/** Default: `Close`. This attribute is only used on iOS */
|
|
16
10
|
closeLabel?: string;
|
|
17
11
|
}
|
|
@@ -24,10 +18,3 @@ export class DefaultUserFeedbackOptions implements Required<UserFeedbackOptions>
|
|
|
24
18
|
public submitLabel = 'Send';
|
|
25
19
|
public closeLabel = 'Close';
|
|
26
20
|
}
|
|
27
|
-
|
|
28
|
-
export interface UserFeedbackResult {
|
|
29
|
-
/** `true` if the user has sent the feedback. `false` if she has closed the modal without sending it. */
|
|
30
|
-
isSent: boolean;
|
|
31
|
-
/** If the feedback was sent this will contain the Bugfender URL for the feedback. */
|
|
32
|
-
feedbackURL?: string;
|
|
33
|
-
}
|
|
Binary file
|