@squiz/component-logger-lib
Advanced tools
Comparing version
@@ -8,3 +8,3 @@ export type ComponentLogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR'; | ||
tags?: string; | ||
traceId?: string; | ||
traceid?: string; | ||
} |
export interface ComponentLoggerConfig { | ||
enabled: boolean; | ||
logUrl?: string; | ||
key?: string; | ||
tenantId?: string; | ||
logUrl: string; | ||
key: string; | ||
tenantId: string; | ||
tags?: string; | ||
} |
@@ -11,4 +11,4 @@ import { ComponentLogLevel } from './component-log-message'; | ||
error(message: string | any, traceId?: string): Promise<void>; | ||
append(level: ComponentLogLevel, message: string | any, traceId?: string): Promise<void>; | ||
protected append(level: ComponentLogLevel, message: string | any, traceId?: string): Promise<void>; | ||
flush(): Promise<void>; | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
const superagent_1 = __importDefault(require("superagent")); | ||
const MESSAGE_BATCH_SIZE = 100; | ||
class ComponentLogger { | ||
@@ -45,7 +46,6 @@ constructor(config) { | ||
tags: this.config.tags, | ||
traceId: traceId, | ||
traceid: traceId, | ||
}); | ||
if (this.batch.length == 100) { | ||
if (this.batch.length == MESSAGE_BATCH_SIZE) { | ||
await this.flush(); | ||
this.batch = []; | ||
} | ||
@@ -56,4 +56,5 @@ } | ||
try { | ||
const url = `${this.config.logUrl}/${this.config.tenantId}`; | ||
await superagent_1.default.post(url).set('X-API-Key', this.config.key).send(this.batch); | ||
const url = `${this.config.logUrl.replace(/\/+$/, '')}/${this.config.tenantId}`; | ||
await superagent_1.default.post(url).set('x-api-key', this.config.key).send(this.batch); | ||
this.batch = []; | ||
} | ||
@@ -60,0 +61,0 @@ catch (err) { |
"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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const component_logger_1 = require("./component-logger"); | ||
const process = __importStar(require("process")); | ||
const superagent_1 = __importDefault(require("superagent")); | ||
const postSetMock = { | ||
send: jest.fn(), | ||
}; | ||
const postMock = { | ||
set: () => { | ||
return postSetMock; | ||
}, | ||
}; | ||
jest.mock('superagent', () => ({ | ||
post: () => { | ||
return postMock; | ||
}, | ||
})); | ||
const loggerConfig = { | ||
enabled: true, | ||
logUrl: 'some-log-url', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
describe('ComponentLogger', () => { | ||
it('should allow sending log messages', async () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
beforeAll(() => { | ||
jest.useFakeTimers(); | ||
jest.setSystemTime(new Date('2023-05-28T00:00:00.000Z')); | ||
}); | ||
afterAll(() => { | ||
jest.useRealTimers(); | ||
}); | ||
it('should throw error if config.logUrl is not set', async () => { | ||
const loggerConfig = { | ||
enabled: true, | ||
logUrl: '', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
expect(() => new component_logger_1.ComponentLogger(loggerConfig)).toThrow('config.logUrl is required'); | ||
}); | ||
it('should throw error if config.key is not set', async () => { | ||
const config = { | ||
enabled: JSON.parse((process.env.COMPONENT_LOGGER_ENABLED || 'false').toLocaleLowerCase()), | ||
logUrl: process.env.COMPONENT_LOGGER_URL, | ||
key: process.env.COMPONENT_LOGGER_KEY, | ||
tenantId: process.env.COMPONENT_LOGGER_TENANT_ID, | ||
tags: process.env.COMPONENT_LOGGER_TAGS, | ||
enabled: true, | ||
logUrl: 'some-log-url', | ||
key: '', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
const logger = new component_logger_1.ComponentLogger(config); | ||
expect(() => new component_logger_1.ComponentLogger(config)).toThrow('config.key is required'); | ||
}); | ||
it('should throw error if config.tenantId is not set', async () => { | ||
const loggerConfig = { | ||
enabled: true, | ||
logUrl: 'some-log-url', | ||
key: 'some-key', | ||
tenantId: '', | ||
tags: 'some-tags', | ||
}; | ||
expect(() => new component_logger_1.ComponentLogger(loggerConfig)).toThrow('config.tenantId is required'); | ||
}); | ||
it('should set correct log service URL and API key', async () => { | ||
const postSpy = jest.spyOn(superagent_1.default, 'post'); | ||
const postSetSpy = jest.spyOn(postMock, 'set'); | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
await logger.flush(); | ||
expect(postSpy).toBeCalledWith('some-log-url/some-tenant-id'); | ||
expect(postSetSpy).toBeCalledWith('x-api-key', 'some-key'); | ||
}); | ||
it('should strip off extra "/" on the logUrl', async () => { | ||
const loggerConfig = { | ||
enabled: true, | ||
logUrl: 'some-log-url/', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
const postSpy = jest.spyOn(superagent_1.default, 'post'); | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
await logger.flush(); | ||
expect(postSpy).toBeCalledWith('some-log-url/some-tenant-id'); | ||
}); | ||
it('should not send message if disabled', async () => { | ||
const loggerConfig = { | ||
enabled: false, | ||
logUrl: 'some-log-url', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.warn('this message wont be sent', '123'); | ||
await logger.flush(); | ||
expect(postSetMock.send).toBeCalledTimes(0); | ||
}); | ||
it('should send the log messages in batch', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox 1', '123'); | ||
await logger.info('The quick brown fox 2', '124'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'INFO', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'The quick brown fox 1', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
{ | ||
level: 'INFO', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'The quick brown fox 2', | ||
tags: 'some-tags', | ||
traceid: '124', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should json encode the message if not string', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.warn(['this', 'is', 'not string'], '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'WARN', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: '["this","is","not string"]', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should not send message if there is nothing the message queue', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.flush(); | ||
expect(postSetMock.send).toBeCalledTimes(0); | ||
}); | ||
it('should clear the message queue after sending the message', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
// flushing the log messages again should trigger send only once | ||
await logger.flush(); | ||
await logger.flush(); | ||
await logger.flush(); | ||
await logger.flush(); | ||
expect(postSetMock.send).toBeCalledTimes(1); | ||
}); | ||
it('should not send message till queue reaching the max message count', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
expect(postSetMock.send).toBeCalledTimes(0); | ||
}); | ||
it('should automatically flush the queue after reaching the max message count', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
for (let count = 0; count <= 100; count++) { | ||
await logger.info('The quick brown fox', `${count}`); | ||
} | ||
// this should send all 100 messages above in a single go | ||
expect(postSetMock.send).toBeCalledTimes(1); | ||
}); | ||
it('should send debug message', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.debug('some debug message', '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'DEBUG', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'some debug message', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should send warn message', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.warn('some warn message', '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'WARN', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'some warn message', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should send error message', async () => { | ||
const logger = new component_logger_1.ComponentLogger(loggerConfig); | ||
await logger.error('some error message', '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'ERROR', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'some error message', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
}); | ||
//# sourceMappingURL=component-logger.spec.js.map |
export { ComponentLogger } from './component-logger'; | ||
export { getComponentLogger } from './getComponentLogger'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ComponentLogger = void 0; | ||
exports.getComponentLogger = exports.ComponentLogger = void 0; | ||
var component_logger_1 = require("./component-logger"); | ||
Object.defineProperty(exports, "ComponentLogger", { enumerable: true, get: function () { return component_logger_1.ComponentLogger; } }); | ||
var getComponentLogger_1 = require("./getComponentLogger"); | ||
Object.defineProperty(exports, "getComponentLogger", { enumerable: true, get: function () { return getComponentLogger_1.getComponentLogger; } }); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@squiz/component-logger-lib", | ||
"version": "1.32.1-alpha.22", | ||
"version": "1.32.1-alpha.25", | ||
"description": "", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "jest --passWithNoTests", | ||
"test": "jest -c jest.config.ts", | ||
"test:integration": "jest -c jest.integration.config.ts", | ||
"compile": "tsc" | ||
@@ -16,2 +17,3 @@ }, | ||
"devDependencies": { | ||
"@squiz/dx-common-lib": "1.32.1-alpha.19", | ||
"@types/node": "18.15.2", | ||
@@ -23,3 +25,3 @@ "dotenv": "^16.0.3", | ||
}, | ||
"gitHead": "2ad540de21c3f73986bae9aed062a44e34521b75" | ||
"gitHead": "cd1dce796887c2f5dd7ca3f9f6c3166787e395b3" | ||
} |
@@ -9,3 +9,3 @@ export type ComponentLogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR'; | ||
tags?: string; | ||
traceId?: string; | ||
traceid?: string; | ||
} |
export interface ComponentLoggerConfig { | ||
enabled: boolean; | ||
logUrl?: string; | ||
key?: string; | ||
tenantId?: string; | ||
logUrl: string; | ||
key: string; | ||
tenantId: string; | ||
tags?: string; //TODO: Probably should be an array of key-value pairs? | ||
} |
import { ComponentLogger } from './component-logger'; | ||
import { ComponentLoggerConfig } from './component-logger-config'; | ||
import * as process from 'process'; | ||
import superagent from 'superagent'; | ||
const postSetMock = { | ||
send: jest.fn(), | ||
}; | ||
const postMock = { | ||
set: () => { | ||
return postSetMock; | ||
}, | ||
}; | ||
jest.mock('superagent', () => ({ | ||
post: () => { | ||
return postMock; | ||
}, | ||
})); | ||
const loggerConfig = <ComponentLoggerConfig>{ | ||
enabled: true, | ||
logUrl: 'some-log-url', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
describe('ComponentLogger', () => { | ||
it('should allow sending log messages', async () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
beforeAll(() => { | ||
jest.useFakeTimers(); | ||
jest.setSystemTime(new Date('2023-05-28T00:00:00.000Z')); | ||
}); | ||
afterAll(() => { | ||
jest.useRealTimers(); | ||
}); | ||
it('should throw error if config.logUrl is not set', async () => { | ||
const loggerConfig = <ComponentLoggerConfig>{ | ||
enabled: true, | ||
logUrl: '', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
expect(() => new ComponentLogger(loggerConfig)).toThrow('config.logUrl is required'); | ||
}); | ||
it('should throw error if config.key is not set', async () => { | ||
const config = <ComponentLoggerConfig>{ | ||
enabled: JSON.parse((process.env.COMPONENT_LOGGER_ENABLED || 'false').toLocaleLowerCase()), | ||
logUrl: process.env.COMPONENT_LOGGER_URL, | ||
key: process.env.COMPONENT_LOGGER_KEY, | ||
tenantId: process.env.COMPONENT_LOGGER_TENANT_ID, | ||
tags: process.env.COMPONENT_LOGGER_TAGS, | ||
enabled: true, | ||
logUrl: 'some-log-url', | ||
key: '', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
expect(() => new ComponentLogger(config)).toThrow('config.key is required'); | ||
}); | ||
const logger = new ComponentLogger(config); | ||
it('should throw error if config.tenantId is not set', async () => { | ||
const loggerConfig = <ComponentLoggerConfig>{ | ||
enabled: true, | ||
logUrl: 'some-log-url', | ||
key: 'some-key', | ||
tenantId: '', | ||
tags: 'some-tags', | ||
}; | ||
expect(() => new ComponentLogger(loggerConfig)).toThrow('config.tenantId is required'); | ||
}); | ||
it('should set correct log service URL and API key', async () => { | ||
const postSpy = jest.spyOn(superagent, 'post'); | ||
const postSetSpy = jest.spyOn(postMock, 'set'); | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
await logger.flush(); | ||
expect(postSpy).toBeCalledWith('some-log-url/some-tenant-id'); | ||
expect(postSetSpy).toBeCalledWith('x-api-key', 'some-key'); | ||
}); | ||
it('should strip off extra "/" on the logUrl', async () => { | ||
const loggerConfig = <ComponentLoggerConfig>{ | ||
enabled: true, | ||
logUrl: 'some-log-url/', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
const postSpy = jest.spyOn(superagent, 'post'); | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
await logger.flush(); | ||
expect(postSpy).toBeCalledWith('some-log-url/some-tenant-id'); | ||
}); | ||
it('should not send message if disabled', async () => { | ||
const loggerConfig = <ComponentLoggerConfig>{ | ||
enabled: false, | ||
logUrl: 'some-log-url', | ||
key: 'some-key', | ||
tenantId: 'some-tenant-id', | ||
tags: 'some-tags', | ||
}; | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.warn('this message wont be sent', '123'); | ||
await logger.flush(); | ||
expect(postSetMock.send).toBeCalledTimes(0); | ||
}); | ||
it('should send the log messages in batch', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox 1', '123'); | ||
await logger.info('The quick brown fox 2', '124'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'INFO', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'The quick brown fox 1', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
{ | ||
level: 'INFO', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'The quick brown fox 2', | ||
tags: 'some-tags', | ||
traceid: '124', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should json encode the message if not string', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.warn(['this', 'is', 'not string'], '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'WARN', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: '["this","is","not string"]', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should not send message if there is nothing the message queue', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.flush(); | ||
expect(postSetMock.send).toBeCalledTimes(0); | ||
}); | ||
it('should clear the message queue after sending the message', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
// flushing the log messages again should trigger send only once | ||
await logger.flush(); | ||
await logger.flush(); | ||
await logger.flush(); | ||
await logger.flush(); | ||
expect(postSetMock.send).toBeCalledTimes(1); | ||
}); | ||
it('should not send message till queue reaching the max message count', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.info('The quick brown fox', '123'); | ||
expect(postSetMock.send).toBeCalledTimes(0); | ||
}); | ||
it('should automatically flush the queue after reaching the max message count', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
for (let count = 0; count <= 100; count++) { | ||
await logger.info('The quick brown fox', `${count}`); | ||
} | ||
// this should send all 100 messages above in a single go | ||
expect(postSetMock.send).toBeCalledTimes(1); | ||
}); | ||
it('should send debug message', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.debug('some debug message', '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'DEBUG', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'some debug message', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should send warn message', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.warn('some warn message', '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'WARN', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'some warn message', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
it('should send error message', async () => { | ||
const logger = new ComponentLogger(loggerConfig); | ||
await logger.error('some error message', '123'); | ||
await logger.flush(); | ||
const expectedMessages = [ | ||
{ | ||
level: 'ERROR', | ||
service: 'render-runtime', | ||
timestamp: '2023-05-28T00:00:00.000Z', | ||
message: 'some error message', | ||
tags: 'some-tags', | ||
traceid: '123', | ||
}, | ||
]; | ||
expect(postSetMock.send).toBeCalledWith(expectedMessages); | ||
}); | ||
}); |
@@ -5,2 +5,4 @@ import superagent from 'superagent'; | ||
const MESSAGE_BATCH_SIZE = 100; | ||
export class ComponentLogger { | ||
@@ -39,3 +41,3 @@ private batch: Array<ComponentLogMessage> = []; | ||
async append(level: ComponentLogLevel, message: string | any, traceId?: string): Promise<void> { | ||
protected async append(level: ComponentLogLevel, message: string | any, traceId?: string): Promise<void> { | ||
const payload = typeof message == 'string' ? message : JSON.stringify(message); | ||
@@ -49,8 +51,7 @@ | ||
tags: this.config.tags, | ||
traceId: traceId, | ||
traceid: traceId, | ||
}); | ||
if (this.batch.length == 100) { | ||
if (this.batch.length == MESSAGE_BATCH_SIZE) { | ||
await this.flush(); | ||
this.batch = []; | ||
} | ||
@@ -62,4 +63,5 @@ } | ||
try { | ||
const url = `${this.config.logUrl}/${this.config.tenantId}`; | ||
await superagent.post(url).set('X-API-Key', this.config.key!).send(this.batch); | ||
const url = `${this.config.logUrl.replace(/\/+$/, '')}/${this.config.tenantId}`; | ||
await superagent.post(url).set('x-api-key', this.config.key).send(this.batch); | ||
this.batch = []; | ||
} catch (err) { | ||
@@ -66,0 +68,0 @@ console.error(err); |
export { ComponentLogger } from './component-logger'; | ||
export { getComponentLogger } from './getComponentLogger'; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
113041
223.37%38
46.15%851
218.73%1
-83.33%6
20%1
Infinity%