Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

@aircall/logger

Package Overview
Dependencies
Maintainers
8
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aircall/logger - npm Package Compare versions

Comparing version
2.3.3
to
2.3.4
+15
-0
CHANGELOG.md

@@ -6,2 +6,17 @@ # Change Log

## [2.3.4](http://bitbucket.org/aircall/front-end-modules/compare/@aircall/logger@2.3.3...@aircall/logger@2.3.4) (2020-04-09)
### Bug Fixes
* **logger:** rename variable ([0457ea8](http://bitbucket.org/aircall/front-end-modules/commits/0457ea8f3830ab5c1c7bd63b3034b86c5ac7cfd1))
* prettify ([a4f45d6](http://bitbucket.org/aircall/front-end-modules/commits/a4f45d68053b300f8a5ba933242d7d44b2bda6fd))
* **logger:** create the logger singleton from the consumer context ([b05c79b](http://bitbucket.org/aircall/front-end-modules/commits/b05c79b45ee41f18cdfcc1d9b335f1e73f3d9a00))
* **logger:** make the middleware accept an instance of the logger ([9783d48](http://bitbucket.org/aircall/front-end-modules/commits/9783d4826f0d05b0f17bee7bccf70bc65b5cfc2c))
* **logger:** make the middleware accept an instance of the logger ([40f5d5a](http://bitbucket.org/aircall/front-end-modules/commits/40f5d5ab1b32cb4a1845aca86fd651f327031bb6))
## [2.3.3](http://bitbucket.org/aircall/front-end-modules/compare/@aircall/logger@2.3.2...@aircall/logger@2.3.3) (2020-04-02)

@@ -8,0 +23,0 @@

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;AAGA,IAAY,MAOX;AAPD,WAAY,MAAM;IAChB,8BAAoB,CAAA;IACpB,4BAAkB,CAAA;IAClB,gCAAsB,CAAA;IACtB,8BAAoB,CAAA;IACpB,8BAAoB,CAAA;IACpB,gCAAsB,CAAA;AACxB,CAAC,EAPW,MAAM,GAAN,cAAM,KAAN,cAAM,QAOjB;AAQD,MAAM,k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CAAC,CAAC;AAEU,QAAA,KAAK,GAAG,CAAC,OAAe,EAAE,aAAqB,EAAE,EAAmB,EAAE,CAAC,CAAC;IACnF,IAAI,EAAE,MAAM,CAAC,KAAK;IAClB,OAAO;IACP,UAAU;CACX,CAAC,CAAC"}

@@ -1,1 +0,1 @@

export declare const DEUBG_MODE_LIMIT_STORED_ACTIONS = 20;
export declare const DEBUG_MODE_LIMIT_STORED_ACTIONS = 20;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Number of stored actions for the debug mode;
exports.DEUBG_MODE_LIMIT_STORED_ACTIONS = 20;
exports.DEBUG_MODE_LIMIT_STORED_ACTIONS = 20;
//# sourceMappingURL=constants.js.map

@@ -1,6 +0,3 @@

import Logger from './Logger';
declare const logger: Logger;
export * from './actions';
export * from './middleware';
export * from './Logger';
export default logger;

@@ -6,8 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const Logger_1 = require("./Logger");
const logger = new Logger_1.default();
__export(require("./actions"));
__export(require("./middleware"));
__export(require("./Logger"));
exports.default = logger;
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,qCAA8B;AAE9B,MAAM,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAC;AAE5B,+BAA0B;AAC1B,kCAA6B;AAC7B,8BAAyB;AAEzB,kBAAe,MAAM,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,+BAA0B;AAC1B,kCAA6B;AAC7B,8BAAyB"}

@@ -30,3 +30,3 @@ import { StatusType } from '@datadog/browser-logs';

}
export default class Logger {
export declare class Logger {
initialized: boolean;

@@ -33,0 +33,0 @@ queue: Function[];

@@ -64,3 +64,3 @@ "use strict";

}
exports.default = Logger;
exports.Logger = Logger;
//# sourceMappingURL=Logger.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"Log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,UAAqB,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF;AA5DD,wBA4DC"}

@@ -1,2 +0,6 @@

import { Action, Middleware, Dispatch } from 'redux';
export declare const loggerMiddleware: Middleware<{}, Action, Dispatch<Action>>;
import { Action, Dispatch } from 'redux';
import { Logger } from './Logger';
declare type actionInterceptor = (action: Action) => Action;
declare type loggerMiddlewareReturnType = (next: Dispatch<Action>) => actionInterceptor;
export declare const loggerMiddleware: (logger: Logger) => () => loggerMiddlewareReturnType;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("./");
const browser_logs_1 = require("@datadog/browser-logs");
const constants_1 = require("./constants");
const actions_1 = require("./actions");
exports.loggerMiddleware = () => {
const lastDispatchedActions = [];
return (next) => (action) => {
if (_1.default.level !== browser_logs_1.StatusType.debug) {
exports.loggerMiddleware = (logger) => {
return () => {
const lastDispatchedActions = [];
return (next) => (action) => {
if (logger.level !== browser_logs_1.StatusType.debug) {
return next(action);
}
if (actions_1.isLoggerAction(action)) {
action.properties.lastDispatchedActions = lastDispatchedActions;
}
else {
lastDispatchedActions.push({ type: action.type });
}
if (lastDispatchedActions.length > constants_1.DEBUG_MODE_LIMIT_STORED_ACTIONS) {
lastDispatchedActions.shift();
}
return next(action);
}
if (actions_1.isLoggerAction(action)) {
action.properties.lastDispatchedActions = lastDispatchedActions;
}
else {
lastDispatchedActions.push({ type: action.type });
}
if (lastDispatchedActions.length > constants_1.DEUBG_MODE_LIMIT_STORED_ACTIONS) {
lastDispatchedActions.shift();
}
return next(action);
};
};
};
//# sourceMappingURL=middleware.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AACxB,wDAAmD;AAEnD,2CAA8D;AAC9D,uCAA2C;AAK9B,QAAA,gBAAgB,GAA8C,GAA+B,EAAE;IAC1G,MAAM,qBAAqB,GAAa,EAAE,CAAC;IAE3C,OAAO,CAAC,IA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AK,EAAE,CAAC;aAC/B;YAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
{
"name": "@aircall/logger",
"version": "2.3.3",
"version": "2.3.4",
"main": "dist/index.js",

@@ -14,3 +14,3 @@ "types": "dist/index.d.ts",

},
"gitHead": "b78b28cbf565454ebe6f37580f3f8df9609bc857",
"gitHead": "6574e120a8b34fe9032587850a0aa3f775c2c808",
"dependencies": {

@@ -17,0 +17,0 @@ "@datadog/browser-logs": "1.7.3",

global.console = {
log: jest.fn(),
log: jest.fn(),
debug: jest.fn(),

@@ -10,9 +10,9 @@ info: jest.fn(),

global.DD_LOGS = {
init: jest.fn(),
logger: {
setContext: jest.fn(),
setLevel: jest.fn(),
setHandler: jest.fn(),
info: jest.fn()
}
init: jest.fn(),
logger: {
setContext: jest.fn(),
setLevel: jest.fn(),
setHandler: jest.fn(),
info: jest.fn()
}
};

@@ -1,15 +0,16 @@

import { isLoggerAction, LOGGER, initLogger,log, debug, info, warn, error } from './actions';
import { isLoggerAction, LOGGER, initLogger, log, debug, info, warn, error } from './actions';
import { LOGGER_LEVEL } from './Logger';
describe('actions', (): void => {
describe('isLoggerAction', (): void => {
it('should return false if it is not a logger action', (): void => {
expect(isLoggerAction({type: 'FOO'})).toBeFalsy();
expect(isLoggerAction({ type: 'FOO' })).toBeFalsy();
});
it('should return true if it is a logger action', (): void => {
[ LOGGER.LOG, LOGGER.DEBUG, LOGGER.INFO, LOGGER.WARN, LOGGER.ERROR ].forEach((type: LOGGER): void => {
expect(isLoggerAction({ type })).toBeTruthy();
});
[LOGGER.LOG, LOGGER.DEBUG, LOGGER.INFO, LOGGER.WARN, LOGGER.ERROR].forEach(
(type: LOGGER): void => {
expect(isLoggerAction({ type })).toBeTruthy();
}
);
});

@@ -16,0 +17,0 @@ });

@@ -19,5 +19,6 @@ import { Action } from 'redux';

const loggerActionsTypes = [ LOGGER.LOG, LOGGER.DEBUG, LOGGER.INFO, LOGGER.WARN, LOGGER.ERROR ];
const loggerActionsTypes = [LOGGER.LOG, LOGGER.DEBUG, LOGGER.INFO, LOGGER.WARN, LOGGER.ERROR];
export const isLoggerAction = (action: Action): action is LoggerLogAction => loggerActionsTypes.includes(action.type);
export const isLoggerAction = (action: Action): action is LoggerLogAction =>
loggerActionsTypes.includes(action.type);

@@ -28,3 +29,7 @@ export const initLogger = (): { type: LOGGER.INIT } => ({

export const log = (level: StatusType, message: string, properties: object = {}): LoggerLogAction & { level: StatusType } => ({
export const log = (
level: StatusType,
message: string,
properties: object = {}
): LoggerLogAction & { level: StatusType } => ({
type: LOGGER.LOG,

@@ -31,0 +36,0 @@ level,

// Number of stored actions for the debug mode;
export const DEUBG_MODE_LIMIT_STORED_ACTIONS = 20;
export const DEBUG_MODE_LIMIT_STORED_ACTIONS = 20;

@@ -1,9 +0,3 @@

import Logger from './Logger';
const logger = new Logger();
export * from './actions';
export * from './middleware';
export * from './Logger';
export default logger;
jest.mock('@datadog/browser-logs');
import Logger, { LOGGER_ENVIRONMENT, LOGGER_LEVEL } from './Logger';
import { Logger, LOGGER_ENVIRONMENT, LOGGER_LEVEL } from './Logger';
import { datadogLogs, StatusType } from '@datadog/browser-logs';
const properties = { foo: 'BAR' };
const [ message, token ] = [ 'MESSAGE', 'TOKEN'];
const [message, token] = ['MESSAGE', 'TOKEN'];

@@ -21,3 +21,2 @@ const user_session = {

describe('Logger', (): void => {
it('should be an instance of Logger', (): void => {

@@ -96,5 +95,2 @@ expect(logger).toBeInstanceOf(Logger);

});
});

@@ -36,3 +36,3 @@ import { datadogLogs as sdk, StatusType, HandlerType } from '@datadog/browser-logs';

export default class Logger {
export class Logger {
public initialized = false;

@@ -44,3 +44,4 @@ public queue: Function[] = [];

public init({ level, context, token }: LoggerInitOptions): void {
const isDevelopment: boolean = context.user_session.environment === LOGGER_ENVIRONMENT.DEVELOPMENT;
const isDevelopment: boolean =
context.user_session.environment === LOGGER_ENVIRONMENT.DEVELOPMENT;

@@ -97,3 +98,2 @@ sdk.init({

}
}

@@ -1,3 +0,3 @@

import logger, { LOGGER, LOGGER_LEVEL } from './';
import { DEUBG_MODE_LIMIT_STORED_ACTIONS } from './constants';
import { Logger, LOGGER, LOGGER_LEVEL } from './';
import { DEBUG_MODE_LIMIT_STORED_ACTIONS } from './constants';
import { loggerMiddleware } from './middleware';

@@ -8,4 +8,5 @@

describe('loggerMiddleware', (): void => {
const logger = new Logger();
const handler = jest.fn();
const store = createStore(handler, undefined, applyMiddleware(loggerMiddleware));
const store = createStore(handler, undefined, applyMiddleware(loggerMiddleware(logger)));
const fooAction = { type: 'FOO' };

@@ -27,13 +28,16 @@ const infoAction = { type: LOGGER.INFO, properties: {} };

store.dispatch(infoAction);
expect(handler).toHaveBeenCalledWith(undefined, { ...infoAction, properties: { lastDispatchedActions: [fooAction] } });
expect(handler).toHaveBeenCalledWith(undefined, {
...infoAction,
properties: { lastDispatchedActions: [fooAction] }
});
});
it('should keep only the last DEUBG_MODE_LIMIT_STORED_ACTIONS actions dispatched', (): void => {
it('should keep only the last DEBUG_MODE_LIMIT_STORED_ACTIONS actions dispatched', (): void => {
logger.setLevel(LOGGER_LEVEL.debug);
for (let i = 0; i < DEUBG_MODE_LIMIT_STORED_ACTIONS + 5; i ++) {
for (let i = 0; i < DEBUG_MODE_LIMIT_STORED_ACTIONS + 5; i++) {
store.dispatch(fooAction);
}
const lastDispatchedActions = (new Array(DEUBG_MODE_LIMIT_STORED_ACTIONS)).fill(fooAction);
const lastDispatchedActions = new Array(DEBUG_MODE_LIMIT_STORED_ACTIONS).fill(fooAction);

@@ -47,3 +51,2 @@ store.dispatch(infoAction);

});
});

@@ -1,6 +0,6 @@

import logger from './';
import { StatusType } from '@datadog/browser-logs';
import { Action, Middleware, Dispatch } from 'redux';
import { DEUBG_MODE_LIMIT_STORED_ACTIONS } from './constants';
import { Action, Dispatch } from 'redux';
import { DEBUG_MODE_LIMIT_STORED_ACTIONS } from './constants';
import { isLoggerAction } from './actions';
import { Logger } from './Logger';

@@ -10,23 +10,24 @@ type actionInterceptor = (action: Action) => Action;

export const loggerMiddleware: Middleware <{}, Action, Dispatch<Action>> = (): loggerMiddlewareReturnType => {
const lastDispatchedActions: Action[] = [];
export const loggerMiddleware = (logger: Logger) => {
return (): loggerMiddlewareReturnType => {
const lastDispatchedActions: Action[] = [];
return (next: Dispatch<Action>): actionInterceptor => (action: Action): Action => {
return (next: Dispatch<Action>): actionInterceptor => (action: Action): Action => {
if (logger.level !== StatusType.debug) {
return next(action);
}
if (logger.level !== StatusType.debug) {
return next(action);
}
if (isLoggerAction(action)) {
action.properties.lastDispatchedActions = lastDispatchedActions;
} else {
lastDispatchedActions.push({ type: action.type });
}
if (isLoggerAction(action)) {
action.properties.lastDispatchedActions = lastDispatchedActions;
} else {
lastDispatchedActions.push({ type: action.type });
}
if (lastDispatchedActions.length > DEBUG_MODE_LIMIT_STORED_ACTIONS) {
lastDispatchedActions.shift();
}
if (lastDispatchedActions.length > DEUBG_MODE_LIMIT_STORED_ACTIONS) {
lastDispatchedActions.shift();
}
return next(action);
return next(action);
};
};
};
import logger from './index';
import Logger from './Logger';
describe('logger', (): void => {
it('should return an instance of Logger', (): void => {
expect(logger).toBeInstanceOf(Logger);
});
});