Skip to content

Commit a46459a

Browse files
authored
Merge pull request #2412 from bugsnag/plat-12947-9
Ensure all changes are included in base
2 parents 04b5760 + 26f2412 commit a46459a

File tree

30 files changed

+53
-73
lines changed

30 files changed

+53
-73
lines changed

packages/browser/src/config.ts

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import { schema } from '@bugsnag/core'
2-
import assign from '@bugsnag/core/lib/es-utils/assign'
32
import getPrefixedConsole from './get-prefixed-console'
43

54
const config = {
6-
releaseStage: assign({}, schema.releaseStage, {
7-
defaultValue: () => {
8-
if (/^localhost(:\d+)?$/.test(window.location.host)) return 'development'
9-
return 'production'
5+
releaseStage: {
6+
...schema.releaseStage, ...{
7+
defaultValue: () => {
8+
if (/^localhost(:\d+)?$/.test(window.location.host)) return 'development'
9+
return 'production'
10+
}
1011
}
11-
}),
12-
appType: assign({}, schema.appType, {
13-
defaultValue: () => 'browser'
14-
}),
15-
logger: assign({}, schema.logger, {
16-
defaultValue: () =>
17-
// set logger based on browser capability
18-
(typeof console !== 'undefined' && typeof console.debug === 'function')
19-
? getPrefixedConsole()
20-
: undefined
21-
})
12+
},
13+
appType: {
14+
...schema.appType, ...{
15+
defaultValue: () => 'browser'
16+
}
17+
},
18+
logger: {
19+
...schema.logger, ...{
20+
defaultValue: () =>
21+
// set logger based on browser capability
22+
(typeof console !== 'undefined' && typeof console.debug === 'function')
23+
? getPrefixedConsole()
24+
: undefined
25+
}
26+
}
2227
}
2328

2429
export default config

packages/browser/src/get-prefixed-console.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import map from '@bugsnag/core/lib/es-utils/map'
2-
31
type LoggerMethod = 'debug' | 'info' | 'warn' | 'error'
42

53
const getPrefixedConsole = () => {
64
const logger: Record<string, unknown> = {}
75
const consoleLog = console.log
8-
map(['debug', 'info', 'warn', 'error'], (method: LoggerMethod) => {
6+
const loggerMethods = ['debug', 'info', 'warn', 'error'] as const
7+
loggerMethods.map((method: LoggerMethod) => {
98
const consoleMethod = console[method]
109
logger[method] = typeof consoleMethod === 'function'
1110
? consoleMethod.bind(console, '[bugsnag]')

packages/core/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"./lib/json-payload": "./src/lib/json-payload.js",
1313
"./lib/es-utils/assign": "./src/lib/es-utils/assign.js",
1414
"./lib/validators/int-range": "./src/lib/validators/int-range.js",
15-
"./lib/es-utils/map": "./src/lib/es-utils/map.js",
1615
"./lib/es-utils/includes": "./src/lib/es-utils/includes.js",
1716
"./lib/es-utils/filter": "./src/lib/es-utils/filter.js",
1817
"./lib/iserror": "./src/lib/iserror.js",

packages/core/src/lib/es-utils/map.d.ts

-1
This file was deleted.

packages/core/src/lib/es-utils/map.js

-5
This file was deleted.

packages/core/src/lib/feature-flag-delegate.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const map = require('./es-utils/map')
21
const filter = require('./es-utils/filter')
32
const isArray = require('./es-utils/is-array')
43
const jsonStringify = require('@bugsnag/safe-json-stringify')
@@ -47,8 +46,7 @@ function merge (existingFeatures, newFeatures, existingFeatureKeys) {
4746
// by the Bugsnag Event API:
4847
// [{ featureFlag: 'name', variant: 'variant' }, { featureFlag: 'name 2' }]
4948
function toEventApi (featureFlags) {
50-
return map(
51-
filter(featureFlags, Boolean),
49+
return filter(featureFlags, Boolean).map(
5250
({ name, variant }) => {
5351
const flag = { featureFlag: name }
5452

packages/core/test/lib/es-utils.test.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import map from '../../src/lib/es-utils/map'
21
import reduce from '../../src/lib/es-utils/reduce'
32
import filter from '../../src/lib/es-utils/filter'
43
import keys from '../../src/lib/es-utils/keys'
@@ -13,13 +12,6 @@ describe('es-utils', () => {
1312
})
1413
})
1514

16-
describe('map(arr, fn)', () => {
17-
it('works with a variety of examples', () => {
18-
expect(map(['a', 'b', 'c'], x => x)).toEqual(['a', 'b', 'c'])
19-
expect(map(['a', 'b', 'c'], (x) => x.toUpperCase())).toEqual(['A', 'B', 'C'])
20-
})
21-
})
22-
2315
describe('filter(arr, fn)', () => {
2416
it('works with a variety of examples', () => {
2517
const arr = ['a', 0, false, undefined, 1, 'undefined']

packages/delivery-x-domain-request/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/delivery.ts",
5-
external: ['@bugsnag/core', '@bugsnag/core/lib/json-payload']
5+
external: [/node_modules/]
66
});

packages/delivery-xml-http-request/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/delivery.ts",
5-
external: ['@bugsnag/core', '@bugsnag/core/lib/json-payload']
5+
external: [/node_modules/]
66
});

packages/node/src/get-prefixed-console.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import map from '@bugsnag/core/lib/es-utils/map'
2-
31
type LoggerMethod = 'debug' | 'info' | 'warn' | 'error'
42

53
const getPrefixedConsole = () => {
64
const logger: Record<string, unknown> = {}
75
const consoleLog = console.log
8-
map(['debug', 'info', 'warn', 'error'], (method: LoggerMethod) => {
6+
const loggerMethods = ['debug', 'info', 'warn', 'error'] as const
7+
loggerMethods.map((method: LoggerMethod) => {
98
const consoleMethod = console[method]
109
logger[method] = typeof consoleMethod === 'function'
1110
? consoleMethod.bind(console, '[bugsnag]')

packages/plugin-app-duration/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from '../../.rollup/index.mjs'
22

33
export default createRollupConfig({
44
input: 'src/app-duration.ts',
5-
external: ['@bugsnag/core']
5+
external: [/node_modules/]
66
})

packages/plugin-browser-context/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/context.ts",
5-
external: ["@bugsnag/core"],
5+
external: [/node_modules/]
66
});

packages/plugin-browser-device/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from '../../.rollup/index.mjs'
22

33
export default createRollupConfig({
44
input: 'src/device.ts',
5-
external: ['@bugsnag/core', '@bugsnag/cuid'],
5+
external: [/node_modules/],
66
})

packages/plugin-browser-request/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/request.ts",
5-
external: ['@bugsnag/core', '@bugsnag/core/lib/es-utils/assign']
5+
external: [/node_modules/],
66
});

packages/plugin-browser-session/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/session.ts",
5-
external: ['@bugsnag/core', "@bugsnag/core/lib/es-utils/includes"]
5+
external: [/node_modules/],
66
});

packages/plugin-client-ip/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/client-ip.ts",
5-
external: ['@bugsnag/core', "@bugsnag/core/lib/es-utils/assign"]
5+
external: [/node_modules/],
66
});

packages/plugin-console-breadcrumbs/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/console-breadcrumbs.ts",
5-
external: ['@bugsnag/core', "@bugsnag/core/lib/es-utils/filter", "@bugsnag/core/lib/es-utils/map", "@bugsnag/core/lib/es-utils/reduce"]
5+
external: [/node_modules/],
66
});

packages/plugin-console-breadcrumbs/src/console-breadcrumbs.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Client, Config, Plugin } from '@bugsnag/core'
22
import filter from '@bugsnag/core/lib/es-utils/filter'
3-
import map from '@bugsnag/core/lib/es-utils/map'
43
import reduce from '@bugsnag/core/lib/es-utils/reduce'
54

65
type ConsoleMethod = 'log' | 'debug' | 'info' | 'warn' | 'error'
@@ -23,7 +22,7 @@ const plugin: Plugin = {
2322

2423
if (isDev || !(client as ClientWithInternals)._isBreadcrumbTypeEnabled('log')) return
2524

26-
map(CONSOLE_LOG_METHODS, method => {
25+
CONSOLE_LOG_METHODS.map(method => {
2726
const original = console[method]
2827
console[method] = (...args: any) => {
2928
client.leaveBreadcrumb(

packages/plugin-inline-script-content/rollup.config.npm.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export default createRollupConfig({
44
input: 'src/inline-script-content.ts',
55
external: [
66
'@bugsnag/core',
7-
'@bugsnag/core/lib/es-utils/map',
87
'@bugsnag/core/lib/es-utils/reduce',
98
'@bugsnag/core/lib/es-utils/filter'
109
]

packages/plugin-inline-script-content/src/inline-script-content.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import map from '@bugsnag/core/lib/es-utils/map'
21
import reduce from '@bugsnag/core/lib/es-utils/reduce'
32
import filter from '@bugsnag/core/lib/es-utils/filter'
43
import { Client } from '@bugsnag/core'
@@ -96,12 +95,12 @@ export default (doc = document, win = window) => ({
9695

9796
// Proxy all the timer functions whose callback is their 0th argument.
9897
// Keep a reference to the original setTimeout because we need it later
99-
const [_setTimeout] = map([
98+
const [_setTimeout] = [
10099
'setTimeout',
101100
'setInterval',
102101
'setImmediate',
103102
'requestAnimationFrame'
104-
], fn =>
103+
].map(fn =>
105104
__proxy(win, fn, original =>
106105
__traceOriginalScript(original, (args: any) => ({
107106
get: () => args[0],
@@ -112,13 +111,13 @@ export default (doc = document, win = window) => ({
112111
)
113112

114113
// Proxy all the host objects whose prototypes have an addEventListener function
115-
map([
116-
'EventTarget', 'Window', 'Node', 'ApplicationCache', 'AudioTrackList', 'ChannelMergerNode',
117-
'CryptoOperation', 'EventSource', 'FileReader', 'HTMLUnknownElement', 'IDBDatabase',
114+
const eventListeners = ['EventTarget', 'Window', 'Node', 'ApplicationCache', 'AudioTrackList', 'ChannelMergerNode', 'CryptoOperation', 'EventSource', 'FileReader', 'HTMLUnknownElement', 'IDBDatabase',
118115
'IDBRequest', 'IDBTransaction', 'KeyOperation', 'MediaController', 'MessagePort', 'ModalWindow',
119116
'Notification', 'SVGElementInstance', 'Screen', 'TextTrack', 'TextTrackCue', 'TextTrackList',
120117
'WebSocket', 'WebSocketWorker', 'Worker', 'XMLHttpRequest', 'XMLHttpRequestEventTarget', 'XMLHttpRequestUpload'
121-
], o => {
118+
]
119+
120+
eventListeners.map(o => {
122121
// @ts-expect-error Element implicitly has an 'any' type because index expression is not of type 'number'
123122
if (!win[o] || !win[o].prototype || !Object.prototype.hasOwnProperty.call(win[o].prototype, 'addEventListener')) return
124123
// @ts-expect-error Element implicitly has an 'any' type because index expression is not of type 'number'

packages/plugin-interaction-breadcrumbs/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from '../../.rollup/index.mjs'
22

33
export default createRollupConfig({
44
input: 'src/interaction-breadcrumbs.ts',
5-
external: ['@bugsnag/core']
5+
external: [/node_modules/]
66
})

packages/plugin-navigation-breadcrumbs/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from '../../.rollup/index.mjs'
22

33
export default createRollupConfig({
44
input: 'src/navigation-breadcrumbs.ts',
5-
external: ['@bugsnag/core']
5+
external: [/node_modules/]
66
})

packages/plugin-network-breadcrumbs/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/network-breadcrumbs.ts",
5-
external: ['@bugsnag/core', "@bugsnag/core/lib/es-utils/includes"]
5+
external: [/node_modules/],
66
});

packages/plugin-simple-throttle/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from '../../.rollup/index.mjs'
22

33
export default createRollupConfig({
44
input: 'src/throttle.ts',
5-
external: ['@bugsnag/core', '@bugsnag/core/lib/validators/int-range']
5+
external: [/node_modules/]
66
})

packages/plugin-strip-query-string/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from "../../.rollup/index.mjs";
22

33
export default createRollupConfig({
44
input: "src/strip-query-string.ts",
5-
external: ['@bugsnag/core', "@bugsnag/core/lib/es-utils/map", "@bugsnag/core/lib/es-utils/reduce"]
5+
external: [/node_modules/],
66
});

packages/plugin-strip-query-string/src/strip-query-string.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Remove query strings (and fragments) from stacktraces
33
*/
44
import { Plugin, Stackframe } from '@bugsnag/core'
5-
import map from '@bugsnag/core/lib/es-utils/map'
65
import reduce from '@bugsnag/core/lib/es-utils/reduce'
76

87
const strip = (str: any) =>
@@ -18,7 +17,7 @@ const plugin: ExtendedPlugin = {
1817
load: (client) => {
1918
client.addOnError(event => {
2019
const allFrames: Stackframe[] = reduce(event.errors, (accum, er) => accum.concat(er.stacktrace), [])
21-
map(allFrames, frame => {
20+
allFrames.map(frame => {
2221
frame.file = strip(frame.file)
2322
})
2423
})

packages/plugin-window-onerror/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from '../../.rollup/index.mjs'
22

33
export default createRollupConfig({
44
input: 'src/onerror.ts',
5-
external: ['@bugsnag/core']
5+
external: [/node_modules/],
66
})

packages/plugin-window-unhandled-rejection/rollup.config.npm.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import createRollupConfig from '../../.rollup/index.mjs'
22

33
export default createRollupConfig({
44
input: 'src/unhandled-rejection.ts',
5-
external: ['@bugsnag/core', '@bugsnag/core/lib/iserror', '@bugsnag/core/lib/es-utils/map']
5+
external: [/node_modules/]
66
})

packages/plugin-window-unhandled-rejection/src/unhandled-rejection.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Config, Plugin } from '@bugsnag/core'
2-
import map from '@bugsnag/core/lib/es-utils/map'
32
import isError from '@bugsnag/core/lib/iserror'
43
import fixBluebirdStacktrace from './fix-bluebird-stacktrace'
54

@@ -45,7 +44,7 @@ export default (win = window): Plugin => {
4544
}, 'unhandledrejection handler', 1, client._logger)
4645

4746
if (isBluebird) {
48-
map(event.errors[0].stacktrace, fixBluebirdStacktrace(error))
47+
event.errors[0].stacktrace.map(fixBluebirdStacktrace(error))
4948
}
5049

5150
client._notify(event, (event) => {

packages/web-worker/src/get-prefixed-console.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import map from '@bugsnag/core/lib/es-utils/map'
2-
31
type LoggerMethod = 'debug' | 'info' | 'warn' | 'error'
42

53
const getPrefixedConsole = () => {
64
const logger: Record<string, unknown> = {}
75
const consoleLog = console.log
8-
map(['debug', 'info', 'warn', 'error'], (method: LoggerMethod) => {
6+
const loggerMethods = ['debug', 'info', 'warn', 'error'] as const
7+
loggerMethods.map((method: LoggerMethod) => {
98
const consoleMethod = console[method]
109
logger[method] = typeof consoleMethod === 'function'
1110
? consoleMethod.bind(console, '[bugsnag]')

0 commit comments

Comments
 (0)