Skip to content
Merged
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
13 changes: 12 additions & 1 deletion packages/core/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<T>(arr: T[], callback: (item: T) => boolean): number {
for (let i = 0; i < arr.length; i++) {
if (callback(arr[i]) === true) {
return i;
}
}

return -1;
}