Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aircall/logger

Package Overview
Dependencies
Maintainers
5
Versions
58
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.8.2 to 2.8.3

scripts/validations/build-validate-schema.mjs

4

CHANGELOG.md

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

## [2.8.3](https://gitlab.com/aircall/shared/front-end-modules/compare/@aircall/logger@2.8.2...@aircall/logger@2.8.3) (2023-01-13)
**Note:** Version bump only for package @aircall/logger
## [2.8.2](https://gitlab.com/aircall/shared/front-end-modules/compare/@aircall/logger@2.8.1...@aircall/logger@2.8.2) (2023-01-05)

@@ -8,0 +12,0 @@

28

dist/actions.js

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.error = exports.warn = exports.info = exports.debug = exports.log = exports.initLogger = exports.isLoggerAction = exports.LOGGER = void 0;
var LOGGER;
export var LOGGER;
(function (LOGGER) {

@@ -12,11 +9,9 @@ LOGGER["INIT"] = "LOGGER_INIT";

LOGGER["ERROR"] = "LOGGER_ERROR";
})(LOGGER = exports.LOGGER || (exports.LOGGER = {}));
})(LOGGER || (LOGGER = {}));
const loggerActionsTypes = [LOGGER.LOG, LOGGER.DEBUG, LOGGER.INFO, LOGGER.WARN, LOGGER.ERROR];
const isLoggerAction = (action) => loggerActionsTypes.includes(action.type);
exports.isLoggerAction = isLoggerAction;
const initLogger = () => ({
export const isLoggerAction = (action) => loggerActionsTypes.includes(action.type);
export const initLogger = () => ({
type: LOGGER.INIT
});
exports.initLogger = initLogger;
const log = (level, message, properties = {}) => ({
export const log = (level, message, properties = {}) => ({
type: LOGGER.LOG,

@@ -27,4 +22,3 @@ level,

});
exports.log = log;
const debug = (message, properties = {}) => ({
export const debug = (message, properties = {}) => ({
type: LOGGER.DEBUG,

@@ -34,4 +28,3 @@ message,

});
exports.debug = debug;
const info = (message, properties = {}) => ({
export const info = (message, properties = {}) => ({
type: LOGGER.INFO,

@@ -41,4 +34,3 @@ message,

});
exports.info = info;
const warn = (message, properties = {}) => ({
export const warn = (message, properties = {}) => ({
type: LOGGER.WARN,

@@ -48,4 +40,3 @@ message,

});
exports.warn = warn;
const error = (message, properties = {}) => ({
export const error = (message, properties = {}) => ({
type: LOGGER.ERROR,

@@ -55,3 +46,2 @@ message,

});
exports.error = error;
//# sourceMappingURL=actions.js.map
export declare const DEBUG_MODE_LIMIT_STORED_ACTIONS = 20;
export declare const SENSITIVE_KEYS: string[];
export declare const DEFAULT_SENSITIVE_TEXT = "<sensitive>";
export declare const CUSTOM_LOG_SCHEMA_KEYWORDS: string[];

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CUSTOM_LOG_SCHEMA_KEYWORDS = exports.DEFAULT_SENSITIVE_TEXT = exports.SENSITIVE_KEYS = exports.DEBUG_MODE_LIMIT_STORED_ACTIONS = void 0;
// Number of stored actions for the debug mode;
exports.DEBUG_MODE_LIMIT_STORED_ACTIONS = 20;
export const DEBUG_MODE_LIMIT_STORED_ACTIONS = 20;
// List of keys that we need to check against to see if it needs to be hidden.
exports.SENSITIVE_KEYS = [
export const SENSITIVE_KEYS = [
'password',

@@ -16,15 +13,3 @@ 'Authorization',

];
exports.DEFAULT_SENSITIVE_TEXT = '<sensitive>';
// Our common log schema relies on those custom keywords
// @see https://ajv.js.org/strict-mode.html#json-schema-schemas
exports.CUSTOM_LOG_SCHEMA_KEYWORDS = [
'destination',
'bytes_read',
'bytes_written',
'connectivity',
'downlink_kbps',
'signal_strength',
'uplink_kbps',
'useragent_details'
];
export const DEFAULT_SENSITIVE_TEXT = '<sensitive>';
//# sourceMappingURL=constants.js.map

@@ -1,20 +0,4 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./actions"), exports);
__exportStar(require("./middleware"), exports);
__exportStar(require("./Logger"), exports);
export * from './actions';
export * from './middleware';
export * from './Logger';
//# sourceMappingURL=index.js.map

@@ -1,11 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = exports.LOGGER_ENVIRONMENT = exports.LOGGER_LEVEL = void 0;
const browser_logs_1 = require("@datadog/browser-logs");
Object.defineProperty(exports, "LOGGER_LEVEL", { enumerable: true, get: function () { return browser_logs_1.StatusType; } });
const constants_1 = require("./constants");
const utils_1 = require("./utils");
import { datadogLogs as sdk, StatusType, HandlerType } from '@datadog/browser-logs';
import { SENSITIVE_KEYS, DEFAULT_SENSITIVE_TEXT } from './constants';
import { containsAValue, isString, deepMap, isObject, isArray } from './utils';
// @ts-ignore
const validate_schema_1 = require("./validate-schema");
var LOGGER_ENVIRONMENT;
import validate from './validate-schema';
export { StatusType as LOGGER_LEVEL };
export var LOGGER_ENVIRONMENT;
(function (LOGGER_ENVIRONMENT) {

@@ -17,4 +14,4 @@ LOGGER_ENVIRONMENT["DEVELOPMENT"] = "development";

LOGGER_ENVIRONMENT["PRODUCTION"] = "production";
})(LOGGER_ENVIRONMENT = exports.LOGGER_ENVIRONMENT || (exports.LOGGER_ENVIRONMENT = {}));
class Logger {
})(LOGGER_ENVIRONMENT || (LOGGER_ENVIRONMENT = {}));
export class Logger {
constructor() {

@@ -27,4 +24,4 @@ this.initialized = false;

const isDevelopment = context.user_session.environment === LOGGER_ENVIRONMENT.DEVELOPMENT;
this.compiledLogSchema = validate_schema_1.default;
browser_logs_1.datadogLogs.init({
this.compiledLogSchema = validate;
sdk.init({
clientToken: token,

@@ -38,3 +35,3 @@ datacenter: 'us',

this.setContext(context);
browser_logs_1.datadogLogs.logger.setHandler(isDevelopment ? browser_logs_1.HandlerType.console : browser_logs_1.HandlerType.http);
sdk.logger.setHandler(isDevelopment ? HandlerType.console : HandlerType.http);
this.setLevel(level);

@@ -77,3 +74,3 @@ this.initialized = true;

const currentDate = new Date(Date.now());
const datadogInternalContext = browser_logs_1.datadogLogs.getInternalContext();
const datadogInternalContext = sdk.getInternalContext();
log.version = version;

@@ -89,3 +86,3 @@ log.env = environment;

setContext(context) {
browser_logs_1.datadogLogs.logger.setContext(context);
sdk.logger.setContext(context);
}

@@ -99,13 +96,13 @@ // Send logs or enqueue them if the SDK isn't initialized

this.level = level;
browser_logs_1.datadogLogs.logger.setLevel(level);
sdk.logger.setLevel(level);
}
// It will scrub the properties which their keys contains some sensitive keywords
cleanProperties(properties = {}) {
return (0, utils_1.deepMap)(properties, (value, key) => {
return deepMap(properties, (value, key) => {
try {
const parsedValue = (0, utils_1.isString)(value) && JSON.parse(value);
const parsedValue = isString(value) && JSON.parse(value);
// We need to make sure that the parsed value is actually an object or an array before
// re-executing the `cleanProperties` on it because JSON.parse('10') for instance
// return 10 and doesn't throw an error.
if ((0, utils_1.isObject)(parsedValue) || (0, utils_1.isArray)(parsedValue)) {
if (isObject(parsedValue) || isArray(parsedValue)) {
return JSON.stringify(this.cleanProperties(parsedValue));

@@ -117,5 +114,5 @@ }

}
const keyContainsSensitiveData = (0, utils_1.isString)(key) && (0, utils_1.containsAValue)(key, constants_1.SENSITIVE_KEYS);
const keyContainsSensitiveData = isString(key) && containsAValue(key, SENSITIVE_KEYS);
if (keyContainsSensitiveData) {
return constants_1.DEFAULT_SENSITIVE_TEXT;
return DEFAULT_SENSITIVE_TEXT;
}

@@ -128,3 +125,3 @@ return value;

const cleanedProperties = this.cleanProperties(properties);
this.logOrEnqueue(() => browser_logs_1.datadogLogs.logger.log(message, cleanedProperties, level));
this.logOrEnqueue(() => sdk.logger.log(message, cleanedProperties, level));
}

@@ -134,3 +131,3 @@ // Send debug logs

const cleanedProperties = this.cleanProperties(properties);
this.logOrEnqueue(() => browser_logs_1.datadogLogs.logger.debug(message, cleanedProperties));
this.logOrEnqueue(() => sdk.logger.debug(message, cleanedProperties));
}

@@ -140,3 +137,3 @@ // Send info logs

const cleanedProperties = this.cleanProperties(properties);
this.logOrEnqueue(() => browser_logs_1.datadogLogs.logger.info(message, cleanedProperties));
this.logOrEnqueue(() => sdk.logger.info(message, cleanedProperties));
}

@@ -146,3 +143,3 @@ // Send warning logs

const cleanedProperties = this.cleanProperties(properties);
this.logOrEnqueue(() => browser_logs_1.datadogLogs.logger.warn(message, cleanedProperties));
this.logOrEnqueue(() => sdk.logger.warn(message, cleanedProperties));
}

@@ -152,6 +149,5 @@ // Send error logs

const cleanedProperties = this.cleanProperties(properties);
this.logOrEnqueue(() => browser_logs_1.datadogLogs.logger.error(message, cleanedProperties));
this.logOrEnqueue(() => sdk.logger.error(message, cleanedProperties));
}
}
exports.Logger = Logger;
//# sourceMappingURL=Logger.js.map

@@ -1,15 +0,12 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loggerMiddleware = void 0;
const browser_logs_1 = require("@datadog/browser-logs");
const constants_1 = require("./constants");
const actions_1 = require("./actions");
const loggerMiddleware = (logger) => {
import { StatusType } from '@datadog/browser-logs';
import { DEBUG_MODE_LIMIT_STORED_ACTIONS } from './constants';
import { isLoggerAction } from './actions';
export const loggerMiddleware = (logger) => {
return () => {
const lastDispatchedActions = [];
return (next) => (action) => {
if (logger.level !== browser_logs_1.StatusType.debug) {
if (logger.level !== StatusType.debug) {
return next(action);
}
if ((0, actions_1.isLoggerAction)(action)) {
if (isLoggerAction(action)) {
action.properties.lastDispatchedActions = lastDispatchedActions;

@@ -20,3 +17,3 @@ }

}
if (lastDispatchedActions.length > constants_1.DEBUG_MODE_LIMIT_STORED_ACTIONS) {
if (lastDispatchedActions.length > DEBUG_MODE_LIMIT_STORED_ACTIONS) {
lastDispatchedActions.shift();

@@ -28,3 +25,2 @@ }

};
exports.loggerMiddleware = loggerMiddleware;
//# sourceMappingURL=middleware.js.map

@@ -1,9 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isString = exports.containsAValue = exports.deepMap = exports.map = exports.mapObject = exports.isObject = exports.isArray = void 0;
const isArray = (value) => Array.isArray(value);
exports.isArray = isArray;
const isObject = (value) => value !== null && typeof value === 'object';
exports.isObject = isObject;
const mapObject = (object, iteratee) => {
export const isArray = (value) => Array.isArray(value);
export const isObject = (value) => value !== null && typeof value === 'object';
export const mapObject = (object, iteratee) => {
const source = {};

@@ -18,13 +13,11 @@ for (const key in object) {

};
exports.mapObject = mapObject;
const map = (value, iteratee) => {
if ((0, exports.isArray)(value)) {
export const map = (value, iteratee) => {
if (isArray(value)) {
return value.map((element, index) => iteratee(element, index, value));
}
if ((0, exports.isObject)(value)) {
return (0, exports.mapObject)(value, (value, key) => iteratee(value, key, value));
if (isObject(value)) {
return mapObject(value, (value, key) => iteratee(value, key, value));
}
};
exports.map = map;
const deepMap = (object, iteratee, maxDepth = 10) => {
export const deepMap = (object, iteratee, maxDepth = 10) => {
let count = 0;

@@ -36,4 +29,4 @@ const closure = (object, iteratee) => {

}
return (0, exports.map)(object, (value, key) => {
if ((0, exports.isArray)(value) || (0, exports.isObject)(value)) {
return map(object, (value, key) => {
if (isArray(value) || isObject(value)) {
count++;

@@ -48,4 +41,3 @@ return closure(value, iteratee);

};
exports.deepMap = deepMap;
const containsAValue = (value, keys) => {
export const containsAValue = (value, keys) => {
// Empty values should always return false

@@ -57,7 +49,5 @@ if (!value) {

};
exports.containsAValue = containsAValue;
function isString(value) {
export function isString(value) {
return typeof value === 'string';
}
exports.isString = isString;
//# sourceMappingURL=utils.js.map
{
"name": "@aircall/logger",
"version": "2.8.2",
"version": "2.8.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"compile:schema:validation": "rm -rf src/validate-schema.js && ts-node src/validations/logSchema.ts",
"compile:schema:validation": "rm -rf src/validate-schema.js && ts-node scripts/validations/build-validate-schema.mjs",
"prestart": "yarn compile:schema:validation",

@@ -17,3 +17,3 @@ "prebuild": "yarn compile:schema:validation",

},
"gitHead": "f56e14dde828c80b6d68afaa1f56972a669249a6",
"gitHead": "8b834c28bfd294b3c6094b1b3103f033cd57f227",
"dependencies": {

@@ -20,0 +20,0 @@ "@datadog/browser-logs": "4.23.3",

@@ -16,14 +16,1 @@ // Number of stored actions for the debug mode;

export const DEFAULT_SENSITIVE_TEXT = '<sensitive>';
// Our common log schema relies on those custom keywords
// @see https://ajv.js.org/strict-mode.html#json-schema-schemas
export const CUSTOM_LOG_SCHEMA_KEYWORDS = [
'destination',
'bytes_read',
'bytes_written',
'connectivity',
'downlink_kbps',
'signal_strength',
'uplink_kbps',
'useragent_details'
];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc