@mongodb-js/compass-logging
Advanced tools
Comparing version 0.0.0-next-0d9e77c42a99b49fd4ecc7167d0c769866f92ef2 to 0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128
@@ -1,12 +0,6 @@ | ||
import { MongoLogWriter, mongoLogId } from 'mongodb-log-writer'; | ||
export { createLogger } from './ipc-logger'; | ||
export type { Logger } from './logger'; | ||
export { mongoLogId } from 'mongodb-log-writer'; | ||
import createDebug from 'debug'; | ||
declare type TrackProps = Record<string, any> | (() => Record<string, any>); | ||
declare type TrackFunction = (event: string, properties?: TrackProps) => void; | ||
export declare function createLoggerAndTelemetry(component: string): { | ||
log: ReturnType<MongoLogWriter['bindComponent']>; | ||
mongoLogId: typeof mongoLogId; | ||
debug: ReturnType<typeof createDebug>; | ||
track: TrackFunction; | ||
}; | ||
export default createLoggerAndTelemetry; | ||
export declare const debug: createDebug.Debugger; | ||
//# sourceMappingURL=index.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,87 +6,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createLoggerAndTelemetry = void 0; | ||
const mongodb_log_writer_1 = require("mongodb-log-writer"); | ||
const is_electron_renderer_1 = __importDefault(require("is-electron-renderer")); | ||
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"); | ||
Object.defineProperty(exports, "mongoLogId", { enumerable: true, get: function () { return mongodb_log_writer_1.mongoLogId; } }); | ||
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; | ||
const target = { | ||
write(line, callback) { | ||
emit(ipc, 'compass:log', { line }); | ||
callback(); | ||
}, | ||
end(callback) { | ||
callback(); | ||
}, | ||
}; | ||
const writer = new mongodb_log_writer_1.MongoLogWriter('', null, target); | ||
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, | ||
}, | ||
}); | ||
return; | ||
} | ||
} | ||
emit(ipc, 'compass:track', data); | ||
}; | ||
const debug = (0, debug_1.default)(`mongodb-compass:${component.toLowerCase()}`); | ||
writer.on('log', ({ s, ctx, msg, attr }) => { | ||
if (attr) { | ||
debug(msg, { s, ctx, ...attr }); | ||
} | ||
else { | ||
debug(msg, { s, ctx }); | ||
} | ||
}); | ||
return { | ||
log: writer.bindComponent(component), | ||
mongoLogId: mongodb_log_writer_1.mongoLogId, | ||
debug, | ||
track, | ||
}; | ||
} | ||
exports.createLoggerAndTelemetry = createLoggerAndTelemetry; | ||
exports.default = createLoggerAndTelemetry; | ||
exports.debug = (0, debug_1.default)('mongodb-compass'); | ||
//# sourceMappingURL=index.js.map |
@@ -16,3 +16,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/compass", | ||
"version": "0.0.0-next-0d9e77c42a99b49fd4ecc7167d0c769866f92ef2", | ||
"version": "0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128", | ||
"repository": { | ||
@@ -23,12 +23,15 @@ "type": "git", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"provider.js" | ||
], | ||
"license": "SSPL", | ||
"peerDependencies": { | ||
"hadron-ipc": "^3.1.0" | ||
"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,22 +46,26 @@ "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", | ||
"check-ci": "npm run check", | ||
"test": "mocha", | ||
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", | ||
"test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", | ||
"test-watch": "npm run test -- --watch", | ||
"test-ci": "npm run test-cov", | ||
"reformat": "npm run prettier -- --write ." | ||
"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-0df16eac622fa26bc26ea5bc44d4af849a08e128", | ||
"hadron-ipc": "0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128", | ||
"is-electron-renderer": "^2.0.1", | ||
"mongodb-log-writer": "^1.1.4" | ||
"mongodb-log-writer": "^1.4.2", | ||
"react": "^17.0.2" | ||
}, | ||
"devDependencies": { | ||
"@mongodb-js/eslint-config-compass": "0.0.0-next-0d9e77c42a99b49fd4ecc7167d0c769866f92ef2", | ||
"@mongodb-js/mocha-config-compass": "0.0.0-next-0d9e77c42a99b49fd4ecc7167d0c769866f92ef2", | ||
"@mongodb-js/prettier-config-compass": "0.0.0-next-0d9e77c42a99b49fd4ecc7167d0c769866f92ef2", | ||
"@mongodb-js/tsconfig-compass": "0.0.0-next-0d9e77c42a99b49fd4ecc7167d0c769866f92ef2", | ||
"@mongodb-js/eslint-config-compass": "0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128", | ||
"@mongodb-js/mocha-config-compass": "0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128", | ||
"@mongodb-js/prettier-config-compass": "0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128", | ||
"@mongodb-js/tsconfig-compass": "0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128", | ||
"@types/chai": "^4.2.21", | ||
"@types/debug": "^4.1.9", | ||
"@types/mocha": "^9.0.0", | ||
@@ -69,8 +76,7 @@ "@types/sinon-chai": "^3.2.5", | ||
"eslint": "^7.25.0", | ||
"hadron-ipc": "0.0.0-next-0d9e77c42a99b49fd4ecc7167d0c769866f92ef2", | ||
"mocha": "^8.4.0", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.7.1", | ||
"sinon": "^9.2.3", | ||
"typescript": "^4.8.3" | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -80,3 +86,3 @@ "optionalPeerDependencies": { | ||
}, | ||
"gitHead": "0d9e77c42a99b49fd4ecc7167d0c769866f92ef2" | ||
"gitHead": "0df16eac622fa26bc26ea5bc44d4af849a08e128" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46392
18
181
6
1
+ Addedhadron-app-registry@0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128
+ Addedhadron-ipc@0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128
+ Addedreact@^17.0.2
+ Added@babel/runtime@7.26.0(transitive)
+ Added@types/hoist-non-react-statics@3.3.5(transitive)
+ Added@types/prop-types@15.7.13(transitive)
+ Added@types/react@18.3.12(transitive)
+ Added@types/use-sync-external-store@0.0.3(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcreate-react-class@15.7.0(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addedelectron@30.5.1(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedeventemitter3@1.2.04.0.7(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addedhadron-app-registry@0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128(transitive)
+ Addedhadron-ipc@0.0.0-next-0df16eac622fa26bc26ea5bc44d4af849a08e128(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhoist-non-react-statics@3.3.2(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@15.7.017.0.2(transitive)
+ Addedreact-is@16.13.118.3.1(transitive)
+ Addedreact-redux@8.1.3(transitive)
+ Addedredux@4.2.1(transitive)
+ Addedreflux@0.4.1(transitive)
+ Addedreflux-core@0.3.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addeduse-sync-external-store@1.2.2(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)
- Removedelectron@32.2.6(transitive)
- Removedhadron-ipc@3.2.27(transitive)
- Removedhas-symbols@1.1.0(transitive)
Updateddebug@^4.3.4
Updatedmongodb-log-writer@^1.4.2