Socket
Socket
Sign inDemoInstall

@sentry/hub

Package Overview
Dependencies
Maintainers
8
Versions
430
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/hub - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

26

dist/hub.d.ts

@@ -1,4 +0,13 @@

import { Breadcrumb, SentryBreadcrumbHint, SentryEvent, SentryEventHint, Severity } from '@sentry/types';
import { Breadcrumb, Integration, IntegrationClass, SentryBreadcrumbHint, SentryEvent, SentryEventHint, Severity } from '@sentry/types';
import { Carrier, Layer } from './interfaces';
import { Scope } from './scope';
declare module 'domain' {
let active: Domain;
/**
* Extension for domain interface
*/
interface Domain {
__SENTRY__?: Carrier;
}
}
/**

@@ -150,2 +159,4 @@ * API compatibility version of this hub.

run(callback: ((hub: Hub) => void)): void;
/** Returns the integration if installed on the current client. */
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
}

@@ -159,3 +170,3 @@ /** Returns the global shim registry. */

*/
export declare function makeMain(hub?: Hub): Hub | undefined;
export declare function makeMain(hub: Hub): Hub;
/**

@@ -170,2 +181,7 @@ * Returns the default hub instance.

/**
* This will tell whether a carrier has a hub on it or not
* @param carrier object
*/
export declare function hasHubOnCarrier(carrier: any): boolean;
/**
* This will create a new {@link Hub} and add to the passed object on

@@ -176,1 +192,7 @@ * __SENTRY__.hub.

export declare function getHubFromCarrier(carrier: any): Hub;
/**
* This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
* @param carrier object
* @param hub Hub
*/
export declare function setHubOnCarrier(carrier: any, hub: Hub): boolean;

81

dist/hub.js

@@ -34,3 +34,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var logger_1 = require("@sentry/utils/logger");
var misc_1 = require("@sentry/utils/misc");
var domain = require("domain");
var scope_1 = require("./scope");

@@ -98,3 +100,3 @@ /**

(_a = top.client)[method].apply(_a, __spread(args, [top.scope])).catch(function (err) {
console.error(err);
logger_1.logger.error(err);
});

@@ -283,2 +285,12 @@ }

};
/** Returns the integration if installed on the current client. */
Hub.prototype.getIntegration = function (integration) {
try {
return this.getClient().getIntegration(integration);
}
catch (_oO) {
logger_1.logger.warn("Cannot retrieve integration " + integration.id + " from the current Hub");
return null;
}
};
return Hub;

@@ -293,3 +305,3 @@ }());

};
return carrier.__SENTRY__;
return carrier;
}

@@ -304,4 +316,4 @@ exports.getMainCarrier = getMainCarrier;

var registry = getMainCarrier();
var oldHub = registry.hub;
registry.hub = hub;
var oldHub = getHubFromCarrier(registry);
setHubOnCarrier(registry, hub);
return oldHub;

@@ -318,27 +330,42 @@ }

