@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.
Files changed (90) hide show
  1. package/RnBugfender.podspec +15 -0
  2. package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/7.4.2/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/7.4.2/gc.properties +0 -0
  8. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  10. package/android/.gradle/vcs-1/gc.properties +0 -0
  11. package/android/build.gradle +117 -40
  12. package/android/gradle.properties +5 -0
  13. package/android/src/main/java/com/{bugfender/react → bugfender.react}/RnBugfenderModule.java +0 -0
  14. package/android/src/main/java/com/{bugfender/react → bugfender.react}/RnBugfenderPackage.java +0 -0
  15. package/ios/{RnBugfender.m → RnBugfender.mm} +16 -4
  16. package/ios/RnBugfender.xcodeproj/project.pbxproj +4 -17
  17. package/lib/commonjs/bugfender.js +14 -26
  18. package/lib/commonjs/bugfender.js.map +1 -1
  19. package/lib/commonjs/index.js +2 -2
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/index.web.js +2 -2
  22. package/lib/commonjs/index.web.js.map +1 -1
  23. package/lib/commonjs/override-console-methods.js +9 -9
  24. package/lib/commonjs/override-console-methods.js.map +1 -1
  25. package/lib/commonjs/sdk-options.js +5 -34
  26. package/lib/commonjs/sdk-options.js.map +1 -1
  27. package/lib/commonjs/types/sdk-options.js +2 -2
  28. package/lib/commonjs/types/sdk-options.js.map +1 -1
  29. package/lib/commonjs/user-feedback.js.map +1 -1
  30. package/lib/module/bugfender.js +12 -22
  31. package/lib/module/bugfender.js.map +1 -1
  32. package/lib/module/index.js +1 -1
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/index.web.js +1 -1
  35. package/lib/module/index.web.js.map +1 -1
  36. package/lib/module/override-console-methods.js +9 -9
  37. package/lib/module/override-console-methods.js.map +1 -1
  38. package/lib/module/sdk-options.js +5 -34
  39. package/lib/module/sdk-options.js.map +1 -1
  40. package/lib/module/types/sdk-options.js +2 -2
  41. package/lib/module/types/sdk-options.js.map +1 -1
  42. package/lib/module/user-feedback.js.map +1 -1
  43. package/lib/typescript/bugfender.d.ts +4 -6
  44. package/lib/typescript/index.d.ts +1 -1
  45. package/lib/typescript/index.web.d.ts +1 -1
  46. package/lib/typescript/override-console-methods.d.ts +1 -2
  47. package/lib/typescript/sdk-options.d.ts +2 -12
  48. package/lib/typescript/user-feedback.d.ts +2 -15
  49. package/package.json +26 -22
  50. package/src/bugfender.ts +11 -16
  51. package/src/index.tsx +1 -1
  52. package/src/index.web.tsx +1 -1
  53. package/src/override-console-methods.ts +8 -9
  54. package/src/sdk-options.ts +6 -35
  55. package/src/types/sdk-options.ts +2 -2
  56. package/src/user-feedback.ts +3 -16
  57. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  58. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  59. package/android/gradlew +0 -185
  60. package/android/gradlew.bat +0 -89
  61. package/lib/commonjs/print-to-console.js +0 -78
  62. package/lib/commonjs/print-to-console.js.map +0 -1
  63. package/lib/commonjs/string-formatter.js +0 -55
  64. package/lib/commonjs/string-formatter.js.map +0 -1
  65. package/lib/commonjs/types/device.js +0 -2
  66. package/lib/commonjs/types/device.js.map +0 -1
  67. package/lib/commonjs/types/log.js +0 -35
  68. package/lib/commonjs/types/log.js.map +0 -1
  69. package/lib/commonjs/utilities.js +0 -18
  70. package/lib/commonjs/utilities.js.map +0 -1
  71. package/lib/module/print-to-console.js +0 -67
  72. package/lib/module/print-to-console.js.map +0 -1
  73. package/lib/module/string-formatter.js +0 -45
  74. package/lib/module/string-formatter.js.map +0 -1
  75. package/lib/module/types/device.js +0 -2
  76. package/lib/module/types/device.js.map +0 -1
  77. package/lib/module/types/log.js +0 -24
  78. package/lib/module/types/log.js.map +0 -1
  79. package/lib/module/utilities.js +0 -11
  80. package/lib/module/utilities.js.map +0 -1
  81. package/lib/typescript/print-to-console.d.ts +0 -14
  82. package/lib/typescript/string-formatter.d.ts +0 -4
  83. package/lib/typescript/types/device.d.ts +0 -4
  84. package/lib/typescript/types/log.d.ts +0 -59
  85. package/lib/typescript/utilities.d.ts +0 -1
  86. package/src/print-to-console.ts +0 -67
  87. package/src/string-formatter.ts +0 -44
  88. package/src/types/device.ts +0 -4
  89. package/src/types/log.ts +0 -75
  90. 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 { removeUndefinedAttributes } from "./utilities";
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
- // Validate user provided options
21
- this.validate(options);
22
- options = { ...options
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,"sources":["sdk-options.ts"],"names":["removeUndefinedAttributes","SDKOptions","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logBrowserEvents","logUIEvents","registerErrorHandler","version","init","options","validate","enableLogcatLogging","maximumLocalStorageSize","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,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E,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;;AA3DqB","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 maximumLocalStorageSize: 5 * 1024 * 1024,\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
+ {"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 { removeUndefinedAttributes } from "../utilities";
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
- removeUndefinedAttributes(options);
43
+ removeUndefinedProperties(options);
44
44
  return options;
45
45
  }
46
46
 
@@ -1 +1 @@
1
- {"version":3,"sources":["sdk-options.ts"],"names":["removeUndefinedAttributes","SDKOptionsBuilder","constructor","commonOptions","native","nativeOptions","web","webOptions","build","options","appKey","apiURL","baseURL","overrideConsoleMethods","printToConsole","logUIEvents","registerErrorHandler","deviceName","logBrowserEvents","version","enableLogcatLogging","maximumLocalStorageSize"],"mappings":";;AA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AAAA,yBAAyB,CAACS,OAAD,CAAzB;AAEA,WAAOA,OAAP;AACD;;AAvC4B","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 /** 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 removeUndefinedAttributes(options);\n\n return options;\n }\n}\n"]}
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,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for `Bugfender.getUserFeedback` with customised modal strings.\n */\nexport interface UserFeedbackOptions {\n /** Default: `Feedback`. */\n title?: string;\n /** Default `Please insert your feedback here and click send`. */\n hint?: string;\n /** Default: `Subject…`. */\n subjectPlaceholder?: string;\n /** Default: `Your feedback…`. */\n feedbackPlaceholder?: string;\n /** Default: `Send`. */\n submitLabel?: 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\nexport interface UserFeedbackResult {\n /** `true` if the user has sent the feedback. `false` if she has closed the modal without sending it. */\n isSent: boolean;\n /** If the feedback was sent this will contain the Bugfender URL for the feedback. */\n feedbackURL?: string;\n}\n"]}
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, UserFeedbackResult } from './user-feedback';
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: ILogEntry): void;
121
+ sendLog(log: LogEntry): void;
124
122
  /**
125
123
  * Send an issue.
126
124
  *
@@ -1,4 +1,4 @@
1
- import { LogLevel } from './types/log';
1
+ import { LogLevel } from '@bugfender/common';
2
2
  import { SDKOptionsBuilder } from './types/sdk-options';
3
3
  import { BugfenderClass } from './bugfender';
4
4
  declare const Bugfender: BugfenderClass;
@@ -1,4 +1,4 @@
1
- import { LogLevel } from './types/log';
1
+ import { LogLevel } from '@bugfender/common';
2
2
  import { SDKOptionsBuilder } from './types/sdk-options';
3
3
  import { Bugfender } from '@bugfender/sdk';
4
4
  export { Bugfender, LogLevel, SDKOptionsBuilder };
@@ -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(stringFormatter: StringFormatter): void;
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.0",
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
- "pods": "cd example && pod-install --quiet",
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
- "@commitlint/config-conventional": "^11.0.0",
59
- "@react-native-community/eslint-config": "^2.0.0",
60
- "@release-it/conventional-changelog": "^2.0.0",
61
- "@types/jest": "^26.0.0",
62
- "@types/react": "^16.9.19",
63
- "@types/react-native": "0.62.13",
64
- "commitlint": "^11.0.0",
65
- "eslint": "^7.2.0",
66
- "eslint-config-prettier": "^7.0.0",
67
- "eslint-plugin-prettier": "^3.1.3",
68
- "husky": "^6.0.0",
69
- "jest": "^26.0.1",
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": "16.13.1",
73
- "react-native": "0.64.1",
74
- "react-native-builder-bob": "^0.18.0",
75
- "release-it": "^14.2.2",
76
- "typescript": "^4.1.3"
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/sdk": "^2.1.0",
157
- "util": "^0.12.4"
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, UserFeedbackResult } from './user-feedback';
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(this.stringFormatter);
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 = this.stringFormatter.format([...parameters]);
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 = this.stringFormatter.format([...parameters]);
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 = this.stringFormatter.format([...parameters]);
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 = this.stringFormatter.format([...parameters]);
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 = this.stringFormatter.format([...parameters]);
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 = this.stringFormatter.format([...parameters]);
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: ILogEntry): void {
272
+ public sendLog(log: LogEntry): void {
278
273
  this.printToConsole.printLog(log);
279
274
 
280
275
  RnBugfender.log(
package/src/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { LogLevel } from './types/log';
1
+ import { LogLevel } from '@bugfender/common';
2
2
  import { SDKOptionsBuilder } from './types/sdk-options';
3
3
  import { BugfenderClass } from './bugfender';
4
4
 
package/src/index.web.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { LogLevel } from './types/log';
1
+ import { LogLevel } from '@bugfender/common';
2
2
  import { SDKOptionsBuilder } from './types/sdk-options';
3
3
  import { Bugfender } from '@bugfender/sdk';
4
4
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
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(stringFormatter: StringFormatter): void {
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 = stringFormatter.format([...parameters]);
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 = stringFormatter.format([...parameters]);
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 = stringFormatter.format([...parameters]);
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 = stringFormatter.format([...parameters]);
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 = stringFormatter.format([...parameters]);
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 = stringFormatter.format([...parameters]);
46
+ let message = format([...parameters]);
48
47
  RnBugfender.error('', message);
49
48
  },
50
49
  };
@@ -1,8 +1,8 @@
1
1
  import type {ISDKOptions} from "./types/sdk-options";
2
- import {removeUndefinedAttributes} from "./utilities";
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
- // Validate user provided options
19
- this.validate(options);
18
+ // Prepare options
19
+ options = prepareOptions(options);
20
20
 
21
- options = { ...options };
22
- removeUndefinedAttributes(options);
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
  }
@@ -1,4 +1,4 @@
1
- import {removeUndefinedAttributes} from "../utilities";
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
- removeUndefinedAttributes(options);
76
+ removeUndefinedProperties(options);
77
77
 
78
78
  return options;
79
79
  }
@@ -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
- }
@@ -1,5 +0,0 @@
1
- distributionBase=GRADLE_USER_HOME
2
- distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
4
- zipStoreBase=GRADLE_USER_HOME
5
- zipStorePath=wrapper/dists