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

@backtrace/node

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backtrace/node - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

lib/storage/FsNodeFileSystem.d.ts

2

lib/BacktraceClient.d.ts

@@ -5,4 +5,6 @@ import { BacktraceCoreClient } from '@backtrace/sdk-core';

import { BacktraceNodeClientSetup } from './builder/BacktraceClientSetup';
import { NodeFileSystem } from './storage/interfaces/NodeFileSystem';
export declare class BacktraceClient extends BacktraceCoreClient<BacktraceConfiguration> {
private _listeners;
protected get nodeFileSystem(): NodeFileSystem | undefined;
constructor(clientSetup: BacktraceNodeClientSetup);

@@ -9,0 +11,0 @@ initialize(): void;

7

lib/breadcrumbs/FileBreadcrumbsStorage.d.ts
import { BacktraceAttachment, BreadcrumbsStorage, RawBreadcrumb, SessionFiles } from '@backtrace/sdk-core';
import { NodeFileSystem } from '../storage/interfaces/NodeFileSystem';
export declare class FileBreadcrumbsStorage implements BreadcrumbsStorage {

@@ -8,5 +9,5 @@ private readonly _mainFile;

private readonly _writer;
constructor(_mainFile: string, _fallbackFile: string, maximumBreadcrumbs: number);
static createFromSession(session: SessionFiles): FileBreadcrumbsStorage | undefined;
static create(session: SessionFiles, maximumBreadcrumbs: number): FileBreadcrumbsStorage;
constructor(_mainFile: string, _fallbackFile: string, fileSystem: NodeFileSystem, maximumBreadcrumbs: number);
static createFromSession(session: SessionFiles, fileSystem: NodeFileSystem): FileBreadcrumbsStorage | undefined;
static create(session: SessionFiles, fileSystem: NodeFileSystem, maximumBreadcrumbs: number): FileBreadcrumbsStorage;
getAttachments(): BacktraceAttachment<unknown>[];

@@ -13,0 +14,0 @@ add(rawBreadcrumb: RawBreadcrumb): number;

import { PartialCoreClientSetup } from '@backtrace/sdk-core';
import { BacktraceSetupConfiguration } from '../BacktraceConfiguration';
import { NodeFileSystem } from '../storage/interfaces/NodeFileSystem';
export interface BacktraceClientSetup extends PartialCoreClientSetup<'sdkOptions' | 'requestHandler'> {

@@ -7,2 +8,3 @@ }

readonly options: BacktraceSetupConfiguration;
readonly fileSystem?: NodeFileSystem;
};

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

import { NodeFileSystem } from '../storage/interfaces/NodeFileSystem';
export declare class AlternatingFileWriter {

@@ -5,9 +6,12 @@ private readonly _mainFile;

private readonly _fileCapacity;
private readonly _fileSystem;
private _fileStream?;
private _count;
private _disposed;
constructor(_mainFile: string, _fallbackFile: string, _fileCapacity: number);
constructor(_mainFile: string, _fallbackFile: string, _fileCapacity: number, _fileSystem: NodeFileSystem);
writeLine(value: string): Promise<this>;
private writeAsync;
private safeWriteAsync;
dispose(): void;
private safeCreateStream;
private safeMoveMainToFallback;
}

@@ -32,14 +32,18 @@ /******/ (() => { // webpackBootstrap

const NodeDiagnosticReportConverter_1 = __webpack_require__(745);
const NodeFileSystem_1 = __webpack_require__(360);
const FsNodeFileSystem_1 = __webpack_require__(558);
class BacktraceClient extends sdk_core_1.BacktraceCoreClient {
get nodeFileSystem() {
return this.fileSystem;
}
constructor(clientSetup) {
var _a, _b, _c, _d;
super(Object.assign(Object.assign({ sdkOptions: agentDefinition_1.AGENT, requestHandler: new BacktraceNodeRequestHandler_1.BacktraceNodeRequestHandler(clientSetup.options), debugIdMapProvider: new sdk_core_1.VariableDebugIdMapProvider(global), fileSystem: new NodeFileSystem_1.NodeFileSystem() }, clientSetup), { options: Object.assign(Object.assign({}, clientSetup.options), { attachments: (_a = clientSetup.options.attachments) === null || _a === void 0 ? void 0 : _a.map(transformAttachments_1.transformAttachment) }) }));
var _a, _b, _c, _d, _e;
const fileSystem = (_a = clientSetup.fileSystem) !== null && _a !== void 0 ? _a : new FsNodeFileSystem_1.FsNodeFileSystem();
super(Object.assign(Object.assign({ sdkOptions: agentDefinition_1.AGENT, requestHandler: new BacktraceNodeRequestHandler_1.BacktraceNodeRequestHandler(clientSetup.options), debugIdMapProvider: new sdk_core_1.VariableDebugIdMapProvider(global) }, clientSetup), { fileSystem, options: Object.assign(Object.assign({}, clientSetup.options), { attachments: (_b = clientSetup.options.attachments) === null || _b === void 0 ? void 0 : _b.map(transformAttachments_1.transformAttachment) }) }));
this._listeners = {};
const breadcrumbsManager = this.modules.get(sdk_core_1.BreadcrumbsManager);
if (breadcrumbsManager && this.sessionFiles) {
breadcrumbsManager.setStorage(FileBreadcrumbsStorage_1.FileBreadcrumbsStorage.create(this.sessionFiles, (_c = (_b = clientSetup.options.breadcrumbs) === null || _b === void 0 ? void 0 : _b.maximumBreadcrumbs) !== null && _c !== void 0 ? _c : 100));
breadcrumbsManager.setStorage(FileBreadcrumbsStorage_1.FileBreadcrumbsStorage.create(this.sessionFiles, fileSystem, (_d = (_c = clientSetup.options.breadcrumbs) === null || _c === void 0 ? void 0 : _c.maximumBreadcrumbs) !== null && _d !== void 0 ? _d : 100));
}
if (this.sessionFiles && this.fileSystem && ((_d = clientSetup.options.database) === null || _d === void 0 ? void 0 : _d.captureNativeCrashes)) {
this.addModule(sdk_core_1.FileAttributeManager, sdk_core_1.FileAttributeManager.create(this.fileSystem));
if (this.sessionFiles && ((_e = clientSetup.options.database) === null || _e === void 0 ? void 0 : _e.captureNativeCrashes)) {
this.addModule(sdk_core_1.FileAttributeManager, sdk_core_1.FileAttributeManager.create(fileSystem));
}

@@ -196,3 +200,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
if (!this.database || !this.fileSystem || !((_a = this.options.database) === null || _a === void 0 ? void 0 : _a.captureNativeCrashes)) {
if (!this.database || !this.nodeFileSystem || !((_a = this.options.database) === null || _a === void 0 ? void 0 : _a.captureNativeCrashes)) {
return;

@@ -206,3 +210,3 @@ }

try {
databaseFiles = yield this.fileSystem.readDir(databasePath);
databaseFiles = yield this.nodeFileSystem.readDir(databasePath);
}

@@ -224,3 +228,3 @@ catch (_g) {

try {
const recordJson = yield this.fileSystem.readFile(recordPath);
const recordJson = yield this.nodeFileSystem.readFile(recordPath);
const report = converter.convert(JSON.parse(recordJson));

@@ -245,7 +249,7 @@ reports.push([recordPath, report]);

if (session) {
const breadcrumbsStorage = FileBreadcrumbsStorage_1.FileBreadcrumbsStorage.createFromSession(session);
const breadcrumbsStorage = FileBreadcrumbsStorage_1.FileBreadcrumbsStorage.createFromSession(session, this.nodeFileSystem);
if (breadcrumbsStorage) {
report.attachments.push(...breadcrumbsStorage.getAttachments());
}
const fileAttributes = sdk_core_1.FileAttributeManager.createFromSession(session, this.fileSystem);
const fileAttributes = sdk_core_1.FileAttributeManager.createFromSession(session, this.nodeFileSystem);
Object.assign(report.attributes, yield fileAttributes.get());

@@ -267,3 +271,3 @@ report.attributes['application.session'] = session.sessionId;

try {
yield this.fileSystem.unlink(recordPath);
yield this.nodeFileSystem.unlink(recordPath);
}

@@ -455,3 +459,3 @@ catch (_k) {

agent: "@backtrace/node",
agentVersion: "0.1.1",
agentVersion: "0.1.2",
};

@@ -1012,9 +1016,9 @@

}
constructor(_mainFile, _fallbackFile, maximumBreadcrumbs) {
constructor(_mainFile, _fallbackFile, fileSystem, maximumBreadcrumbs) {
this._mainFile = _mainFile;
this._fallbackFile = _fallbackFile;
this._lastBreadcrumbId = sdk_core_1.TimeHelper.toTimestampInSec(sdk_core_1.TimeHelper.now());
this._writer = new AlternatingFileWriter_1.AlternatingFileWriter(_mainFile, _fallbackFile, maximumBreadcrumbs);
this._writer = new AlternatingFileWriter_1.AlternatingFileWriter(_mainFile, _fallbackFile, Math.floor(maximumBreadcrumbs / 2), fileSystem);
}
static createFromSession(session) {
static createFromSession(session, fileSystem) {
const files = session

@@ -1027,8 +1031,8 @@ .getSessionFiles()

}
return new FileBreadcrumbsStorage(files[0], files[1], 1);
return new FileBreadcrumbsStorage(files[0], files[1], fileSystem, 1);
}
static create(session, maximumBreadcrumbs) {
static create(session, fileSystem, maximumBreadcrumbs) {
const file1 = session.getFileName(this.getFileName(0));
const file2 = session.getFileName(this.getFileName(1));
return new FileBreadcrumbsStorage(file1, file2, maximumBreadcrumbs);
return new FileBreadcrumbsStorage(file1, file2, fileSystem, maximumBreadcrumbs);
}

@@ -1107,3 +1111,3 @@ getAttachments() {

/***/ 636:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
/***/ (function(__unused_webpack_module, exports) {

@@ -1120,13 +1124,10 @@

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AlternatingFileWriter = void 0;
const fs_1 = __importDefault(__webpack_require__(147));
class AlternatingFileWriter {
constructor(_mainFile, _fallbackFile, _fileCapacity) {
constructor(_mainFile, _fallbackFile, _fileCapacity, _fileSystem) {
this._mainFile = _mainFile;
this._fallbackFile = _fallbackFile;
this._fileCapacity = _fileCapacity;
this._fileSystem = _fileSystem;
this._count = 0;

@@ -1144,11 +1145,19 @@ this._disposed = false;

if (!this._fileStream) {
this._fileStream = fs_1.default.createWriteStream(this._mainFile, 'utf-8');
const stream = this.safeCreateStream(this._mainFile);
if (!stream) {
return this;
}
this._fileStream = stream;
}
else if (this._count >= this._fileCapacity) {
this._fileStream.close();
yield fs_1.default.promises.rename(this._mainFile, this._fallbackFile);
this.safeMoveMainToFallback();
this._count = 0;
this._fileStream = fs_1.default.createWriteStream(this._mainFile, 'utf-8');
const stream = this.safeCreateStream(this._mainFile);
if (!stream) {
return this;
}
this._fileStream = stream;
}
yield this.writeAsync(this._fileStream, value + '\n');
yield this.safeWriteAsync(this._fileStream, value + '\n');
this._count++;

@@ -1158,4 +1167,4 @@ return this;

}
writeAsync(fs, data) {
return new Promise((resolve, reject) => fs.write(data, (err) => (err ? reject(err) : resolve())));
safeWriteAsync(fs, data) {
return new Promise((resolve) => fs.write(data, (err) => (err ? resolve(false) : resolve(true))));
}

@@ -1167,2 +1176,19 @@ dispose() {

}
safeCreateStream(path) {
try {
return this._fileSystem.createWriteStream(path);
}
catch (_a) {
return undefined;
}
}
safeMoveMainToFallback() {
try {
this._fileSystem.renameSync(this._mainFile, this._fallbackFile);
return true;
}
catch (_a) {
return false;
}
}
}

@@ -1350,3 +1376,3 @@ exports.AlternatingFileWriter = AlternatingFileWriter;

/***/ 360:
/***/ 558:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

@@ -1368,6 +1394,6 @@

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.NodeFileSystem = void 0;
exports.FsNodeFileSystem = void 0;
const fs_1 = __importDefault(__webpack_require__(147));
const attachment_1 = __webpack_require__(577);
class NodeFileSystem {
class FsNodeFileSystem {
readDir(dir) {

@@ -1403,2 +1429,13 @@ return fs_1.default.promises.readdir(dir);

}
rename(oldPath, newPath) {
return fs_1.default.promises.rename(oldPath, newPath);
}
renameSync(oldPath, newPath) {
fs_1.default.renameSync(oldPath, newPath);
}
createWriteStream(path) {
const stream = fs_1.default.createWriteStream(path, 'utf-8');
stream.writeSync = (chunk) => stream.write(chunk);
return stream;
}
exists(path) {

@@ -1422,3 +1459,3 @@ return __awaiter(this, void 0, void 0, function* () {

}
exports.NodeFileSystem = NodeFileSystem;
exports.FsNodeFileSystem = FsNodeFileSystem;

@@ -1425,0 +1462,0 @@

{
"name": "@backtrace/node",
"version": "0.1.1",
"version": "0.1.2",
"description": "Backtrace-JavaScript Node.JS integration",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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