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

@compas/stdlib

Package Overview
Dependencies
Maintainers
1
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compas/stdlib - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

src/sentry.d.ts

1

index.d.ts

@@ -18,1 +18,2 @@ export { uuid } from "./src/datatypes.js";

export { newEvent, eventStart, eventRename, eventStop, newEventFromEvent } from "./src/events.js";
export { _compasSentryExport, compasWithSentry } from "./src/sentry.js";

@@ -95,1 +95,3 @@ /// <reference path="./types/advanced-types.d.ts">

} from "./src/events.js";
export { _compasSentryExport, compasWithSentry } from "./src/sentry.js";

11

package.json
{
"name": "@compas/stdlib",
"version": "0.10.0",
"version": "0.10.1",
"description": "All kinds of utility functions",

@@ -23,7 +23,10 @@ "exports": {

"dependencies": {
"@types/node": "20.10.8",
"dotenv": "16.3.1",
"@types/node": "20.12.7",
"dotenv": "16.4.5",
"lodash.merge": "4.6.2",
"pino": "8.17.2"
"pino": "8.20.0"
},
"devDependencies": {
"@sentry/node": "^7.110.0"
},
"author": {

@@ -30,0 +33,0 @@ "name": "Dirk de Visser",

@@ -19,3 +19,3 @@ /**

name?: string | undefined;
location?: "user" | "project" | undefined;
location?: "project" | "user" | undefined;
} | undefined): void;

@@ -22,0 +22,0 @@ /**

@@ -60,4 +60,4 @@ /**

* The insight event is a tool for tracking the duration of (async) functions manually.
* By utilizing the insight event, you can gain access to a task or request-specific logger and
* obtain insights into the execution time of your functions.
* By utilizing the insight event, you can gain access to a task or request-specific
* logger and obtain insights into the execution time of your functions.
*

@@ -75,2 +75,3 @@ * How to use the Insight Event:

span: InsightEventSpan;
_compasSentrySpan?: import("@sentry/node").Span | undefined;
};
import { AppError } from "./error.js";
import { isNil } from "./lodash.js";
import { _compasSentryExport } from "./sentry.js";

@@ -16,4 +17,4 @@ /**

* The insight event is a tool for tracking the duration of (async) functions manually.
* By utilizing the insight event, you can gain access to a task or request-specific logger and
* obtain insights into the execution time of your functions.
* By utilizing the insight event, you can gain access to a task or request-specific
* logger and obtain insights into the execution time of your functions.
*

@@ -28,3 +29,4 @@ * How to use the Insight Event:

* You could pass the event object down through your (async) functions as an argument.
* This allows the insight event to associate the event with the specific task or request.
* This allows the insight event to associate the event with the specific task or
* request.
*

@@ -69,2 +71,3 @@ * Finally, you should stop the event for correct logging by calling {@link eventStop}.

* @property {InsightEventSpan} span
* @property {import("@sentry/node").Span} [_compasSentrySpan]
*/

@@ -97,2 +100,4 @@

},
_compasSentrySpan: undefined,
};

@@ -127,2 +132,6 @@ }

if (event._compasSentrySpan) {
event._compasSentrySpan.end();
}
throw AppError.serverError({

@@ -159,5 +168,17 @@ message: "Operation aborted",

if (typeof _compasSentryExport?.startInactiveSpan === "function") {
event._compasSentrySpan = _compasSentryExport.startInactiveSpan({
op: "event",
name: name,
description: name,
});
}
if (event.signal?.aborted) {
event.span.abortedTime = Date.now();
if (event._compasSentrySpan) {
event._compasSentrySpan.end();
}
throw AppError.serverError({

@@ -183,5 +204,14 @@ message: "Operation aborted",

if (event._compasSentrySpan) {
event._compasSentrySpan.description = name;
event._compasSentrySpan.updateName(name);
}
if (event.signal?.aborted) {
event.span.abortedTime = Date.now();
if (event._compasSentrySpan) {
event._compasSentrySpan.end();
}
throw AppError.serverError({

@@ -209,2 +239,6 @@ message: "Operation aborted",

if (event._compasSentrySpan) {
event._compasSentrySpan.end();
}
if (isNil(event.rootEvent)) {

@@ -211,0 +245,0 @@ event.log.info({

@@ -6,2 +6,3 @@ import { pino } from "pino";

import { loggerWriteGithubActions, loggerWritePretty } from "./log-writers.js";
import { _compasSentryExport } from "./sentry.js";

@@ -127,2 +128,59 @@ /**

if (typeof _compasSentryExport?.addBreadcrumb === "function") {
let addedContextAsBreadcrumb = false;
return {
info: (message) => {
if (!addedContextAsBreadcrumb) {
// @ts-expect-error
_compasSentryExport.addBreadcrumb({
category: context.type,
data: {
...context,
},
level: "info",
type: "default",
});
addedContextAsBreadcrumb = true;
}
// @ts-expect-error
_compasSentryExport.addBreadcrumb({
category: context.type,
data: typeof message === "string" ? undefined : message,
message: typeof message === "string" ? message : undefined,
level: "info",
type: "default",
});
childLogger.info({ message });
},
error: (message) => {
if (!addedContextAsBreadcrumb) {
// @ts-expect-error
_compasSentryExport.addBreadcrumb({
category: "log",
data: {
...context,
},
level: "info",
type: "default",
});
addedContextAsBreadcrumb = true;
}
// @ts-expect-error
_compasSentryExport.addBreadcrumb({
category: "log",
data: typeof message === "string" ? undefined : message,
message: typeof message === "string" ? message : undefined,
level: "error",
type: "error",
});
childLogger.error({ message });
},
};
}
return {

@@ -129,0 +187,0 @@ info: (message) => childLogger.info({ message }),

@@ -12,5 +12,6 @@ import { lstatSync, realpathSync } from "node:fs";

loggerDetermineDefaultDestination,
loggerExtendGlobalContext,
newLogger,
loggerExtendGlobalContext,
} from "./logger.js";
import { _compasSentryExport } from "./sentry.js";

@@ -101,3 +102,7 @@ /**

process.on("unhandledRejection", (reason, promise) =>
process.on("unhandledRejection", (reason, promise) => {
if (_compasSentryExport) {
_compasSentryExport.captureException(reason);
}
unhandled({

@@ -107,6 +112,10 @@ type: "unhandledRejection",

promise,
}),
);
});
});
process.on("uncaughtException", (error, origin) =>
process.on("uncaughtException", (error, origin) => {
if (_compasSentryExport) {
_compasSentryExport.captureException(error);
}
unhandled({

@@ -116,13 +125,17 @@ type: "uncaughtException",

origin,
}),
);
});
});
process.on("warning", (warn) =>
process.on("warning", (warn) => {
logger.error({
type: "warning",
warning: AppError.format(warn),
}),
);
});
});
Promise.resolve(cb(logger)).catch((e) => {
if (_compasSentryExport) {
_compasSentryExport.captureException(e);
}
unhandled({

@@ -129,0 +142,0 @@ type: "error",

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