Skip to content

Commit 1dc56b5

Browse files
fix: replace thrown errors with logs (#1220)
* fix: Replace Thrown Errors with Logs sss chore(ios): bump sdk to v13.1.0 (#1227) * chore(ios): bump ios sdk v13.1.0 * chore(ios): bump ios sdk v13.1.0 * chore(ios): bump ios sdk v13.1.0 chore(android): bump sdk to v13.1.1 (#1228) * chore(android): bump android sdk v13.1.1 feat: enhance non-fatals support (#1194) * add non fatal api --------- Co-authored-by: Ahmed Mahmoud <[email protected]> fix: read env variable in sourcemap (#1232) * fix sourcemap issue * fix sourcemap issue * fix sourcemap issue * Update typo in CHANGELOG.md --------- Co-authored-by: Andrew Amin <[email protected]> Release:v13.1.1 (#1231) * release/v13.1.1 * Update CHANGELOG.md Update CHANGELOG.md chore(deps): bump @babel/traverse in /examples/default Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.8 to 7.24.6. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.24.6/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> chore(deps): bump follow-redirects from 1.15.2 to 1.15.6 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.6. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.15.2...v1.15.6) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> fix: cont work after logging fix(android): change parameters used in inner class to final (#1239) chore(android): bump sdk to v13.2.0 (#1245) * chore(android): bump sdk to v13.2.0 * chore: update changelog chore(ios): bump sdk to v13.2.0 (#1246) release: v13.2.0 (#1247) chore: resolve issues in changelog (#1249) feat(example): add apm screen (#1141) fix(android): resolve an OOM in network logs (#1244) fix(android): APM network logging(#1253) * fix(android): add W3C External Trace Attributes placeholder * chore: add CHANGLOG * chore: add CHANGLOG * fix: remove ios sub module feat: export upload utils (#1252) chore(example): remove flipper (#1259) fix(android): pass network start time in microseconds (#1260) * fix: network timestamp in android side * fix: PR comments Co-authored-by: Ahmed Elrefaey <[email protected]> --------- Co-authored-by: Ahmed Elrefaey <[email protected]> feat: support feature flags with variants (#1230) Jira ID: MOB-14684 --------- Co-authored-by: Ahmed Elrefaey <[email protected]> chore(android): bump android sdk to v13.3.0 (#1261) chore(ios): bump sdk to v13.3.0 (#1262) release: v13.3.0 (#1263) chore: remove duplicate app flows entries in changelog (#1264) chore: remove duplicate execution traces deprecation in changelog (#1265) feat: navigation tracking support with expo router (#1270) * feat: add screen tracker on screen change listener and tests * feat (example): add screen change listener chore: enhance expo router tracking support (#1272) ci: generalize enterprise releases (#1275) ci: run tests before enterprise releases (#1271) ci: publish snapshots to npm (#1274) fix: PR comments fix(ios): network log empty response body (#1273) fix: drop non-error objects when reporting errors (#1279) * Fix: omitted non-error objects when logging errors * ci: publish snapshots to npm (#1274) * Fix: omitted non-error objects when logging errors * fix: use warn instead of logs Co-authored-by: Ahmed Elrefaey <[email protected]> * Update CHANGELOG.md Co-authored-by: Ahmed Elrefaey <[email protected]> * fix: merge issues --------- Co-authored-by: Ahmed Elrefaey <[email protected]> feat: capture client error in the network interceptor (#1257) * feat/support-capture-client-error-in-xhr-requests --------- Co-authored-by: Abdelhamid Nasser <[email protected]> Co-authored-by: Ahmed Elrefaey <[email protected]> Co-authored-by: kholood <[email protected]> fix: APM test cases * fix: APM test cases * fix test cases * fix: PR comments * fix: PR comments * fix: PR comments
1 parent e4c8a60 commit 1dc56b5

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.4.0...dev)
4+
5+
### Fixed
6+
7+
- Replace thrown errors with logs ([#1220](https://github.com/Instabug/Instabug-React-Native/pull/1220))
8+
39
## [13.4.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.3.0...v13.4.0) (October 2, 2024)
410

511
### Added

src/modules/Instabug.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import * as NetworkLogger from './NetworkLogger';
2525
import { captureUnhandledRejections } from '../utils/UnhandledRejectionTracking';
2626
import type { ReproConfig } from '../models/ReproConfig';
2727
import type { FeatureFlag } from '../models/FeatureFlag';
28+
import InstabugConstants from '../utils/InstabugConstants';
2829

2930
let _currentScreen: string | null = null;
3031
let _lastScreen: string | null = null;
@@ -381,7 +382,8 @@ export const setReproStepsConfig = (config: ReproConfig) => {
381382
*/
382383
export const setUserAttribute = (key: string, value: string) => {
383384
if (!key || typeof key !== 'string' || typeof value !== 'string') {
384-
throw new TypeError('Invalid param, Expected String');
385+
console.error(InstabugConstants.SET_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE);
386+
return;
385387
}
386388
NativeInstabug.setUserAttribute(key, value);
387389
};
@@ -404,7 +406,9 @@ export const getUserAttribute = async (key: string): Promise<string | null> => {
404406
*/
405407
export const removeUserAttribute = (key: string) => {
406408
if (!key || typeof key !== 'string') {
407-
throw new TypeError('Invalid param, Expected String');
409+
console.error(InstabugConstants.REMOVE_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE);
410+
411+
return;
408412
}
409413
NativeInstabug.removeUserAttribute(key);
410414
};

src/utils/InstabugConstants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const InstabugConstants = {
77
'The response body has not been logged because it exceeds the maximum size of 10 Kb',
88
MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE:
99
'The request body has not been logged because it exceeds the maximum size of 10 Kb',
10+
SET_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE:
11+
'IBG-RN: Expected key and value passed to setUserAttribute to be of type string',
12+
REMOVE_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE:
13+
'IBG-RN: Expected key and value passed to removeUserAttribute to be of type string',
1014
};
1115

1216
export default InstabugConstants;

test/modules/APM.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ describe('APM Module', () => {
6262

6363
it("should throw an error if native startExecutionTrace didn't return an ID", async () => {
6464
mocked(NativeAPM).startExecutionTrace.mockResolvedValueOnce(null);
65-
6665
const promise = APM.startExecutionTrace('trace');
6766

6867
await expect(promise).rejects.toThrowError(/trace "trace" wasn't created/i);

test/modules/Instabug.spec.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from '../../src/utils/Enums';
2424
import InstabugUtils from '../../src/utils/InstabugUtils';
2525
import type { FeatureFlag } from '../../src/models/FeatureFlag';
26+
import InstabugConstants from '../../src/utils/InstabugConstants';
2627

2728
describe('Instabug Module', () => {
2829
beforeEach(() => {
@@ -640,10 +641,13 @@ describe('Instabug Module', () => {
640641
[{}, 'value'],
641642
['key', []],
642643
])("should fail if key and value aren't strings when calling setUserAttribute", (key, value) => {
643-
// @ts-ignore
644-
expect(() => Instabug.setUserAttribute(key, value)).toThrow(TypeError);
644+
const logSpy = jest.spyOn(console, 'error');
645645

646+
// @ts-ignore
647+
Instabug.setUserAttribute(key, value);
646648
expect(NativeInstabug.setUserAttribute).not.toBeCalled();
649+
expect(logSpy).toHaveBeenCalledWith(InstabugConstants.SET_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE);
650+
logSpy.mockRestore();
647651
});
648652

649653
it('should call the native method setUserAttribute', () => {
@@ -676,14 +680,17 @@ describe('Instabug Module', () => {
676680
expect(NativeInstabug.removeUserAttribute).toBeCalledWith(key);
677681
});
678682

679-
it.each([null, 1, {}])(
680-
"should fail if key isn't a string when calling removeUserAttribute",
681-
(key) => {
682-
// @ts-ignore
683-
expect(() => Instabug.removeUserAttribute(key)).toThrow(TypeError);
684-
expect(NativeInstabug.removeUserAttribute).not.toBeCalled();
685-
},
686-
);
683+
it.each([[null]])("should fail if key isn't a string when calling removeUserAttribute", (key) => {
684+
const logSpy = jest.spyOn(console, 'error');
685+
686+
// @ts-ignore
687+
Instabug.removeUserAttribute(key);
688+
expect(NativeInstabug.removeUserAttribute).not.toBeCalled();
689+
expect(logSpy).toHaveBeenCalledWith(
690+
InstabugConstants.REMOVE_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE,
691+
);
692+
logSpy.mockRestore();
693+
});
687694

688695
it('should call native method getAllUserAttributes', async () => {
689696
const expected = { type: 'guest' };

0 commit comments

Comments
 (0)