@lark-sentry/types 1.0.0 → 1.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.cjs.map +1 -1
- package/dist/index.d.cts +24 -39
- package/dist/index.d.ts +24 -39
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/common.ts","../src/enums.ts"],"sourcesContent":["import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/common.ts","../src/enums.ts"],"sourcesContent":["import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends IReportPayload {\n userAction: BreadcrumbType;\n}\n\nexport interface IDeviceInfo {\n browserName: string; // 例如 chrome\n browserVersion: string; // 浏览器版本\n osName: string; // 操作系统\n osVersion: string; // 操作系统版本\n userAgent: string; // 用户代理\n deviceType: string; // 设备种类, 例如 PC\n deviceModel: string; // 设备描述\n}\n\nexport interface IReportPayload {\n id: string;\n type: EventType;\n name: string;\n time: string;\n timestamp: number;\n message: string;\n status: Status;\n}\n\nexport interface IHttpData extends IReportPayload {\n method: HttpMethod | string;\n // 接口地址\n api: string;\n // 请求时长\n elapsedTime: number;\n // http 状态码\n statusCode: number;\n requestData?: unknown;\n responseData?: unknown;\n}\n\nexport interface IResourceError extends IReportPayload {\n src: string;\n href: string;\n}\n\ninterface IPerformanceMetricData extends IReportPayload {\n value: Metric[\"value\"];\n rating?: Metric[\"rating\"]; // \"good\" | \"needs-improvement\" | \"poor\"\n}\n\ninterface IPerformanceResourceListData extends IReportPayload {\n resourceList: (PerformanceResourceTiming & {\n fromCache: boolean;\n })[];\n}\ninterface IPerformanceLongTaskData extends IReportPayload {\n longTasks: PerformanceEntry[];\n}\n\ninterface IPerformanceMemoryData extends IReportPayload {\n memory: unknown;\n}\n\nexport type IPerformanceData =\n | IPerformanceMetricData\n | IPerformanceResourceListData\n | IPerformanceLongTaskData\n | IPerformanceMemoryData;\n\nexport interface ICodeError extends IReportPayload {\n column: number;\n line: number;\n}\n\nexport interface IScreenRecordData extends IReportPayload {\n event: string;\n}\n\nexport interface IRouteData extends IReportPayload {\n from: string;\n to: string;\n}\n\nexport type IBaseDataWithEvent = IReportPayload & {\n extra: \"WhiteScreen\" | unknown;\n};\n\nexport type TReportPayload =\n | IBaseDataWithEvent\n | IHttpData\n | IResourceError\n | IPerformanceData\n | ICodeError\n | IScreenRecordData\n | IRouteData;\n\nexport type TOnReportWhiteScreenData = (data: IReportPayload) => void;\n\nexport type TOnReportPerformanceData = (data: IPerformanceData) => void;\n\nexport interface IReportData<\n T extends TReportPayload = TReportPayload,\n> extends IReportPayload {\n // 页面的地址\n url: string;\n // 用户 ID\n userId: string;\n // 前端项目的 ID\n projectId: string;\n // SDK 版本\n sdkVersion: string;\n breadcrumbs?: IBreadcrumbItem[];\n deviceInfo: IDeviceInfo;\n payload: T;\n}\n\nexport interface IDataReporter {\n send(payload: TReportPayload): Promise<void>;\n}\n\nexport interface IExtendedErrorEvent extends ErrorEvent {\n target: EventTarget & {\n src: string;\n href: string;\n localName: string;\n };\n}\n\nexport type TUnknownError = IExtendedErrorEvent | Error /** React */ | unknown;\n\nexport type WithSentry<T, S extends IReportPayload = IReportPayload> = T & {\n __sentry__: S;\n};\n\nexport abstract class SentryPlugin {\n public type: EventType;\n constructor(type: EventType) {\n this.type = type;\n }\n abstract init(): void;\n}\n","export enum HttpStatus {\n OK = \"OK\", // 200\n BadRequest = \"Bad Request\", // 400\n Unauthorized = \"Unauthorized\", // 401\n Forbidden = \"Forbidden\", // 403\n NotFound = \"NotFound\", // 404\n Conflict = \"Conflict\", // 409\n PayloadTooLarge = \"Payload Too Large\", // 413\n TooManyRequests = \"Too Many Requests\", // 429\n InternalServerError = \"Internal Server Error\", // 500\n NotImplemented = \"Not Implemented\", // 501\n ServiceUnavailable = \"Service Unavailable\", // 503\n GatewayTimeout = \"Gateway Timeout\", // 504\n UnknownError = \"Unknown Error\",\n}\n\nexport enum BreadcrumbType {\n // 网络请求\n Http = \"Http\",\n // 点击\n Click = \"Click\",\n // 路由导航\n Route = \"Route\",\n // 资源加载\n Resource = \"Resource\",\n // 代码报错\n CodeError = \"Code Error\",\n // 自定义\n Custom = \"Custom\",\n}\n\nexport enum Status {\n Error = \"Error\",\n OK = \"OK\",\n}\n\nexport enum EventType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n Click = \"Click\",\n HashChange = \"Event hashchange\",\n History = \"History\",\n Resource = \"Resource\",\n UnhandledRejection = \"Event unhandledrejection\",\n Error = \"Error\",\n Vue = \"Vue\",\n React = \"React\",\n Performance = \"Performance\",\n ScreenRecord = \"ScreenRecord\",\n WhiteScreen = \"WhiteScreen\",\n Custom = \"Custom\",\n}\n\nexport enum HttpType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n}\n\nexport enum HttpStatusCode {\n OK = 200,\n BadRequest = 400,\n Unauthorized = 401,\n Forbidden = 403,\n NotFound = 404,\n Conflict = 409,\n PayloadTooLarge = 413,\n TooManyRequests = 429,\n InternalServerError = 500,\n NotImplemented = 501,\n ServiceUnavailable = 503,\n GatewayTimeout = 504,\n}\n\nexport enum HttpMethod {\n Get = \"GET\",\n Head = \"HEAD\",\n Post = \"POST\",\n Put = \"PUT\",\n Delete = \"DELETE\",\n Connect = \"CONNECT\",\n Options = \"OPTIONS\",\n Trace = \"TRACE\",\n Patch = \"PATCH\",\n}\n"],"names":["HttpStatus","BreadcrumbType","Status","EventType","HttpType","HttpStatusCode","HttpMethod"],"mappings":";;;;;AAgJO,MAAe,YAAA,CAAa;AAAA,EAEjC,YAAY,IAAA,EAAiB;AAD7B,IAAA,aAAA,CAAA,IAAA,EAAO,MAAA,CAAA;AAEL,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAEF;;ACtJO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AACL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AACL,EAAAA,YAAA,YAAA,CAAA,GAAa,aAAA;AACb,EAAAA,YAAA,cAAA,CAAA,GAAe,cAAA;AACf,EAAAA,YAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,YAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,YAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,YAAA,iBAAA,CAAA,GAAkB,mBAAA;AAClB,EAAAA,YAAA,iBAAA,CAAA,GAAkB,mBAAA;AAClB,EAAAA,YAAA,qBAAA,CAAA,GAAsB,uBAAA;AACtB,EAAAA,YAAA,gBAAA,CAAA,GAAiB,iBAAA;AACjB,EAAAA,YAAA,oBAAA,CAAA,GAAqB,qBAAA;AACrB,EAAAA,YAAA,gBAAA,CAAA,GAAiB,iBAAA;AACjB,EAAAA,YAAA,cAAA,CAAA,GAAe,eAAA;AAbL,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AAgBL,IAAK,cAAA,qBAAAC,eAAAA,KAAL;AAEL,EAAAA,gBAAA,MAAA,CAAA,GAAO,MAAA;AAEP,EAAA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YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,YAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,YAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,YAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,YAAA,OAAA,CAAA,GAAQ,OAAA;AATE,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;;;;;;;;;;;"}
|
package/dist/index.d.cts
CHANGED
|
@@ -111,7 +111,7 @@ interface ISentry {
|
|
|
111
111
|
deviceInfo: IDeviceInfo;
|
|
112
112
|
setOptions: (newOptions: Partial<IOptions>) => void;
|
|
113
113
|
}
|
|
114
|
-
interface IBreadcrumbItem extends
|
|
114
|
+
interface IBreadcrumbItem extends IReportPayload {
|
|
115
115
|
userAction: BreadcrumbType;
|
|
116
116
|
}
|
|
117
117
|
interface IDeviceInfo {
|
|
@@ -123,7 +123,7 @@ interface IDeviceInfo {
|
|
|
123
123
|
deviceType: string;
|
|
124
124
|
deviceModel: string;
|
|
125
125
|
}
|
|
126
|
-
interface
|
|
126
|
+
interface IReportPayload {
|
|
127
127
|
id: string;
|
|
128
128
|
type: EventType;
|
|
129
129
|
name: string;
|
|
@@ -131,52 +131,53 @@ interface IBaseData<T = unknown> {
|
|
|
131
131
|
timestamp: number;
|
|
132
132
|
message: string;
|
|
133
133
|
status: Status;
|
|
134
|
-
payload?: T;
|
|
135
134
|
}
|
|
136
|
-
interface IHttpData
|
|
135
|
+
interface IHttpData extends IReportPayload {
|
|
137
136
|
method: HttpMethod | string;
|
|
138
137
|
api: string;
|
|
139
138
|
elapsedTime: number;
|
|
140
139
|
statusCode: number;
|
|
141
|
-
requestData?:
|
|
142
|
-
responseData?:
|
|
140
|
+
requestData?: unknown;
|
|
141
|
+
responseData?: unknown;
|
|
143
142
|
}
|
|
144
|
-
interface IResourceError extends
|
|
143
|
+
interface IResourceError extends IReportPayload {
|
|
145
144
|
src: string;
|
|
146
145
|
href: string;
|
|
147
146
|
}
|
|
148
|
-
interface IPerformanceMetricData extends
|
|
147
|
+
interface IPerformanceMetricData extends IReportPayload {
|
|
149
148
|
value: Metric["value"];
|
|
150
149
|
rating?: Metric["rating"];
|
|
151
150
|
}
|
|
152
|
-
interface IPerformanceResourceListData extends
|
|
151
|
+
interface IPerformanceResourceListData extends IReportPayload {
|
|
153
152
|
resourceList: (PerformanceResourceTiming & {
|
|
154
153
|
fromCache: boolean;
|
|
155
154
|
})[];
|
|
156
155
|
}
|
|
157
|
-
interface IPerformanceLongTaskData extends
|
|
156
|
+
interface IPerformanceLongTaskData extends IReportPayload {
|
|
158
157
|
longTasks: PerformanceEntry[];
|
|
159
158
|
}
|
|
160
|
-
interface IPerformanceMemoryData extends
|
|
159
|
+
interface IPerformanceMemoryData extends IReportPayload {
|
|
161
160
|
memory: unknown;
|
|
162
161
|
}
|
|
163
162
|
type IPerformanceData = IPerformanceMetricData | IPerformanceResourceListData | IPerformanceLongTaskData | IPerformanceMemoryData;
|
|
164
|
-
interface ICodeError extends
|
|
163
|
+
interface ICodeError extends IReportPayload {
|
|
165
164
|
column: number;
|
|
166
165
|
line: number;
|
|
167
166
|
}
|
|
168
|
-
interface IScreenRecordData extends
|
|
167
|
+
interface IScreenRecordData extends IReportPayload {
|
|
169
168
|
event: string;
|
|
170
169
|
}
|
|
171
|
-
interface IRouteData extends
|
|
170
|
+
interface IRouteData extends IReportPayload {
|
|
172
171
|
from: string;
|
|
173
172
|
to: string;
|
|
174
173
|
}
|
|
175
|
-
type
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
type IBaseDataWithEvent = IReportPayload & {
|
|
175
|
+
extra: "WhiteScreen" | unknown;
|
|
176
|
+
};
|
|
177
|
+
type TReportPayload = IBaseDataWithEvent | IHttpData | IResourceError | IPerformanceData | ICodeError | IScreenRecordData | IRouteData;
|
|
178
|
+
type TOnReportWhiteScreenData = (data: IReportPayload) => void;
|
|
178
179
|
type TOnReportPerformanceData = (data: IPerformanceData) => void;
|
|
179
|
-
interface IReportData<T extends TReportPayload = TReportPayload> extends
|
|
180
|
+
interface IReportData<T extends TReportPayload = TReportPayload> extends IReportPayload {
|
|
180
181
|
url: string;
|
|
181
182
|
userId: string;
|
|
182
183
|
projectId: string;
|
|
@@ -196,7 +197,7 @@ interface IExtendedErrorEvent extends ErrorEvent {
|
|
|
196
197
|
};
|
|
197
198
|
}
|
|
198
199
|
type TUnknownError = IExtendedErrorEvent | Error /** React */ | unknown;
|
|
199
|
-
type WithSentry<T, S extends
|
|
200
|
+
type WithSentry<T, S extends IReportPayload = IReportPayload> = T & {
|
|
200
201
|
__sentry__: S;
|
|
201
202
|
};
|
|
202
203
|
declare abstract class SentryPlugin {
|
|
@@ -205,25 +206,9 @@ declare abstract class SentryPlugin {
|
|
|
205
206
|
abstract init(): void;
|
|
206
207
|
}
|
|
207
208
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
[EventType.Error]: TUnknownError;
|
|
212
|
-
[EventType.History]: Pick<IRouteData, "from" | "to">;
|
|
213
|
-
[EventType.UnhandledRejection]: PromiseRejectionEvent;
|
|
214
|
-
[EventType.HashChange]: HashChangeEvent;
|
|
215
|
-
[EventType.Click]: PointerEvent;
|
|
216
|
-
[EventType.WhiteScreen]: unknown;
|
|
217
|
-
[EventType.Resource]: unknown;
|
|
218
|
-
[EventType.Vue]: unknown;
|
|
219
|
-
[EventType.React]: unknown;
|
|
220
|
-
[EventType.Performance]: unknown;
|
|
221
|
-
[EventType.ScreenRecord]: unknown;
|
|
222
|
-
[EventType.Custom]: unknown;
|
|
223
|
-
}
|
|
224
|
-
type TEventHandler<T extends EventType> = (data: IType2param[T]) => void;
|
|
225
|
-
type IPub = <T extends EventType>(type: T, param?: IType2param[T]) => void;
|
|
226
|
-
type ISub = <T extends EventType>(type: T, handler: TEventHandler<T>) => void;
|
|
209
|
+
type TEventHandler<T extends TReportPayload = TReportPayload> = (data: T) => void;
|
|
210
|
+
type IPub = (type: EventType, param: TReportPayload) => void;
|
|
211
|
+
type ISub<T extends TReportPayload = TReportPayload> = (type: EventType, handler: TEventHandler<T>) => void;
|
|
227
212
|
|
|
228
213
|
export { BreadcrumbType, EventType, HttpMethod, HttpStatus, HttpStatusCode, HttpType, SentryPlugin, Status };
|
|
229
|
-
export type {
|
|
214
|
+
export type { IBaseDataWithEvent, IBreadcrumbItem, ICodeError, IDataReporter, IDeviceInfo, IExtendedErrorEvent, IHttpData, IOptions, IPerformanceData, IPub, IReportData, IReportPayload, IResourceError, IRouteData, IScreenRecordData, ISentry, ISub, TEventHandler, TOnReportPerformanceData, TOnReportWhiteScreenData, TReportPayload, TUnknownError, WithSentry };
|
package/dist/index.d.ts
CHANGED
|
@@ -111,7 +111,7 @@ interface ISentry {
|
|
|
111
111
|
deviceInfo: IDeviceInfo;
|
|
112
112
|
setOptions: (newOptions: Partial<IOptions>) => void;
|
|
113
113
|
}
|
|
114
|
-
interface IBreadcrumbItem extends
|
|
114
|
+
interface IBreadcrumbItem extends IReportPayload {
|
|
115
115
|
userAction: BreadcrumbType;
|
|
116
116
|
}
|
|
117
117
|
interface IDeviceInfo {
|
|
@@ -123,7 +123,7 @@ interface IDeviceInfo {
|
|
|
123
123
|
deviceType: string;
|
|
124
124
|
deviceModel: string;
|
|
125
125
|
}
|
|
126
|
-
interface
|
|
126
|
+
interface IReportPayload {
|
|
127
127
|
id: string;
|
|
128
128
|
type: EventType;
|
|
129
129
|
name: string;
|
|
@@ -131,52 +131,53 @@ interface IBaseData<T = unknown> {
|
|
|
131
131
|
timestamp: number;
|
|
132
132
|
message: string;
|
|
133
133
|
status: Status;
|
|
134
|
-
payload?: T;
|
|
135
134
|
}
|
|
136
|
-
interface IHttpData
|
|
135
|
+
interface IHttpData extends IReportPayload {
|
|
137
136
|
method: HttpMethod | string;
|
|
138
137
|
api: string;
|
|
139
138
|
elapsedTime: number;
|
|
140
139
|
statusCode: number;
|
|
141
|
-
requestData?:
|
|
142
|
-
responseData?:
|
|
140
|
+
requestData?: unknown;
|
|
141
|
+
responseData?: unknown;
|
|
143
142
|
}
|
|
144
|
-
interface IResourceError extends
|
|
143
|
+
interface IResourceError extends IReportPayload {
|
|
145
144
|
src: string;
|
|
146
145
|
href: string;
|
|
147
146
|
}
|
|
148
|
-
interface IPerformanceMetricData extends
|
|
147
|
+
interface IPerformanceMetricData extends IReportPayload {
|
|
149
148
|
value: Metric["value"];
|
|
150
149
|
rating?: Metric["rating"];
|
|
151
150
|
}
|
|
152
|
-
interface IPerformanceResourceListData extends
|
|
151
|
+
interface IPerformanceResourceListData extends IReportPayload {
|
|
153
152
|
resourceList: (PerformanceResourceTiming & {
|
|
154
153
|
fromCache: boolean;
|
|
155
154
|
})[];
|
|
156
155
|
}
|
|
157
|
-
interface IPerformanceLongTaskData extends
|
|
156
|
+
interface IPerformanceLongTaskData extends IReportPayload {
|
|
158
157
|
longTasks: PerformanceEntry[];
|
|
159
158
|
}
|
|
160
|
-
interface IPerformanceMemoryData extends
|
|
159
|
+
interface IPerformanceMemoryData extends IReportPayload {
|
|
161
160
|
memory: unknown;
|
|
162
161
|
}
|
|
163
162
|
type IPerformanceData = IPerformanceMetricData | IPerformanceResourceListData | IPerformanceLongTaskData | IPerformanceMemoryData;
|
|
164
|
-
interface ICodeError extends
|
|
163
|
+
interface ICodeError extends IReportPayload {
|
|
165
164
|
column: number;
|
|
166
165
|
line: number;
|
|
167
166
|
}
|
|
168
|
-
interface IScreenRecordData extends
|
|
167
|
+
interface IScreenRecordData extends IReportPayload {
|
|
169
168
|
event: string;
|
|
170
169
|
}
|
|
171
|
-
interface IRouteData extends
|
|
170
|
+
interface IRouteData extends IReportPayload {
|
|
172
171
|
from: string;
|
|
173
172
|
to: string;
|
|
174
173
|
}
|
|
175
|
-
type
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
type IBaseDataWithEvent = IReportPayload & {
|
|
175
|
+
extra: "WhiteScreen" | unknown;
|
|
176
|
+
};
|
|
177
|
+
type TReportPayload = IBaseDataWithEvent | IHttpData | IResourceError | IPerformanceData | ICodeError | IScreenRecordData | IRouteData;
|
|
178
|
+
type TOnReportWhiteScreenData = (data: IReportPayload) => void;
|
|
178
179
|
type TOnReportPerformanceData = (data: IPerformanceData) => void;
|
|
179
|
-
interface IReportData<T extends TReportPayload = TReportPayload> extends
|
|
180
|
+
interface IReportData<T extends TReportPayload = TReportPayload> extends IReportPayload {
|
|
180
181
|
url: string;
|
|
181
182
|
userId: string;
|
|
182
183
|
projectId: string;
|
|
@@ -196,7 +197,7 @@ interface IExtendedErrorEvent extends ErrorEvent {
|
|
|
196
197
|
};
|
|
197
198
|
}
|
|
198
199
|
type TUnknownError = IExtendedErrorEvent | Error /** React */ | unknown;
|
|
199
|
-
type WithSentry<T, S extends
|
|
200
|
+
type WithSentry<T, S extends IReportPayload = IReportPayload> = T & {
|
|
200
201
|
__sentry__: S;
|
|
201
202
|
};
|
|
202
203
|
declare abstract class SentryPlugin {
|
|
@@ -205,25 +206,9 @@ declare abstract class SentryPlugin {
|
|
|
205
206
|
abstract init(): void;
|
|
206
207
|
}
|
|
207
208
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
[EventType.Error]: TUnknownError;
|
|
212
|
-
[EventType.History]: Pick<IRouteData, "from" | "to">;
|
|
213
|
-
[EventType.UnhandledRejection]: PromiseRejectionEvent;
|
|
214
|
-
[EventType.HashChange]: HashChangeEvent;
|
|
215
|
-
[EventType.Click]: PointerEvent;
|
|
216
|
-
[EventType.WhiteScreen]: unknown;
|
|
217
|
-
[EventType.Resource]: unknown;
|
|
218
|
-
[EventType.Vue]: unknown;
|
|
219
|
-
[EventType.React]: unknown;
|
|
220
|
-
[EventType.Performance]: unknown;
|
|
221
|
-
[EventType.ScreenRecord]: unknown;
|
|
222
|
-
[EventType.Custom]: unknown;
|
|
223
|
-
}
|
|
224
|
-
type TEventHandler<T extends EventType> = (data: IType2param[T]) => void;
|
|
225
|
-
type IPub = <T extends EventType>(type: T, param?: IType2param[T]) => void;
|
|
226
|
-
type ISub = <T extends EventType>(type: T, handler: TEventHandler<T>) => void;
|
|
209
|
+
type TEventHandler<T extends TReportPayload = TReportPayload> = (data: T) => void;
|
|
210
|
+
type IPub = (type: EventType, param: TReportPayload) => void;
|
|
211
|
+
type ISub<T extends TReportPayload = TReportPayload> = (type: EventType, handler: TEventHandler<T>) => void;
|
|
227
212
|
|
|
228
213
|
export { BreadcrumbType, EventType, HttpMethod, HttpStatus, HttpStatusCode, HttpType, SentryPlugin, Status };
|
|
229
|
-
export type {
|
|
214
|
+
export type { IBaseDataWithEvent, IBreadcrumbItem, ICodeError, IDataReporter, IDeviceInfo, IExtendedErrorEvent, IHttpData, IOptions, IPerformanceData, IPub, IReportData, IReportPayload, IResourceError, IRouteData, IScreenRecordData, ISentry, ISub, TEventHandler, TOnReportPerformanceData, TOnReportWhiteScreenData, TReportPayload, TUnknownError, WithSentry };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/common.ts","../src/enums.ts"],"sourcesContent":["import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/common.ts","../src/enums.ts"],"sourcesContent":["import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends IReportPayload {\n userAction: BreadcrumbType;\n}\n\nexport interface IDeviceInfo {\n browserName: string; // 例如 chrome\n browserVersion: string; // 浏览器版本\n osName: string; // 操作系统\n osVersion: string; // 操作系统版本\n userAgent: string; // 用户代理\n deviceType: string; // 设备种类, 例如 PC\n deviceModel: string; // 设备描述\n}\n\nexport interface IReportPayload {\n id: string;\n type: EventType;\n name: string;\n time: string;\n timestamp: number;\n message: string;\n status: Status;\n}\n\nexport interface IHttpData extends IReportPayload {\n method: HttpMethod | string;\n // 接口地址\n api: string;\n // 请求时长\n elapsedTime: number;\n // http 状态码\n statusCode: number;\n requestData?: unknown;\n responseData?: unknown;\n}\n\nexport interface IResourceError extends IReportPayload {\n src: string;\n href: string;\n}\n\ninterface IPerformanceMetricData extends IReportPayload {\n value: Metric[\"value\"];\n rating?: Metric[\"rating\"]; // \"good\" | \"needs-improvement\" | \"poor\"\n}\n\ninterface IPerformanceResourceListData extends IReportPayload {\n resourceList: (PerformanceResourceTiming & {\n fromCache: boolean;\n })[];\n}\ninterface IPerformanceLongTaskData extends IReportPayload {\n longTasks: PerformanceEntry[];\n}\n\ninterface IPerformanceMemoryData extends IReportPayload {\n memory: unknown;\n}\n\nexport type IPerformanceData =\n | IPerformanceMetricData\n | IPerformanceResourceListData\n | IPerformanceLongTaskData\n | IPerformanceMemoryData;\n\nexport interface ICodeError extends IReportPayload {\n column: number;\n line: number;\n}\n\nexport interface IScreenRecordData extends IReportPayload {\n event: string;\n}\n\nexport interface IRouteData extends IReportPayload {\n from: string;\n to: string;\n}\n\nexport type IBaseDataWithEvent = IReportPayload & {\n extra: \"WhiteScreen\" | unknown;\n};\n\nexport type TReportPayload =\n | IBaseDataWithEvent\n | IHttpData\n | IResourceError\n | IPerformanceData\n | ICodeError\n | IScreenRecordData\n | IRouteData;\n\nexport type TOnReportWhiteScreenData = (data: IReportPayload) => void;\n\nexport type TOnReportPerformanceData = (data: IPerformanceData) => void;\n\nexport interface IReportData<\n T extends TReportPayload = TReportPayload,\n> extends IReportPayload {\n // 页面的地址\n url: string;\n // 用户 ID\n userId: string;\n // 前端项目的 ID\n projectId: string;\n // SDK 版本\n sdkVersion: string;\n breadcrumbs?: IBreadcrumbItem[];\n deviceInfo: IDeviceInfo;\n payload: T;\n}\n\nexport interface IDataReporter {\n send(payload: TReportPayload): Promise<void>;\n}\n\nexport interface IExtendedErrorEvent extends ErrorEvent {\n target: EventTarget & {\n src: string;\n href: string;\n localName: string;\n };\n}\n\nexport type TUnknownError = IExtendedErrorEvent | Error /** React */ | unknown;\n\nexport type WithSentry<T, S extends IReportPayload = IReportPayload> = T & {\n __sentry__: S;\n};\n\nexport abstract class SentryPlugin {\n public type: EventType;\n constructor(type: EventType) {\n this.type = type;\n }\n abstract init(): void;\n}\n","export enum HttpStatus {\n OK = \"OK\", // 200\n BadRequest = \"Bad Request\", // 400\n Unauthorized = \"Unauthorized\", // 401\n Forbidden = \"Forbidden\", // 403\n NotFound = \"NotFound\", // 404\n Conflict = \"Conflict\", // 409\n PayloadTooLarge = \"Payload Too Large\", // 413\n TooManyRequests = \"Too Many Requests\", // 429\n InternalServerError = \"Internal Server Error\", // 500\n NotImplemented = \"Not Implemented\", // 501\n ServiceUnavailable = \"Service Unavailable\", // 503\n GatewayTimeout = \"Gateway Timeout\", // 504\n UnknownError = \"Unknown Error\",\n}\n\nexport enum BreadcrumbType {\n // 网络请求\n Http = \"Http\",\n // 点击\n Click = \"Click\",\n // 路由导航\n Route = \"Route\",\n // 资源加载\n Resource = \"Resource\",\n // 代码报错\n CodeError = \"Code Error\",\n // 自定义\n Custom = \"Custom\",\n}\n\nexport enum Status {\n Error = \"Error\",\n OK = \"OK\",\n}\n\nexport enum EventType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n Click = \"Click\",\n HashChange = \"Event hashchange\",\n History = \"History\",\n Resource = \"Resource\",\n UnhandledRejection = \"Event unhandledrejection\",\n Error = \"Error\",\n Vue = \"Vue\",\n React = \"React\",\n Performance = \"Performance\",\n ScreenRecord = \"ScreenRecord\",\n WhiteScreen = \"WhiteScreen\",\n Custom = \"Custom\",\n}\n\nexport enum HttpType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n}\n\nexport enum HttpStatusCode {\n OK = 200,\n BadRequest = 400,\n Unauthorized = 401,\n Forbidden = 403,\n NotFound = 404,\n Conflict = 409,\n PayloadTooLarge = 413,\n TooManyRequests = 429,\n InternalServerError = 500,\n NotImplemented = 501,\n ServiceUnavailable = 503,\n GatewayTimeout = 504,\n}\n\nexport enum HttpMethod {\n Get = \"GET\",\n Head = \"HEAD\",\n Post = \"POST\",\n Put = \"PUT\",\n Delete = \"DELETE\",\n Connect = \"CONNECT\",\n Options = \"OPTIONS\",\n Trace = \"TRACE\",\n Patch = \"PATCH\",\n}\n"],"names":["HttpStatus","BreadcrumbType","Status","EventType","HttpType","HttpStatusCode","HttpMethod"],"mappings":";;;AAgJO,MAAe,YAAA,CAAa;AAAA,EAEjC,YAAY,IAAA,EAAiB;AAD7B,IAAA,aAAA,CAAA,IAAA,EAAO,MAAA,CAAA;AAEL,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAEF;;ACtJO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AACL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AACL,EAAAA,YAAA,YAAA,CAAA,GAAa,aAAA;AACb,EAAAA,YAAA,cAAA,CAAA,GAAe,cAAA;AACf,EAAAA,YAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,YAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,YAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,YAAA,iBAAA,CAAA,GAAkB,mBAAA;AAClB,EAAAA,YAAA,iBAAA,CAAA,GAAkB,mBAAA;AAClB,EAAAA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AiB,GAAA,CAAA,GAAjB,gBAAA;AACA,EAAAA,eAAAA,CAAAA,eAAAA,CAAA,wBAAqB,GAAA,CAAA,GAArB,oBAAA;AACA,EAAAA,eAAAA,CAAAA,eAAAA,CAAA,oBAAiB,GAAA,CAAA,GAAjB,gBAAA;AAZU,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;AAeL,IAAK,UAAA,qBAAAC,WAAAA,KAAL;AACL,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,YAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,YAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,YAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,YAAA,OAAA,CAAA,GAAQ,OAAA;AATE,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;;;;"}
|
package/dist/index.min.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.min.cjs","sources":["../src/enums.ts","../src/common.ts"],"sourcesContent":["export enum HttpStatus {\n OK = \"OK\", // 200\n BadRequest = \"Bad Request\", // 400\n Unauthorized = \"Unauthorized\", // 401\n Forbidden = \"Forbidden\", // 403\n NotFound = \"NotFound\", // 404\n Conflict = \"Conflict\", // 409\n PayloadTooLarge = \"Payload Too Large\", // 413\n TooManyRequests = \"Too Many Requests\", // 429\n InternalServerError = \"Internal Server Error\", // 500\n NotImplemented = \"Not Implemented\", // 501\n ServiceUnavailable = \"Service Unavailable\", // 503\n GatewayTimeout = \"Gateway Timeout\", // 504\n UnknownError = \"Unknown Error\",\n}\n\nexport enum BreadcrumbType {\n // 网络请求\n Http = \"Http\",\n // 点击\n Click = \"Click\",\n // 路由导航\n Route = \"Route\",\n // 资源加载\n Resource = \"Resource\",\n // 代码报错\n CodeError = \"Code Error\",\n // 自定义\n Custom = \"Custom\",\n}\n\nexport enum Status {\n Error = \"Error\",\n OK = \"OK\",\n}\n\nexport enum EventType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n Click = \"Click\",\n HashChange = \"Event hashchange\",\n History = \"History\",\n Resource = \"Resource\",\n UnhandledRejection = \"Event unhandledrejection\",\n Error = \"Error\",\n Vue = \"Vue\",\n React = \"React\",\n Performance = \"Performance\",\n ScreenRecord = \"ScreenRecord\",\n WhiteScreen = \"WhiteScreen\",\n Custom = \"Custom\",\n}\n\nexport enum HttpType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n}\n\nexport enum HttpStatusCode {\n OK = 200,\n BadRequest = 400,\n Unauthorized = 401,\n Forbidden = 403,\n NotFound = 404,\n Conflict = 409,\n PayloadTooLarge = 413,\n TooManyRequests = 429,\n InternalServerError = 500,\n NotImplemented = 501,\n ServiceUnavailable = 503,\n GatewayTimeout = 504,\n}\n\nexport enum HttpMethod {\n Get = \"GET\",\n Head = \"HEAD\",\n Post = \"POST\",\n Put = \"PUT\",\n Delete = \"DELETE\",\n Connect = \"CONNECT\",\n Options = \"OPTIONS\",\n Trace = \"TRACE\",\n Patch = \"PATCH\",\n}\n","import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends
|
|
1
|
+
{"version":3,"file":"index.min.cjs","sources":["../src/enums.ts","../src/common.ts"],"sourcesContent":["export enum HttpStatus {\n OK = \"OK\", // 200\n BadRequest = \"Bad Request\", // 400\n Unauthorized = \"Unauthorized\", // 401\n Forbidden = \"Forbidden\", // 403\n NotFound = \"NotFound\", // 404\n Conflict = \"Conflict\", // 409\n PayloadTooLarge = \"Payload Too Large\", // 413\n TooManyRequests = \"Too Many Requests\", // 429\n InternalServerError = \"Internal Server Error\", // 500\n NotImplemented = \"Not Implemented\", // 501\n ServiceUnavailable = \"Service Unavailable\", // 503\n GatewayTimeout = \"Gateway Timeout\", // 504\n UnknownError = \"Unknown Error\",\n}\n\nexport enum BreadcrumbType {\n // 网络请求\n Http = \"Http\",\n // 点击\n Click = \"Click\",\n // 路由导航\n Route = \"Route\",\n // 资源加载\n Resource = \"Resource\",\n // 代码报错\n CodeError = \"Code Error\",\n // 自定义\n Custom = \"Custom\",\n}\n\nexport enum Status {\n Error = \"Error\",\n OK = \"OK\",\n}\n\nexport enum EventType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n Click = \"Click\",\n HashChange = \"Event hashchange\",\n History = \"History\",\n Resource = \"Resource\",\n UnhandledRejection = \"Event unhandledrejection\",\n Error = \"Error\",\n Vue = \"Vue\",\n React = \"React\",\n Performance = \"Performance\",\n ScreenRecord = \"ScreenRecord\",\n WhiteScreen = \"WhiteScreen\",\n Custom = \"Custom\",\n}\n\nexport enum HttpType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n}\n\nexport enum HttpStatusCode {\n OK = 200,\n BadRequest = 400,\n Unauthorized = 401,\n Forbidden = 403,\n NotFound = 404,\n Conflict = 409,\n PayloadTooLarge = 413,\n TooManyRequests = 429,\n InternalServerError = 500,\n NotImplemented = 501,\n ServiceUnavailable = 503,\n GatewayTimeout = 504,\n}\n\nexport enum HttpMethod {\n Get = \"GET\",\n Head = \"HEAD\",\n Post = \"POST\",\n Put = \"PUT\",\n Delete = \"DELETE\",\n Connect = \"CONNECT\",\n Options = \"OPTIONS\",\n Trace = \"TRACE\",\n Patch = \"PATCH\",\n}\n","import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends IReportPayload {\n userAction: BreadcrumbType;\n}\n\nexport interface IDeviceInfo {\n browserName: string; // 例如 chrome\n browserVersion: string; // 浏览器版本\n osName: string; // 操作系统\n osVersion: string; // 操作系统版本\n userAgent: string; // 用户代理\n deviceType: string; // 设备种类, 例如 PC\n deviceModel: string; // 设备描述\n}\n\nexport interface IReportPayload {\n id: string;\n type: EventType;\n name: string;\n time: string;\n timestamp: number;\n message: string;\n status: Status;\n}\n\nexport interface IHttpData extends IReportPayload {\n method: HttpMethod | string;\n // 接口地址\n api: string;\n // 请求时长\n elapsedTime: number;\n // http 状态码\n statusCode: number;\n requestData?: unknown;\n responseData?: unknown;\n}\n\nexport interface IResourceError extends IReportPayload {\n src: string;\n href: string;\n}\n\ninterface IPerformanceMetricData extends IReportPayload {\n value: Metric[\"value\"];\n rating?: Metric[\"rating\"]; // \"good\" | \"needs-improvement\" | \"poor\"\n}\n\ninterface IPerformanceResourceListData extends IReportPayload {\n resourceList: (PerformanceResourceTiming & {\n fromCache: boolean;\n })[];\n}\ninterface IPerformanceLongTaskData extends IReportPayload {\n longTasks: PerformanceEntry[];\n}\n\ninterface IPerformanceMemoryData extends IReportPayload {\n memory: unknown;\n}\n\nexport type IPerformanceData =\n | IPerformanceMetricData\n | IPerformanceResourceListData\n | IPerformanceLongTaskData\n | IPerformanceMemoryData;\n\nexport interface ICodeError extends IReportPayload {\n column: number;\n line: number;\n}\n\nexport interface IScreenRecordData extends IReportPayload {\n event: string;\n}\n\nexport interface IRouteData extends IReportPayload {\n from: string;\n to: string;\n}\n\nexport type IBaseDataWithEvent = IReportPayload & {\n extra: \"WhiteScreen\" | unknown;\n};\n\nexport type TReportPayload =\n | IBaseDataWithEvent\n | IHttpData\n | IResourceError\n | IPerformanceData\n | ICodeError\n | IScreenRecordData\n | IRouteData;\n\nexport type TOnReportWhiteScreenData = (data: IReportPayload) => void;\n\nexport type TOnReportPerformanceData = (data: IPerformanceData) => void;\n\nexport interface IReportData<\n T extends TReportPayload = TReportPayload,\n> extends IReportPayload {\n // 页面的地址\n url: string;\n // 用户 ID\n userId: string;\n // 前端项目的 ID\n projectId: string;\n // SDK 版本\n sdkVersion: string;\n breadcrumbs?: IBreadcrumbItem[];\n deviceInfo: IDeviceInfo;\n payload: T;\n}\n\nexport interface IDataReporter {\n send(payload: TReportPayload): Promise<void>;\n}\n\nexport interface IExtendedErrorEvent extends ErrorEvent {\n target: EventTarget & {\n src: string;\n href: string;\n localName: string;\n };\n}\n\nexport type TUnknownError = IExtendedErrorEvent | Error /** React */ | unknown;\n\nexport type WithSentry<T, S extends IReportPayload = IReportPayload> = T & {\n __sentry__: S;\n};\n\nexport abstract class SentryPlugin {\n public type: EventType;\n constructor(type: EventType) {\n this.type = type;\n }\n abstract init(): void;\n}\n"],"names":["HttpStatus","BreadcrumbType","Status","EventType","HttpType","HttpStatusCode","HttpMethod","constructor","type","__publicField","this"],"mappings":"kJAAO,IAAKA,GAAAA,IACVA,EAAA,GAAK,KACLA,EAAA,WAAa,cACbA,EAAA,aAAe,eACfA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,gBAAkB,oBAClBA,EAAA,gBAAkB,oBAClBA,EAAA,oBAAsB,wBACtBA,EAAA,eAAiB,kBACjBA,EAAA,mBAAqB,sBACrBA,EAAA,eAAiB,kBACjBA,EAAA,aAAe,gBAbLA,IAAAA,GAAA,CAAA,GAgBAC,GAAAA,IAEVA,EAAA,KAAO,OAEPA,EAAA,MAAQ,QAERA,EAAA,MAAQ,QAERA,EAAA,SAAW,WAEXA,EAAA,UAAY,aAEZA,EA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":["../src/common.ts","../src/enums.ts"],"sourcesContent":["import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends
|
|
1
|
+
{"version":3,"file":"index.min.js","sources":["../src/common.ts","../src/enums.ts"],"sourcesContent":["import type { BreadcrumbType, EventType, HttpMethod, Status } from \"./enums.js\";\n\nimport type { Metric } from \"web-vitals\";\nimport type { IOptions } from \"./options.js\";\n\nexport interface ISentry {\n codeErrors: Set<string>;\n whiteScreenTimer: number | null;\n options: IOptions;\n shouldRecordScreen: boolean;\n deviceInfo: IDeviceInfo;\n setOptions: (newOptions: Partial<IOptions>) => void;\n}\n\nexport interface IBreadcrumbItem extends IReportPayload {\n userAction: BreadcrumbType;\n}\n\nexport interface IDeviceInfo {\n browserName: string; // 例如 chrome\n browserVersion: string; // 浏览器版本\n osName: string; // 操作系统\n osVersion: string; // 操作系统版本\n userAgent: string; // 用户代理\n deviceType: string; // 设备种类, 例如 PC\n deviceModel: string; // 设备描述\n}\n\nexport interface IReportPayload {\n id: string;\n type: EventType;\n name: string;\n time: string;\n timestamp: number;\n message: string;\n status: Status;\n}\n\nexport interface IHttpData extends IReportPayload {\n method: HttpMethod | string;\n // 接口地址\n api: string;\n // 请求时长\n elapsedTime: number;\n // http 状态码\n statusCode: number;\n requestData?: unknown;\n responseData?: unknown;\n}\n\nexport interface IResourceError extends IReportPayload {\n src: string;\n href: string;\n}\n\ninterface IPerformanceMetricData extends IReportPayload {\n value: Metric[\"value\"];\n rating?: Metric[\"rating\"]; // \"good\" | \"needs-improvement\" | \"poor\"\n}\n\ninterface IPerformanceResourceListData extends IReportPayload {\n resourceList: (PerformanceResourceTiming & {\n fromCache: boolean;\n })[];\n}\ninterface IPerformanceLongTaskData extends IReportPayload {\n longTasks: PerformanceEntry[];\n}\n\ninterface IPerformanceMemoryData extends IReportPayload {\n memory: unknown;\n}\n\nexport type IPerformanceData =\n | IPerformanceMetricData\n | IPerformanceResourceListData\n | IPerformanceLongTaskData\n | IPerformanceMemoryData;\n\nexport interface ICodeError extends IReportPayload {\n column: number;\n line: number;\n}\n\nexport interface IScreenRecordData extends IReportPayload {\n event: string;\n}\n\nexport interface IRouteData extends IReportPayload {\n from: string;\n to: string;\n}\n\nexport type IBaseDataWithEvent = IReportPayload & {\n extra: \"WhiteScreen\" | unknown;\n};\n\nexport type TReportPayload =\n | IBaseDataWithEvent\n | IHttpData\n | IResourceError\n | IPerformanceData\n | ICodeError\n | IScreenRecordData\n | IRouteData;\n\nexport type TOnReportWhiteScreenData = (data: IReportPayload) => void;\n\nexport type TOnReportPerformanceData = (data: IPerformanceData) => void;\n\nexport interface IReportData<\n T extends TReportPayload = TReportPayload,\n> extends IReportPayload {\n // 页面的地址\n url: string;\n // 用户 ID\n userId: string;\n // 前端项目的 ID\n projectId: string;\n // SDK 版本\n sdkVersion: string;\n breadcrumbs?: IBreadcrumbItem[];\n deviceInfo: IDeviceInfo;\n payload: T;\n}\n\nexport interface IDataReporter {\n send(payload: TReportPayload): Promise<void>;\n}\n\nexport interface IExtendedErrorEvent extends ErrorEvent {\n target: EventTarget & {\n src: string;\n href: string;\n localName: string;\n };\n}\n\nexport type TUnknownError = IExtendedErrorEvent | Error /** React */ | unknown;\n\nexport type WithSentry<T, S extends IReportPayload = IReportPayload> = T & {\n __sentry__: S;\n};\n\nexport abstract class SentryPlugin {\n public type: EventType;\n constructor(type: EventType) {\n this.type = type;\n }\n abstract init(): void;\n}\n","export enum HttpStatus {\n OK = \"OK\", // 200\n BadRequest = \"Bad Request\", // 400\n Unauthorized = \"Unauthorized\", // 401\n Forbidden = \"Forbidden\", // 403\n NotFound = \"NotFound\", // 404\n Conflict = \"Conflict\", // 409\n PayloadTooLarge = \"Payload Too Large\", // 413\n TooManyRequests = \"Too Many Requests\", // 429\n InternalServerError = \"Internal Server Error\", // 500\n NotImplemented = \"Not Implemented\", // 501\n ServiceUnavailable = \"Service Unavailable\", // 503\n GatewayTimeout = \"Gateway Timeout\", // 504\n UnknownError = \"Unknown Error\",\n}\n\nexport enum BreadcrumbType {\n // 网络请求\n Http = \"Http\",\n // 点击\n Click = \"Click\",\n // 路由导航\n Route = \"Route\",\n // 资源加载\n Resource = \"Resource\",\n // 代码报错\n CodeError = \"Code Error\",\n // 自定义\n Custom = \"Custom\",\n}\n\nexport enum Status {\n Error = \"Error\",\n OK = \"OK\",\n}\n\nexport enum EventType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n Click = \"Click\",\n HashChange = \"Event hashchange\",\n History = \"History\",\n Resource = \"Resource\",\n UnhandledRejection = \"Event unhandledrejection\",\n Error = \"Error\",\n Vue = \"Vue\",\n React = \"React\",\n Performance = \"Performance\",\n ScreenRecord = \"ScreenRecord\",\n WhiteScreen = \"WhiteScreen\",\n Custom = \"Custom\",\n}\n\nexport enum HttpType {\n Xhr = \"XMLHttpRequest\",\n Fetch = \"fetch\",\n}\n\nexport enum HttpStatusCode {\n OK = 200,\n BadRequest = 400,\n Unauthorized = 401,\n Forbidden = 403,\n NotFound = 404,\n Conflict = 409,\n PayloadTooLarge = 413,\n TooManyRequests = 429,\n InternalServerError = 500,\n NotImplemented = 501,\n ServiceUnavailable = 503,\n GatewayTimeout = 504,\n}\n\nexport enum HttpMethod {\n Get = \"GET\",\n Head = \"HEAD\",\n Post = \"POST\",\n Put = \"PUT\",\n Delete = \"DELETE\",\n Connect = \"CONNECT\",\n Options = \"OPTIONS\",\n Trace = \"TRACE\",\n Patch = \"PATCH\",\n}\n"],"names":["SentryPlugin","constructor","type","__publicField","this","HttpStatus","BreadcrumbType","Status","EventType","HttpType","HttpStatusCode","HttpMethod"],"mappings":"qIAgJO,MAAeA,EAEpB,WAAAC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