@ohbug/browser 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -674
- package/dist/index.mjs +1 -653
- package/package.json +6 -8
- package/src/capture/action/captureClick.ts +0 -35
- package/src/capture/action/captureUrlChange.ts +0 -100
- package/src/capture/console/captureConsole.ts +0 -45
- package/src/capture/index.ts +0 -64
- package/src/capture/network/captureAjaxError.ts +0 -81
- package/src/capture/network/captureFetchError.ts +0 -69
- package/src/capture/network/captureWebSocketError.ts +0 -51
- package/src/capture/script/captureUncaughtError.ts +0 -20
- package/src/capture/script/captureUnhandledrejectionError.ts +0 -20
- package/src/client.ts +0 -46
- package/src/destroy.ts +0 -22
- package/src/device.ts +0 -19
- package/src/dispatch/index.ts +0 -2
- package/src/dispatch/networkDispatcher.ts +0 -29
- package/src/dispatch/scriptDispatcher.ts +0 -30
- package/src/extension.ts +0 -12
- package/src/handle/ajaxErrorHandler.ts +0 -26
- package/src/handle/fetchErrorHandler.ts +0 -25
- package/src/handle/index.ts +0 -16
- package/src/handle/resourceErrorHandler.ts +0 -41
- package/src/handle/uncaughtErrorHandler.ts +0 -37
- package/src/handle/unhandledrejectionErrorHandler.ts +0 -21
- package/src/handle/unknownErrorHandler.ts +0 -18
- package/src/handle/websocketErrorHandler.ts +0 -23
- package/src/index.ts +0 -13
- package/src/notifier.ts +0 -42
- package/src/version.ts +0 -1
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getOhbugObject } from '@ohbug/utils'
|
|
2
|
-
import type { OhbugBaseDetail } from '@ohbug/types'
|
|
3
|
-
import { EventTypes } from '@ohbug/core'
|
|
4
|
-
|
|
5
|
-
export interface FetchErrorDetail extends OhbugBaseDetail {
|
|
6
|
-
req: {
|
|
7
|
-
url: string
|
|
8
|
-
method: string
|
|
9
|
-
data: string
|
|
10
|
-
}
|
|
11
|
-
res: {
|
|
12
|
-
status: number
|
|
13
|
-
statusText: string
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function fetchErrorHandler(detail: FetchErrorDetail) {
|
|
18
|
-
const { client } = getOhbugObject<Window>()
|
|
19
|
-
const event = client.createEvent<FetchErrorDetail>({
|
|
20
|
-
category: 'error',
|
|
21
|
-
type: EventTypes.FETCH_ERROR,
|
|
22
|
-
detail,
|
|
23
|
-
})
|
|
24
|
-
client.notify(event)
|
|
25
|
-
}
|
package/src/handle/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// script
|
|
2
|
-
export { uncaughtErrorHandler } from './uncaughtErrorHandler'
|
|
3
|
-
export { resourceErrorHandler } from './resourceErrorHandler'
|
|
4
|
-
export { unhandledrejectionErrorHandler } from './unhandledrejectionErrorHandler'
|
|
5
|
-
export { unknownErrorHandler } from './unknownErrorHandler'
|
|
6
|
-
export type { UncaughtErrorDetail } from './uncaughtErrorHandler'
|
|
7
|
-
export type { ResourceErrorDetail } from './resourceErrorHandler'
|
|
8
|
-
export type { UnhandledrejectionErrorDetail } from './unhandledrejectionErrorHandler'
|
|
9
|
-
export type { UnknownErrorDetail } from './unknownErrorHandler'
|
|
10
|
-
// network
|
|
11
|
-
export { ajaxErrorHandler } from './ajaxErrorHandler'
|
|
12
|
-
export { fetchErrorHandler } from './fetchErrorHandler'
|
|
13
|
-
export { websocketErrorHandler } from './websocketErrorHandler'
|
|
14
|
-
export type { AjaxErrorDetail } from './ajaxErrorHandler'
|
|
15
|
-
export type { FetchErrorDetail } from './fetchErrorHandler'
|
|
16
|
-
export type { WebsocketErrorDetail } from './websocketErrorHandler'
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { getOhbugObject, getSelector } from '@ohbug/utils'
|
|
2
|
-
import type { OhbugBaseDetail } from '@ohbug/types'
|
|
3
|
-
import { EventTypes } from '@ohbug/core'
|
|
4
|
-
|
|
5
|
-
export interface ResourceErrorDetail extends OhbugBaseDetail {
|
|
6
|
-
outerHTML: string
|
|
7
|
-
src: string
|
|
8
|
-
tagName: string
|
|
9
|
-
id: string
|
|
10
|
-
className: string
|
|
11
|
-
name: string
|
|
12
|
-
// https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeType
|
|
13
|
-
nodeType: number
|
|
14
|
-
selector: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function resourceErrorHandler(error: ErrorEvent) {
|
|
18
|
-
const target = (error.target || error.srcElement) as any
|
|
19
|
-
const { outerHTML } = target
|
|
20
|
-
|
|
21
|
-
const selector = getSelector(error)
|
|
22
|
-
|
|
23
|
-
const detail: ResourceErrorDetail = {
|
|
24
|
-
outerHTML,
|
|
25
|
-
src: target && target.src,
|
|
26
|
-
tagName: target && target.tagName,
|
|
27
|
-
id: target && target.id,
|
|
28
|
-
className: target && target.className,
|
|
29
|
-
name: target && target.name,
|
|
30
|
-
// https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeType
|
|
31
|
-
nodeType: target && target.nodeType,
|
|
32
|
-
selector,
|
|
33
|
-
}
|
|
34
|
-
const { client } = getOhbugObject<Window>()
|
|
35
|
-
const event = client.createEvent<ResourceErrorDetail>({
|
|
36
|
-
category: 'error',
|
|
37
|
-
type: EventTypes.RESOURCE_ERROR,
|
|
38
|
-
detail,
|
|
39
|
-
})
|
|
40
|
-
client.notify(event)
|
|
41
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getOhbugObject } from '@ohbug/utils'
|
|
2
|
-
import type { OhbugBaseDetail } from '@ohbug/types'
|
|
3
|
-
import { EventTypes } from '@ohbug/core'
|
|
4
|
-
|
|
5
|
-
export interface UncaughtErrorDetail extends OhbugBaseDetail {
|
|
6
|
-
name: string
|
|
7
|
-
filename: string
|
|
8
|
-
lineno: number
|
|
9
|
-
colno: number
|
|
10
|
-
stack: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function uncaughtErrorHandler(error: ErrorEvent) {
|
|
14
|
-
const {
|
|
15
|
-
message,
|
|
16
|
-
filename,
|
|
17
|
-
lineno,
|
|
18
|
-
colno,
|
|
19
|
-
error: { stack, name },
|
|
20
|
-
} = error
|
|
21
|
-
|
|
22
|
-
const detail: UncaughtErrorDetail = {
|
|
23
|
-
name,
|
|
24
|
-
message,
|
|
25
|
-
filename,
|
|
26
|
-
lineno,
|
|
27
|
-
colno,
|
|
28
|
-
stack,
|
|
29
|
-
}
|
|
30
|
-
const { client } = getOhbugObject<Window>()
|
|
31
|
-
const event = client.createEvent<UncaughtErrorDetail>({
|
|
32
|
-
category: 'error',
|
|
33
|
-
type: EventTypes.UNCAUGHT_ERROR,
|
|
34
|
-
detail,
|
|
35
|
-
})
|
|
36
|
-
client.notify(event)
|
|
37
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getOhbugObject } from '@ohbug/utils'
|
|
2
|
-
import type { OhbugBaseDetail } from '@ohbug/types'
|
|
3
|
-
import { EventTypes } from '@ohbug/core'
|
|
4
|
-
|
|
5
|
-
export interface UnhandledrejectionErrorDetail extends OhbugBaseDetail {
|
|
6
|
-
stack: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function unhandledrejectionErrorHandler(error: PromiseRejectionEvent) {
|
|
10
|
-
const detail: UnhandledrejectionErrorDetail = {
|
|
11
|
-
message: error.reason.message || error.reason,
|
|
12
|
-
stack: error.reason.stack,
|
|
13
|
-
}
|
|
14
|
-
const { client } = getOhbugObject<Window>()
|
|
15
|
-
const event = client.createEvent<UnhandledrejectionErrorDetail>({
|
|
16
|
-
category: 'error',
|
|
17
|
-
type: EventTypes.UNHANDLEDREJECTION_ERROR,
|
|
18
|
-
detail,
|
|
19
|
-
})
|
|
20
|
-
client.notify(event)
|
|
21
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getOhbugObject } from '@ohbug/utils'
|
|
2
|
-
import type { OhbugBaseDetail } from '@ohbug/types'
|
|
3
|
-
import { EventTypes } from '@ohbug/core'
|
|
4
|
-
|
|
5
|
-
export interface UnknownErrorDetail extends OhbugBaseDetail {}
|
|
6
|
-
|
|
7
|
-
export function unknownErrorHandler(error: any) {
|
|
8
|
-
const detail: UnknownErrorDetail = error.message
|
|
9
|
-
? error
|
|
10
|
-
: { message: error }
|
|
11
|
-
const { client } = getOhbugObject<Window>()
|
|
12
|
-
const event = client.createEvent<UnknownErrorDetail>({
|
|
13
|
-
category: 'error',
|
|
14
|
-
type: EventTypes.UNKNOWN_ERROR,
|
|
15
|
-
detail,
|
|
16
|
-
})
|
|
17
|
-
client.notify(event)
|
|
18
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { getOhbugObject } from '@ohbug/utils'
|
|
2
|
-
import type { OhbugBaseDetail } from '@ohbug/types'
|
|
3
|
-
import { EventTypes } from '@ohbug/core'
|
|
4
|
-
|
|
5
|
-
export interface WebsocketErrorDetail extends OhbugBaseDetail {
|
|
6
|
-
url: string
|
|
7
|
-
timeStamp: number
|
|
8
|
-
readyState: number
|
|
9
|
-
protocol: string
|
|
10
|
-
extensions: string
|
|
11
|
-
binaryType: string
|
|
12
|
-
bufferedAmount: number
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function websocketErrorHandler(detail: WebsocketErrorDetail) {
|
|
16
|
-
const { client } = getOhbugObject<Window>()
|
|
17
|
-
const event = client.createEvent<WebsocketErrorDetail>({
|
|
18
|
-
category: 'error',
|
|
19
|
-
type: EventTypes.WEBSOCKET_ERROR,
|
|
20
|
-
detail,
|
|
21
|
-
})
|
|
22
|
-
client.notify(event)
|
|
23
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BrowserClient } from './client'
|
|
2
|
-
|
|
3
|
-
export type {
|
|
4
|
-
UncaughtErrorDetail,
|
|
5
|
-
ResourceErrorDetail,
|
|
6
|
-
UnhandledrejectionErrorDetail,
|
|
7
|
-
UnknownErrorDetail,
|
|
8
|
-
AjaxErrorDetail,
|
|
9
|
-
FetchErrorDetail,
|
|
10
|
-
WebsocketErrorDetail,
|
|
11
|
-
} from './handle'
|
|
12
|
-
|
|
13
|
-
export default BrowserClient
|
package/src/notifier.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { OhbugEventWithMethods } from '@ohbug/types'
|
|
2
|
-
|
|
3
|
-
import { getOhbugObject } from '@ohbug/utils'
|
|
4
|
-
|
|
5
|
-
const getCircularReplacer = () => {
|
|
6
|
-
const seen = new WeakSet()
|
|
7
|
-
return (_: any, value: any) => {
|
|
8
|
-
if (typeof value === 'object' && value !== null) {
|
|
9
|
-
if (seen.has(value))
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
seen.add(value)
|
|
13
|
-
}
|
|
14
|
-
return value
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function notifier<D>(event: OhbugEventWithMethods<D>) {
|
|
19
|
-
const { client } = getOhbugObject<Window>()
|
|
20
|
-
const url = client.__config.endpoint!
|
|
21
|
-
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
const json = JSON.stringify(event, getCircularReplacer())
|
|
24
|
-
if (navigator.sendBeacon) {
|
|
25
|
-
const result = navigator.sendBeacon(url, json)
|
|
26
|
-
resolve(result)
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const xhr = new XMLHttpRequest()
|
|
30
|
-
xhr.onreadystatechange = () => {
|
|
31
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
32
|
-
if (xhr.status >= 200 && xhr.status < 300)
|
|
33
|
-
return resolve(xhr.response)
|
|
34
|
-
reject(xhr)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
xhr.open('POST', url)
|
|
38
|
-
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
|
|
39
|
-
xhr.send(json)
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
}
|
package/src/version.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const version = '__VERSION__'
|