diff --git a/docs/migration/v8-to-v9.md b/docs/migration/v8-to-v9.md index d3951290218a..20c29bbffac3 100644 --- a/docs/migration/v8-to-v9.md +++ b/docs/migration/v8-to-v9.md @@ -107,6 +107,7 @@ It will be removed in a future major version. - The `getNumberOfUrlSegments` method has been removed. There is no replacement. - The `validSeverityLevels` export has been removed. There is no replacement. - The `arrayify` export has been removed. There is no replacement. +- The `flatten` export has been removed. There is no replacement. ### `@sentry/nestjs` diff --git a/packages/core/src/utils-hoist/array.ts b/packages/core/src/utils-hoist/array.ts deleted file mode 100644 index 412e22224156..000000000000 --- a/packages/core/src/utils-hoist/array.ts +++ /dev/null @@ -1,22 +0,0 @@ -export type NestedArray = Array | T>; - -/** Flattens a multi-dimensional array - * - * @deprecated This function is deprecated and will be removed in the next major version. - */ -export function flatten(input: NestedArray): T[] { - const result: T[] = []; - - const flattenHelper = (input: NestedArray): void => { - input.forEach((el: T | NestedArray) => { - if (Array.isArray(el)) { - flattenHelper(el as NestedArray); - } else { - result.push(el as T); - } - }); - }; - - flattenHelper(input); - return result; -} diff --git a/packages/core/src/utils-hoist/index.ts b/packages/core/src/utils-hoist/index.ts index 3bf0f1b9527e..e8cc031f84f7 100644 --- a/packages/core/src/utils-hoist/index.ts +++ b/packages/core/src/utils-hoist/index.ts @@ -1,6 +1,4 @@ export { applyAggregateErrorsToEvent } from './aggregate-errors'; -// eslint-disable-next-line deprecation/deprecation -export { flatten } from './array'; export { getBreadcrumbLogLevelFromHttpStatusCode } from './breadcrumb-log-level'; export { getComponentName, getDomElement, getLocationHref, htmlTreeAsString } from './browser'; export { dsnFromString, dsnToString, makeDsn } from './dsn'; diff --git a/packages/core/test/utils-hoist/array.test.ts b/packages/core/test/utils-hoist/array.test.ts deleted file mode 100644 index 3716a6d190b1..000000000000 --- a/packages/core/test/utils-hoist/array.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type { NestedArray } from '../../src/utils-hoist/array'; -// eslint-disable-next-line deprecation/deprecation -import { flatten } from '../../src/utils-hoist/array'; - -describe('flatten', () => { - it('should return the same array when input is a flat array', () => { - const input = [1, 2, 3, 4]; - const expected = [1, 2, 3, 4]; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); - - it('should flatten a nested array of numbers', () => { - const input = [[1, 2, [3]], 4]; - const expected = [1, 2, 3, 4]; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); - - it('should flatten a nested array of strings', () => { - const input = [ - ['Hello', 'World'], - ['How', 'Are', 'You'], - ]; - const expected = ['Hello', 'World', 'How', 'Are', 'You']; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); - - it('should flatten a nested array of objects', () => { - const input: NestedArray<{ a: number; b?: number } | { b: number; a?: number }> = [ - [{ a: 1 }, { b: 2 }], - [{ a: 3 }, { b: 4 }], - ]; - const expected = [{ a: 1 }, { b: 2 }, { a: 3 }, { b: 4 }]; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); - - it('should flatten a mixed type array', () => { - const input: NestedArray = [['a', { b: 2 }, 'c'], 'd']; - const expected = ['a', { b: 2 }, 'c', 'd']; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); - - it('should flatten a deeply nested array', () => { - const input = [1, [2, [3, [4, [5]]]]]; - const expected = [1, 2, 3, 4, 5]; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); - - it('should return an empty array when input is empty', () => { - const input: any[] = []; - const expected: any[] = []; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); - - it('should return the same array when input is a flat array', () => { - const input = [1, 'a', { b: 2 }, 'c', 3]; - const expected = [1, 'a', { b: 2 }, 'c', 3]; - // eslint-disable-next-line deprecation/deprecation - expect(flatten(input)).toEqual(expected); - }); -}); diff --git a/packages/node/src/utils/redisCache.ts b/packages/node/src/utils/redisCache.ts index 2a963710e0d5..20cca873c55a 100644 --- a/packages/node/src/utils/redisCache.ts +++ b/packages/node/src/utils/redisCache.ts @@ -95,9 +95,8 @@ export function calculateCacheItemSize(response: unknown): number | undefined { : getSize(response); } -// TODO(v9): This is inlined from core so we can deprecate `flatten`. -// It's usage can be replaced with `Array.flat` in v9. type NestedArray = Array | T>; + function flatten(input: NestedArray): T[] { const result: T[] = []; diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 45b540109b14..80dfd17ab72c 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -62,7 +62,6 @@ import { extractTraceparentData as extractTraceparentData_imported, filenameIsInApp as filenameIsInApp_imported, fill as fill_imported, - flatten as flatten_imported, forEachEnvelopeItem as forEachEnvelopeItem_imported, generatePropagationContext as generatePropagationContext_imported, generateSentryTraceHeader as generateSentryTraceHeader_imported, @@ -599,10 +598,6 @@ export const isNodeEnv = isNodeEnv_imported; /** @deprecated Import from `@sentry/core` instead. */ export const loadModule = loadModule_imported; -/** @deprecated Import from `@sentry/core` instead. */ -// eslint-disable-next-line deprecation/deprecation -export const flatten = flatten_imported; - /** @deprecated Import from `@sentry/core` instead. */ // eslint-disable-next-line deprecation/deprecation export const memoBuilder = memoBuilder_imported;