@bugfender/rn-bugfender 2.0.0-alpha.0 → 2.0.0
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/README.md +46 -19
- package/lib/commonjs/print-to-console.js +2 -2
- package/lib/commonjs/print-to-console.js.map +1 -1
- package/lib/commonjs/sdk-options.js +6 -12
- package/lib/commonjs/sdk-options.js.map +1 -1
- package/lib/commonjs/types/sdk-options.js +12 -10
- package/lib/commonjs/types/sdk-options.js.map +1 -1
- package/lib/commonjs/utilities.js +18 -0
- package/lib/commonjs/utilities.js.map +1 -0
- package/lib/module/print-to-console.js +2 -2
- package/lib/module/print-to-console.js.map +1 -1
- package/lib/module/sdk-options.js +5 -12
- package/lib/module/sdk-options.js.map +1 -1
- package/lib/module/types/sdk-options.js +11 -10
- package/lib/module/types/sdk-options.js.map +1 -1
- package/lib/module/utilities.js +11 -0
- package/lib/module/utilities.js.map +1 -0
- package/lib/typescript/utilities.d.ts +1 -0
- package/package.json +3 -3
- package/src/sdk-options.ts +2 -7
- package/src/types/sdk-options.ts +3 -7
- package/src/utilities.ts +8 -0
- package/ios/RnBugfender.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/RnBugfender.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
package/README.md
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
# React Native plugin for Bugfender
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
The Bugfender bindings for React Native depend on the native iOS and Android Bugfender SDKs.
|
|
6
|
-
|
|
7
|
-
## Creating a RN new project compatible with Bugfender
|
|
8
|
-
|
|
9
|
-
You can create a new project using
|
|
10
|
-
|
|
11
|
-
`$ npx react-native init AwesomeProject`
|
|
12
|
-
|
|
13
|
-
or if you already started your project using the tool `create-react-native-app` you will need to `eject` your project in order to add native modules.
|
|
14
|
-
|
|
15
|
-
More info can be found in the [official docs](https://facebook.github.io/react-native/docs/getting-started)
|
|
16
|
-
|
|
17
|
-
Before moving to the next point **compile the project and ensure you can execute**.
|
|
18
|
-
In this way, we can discard issues in the next steps.
|
|
3
|
+
Bugfender module for React Native and React Native for the Web. It depends on the iOS, Android and Javascript Bugfender SDKs.
|
|
19
4
|
|
|
20
5
|
## Adding Bugfender to your project
|
|
21
6
|
|
|
@@ -27,7 +12,7 @@ Add the bugfender plugin from npm
|
|
|
27
12
|
|
|
28
13
|
`$ npm install @bugfender/rn-bugfender --save`
|
|
29
14
|
|
|
30
|
-
### Android
|
|
15
|
+
### Android & React Native for the Web
|
|
31
16
|
You are done!
|
|
32
17
|
|
|
33
18
|
### iOS
|
|
@@ -75,10 +60,26 @@ Bugfender.init({
|
|
|
75
60
|
// printToConsole: true,
|
|
76
61
|
// logUIEvents: true,
|
|
77
62
|
// registerErrorHandler: true,
|
|
78
|
-
// deviceName: 'Anonymous
|
|
79
|
-
// enableLogcatLogging: false,
|
|
63
|
+
// deviceName: 'Anonymous',
|
|
64
|
+
// enableLogcatLogging: false, // Android specific
|
|
65
|
+
// logBrowserEvents: true, // Web specific
|
|
66
|
+
// build: '42', // Web specific
|
|
67
|
+
// version: '1.0', // Web sprecific
|
|
80
68
|
});
|
|
81
69
|
|
|
70
|
+
// Alternatively, SDKOptionsBuilder can be used to make it apparent what options are specific of certain platforms
|
|
71
|
+
Bugfender.init(
|
|
72
|
+
new SDKOptionsBuilder({
|
|
73
|
+
appKey: '<YOUR APP KEY>',
|
|
74
|
+
}).native({
|
|
75
|
+
enableLogcatLogging: false,
|
|
76
|
+
}).web({
|
|
77
|
+
logBrowserEvents: true,
|
|
78
|
+
build: '42',
|
|
79
|
+
version: '1.0',
|
|
80
|
+
}).build()
|
|
81
|
+
);
|
|
82
|
+
|
|
82
83
|
// Send logs with different levels
|
|
83
84
|
Bugfender.log('This is a debug log in Bugfender from React Native');
|
|
84
85
|
Bugfender.warn('This is a warn log in Bugfender from React Native');
|
|
@@ -135,6 +136,9 @@ Bugfender.setDeviceKey('device.key.boolean', true);
|
|
|
135
136
|
Bugfender.setDeviceKey('device.key.float', 10.1);
|
|
136
137
|
Bugfender.setDeviceKey('device.key.integer', 102);
|
|
137
138
|
|
|
139
|
+
// Remove device values
|
|
140
|
+
Bugfender.removeDeviceKey('device.key.integer');
|
|
141
|
+
|
|
138
142
|
// Get different URLs
|
|
139
143
|
Bugfender.getDeviceURL().then((url) => console.log('Device url: %s', url));
|
|
140
144
|
Bugfender.getSessionURL().then((url) => console.log('Session url: %s', url));
|
|
@@ -142,6 +146,29 @@ Bugfender.getSessionURL().then((url) => console.log('Session url: %s', url));
|
|
|
142
146
|
// Synchronizes all logs and issues with the server once
|
|
143
147
|
Bugfender.forceSendOnce();
|
|
144
148
|
```
|
|
149
|
+
## Changelog
|
|
150
|
+
The changelog of the Bugfender Web SDK can be found in ReleaseNotes under the [react-native](https://bugfender.releasenotes.io/tag/react-native) tag. For all the Bugfender product changes please visit the general release notes.
|
|
151
|
+
|
|
152
|
+
### 2.x Breaking Changes
|
|
153
|
+
The Web SDK API has changed in order be unified with [Bugfender Web SDK](https://www.npmjs.com/package/@bugfender/sdk):
|
|
154
|
+
* The following methods have been removed and replaced with init method attributes:
|
|
155
|
+
* `setApiUrl`
|
|
156
|
+
* `setBaseUrl`
|
|
157
|
+
* `overrideDeviceName`
|
|
158
|
+
* `setMaximumLocalStorageSize`
|
|
159
|
+
* `enableLogcatLogging`
|
|
160
|
+
* `enableCrashReporting`
|
|
161
|
+
* `enableUIEventLogging`
|
|
162
|
+
|
|
163
|
+
* The following methods have been renamed:
|
|
164
|
+
* `setForceEnabled` renamed to `sendForceOnce`
|
|
165
|
+
* `showUserFeedback` renamed to `sendUserFeedback`
|
|
166
|
+
* `d` rename to `debug`
|
|
167
|
+
* `w` renamed to `warn`
|
|
168
|
+
* `e` renamed to `error`
|
|
169
|
+
* `log` renamed to `sendLog`
|
|
170
|
+
|
|
171
|
+
* `setDeviceKey` method replaces `setDeviceBoolean`, `setDeviceString`, `setDeviceInteger` & `setDeviceFloat`
|
|
145
172
|
|
|
146
173
|
## Cocoapods Troubleshooting
|
|
147
174
|
We did our best to create a installation process that worked for most of the users. However, the React Native configuration can be tricky sometimes.
|
|
@@ -13,9 +13,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
13
13
|
|
|
14
14
|
class PrintToConsole {
|
|
15
15
|
constructor(console) {
|
|
16
|
-
_defineProperty(this, "printToConsole", false);
|
|
17
|
-
|
|
18
16
|
this.console = console;
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "printToConsole", false);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
init(printToConsole) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["print-to-console.ts"],"names":["PrintToConsole","constructor","console","init","printToConsole","error","info","log","debug","trace","warn","printLog","levelToMethod","method","level","LogLevel","Debug","tag","location","file","line","filter","p","join","message","text"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEO,MAAMA,cAAN,CAAqB;AAG1BC,EAAAA,WAAW,CACUC,OADV,EAET;AAAA,
|
|
1
|
+
{"version":3,"sources":["print-to-console.ts"],"names":["PrintToConsole","constructor","console","init","printToConsole","error","info","log","debug","trace","warn","printLog","levelToMethod","method","level","LogLevel","Debug","tag","location","file","line","filter","p","join","message","text"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEO,MAAMA,cAAN,CAAqB;AAG1BC,EAAAA,WAAW,CACUC,OADV,EAET;AAAA,SADmBA,OACnB,GADmBA,OACnB;;AAAA,4CAJkC,KAIlC;AACD;;AAEMC,EAAAA,IAAI,CAACC,cAAD,EAAgC;AACzC,SAAKA,cAAL,GAAsBA,cAAtB;AACD;;AAEMC,EAAAA,KAAK,GAAiC;AAC3C,QAAI,KAAKD,cAAT,EAAyB;AACvB,WAAKF,OAAL,CAAaG,KAAb,CAAmB,YAAnB;AACD;AACF;;AAEMC,EAAAA,IAAI,GAAiC;AAC1C,QAAI,KAAKF,c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,IAAX,CAAiB,IAAGP,QAAS,EAAtD,CAPuB,CASvB;;AACA,WAAKhB,OAAL,CAAaW,MAAb,EAAqBW,OAArB;AACD;AACF;;AA7DyB","sourcesContent":["import {format} from 'util';\nimport type {ILogEntry} from \"./types/log\";\nimport {LogLevel} from \"./types/log\";\n\nexport class PrintToConsole {\n protected printToConsole: boolean = false;\n\n constructor(\n protected readonly console: Console,\n ) {\n }\n\n public init(printToConsole: boolean): void {\n this.printToConsole = printToConsole;\n }\n\n public error(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.error(...parameters);\n }\n }\n\n public info(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.info(...parameters);\n }\n }\n\n public log(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.log(...parameters);\n }\n }\n\n public debug(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.debug(...parameters);\n }\n }\n\n public trace(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.trace(...parameters);\n }\n }\n\n public warn(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.warn(...parameters);\n }\n }\n\n public printLog(log: ILogEntry): void {\n if (this.printToConsole) {\n // Log to browser console\n // debug, warning, error, trace, info, fatal\n const levelToMethod = ['log', 'warn', 'error', 'trace', 'info', 'error'];\n const method = levelToMethod[log.level || LogLevel.Debug];\n const tag = log.tag ? `[${log.tag}] ` : '';\n const location = [log.file || '', log.method || '', log.line || ''].filter(p => p !== '').join(':');\n const message = `${tag}${format(log.text)} ${location}`;\n\n // @ts-ignore\n this.console[method](message);\n }\n }\n}\n"]}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SDKOptions = void 0;
|
|
7
7
|
|
|
8
|
+
var _utilities = require("./utilities");
|
|
9
|
+
|
|
8
10
|
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; }
|
|
9
11
|
|
|
10
12
|
class SDKOptions {
|
|
@@ -24,18 +26,10 @@ class SDKOptions {
|
|
|
24
26
|
|
|
25
27
|
init(options) {
|
|
26
28
|
// Validate user provided options
|
|
27
|
-
this.validate(options);
|
|
28
|
-
|
|
29
|
+
this.validate(options);
|
|
29
30
|
options = { ...options
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
let [key, value] = _ref;
|
|
33
|
-
|
|
34
|
-
if (value === undefined) {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
delete options[key];
|
|
37
|
-
}
|
|
38
|
-
}); // Set default values if needed
|
|
32
|
+
(0, _utilities.removeUndefinedAttributes)(options); // Set default values if needed
|
|
39
33
|
|
|
40
34
|
return {
|
|
41
35
|
overrideConsoleMethods: true,
|
|
@@ -49,8 +43,8 @@ class SDKOptions {
|
|
|
49
43
|
|
|
50
44
|
validate(options) {
|
|
51
45
|
const urlValidator = new RegExp(/^http(s)?:\/\//i);
|
|
52
|
-
Object.entries(this.rules).forEach(
|
|
53
|
-
let [key, rules] =
|
|
46
|
+
Object.entries(this.rules).forEach(_ref => {
|
|
47
|
+
let [key, rules] = _ref;
|
|
54
48
|
// @ts-ignore
|
|
55
49
|
const value = options[key];
|
|
56
50
|
rules.forEach(rule => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["sdk-options.ts"],"names":["SDKOptions","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logBrowserEvents","logUIEvents","registerErrorHandler","version","init","options","validate","
|
|
1
|
+
{"version":3,"sources":["sdk-options.ts"],"names":["SDKOptions","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logBrowserEvents","logUIEvents","registerErrorHandler","version","init","options","validate","enableLogcatLogging","urlValidator","RegExp","Object","entries","rules","forEach","key","value","rule","Error","includes","test"],"mappings":";;;;;;;AACA;;;;AAEO,MAAMA,UAAN,CAAiB;AAAA;AAAA,mCACJ;AAChBC,MAAAA,MAAM,EAAE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C,kBAAM,IAAIE,KAAJ,CAAW,uBAAsBH,GAAI,yBAArC,CAAN;AACD;AACF,SAJD,MAIO,IAAIE,IAAI,KAAK,QAAb,EAAuB;AAC5B,cAAI,CAAC,CAAC,QAAD,EAAW,WAAX,EAAwBE,QAAxB,CAAiC,OAAOH,KAAxC,CAAL,EAAqD;AACnD,kBAAM,IAAIE,KAAJ,CAAW,IAAGH,GAAI,4BAAlB,CAAN;AACD;AACF,SAJM,MAIA,IAAIE,IAAI,KAAK,KAAb,EAAoB;AACzB,cAAI,OAAOD,KAAP,KAAiB,WAAjB,IAAgC,CAACP,YAAY,CAACW,IAAb,CAAkBJ,KAAlB,CAArC,EAA+D;AAC7D,kBAAM,IAAIE,KAAJ,CAAW,IAAGH,GAAI,+BAAlB,CAAN;AACD;AACF,SAJM,MAIA,IAAIE,IAAI,KAAK,SAAb,EAAwB;AAC7B,cAAI,CAAC,CAAC,SAAD,EAAY,WAAZ,EAAyBE,QAAzB,CAAkC,OAAOH,KAAzC,CAAL,EAAsD;AACpD,kBAAM,IAAIE,KAAJ,CAAW,IAAGH,GAAI,6BAAlB,CAAN;AACD;AACF;AACF,OAlBD;AAmBD,KAvBD;AAwBD;;AA1DqB","sourcesContent":["import type {ISDKOptions} from \"./types/sdk-options\";\nimport {removeUndefinedAttributes} from \"./utilities\";\n\nexport class SDKOptions {\n protected rules = {\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 // Validate user provided options\n this.validate(options);\n\n options = { ...options };\n removeUndefinedAttributes(options);\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 ...options,\n };\n }\n\n protected validate(options: ISDKOptions): void {\n const urlValidator = new RegExp(/^http(s)?:\\/\\//i);\n\n Object.entries(this.rules).forEach(([key, rules]) => {\n // @ts-ignore\n const value = options[key];\n\n rules.forEach(rule => {\n if (rule === 'required') {\n if (typeof value === 'undefined') {\n throw new Error(`Bugfender requires '${key}' option to initialize.`)\n }\n } else if (rule === 'string') {\n if (!['string', 'undefined'].includes(typeof value)) {\n throw new Error(`'${key}' option must be a string.`);\n }\n } else if (rule === 'url') {\n if (typeof value !== 'undefined' && !urlValidator.test(value)) {\n throw new Error(`'${key}' option must be a valid URL.`);\n }\n } else if (rule === 'boolean') {\n if (!['boolean', 'undefined'].includes(typeof value)) {\n throw new Error(`'${key}' option must be a boolean.`);\n }\n }\n })\n });\n }\n}\n"]}
|
|
@@ -5,8 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SDKOptionsBuilder = void 0;
|
|
7
7
|
|
|
8
|
+
var _utilities = require("../utilities");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
8
12
|
class SDKOptionsBuilder {
|
|
9
13
|
constructor(commonOptions) {
|
|
14
|
+
_defineProperty(this, "commonOptions", void 0);
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "nativeOptions", void 0);
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "webOptions", void 0);
|
|
19
|
+
|
|
10
20
|
this.commonOptions = commonOptions;
|
|
11
21
|
}
|
|
12
22
|
|
|
@@ -36,16 +46,8 @@ class SDKOptionsBuilder {
|
|
|
36
46
|
build: (_this$webOptions2 = this.webOptions) === null || _this$webOptions2 === void 0 ? void 0 : _this$webOptions2.build,
|
|
37
47
|
version: (_this$webOptions3 = this.webOptions) === null || _this$webOptions3 === void 0 ? void 0 : _this$webOptions3.version,
|
|
38
48
|
enableLogcatLogging: (_this$nativeOptions = this.nativeOptions) === null || _this$nativeOptions === void 0 ? void 0 : _this$nativeOptions.enableLogcatLogging
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
Object.entries(options).forEach(_ref => {
|
|
42
|
-
let [key, value] = _ref;
|
|
43
|
-
|
|
44
|
-
if (value === undefined) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
delete options[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
+
};
|
|
50
|
+
(0, _utilities.removeUndefinedAttributes)(options);
|
|
49
51
|
return options;
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["sdk-options.ts"],"names":["SDKOptionsBuilder","constructor","commonOptions","native","nativeOptions","web","webOptions","build","options","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logUIEvents","registerErrorHandler","deviceName","logBrowserEvents","version","enableLogcatLogging"
|
|
1
|
+
{"version":3,"sources":["sdk-options.ts"],"names":["SDKOptionsBuilder","constructor","commonOptions","native","nativeOptions","web","webOptions","build","options","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logUIEvents","registerErrorHandler","deviceName","logBrowserEvents","version","enableLogcatLogging"],"mappings":";;;;;;;AAAA;;;;AAqCO,MAAMA,iBAAN,CAAwB;AAK7BC,EAAAA,WAAW,CAACC,aAAD,EAAmC;AAAA;;AAAA;;AAAA;;AAC5C,SAAKA,aAAL,GAAqBA,aAArB;AACD;;AAEMC,EAAAA,MAAM,CAACC,aAAD,EAAsD;AACjE,SAAKA,aAAL,GAAqBA,aAArB;AACA,WAAO,IAAP;AACD;;AAEMC,EAAAA,GAAG,CAACC,UAAD,EAAgD;AACxD,SAAKA,UAAL,GAAkBA,UAAlB;AACA,WAAO,IAAP;AACD;;AAEMC,EAAAA,KAAK,GAAgB;AAAA;;AAC1B,UAAMC,OAAoB,GAAG;AAC3BC,MAAAA,MAAM,EAAE,KAAKP,aAAL,CAAmBO,MADA;AAE3BC,MAAAA,MAAM,EAAE,KAAKR,aAAL,CAAmBQ,MAFA;AAG3BC,MAAAA,OAAO,EAAE,KAAKT,aAAL,CAAmBS,OAHD;AAI3BC,MAAAA,sBAAsB,EAAE,KAAKV,aAAL,CAAmBU,sBAJhB;AAK3BC,MAAAA,cAAc,EAAE,KAAKX,aAAL,CAAmBW,cALR;AAM3BC,MAAAA,WAAW,EAAE,KAAKZ,aAAL,CAAmBY,WANL;AAO3BC,MAAAA,oBAAoB,EAAE,KAAKb,aAAL,CAAmBa,oBAPd;AAQ3BC,MAAAA,UAAU,EAAE,KAAKd,aAAL,CAAmBc,UARJ;AAS3BC,MAAAA,gBAAgB,sBAAE,KAAKX,UAAP,qDAAE,iBAAiBW,gBATR;AAU3BV,MAAAA,KAAK,uBAAE,KAAKD,UAAP,sDAAE,kBAAiBC,KAVG;AAW3BW,MAAAA,OAAO,uBAAE,KAAKZ,UAAP,sDAAE,kBAAiBY,OAXC;AAY3BC,MAAAA,mBAAmB,yBAAE,KAAKf,aAAP,wDAAE,oBAAoBe;AAZd,KAA7B;AAeA,8CAA0BX,OAA1B;AAEA,WAAOA,OAAP;AACD;;AAtC4B","sourcesContent":["import {removeUndefinedAttributes} from \"../utilities\";\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 /** 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 };\n\n removeUndefinedAttributes(options);\n\n return options;\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removeUndefinedAttributes = removeUndefinedAttributes;
|
|
7
|
+
|
|
8
|
+
function removeUndefinedAttributes(object) {
|
|
9
|
+
Object.entries(object).forEach(_ref => {
|
|
10
|
+
let [key, value] = _ref;
|
|
11
|
+
|
|
12
|
+
if (value === undefined) {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
delete object[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["utilities.ts"],"names":["removeUndefinedAttributes","object","Object","entries","forEach","key","value","undefined"],"mappings":";;;;;;;AAAO,SAASA,yBAAT,CAAmCC,MAAnC,EAAgD;AACrDC,EAAAA,MAAM,CAACC,OAAP,CAAeF,MAAf,EAAuBG,OAAvB,CAA+B,QAAkB;AAAA,QAAjB,CAACC,GAAD,EAAMC,KAAN,CAAiB;;AAC/C,QAAIA,KAAK,KAAKC,SAAd,EAAyB;AACvB;AACA,aAAON,MAAM,CAACI,GAAD,CAAb;AACD;AACF,GALD;AAMD","sourcesContent":["export function removeUndefinedAttributes(object: any) {\n Object.entries(object).forEach(([key, value]) => {\n if (value === undefined) {\n // @ts-ignore\n delete object[key];\n }\n });\n}\n"]}
|
|
@@ -4,9 +4,9 @@ import { format } from 'util';
|
|
|
4
4
|
import { LogLevel } from "./types/log";
|
|
5
5
|
export class PrintToConsole {
|
|
6
6
|
constructor(console) {
|
|
7
|
-
_defineProperty(this, "printToConsole", false);
|
|
8
|
-
|
|
9
7
|
this.console = console;
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "printToConsole", false);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
init(printToConsole) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["print-to-console.ts"],"names":["format","LogLevel","PrintToConsole","constructor","console","init","printToConsole","error","info","log","debug","trace","warn","printLog","levelToMethod","method","level","Debug","tag","location","file","line","filter","p","join","message","text"],"mappings":";;AAAA,SAAQA,MAAR,QAAqB,MAArB;AAEA,SAAQC,QAAR,QAAuB,aAAvB;AAEA,OAAO,MAAMC,cAAN,CAAqB;AAG1BC,EAAAA,WAAW,CACUC,OADV,EAET;AAAA,
|
|
1
|
+
{"version":3,"sources":["print-to-console.ts"],"names":["format","LogLevel","PrintToConsole","constructor","console","init","printToConsole","error","info","log","debug","trace","warn","printLog","levelToMethod","method","level","Debug","tag","location","file","line","filter","p","join","message","text"],"mappings":";;AAAA,SAAQA,MAAR,QAAqB,MAArB;AAEA,SAAQC,QAAR,QAAuB,aAAvB;AAEA,OAAO,MAAMC,cAAN,CAAqB;AAG1BC,EAAAA,WAAW,CACUC,OADV,EAET;AAAA,SADmBA,OACnB,GADmBA,OACnB;;AAAA,4CAJkC,KAIlC;AACD;;AAEMC,EAAAA,IAAI,CAACC,cAAD,EAAgC;AACzC,SAAKA,cAAL,GAAsBA,cAAtB;AACD;;AAEMC,EAAAA,KAAK,GAAiC;AAC3C,QAAI,KAAKD,cAAT,EAAyB;AACvB,WAAKF,OAAL,CAAaG,KAAb,CAAmB,YAAnB;AACD;AACF;;AAEMC,EAAAA,IAAI,GAAiC;AAC1C,QAAI,KAAKF,cAAT,EAAyB;AACvB,WAAKF,OAAL,CAAaI,IAAb,CAAkB,YAAlB;AACD;AACF;;AAEMC,EAAAA,GAAG,GAAiC;AACzC,QAAI,KAAKH,cAAT,EAAyB;AACvB,WAAKF,OAAL,CAAaK,GAAb,CAAiB,YAAjB;AACD;AACF;;AAEMC,EAAAA,KAAK,GAAiC;AAC3C,QAAI,KAAKJ,cAAT,EAAyB;AACvB,WAAKF,OAAL,CAAaM,KAAb,CAAmB,YAAnB;AACD;AACF;;AAEMC,EAAAA,KAAK,GAAiC;AAC3C,QAAI,KAAKL,cAAT,EAAyB;AACvB,WAAKF,OAAL,CAAaO,KAAb,CAAmB,YAAnB;AACD;AACF;;AAEMC,EAAAA,IAAI,GAAiC;AAC1C,QAAI,KAAKN,cAAT,EAAyB;AACvB,WAAKF,OAAL,CAAaQ,IAAb,CAAkB,YAAlB;AACD;AACF;;AAEMC,EAAAA,QAAQ,CAACJ,GAAD,EAAuB;AACpC,QAAI,KAAKH,cAAT,EAAyB;AACvB;AACA;AACA,YAAMQ,aAAa,GAAG,CAAC,KAAD,EAAQ,MAAR,EAAgB,OAAhB,EAAyB,OAAzB,EAAkC,MAAlC,EAA0C,OAA1C,CAAtB;AACA,YAAMC,MAAM,GAAGD,aAAa,CAACL,GAAG,CAACO,KAAJ,IAAaf,QAAQ,CAACgB,KAAvB,CAA5B;AACA,YAAMC,GAAG,GAAGT,GAAG,CAACS,GAAJ,GAAW,IAAGT,GAAG,CAACS,GAAI,IAAtB,GAA4B,EAAxC;AACA,YAAMC,QAAQ,GAAG,CAACV,GAAG,CAACW,IAAJ,IAAY,EAAb,EAAiBX,GAAG,CAACM,MAAJ,IAAc,EAA/B,EAAmCN,GAAG,CAACY,IAAJ,IAAY,EAA/C,EAAmDC,MAAnD,CAA0DC,CAAC,IAAIA,CAAC,KAAK,EAArE,EAAyEC,IAAzE,CAA8E,GAA9E,CAAjB;AACA,YAAMC,OAAO,GAAI,GAAEP,GAAI,GAAElB,MAAM,CAACS,GAAG,CAACiB,IAAL,CAAW,IAAGP,QAAS,EAAtD,CAPuB,CASvB;;AACA,WAAKf,OAAL,CAAaW,MAAb,EAAqBU,OAArB;AACD;AACF;;AA7DyB","sourcesContent":["import {format} from 'util';\nimport type {ILogEntry} from \"./types/log\";\nimport {LogLevel} from \"./types/log\";\n\nexport class PrintToConsole {\n protected printToConsole: boolean = false;\n\n constructor(\n protected readonly console: Console,\n ) {\n }\n\n public init(printToConsole: boolean): void {\n this.printToConsole = printToConsole;\n }\n\n public error(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.error(...parameters);\n }\n }\n\n public info(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.info(...parameters);\n }\n }\n\n public log(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.log(...parameters);\n }\n }\n\n public debug(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.debug(...parameters);\n }\n }\n\n public trace(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.trace(...parameters);\n }\n }\n\n public warn(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.warn(...parameters);\n }\n }\n\n public printLog(log: ILogEntry): void {\n if (this.printToConsole) {\n // Log to browser console\n // debug, warning, error, trace, info, fatal\n const levelToMethod = ['log', 'warn', 'error', 'trace', 'info', 'error'];\n const method = levelToMethod[log.level || LogLevel.Debug];\n const tag = log.tag ? `[${log.tag}] ` : '';\n const location = [log.file || '', log.method || '', log.line || ''].filter(p => p !== '').join(':');\n const message = `${tag}${format(log.text)} ${location}`;\n\n // @ts-ignore\n this.console[method](message);\n }\n }\n}\n"]}
|
|
@@ -1,5 +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 { removeUndefinedAttributes } from "./utilities";
|
|
3
4
|
export class SDKOptions {
|
|
4
5
|
constructor() {
|
|
5
6
|
_defineProperty(this, "rules", {
|
|
@@ -17,18 +18,10 @@ export class SDKOptions {
|
|
|
17
18
|
|
|
18
19
|
init(options) {
|
|
19
20
|
// Validate user provided options
|
|
20
|
-
this.validate(options);
|
|
21
|
-
|
|
21
|
+
this.validate(options);
|
|
22
22
|
options = { ...options
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
let [key, value] = _ref;
|
|
26
|
-
|
|
27
|
-
if (value === undefined) {
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
delete options[key];
|
|
30
|
-
}
|
|
31
|
-
}); // Set default values if needed
|
|
24
|
+
removeUndefinedAttributes(options); // Set default values if needed
|
|
32
25
|
|
|
33
26
|
return {
|
|
34
27
|
overrideConsoleMethods: true,
|
|
@@ -42,8 +35,8 @@ export class SDKOptions {
|
|
|
42
35
|
|
|
43
36
|
validate(options) {
|
|
44
37
|
const urlValidator = new RegExp(/^http(s)?:\/\//i);
|
|
45
|
-
Object.entries(this.rules).forEach(
|
|
46
|
-
let [key, rules] =
|
|
38
|
+
Object.entries(this.rules).forEach(_ref => {
|
|
39
|
+
let [key, rules] = _ref;
|
|
47
40
|
// @ts-ignore
|
|
48
41
|
const value = options[key];
|
|
49
42
|
rules.forEach(rule => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["sdk-options.ts"],"names":["SDKOptions","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logBrowserEvents","logUIEvents","registerErrorHandler","version","init","options","validate","
|
|
1
|
+
{"version":3,"sources":["sdk-options.ts"],"names":["removeUndefinedAttributes","SDKOptions","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logBrowserEvents","logUIEvents","registerErrorHandler","version","init","options","validate","enableLogcatLogging","urlValidator","RegExp","Object","entries","rules","forEach","key","value","rule","Error","includes","test"],"mappings":";;AACA,SAAQA,yBAAR,QAAwC,aAAxC;AAEA,OAAO,MAAMC,UAAN,CAAiB;AAAA;AAAA,mCACJ;AAChBC,MAAAA,MAAM,EAAE,CAAC,UAAD,EAAa,QAAb,CADQ;AAEhBC,MAAAA,MAAM,EAAE,CAAC,QAAD,EAAW,KAAX,CAFQ;AAGhBC,MAAAA,OAAO,EAAE,CAAC,QAAD,EAAW,KAAX,CAHO;AAIhBC,MAAAA,sBAAsB,EAAE,CAAC,SAAD,CAJR;AAKhBC,MAAAA,cAAc,EAAE,CAAC,SAAD,CALA;AAMhBC,MAAAA,gBAAgB,EAAE,CAAC,SAAD,CANF;AAOhBC,MAAAA,WAAW,EAAE,CAAC,SAAD,CAPG;AAQhBC,MAAAA,oBAAoB,EAAE,CAAC,SAAD,CARN;AAShBC,MAAAA,OAAO,EAAE,CAAC,QAAD;AATO,KADI;AAAA;;AAafC,EAAAA,IAAI,CAACC,OAAD,EAAoC;AAC7C;AACA,SAAKC,QAAL,CAAcD,OAAd;AAEAA,IAAAA,OAAO,GAAG,EAAE,GAAGA;AAAL,KAAV;AACAZ,IAAAA,yBAAyB,CAACY,OAAD,CAAzB,CAL6C,CAO7C;;AAC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kC,OAAOH,KAAzC,CAAL,EAAsD;AACpD,kBAAM,IAAIE,KAAJ,CAAW,IAAGH,GAAI,6BAAlB,CAAN;AACD;AACF;AACF,OAlBD;AAmBD,KAvBD;AAwBD;;AA1DqB","sourcesContent":["import type {ISDKOptions} from \"./types/sdk-options\";\nimport {removeUndefinedAttributes} from \"./utilities\";\n\nexport class SDKOptions {\n protected rules = {\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 // Validate user provided options\n this.validate(options);\n\n options = { ...options };\n removeUndefinedAttributes(options);\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 ...options,\n };\n }\n\n protected validate(options: ISDKOptions): void {\n const urlValidator = new RegExp(/^http(s)?:\\/\\//i);\n\n Object.entries(this.rules).forEach(([key, rules]) => {\n // @ts-ignore\n const value = options[key];\n\n rules.forEach(rule => {\n if (rule === 'required') {\n if (typeof value === 'undefined') {\n throw new Error(`Bugfender requires '${key}' option to initialize.`)\n }\n } else if (rule === 'string') {\n if (!['string', 'undefined'].includes(typeof value)) {\n throw new Error(`'${key}' option must be a string.`);\n }\n } else if (rule === 'url') {\n if (typeof value !== 'undefined' && !urlValidator.test(value)) {\n throw new Error(`'${key}' option must be a valid URL.`);\n }\n } else if (rule === 'boolean') {\n if (!['boolean', 'undefined'].includes(typeof value)) {\n throw new Error(`'${key}' option must be a boolean.`);\n }\n }\n })\n });\n }\n}\n"]}
|
|
@@ -1,5 +1,14 @@
|
|
|
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
|
+
|
|
3
|
+
import { removeUndefinedAttributes } from "../utilities";
|
|
1
4
|
export class SDKOptionsBuilder {
|
|
2
5
|
constructor(commonOptions) {
|
|
6
|
+
_defineProperty(this, "commonOptions", void 0);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "nativeOptions", void 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "webOptions", void 0);
|
|
11
|
+
|
|
3
12
|
this.commonOptions = commonOptions;
|
|
4
13
|
}
|
|
5
14
|
|
|
@@ -29,16 +38,8 @@ export class SDKOptionsBuilder {
|
|
|
29
38
|
build: (_this$webOptions2 = this.webOptions) === null || _this$webOptions2 === void 0 ? void 0 : _this$webOptions2.build,
|
|
30
39
|
version: (_this$webOptions3 = this.webOptions) === null || _this$webOptions3 === void 0 ? void 0 : _this$webOptions3.version,
|
|
31
40
|
enableLogcatLogging: (_this$nativeOptions = this.nativeOptions) === null || _this$nativeOptions === void 0 ? void 0 : _this$nativeOptions.enableLogcatLogging
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
Object.entries(options).forEach(_ref => {
|
|
35
|
-
let [key, value] = _ref;
|
|
36
|
-
|
|
37
|
-
if (value === undefined) {
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
delete options[key];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
41
|
+
};
|
|
42
|
+
removeUndefinedAttributes(options);
|
|
42
43
|
return options;
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["sdk-options.ts"],"names":["SDKOptionsBuilder","constructor","commonOptions","native","nativeOptions","web","webOptions","build","options","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logUIEvents","registerErrorHandler","deviceName","logBrowserEvents","version","enableLogcatLogging","
|
|
1
|
+
{"version":3,"sources":["sdk-options.ts"],"names":["removeUndefinedAttributes","SDKOptionsBuilder","constructor","commonOptions","native","nativeOptions","web","webOptions","build","options","appKey","apiURL","baseURL","overrideConsole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,IAAAA,yBAAyB,CAACS,OAAD,CAAzB;AAEA,WAAOA,OAAP;AACD;;AAtC4B","sourcesContent":["import {removeUndefinedAttributes} from \"../utilities\";\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 /** 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 };\n\n removeUndefinedAttributes(options);\n\n return options;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["utilities.ts"],"names":["removeUndefinedAttributes","object","Object","entries","forEach","key","value","undefined"],"mappings":"AAAA,OAAO,SAASA,yBAAT,CAAmCC,MAAnC,EAAgD;AACrDC,EAAAA,MAAM,CAACC,OAAP,CAAeF,MAAf,EAAuBG,OAAvB,CAA+B,QAAkB;AAAA,QAAjB,CAACC,GAAD,EAAMC,KAAN,CAAiB;;AAC/C,QAAIA,KAAK,KAAKC,SAAd,EAAyB;AACvB;AACA,aAAON,MAAM,CAACI,GAAD,CAAb;AACD;AACF,GALD;AAMD","sourcesContent":["export function removeUndefinedAttributes(object: any) {\n Object.entries(object).forEach(([key, value]) => {\n if (value === undefined) {\n // @ts-ignore\n delete object[key];\n }\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeUndefinedAttributes(object: any): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bugfender/rn-bugfender",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "React Native bindings for Bugfender SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"pod-install": "^0.1.0",
|
|
71
71
|
"prettier": "^2.0.5",
|
|
72
72
|
"react": "16.13.1",
|
|
73
|
-
"react-native": "0.
|
|
73
|
+
"react-native": "0.64.1",
|
|
74
74
|
"react-native-builder-bob": "^0.18.0",
|
|
75
75
|
"release-it": "^14.2.2",
|
|
76
76
|
"typescript": "^4.1.3"
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
]
|
|
154
154
|
},
|
|
155
155
|
"dependencies": {
|
|
156
|
-
"@bugfender/sdk": "^2.0.0
|
|
156
|
+
"@bugfender/sdk": "^2.0.0",
|
|
157
157
|
"util": "^0.12.4"
|
|
158
158
|
}
|
|
159
159
|
}
|
package/src/sdk-options.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {ISDKOptions} from "./types/sdk-options";
|
|
2
|
+
import {removeUndefinedAttributes} from "./utilities";
|
|
2
3
|
|
|
3
4
|
export class SDKOptions {
|
|
4
5
|
protected rules = {
|
|
@@ -17,14 +18,8 @@ export class SDKOptions {
|
|
|
17
18
|
// Validate user provided options
|
|
18
19
|
this.validate(options);
|
|
19
20
|
|
|
20
|
-
// Removing undefined attributes
|
|
21
21
|
options = { ...options };
|
|
22
|
-
|
|
23
|
-
if (value === undefined) {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
delete options[key];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
22
|
+
removeUndefinedAttributes(options);
|
|
28
23
|
|
|
29
24
|
// Set default values if needed
|
|
30
25
|
return {
|
package/src/types/sdk-options.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {removeUndefinedAttributes} from "../utilities";
|
|
2
|
+
|
|
1
3
|
export interface ISDKCommonOptions {
|
|
2
4
|
/** The app key to log into */
|
|
3
5
|
appKey: string;
|
|
@@ -68,13 +70,7 @@ export class SDKOptionsBuilder {
|
|
|
68
70
|
enableLogcatLogging: this.nativeOptions?.enableLogcatLogging,
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
Object.entries(options).forEach(([key, value]) => {
|
|
73
|
-
if (value === undefined) {
|
|
74
|
-
// @ts-ignore
|
|
75
|
-
delete options[key];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
73
|
+
removeUndefinedAttributes(options);
|
|
78
74
|
|
|
79
75
|
return options;
|
|
80
76
|
}
|
package/src/utilities.ts
ADDED