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

@mongodb-js/compass-logging

Package Overview
Dependencies
Maintainers
0
Versions
493
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongodb-js/compass-logging - npm Package Compare versions

Comparing version 0.0.0-next-80a9e175edd3eabee53daee876d77943872e4205 to 0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730

dist/ipc-logger.d.ts

6

dist/index.d.ts

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

export { createLoggerAndTelemetry } from './logger';
export { createLoggerAndTelemetry as default } from './logger';
export type { LoggerAndTelemetry } from './logger';
export { useLoggerAndTelemetry, useTrackOnChange, withLoggerAndTelemetry, } from './react';
export { createLogger } from './ipc-logger';
export type { Logger } from './logger';
export { mongoLogId } from 'mongodb-log-writer';

@@ -6,0 +4,0 @@ import createDebug from 'debug';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.debug = exports.mongoLogId = exports.withLoggerAndTelemetry = exports.useTrackOnChange = exports.useLoggerAndTelemetry = exports.default = exports.createLoggerAndTelemetry = void 0;
var logger_1 = require("./logger");
Object.defineProperty(exports, "createLoggerAndTelemetry", { enumerable: true, get: function () { return logger_1.createLoggerAndTelemetry; } });
var logger_2 = require("./logger");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return logger_2.createLoggerAndTelemetry; } });
var react_1 = require("./react");
Object.defineProperty(exports, "useLoggerAndTelemetry", { enumerable: true, get: function () { return react_1.useLoggerAndTelemetry; } });
Object.defineProperty(exports, "useTrackOnChange", { enumerable: true, get: function () { return react_1.useTrackOnChange; } });
Object.defineProperty(exports, "withLoggerAndTelemetry", { enumerable: true, get: function () { return react_1.withLoggerAndTelemetry; } });
exports.debug = exports.mongoLogId = exports.createLogger = void 0;
var ipc_logger_1 = require("./ipc-logger");
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return ipc_logger_1.createLogger; } });
var mongodb_log_writer_1 = require("mongodb-log-writer");

@@ -17,0 +11,0 @@ Object.defineProperty(exports, "mongoLogId", { enumerable: true, get: function () { return mongodb_log_writer_1.mongoLogId; } });

