@canmi/web 2026.1005.5 → 2026.1005.6
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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region sentry/src/feedback.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Show the dialog, registering the integration the first time.
|
|
4
|
+
*
|
|
5
|
+
* Answers whether it opened: not without a client, which an app without a DSN never makes, and
|
|
6
|
+
* not when the dialog itself fails. A caller offers another way to write when it did not. In
|
|
7
|
+
* development it opens, and what is sent is dropped.
|
|
8
|
+
*/
|
|
9
|
+
export declare function openReport(): Promise<boolean>;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { feedbackIntegration, getClient, getFeedback } from "@sentry/sveltekit";
|
|
2
|
+
//#region sentry/src/feedback.ts
|
|
3
|
+
/**
|
|
4
|
+
* Sentry's feedback dialog, in a module nothing imports until a reader asks for it.
|
|
5
|
+
*
|
|
6
|
+
* Its widget is 24KB gzipped, so it is a module of its own and an app reaches it with
|
|
7
|
+
* `await import('@canmi/web/sentry/feedback')` from the control that opens it, never at the top
|
|
8
|
+
* of a file: that keeps it out of every page's entry, and out of the server, where
|
|
9
|
+
* `@sentry/sveltekit` has no `getFeedback`. Named imports, because a namespace import forces every
|
|
10
|
+
* export live and the bundler could no longer split this off. See spec/web/sentry.md.
|
|
11
|
+
*/
|
|
12
|
+
let form;
|
|
13
|
+
/**
|
|
14
|
+
* Show the dialog, registering the integration the first time.
|
|
15
|
+
*
|
|
16
|
+
* Answers whether it opened: not without a client, which an app without a DSN never makes, and
|
|
17
|
+
* not when the dialog itself fails. A caller offers another way to write when it did not. In
|
|
18
|
+
* development it opens, and what is sent is dropped.
|
|
19
|
+
*/
|
|
20
|
+
async function openReport() {
|
|
21
|
+
try {
|
|
22
|
+
const client = getClient();
|
|
23
|
+
if (!client) return false;
|
|
24
|
+
if (!getFeedback()) client.addIntegration(feedbackIntegration({ autoInject: false }));
|
|
25
|
+
const feedback = getFeedback();
|
|
26
|
+
if (!feedback) return false;
|
|
27
|
+
form ??= await feedback.createForm();
|
|
28
|
+
form.appendToDom();
|
|
29
|
+
form.open();
|
|
30
|
+
return true;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { openReport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canmi/web",
|
|
3
|
-
"version": "2026.1005.
|
|
3
|
+
"version": "2026.1005.6",
|
|
4
4
|
"description": "SvelteKit compat, referer and Sentry.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browserslist",
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"types": "./dist/sentry/src/client.d.ts",
|
|
41
41
|
"default": "./dist/sentry/src/client.js"
|
|
42
42
|
},
|
|
43
|
+
"./sentry/feedback": {
|
|
44
|
+
"types": "./dist/sentry/src/feedback.d.ts",
|
|
45
|
+
"default": "./dist/sentry/src/feedback.js"
|
|
46
|
+
},
|
|
43
47
|
"./sentry/server": {
|
|
44
48
|
"types": "./dist/sentry/src/server.d.ts",
|
|
45
49
|
"default": "./dist/sentry/src/server.js"
|