diff --git a/packages/core/src/integration.ts b/packages/core/src/integration.ts index 58b63dacc199..d60bb857bbd5 100644 --- a/packages/core/src/integration.ts +++ b/packages/core/src/integration.ts @@ -69,7 +69,7 @@ export function getIntegrationsToSetup(options: Options): Integration[] { // `beforeSendTransaction`. It therefore has to run after all other integrations, so that the changes of all event // processors will be reflected in the printed values. For lack of a more elegant way to guarantee that, we therefore // locate it and, assuming it exists, pop it out of its current spot and shove it onto the end of the array. - const debugIndex = finalIntegrations.findIndex(integration => integration.name === 'Debug'); + const debugIndex = findIndex(finalIntegrations, integration => integration.name === 'Debug'); if (debugIndex !== -1) { const [debugInstance] = finalIntegrations.splice(debugIndex, 1); finalIntegrations.push(debugInstance); @@ -107,3 +107,14 @@ export function setupIntegration(integration: Integration, integrationIndex: Int __DEBUG_BUILD__ && logger.log(`Integration installed: ${integration.name}`); } } + +// Polyfill for Array.findIndex(), which is not supported in ES5 +function findIndex(arr: T[], callback: (item: T) => boolean): number { + for (let i = 0; i < arr.length; i++) { + if (callback(arr[i]) === true) { + return i; + } + } + + return -1; +}