Skip to content

fix: stop using @types/node in @sentry/hub #3050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions packages/hub/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Client } from '@sentry/types';
import * as domain from 'domain';

import { Hub } from './hub';
import { Scope } from './scope';
Expand All @@ -25,13 +24,8 @@ export interface Carrier {
*/
extensions?: {
/** Hack to prevent bundlers from breaking our usage of the domain package in the cross-platform Hub package */
domain?: typeof domain & {
/**
* The currently active domain. This is part of the domain package, but for some reason not declared in the
* package's typedef.
*/
active?: domain.Domain;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
domain?: { [key: string]: any };
} & {
/** Extension methods for the hub, which are bound to the current Hub instance */
// eslint-disable-next-line @typescript-eslint/ban-types
Expand All @@ -40,4 +34,7 @@ export interface Carrier {
};
}

export interface DomainAsCarrier extends domain.Domain, Carrier {}
export interface DomainAsCarrier extends Carrier {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
members: { [key: string]: any }[];
}
4 changes: 3 additions & 1 deletion packages/hub/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,12 @@ export class Scope implements ScopeInterface {
* Retruns the global event processors.
*/
function getGlobalEventProcessors(): EventProcessor[] {
const global = getGlobalObject<Window | NodeJS.Global>();
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
const global = getGlobalObject<any>();
global.__SENTRY__ = global.__SENTRY__ || {};
global.__SENTRY__.globalEventProcessors = global.__SENTRY__.globalEventProcessors || [];
return global.__SENTRY__.globalEventProcessors;
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/hub/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"exclude": ["dist"],
"compilerOptions": {
"rootDir": ".",
"types": ["node", "jest"]
"types": ["jest"]
}
}
4 changes: 1 addition & 3 deletions packages/tracing/src/hubextensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ function getDefaultSamplingContext(transactionContext: TransactionContext): Samp
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const requestType = nodeHttpModule.IncomingMessage;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const request = domain.members.find((member: any) => isInstanceOf(member, requestType));

const request = domain.members.find(member => isInstanceOf(member, requestType));
if (request) {
defaultSamplingContext.request = extractNodeRequestData(request);
}
Expand Down