New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aircall/logger

Package Overview
Dependencies
Maintainers
4
Versions
60
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 0.0.11 to 0.0.12

21

dist/actions.d.ts

@@ -9,19 +9,12 @@ export declare enum LOGGER {

export interface LoggerLog {
type: LOGGER;
message: string;
properties: any;
properties: object;
}
export declare const init: (message: string, properties?: any) => {
export declare const init: () => {
type: LOGGER.INIT;
};
export declare const info: (message: string, properties?: any) => LoggerLog & {
type: LOGGER.INFO;
};
export declare const warn: (message: string, properties?: any) => LoggerLog & {
type: LOGGER.WARN;
};
export declare const error: (message: string, properties?: any) => LoggerLog & {
type: LOGGER.ERROR;
};
export declare const track: (message: string, properties?: any) => LoggerLog & {
type: LOGGER.TRACK;
};
export declare const info: (message: string, properties?: object) => LoggerLog;
export declare const warn: (message: string, properties?: object) => LoggerLog;
export declare const error: (message: string, properties?: object) => LoggerLog;
export declare const track: (message: string, properties?: object) => LoggerLog;

@@ -11,6 +11,6 @@ "use strict";

})(LOGGER = exports.LOGGER || (exports.LOGGER = {}));
exports.init = (message, properties) => ({
exports.init = () => ({
type: LOGGER.INIT
});
exports.info = (message, properties) => ({
exports.info = (message, properties = {}) => ({
type: LOGGER.INFO,

@@ -20,3 +20,3 @@ message,

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

@@ -26,3 +26,3 @@ message,

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

@@ -32,3 +32,3 @@ message,

});
exports.track = (message, properties) => ({
exports.track = (message, properties = {}) => ({
type: LOGGER.TRACK,

@@ -35,0 +35,0 @@ message,

export declare type LoggerLevel = 'INFO' | 'WARN' | 'ERROR';
export declare type LoggerIdentificationOptions = {
export interface LoggerIdentificationOptions {
user_id: string;

@@ -8,7 +8,7 @@ app_version: string;

environment: string;
};
export declare type LoggerInitOptions = {
}
export interface LoggerInitOptions {
debugMode: boolean;
key: string;
};
}
export default class Logger {

@@ -24,6 +24,6 @@ private initialized;

private log;
info(message: string, properties?: any): void;
warn(message: string, properties?: any): void;
error(message: string, properties?: any): void;
track(event: string, properties?: any, integrations?: any): void;
info(message: string, properties?: object): void;
warn(message: string, properties?: object): void;
error(message: string, properties?: object): void;
track(event: string, properties?: object, integrations?: object): void;
}

@@ -31,12 +31,12 @@ "use strict";

}
log(level, message, properties) {
log(level, message, properties = {}) {
this.track('log', Object.assign({ level, message }, properties), { 'All': false, 'Amazon Kinesis': true });
}
info(message, properties) {
info(message, properties = {}) {
this.log('INFO', message, properties);
}
warn(message, properties) {
warn(message, properties = {}) {
this.log('WARN', message, properties);
}
error(message, properties) {
error(message, properties = {}) {
this.log('ERROR', message, properties);

@@ -46,3 +46,3 @@ }

if (this.debugMode) {
console.log(event, Object.assign({}, properties, this.identification));
console.log(event, Object.assign({}, properties, this.identification)); // eslint-disable-line no-console
}

@@ -49,0 +49,0 @@ else {

@@ -9,3 +9,5 @@ "use strict";

let logger = new Logger_1.default();
beforeEach(() => logger = new Logger_1.default());
beforeEach(() => {
logger = new Logger_1.default();
});
describe('Logger', () => {

@@ -16,11 +18,6 @@ it('should be an instance of Logger', () => {

describe('init', () => {
it('should call getScriptTag', () => {
const spy = jest.spyOn(logger, 'getScriptTag');
logger.init(initOptions);
expect(spy).toHaveBeenCalledWith(initOptions.key);
});
it('should inject a script tag', () => {
const spy = jest.spyOn(document.head, 'appendChild');
logger.init(initOptions);
expect(document.head.appendChild).toHaveBeenCalledWith(expect.any(HTMLScriptElement));
expect(spy).toHaveBeenCalledWith(expect.any(HTMLScriptElement));
});

@@ -27,0 +24,0 @@ });

{
"name": "@aircall/logger",
"version": "0.0.11",
"version": "0.0.12",
"main": "dist/index.js",

@@ -13,6 +13,6 @@ "types": "dist/index.d.ts",

},
"dependencies": {
"@aircall/types": "^0.0.2"
},
"gitHead": "5c7555238372b2eb47a8f3ec47ca9986f1c2b92d"
"gitHead": "92f3ab92e98b377f17ab2dba05ce437ed8b28c34",
"devDependencies": {
"@types/segment-analytics": "^0.0.31"
}
}

@@ -10,32 +10,33 @@ export enum LOGGER {

export interface LoggerLog {
type: LOGGER;
message: string;
properties: any;
properties: object;
}
export const init = (message: string, properties?: any): { type: LOGGER.INIT } => ({
type: LOGGER.INIT
export const init = (): { type: LOGGER.INIT } => ({
type: LOGGER.INIT
});
export const info = (message: string, properties?: any): LoggerLog & { type: LOGGER.INFO } => ({
type: LOGGER.INFO,
message,
properties
export const info = (message: string, properties: object = {}): LoggerLog => ({
type: LOGGER.INFO,
message,
properties
});
export const warn = (message: string, properties?: any): LoggerLog & { type: LOGGER.WARN } => ({
type: LOGGER.WARN,
message,
properties
export const warn = (message: string, properties: object = {}): LoggerLog => ({
type: LOGGER.WARN,
message,
properties
});
export const error = (message: string, properties?: any): LoggerLog & { type: LOGGER.ERROR } => ({
type: LOGGER.ERROR,
message,
properties
export const error = (message: string, properties: object = {}): LoggerLog => ({
type: LOGGER.ERROR,
message,
properties
});
export const track = (message: string, properties?: any): LoggerLog & { type: LOGGER.TRACK } => ({
type: LOGGER.TRACK,
message,
properties
export const track = (message: string, properties: object = {}): LoggerLog => ({
type: LOGGER.TRACK,
message,
properties
});
import Logger from './Logger';
import { LoggerInitOptions } from '@aircall/types';
const initOptions: LoggerInitOptions = {
key: 'FOO',
debugMode: false
const initOptions = {
key: 'FOO',
debugMode: false
};

@@ -11,28 +10,24 @@

beforeEach(() => logger = new Logger());
beforeEach((): void => {
logger = new Logger();
});
describe('Logger', () => {
describe('Logger', (): void => {
it('should be an instance of Logger', () => {
expect(logger).toBeInstanceOf(Logger);
});
it('should be an instance of Logger', (): void => {
expect(logger).toBeInstanceOf(Logger);
});
describe('init', () => {
describe('init', (): void => {
it('should call getScriptTag', () => {
const spy = jest.spyOn<any, string>(logger, 'getScriptTag');
logger.init(initOptions);
expect(spy).toHaveBeenCalledWith(initOptions.key);
});
it('should inject a script tag', (): void => {
const spy: jest.SpyInstance = jest.spyOn(document.head, 'appendChild');
logger.init(initOptions);
expect(spy).toHaveBeenCalledWith(expect.any(HTMLScriptElement));
});
it('should inject a script tag', () => {
const spy = jest.spyOn<any, string>(document.head, 'appendChild');
logger.init(initOptions);
expect(document.head.appendChild).toHaveBeenCalledWith(expect.any(HTMLScriptElement));
});
});
});
});
interface WindowWithAnalytics extends Window {
analytics: any;
analytics: SegmentAnalytics.AnalyticsJS;
}

@@ -7,3 +7,3 @@

export type LoggerIdentificationOptions = {
export interface LoggerIdentificationOptions {
user_id: string;

@@ -14,8 +14,8 @@ app_version: string;

environment: string;
};
}
export type LoggerInitOptions = {
export interface LoggerInitOptions {
debugMode: boolean;
key: string;
};
}

@@ -33,8 +33,8 @@

private onInitialized() {
private onInitialized(): void {
this.initialized = true;
}
private getScriptTag(key: LoggerInitOptions['key']) {
const script = document.createElement('script');
private getScriptTag(key: LoggerInitOptions['key']): HTMLScriptElement {
const script: HTMLScriptElement = document.createElement('script');

@@ -49,4 +49,4 @@ script.type = 'text/javascript';

public init(options: LoggerInitOptions) {
const script = this.getScriptTag(options.key);
public init(options: LoggerInitOptions): void {
const script: HTMLScriptElement = this.getScriptTag(options.key);

@@ -58,3 +58,3 @@ this.debugMode = options.debugMode;

public identify(options: LoggerIdentificationOptions) {
public identify(options: LoggerIdentificationOptions): void {
(window as WindowWithAnalytics).analytics.identify(options.user_id, options);

@@ -65,21 +65,21 @@ this.identification = options;

private log(level: LoggerLevel, message: string, properties?: any): void {
private log(level: LoggerLevel, message: string, properties: object = {}): void {
this.track('log', { level, message, ...properties }, { 'All': false, 'Amazon Kinesis': true });
}
public info(message: string, properties?: any): void {
public info(message: string, properties: object = {}): void {
this.log('INFO', message, properties);
}
public warn(message: string, properties?: any): void {
public warn(message: string, properties: object = {}): void {
this.log('WARN', message, properties);
}
public error(message: string, properties?: any): void {
public error(message: string, properties: object = {}): void {
this.log('ERROR', message, properties);
}
public track(event: string, properties: any = {}, integrations: any = {}) {
public track(event: string, properties: object = {}, integrations: object = {}): void {
if (this.debugMode) {
console.log(event, { ...properties, ...this.identification });
console.log(event, { ...properties, ...this.identification }); // eslint-disable-line no-console
} else {

@@ -86,0 +86,0 @@ (window as WindowWithAnalytics).analytics.track(event, { ...properties, ...this.identification }, {

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

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