import { MongoLogWriter, mongoLogId } from 'mongodb-log-writer';
import createDebug from 'debug';
type TrackProps = Record<string, any> | (() => Record<string, any>);
type TrackFunction = (event: string, properties?: TrackProps) => void;
export type LoggerAndTelemetry = {
export type Logger = {
log: ReturnType<MongoLogWriter['bindComponent']>;
mongoLogId: typeof mongoLogId;
debug: ReturnType<typeof createDebug>;
track: TrackFunction;
};
export declare function createLoggerAndTelemetry(component: string): LoggerAndTelemetry;
export default createLoggerAndTelemetry;
export declare function createGenericLogger(component: string, emit: (event: string, arg: any) => void): Logger;
//# sourceMappingURL=logger.d.ts.map
"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) {

@@ -29,21 +6,13 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.createLoggerAndTelemetry = void 0;
exports.createGenericLogger = void 0;
const mongodb_log_writer_1 = require("mongodb-log-writer");
const is_electron_renderer_1 = __importDefault(require("is-electron-renderer"));
const debug_1 = __importDefault(require("debug"));
let preferences;
function emit(ipc, event, data) {
var _a;
void ((_a = ipc === null || ipc === void 0 ? void 0 : ipc.callQuiet) === null || _a === void 0 ? void 0 : _a.call(ipc, event, data));
if (typeof process !== 'undefined' && typeof process.emit === 'function') {
process.emit(event, data);
}
}
function createLoggerAndTelemetry(component) {
const ipc = is_electron_renderer_1.default
? require('hadron-ipc')
: null;
function createGenericLogger(component, emit) {
// Do not create an actual Writable stream here, since the callback
// logic in Node.js streams would mean that two writes from the
// same event loop tick would not be written synchronously,
// allowing another logger's write to be written out-of-order.
const target = {
write(line, callback) {
emit(ipc, 'compass:log', { line });
emit('compass:log', { line });
callback();

@@ -57,47 +26,2 @@ },

const log = writer.bindComponent(component);
const track = (...args) => {
void Promise.resolve()
.then(() => trackAsync(...args))
.catch((error) => debug('track failed', error));
};
const trackAsync = async (event, properties = {}) => {
try {
preferences !== null && preferences !== void 0 ? preferences : (preferences = (await Promise.resolve().then(() => __importStar(require('compass-preferences-model'))))
.preferencesAccess);
}
catch (_a) {
preferences !== null && preferences !== void 0 ? preferences : (preferences = {
getPreferences() {
return { trackUsageStatistics: true };
},
});
}
const { trackUsageStatistics = true } = preferences === null || preferences === void 0 ? void 0 : preferences.getPreferences();
if (!trackUsageStatistics) {
return;
}
const data = {
event,
properties,
};
if (typeof properties === 'function') {
try {
data.properties = await properties();
}
catch (error) {
emit(ipc, 'compass:track', {
event: 'Error Fetching Attributes',
properties: {
event_name: event,
},
});
log.error((0, mongodb_log_writer_1.mongoLogId)(1001000190), 'Telemetry', 'Error computing event properties for telemetry', {
event,
error: error.stack,
});
return;
}
}
emit(ipc, 'compass:track', data);
};
const debug = (0, debug_1.default)(`mongodb-compass:${component.toLowerCase()}`);

@@ -116,7 +40,5 @@ writer.on('log', ({ s, ctx, msg, attr }) => {

debug,
track,
};
}
exports.createLoggerAndTelemetry = createLoggerAndTelemetry;
exports.default = createLoggerAndTelemetry;
exports.createGenericLogger = createGenericLogger;
//# sourceMappingURL=logger.js.map

@@ -16,3 +16,3 @@ {

"homepage": "https://github.com/mongodb-js/compass",
"version": "0.0.0-next-80a9e175edd3eabee53daee876d77943872e4205",
"version": "0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730",
"repository": {

@@ -23,12 +23,15 @@ "type": "git",

"files": [
"dist"
"dist",
"provider.js"
],
"license": "SSPL",
"peerDependencies": {
"hadron-ipc": "^3.1.3"
"main": "dist/index.js",
"exports": {
".": "./dist/index.js",
"./provider": "./dist/provider.js"
},
"main": "dist/index.js",
"compass:main": "src/index.ts",
"compass:exports": {
".": "./src/index.ts"
".": "./src/index.ts",
"./provider": "./src/provider.ts"
},

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

"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "depcheck",
"depcheck": "compass-scripts check-peer-deps && depcheck",
"check": "npm run lint && npm run depcheck",

@@ -51,15 +54,19 @@ "check-ci": "npm run check",

"test-ci": "npm run test-cov",
"reformat": "npm run prettier -- --write . && npm run eslint . --fix"
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
},
"dependencies": {
"debug": "^4.2.0",
"debug": "^4.3.4",
"hadron-app-registry": "0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730",
"hadron-ipc": "0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730",
"is-electron-renderer": "^2.0.1",
"mongodb-log-writer": "^1.2.0"
"mongodb-log-writer": "^1.4.2",
"react": "^17.0.2"
},
"devDependencies": {
"@mongodb-js/eslint-config-compass": "0.0.0-next-80a9e175edd3eabee53daee876d77943872e4205",
"@mongodb-js/mocha-config-compass": "0.0.0-next-80a9e175edd3eabee53daee876d77943872e4205",
"@mongodb-js/prettier-config-compass": "0.0.0-next-80a9e175edd3eabee53daee876d77943872e4205",
"@mongodb-js/tsconfig-compass": "0.0.0-next-80a9e175edd3eabee53daee876d77943872e4205",
"@mongodb-js/eslint-config-compass": "0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730",
"@mongodb-js/mocha-config-compass": "0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730",
"@mongodb-js/prettier-config-compass": "0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730",
"@mongodb-js/tsconfig-compass": "0.0.0-next-80f6ac0b3460eec09e5e7aa7f17b44a732ed5730",
"@types/chai": "^4.2.21",
"@types/debug": "^4.1.9",
"@types/mocha": "^9.0.0",

@@ -70,3 +77,2 @@ "@types/sinon-chai": "^3.2.5",

"eslint": "^7.25.0",
"hadron-ipc": "0.0.0-next-80a9e175edd3eabee53daee876d77943872e4205",
"mocha": "^10.2.0",

@@ -81,3 +87,3 @@ "nyc": "^15.1.0",

},
"gitHead": "80a9e175edd3eabee53daee876d77943872e4205"
"gitHead": "80f6ac0b3460eec09e5e7aa7f17b44a732ed5730"
}

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

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