@watchupltd/browser 0.1.9
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.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/package.json +19 -0
- package/src/index.d.ts +10 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +60 -0
- package/src/index.js.map +1 -0
- package/src/index.ts +73 -0
- package/tsconfig.json +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WatchUpClient, WatchUpClientOptions } from "@watchup/core";
|
|
2
|
+
export * from "@watchup/core";
|
|
3
|
+
export interface BrowserWatchUpOptions extends WatchUpClientOptions {
|
|
4
|
+
autoCaptureErrors?: boolean;
|
|
5
|
+
autoCaptureUnhandledRejections?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function initBrowserWatchUp(options: BrowserWatchUpOptions): WatchUpClient;
|
|
8
|
+
export declare function getWatchUpClient(): WatchUpClient;
|
|
9
|
+
export declare function shutdownBrowserWatchUp(): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACjF,cAAc,eAAe,CAAC;AAE9B,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAKD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa,CAiDhF;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { initWatchUp } from "@watchup/core";
|
|
2
|
+
export * from "@watchup/core";
|
|
3
|
+
let activeClient;
|
|
4
|
+
let cleanup;
|
|
5
|
+
export function initBrowserWatchUp(options) {
|
|
6
|
+
cleanup?.();
|
|
7
|
+
const client = initWatchUp({
|
|
8
|
+
platform: "browser",
|
|
9
|
+
...options
|
|
10
|
+
});
|
|
11
|
+
const disposers = [];
|
|
12
|
+
if (typeof window !== "undefined" && options.autoCaptureErrors !== false) {
|
|
13
|
+
const onError = (event) => {
|
|
14
|
+
void client.captureException(event.error ?? event.message, {
|
|
15
|
+
service: options.service ?? "frontend",
|
|
16
|
+
metadata: {
|
|
17
|
+
filename: event.filename,
|
|
18
|
+
lineno: event.lineno,
|
|
19
|
+
colno: event.colno,
|
|
20
|
+
url: window.location.href
|
|
21
|
+
},
|
|
22
|
+
user_agent: navigator.userAgent
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
window.addEventListener("error", onError);
|
|
26
|
+
disposers.push(() => window.removeEventListener("error", onError));
|
|
27
|
+
}
|
|
28
|
+
if (typeof window !== "undefined" && options.autoCaptureUnhandledRejections !== false) {
|
|
29
|
+
const onRejection = (event) => {
|
|
30
|
+
void client.captureException(event.reason, {
|
|
31
|
+
service: options.service ?? "frontend",
|
|
32
|
+
metadata: {
|
|
33
|
+
type: "unhandledrejection",
|
|
34
|
+
url: window.location.href
|
|
35
|
+
},
|
|
36
|
+
user_agent: navigator.userAgent
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
40
|
+
disposers.push(() => window.removeEventListener("unhandledrejection", onRejection));
|
|
41
|
+
}
|
|
42
|
+
activeClient = client;
|
|
43
|
+
cleanup = () => {
|
|
44
|
+
disposers.forEach((dispose) => dispose());
|
|
45
|
+
client.close();
|
|
46
|
+
activeClient = undefined;
|
|
47
|
+
};
|
|
48
|
+
return client;
|
|
49
|
+
}
|
|
50
|
+
export function getWatchUpClient() {
|
|
51
|
+
if (!activeClient) {
|
|
52
|
+
throw new Error("WatchUp browser client has not been initialized");
|
|
53
|
+
}
|
|
54
|
+
return activeClient;
|
|
55
|
+
}
|
|
56
|
+
export function shutdownBrowserWatchUp() {
|
|
57
|
+
cleanup?.();
|
|
58
|
+
cleanup = undefined;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuC,MAAM,eAAe,CAAC;AACjF,cAAc,eAAe,CAAC;AAO9B,IAAI,YAAuC,CAAC;AAC5C,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,kBAAkB,CAAC,OAA8B;IAC/D,OAAO,EAAE,EAAE,CAAC;IAEZ,MAAM,MAAM,GAAG,WAAW,CAAC;QACzB,QAAQ,EAAE,SAAS;QACnB,GAAG,OAAO;KACX,CAAC,CAAC;IACH,MAAM,SAAS,GAAsB,EAAE,CAAC;IAExC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,iBAAiB,KAAK,KAAK,EAAE,CAAC;QACzE,MAAM,OAAO,GAAG,CAAC,KAAiB,EAAE,EAAE;YACpC,KAAK,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE;gBACzD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,UAAU;gBACtC,QAAQ,EAAE;oBACR,QAAQ,EAAE,KAAK,CAAC,QAAQ;oBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;iBAC1B;gBACD,UAAU,EAAE,SAAS,CAAC,SAAS;aAChC,CAAC,CAAC;QACL,CAAC,CAAC;QACF,MAAM,CA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sB;IACpC,OAAO,EAAE,EAAE,CAAC;IACZ,OAAO,GAAG,SAAS,CAAC;AACtB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@watchupltd/browser",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.json"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@watchupltd/core": "0.1.9"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WatchUpClient, WatchUpClientOptions } from "@watchup/core";
|
|
2
|
+
export * from "@watchup/core";
|
|
3
|
+
export interface BrowserWatchUpOptions extends WatchUpClientOptions {
|
|
4
|
+
autoCaptureErrors?: boolean;
|
|
5
|
+
autoCaptureUnhandledRejections?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function initBrowserWatchUp(options: BrowserWatchUpOptions): WatchUpClient;
|
|
8
|
+
export declare function getWatchUpClient(): WatchUpClient;
|
|
9
|
+
export declare function shutdownBrowserWatchUp(): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACjF,cAAc,eAAe,CAAC;AAE9B,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAKD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa,CAiDhF;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { initWatchUp } from "@watchup/core";
|
|
2
|
+
export * from "@watchup/core";
|
|
3
|
+
let activeClient;
|
|
4
|
+
let cleanup;
|
|
5
|
+
export function initBrowserWatchUp(options) {
|
|
6
|
+
cleanup?.();
|
|
7
|
+
const client = initWatchUp({
|
|
8
|
+
platform: "browser",
|
|
9
|
+
...options
|
|
10
|
+
});
|
|
11
|
+
const disposers = [];
|
|
12
|
+
if (typeof window !== "undefined" && options.autoCaptureErrors !== false) {
|
|
13
|
+
const onError = (event) => {
|
|
14
|
+
void client.captureException(event.error ?? event.message, {
|
|
15
|
+
service: options.service ?? "frontend",
|
|
16
|
+
metadata: {
|
|
17
|
+
filename: event.filename,
|
|
18
|
+
lineno: event.lineno,
|
|
19
|
+
colno: event.colno,
|
|
20
|
+
url: window.location.href
|
|
21
|
+
},
|
|
22
|
+
user_agent: navigator.userAgent
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
window.addEventListener("error", onError);
|
|
26
|
+
disposers.push(() => window.removeEventListener("error", onError));
|
|
27
|
+
}
|
|
28
|
+
if (typeof window !== "undefined" && options.autoCaptureUnhandledRejections !== false) {
|
|
29
|
+
const onRejection = (event) => {
|
|
30
|
+
void client.captureException(event.reason, {
|
|
31
|
+
service: options.service ?? "frontend",
|
|
32
|
+
metadata: {
|
|
33
|
+
type: "unhandledrejection",
|
|
34
|
+
url: window.location.href
|
|
35
|
+
},
|
|
36
|
+
user_agent: navigator.userAgent
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
40
|
+
disposers.push(() => window.removeEventListener("unhandledrejection", onRejection));
|
|
41
|
+
}
|
|
42
|
+
activeClient = client;
|
|
43
|
+
cleanup = () => {
|
|
44
|
+
disposers.forEach((dispose) => dispose());
|
|
45
|
+
client.close();
|
|
46
|
+
activeClient = undefined;
|
|
47
|
+
};
|
|
48
|
+
return client;
|
|
49
|
+
}
|
|
50
|
+
export function getWatchUpClient() {
|
|
51
|
+
if (!activeClient) {
|
|
52
|
+
throw new Error("WatchUp browser client has not been initialized");
|
|
53
|
+
}
|
|
54
|
+
return activeClient;
|
|
55
|
+
}
|
|
56
|
+
export function shutdownBrowserWatchUp() {
|
|
57
|
+
cleanup?.();
|
|
58
|
+
cleanup = undefined;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuC,MAAM,eAAe,CAAC;AACjF,cAAc,eAAe,CAAC;AAO9B,IAAI,YAAuC,CAAC;AAC5C,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,kBAAkB,CAAC,OAA8B;IAC/D,OAAO,EAAE,EAAE,CAAC;IAEZ,MAAM,MAAM,GAAG,WAAW,CAAC;QACzB,QAAQ,EAAE,SAAS;QACnB,GAAG,OAAO;KACX,CAAC,CAAC;IACH,MAAM,SAAS,GAAsB,EAAE,CAAC;IAExC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,iBAAiB,KAAK,KAAK,EAAE,CAAC;QACzE,MAAM,OAAO,GAAG,CAAC,KAAiB,EAAE,EAAE;YACpC,KAAK,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE;gBACzD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,UAAU;gBACtC,QAAQ,EAAE;oBACR,QAAQ,EAAE,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IAC3B,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO,EAAE,EAAE,CAAC;IACZ,OAAO,GAAG,SAAS,CAAC;AACtB,CAAC"}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { initWatchUp, WatchUpClient, WatchUpClientOptions } from "@watchup/core";
|
|
2
|
+
export * from "@watchup/core";
|
|
3
|
+
|
|
4
|
+
export interface BrowserWatchUpOptions extends WatchUpClientOptions {
|
|
5
|
+
autoCaptureErrors?: boolean;
|
|
6
|
+
autoCaptureUnhandledRejections?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let activeClient: WatchUpClient | undefined;
|
|
10
|
+
let cleanup: (() => void) | undefined;
|
|
11
|
+
|
|
12
|
+
export function initBrowserWatchUp(options: BrowserWatchUpOptions): WatchUpClient {
|
|
13
|
+
cleanup?.();
|
|
14
|
+
|
|
15
|
+
const client = initWatchUp({
|
|
16
|
+
platform: "browser",
|
|
17
|
+
...options
|
|
18
|
+
});
|
|
19
|
+
const disposers: Array<() => void> = [];
|
|
20
|
+
|
|
21
|
+
if (typeof window !== "undefined" && options.autoCaptureErrors !== false) {
|
|
22
|
+
const onError = (event: ErrorEvent) => {
|
|
23
|
+
void client.captureException(event.error ?? event.message, {
|
|
24
|
+
service: options.service ?? "frontend",
|
|
25
|
+
metadata: {
|
|
26
|
+
filename: event.filename,
|
|
27
|
+
lineno: event.lineno,
|
|
28
|
+
colno: event.colno,
|
|
29
|
+
url: window.location.href
|
|
30
|
+
},
|
|
31
|
+
user_agent: navigator.userAgent
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
window.addEventListener("error", onError);
|
|
35
|
+
disposers.push(() => window.removeEventListener("error", onError));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (typeof window !== "undefined" && options.autoCaptureUnhandledRejections !== false) {
|
|
39
|
+
const onRejection = (event: PromiseRejectionEvent) => {
|
|
40
|
+
void client.captureException(event.reason, {
|
|
41
|
+
service: options.service ?? "frontend",
|
|
42
|
+
metadata: {
|
|
43
|
+
type: "unhandledrejection",
|
|
44
|
+
url: window.location.href
|
|
45
|
+
},
|
|
46
|
+
user_agent: navigator.userAgent
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
50
|
+
disposers.push(() => window.removeEventListener("unhandledrejection", onRejection));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
activeClient = client;
|
|
54
|
+
cleanup = () => {
|
|
55
|
+
disposers.forEach((dispose) => dispose());
|
|
56
|
+
client.close();
|
|
57
|
+
activeClient = undefined;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return client;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getWatchUpClient(): WatchUpClient {
|
|
64
|
+
if (!activeClient) {
|
|
65
|
+
throw new Error("WatchUp browser client has not been initialized");
|
|
66
|
+
}
|
|
67
|
+
return activeClient;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function shutdownBrowserWatchUp(): void {
|
|
71
|
+
cleanup?.();
|
|
72
|
+
cleanup = undefined;
|
|
73
|
+
}
|