8000 ref: Fix circular dependency checks & setup (#12159) · mwdiaz/sentry-javascript@53d814b · GitHub
[go: up one dir, main page]

Skip to content

Commit 53d814b

Browse files
authored
ref: Fix circular dependency checks & setup (getsentry#12159)
I noticed we were getting some build warnings for circular dependency issues, which indicated that madge was not correctly capturing all issues. So I went ahead and updated madge to latest, and aligned the setup, which actually surfaced problems again more correctly. I also fixed all the circular dep issues that were raised there. We still have a bunch of types-related circular deps but these are hard to solve, so let's ignore this for now.
1 parent 772269a commit 53d814b

File tree

24 files changed

+338
-403
lines changed
  • tracing
  • utils
  • deno
  • node/src
  • types/src
  • vercel-edge
  • 24 files changed

    +338
    -403
    lines changed

    .madgerc

    Lines changed: 7 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,7 @@
    1+
    {
    2+
    "detectiveOptions": {
    3+
    "ts": {
    4+
    "skipTypeImports": true
    5+
    }
    6+
    }
    7+
    }

    package.json

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -114,7 +114,7 @@
    114114
    "jest-environment-node": "^27.5.1",
    115115
    "jsdom": "^21.1.2",
    116116
    "lerna": "7.1.1",
    117-
    "madge": "4.0.2",
    117+
    "madge": "7.0.0",
    118118
    "nodemon": "^2.0.16",
    119119
    "npm-run-all": "^4.1.5",
    120120
    "prettier": "^3.1.1",

    packages/bun/package.json

    Lines changed: 1 addition & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -76,12 +76,5 @@
    7676
    "volta": {
    7777
    "extends": "../../package.json"
    7878
    },
    79-
    "sideEffects": false,
    80-
    "madge": {
    81-
    "detectiveOptions": {
    82-
    "ts": {
    83-
    "skipTypeImports": true
    84-
    }
    85-
    }
    86-
    }
    79+
    "sideEffects": false
    8780
    }

    packages/core/package.json

    Lines changed: 0 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -69,12 +69,5 @@
    6969
    "volta": {
    7070
    "extends": "../../package.json"
    7171
    },
    72-
    "madge": {
    73-
    "detectiveOptions": {
    74-
    "ts": {
    75-
    "skipTypeImports": true
    76-
    }
    77-
    }
    78-
    },
    7972
    "sideEffects": false
    8073
    }

    packages/core/src/asyncContext/stackStrategy.ts

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,6 +1,6 @@
    11
    import type { Client, Scope as ScopeInterface } from '@sentry/types';
    22
    import { isThenable } from '@sentry/utils';
    3-
    import { getDefaultCurrentScope, getDefaultIsolationScope } from '../currentScopes';
    3+
    import { getDefaultCurrentScope, getDefaultIsolationScope } from '../defaultScopes';
    44
    import { Scope } from '../scope';
    55

    66
    import { getMainCarrier, getSentryCarrier } from './../carrier';

    packages/core/src/currentScopes.ts

    Lines changed: 0 additions & 10 deletions
    Original file line numberDiff line numberDiff line change
    @@ -5,16 +5,6 @@ import { getAsyncContextStrategy } from './asyncContext';
    55
    import { getMainCarrier } from './carrier';
    66
    import { Scope as ScopeClass } from './scope';
    77

    8-
    /** Get the default current scope. */
    9-
    export function getDefaultCurrentScope(): Scope {
    10-
    return getGlobalSingleton('defaultCurrentScope', () => new ScopeClass());
    11-
    }
    12-
    13-
    /** Get the default isolation scope. */
    14-
    export function getDefaultIsolationScope(): Scope {
    15-
    return getGlobalSingleton('defaultIsolationScope', () => new ScopeClass());
    16-
    }
    17-
    188
    /**
    199
    * Get the currently active scope.
    2010
    */

    packages/core/src/defaultScopes.ts

    Lines changed: 13 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,13 @@
    1+
    import type { Scope } from '@sentry/types';
    2+
    import { getGlobalSingleton } from '@sentry/utils';
    3+
    import { Scope as ScopeClass } from './scope';
    4+
    5+
    /** Get the default current scope. */
    6+
    export function getDefaultCurrentScope(): Scope {
    7+
    return getGlobalSingleton('defaultCurrentScope', () => new ScopeClass());
    8+
    }
    9+
    10+
    /** Get the default isolation scope. */
    11+
    export function getDefaultIsolationScope(): Scope {
    12+
    return getGlobalSingleton('defaultIsolationScope', () => new ScopeClass());
    13+
    }

    packages/core/src/envelope.ts

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -22,7 +22,8 @@ import {
    2222
    getSdkMetadataForEnvelopeHeader,
    2323
    } from '@sentry/utils';
    2424
    import { createSpanEnvelopeItem } from '@sentry/utils';
    25-
    import { type SentrySpan, getDynamicSamplingContextFromSpan } from './tracing';
    25+
    import { getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext';
    26+
    import type { SentrySpan } from './tracing/sentrySpan';
    2627
    import { spanToJSON } from './utils/spanUtils';
    2728

    2829
    /**

    packages/core/src/index.ts

    Lines changed: 3 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -38,9 +38,11 @@ export {
    3838
    withScope,
    3939
    withIsolationScope,
    4040
    getClient,
    41+
    } from './currentScopes';
    42+
    export {
    4143
    getDefaultCurrentScope,
    4244
    getDefaultIsolationScope,
    43-
    } from './currentScopes';
    45+
    } from './defaultScopes';
    4446
    export { setAsyncContextStrategy } from './asyncContext';
    4547
    export { getMainCarrier } from './carrier';
    4648
    export { makeSession, closeSession, updateSession } from './session';
    @@ -69,7 +71,6 @@ export { handleCallbackErrors } from './utils/handleCallbackErrors';
    6971
    export { parameterize } from './utils/parameterize';
    7072
    export {
    7173
    spanToTraceHeader,
    72-
    spanToBaggageHeader,
    7374
    spanToJSON,
    7475
    spanIsSampled,
    7576
    spanToTraceContext,

    packages/core/src/tracing/dynamicSamplingContext.ts

    Lines changed: 13 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,5 +1,9 @@
    11
    import type { Client, DynamicSamplingContext, Span } from '@sentry/types';
    2-
    import { addNonEnumerableProperty, dropUndefinedKeys } from '@sentry/utils';
    2+
    import {
    3+
    addNonEnumerableProperty,
    4+
    dropUndefinedKeys,
    5+
    dynamicSamplingContextToSentryBaggageHeader,
    6+
    } from '@sentry/utils';
    37

    48
    import { DEFAULT_ENVIRONMENT } from '../constants';
    59
    import { getClient } from '../currentScopes';
    @@ -93,3 +97,11 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly<Partial<
    9397

    9498
    return dsc;
    9599
    }
    100+
    101+
    /**
    102+
    * Convert a Span to a baggage header.
    103+
    */
    104+
    export function spanToBaggageHeader(span: Span): string | undefined {
    105+
    const dsc = getDynamicSamplingContextFromSpan(span);
    106+
    return dynamicSamplingContextToSentryBaggageHeader(dsc);
    107+
    }

    0 commit comments

    Comments
     (0)
    0