
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
dyna-sentry
Advanced tools
Enhances Sentry with additional features.
Easily send issues with data and a special scope using a single method.
Convert console.error, console.warn, etc., to Sentry Issues.
This is all that is required:
// Initialize Sentry as you normally do
import * as Sentry from '@sentry/browser';
Sentry.init({
dsn: "https://<your Sentry link>",
});
// Instantiate DynaSentry
import { DynaSentry, EConsoleTypes } from "dyna-sentry";
const dynaSentry = new DynaSentry({
Sentry,
captureConsole: {
consoleTypes: [
EConsoleTypes.ERROR,
EConsoleTypes.WARN,
// LOG, INFO, DEBUG are also available
],
},
});
Whenever your app encounters console.error or console.warn, an issue will be sent to Sentry. The first text argument of the console is used as the title of the issue, and everything else is included as additional data.
You can filter out specific consoles to prevent them from being sent to Sentry. This is necessary when you are also logging the POST requests for each sent issue.
import { DynaSentry, EConsoleTypes } from "dyna-sentry";
const dynaSentry = new DynaSentry({
Sentry,
captureConsole: {
consoleTypes: [
EConsoleTypes.ERROR,
EConsoleTypes.WARN,
// LOG, INFO, DEBUG are also available
],
filter: (consoleType, consoleArgs, consoleText) => {
if (consoleText.indexOf('invalid customer id') !== -1) return false;
return true;
},
},
});
You can easily filter out consoles that contain specific text and prevent them from being sent to Sentry. This is useful when you want to exclude certain messages from being logged.
import { DynaSentry, EConsoleTypes } from "dyna-sentry";
const dynaSentry = new DynaSentry({
Sentry,
captureConsole: {
consoleTypes: [
EConsoleTypes.ERROR,
EConsoleTypes.WARN,
// LOG, INFO, DEBUG are also available
],
filterOut: {
texts: [
"DEBUG-3052",
"[Violation]",
],
},
},
});
// Initialize Sentry as you normally do
import * as Sentry from '@sentry/browser';
Sentry.init({
dsn: "https://<your Sentry link>",
});
// Instantiate DynaSentry
import { DynaSentry } from "dyna-sentry";
const dynaSentry = new DynaSentry({ Sentry });
// Send an issue to Sentry from anywhere in your app
dynaSentry.sendIssue({
title: 'Cannot send email',
data: { email },
});
Note: You can use
sendIssuewith or without thecaptureConsolesetup.
sendIssue MethodThe default level is "Error." You can easily set it using an enum.
import { ELevel } from "dyna-sentry";
dynaSentry.sendIssue({
level: ELevel.WARN,
title: 'Cannot send email',
data: { email },
stringifyData: false,
});
The ELevel Enum:
enum ELevel {
FATAL = "fatal",
ERROR = "error",
WARN = "warning",
LOG = "log",
INFO = "info",
DEBUG = "debug",
CRITICAL = "critical"
}
When you stringify the data, you can see the entire depth of the object on Sentry.
Tip: The data stringify of the sendIssue can process objects with circular references without exceptions, thanks to dyna-stringify.
dynaSentry.sendIssue({
title: 'Cannot send email',
data: { email },
stringifyData: true,
});
Sentry offers numerous methods to define the scope of the issue. sendIssue provides a callback to define anything that Sentry offers.
dynaSentry.sendIssue({
title: 'Cannot send email',
data: { email },
stringifyData: false,
setScope: scope => {
scope.setUser({ id: "204523" });
scope.setTag('id24534', 'Network layer');
},
});
There is no clear API for all of Sentry's scope methods. Below is an interface for the scope, taken from @sentry/types/dist/scope.d.ts. If you are using TypeScript, you can inspect all methods and types. If not, you can search for each method in Sentry's API.
export interface Scope {
/** Add new event processor that will be called after {@link applyToEvent}. */
addEventProcessor(callback: EventProcessor): this;
/**
* Updates user context information for future events.
*
* @param user User context object to be set in the current context. Pass `null` to unset the user.
*/
setUser(user: User | null): this;
/**
* Set an object that will be merged sent as tags data with the event.
* @param tags Tags context object to merge into current context.
*/
setTags(tags: {
[key: string]: string;
}): this;
/**
* Set key:value that will be sent as tags data with the event.
* @param key String key of tag
* @param value String value of tag
*/
setTag(key: string, value: string): this;
/**
* Set an object that will be merged sent as extra data with the event.
* @param extras Extras object to merge into current context.
*/
setExtras(extras: {
[key: string]: any;
}): this;
/**
* Set key:value that will be sent as extra data with the event.
* @param key String of extra
* @param extra Any kind of data. This data will be normailzed.
*/
setExtra(key: string, extra: any): this;
/**
* Sets the fingerprint on the scope to send with the events.
* @param fingerprint string[] to group events in Sentry.
*/
setFingerprint(fingerprint: string[]): this;
/**
* Sets the level on the scope for future events.
* @param level string {@link Severity}
*/
setLevel(level: Severity): this;
/**
* Sets the transaction on the scope for future events.
* @param transaction string This will be converted in a tag in Sentry
*/
setTransaction(transaction?: string): this;
/**
* Sets context data with the given name.
* @param name of the context
* @param context Any kind of data. This data will be normailzed.
*/
setContext(name: string, context: {
[key: string]: any;
} | null): this;
/**
* Sets the Span on the scope.
* @param span Span
*/
setSpan(span?: Span): this;
/** Clears the current scope and resets its properties. */
clear(): this;
/**
* Sets the breadcrumbs in the scope
* @param breadcrumbs Breadcrumb
* @param maxBreadcrumbs number of max breadcrumbs to merged into event.
*/
addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this;
/**
* Clears all currently set Breadcrumbs.
*/
clearBreadcrumbs(): this;
}
Configuration for new DynaSentry(config: IDynaSentryConfig).
IDynaSentryConfig {
Sentry: any;
captureConsole?: {
consoleTypes?: EConsoleType[]; // default: empty (none)
stringifyData?: boolean; // default: false
filter?: (consoleType: EConsoleType, consoleArgs: any[], consoleText: string) => boolean;
filterOut?: IFilterOut;
setScope?: (scope: Sentry.Scope) => void;
};
}
sendIssuepublic sendIssue(options: {
title: string;
level?: ELevel;
data?: any;
stringifyData?: boolean; // default: false
setScope?: (scope: Sentry.Scope) => void;
}): void
export enum EConsoleType {
ERROR = 'error',
WARN = 'warn',
LOG = 'log',
INFO = 'info',
DEBUG = 'debug',
}
export enum ELevel {
FATAL = "fatal",
ERROR = "error",
WARN = "warning",
LOG = "log",
INFO = "info",
DEBUG = "debug",
CRITICAL = "critical"
}```
##
FAQs
A dyna sugar on Sentry
We found that dyna-sentry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.