Skip to content

Commit

Permalink
fix: replace thrown errors with logs (#1220)
Browse files Browse the repository at this point in the history
* 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 <68241710+a7medev@users.noreply.github.com>

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 <160974398+AndrewAminInstabug@users.noreply.github.com>

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] <support@github.com>

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] <support@github.com>

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 <68241710+a7medev@users.noreply.github.com>

---------

Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>

feat: support feature flags with variants (#1230)

Jira ID: MOB-14684

---------

Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>

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 <68241710+a7medev@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>

* fix: merge issues

---------

Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>

feat: capture client error in the network interceptor (#1257)

* feat/support-capture-client-error-in-xhr-requests
---------

Co-authored-by: Abdelhamid Nasser <38096011+abdelhamid-f-nasser@users.noreply.github.com>
Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Co-authored-by: kholood <keassa@instabug.com>

fix: APM test cases

* fix: APM test cases

* fix test cases

* fix: PR comments

* fix: PR comments

* fix: PR comments
  • Loading branch information
ahmedAlaaInstabug authored Nov 6, 2024
1 parent e4c8a60 commit 1dc56b5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.4.0...dev)

### Fixed

- Replace thrown errors with logs ([#1220](https://github.com/Instabug/Instabug-React-Native/pull/1220))

## [13.4.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.3.0...v13.4.0) (October 2, 2024)

### Added
Expand Down
8 changes: 6 additions & 2 deletions src/modules/Instabug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as NetworkLogger from './NetworkLogger';
import { captureUnhandledRejections } from '../utils/UnhandledRejectionTracking';
import type { ReproConfig } from '../models/ReproConfig';
import type { FeatureFlag } from '../models/FeatureFlag';
import InstabugConstants from '../utils/InstabugConstants';

let _currentScreen: string | null = null;
let _lastScreen: string | null = null;
Expand Down Expand Up @@ -381,7 +382,8 @@ export const setReproStepsConfig = (config: ReproConfig) => {
*/
export const setUserAttribute = (key: string, value: string) => {
if (!key || typeof key !== 'string' || typeof value !== 'string') {
throw new TypeError('Invalid param, Expected String');
console.error(InstabugConstants.SET_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE);
return;
}
NativeInstabug.setUserAttribute(key, value);
};
Expand All @@ -404,7 +406,9 @@ export const getUserAttribute = async (key: string): Promise<string | null> => {
*/
export const removeUserAttribute = (key: string) => {
if (!key || typeof key !== 'string') {
throw new TypeError('Invalid param, Expected String');
console.error(InstabugConstants.REMOVE_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE);

return;
}
NativeInstabug.removeUserAttribute(key);
};
Expand Down
4 changes: 4 additions & 0 deletions src/utils/InstabugConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const InstabugConstants = {
'The response body has not been logged because it exceeds the maximum size of 10 Kb',
MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE:
'The request body has not been logged because it exceeds the maximum size of 10 Kb',
SET_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE:
'IBG-RN: Expected key and value passed to setUserAttribute to be of type string',
REMOVE_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE:
'IBG-RN: Expected key and value passed to removeUserAttribute to be of type string',
};

export default InstabugConstants;
1 change: 0 additions & 1 deletion test/modules/APM.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ describe('APM Module', () => {

it("should throw an error if native startExecutionTrace didn't return an ID", async () => {
mocked(NativeAPM).startExecutionTrace.mockResolvedValueOnce(null);

const promise = APM.startExecutionTrace('trace');

await expect(promise).rejects.toThrowError(/trace "trace" wasn't created/i);
Expand Down
27 changes: 17 additions & 10 deletions test/modules/Instabug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '../../src/utils/Enums';
import InstabugUtils from '../../src/utils/InstabugUtils';
import type { FeatureFlag } from '../../src/models/FeatureFlag';
import InstabugConstants from '../../src/utils/InstabugConstants';

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

// @ts-ignore
Instabug.setUserAttribute(key, value);
expect(NativeInstabug.setUserAttribute).not.toBeCalled();
expect(logSpy).toHaveBeenCalledWith(InstabugConstants.SET_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE);
logSpy.mockRestore();
});

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

it.each([null, 1, {}])(
"should fail if key isn't a string when calling removeUserAttribute",
(key) => {
// @ts-ignore
expect(() => Instabug.removeUserAttribute(key)).toThrow(TypeError);
expect(NativeInstabug.removeUserAttribute).not.toBeCalled();
},
);
it.each([[null]])("should fail if key isn't a string when calling removeUserAttribute", (key) => {
const logSpy = jest.spyOn(console, 'error');

// @ts-ignore
Instabug.removeUserAttribute(key);
expect(NativeInstabug.removeUserAttribute).not.toBeCalled();
expect(logSpy).toHaveBeenCalledWith(
InstabugConstants.REMOVE_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE,
);
logSpy.mockRestore();
});

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

0 comments on commit 1dc56b5

Please sign in to comment.