function getCurrentHub() {
// Get main carrier (global for every environment)
var registry = getMainCarrier();
if (!registry.hub || registry.hub.isOlderThan(exports.API_VERSION)) {
registry.hub = new Hub();
// If there's no hub, or its an old API, assign a new one
if (!hasHubOnCarrier(registry) || getHubFromCarrier(registry).isOlderThan(exports.API_VERSION)) {
setHubOnCarrier(registry, new Hub());
}
var domain = null;
// Prefer domains over global if they are there
try {
domain = process.domain;
var activeDomain = domain.active;
// If there no active domain, just return global hub
if (!activeDomain) {
return getHubFromCarrier(registry);
}
// If there's no hub on current domain, or its an old API, assign a new one
if (!hasHubOnCarrier(activeDomain) || getHubFromCarrier(activeDomain).isOlderThan(exports.API_VERSION)) {
var registryHubTopStack = getHubFromCarrier(registry).getStackTop();
setHubOnCarrier(activeDomain, new Hub(registryHubTopStack.client, scope_1.Scope.clone(registryHubTopStack.scope)));
}
// Return hub that lives on a domain
return getHubFromCarrier(activeDomain);
}
catch (_Oo) {
// We do not have process
// Return hub that lives on a global object
return getHubFromCarrier(registry);
}
if (!domain) {
return registry.hub;
}
exports.getCurrentHub = getCurrentHub;
/**
* This will tell whether a carrier has a hub on it or not
* @param carrier object
*/
function hasHubOnCarrier(carrier) {
if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) {
return true;
}
var carrier = domain.__SENTRY__;
if (!carrier) {
domain.__SENTRY__ = carrier = {};
else {
return false;
}
if (!carrier.hub) {
var top_1 = registry.hub.getStackTop();
carrier.hub = top_1 ? new Hub(top_1.client, scope_1.Scope.clone(top_1.scope)) : new Hub();
}
return carrier.hub;
}
exports.getCurrentHub = getCurrentHub;
exports.hasHubOnCarrier = hasHubOnCarrier;
/**

@@ -360,2 +387,16 @@ * This will create a new {@link Hub} and add to the passed object on

exports.getHubFromCarrier = getHubFromCarrier;
/**
* This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
* @param carrier object
* @param hub Hub
*/
function setHubOnCarrier(carrier, hub) {
if (!carrier) {
return false;
}
carrier.__SENTRY__ = carrier.__SENTRY__ || {};
carrier.__SENTRY__.hub = hub;
return true;
}
exports.setHubOnCarrier = setHubOnCarrier;
//# sourceMappingURL=hub.js.map
export { Carrier, Layer } from './interfaces';
export { Scope } from './scope';
export { getCurrentHub, getHubFromCarrier, Hub } from './hub';
export { addGlobalEventProcessor, Scope } from './scope';
export { getCurrentHub, getHubFromCarrier, getMainCarrier, Hub, setHubOnCarrier } from './hub';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var scope_1 = require("./scope");
exports.addGlobalEventProcessor = scope_1.addGlobalEventProcessor;
exports.Scope = scope_1.Scope;

@@ -8,3 +9,5 @@ var hub_1 = require("./hub");

exports.getHubFromCarrier = hub_1.getHubFromCarrier;
exports.getMainCarrier = hub_1.getMainCarrier;
exports.Hub = hub_1.Hub;
exports.setHubOnCarrier = hub_1.setHubOnCarrier;
//# sourceMappingURL=index.js.map

@@ -10,3 +10,5 @@ import { Hub } from './hub';

export interface Carrier {
hub?: Hub;
__SENTRY__?: {
hub?: Hub;
};
}
import { Breadcrumb, SentryEvent, SentryEventHint, Severity, User } from '@sentry/types';
export declare type EventProcessor = (event: SentryEvent, hint?: SentryEventHint) => Promise<SentryEvent | null>;
/**

@@ -12,3 +13,3 @@ * Holds additional event information. {@link Scope.applyToEvent} will be

/** Callback list that will be called after {@link applyToEvent}. */
protected eventProcessors: Array<(scope: SentryEvent, hint?: SentryEventHint) => Promise<SentryEvent | null>>;
protected eventProcessors: EventProcessor[];
/** Array of breadcrumbs. */

@@ -33,3 +34,3 @@ protected breadcrumbs: Breadcrumb[];

/** Add new event processor that will be called after {@link applyToEvent}. */
addEventProcessor(callback: (scope: SentryEvent, hint?: SentryEventHint) => Promise<SentryEvent | null>): Scope;
addEventProcessor(callback: EventProcessor): Scope;
/**

@@ -107,1 +108,6 @@ * This will be called on every set call.

}
/**
* Add a EventProcessor to be kept globally.
* @param callback EventProcessor to add
*/
export declare function addGlobalEventProcessor(callback: EventProcessor): void;

@@ -48,12 +48,2 @@ "use strict";

};
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
var __read = (this && this.__read) || function (o, n) {

@@ -79,3 +69,14 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

};
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });
var misc_1 = require("@sentry/utils/misc");
var object_1 = require("@sentry/utils/object");

@@ -140,3 +141,3 @@ /**

_d.trys.push([1, 8, 9, 10]);
_b = __values(this.eventProcessors), _c = _b.next();
_b = __values(__spread(getGlobalEventProcessors(), this.eventProcessors)), _c = _b.next();
_d.label = 2;

@@ -329,2 +330,19 @@ case 2:

exports.Scope = Scope;
/**
* Retruns the global event processors.
*/
function getGlobalEventProcessors() {
var global = misc_1.getGlobalObject();
global.__SENTRY__ = global.__SENTRY__ || {};
global.__SENTRY__.globalEventProcessors = global.__SENTRY__.globalEventProcessors || [];
return global.__SENTRY__.globalEventProcessors;
}
/**
* Add a EventProcessor to be kept globally.
* @param callback EventProcessor to add
*/
function addGlobalEventProcessor(callback) {
getGlobalEventProcessors().push(callback);
}
exports.addGlobalEventProcessor = addGlobalEventProcessor;
//# sourceMappingURL=scope.js.map
{
"name": "@sentry/hub",
"version": "4.1.1",
"version": "4.2.0",
"description": "Sentry hub which handles global state managment.",

@@ -18,4 +18,4 @@ "repository": "git://github.com/getsentry/raven-js.git",

"dependencies": {
"@sentry/types": "4.1.0",
"@sentry/utils": "4.1.1"
"@sentry/types": "4.2.0",
"@sentry/utils": "4.2.0"
},

@@ -22,0 +22,0 @@ "devDependencies": {

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