Skip to content
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
1 change: 1 addition & 0 deletions docs/migration/draft-v9-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
be removed in v9.
- Deprecated `TransactionNamingScheme` type.
- Deprecated `urlEncode`. No replacements.
- Deprecated `arrayify`. No replacements.

## `@sentry/core`

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/utils-hoist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export {
addContextToFrame,
addExceptionMechanism,
addExceptionTypeValue,
// eslint-disable-next-line deprecation/deprecation
arrayify,
checkOrSetAlreadyCaught,
getEventDescription,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/utils-hoist/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ export function checkOrSetAlreadyCaught(exception: unknown): boolean {
*
* @param maybeArray Input to turn into an array, if necessary
* @returns The input, if already an array, or an array with the input as the only element, if not
*
* @deprecated This function has been deprecated and will not be replaced.
*/
export function arrayify<T = unknown>(maybeArray: T | T[]): T[] {
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
Expand Down
8 changes: 8 additions & 0 deletions packages/core/test/utils-hoist/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,24 @@ describe('uuid4 generation', () => {

describe('arrayify()', () => {
it('returns arrays untouched', () => {
// eslint-disable-next-line deprecation/deprecation
expect(arrayify([])).toEqual([]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(['dogs', 'are', 'great'])).toEqual(['dogs', 'are', 'great']);
});

it('wraps non-arrays with an array', () => {
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(1231)).toEqual([1231]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify('dogs are great')).toEqual(['dogs are great']);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(true)).toEqual([true]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify({})).toEqual([{}]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(null)).toEqual([null]);
// eslint-disable-next-line deprecation/deprecation
expect(arrayify(undefined)).toEqual([undefined]);
});
});
6 changes: 3 additions & 3 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import * as fs from 'fs';
import * as path from 'path';
import { arrayify, escapeStringForRegex, loadModule, logger } from '@sentry/core';
import { escapeStringForRegex, loadModule, logger } from '@sentry/core';
import { getSentryRelease } from '@sentry/node';
import * as chalk from 'chalk';
import { sync as resolveSync } from 'resolve';
Expand Down Expand Up @@ -491,7 +491,7 @@ function addFilesToWebpackEntryPoint(
let newEntryPoint = currentEntryPoint;

if (typeof currentEntryPoint === 'string' || Array.isArray(currentEntryPoint)) {
newEntryPoint = arrayify(currentEntryPoint);
newEntryPoint = Array.isArray(currentEntryPoint) ? currentEntryPoint : [currentEntryPoint];
if (newEntryPoint.some(entry => filesToInsert.includes(entry))) {
return;
}
Expand All @@ -507,7 +507,7 @@ function addFilesToWebpackEntryPoint(
// descriptor object (webpack 5+)
else if (typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint) {
const currentImportValue = currentEntryPoint.import;
const newImportValue = arrayify(currentImportValue);
const newImportValue = Array.isArray(currentImportValue) ? currentImportValue : [currentImportValue];
if (newImportValue.some(entry => filesToInsert.includes(entry))) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export {
loadModule,
flatten,
memoBuilder,
// eslint-disable-next-line deprecation/deprecation
arrayify,
normalizeUrlToBase,
// eslint-disable-next-line deprecation/deprecation
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineIntegration, hasTracingEnabled } from '@sentry/core';
import { GLOBAL_OBJ, arrayify, consoleSandbox } from '@sentry/core';
import { GLOBAL_OBJ, consoleSandbox } from '@sentry/core';
import type { Client, IntegrationFn } from '@sentry/types';

import { DEFAULT_HOOKS } from './constants';
Expand Down Expand Up @@ -48,7 +48,7 @@ Update your \`Sentry.init\` call with an appropriate config option:
}

if (options.app) {
const apps = arrayify(options.app);
const apps = Array.isArray(options.app) ? options.app : [options.app];
apps.forEach(app => vueInit(app, options));
} else if (options.Vue) {
vueInit(options.Vue, options);
Expand Down
Loading