Skip to content

Commit fbf8d1c

Browse files
authored
Bug fixes & improvements (#15)
* IM-0 - add lint and tsc check to travis * IM-0 - clean before each init * IM-0 - bump version * IM-0 - code clean Co-authored-by: Imran Mentese <imran.mentese@arhs-spikeseed.com>
1 parent 7cb9cc4 commit fbf8d1c

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ node_js:
44
install:
55
- yarn
66
script:
7+
- yarn run tsc
8+
- yarn run lint
79
- yarn run test
810
after_success:
911
- npm run test:cov && bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION

CHANGELOG.md

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

3+
### Version 1.2.1
4+
5+
- BugFixes
6+
- Fix small issue when app refreshed many times
7+
38
### Version 1.2.0
49

510
- News

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "react-native-logging-tools",
33
"title": "React Native library created to ease logging",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"main": "src/index.ts",
66
"typings": "index.d.ts",
77
"scripts": {
88
"prettier:fix": "prettier --config ./.prettierrc.js --write --check \"src/**/*.ts\" ",
9+
"lint": "tslint -p tsconfig.json 'src/**/*.tsx' 'src/**/*.ts'",
910
"lint:fix": "tslint -p tsconfig.json --fix 'src/**/*.tsx' 'src/**/*.ts'",
1011
"precommit": "yarn run prettier:fix && yarn run lint:fix && yarn run tsc",
1112
"test": "TZ=UTC jest",

src/__tests__/index.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
import * as Init from '../modules/init';
1818
import { ITealium } from '../model/tealium';
1919
import { log } from '../modules/events';
20-
import { excludeLogs, loggers } from '../modules/init';
2120

2221
describe('index test suite', () => {
2322
const analytics = {
@@ -72,18 +71,18 @@ describe('index test suite', () => {
7271

7372
it('should init properly empty', () => {
7473
init({});
75-
expect(loggers).toEqual([]);
74+
expect(Init.loggers).toEqual([]);
7675
});
7776

7877
it('should init properly', () => {
7978
init({ config: {}, analytics: [], errorReporters: [] });
80-
expect(loggers).toEqual([]);
79+
expect(Init.loggers).toEqual([]);
8180
});
8281

8382
it('should init properly with wrong analytics and errorReporters', () => {
8483
// @ts-ignore
8584
init({ config: {}, analytics: [{}], errorReporters: [{}] });
86-
expect(loggers).toEqual([]);
85+
expect(Init.loggers).toEqual([]);
8786
});
8887

8988
it('should init properly and log event with reject', () => {
@@ -121,7 +120,7 @@ describe('index test suite', () => {
121120
excludeLogs: { instabug: [DEBUG_LOG] },
122121
},
123122
});
124-
expect(excludeLogs).toEqual({ instabug: [DEBUG_LOG] });
123+
expect(Init.excludeLogs).toEqual({ instabug: [DEBUG_LOG] });
125124
});
126125

127126
// Firebase & Sentry

src/flipper/__tests__/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getCurrentDateTime } from '../../helpers/functions';
33

44
jest.mock('../../helpers/functions', () => ({
55
getCurrentDateTime: jest.fn(),
6-
}))
6+
}));
77

88
describe('flipper test suite', () => {
99
it('should init properly flipper and send event', () => {

src/helpers/functions.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export const isFunction = (func: any) => func && typeof func === 'function';
1313
*
1414
* @return return current date and hour
1515
*/
16-
export const getCurrentDateTime = (date = new Date()) => {
17-
return `${date.getFullYear()}-${
18-
date.getMonth() + 1
19-
}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
20-
};
16+
export const getCurrentDateTime = (date = new Date()) =>
17+
`${date.getFullYear()}-${date.getMonth() +
18+
1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;

src/modules/init/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ export let Reactotron: any;
1414
export let AsyncStorage: any;
1515
export let isSensitiveBuild: boolean;
1616

17-
export const loggers: Function[] = [];
18-
export const recordErrors: Function[] = [];
17+
export let loggers: Function[] = [];
18+
export let recordErrors: Function[] = [];
1919
export let excludeLogs: IExcludeLogs = {};
2020

21+
function clean() {
22+
loggers = [];
23+
recordErrors = [];
24+
}
25+
2126
export function init(initConfig: IInit): void {
27+
clean();
28+
2229
if (initConfig.config) {
2330
if (initConfig.config.useFlipperPlugin) {
2431
flipperConnectionManager = new FlipperConnectionManager();

0 commit comments

Comments
 (0)