@sentry/feedback 10.58.0
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/LICENSE +21 -0
- package/README.md +29 -0
- package/build/npm/cjs/index.js +1836 -0
- package/build/npm/cjs/index.js.map +1 -0
- package/build/npm/esm/index.js +1830 -0
- package/build/npm/esm/index.js.map +1 -0
- package/build/npm/esm/package.json +1 -0
- package/build/npm/types/constants/index.d.ts +34 -0
- package/build/npm/types/constants/index.d.ts.map +1 -0
- package/build/npm/types/core/TestClient.d.ts +27 -0
- package/build/npm/types/core/TestClient.d.ts.map +1 -0
- package/build/npm/types/core/components/Actor.css.d.ts +5 -0
- package/build/npm/types/core/components/Actor.css.d.ts.map +1 -0
- package/build/npm/types/core/components/Actor.d.ts +18 -0
- package/build/npm/types/core/components/Actor.d.ts.map +1 -0
- package/build/npm/types/core/components/FeedbackIcon.d.ts +5 -0
- package/build/npm/types/core/components/FeedbackIcon.d.ts.map +1 -0
- package/build/npm/types/core/createMainStyles.d.ts +6 -0
- package/build/npm/types/core/createMainStyles.d.ts.map +1 -0
- package/build/npm/types/core/getFeedback.d.ts +8 -0
- package/build/npm/types/core/getFeedback.d.ts.map +1 -0
- package/build/npm/types/core/integration.d.ts +25 -0
- package/build/npm/types/core/integration.d.ts.map +1 -0
- package/build/npm/types/core/sendFeedback.d.ts +6 -0
- package/build/npm/types/core/sendFeedback.d.ts.map +1 -0
- package/build/npm/types/core/types.d.ts +17 -0
- package/build/npm/types/core/types.d.ts.map +1 -0
- package/build/npm/types/index.d.ts +6 -0
- package/build/npm/types/index.d.ts.map +1 -0
- package/build/npm/types/modal/components/Dialog.css.d.ts +5 -0
- package/build/npm/types/modal/components/Dialog.css.d.ts.map +1 -0
- package/build/npm/types/modal/components/Dialog.d.ts +12 -0
- package/build/npm/types/modal/components/Dialog.d.ts.map +1 -0
- package/build/npm/types/modal/components/DialogHeader.d.ts +7 -0
- package/build/npm/types/modal/components/DialogHeader.d.ts.map +1 -0
- package/build/npm/types/modal/components/Form.d.ts +14 -0
- package/build/npm/types/modal/components/Form.d.ts.map +1 -0
- package/build/npm/types/modal/components/SentryLogo.d.ts +5 -0
- package/build/npm/types/modal/components/SentryLogo.d.ts.map +1 -0
- package/build/npm/types/modal/components/SuccessIcon.d.ts +5 -0
- package/build/npm/types/modal/components/SuccessIcon.d.ts.map +1 -0
- package/build/npm/types/modal/integration.d.ts +3 -0
- package/build/npm/types/modal/integration.d.ts.map +1 -0
- package/build/npm/types/screenshot/components/IconClose.d.ts +7 -0
- package/build/npm/types/screenshot/components/IconClose.d.ts.map +1 -0
- package/build/npm/types/screenshot/components/ScreenshotEditor.d.ts +28 -0
- package/build/npm/types/screenshot/components/ScreenshotEditor.d.ts.map +1 -0
- package/build/npm/types/screenshot/components/ScreenshotInput.css.d.ts +5 -0
- package/build/npm/types/screenshot/components/ScreenshotInput.css.d.ts.map +1 -0
- package/build/npm/types/screenshot/components/Toolbar.d.ts +13 -0
- package/build/npm/types/screenshot/components/Toolbar.d.ts.map +1 -0
- package/build/npm/types/screenshot/components/useTakeScreenshot.d.ts +14 -0
- package/build/npm/types/screenshot/components/useTakeScreenshot.d.ts.map +1 -0
- package/build/npm/types/screenshot/integration.d.ts +3 -0
- package/build/npm/types/screenshot/integration.d.ts.map +1 -0
- package/build/npm/types/util/createFeedbackError.d.ts +4 -0
- package/build/npm/types/util/createFeedbackError.d.ts.map +1 -0
- package/build/npm/types/util/debug-build.d.ts +7 -0
- package/build/npm/types/util/debug-build.d.ts.map +1 -0
- package/build/npm/types/util/isScreenshotSupported.d.ts +15 -0
- package/build/npm/types/util/isScreenshotSupported.d.ts.map +1 -0
- package/build/npm/types/util/mergeOptions.d.ts +7 -0
- package/build/npm/types/util/mergeOptions.d.ts.map +1 -0
- package/build/npm/types/util/setAttributesNS.d.ts +5 -0
- package/build/npm/types/util/setAttributesNS.d.ts.map +1 -0
- package/build/npm/types/util/validate.d.ts +7 -0
- package/build/npm/types/util/validate.d.ts.map +1 -0
- package/build/npm/types-ts3.8/constants/index.d.ts +34 -0
- package/build/npm/types-ts3.8/core/TestClient.d.ts +27 -0
- package/build/npm/types-ts3.8/core/components/Actor.css.d.ts +5 -0
- package/build/npm/types-ts3.8/core/components/Actor.d.ts +18 -0
- package/build/npm/types-ts3.8/core/components/FeedbackIcon.d.ts +5 -0
- package/build/npm/types-ts3.8/core/createMainStyles.d.ts +6 -0
- package/build/npm/types-ts3.8/core/getFeedback.d.ts +8 -0
- package/build/npm/types-ts3.8/core/integration.d.ts +25 -0
- package/build/npm/types-ts3.8/core/sendFeedback.d.ts +6 -0
- package/build/npm/types-ts3.8/core/types.d.ts +17 -0
- package/build/npm/types-ts3.8/index.d.ts +6 -0
- package/build/npm/types-ts3.8/modal/components/Dialog.css.d.ts +5 -0
- package/build/npm/types-ts3.8/modal/components/Dialog.d.ts +13 -0
- package/build/npm/types-ts3.8/modal/components/DialogHeader.d.ts +8 -0
- package/build/npm/types-ts3.8/modal/components/Form.d.ts +15 -0
- package/build/npm/types-ts3.8/modal/components/SentryLogo.d.ts +5 -0
- package/build/npm/types-ts3.8/modal/components/SuccessIcon.d.ts +5 -0
- package/build/npm/types-ts3.8/modal/integration.d.ts +3 -0
- package/build/npm/types-ts3.8/screenshot/components/IconClose.d.ts +9 -0
- package/build/npm/types-ts3.8/screenshot/components/ScreenshotEditor.d.ts +30 -0
- package/build/npm/types-ts3.8/screenshot/components/ScreenshotInput.css.d.ts +5 -0
- package/build/npm/types-ts3.8/screenshot/components/Toolbar.d.ts +15 -0
- package/build/npm/types-ts3.8/screenshot/components/useTakeScreenshot.d.ts +14 -0
- package/build/npm/types-ts3.8/screenshot/integration.d.ts +3 -0
- package/build/npm/types-ts3.8/util/createFeedbackError.d.ts +4 -0
- package/build/npm/types-ts3.8/util/debug-build.d.ts +7 -0
- package/build/npm/types-ts3.8/util/isScreenshotSupported.d.ts +15 -0
- package/build/npm/types-ts3.8/util/mergeOptions.d.ts +7 -0
- package/build/npm/types-ts3.8/util/setAttributesNS.d.ts +5 -0
- package/build/npm/types-ts3.8/util/validate.d.ts +7 -0
- package/package.json +74 -0
|
@@ -0,0 +1,1836 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
|
|
5
|
+
const WINDOW = core.GLOBAL_OBJ;
|
|
6
|
+
const DOCUMENT = WINDOW.document;
|
|
7
|
+
const NAVIGATOR = WINDOW.navigator;
|
|
8
|
+
const TRIGGER_LABEL = "Report a Bug";
|
|
9
|
+
const CANCEL_BUTTON_LABEL = "Cancel";
|
|
10
|
+
const SUBMIT_BUTTON_LABEL = "Send Bug Report";
|
|
11
|
+
const CONFIRM_BUTTON_LABEL = "Confirm";
|
|
12
|
+
const FORM_TITLE = "Report a Bug";
|
|
13
|
+
const EMAIL_PLACEHOLDER = "your.email@example.org";
|
|
14
|
+
const EMAIL_LABEL = "Email";
|
|
15
|
+
const MESSAGE_PLACEHOLDER = "What's the bug? What did you expect?";
|
|
16
|
+
const MESSAGE_LABEL = "Description";
|
|
17
|
+
const NAME_PLACEHOLDER = "Your Name";
|
|
18
|
+
const NAME_LABEL = "Name";
|
|
19
|
+
const SUCCESS_MESSAGE_TEXT = "Thank you for your report!";
|
|
20
|
+
const IS_REQUIRED_LABEL = "(required)";
|
|
21
|
+
const ADD_SCREENSHOT_LABEL = "Add a screenshot";
|
|
22
|
+
const REMOVE_SCREENSHOT_LABEL = "Remove screenshot";
|
|
23
|
+
const HIGHLIGHT_TOOL_TEXT = "Highlight";
|
|
24
|
+
const HIDE_TOOL_TEXT = "Hide";
|
|
25
|
+
const REMOVE_HIGHLIGHT_TEXT = "Remove";
|
|
26
|
+
const ERROR_EMPTY_MESSAGE_TEXT = "Unable to submit feedback with empty message";
|
|
27
|
+
const ERROR_NO_CLIENT_TEXT = "No client setup, cannot send feedback.";
|
|
28
|
+
const ERROR_TIMEOUT_TEXT = "Unable to determine if Feedback was correctly sent.";
|
|
29
|
+
const ERROR_FORBIDDEN_TEXT = "Unable to send feedback. This could be because this domain is not in your list of allowed domains.";
|
|
30
|
+
const ERROR_GENERIC_TEXT = "Unable to send feedback. This could be because of network issues, or because you are using an ad-blocker.";
|
|
31
|
+
const FEEDBACK_WIDGET_SOURCE = "widget";
|
|
32
|
+
const FEEDBACK_API_SOURCE = "api";
|
|
33
|
+
const SUCCESS_MESSAGE_TIMEOUT = 5e3;
|
|
34
|
+
|
|
35
|
+
const DEFAULT_MESSAGES = {
|
|
36
|
+
ERROR_EMPTY_MESSAGE: ERROR_EMPTY_MESSAGE_TEXT,
|
|
37
|
+
ERROR_NO_CLIENT: ERROR_NO_CLIENT_TEXT,
|
|
38
|
+
ERROR_TIMEOUT: ERROR_TIMEOUT_TEXT,
|
|
39
|
+
ERROR_FORBIDDEN: ERROR_FORBIDDEN_TEXT,
|
|
40
|
+
ERROR_GENERIC: ERROR_GENERIC_TEXT
|
|
41
|
+
};
|
|
42
|
+
function resolveFeedbackErrorMessage(code, messages) {
|
|
43
|
+
return messages?.[code] ?? DEFAULT_MESSAGES[code];
|
|
44
|
+
}
|
|
45
|
+
function createFeedbackError(code, messages) {
|
|
46
|
+
return new Error(resolveFeedbackErrorMessage(code, messages));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const sendFeedback = (params, hint = { includeReplay: true }) => {
|
|
50
|
+
const errorMessages = hint.errorMessages;
|
|
51
|
+
if (!params.message) {
|
|
52
|
+
throw createFeedbackError("ERROR_EMPTY_MESSAGE", errorMessages);
|
|
53
|
+
}
|
|
54
|
+
const client = core.getClient();
|
|
55
|
+
if (!client) {
|
|
56
|
+
throw createFeedbackError("ERROR_NO_CLIENT", errorMessages);
|
|
57
|
+
}
|
|
58
|
+
if (params.tags && Object.keys(params.tags).length) {
|
|
59
|
+
core.getCurrentScope().setTags(params.tags);
|
|
60
|
+
}
|
|
61
|
+
const eventId = core.captureFeedback(
|
|
62
|
+
{
|
|
63
|
+
source: FEEDBACK_API_SOURCE,
|
|
64
|
+
url: core.getLocationHref(),
|
|
65
|
+
...params
|
|
66
|
+
},
|
|
67
|
+
hint
|
|
68
|
+
);
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const timeout = setTimeout(() => {
|
|
71
|
+
cleanup();
|
|
72
|
+
reject(resolveFeedbackErrorMessage("ERROR_TIMEOUT", errorMessages));
|
|
73
|
+
}, 3e4);
|
|
74
|
+
const cleanup = client.on("afterSendEvent", (event, response) => {
|
|
75
|
+
if (event.event_id !== eventId) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
clearTimeout(timeout);
|
|
79
|
+
cleanup();
|
|
80
|
+
if (response?.statusCode && response.statusCode >= 200 && response.statusCode < 300) {
|
|
81
|
+
return resolve(eventId);
|
|
82
|
+
}
|
|
83
|
+
if (response?.statusCode === 403) {
|
|
84
|
+
return reject(resolveFeedbackErrorMessage("ERROR_FORBIDDEN", errorMessages));
|
|
85
|
+
}
|
|
86
|
+
return reject(resolveFeedbackErrorMessage("ERROR_GENERIC", errorMessages));
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
|
|
92
|
+
|
|
93
|
+
function isScreenshotSupported() {
|
|
94
|
+
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(NAVIGATOR.userAgent)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (/Macintosh/i.test(NAVIGATOR.userAgent) && NAVIGATOR.maxTouchPoints && NAVIGATOR.maxTouchPoints > 1) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (!isSecureContext) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function mergeOptions(defaultOptions, optionOverrides) {
|
|
107
|
+
return {
|
|
108
|
+
...defaultOptions,
|
|
109
|
+
...optionOverrides,
|
|
110
|
+
tags: {
|
|
111
|
+
...defaultOptions.tags,
|
|
112
|
+
...optionOverrides.tags
|
|
113
|
+
},
|
|
114
|
+
onFormOpen: () => {
|
|
115
|
+
optionOverrides.onFormOpen?.();
|
|
116
|
+
defaultOptions.onFormOpen?.();
|
|
117
|
+
},
|
|
118
|
+
onFormClose: () => {
|
|
119
|
+
optionOverrides.onFormClose?.();
|
|
120
|
+
defaultOptions.onFormClose?.();
|
|
121
|
+
},
|
|
122
|
+
onSubmitSuccess: (data, eventId) => {
|
|
123
|
+
optionOverrides.onSubmitSuccess?.(data, eventId);
|
|
124
|
+
defaultOptions.onSubmitSuccess?.(data, eventId);
|
|
125
|
+
},
|
|
126
|
+
onSubmitError: (error) => {
|
|
127
|
+
optionOverrides.onSubmitError?.(error);
|
|
128
|
+
defaultOptions.onSubmitError?.(error);
|
|
129
|
+
},
|
|
130
|
+
onFormSubmitted: () => {
|
|
131
|
+
optionOverrides.onFormSubmitted?.();
|
|
132
|
+
defaultOptions.onFormSubmitted?.();
|
|
133
|
+
},
|
|
134
|
+
themeDark: {
|
|
135
|
+
...defaultOptions.themeDark,
|
|
136
|
+
...optionOverrides.themeDark
|
|
137
|
+
},
|
|
138
|
+
themeLight: {
|
|
139
|
+
...defaultOptions.themeLight,
|
|
140
|
+
...optionOverrides.themeLight
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function createActorStyles(styleNonce) {
|
|
146
|
+
const style = DOCUMENT.createElement("style");
|
|
147
|
+
style.textContent = `
|
|
148
|
+
.widget__actor {
|
|
149
|
+
position: fixed;
|
|
150
|
+
z-index: var(--z-index);
|
|
151
|
+
margin: var(--page-margin);
|
|
152
|
+
inset: var(--actor-inset);
|
|
153
|
+
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
gap: 8px;
|
|
157
|
+
padding: 16px;
|
|
158
|
+
|
|
159
|
+
font-family: inherit;
|
|
160
|
+
font-size: var(--font-size);
|
|
161
|
+
font-weight: 600;
|
|
162
|
+
line-height: 1.14em;
|
|
163
|
+
text-decoration: none;
|
|
164
|
+
|
|
165
|
+
background: var(--actor-background, var(--background));
|
|
166
|
+
border-radius: var(--actor-border-radius, 1.7em/50%);
|
|
167
|
+
border: var(--actor-border, var(--border));
|
|
168
|
+
box-shadow: var(--actor-box-shadow, var(--box-shadow));
|
|
169
|
+
color: var(--actor-color, var(--foreground));
|
|
170
|
+
fill: var(--actor-color, var(--foreground));
|
|
171
|
+
cursor: pointer;
|
|
172
|
+
opacity: 1;
|
|
173
|
+
transition: transform 0.2s ease-in-out;
|
|
174
|
+
transform: translate(0, 0) scale(1);
|
|
175
|
+
}
|
|
176
|
+
.widget__actor[aria-hidden="true"] {
|
|
177
|
+
opacity: 0;
|
|
178
|
+
pointer-events: none;
|
|
179
|
+
visibility: hidden;
|
|
180
|
+
transform: translate(0, 16px) scale(0.98);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.widget__actor:hover {
|
|
184
|
+
background: var(--actor-hover-background, var(--background));
|
|
185
|
+
filter: var(--interactive-filter);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.widget__actor svg {
|
|
189
|
+
width: 1.14em;
|
|
190
|
+
height: 1.14em;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@media (max-width: 600px) {
|
|
194
|
+
.widget__actor span {
|
|
195
|
+
display: none;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
`;
|
|
199
|
+
if (styleNonce) {
|
|
200
|
+
style.setAttribute("nonce", styleNonce);
|
|
201
|
+
}
|
|
202
|
+
return style;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function setAttributesNS(el, attributes) {
|
|
206
|
+
Object.entries(attributes).forEach(([key, val]) => {
|
|
207
|
+
el.setAttributeNS(null, key, val);
|
|
208
|
+
});
|
|
209
|
+
return el;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const SIZE = 20;
|
|
213
|
+
const XMLNS$2 = "http://www.w3.org/2000/svg";
|
|
214
|
+
function FeedbackIcon() {
|
|
215
|
+
const createElementNS = (tagName) => WINDOW.document.createElementNS(XMLNS$2, tagName);
|
|
216
|
+
const svg = setAttributesNS(createElementNS("svg"), {
|
|
217
|
+
width: `${SIZE}`,
|
|
218
|
+
height: `${SIZE}`,
|
|
219
|
+
viewBox: `0 0 ${SIZE} ${SIZE}`,
|
|
220
|
+
fill: "var(--actor-color, var(--foreground))"
|
|
221
|
+
});
|
|
222
|
+
const g = setAttributesNS(createElementNS("g"), {
|
|
223
|
+
clipPath: "url(#clip0_57_80)"
|
|
224
|
+
});
|
|
225
|
+
const path = setAttributesNS(createElementNS("path"), {
|
|
226
|
+
["fill-rule"]: "evenodd",
|
|
227
|
+
["clip-rule"]: "evenodd",
|
|
228
|
+
d: "M15.6622 15H12.3997C12.2129 14.9959 12.031 14.9396 11.8747 14.8375L8.04965 12.2H7.49956V19.1C7.4875 19.3348 7.3888 19.5568 7.22256 19.723C7.05632 19.8892 6.83435 19.9879 6.59956 20H2.04956C1.80193 19.9968 1.56535 19.8969 1.39023 19.7218C1.21511 19.5467 1.1153 19.3101 1.11206 19.0625V12.2H0.949652C0.824431 12.2017 0.700142 12.1783 0.584123 12.1311C0.468104 12.084 0.362708 12.014 0.274155 11.9255C0.185602 11.8369 0.115689 11.7315 0.0685419 11.6155C0.0213952 11.4995 -0.00202913 11.3752 -0.00034808 11.25V3.75C-0.00900498 3.62067 0.0092504 3.49095 0.0532651 3.36904C0.0972798 3.24712 0.166097 3.13566 0.255372 3.04168C0.344646 2.94771 0.452437 2.87327 0.571937 2.82307C0.691437 2.77286 0.82005 2.74798 0.949652 2.75H8.04965L11.8747 0.1625C12.031 0.0603649 12.2129 0.00407221 12.3997 0H15.6622C15.9098 0.00323746 16.1464 0.103049 16.3215 0.278167C16.4966 0.453286 16.5964 0.689866 16.5997 0.9375V3.25269C17.3969 3.42959 18.1345 3.83026 18.7211 4.41679C19.5322 5.22788 19.9878 6.32796 19.9878 7.47502C19.9878 8.62209 19.5322 9.72217 18.7211 10.5333C18.1345 11.1198 17.3969 11.5205 16.5997 11.6974V14.0125C16.6047 14.1393 16.5842 14.2659 16.5395 14.3847C16.4948 14.5035 16.4268 14.6121 16.3394 14.7042C16.252 14.7962 16.147 14.8698 16.0307 14.9206C15.9144 14.9714 15.7891 14.9984 15.6622 15ZM1.89695 10.325H1.88715V4.625H8.33715C8.52423 4.62301 8.70666 4.56654 8.86215 4.4625L12.6872 1.875H14.7247V13.125H12.6872L8.86215 10.4875C8.70666 10.3835 8.52423 10.327 8.33715 10.325H2.20217C2.15205 10.3167 2.10102 10.3125 2.04956 10.3125C1.9981 10.3125 1.94708 10.3167 1.89695 10.325ZM2.98706 12.2V18.1625H5.66206V12.2H2.98706ZM16.5997 9.93612V5.01393C16.6536 5.02355 16.7072 5.03495 16.7605 5.04814C17.1202 5.13709 17.4556 5.30487 17.7425 5.53934C18.0293 5.77381 18.2605 6.06912 18.4192 6.40389C18.578 6.73866 18.6603 7.10452 18.6603 7.47502C18.6603 7.84552 18.578 8.21139 18.4192 8.54616C18.2605 8.88093 18.0293 9.17624 17.7425 9.41071C17.4556 9.64518 17.1202 9.81296 16.7605 9.90191C16.7072 9.91509 16.6536 9.9265 16.5997 9.93612Z"
|
|
229
|
+
});
|
|
230
|
+
svg.appendChild(g).appendChild(path);
|
|
231
|
+
const speakerDefs = createElementNS("defs");
|
|
232
|
+
const speakerClipPathDef = setAttributesNS(createElementNS("clipPath"), {
|
|
233
|
+
id: "clip0_57_80"
|
|
234
|
+
});
|
|
235
|
+
const speakerRect = setAttributesNS(createElementNS("rect"), {
|
|
236
|
+
width: `${SIZE}`,
|
|
237
|
+
height: `${SIZE}`,
|
|
238
|
+
fill: "white"
|
|
239
|
+
});
|
|
240
|
+
speakerClipPathDef.appendChild(speakerRect);
|
|
241
|
+
speakerDefs.appendChild(speakerClipPathDef);
|
|
242
|
+
svg.appendChild(speakerDefs).appendChild(speakerClipPathDef).appendChild(speakerRect);
|
|
243
|
+
return svg;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function Actor({ triggerLabel, triggerAriaLabel, shadow, styleNonce }) {
|
|
247
|
+
const el = DOCUMENT.createElement("button");
|
|
248
|
+
el.type = "button";
|
|
249
|
+
el.className = "widget__actor";
|
|
250
|
+
el.ariaHidden = "false";
|
|
251
|
+
el.ariaLabel = triggerAriaLabel || triggerLabel || TRIGGER_LABEL;
|
|
252
|
+
el.appendChild(FeedbackIcon());
|
|
253
|
+
if (triggerLabel) {
|
|
254
|
+
const label = DOCUMENT.createElement("span");
|
|
255
|
+
label.appendChild(DOCUMENT.createTextNode(triggerLabel));
|
|
256
|
+
el.appendChild(label);
|
|
257
|
+
}
|
|
258
|
+
const style = createActorStyles(styleNonce);
|
|
259
|
+
return {
|
|
260
|
+
el,
|
|
261
|
+
appendToDom() {
|
|
262
|
+
shadow.appendChild(style);
|
|
263
|
+
shadow.appendChild(el);
|
|
264
|
+
},
|
|
265
|
+
removeFromDom() {
|
|
266
|
+
el.remove();
|
|
267
|
+
style.remove();
|
|
268
|
+
},
|
|
269
|
+
show() {
|
|
270
|
+
el.ariaHidden = "false";
|
|
271
|
+
},
|
|
272
|
+
hide() {
|
|
273
|
+
el.ariaHidden = "true";
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const PURPLE = "rgba(88, 74, 192, 1)";
|
|
279
|
+
const DEFAULT_LIGHT = {
|
|
280
|
+
foreground: "#2b2233",
|
|
281
|
+
background: "#ffffff",
|
|
282
|
+
accentForeground: "white",
|
|
283
|
+
accentBackground: PURPLE,
|
|
284
|
+
successColor: "#268d75",
|
|
285
|
+
errorColor: "#df3338",
|
|
286
|
+
border: "1.5px solid rgba(41, 35, 47, 0.13)",
|
|
287
|
+
boxShadow: "0px 4px 24px 0px rgba(43, 34, 51, 0.12)",
|
|
288
|
+
outline: "1px auto var(--accent-background)",
|
|
289
|
+
interactiveFilter: "brightness(95%)"
|
|
290
|
+
};
|
|
291
|
+
const DEFAULT_DARK = {
|
|
292
|
+
foreground: "#ebe6ef",
|
|
293
|
+
background: "#29232f",
|
|
294
|
+
accentForeground: "white",
|
|
295
|
+
accentBackground: PURPLE,
|
|
296
|
+
successColor: "#2da98c",
|
|
297
|
+
errorColor: "#f55459",
|
|
298
|
+
border: "1.5px solid rgba(235, 230, 239, 0.15)",
|
|
299
|
+
boxShadow: "0px 4px 24px 0px rgba(43, 34, 51, 0.12)",
|
|
300
|
+
outline: "1px auto var(--accent-background)",
|
|
301
|
+
interactiveFilter: "brightness(150%)"
|
|
302
|
+
};
|
|
303
|
+
function getThemedCssVariables(theme) {
|
|
304
|
+
return `
|
|
305
|
+
--foreground: ${theme.foreground};
|
|
306
|
+
--background: ${theme.background};
|
|
307
|
+
--accent-foreground: ${theme.accentForeground};
|
|
308
|
+
--accent-background: ${theme.accentBackground};
|
|
309
|
+
--success-color: ${theme.successColor};
|
|
310
|
+
--error-color: ${theme.errorColor};
|
|
311
|
+
--border: ${theme.border};
|
|
312
|
+
--box-shadow: ${theme.boxShadow};
|
|
313
|
+
--outline: ${theme.outline};
|
|
314
|
+
--interactive-filter: ${theme.interactiveFilter};
|
|
315
|
+
`;
|
|
316
|
+
}
|
|
317
|
+
function createMainStyles({
|
|
318
|
+
colorScheme,
|
|
319
|
+
themeDark,
|
|
320
|
+
themeLight,
|
|
321
|
+
styleNonce
|
|
322
|
+
}) {
|
|
323
|
+
const style = DOCUMENT.createElement("style");
|
|
324
|
+
style.textContent = `
|
|
325
|
+
:host {
|
|
326
|
+
--font-family: system-ui, 'Helvetica Neue', Arial, sans-serif;
|
|
327
|
+
--font-size: 14px;
|
|
328
|
+
--z-index: 100000;
|
|
329
|
+
|
|
330
|
+
--page-margin: 16px;
|
|
331
|
+
--inset: auto 0 0 auto;
|
|
332
|
+
--actor-inset: var(--inset);
|
|
333
|
+
|
|
334
|
+
font-family: var(--font-family);
|
|
335
|
+
font-size: var(--font-size);
|
|
336
|
+
|
|
337
|
+
${colorScheme !== "system" ? `color-scheme: only ${colorScheme};` : ""}
|
|
338
|
+
|
|
339
|
+
${getThemedCssVariables(
|
|
340
|
+
colorScheme === "dark" ? { ...DEFAULT_DARK, ...themeDark } : { ...DEFAULT_LIGHT, ...themeLight }
|
|
341
|
+
)}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
${colorScheme === "system" ? `
|
|
345
|
+
@media (prefers-color-scheme: dark) {
|
|
346
|
+
:host {
|
|
347
|
+
color-scheme: only dark;
|
|
348
|
+
|
|
349
|
+
${getThemedCssVariables({ ...DEFAULT_DARK, ...themeDark })}
|
|
350
|
+
}
|
|
351
|
+
}` : ""}
|
|
352
|
+
`;
|
|
353
|
+
if (styleNonce) {
|
|
354
|
+
style.setAttribute("nonce", styleNonce);
|
|
355
|
+
}
|
|
356
|
+
return style;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const buildFeedbackIntegration = ({
|
|
360
|
+
lazyLoadIntegration,
|
|
361
|
+
getModalIntegration,
|
|
362
|
+
getScreenshotIntegration
|
|
363
|
+
}) => {
|
|
364
|
+
const feedbackIntegration = (({
|
|
365
|
+
// FeedbackGeneralConfiguration
|
|
366
|
+
id = "sentry-feedback",
|
|
367
|
+
autoInject = true,
|
|
368
|
+
showBranding = true,
|
|
369
|
+
isEmailRequired = false,
|
|
370
|
+
isNameRequired = false,
|
|
371
|
+
showEmail = true,
|
|
372
|
+
showName = true,
|
|
373
|
+
enableScreenshot = true,
|
|
374
|
+
useSentryUser = {
|
|
375
|
+
email: "email",
|
|
376
|
+
name: "username"
|
|
377
|
+
},
|
|
378
|
+
tags,
|
|
379
|
+
styleNonce,
|
|
380
|
+
scriptNonce,
|
|
381
|
+
// FeedbackThemeConfiguration
|
|
382
|
+
colorScheme = "system",
|
|
383
|
+
themeLight = {},
|
|
384
|
+
themeDark = {},
|
|
385
|
+
// FeedbackTextConfiguration
|
|
386
|
+
addScreenshotButtonLabel = ADD_SCREENSHOT_LABEL,
|
|
387
|
+
cancelButtonLabel = CANCEL_BUTTON_LABEL,
|
|
388
|
+
confirmButtonLabel = CONFIRM_BUTTON_LABEL,
|
|
389
|
+
emailLabel = EMAIL_LABEL,
|
|
390
|
+
emailPlaceholder = EMAIL_PLACEHOLDER,
|
|
391
|
+
formTitle = FORM_TITLE,
|
|
392
|
+
isRequiredLabel = IS_REQUIRED_LABEL,
|
|
393
|
+
messageLabel = MESSAGE_LABEL,
|
|
394
|
+
messagePlaceholder = MESSAGE_PLACEHOLDER,
|
|
395
|
+
nameLabel = NAME_LABEL,
|
|
396
|
+
namePlaceholder = NAME_PLACEHOLDER,
|
|
397
|
+
removeScreenshotButtonLabel = REMOVE_SCREENSHOT_LABEL,
|
|
398
|
+
submitButtonLabel = SUBMIT_BUTTON_LABEL,
|
|
399
|
+
successMessageText = SUCCESS_MESSAGE_TEXT,
|
|
400
|
+
triggerLabel = TRIGGER_LABEL,
|
|
401
|
+
triggerAriaLabel = "",
|
|
402
|
+
highlightToolText = HIGHLIGHT_TOOL_TEXT,
|
|
403
|
+
hideToolText = HIDE_TOOL_TEXT,
|
|
404
|
+
removeHighlightText = REMOVE_HIGHLIGHT_TEXT,
|
|
405
|
+
errorEmptyMessageText = ERROR_EMPTY_MESSAGE_TEXT,
|
|
406
|
+
errorNoClientText = ERROR_NO_CLIENT_TEXT,
|
|
407
|
+
errorTimeoutText = ERROR_TIMEOUT_TEXT,
|
|
408
|
+
errorForbiddenText = ERROR_FORBIDDEN_TEXT,
|
|
409
|
+
errorGenericText = ERROR_GENERIC_TEXT,
|
|
410
|
+
// FeedbackCallbacks
|
|
411
|
+
onFormOpen,
|
|
412
|
+
onFormClose,
|
|
413
|
+
onSubmitSuccess,
|
|
414
|
+
onSubmitError,
|
|
415
|
+
onFormSubmitted
|
|
416
|
+
} = {}) => {
|
|
417
|
+
const _options = {
|
|
418
|
+
id,
|
|
419
|
+
autoInject,
|
|
420
|
+
showBranding,
|
|
421
|
+
isEmailRequired,
|
|
422
|
+
isNameRequired,
|
|
423
|
+
showEmail,
|
|
424
|
+
showName,
|
|
425
|
+
enableScreenshot,
|
|
426
|
+
useSentryUser,
|
|
427
|
+
tags,
|
|
428
|
+
styleNonce,
|
|
429
|
+
scriptNonce,
|
|
430
|
+
colorScheme,
|
|
431
|
+
themeDark,
|
|
432
|
+
themeLight,
|
|
433
|
+
triggerLabel,
|
|
434
|
+
triggerAriaLabel,
|
|
435
|
+
cancelButtonLabel,
|
|
436
|
+
submitButtonLabel,
|
|
437
|
+
confirmButtonLabel,
|
|
438
|
+
formTitle,
|
|
439
|
+
emailLabel,
|
|
440
|
+
emailPlaceholder,
|
|
441
|
+
messageLabel,
|
|
442
|
+
messagePlaceholder,
|
|
443
|
+
nameLabel,
|
|
444
|
+
namePlaceholder,
|
|
445
|
+
successMessageText,
|
|
446
|
+
isRequiredLabel,
|
|
447
|
+
addScreenshotButtonLabel,
|
|
448
|
+
removeScreenshotButtonLabel,
|
|
449
|
+
highlightToolText,
|
|
450
|
+
hideToolText,
|
|
451
|
+
removeHighlightText,
|
|
452
|
+
errorEmptyMessageText,
|
|
453
|
+
errorNoClientText,
|
|
454
|
+
errorTimeoutText,
|
|
455
|
+
errorForbiddenText,
|
|
456
|
+
errorGenericText,
|
|
457
|
+
onFormClose,
|
|
458
|
+
onFormOpen,
|
|
459
|
+
onSubmitError,
|
|
460
|
+
onSubmitSuccess,
|
|
461
|
+
onFormSubmitted
|
|
462
|
+
};
|
|
463
|
+
let _shadow = null;
|
|
464
|
+
let _mainStyle = null;
|
|
465
|
+
let _subscriptions = [];
|
|
466
|
+
const _createShadow = (options) => {
|
|
467
|
+
if (!_shadow) {
|
|
468
|
+
const host = DOCUMENT.createElement("div");
|
|
469
|
+
host.id = String(options.id);
|
|
470
|
+
DOCUMENT.body.appendChild(host);
|
|
471
|
+
_shadow = host.attachShadow({ mode: "open" });
|
|
472
|
+
_mainStyle = createMainStyles(options);
|
|
473
|
+
_shadow.appendChild(_mainStyle);
|
|
474
|
+
}
|
|
475
|
+
return _shadow;
|
|
476
|
+
};
|
|
477
|
+
const _loadAndRenderDialog = async (options) => {
|
|
478
|
+
const screenshotRequired = options.enableScreenshot && isScreenshotSupported();
|
|
479
|
+
let modalIntegration;
|
|
480
|
+
let screenshotIntegration;
|
|
481
|
+
try {
|
|
482
|
+
const modalIntegrationFn = getModalIntegration ? getModalIntegration() : await lazyLoadIntegration("feedbackModalIntegration", scriptNonce);
|
|
483
|
+
modalIntegration = modalIntegrationFn();
|
|
484
|
+
core.addIntegration(modalIntegration);
|
|
485
|
+
} catch {
|
|
486
|
+
DEBUG_BUILD && core.debug.error(
|
|
487
|
+
"[Feedback] Error when trying to load feedback integrations. Try using `feedbackSyncIntegration` in your `Sentry.init`."
|
|
488
|
+
);
|
|
489
|
+
throw new Error("[Feedback] Missing feedback modal integration!");
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
const screenshotIntegrationFn = screenshotRequired ? getScreenshotIntegration ? getScreenshotIntegration() : await lazyLoadIntegration("feedbackScreenshotIntegration", scriptNonce) : void 0;
|
|
493
|
+
if (screenshotIntegrationFn) {
|
|
494
|
+
screenshotIntegration = screenshotIntegrationFn();
|
|
495
|
+
core.addIntegration(screenshotIntegration);
|
|
496
|
+
}
|
|
497
|
+
} catch {
|
|
498
|
+
DEBUG_BUILD && core.debug.error("[Feedback] Missing feedback screenshot integration. Proceeding without screenshots.");
|
|
499
|
+
}
|
|
500
|
+
const errorMessages = {
|
|
501
|
+
ERROR_EMPTY_MESSAGE: options.errorEmptyMessageText,
|
|
502
|
+
ERROR_NO_CLIENT: options.errorNoClientText,
|
|
503
|
+
ERROR_TIMEOUT: options.errorTimeoutText,
|
|
504
|
+
ERROR_FORBIDDEN: options.errorForbiddenText,
|
|
505
|
+
ERROR_GENERIC: options.errorGenericText
|
|
506
|
+
};
|
|
507
|
+
const wrappedSendFeedback = (params, hint) => sendFeedback(params, { includeReplay: true, ...hint, errorMessages });
|
|
508
|
+
const dialog = modalIntegration.createDialog({
|
|
509
|
+
options: {
|
|
510
|
+
...options,
|
|
511
|
+
onFormClose: () => {
|
|
512
|
+
dialog?.close();
|
|
513
|
+
options.onFormClose?.();
|
|
514
|
+
},
|
|
515
|
+
onFormSubmitted: () => {
|
|
516
|
+
dialog?.close();
|
|
517
|
+
options.onFormSubmitted?.();
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
screenshotIntegration,
|
|
521
|
+
sendFeedback: wrappedSendFeedback,
|
|
522
|
+
shadow: _createShadow(options)
|
|
523
|
+
});
|
|
524
|
+
return dialog;
|
|
525
|
+
};
|
|
526
|
+
const _attachTo = (el, optionOverrides = {}) => {
|
|
527
|
+
const mergedOptions = mergeOptions(_options, optionOverrides);
|
|
528
|
+
const targetEl = typeof el === "string" ? DOCUMENT.querySelector(el) : typeof el.addEventListener === "function" ? el : null;
|
|
529
|
+
if (!targetEl) {
|
|
530
|
+
DEBUG_BUILD && core.debug.error("[Feedback] Unable to attach to target element");
|
|
531
|
+
throw new Error("Unable to attach to target element");
|
|
532
|
+
}
|
|
533
|
+
let dialog = null;
|
|
534
|
+
const handleClick = async () => {
|
|
535
|
+
if (!dialog) {
|
|
536
|
+
dialog = await _loadAndRenderDialog({
|
|
537
|
+
...mergedOptions,
|
|
538
|
+
onFormSubmitted: () => {
|
|
539
|
+
dialog?.removeFromDom();
|
|
540
|
+
mergedOptions.onFormSubmitted?.();
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
dialog.appendToDom();
|
|
545
|
+
dialog.open();
|
|
546
|
+
};
|
|
547
|
+
targetEl.addEventListener("click", handleClick);
|
|
548
|
+
const unsubscribe = () => {
|
|
549
|
+
_subscriptions = _subscriptions.filter((sub) => sub !== unsubscribe);
|
|
550
|
+
dialog?.removeFromDom();
|
|
551
|
+
dialog = null;
|
|
552
|
+
targetEl.removeEventListener("click", handleClick);
|
|
553
|
+
};
|
|
554
|
+
_subscriptions.push(unsubscribe);
|
|
555
|
+
return unsubscribe;
|
|
556
|
+
};
|
|
557
|
+
const _createActor = (optionOverrides = {}) => {
|
|
558
|
+
const mergedOptions = mergeOptions(_options, optionOverrides);
|
|
559
|
+
const shadow = _createShadow(mergedOptions);
|
|
560
|
+
const actor = Actor({
|
|
561
|
+
triggerLabel: mergedOptions.triggerLabel,
|
|
562
|
+
triggerAriaLabel: mergedOptions.triggerAriaLabel,
|
|
563
|
+
shadow,
|
|
564
|
+
styleNonce
|
|
565
|
+
});
|
|
566
|
+
_attachTo(actor.el, {
|
|
567
|
+
...mergedOptions,
|
|
568
|
+
onFormOpen() {
|
|
569
|
+
actor.hide();
|
|
570
|
+
},
|
|
571
|
+
onFormClose() {
|
|
572
|
+
actor.show();
|
|
573
|
+
},
|
|
574
|
+
onFormSubmitted() {
|
|
575
|
+
actor.show();
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
return actor;
|
|
579
|
+
};
|
|
580
|
+
return {
|
|
581
|
+
name: "Feedback",
|
|
582
|
+
setupOnce() {
|
|
583
|
+
if (!core.isBrowser() || !_options.autoInject) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (DOCUMENT.readyState === "loading") {
|
|
587
|
+
DOCUMENT.addEventListener("DOMContentLoaded", () => _createActor().appendToDom());
|
|
588
|
+
} else {
|
|
589
|
+
_createActor().appendToDom();
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
/**
|
|
593
|
+
* Adds click listener to the element to open a feedback dialog
|
|
594
|
+
*
|
|
595
|
+
* The returned function can be used to remove the click listener
|
|
596
|
+
*/
|
|
597
|
+
attachTo: _attachTo,
|
|
598
|
+
/**
|
|
599
|
+
* Creates a new widget which is composed of a Button which triggers a Dialog.
|
|
600
|
+
* Accepts partial options to override any options passed to constructor.
|
|
601
|
+
*/
|
|
602
|
+
createWidget(optionOverrides = {}) {
|
|
603
|
+
const actor = _createActor(mergeOptions(_options, optionOverrides));
|
|
604
|
+
actor.appendToDom();
|
|
605
|
+
return actor;
|
|
606
|
+
},
|
|
607
|
+
/**
|
|
608
|
+
* Creates a new Form which you can
|
|
609
|
+
* Accepts partial options to override any options passed to constructor.
|
|
610
|
+
*/
|
|
611
|
+
async createForm(optionOverrides = {}) {
|
|
612
|
+
return _loadAndRenderDialog(mergeOptions(_options, optionOverrides));
|
|
613
|
+
},
|
|
614
|
+
/**
|
|
615
|
+
* Updates the color scheme of the feedback widget at runtime.
|
|
616
|
+
*/
|
|
617
|
+
setTheme(colorScheme2) {
|
|
618
|
+
_options.colorScheme = colorScheme2;
|
|
619
|
+
if (_shadow) {
|
|
620
|
+
const newStyle = createMainStyles(_options);
|
|
621
|
+
if (_mainStyle) {
|
|
622
|
+
_shadow.replaceChild(newStyle, _mainStyle);
|
|
623
|
+
} else {
|
|
624
|
+
_shadow.prepend(newStyle);
|
|
625
|
+
}
|
|
626
|
+
_mainStyle = newStyle;
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
/**
|
|
630
|
+
* Removes the Feedback integration (including host, shadow DOM, and all widgets)
|
|
631
|
+
*/
|
|
632
|
+
remove() {
|
|
633
|
+
if (_shadow) {
|
|
634
|
+
_shadow.parentElement?.remove();
|
|
635
|
+
_shadow = null;
|
|
636
|
+
_mainStyle = null;
|
|
637
|
+
}
|
|
638
|
+
_subscriptions.forEach((sub) => sub());
|
|
639
|
+
_subscriptions = [];
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
});
|
|
643
|
+
return feedbackIntegration;
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
function getFeedback() {
|
|
647
|
+
const client = core.getClient();
|
|
648
|
+
return client?.getIntegrationByName("Feedback");
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
var n,l$1,u$1,i$1,o$1,r$1,f$1,c$1={},s$1=[],a$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,h$1=Array.isArray;function v$1(n,l){for(var u in l)n[u]=l[u];return n}function p$1(n){var l=n.parentNode;l&&l.removeChild(n);}function y$1(l,u,t){var i,o,r,f={};for(r in u)"key"==r?i=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps) void 0===f[r]&&(f[r]=l.defaultProps[r]);return d$1(l,f,i,o,null)}function d$1(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u$1:r,__i:-1,__u:0};return null==r&&null!=l$1.vnode&&l$1.vnode(f),f}function g$1(n){return n.children}function b$1(n,l){this.props=n,this.context=l;}function m$1(n,l){if(null==l)return n.__?m$1(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?m$1(n):null}function w$1(n,u,t){var i,o=n.__v,r=o.__e,f=n.__P;if(f)return (i=v$1({},o)).__v=o.__v+1,l$1.vnode&&l$1.vnode(i),M(f,i,o,n.__n,void 0!==f.ownerSVGElement,32&o.__u?[r]:null,u,null==r?m$1(o):r,!!(32&o.__u),t),i.__.__k[i.__i]=i,i.__d=void 0,i.__e!=r&&k$1(i),i}function k$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k$1(n)}}function x$1(n){(!n.__d&&(n.__d=true)&&i$1.push(n)&&!C$1.__r++||o$1!==l$1.debounceRendering)&&((o$1=l$1.debounceRendering)||r$1)(C$1);}function C$1(){var n,u,t,o=[],r=[];for(i$1.sort(f$1);n=i$1.shift();)n.__d&&(t=i$1.length,u=w$1(n,o,r)||u,0===t||i$1.length>t?(j$1(o,u,r),r.length=o.length=0,u=void 0,i$1.sort(f$1)):u&&l$1.__c&&l$1.__c(u,s$1));u&&j$1(o,u,r),C$1.__r=0;}function P$1(n,l,u,t,i,o,r,f,e,a,h){var v,p,y,d,_,g=t&&t.__k||s$1,b=l.length;for(u.__d=e,S(u,l,g),e=u.__d,v=0;v<b;v++)null!=(y=u.__k[v])&&"boolean"!=typeof y&&"function"!=typeof y&&(p=-1===y.__i?c$1:g[y.__i]||c$1,y.__i=v,M(n,y,p,i,o,r,f,e,a,h),d=y.__e,y.ref&&p.ref!=y.ref&&(p.ref&&N(p.ref,null,y),h.push(y.ref,y.__c||d,y)),null==_&&null!=d&&(_=d),65536&y.__u||p.__k===y.__k?e=$(y,e,n):"function"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=_;}function S(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)null!=(i=n.__k[t]=null==(i=l[t])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?d$1(null,i,null,null,i):h$1(i)?d$1(g$1,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?d$1(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=I(i,u,r=t+a,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,"function"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f===r+1?a++:f>r?s>e-r?a+=f-r:a--:a=f<r&&f==r-1?f-r:0,f!==t+a&&(i.__u|=65536))):(o=u[t])&&null==o.key&&o.__e&&(o.__e==n.__d&&(n.__d=m$1(o)),O(o,o,false),u[t]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=m$1(o)),O(o,o));}function $(n,l,u){var t,i;if("function"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=$(t[i],l,u));return l}n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e);do{l=l&&l.nextSibling;}while(null!=l&&8===l.nodeType);return l}function I(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type)return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--;}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++;}}return -1}function T$1(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||a$1.test(l)?u:u+"px";}function A$1(n,l,u,t,i){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof t&&(n.style.cssText=t=""),t)for(l in t)u&&l in u||T$1(n.style,l,"");if(u)for(l in u)t&&u[l]===t[l]||T$1(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/i,"$1")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=Date.now(),n.addEventListener(l,o?L:D$1,o)):n.removeEventListener(l,o?L:D$1,o);else {if(i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&"rowSpan"!==l&&"colSpan"!==l&&"role"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||false===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u));}}function D$1(n){if(this.l){var u=this.l[n.type+false];if(n.t){if(n.t<=u.u)return}else n.t=Date.now();return u(l$1.event?l$1.event(n):n)}}function L(n){if(this.l)return this.l[n.type+true](l$1.event?l$1.event(n):n)}function M(n,u,t,i,o,r,f,e,c,s){var a,p,y,d,_,m,w,k,x,C,S,$,H,I,T,A=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l$1.__b)&&a(u);n:if("function"==typeof A)try{if(k=u.props,x=(a=A.contextType)&&i[a.__c],C=a?x?x.props.value:a.__:i,t.__c?w=(p=u.__c=t.__c).__=p.__E:("prototype"in A&&A.prototype.render?u.__c=p=new A(k,C):(u.__c=p=new b$1(k,C),p.constructor=A,p.render=q$1),x&&x.sub(p),p.props=k,p.state||(p.state={}),p.context=C,p.__n=i,y=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=A.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=v$1({},p.__s)),v$1(p.__s,A.getDerivedStateFromProps(k,p.__s))),d=p.props,_=p.state,p.__v=u,y)null==A.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else {if(null==A.getDerivedStateFromProps&&k!==d&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(k,C),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(k,p.__s,C)||u.__v===t.__v)){for(u.__v!==t.__v&&(p.props=k,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.forEach(function(n){n&&(n.__=u);}),S=0;S<p._sb.length;S++)p.__h.push(p._sb[S]);p._sb=[],p.__h.length&&f.push(p);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(k,p.__s,C),null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(d,_,m);});}if(p.context=C,p.props=k,p.__P=n,p.__e=!1,$=l$1.__r,H=0,"prototype"in A&&A.prototype.render){for(p.state=p.__s,p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),I=0;I<p._sb.length;I++)p.__h.push(p._sb[I]);p._sb=[];}else do{p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),p.state=p.__s;}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=v$1(v$1({},i),p.getChildContext())),y||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(d,_)),P$1(n,h$1(T=null!=a&&a.type===g$1&&null==a.key?a.props.children:a)?T:[T],u,t,i,o,r,f,e,c,s),p.base=u.__e,u.__u&=-161,p.__h.length&&f.push(p),w&&(p.__E=p.__=null);}catch(n){u.__v=null,c||null!=r?(u.__e=e,u.__u|=c?160:32,r[r.indexOf(e)]=null):(u.__e=t.__e,u.__k=t.__k),l$1.__e(n,u,t);}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=z$1(t.__e,u,t,i,o,r,f,c,s);(a=l$1.diffed)&&a(u);}function j$1(n,u,t){for(var i=0;i<t.length;i++)N(t[i],t[++i],t[++i]);l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function z$1(l,u,t,i,o,r,f,e,s){var a,v,y,d,_,g,b,w=t.props,k=u.props,x=u.type;if("svg"===x&&(o=true),null!=r)for(a=0;a<r.length;a++)if((_=r[a])&&"setAttribute"in _==!!x&&(x?_.localName===x:3===_.nodeType)){l=_,r[a]=null;break}if(null==l){if(null===x)return document.createTextNode(k);l=o?document.createElementNS("http://www.w3.org/2000/svg",x):document.createElement(x,k.is&&k),r=null,e=false;}if(null===x)w===k||e&&l.data===k||(l.data=k);else {if(r=r&&n.call(l.childNodes),w=t.props||c$1,!e&&null!=r)for(w={},a=0;a<l.attributes.length;a++)w[(_=l.attributes[a]).name]=_.value;for(a in w)_=w[a],"children"==a||("dangerouslySetInnerHTML"==a?y=_:"key"===a||a in k||A$1(l,a,null,_,o));for(a in k)_=k[a],"children"==a?d=_:"dangerouslySetInnerHTML"==a?v=_:"value"==a?g=_:"checked"==a?b=_:"key"===a||e&&"function"!=typeof _||w[a]===_||A$1(l,a,_,w[a],o);if(v)e||y&&(v.__html===y.__html||v.__html===l.innerHTML)||(l.innerHTML=v.__html),u.__k=[];else if(y&&(l.innerHTML=""),P$1(l,h$1(d)?d:[d],u,t,i,o&&"foreignObject"!==x,r,f,r?r[0]:t.__k&&m$1(t,0),e,s),null!=r)for(a=r.length;a--;)null!=r[a]&&p$1(r[a]);e||(a="value",void 0!==g&&(g!==l[a]||"progress"===x&&!g||"option"===x&&g!==w[a])&&A$1(l,a,g,w[a],false),a="checked",void 0!==b&&b!==l[a]&&A$1(l,a,b,w[a],false));}return l}function N(n,u,t){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,t);}}function O(n,u,t){var i,o;if(l$1.unmount&&l$1.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||N(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount();}catch(n){l$1.__e(n,u);}i.base=i.__P=null,n.__c=void 0;}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&O(i[o],u,t||"function"!=typeof n.type);t||null==n.__e||p$1(n.__e),n.__=n.__e=n.__d=void 0;}function q$1(n,l,u){return this.constructor(n,u)}function B$1(u,t,i){var o,r,f,e;l$1.__&&l$1.__(u,t),r=(o="function"=="undefined")?null:t.__k,f=[],e=[],M(t,u=(t).__k=y$1(g$1,null,[u]),r||c$1,c$1,void 0!==t.ownerSVGElement,r?null:t.firstChild?n.call(t.childNodes):null,f,r?r.__e:t.firstChild,o,e),u.__d=void 0,j$1(f,u,e);}n=s$1.slice,l$1={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l;}throw n}},u$1=0,b$1.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=v$1({},this.state),"function"==typeof n&&(n=n(v$1({},u),this.props)),n&&v$1(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),x$1(this));},b$1.prototype.forceUpdate=function(n){this.__v&&(this.__e=true,n&&this.__h.push(n),x$1(this));},b$1.prototype.render=g$1,i$1=[],r$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f$1=function(n,l){return n.__v.__b-l.__v.__b},C$1.__r=0;
|
|
652
|
+
|
|
653
|
+
var t,r,u,i,o=0,f=[],c=[],e=l$1,a=e.__b,v=e.__r,l=e.diffed,m=e.__c,s=e.unmount,d=e.__;function h(n,t){e.__h&&e.__h(r,n,o||t),o=0;var u=r.__H||(r.__H={__:[],__h:[]});return n>=u.__.length&&u.__.push({__V:c}),u.__[n]}function p(n){return o=1,y(D,n)}function y(n,u,i){var o=h(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):D(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}));}],o.__c=r,!r.u)){var f=function(n,t,r){if(!o.__c.__H)return true;var u=o.__c.__H.__.filter(function(n){return !!n.__c});if(u.every(function(n){return !n.__N}))return !c||c.call(this,n,t,r);var i=false;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=true);}}),!(!i&&o.__c.props===n)&&(!c||c.call(this,n,t,r))};r.u=true;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u;}e&&e.call(this,n,t,r);},r.shouldComponentUpdate=f;}return o.__N||o.__}function _(n,u){var i=h(t++,3);!e.__s&&C(i.__H,u)&&(i.__=n,i.i=u,r.__H.__h.push(i));}function A(n,u){var i=h(t++,4);!e.__s&&C(i.__H,u)&&(i.__=n,i.i=u,r.__h.push(i));}function F(n){return o=5,q(function(){return {current:n}},[])}function T(n,t,r){o=6,A(function(){return "function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n));}function q(n,r){var u=h(t++,7);return C(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function x(n,t){return o=8,q(function(){return n},t)}function P(n){var u=r.context[n.__c],i=h(t++,9);return i.c=n,u?(null==i.__&&(i.__=true,u.sub(r)),u.props.value):n.__}function V(n,t){e.useDebugValue&&e.useDebugValue(t?t(n):n);}function b(n){var u=h(t++,10),i=p();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n);}),[i[0],function(){i[1](void 0);}]}function g(){var n=h(t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__="P"+i[0]+"-"+i[1]++;}return n.__}function j(){for(var n;n=f.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(z),n.__H.__h.forEach(B),n.__H.__h=[];}catch(t){n.__H.__h=[],e.__e(t,n.__v);}}e.__b=function(n){r=null,a&&a(n);},e.__=function(n,t){t.__k&&t.__k.__m&&(n.__m=t.__k.__m),d&&d(n,t);},e.__r=function(n){v&&v(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0;})):(i.__h.forEach(z),i.__h.forEach(B),i.__h=[],t=0)),u=r;},e.diffed=function(n){l&&l(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(1!==f.push(t)&&i===e.requestAnimationFrame||((i=e.requestAnimationFrame)||w)(j)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c;})),u=r=null;},e.__c=function(n,t){t.some(function(n){try{n.__h.forEach(z),n.__h=n.__h.filter(function(n){return !n.__||B(n)});}catch(r){t.some(function(n){n.__h&&(n.__h=[]);}),t=[],e.__e(r,n.__v);}}),m&&m(n,t);},e.unmount=function(n){s&&s(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{z(n);}catch(n){t=n;}}),r.__H=void 0,t&&e.__e(t,r.__v));};var k="function"==typeof requestAnimationFrame;function w(n){var t,r=function(){clearTimeout(u),k&&cancelAnimationFrame(t),setTimeout(n);},u=setTimeout(r,100);k&&(t=requestAnimationFrame(r));}function z(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t;}function B(n){var t=r;n.__c=n.__(),r=t;}function C(n,t){return !n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function D(n,t){return "function"==typeof t?t(n):t}
|
|
654
|
+
|
|
655
|
+
const hooks = /*#__PURE__*/Object.defineProperty({
|
|
656
|
+
__proto__: null,
|
|
657
|
+
useCallback: x,
|
|
658
|
+
useContext: P,
|
|
659
|
+
useDebugValue: V,
|
|
660
|
+
useEffect: _,
|
|
661
|
+
useErrorBoundary: b,
|
|
662
|
+
useId: g,
|
|
663
|
+
useImperativeHandle: T,
|
|
664
|
+
useLayoutEffect: A,
|
|
665
|
+
useMemo: q,
|
|
666
|
+
useReducer: y,
|
|
667
|
+
useRef: F,
|
|
668
|
+
useState: p
|
|
669
|
+
}, Symbol.toStringTag, { value: 'Module' });
|
|
670
|
+
|
|
671
|
+
const XMLNS$1 = "http://www.w3.org/2000/svg";
|
|
672
|
+
function SentryLogo() {
|
|
673
|
+
const createElementNS = (tagName) => DOCUMENT.createElementNS(XMLNS$1, tagName);
|
|
674
|
+
const svg = setAttributesNS(createElementNS("svg"), {
|
|
675
|
+
width: "32",
|
|
676
|
+
height: "30",
|
|
677
|
+
viewBox: "0 0 72 66",
|
|
678
|
+
fill: "inherit"
|
|
679
|
+
});
|
|
680
|
+
const path = setAttributesNS(createElementNS("path"), {
|
|
681
|
+
transform: "translate(11, 11)",
|
|
682
|
+
d: "M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z"
|
|
683
|
+
});
|
|
684
|
+
svg.appendChild(path);
|
|
685
|
+
return svg;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function DialogHeader({ options }) {
|
|
689
|
+
const logoHtml = q(() => ({ __html: SentryLogo().outerHTML }), []);
|
|
690
|
+
return /* @__PURE__ */ y$1("h2", { class: "dialog__header" }, /* @__PURE__ */ y$1("span", { class: "dialog__title" }, options.formTitle), options.showBranding ? /* @__PURE__ */ y$1(
|
|
691
|
+
"a",
|
|
692
|
+
{
|
|
693
|
+
class: "brand-link",
|
|
694
|
+
target: "_blank",
|
|
695
|
+
href: "https://sentry.io/welcome/",
|
|
696
|
+
title: "Powered by Sentry",
|
|
697
|
+
rel: "noopener noreferrer",
|
|
698
|
+
dangerouslySetInnerHTML: logoHtml
|
|
699
|
+
}
|
|
700
|
+
) : null);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function getMissingFields(feedback, props) {
|
|
704
|
+
const emptyFields = [];
|
|
705
|
+
if (props.isNameRequired && !feedback.name) {
|
|
706
|
+
emptyFields.push(props.nameLabel);
|
|
707
|
+
}
|
|
708
|
+
if (props.isEmailRequired && !feedback.email) {
|
|
709
|
+
emptyFields.push(props.emailLabel);
|
|
710
|
+
}
|
|
711
|
+
if (!feedback.message) {
|
|
712
|
+
emptyFields.push(props.messageLabel);
|
|
713
|
+
}
|
|
714
|
+
return emptyFields;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
function retrieveStringValue(formData, key) {
|
|
718
|
+
const value = formData.get(key);
|
|
719
|
+
if (typeof value === "string") {
|
|
720
|
+
return value.trim();
|
|
721
|
+
}
|
|
722
|
+
return "";
|
|
723
|
+
}
|
|
724
|
+
function Form({
|
|
725
|
+
options,
|
|
726
|
+
defaultEmail,
|
|
727
|
+
defaultName,
|
|
728
|
+
onFormClose,
|
|
729
|
+
onSubmit,
|
|
730
|
+
onSubmitSuccess,
|
|
731
|
+
onSubmitError,
|
|
732
|
+
showEmail,
|
|
733
|
+
showName,
|
|
734
|
+
screenshotInput
|
|
735
|
+
}) {
|
|
736
|
+
const {
|
|
737
|
+
tags,
|
|
738
|
+
addScreenshotButtonLabel,
|
|
739
|
+
removeScreenshotButtonLabel,
|
|
740
|
+
cancelButtonLabel,
|
|
741
|
+
emailLabel,
|
|
742
|
+
emailPlaceholder,
|
|
743
|
+
isEmailRequired,
|
|
744
|
+
isNameRequired,
|
|
745
|
+
messageLabel,
|
|
746
|
+
messagePlaceholder,
|
|
747
|
+
nameLabel,
|
|
748
|
+
namePlaceholder,
|
|
749
|
+
submitButtonLabel,
|
|
750
|
+
isRequiredLabel
|
|
751
|
+
} = options;
|
|
752
|
+
const [isSubmitting, setIsSubmitting] = p(false);
|
|
753
|
+
const [error, setError] = p(null);
|
|
754
|
+
const [showScreenshotInput, setShowScreenshotInput] = p(false);
|
|
755
|
+
const ScreenshotInputComponent = screenshotInput?.input;
|
|
756
|
+
const [screenshotError, setScreenshotError] = p(null);
|
|
757
|
+
const onScreenshotError = x((error2) => {
|
|
758
|
+
setScreenshotError(error2);
|
|
759
|
+
setShowScreenshotInput(false);
|
|
760
|
+
}, []);
|
|
761
|
+
const hasAllRequiredFields = x(
|
|
762
|
+
(data) => {
|
|
763
|
+
const missingFields = getMissingFields(data, {
|
|
764
|
+
emailLabel,
|
|
765
|
+
isEmailRequired,
|
|
766
|
+
isNameRequired,
|
|
767
|
+
messageLabel,
|
|
768
|
+
nameLabel
|
|
769
|
+
});
|
|
770
|
+
if (missingFields.length > 0) {
|
|
771
|
+
setError(`Please enter in the following required fields: ${missingFields.join(", ")}`);
|
|
772
|
+
} else {
|
|
773
|
+
setError(null);
|
|
774
|
+
}
|
|
775
|
+
return missingFields.length === 0;
|
|
776
|
+
},
|
|
777
|
+
[emailLabel, isEmailRequired, isNameRequired, messageLabel, nameLabel]
|
|
778
|
+
);
|
|
779
|
+
const handleSubmit = x(
|
|
780
|
+
async (e) => {
|
|
781
|
+
setIsSubmitting(true);
|
|
782
|
+
try {
|
|
783
|
+
e.preventDefault();
|
|
784
|
+
if (!(e.target instanceof HTMLFormElement)) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
const formData = new FormData(e.target);
|
|
788
|
+
const attachment = await (screenshotInput && showScreenshotInput ? screenshotInput.value() : void 0);
|
|
789
|
+
const data = {
|
|
790
|
+
name: retrieveStringValue(formData, "name"),
|
|
791
|
+
email: retrieveStringValue(formData, "email"),
|
|
792
|
+
message: retrieveStringValue(formData, "message"),
|
|
793
|
+
attachments: attachment ? [attachment] : void 0
|
|
794
|
+
};
|
|
795
|
+
if (!hasAllRequiredFields(data)) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
try {
|
|
799
|
+
const eventId = await onSubmit(
|
|
800
|
+
{
|
|
801
|
+
name: data.name,
|
|
802
|
+
email: data.email,
|
|
803
|
+
message: data.message,
|
|
804
|
+
source: FEEDBACK_WIDGET_SOURCE,
|
|
805
|
+
tags
|
|
806
|
+
},
|
|
807
|
+
{ attachments: data.attachments }
|
|
808
|
+
);
|
|
809
|
+
onSubmitSuccess(data, eventId);
|
|
810
|
+
} catch (error2) {
|
|
811
|
+
DEBUG_BUILD && core.debug.error(error2);
|
|
812
|
+
const err = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
813
|
+
setError(err.message);
|
|
814
|
+
onSubmitError(err);
|
|
815
|
+
}
|
|
816
|
+
} finally {
|
|
817
|
+
setIsSubmitting(false);
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
[screenshotInput && showScreenshotInput, onSubmitSuccess, onSubmitError]
|
|
821
|
+
);
|
|
822
|
+
return /* @__PURE__ */ y$1("form", { class: "form", onSubmit: handleSubmit }, ScreenshotInputComponent && showScreenshotInput ? /* @__PURE__ */ y$1(ScreenshotInputComponent, { onError: onScreenshotError }) : null, /* @__PURE__ */ y$1("fieldset", { class: "form__right", "data-sentry-feedback": true, disabled: isSubmitting }, /* @__PURE__ */ y$1("div", { class: "form__top" }, error ? /* @__PURE__ */ y$1("div", { class: "form__error-container" }, error) : null, showName ? /* @__PURE__ */ y$1("label", { for: "name", class: "form__label" }, /* @__PURE__ */ y$1(LabelText, { label: nameLabel, isRequiredLabel, isRequired: isNameRequired }), /* @__PURE__ */ y$1(
|
|
823
|
+
"input",
|
|
824
|
+
{
|
|
825
|
+
class: "form__input",
|
|
826
|
+
defaultValue: defaultName,
|
|
827
|
+
id: "name",
|
|
828
|
+
name: "name",
|
|
829
|
+
placeholder: namePlaceholder,
|
|
830
|
+
required: isNameRequired,
|
|
831
|
+
type: "text"
|
|
832
|
+
}
|
|
833
|
+
)) : /* @__PURE__ */ y$1("input", { "aria-hidden": true, value: defaultName, name: "name", type: "hidden" }), showEmail ? /* @__PURE__ */ y$1("label", { for: "email", class: "form__label" }, /* @__PURE__ */ y$1(LabelText, { label: emailLabel, isRequiredLabel, isRequired: isEmailRequired }), /* @__PURE__ */ y$1(
|
|
834
|
+
"input",
|
|
835
|
+
{
|
|
836
|
+
class: "form__input",
|
|
837
|
+
defaultValue: defaultEmail,
|
|
838
|
+
id: "email",
|
|
839
|
+
name: "email",
|
|
840
|
+
placeholder: emailPlaceholder,
|
|
841
|
+
required: isEmailRequired,
|
|
842
|
+
type: "email"
|
|
843
|
+
}
|
|
844
|
+
)) : /* @__PURE__ */ y$1("input", { "aria-hidden": true, value: defaultEmail, name: "email", type: "hidden" }), /* @__PURE__ */ y$1("label", { for: "message", class: "form__label" }, /* @__PURE__ */ y$1(LabelText, { label: messageLabel, isRequiredLabel, isRequired: true }), /* @__PURE__ */ y$1(
|
|
845
|
+
"textarea",
|
|
846
|
+
{
|
|
847
|
+
autoFocus: true,
|
|
848
|
+
class: "form__input form__input--textarea",
|
|
849
|
+
id: "message",
|
|
850
|
+
name: "message",
|
|
851
|
+
placeholder: messagePlaceholder,
|
|
852
|
+
required: true,
|
|
853
|
+
rows: 5
|
|
854
|
+
}
|
|
855
|
+
)), ScreenshotInputComponent ? /* @__PURE__ */ y$1("label", { for: "screenshot", class: "form__label" }, /* @__PURE__ */ y$1(
|
|
856
|
+
"button",
|
|
857
|
+
{
|
|
858
|
+
class: "btn btn--default",
|
|
859
|
+
disabled: isSubmitting,
|
|
860
|
+
type: "button",
|
|
861
|
+
onClick: () => {
|
|
862
|
+
setScreenshotError(null);
|
|
863
|
+
setShowScreenshotInput((prev) => !prev);
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
showScreenshotInput ? removeScreenshotButtonLabel : addScreenshotButtonLabel
|
|
867
|
+
), screenshotError ? /* @__PURE__ */ y$1("div", { class: "form__error-container" }, screenshotError.message) : null) : null), /* @__PURE__ */ y$1("div", { class: "btn-group" }, /* @__PURE__ */ y$1("button", { class: "btn btn--primary", disabled: isSubmitting, type: "submit" }, submitButtonLabel), /* @__PURE__ */ y$1("button", { class: "btn btn--default", disabled: isSubmitting, type: "button", onClick: onFormClose }, cancelButtonLabel))));
|
|
868
|
+
}
|
|
869
|
+
function LabelText({
|
|
870
|
+
label,
|
|
871
|
+
isRequired,
|
|
872
|
+
isRequiredLabel
|
|
873
|
+
}) {
|
|
874
|
+
return /* @__PURE__ */ y$1("span", { class: "form__label__text" }, label, isRequired && /* @__PURE__ */ y$1("span", { class: "form__label__text--required" }, isRequiredLabel));
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
const WIDTH = 16;
|
|
878
|
+
const HEIGHT = 17;
|
|
879
|
+
const XMLNS = "http://www.w3.org/2000/svg";
|
|
880
|
+
function SuccessIcon() {
|
|
881
|
+
const createElementNS = (tagName) => WINDOW.document.createElementNS(XMLNS, tagName);
|
|
882
|
+
const svg = setAttributesNS(createElementNS("svg"), {
|
|
883
|
+
width: `${WIDTH}`,
|
|
884
|
+
height: `${HEIGHT}`,
|
|
885
|
+
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
886
|
+
fill: "inherit"
|
|
887
|
+
});
|
|
888
|
+
const g = setAttributesNS(createElementNS("g"), {
|
|
889
|
+
clipPath: "url(#clip0_57_156)"
|
|
890
|
+
});
|
|
891
|
+
const path2 = setAttributesNS(createElementNS("path"), {
|
|
892
|
+
["fill-rule"]: "evenodd",
|
|
893
|
+
["clip-rule"]: "evenodd",
|
|
894
|
+
d: "M3.55544 15.1518C4.87103 16.0308 6.41775 16.5 8 16.5C10.1217 16.5 12.1566 15.6571 13.6569 14.1569C15.1571 12.6566 16 10.6217 16 8.5C16 6.91775 15.5308 5.37103 14.6518 4.05544C13.7727 2.73985 12.5233 1.71447 11.0615 1.10897C9.59966 0.503466 7.99113 0.34504 6.43928 0.653721C4.88743 0.962403 3.46197 1.72433 2.34315 2.84315C1.22433 3.96197 0.462403 5.38743 0.153721 6.93928C-0.15496 8.49113 0.00346625 10.0997 0.608967 11.5615C1.21447 13.0233 2.23985 14.2727 3.55544 15.1518ZM4.40546 3.1204C5.46945 2.40946 6.72036 2.03 8 2.03C9.71595 2.03 11.3616 2.71166 12.575 3.92502C13.7883 5.13838 14.47 6.78405 14.47 8.5C14.47 9.77965 14.0905 11.0306 13.3796 12.0945C12.6687 13.1585 11.6582 13.9878 10.476 14.4775C9.29373 14.9672 7.99283 15.0953 6.73777 14.8457C5.48271 14.596 4.32987 13.9798 3.42502 13.075C2.52018 12.1701 1.90397 11.0173 1.65432 9.76224C1.40468 8.50718 1.5328 7.20628 2.0225 6.02404C2.5122 4.8418 3.34148 3.83133 4.40546 3.1204Z"
|
|
895
|
+
});
|
|
896
|
+
const path = setAttributesNS(createElementNS("path"), {
|
|
897
|
+
d: "M6.68775 12.4297C6.78586 12.4745 6.89218 12.4984 7 12.5C7.11275 12.4955 7.22315 12.4664 7.32337 12.4145C7.4236 12.3627 7.51121 12.2894 7.58 12.2L12 5.63999C12.0848 5.47724 12.1071 5.28902 12.0625 5.11098C12.0178 4.93294 11.9095 4.77744 11.7579 4.67392C11.6064 4.57041 11.4221 4.52608 11.24 4.54931C11.0579 4.57254 10.8907 4.66173 10.77 4.79999L6.88 10.57L5.13 8.56999C5.06508 8.49566 4.98613 8.43488 4.89768 8.39111C4.80922 8.34735 4.713 8.32148 4.61453 8.31498C4.51605 8.30847 4.41727 8.32147 4.32382 8.35322C4.23038 8.38497 4.14413 8.43484 4.07 8.49999C3.92511 8.63217 3.83692 8.81523 3.82387 9.01092C3.81083 9.2066 3.87393 9.39976 4 9.54999L6.43 12.24C6.50187 12.3204 6.58964 12.385 6.68775 12.4297Z"
|
|
898
|
+
});
|
|
899
|
+
svg.appendChild(g).append(path, path2);
|
|
900
|
+
const speakerDefs = createElementNS("defs");
|
|
901
|
+
const speakerClipPathDef = setAttributesNS(createElementNS("clipPath"), {
|
|
902
|
+
id: "clip0_57_156"
|
|
903
|
+
});
|
|
904
|
+
const speakerRect = setAttributesNS(createElementNS("rect"), {
|
|
905
|
+
width: `${WIDTH}`,
|
|
906
|
+
height: `${WIDTH}`,
|
|
907
|
+
fill: "white",
|
|
908
|
+
transform: "translate(0 0.5)"
|
|
909
|
+
});
|
|
910
|
+
speakerClipPathDef.appendChild(speakerRect);
|
|
911
|
+
speakerDefs.appendChild(speakerClipPathDef);
|
|
912
|
+
svg.appendChild(speakerDefs).appendChild(speakerClipPathDef).appendChild(speakerRect);
|
|
913
|
+
return svg;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
function Dialog({ open, onFormSubmitted, ...props }) {
|
|
917
|
+
const options = props.options;
|
|
918
|
+
const successIconHtml = q(() => ({ __html: SuccessIcon().outerHTML }), []);
|
|
919
|
+
const [timeoutId, setTimeoutId] = p(null);
|
|
920
|
+
const handleOnSuccessClick = x(() => {
|
|
921
|
+
if (timeoutId) {
|
|
922
|
+
clearTimeout(timeoutId);
|
|
923
|
+
setTimeoutId(null);
|
|
924
|
+
}
|
|
925
|
+
onFormSubmitted();
|
|
926
|
+
}, [timeoutId]);
|
|
927
|
+
const onSubmitSuccess = x(
|
|
928
|
+
(data, eventId) => {
|
|
929
|
+
props.onSubmitSuccess(data, eventId);
|
|
930
|
+
setTimeoutId(
|
|
931
|
+
setTimeout(() => {
|
|
932
|
+
onFormSubmitted();
|
|
933
|
+
setTimeoutId(null);
|
|
934
|
+
}, SUCCESS_MESSAGE_TIMEOUT)
|
|
935
|
+
);
|
|
936
|
+
},
|
|
937
|
+
[onFormSubmitted]
|
|
938
|
+
);
|
|
939
|
+
return /* @__PURE__ */ y$1(g$1, null, timeoutId ? /* @__PURE__ */ y$1("div", { class: "success__position", onClick: handleOnSuccessClick }, /* @__PURE__ */ y$1("div", { class: "success__content" }, options.successMessageText, /* @__PURE__ */ y$1("span", { class: "success__icon", dangerouslySetInnerHTML: successIconHtml }))) : /* @__PURE__ */ y$1("dialog", { class: "dialog", onClick: options.onFormClose, open }, /* @__PURE__ */ y$1("div", { class: "dialog__position" }, /* @__PURE__ */ y$1(
|
|
940
|
+
"div",
|
|
941
|
+
{
|
|
942
|
+
class: "dialog__content",
|
|
943
|
+
onClick: (e) => {
|
|
944
|
+
e.stopPropagation();
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
/* @__PURE__ */ y$1(DialogHeader, { options }),
|
|
948
|
+
/* @__PURE__ */ y$1(Form, { ...props, onSubmitSuccess })
|
|
949
|
+
))));
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const DIALOG = `
|
|
953
|
+
.dialog {
|
|
954
|
+
position: fixed;
|
|
955
|
+
z-index: var(--z-index);
|
|
956
|
+
margin: 0;
|
|
957
|
+
inset: 0;
|
|
958
|
+
|
|
959
|
+
display: flex;
|
|
960
|
+
align-items: center;
|
|
961
|
+
justify-content: center;
|
|
962
|
+
padding: 0;
|
|
963
|
+
height: 100vh;
|
|
964
|
+
width: 100vw;
|
|
965
|
+
|
|
966
|
+
color: var(--dialog-color, var(--foreground));
|
|
967
|
+
fill: var(--dialog-color, var(--foreground));
|
|
968
|
+
line-height: 1.75em;
|
|
969
|
+
|
|
970
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
971
|
+
border: none;
|
|
972
|
+
inset: 0;
|
|
973
|
+
opacity: 1;
|
|
974
|
+
transition: opacity 0.2s ease-in-out;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
.dialog__position {
|
|
978
|
+
position: fixed;
|
|
979
|
+
z-index: var(--z-index);
|
|
980
|
+
inset: var(--dialog-inset);
|
|
981
|
+
padding: var(--page-margin);
|
|
982
|
+
display: flex;
|
|
983
|
+
max-height: calc(100vh - (2 * var(--page-margin)));
|
|
984
|
+
}
|
|
985
|
+
@media (max-width: 600px) {
|
|
986
|
+
.dialog__position {
|
|
987
|
+
inset: var(--page-margin);
|
|
988
|
+
padding: 0;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
.dialog__position:has(.editor) {
|
|
993
|
+
inset: var(--page-margin);
|
|
994
|
+
padding: 0;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
.dialog:not([open]) {
|
|
998
|
+
opacity: 0;
|
|
999
|
+
pointer-events: none;
|
|
1000
|
+
visibility: hidden;
|
|
1001
|
+
}
|
|
1002
|
+
.dialog:not([open]) .dialog__content {
|
|
1003
|
+
transform: translate(0, -16px) scale(0.98);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
.dialog__content {
|
|
1007
|
+
display: flex;
|
|
1008
|
+
flex-direction: column;
|
|
1009
|
+
gap: 16px;
|
|
1010
|
+
padding: var(--dialog-padding, 24px);
|
|
1011
|
+
max-width: 100%;
|
|
1012
|
+
width: 100%;
|
|
1013
|
+
max-height: 100%;
|
|
1014
|
+
overflow: auto;
|
|
1015
|
+
|
|
1016
|
+
background: var(--dialog-background, var(--background));
|
|
1017
|
+
border-radius: var(--dialog-border-radius, 20px);
|
|
1018
|
+
border: var(--dialog-border, var(--border));
|
|
1019
|
+
box-shadow: var(--dialog-box-shadow, var(--box-shadow));
|
|
1020
|
+
transform: translate(0, 0) scale(1);
|
|
1021
|
+
transition: transform 0.2s ease-in-out;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
`;
|
|
1025
|
+
const DIALOG_HEADER = `
|
|
1026
|
+
.dialog__header {
|
|
1027
|
+
display: flex;
|
|
1028
|
+
gap: 4px;
|
|
1029
|
+
justify-content: space-between;
|
|
1030
|
+
font-weight: var(--dialog-header-weight, 600);
|
|
1031
|
+
margin: 0;
|
|
1032
|
+
}
|
|
1033
|
+
.dialog__title {
|
|
1034
|
+
align-self: center;
|
|
1035
|
+
width: var(--form-width, 272px);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
@media (max-width: 600px) {
|
|
1039
|
+
.dialog__title {
|
|
1040
|
+
width: auto;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.dialog__position:has(.editor) .dialog__title {
|
|
1045
|
+
width: auto;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
.brand-link {
|
|
1050
|
+
display: inline-flex;
|
|
1051
|
+
}
|
|
1052
|
+
.brand-link:focus-visible {
|
|
1053
|
+
outline: var(--outline);
|
|
1054
|
+
}
|
|
1055
|
+
`;
|
|
1056
|
+
const FORM = `
|
|
1057
|
+
.form {
|
|
1058
|
+
display: flex;
|
|
1059
|
+
overflow: auto;
|
|
1060
|
+
flex-direction: row;
|
|
1061
|
+
gap: 16px;
|
|
1062
|
+
flex: 1 0;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
.form fieldset {
|
|
1066
|
+
border: none;
|
|
1067
|
+
margin: 0;
|
|
1068
|
+
padding: 0;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
.form__right {
|
|
1072
|
+
flex: 0 0 auto;
|
|
1073
|
+
display: flex;
|
|
1074
|
+
overflow: auto;
|
|
1075
|
+
flex-direction: column;
|
|
1076
|
+
justify-content: space-between;
|
|
1077
|
+
gap: 20px;
|
|
1078
|
+
width: var(--form-width, 100%);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
.dialog__position:has(.editor) .form__right {
|
|
1082
|
+
width: var(--form-width, 272px);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
.form__top {
|
|
1086
|
+
display: flex;
|
|
1087
|
+
flex-direction: column;
|
|
1088
|
+
gap: 8px;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
.form__error-container {
|
|
1092
|
+
color: var(--error-color);
|
|
1093
|
+
fill: var(--error-color);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
.form__label {
|
|
1097
|
+
display: flex;
|
|
1098
|
+
flex-direction: column;
|
|
1099
|
+
gap: 4px;
|
|
1100
|
+
margin: 0px;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.form__label__text {
|
|
1104
|
+
display: flex;
|
|
1105
|
+
gap: 4px;
|
|
1106
|
+
align-items: center;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
.form__label__text--required {
|
|
1110
|
+
font-size: 0.85em;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
.form__input {
|
|
1114
|
+
font-family: inherit;
|
|
1115
|
+
line-height: inherit;
|
|
1116
|
+
background: transparent;
|
|
1117
|
+
box-sizing: border-box;
|
|
1118
|
+
border: var(--input-border, var(--border));
|
|
1119
|
+
border-radius: var(--input-border-radius, 6px);
|
|
1120
|
+
color: var(--input-color, inherit);
|
|
1121
|
+
fill: var(--input-color, inherit);
|
|
1122
|
+
font-size: var(--input-font-size, inherit);
|
|
1123
|
+
font-weight: var(--input-font-weight, 500);
|
|
1124
|
+
padding: 6px 12px;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
.form__input::placeholder {
|
|
1128
|
+
opacity: 0.65;
|
|
1129
|
+
color: var(--input-placeholder-color, inherit);
|
|
1130
|
+
filter: var(--interactive-filter);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
.form__input:focus-visible {
|
|
1134
|
+
outline: var(--input-focus-outline, var(--outline));
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
.form__input--textarea {
|
|
1138
|
+
font-family: inherit;
|
|
1139
|
+
resize: vertical;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
.error {
|
|
1143
|
+
color: var(--error-color);
|
|
1144
|
+
fill: var(--error-color);
|
|
1145
|
+
}
|
|
1146
|
+
`;
|
|
1147
|
+
const BUTTON = `
|
|
1148
|
+
.btn-group {
|
|
1149
|
+
display: grid;
|
|
1150
|
+
gap: 8px;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
.btn {
|
|
1154
|
+
line-height: inherit;
|
|
1155
|
+
border: var(--button-border, var(--border));
|
|
1156
|
+
border-radius: var(--button-border-radius, 6px);
|
|
1157
|
+
cursor: pointer;
|
|
1158
|
+
font-family: inherit;
|
|
1159
|
+
font-size: var(--button-font-size, inherit);
|
|
1160
|
+
font-weight: var(--button-font-weight, 600);
|
|
1161
|
+
padding: var(--button-padding, 6px 16px);
|
|
1162
|
+
}
|
|
1163
|
+
.btn[disabled] {
|
|
1164
|
+
opacity: 0.6;
|
|
1165
|
+
pointer-events: none;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
.btn--primary {
|
|
1169
|
+
color: var(--button-primary-color, var(--accent-foreground));
|
|
1170
|
+
fill: var(--button-primary-color, var(--accent-foreground));
|
|
1171
|
+
background: var(--button-primary-background, var(--accent-background));
|
|
1172
|
+
border: var(--button-primary-border, var(--border));
|
|
1173
|
+
border-radius: var(--button-primary-border-radius, 6px);
|
|
1174
|
+
font-weight: var(--button-primary-font-weight, 500);
|
|
1175
|
+
}
|
|
1176
|
+
.btn--primary:hover {
|
|
1177
|
+
color: var(--button-primary-hover-color, var(--accent-foreground));
|
|
1178
|
+
fill: var(--button-primary-hover-color, var(--accent-foreground));
|
|
1179
|
+
background: var(--button-primary-hover-background, var(--accent-background));
|
|
1180
|
+
filter: var(--interactive-filter);
|
|
1181
|
+
}
|
|
1182
|
+
.btn--primary:focus-visible {
|
|
1183
|
+
background: var(--button-primary-hover-background, var(--accent-background));
|
|
1184
|
+
filter: var(--interactive-filter);
|
|
1185
|
+
outline: var(--button-primary-focus-outline, var(--outline));
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
.btn--default {
|
|
1189
|
+
color: var(--button-color, var(--foreground));
|
|
1190
|
+
fill: var(--button-color, var(--foreground));
|
|
1191
|
+
background: var(--button-background, var(--background));
|
|
1192
|
+
border: var(--button-border, var(--border));
|
|
1193
|
+
border-radius: var(--button-border-radius, 6px);
|
|
1194
|
+
font-weight: var(--button-font-weight, 500);
|
|
1195
|
+
}
|
|
1196
|
+
.btn--default:hover {
|
|
1197
|
+
color: var(--button-color, var(--foreground));
|
|
1198
|
+
fill: var(--button-color, var(--foreground));
|
|
1199
|
+
background: var(--button-hover-background, var(--background));
|
|
1200
|
+
filter: var(--interactive-filter);
|
|
1201
|
+
}
|
|
1202
|
+
.btn--default:focus-visible {
|
|
1203
|
+
background: var(--button-hover-background, var(--background));
|
|
1204
|
+
filter: var(--interactive-filter);
|
|
1205
|
+
outline: var(--button-focus-outline, var(--outline));
|
|
1206
|
+
}
|
|
1207
|
+
`;
|
|
1208
|
+
const SUCCESS = `
|
|
1209
|
+
.success__position {
|
|
1210
|
+
position: fixed;
|
|
1211
|
+
inset: var(--dialog-inset);
|
|
1212
|
+
padding: var(--page-margin);
|
|
1213
|
+
z-index: var(--z-index);
|
|
1214
|
+
}
|
|
1215
|
+
.success__content {
|
|
1216
|
+
background: var(--success-background, var(--background));
|
|
1217
|
+
border: var(--success-border, var(--border));
|
|
1218
|
+
border-radius: var(--success-border-radius, 1.7em/50%);
|
|
1219
|
+
box-shadow: var(--success-box-shadow, var(--box-shadow));
|
|
1220
|
+
font-weight: var(--success-font-weight, 600);
|
|
1221
|
+
color: var(--success-color);
|
|
1222
|
+
fill: var(--success-color);
|
|
1223
|
+
padding: 12px 24px;
|
|
1224
|
+
line-height: 1.75em;
|
|
1225
|
+
|
|
1226
|
+
display: grid;
|
|
1227
|
+
align-items: center;
|
|
1228
|
+
grid-auto-flow: column;
|
|
1229
|
+
gap: 6px;
|
|
1230
|
+
cursor: default;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
.success__icon {
|
|
1234
|
+
display: flex;
|
|
1235
|
+
}
|
|
1236
|
+
`;
|
|
1237
|
+
function createDialogStyles(styleNonce) {
|
|
1238
|
+
const style = DOCUMENT.createElement("style");
|
|
1239
|
+
style.textContent = `
|
|
1240
|
+
:host {
|
|
1241
|
+
--dialog-inset: var(--inset);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
${DIALOG}
|
|
1245
|
+
${DIALOG_HEADER}
|
|
1246
|
+
${FORM}
|
|
1247
|
+
${BUTTON}
|
|
1248
|
+
${SUCCESS}
|
|
1249
|
+
`;
|
|
1250
|
+
if (styleNonce) {
|
|
1251
|
+
style.setAttribute("nonce", styleNonce);
|
|
1252
|
+
}
|
|
1253
|
+
return style;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
function getUser() {
|
|
1257
|
+
const currentUser = core.getCurrentScope().getUser();
|
|
1258
|
+
const isolationUser = core.getIsolationScope().getUser();
|
|
1259
|
+
const globalUser = core.getGlobalScope().getUser();
|
|
1260
|
+
if (currentUser && Object.keys(currentUser).length) {
|
|
1261
|
+
return currentUser;
|
|
1262
|
+
}
|
|
1263
|
+
if (isolationUser && Object.keys(isolationUser).length) {
|
|
1264
|
+
return isolationUser;
|
|
1265
|
+
}
|
|
1266
|
+
return globalUser;
|
|
1267
|
+
}
|
|
1268
|
+
const feedbackModalIntegration = (() => {
|
|
1269
|
+
return {
|
|
1270
|
+
name: "FeedbackModal",
|
|
1271
|
+
setupOnce() {
|
|
1272
|
+
},
|
|
1273
|
+
createDialog: ({ options, screenshotIntegration, sendFeedback, shadow }) => {
|
|
1274
|
+
const shadowRoot = shadow;
|
|
1275
|
+
const userKey = options.useSentryUser;
|
|
1276
|
+
const user = getUser();
|
|
1277
|
+
const el = DOCUMENT.createElement("div");
|
|
1278
|
+
const style = createDialogStyles(options.styleNonce);
|
|
1279
|
+
let originalOverflow = "";
|
|
1280
|
+
const dialog = {
|
|
1281
|
+
get el() {
|
|
1282
|
+
return el;
|
|
1283
|
+
},
|
|
1284
|
+
appendToDom() {
|
|
1285
|
+
if (!shadowRoot.contains(style) && !shadowRoot.contains(el)) {
|
|
1286
|
+
shadowRoot.appendChild(style);
|
|
1287
|
+
shadowRoot.appendChild(el);
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
removeFromDom() {
|
|
1291
|
+
el.remove();
|
|
1292
|
+
style.remove();
|
|
1293
|
+
DOCUMENT.body.style.overflow = originalOverflow;
|
|
1294
|
+
},
|
|
1295
|
+
open() {
|
|
1296
|
+
renderContent(true);
|
|
1297
|
+
options.onFormOpen?.();
|
|
1298
|
+
core.getClient()?.emit("openFeedbackWidget");
|
|
1299
|
+
originalOverflow = DOCUMENT.body.style.overflow;
|
|
1300
|
+
DOCUMENT.body.style.overflow = "hidden";
|
|
1301
|
+
},
|
|
1302
|
+
close() {
|
|
1303
|
+
renderContent(false);
|
|
1304
|
+
DOCUMENT.body.style.overflow = originalOverflow;
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
const screenshotInput = screenshotIntegration?.createInput({ h: y$1, hooks, dialog, options });
|
|
1308
|
+
const renderContent = (open) => {
|
|
1309
|
+
B$1(
|
|
1310
|
+
/* @__PURE__ */ y$1(
|
|
1311
|
+
Dialog,
|
|
1312
|
+
{
|
|
1313
|
+
options,
|
|
1314
|
+
screenshotInput,
|
|
1315
|
+
showName: options.showName || options.isNameRequired,
|
|
1316
|
+
showEmail: options.showEmail || options.isEmailRequired,
|
|
1317
|
+
defaultName: String(userKey && user?.[userKey.name] || ""),
|
|
1318
|
+
defaultEmail: String(userKey && user?.[userKey.email] || ""),
|
|
1319
|
+
onFormClose: () => {
|
|
1320
|
+
renderContent(false);
|
|
1321
|
+
options.onFormClose?.();
|
|
1322
|
+
},
|
|
1323
|
+
onSubmit: sendFeedback,
|
|
1324
|
+
onSubmitSuccess: (data, eventId) => {
|
|
1325
|
+
renderContent(false);
|
|
1326
|
+
options.onSubmitSuccess?.(data, eventId);
|
|
1327
|
+
},
|
|
1328
|
+
onSubmitError: (error) => {
|
|
1329
|
+
options.onSubmitError?.(error);
|
|
1330
|
+
},
|
|
1331
|
+
onFormSubmitted: () => {
|
|
1332
|
+
options.onFormSubmitted?.();
|
|
1333
|
+
},
|
|
1334
|
+
open
|
|
1335
|
+
}
|
|
1336
|
+
),
|
|
1337
|
+
el
|
|
1338
|
+
);
|
|
1339
|
+
};
|
|
1340
|
+
return dialog;
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
});
|
|
1344
|
+
|
|
1345
|
+
function IconCloseFactory({
|
|
1346
|
+
h
|
|
1347
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1348
|
+
}) {
|
|
1349
|
+
return function IconClose() {
|
|
1350
|
+
return /* @__PURE__ */ h("svg", { "data-test-id": "icon-close", viewBox: "0 0 16 16", fill: "#2B2233", height: "25px", width: "25px" }, /* @__PURE__ */ h("circle", { r: "7", cx: "8", cy: "8", fill: "white" }), /* @__PURE__ */ h(
|
|
1351
|
+
"path",
|
|
1352
|
+
{
|
|
1353
|
+
strokeWidth: "1.5",
|
|
1354
|
+
d: "M8,16a8,8,0,1,1,8-8A8,8,0,0,1,8,16ZM8,1.53A6.47,6.47,0,1,0,14.47,8,6.47,6.47,0,0,0,8,1.53Z"
|
|
1355
|
+
}
|
|
1356
|
+
), /* @__PURE__ */ h(
|
|
1357
|
+
"path",
|
|
1358
|
+
{
|
|
1359
|
+
strokeWidth: "1.5",
|
|
1360
|
+
d: "M5.34,11.41a.71.71,0,0,1-.53-.22.74.74,0,0,1,0-1.06l5.32-5.32a.75.75,0,0,1,1.06,1.06L5.87,11.19A.74.74,0,0,1,5.34,11.41Z"
|
|
1361
|
+
}
|
|
1362
|
+
), /* @__PURE__ */ h(
|
|
1363
|
+
"path",
|
|
1364
|
+
{
|
|
1365
|
+
strokeWidth: "1.5",
|
|
1366
|
+
d: "M10.66,11.41a.74.74,0,0,1-.53-.22L4.81,5.87A.75.75,0,0,1,5.87,4.81l5.32,5.32a.74.74,0,0,1,0,1.06A.71.71,0,0,1,10.66,11.41Z"
|
|
1367
|
+
}
|
|
1368
|
+
));
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
function createScreenshotInputStyles(styleNonce) {
|
|
1373
|
+
const style = DOCUMENT.createElement("style");
|
|
1374
|
+
const surface200 = "#1A141F";
|
|
1375
|
+
const gray100 = "#302735";
|
|
1376
|
+
style.textContent = `
|
|
1377
|
+
.editor {
|
|
1378
|
+
display: flex;
|
|
1379
|
+
flex-grow: 1;
|
|
1380
|
+
flex-direction: column;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
.editor__image-container {
|
|
1384
|
+
justify-items: center;
|
|
1385
|
+
padding: 15px;
|
|
1386
|
+
position: relative;
|
|
1387
|
+
height: 100%;
|
|
1388
|
+
border-radius: var(--menu-border-radius, 6px);
|
|
1389
|
+
|
|
1390
|
+
background-color: ${surface200};
|
|
1391
|
+
background-image: repeating-linear-gradient(
|
|
1392
|
+
-145deg,
|
|
1393
|
+
transparent,
|
|
1394
|
+
transparent 8px,
|
|
1395
|
+
${surface200} 8px,
|
|
1396
|
+
${surface200} 11px
|
|
1397
|
+
),
|
|
1398
|
+
repeating-linear-gradient(
|
|
1399
|
+
-45deg,
|
|
1400
|
+
transparent,
|
|
1401
|
+
transparent 15px,
|
|
1402
|
+
${gray100} 15px,
|
|
1403
|
+
${gray100} 16px
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
.editor__canvas-container {
|
|
1408
|
+
width: 100%;
|
|
1409
|
+
height: 100%;
|
|
1410
|
+
position: relative;
|
|
1411
|
+
display: flex;
|
|
1412
|
+
align-items: center;
|
|
1413
|
+
justify-content: center;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
.editor__canvas-container > * {
|
|
1417
|
+
object-fit: contain;
|
|
1418
|
+
position: absolute;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
.editor__tool-container {
|
|
1422
|
+
padding-top: 8px;
|
|
1423
|
+
display: flex;
|
|
1424
|
+
justify-content: center;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
.editor__tool-bar {
|
|
1428
|
+
display: flex;
|
|
1429
|
+
gap: 8px;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
.editor__tool {
|
|
1433
|
+
display: flex;
|
|
1434
|
+
padding: 8px 12px;
|
|
1435
|
+
justify-content: center;
|
|
1436
|
+
align-items: center;
|
|
1437
|
+
border: var(--button-border, var(--border));
|
|
1438
|
+
border-radius: var(--button-border-radius, 6px);
|
|
1439
|
+
background: var(--button-background, var(--background));
|
|
1440
|
+
color: var(--button-color, var(--foreground));
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
.editor__tool--active {
|
|
1444
|
+
background: var(--button-primary-background, var(--accent-background));
|
|
1445
|
+
color: var(--button-primary-color, var(--accent-foreground));
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
.editor__rect {
|
|
1449
|
+
position: absolute;
|
|
1450
|
+
z-index: 2;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
.editor__rect button {
|
|
1454
|
+
opacity: 0;
|
|
1455
|
+
position: absolute;
|
|
1456
|
+
top: -12px;
|
|
1457
|
+
right: -12px;
|
|
1458
|
+
cursor: pointer;
|
|
1459
|
+
padding: 0;
|
|
1460
|
+
z-index: 3;
|
|
1461
|
+
border: none;
|
|
1462
|
+
background: none;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
.editor__rect:hover button {
|
|
1466
|
+
opacity: 1;
|
|
1467
|
+
}
|
|
1468
|
+
`;
|
|
1469
|
+
if (styleNonce) {
|
|
1470
|
+
style.setAttribute("nonce", styleNonce);
|
|
1471
|
+
}
|
|
1472
|
+
return style;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
function ToolbarFactory({
|
|
1476
|
+
h
|
|
1477
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1478
|
+
}) {
|
|
1479
|
+
return function Toolbar({
|
|
1480
|
+
action,
|
|
1481
|
+
setAction,
|
|
1482
|
+
options
|
|
1483
|
+
}) {
|
|
1484
|
+
return /* @__PURE__ */ h("div", { class: "editor__tool-container" }, /* @__PURE__ */ h("div", { class: "editor__tool-bar" }, /* @__PURE__ */ h(
|
|
1485
|
+
"button",
|
|
1486
|
+
{
|
|
1487
|
+
type: "button",
|
|
1488
|
+
class: `editor__tool ${action === "highlight" ? "editor__tool--active" : ""}`,
|
|
1489
|
+
onClick: () => {
|
|
1490
|
+
setAction(action === "highlight" ? "" : "highlight");
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
options.highlightToolText
|
|
1494
|
+
), /* @__PURE__ */ h(
|
|
1495
|
+
"button",
|
|
1496
|
+
{
|
|
1497
|
+
type: "button",
|
|
1498
|
+
class: `editor__tool ${action === "hide" ? "editor__tool--active" : ""}`,
|
|
1499
|
+
onClick: () => {
|
|
1500
|
+
setAction(action === "hide" ? "" : "hide");
|
|
1501
|
+
}
|
|
1502
|
+
},
|
|
1503
|
+
options.hideToolText
|
|
1504
|
+
)));
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
function useTakeScreenshotFactory({ hooks }) {
|
|
1509
|
+
function useDpi() {
|
|
1510
|
+
const [dpi, setDpi] = hooks.useState(WINDOW.devicePixelRatio ?? 1);
|
|
1511
|
+
hooks.useEffect(() => {
|
|
1512
|
+
const onChange = () => {
|
|
1513
|
+
setDpi(WINDOW.devicePixelRatio);
|
|
1514
|
+
};
|
|
1515
|
+
const media = matchMedia(`(resolution: ${WINDOW.devicePixelRatio}dppx)`);
|
|
1516
|
+
media.addEventListener("change", onChange);
|
|
1517
|
+
return () => {
|
|
1518
|
+
media.removeEventListener("change", onChange);
|
|
1519
|
+
};
|
|
1520
|
+
}, []);
|
|
1521
|
+
return dpi;
|
|
1522
|
+
}
|
|
1523
|
+
return function useTakeScreenshot({ onBeforeScreenshot, onScreenshot, onAfterScreenshot, onError }) {
|
|
1524
|
+
const dpi = useDpi();
|
|
1525
|
+
hooks.useEffect(() => {
|
|
1526
|
+
const takeScreenshot = async () => {
|
|
1527
|
+
onBeforeScreenshot();
|
|
1528
|
+
const stream = await NAVIGATOR.mediaDevices.getDisplayMedia({
|
|
1529
|
+
video: {
|
|
1530
|
+
width: WINDOW.innerWidth * dpi,
|
|
1531
|
+
height: WINDOW.innerHeight * dpi
|
|
1532
|
+
},
|
|
1533
|
+
audio: false,
|
|
1534
|
+
// @ts-expect-error experimental flags: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#prefercurrenttab
|
|
1535
|
+
monitorTypeSurfaces: "exclude",
|
|
1536
|
+
preferCurrentTab: true,
|
|
1537
|
+
selfBrowserSurface: "include",
|
|
1538
|
+
surfaceSwitching: "exclude"
|
|
1539
|
+
});
|
|
1540
|
+
const video = DOCUMENT.createElement("video");
|
|
1541
|
+
await new Promise((resolve, reject) => {
|
|
1542
|
+
video.srcObject = stream;
|
|
1543
|
+
video.onloadedmetadata = () => {
|
|
1544
|
+
onScreenshot(video, dpi);
|
|
1545
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
1546
|
+
resolve();
|
|
1547
|
+
};
|
|
1548
|
+
video.play().catch(reject);
|
|
1549
|
+
});
|
|
1550
|
+
onAfterScreenshot();
|
|
1551
|
+
};
|
|
1552
|
+
takeScreenshot().catch(onError);
|
|
1553
|
+
}, []);
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
function drawRect(command, ctx, color) {
|
|
1558
|
+
switch (command.type) {
|
|
1559
|
+
case "highlight": {
|
|
1560
|
+
ctx.shadowColor = "rgba(0, 0, 0, 0.7)";
|
|
1561
|
+
ctx.shadowBlur = 50;
|
|
1562
|
+
ctx.fillStyle = color;
|
|
1563
|
+
ctx.fillRect(command.x - 1, command.y - 1, command.w + 2, command.h + 2);
|
|
1564
|
+
ctx.clearRect(command.x, command.y, command.w, command.h);
|
|
1565
|
+
break;
|
|
1566
|
+
}
|
|
1567
|
+
case "hide":
|
|
1568
|
+
ctx.fillStyle = "rgb(0, 0, 0)";
|
|
1569
|
+
ctx.fillRect(command.x, command.y, command.w, command.h);
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
function with2dContext(canvas, options, callback) {
|
|
1574
|
+
if (!canvas) {
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
const ctx = canvas.getContext("2d", options);
|
|
1578
|
+
if (!ctx) {
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
callback(canvas, ctx);
|
|
1582
|
+
}
|
|
1583
|
+
function paintImage(maybeDest, source) {
|
|
1584
|
+
with2dContext(maybeDest, { alpha: true }, (destCanvas, destCtx) => {
|
|
1585
|
+
destCtx.drawImage(source, 0, 0, source.width, source.height, 0, 0, destCanvas.width, destCanvas.height);
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
function paintForeground(maybeCanvas, strokeColor, drawCommands) {
|
|
1589
|
+
with2dContext(maybeCanvas, { alpha: true }, (canvas, ctx) => {
|
|
1590
|
+
if (drawCommands.length) {
|
|
1591
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.25)";
|
|
1592
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
1593
|
+
}
|
|
1594
|
+
drawCommands.forEach((command) => {
|
|
1595
|
+
drawRect(command, ctx, strokeColor);
|
|
1596
|
+
});
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
function ScreenshotEditorFactory({
|
|
1600
|
+
h: h2,
|
|
1601
|
+
hooks,
|
|
1602
|
+
outputBuffer,
|
|
1603
|
+
dialog,
|
|
1604
|
+
options
|
|
1605
|
+
}) {
|
|
1606
|
+
const useTakeScreenshot = useTakeScreenshotFactory({ hooks });
|
|
1607
|
+
const Toolbar = ToolbarFactory({ h: h2 });
|
|
1608
|
+
const IconClose = IconCloseFactory({ h: h2 });
|
|
1609
|
+
const editorStyleInnerText = { __html: createScreenshotInputStyles(options.styleNonce).innerText };
|
|
1610
|
+
const dialogStyle = dialog.el.style;
|
|
1611
|
+
const ScreenshotEditor = ({ screenshot }) => {
|
|
1612
|
+
const [action, setAction] = hooks.useState("highlight");
|
|
1613
|
+
const [drawCommands, setDrawCommands] = hooks.useState([]);
|
|
1614
|
+
const measurementRef = hooks.useRef(null);
|
|
1615
|
+
const backgroundRef = hooks.useRef(null);
|
|
1616
|
+
const foregroundRef = hooks.useRef(null);
|
|
1617
|
+
const mouseRef = hooks.useRef(null);
|
|
1618
|
+
const [scaleFactor, setScaleFactor] = hooks.useState(1);
|
|
1619
|
+
const strokeColor = hooks.useMemo(() => {
|
|
1620
|
+
const sentryFeedback = DOCUMENT.getElementById(options.id);
|
|
1621
|
+
if (!sentryFeedback) {
|
|
1622
|
+
return "white";
|
|
1623
|
+
}
|
|
1624
|
+
const computedStyle = getComputedStyle(sentryFeedback);
|
|
1625
|
+
return computedStyle.getPropertyValue("--button-primary-background") || computedStyle.getPropertyValue("--accent-background");
|
|
1626
|
+
}, [options.id]);
|
|
1627
|
+
hooks.useLayoutEffect(() => {
|
|
1628
|
+
const handleResize = () => {
|
|
1629
|
+
const measurementDiv = measurementRef.current;
|
|
1630
|
+
if (!measurementDiv) {
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
with2dContext(screenshot.canvas, { alpha: false }, (canvas) => {
|
|
1634
|
+
const scale = Math.min(
|
|
1635
|
+
measurementDiv.clientWidth / canvas.width,
|
|
1636
|
+
measurementDiv.clientHeight / canvas.height
|
|
1637
|
+
);
|
|
1638
|
+
setScaleFactor(scale);
|
|
1639
|
+
});
|
|
1640
|
+
if (measurementDiv.clientHeight === 0 || measurementDiv.clientWidth === 0) {
|
|
1641
|
+
setTimeout(handleResize, 0);
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
handleResize();
|
|
1645
|
+
WINDOW.addEventListener("resize", handleResize);
|
|
1646
|
+
return () => {
|
|
1647
|
+
WINDOW.removeEventListener("resize", handleResize);
|
|
1648
|
+
};
|
|
1649
|
+
}, [screenshot]);
|
|
1650
|
+
const setCanvasSize = hooks.useCallback(
|
|
1651
|
+
(maybeCanvas, scale) => {
|
|
1652
|
+
with2dContext(maybeCanvas, { alpha: true }, (canvas, ctx) => {
|
|
1653
|
+
ctx.scale(scale, scale);
|
|
1654
|
+
canvas.width = screenshot.canvas.width;
|
|
1655
|
+
canvas.height = screenshot.canvas.height;
|
|
1656
|
+
});
|
|
1657
|
+
},
|
|
1658
|
+
[screenshot]
|
|
1659
|
+
);
|
|
1660
|
+
hooks.useEffect(() => {
|
|
1661
|
+
setCanvasSize(backgroundRef.current, screenshot.dpi);
|
|
1662
|
+
paintImage(backgroundRef.current, screenshot.canvas);
|
|
1663
|
+
}, [screenshot]);
|
|
1664
|
+
hooks.useEffect(() => {
|
|
1665
|
+
setCanvasSize(foregroundRef.current, screenshot.dpi);
|
|
1666
|
+
with2dContext(foregroundRef.current, { alpha: true }, (canvas, ctx) => {
|
|
1667
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1668
|
+
});
|
|
1669
|
+
paintForeground(foregroundRef.current, strokeColor, drawCommands);
|
|
1670
|
+
}, [drawCommands, strokeColor]);
|
|
1671
|
+
hooks.useEffect(() => {
|
|
1672
|
+
setCanvasSize(outputBuffer, screenshot.dpi);
|
|
1673
|
+
paintImage(outputBuffer, screenshot.canvas);
|
|
1674
|
+
with2dContext(DOCUMENT.createElement("canvas"), { alpha: true }, (foreground, ctx) => {
|
|
1675
|
+
ctx.scale(screenshot.dpi, screenshot.dpi);
|
|
1676
|
+
foreground.width = screenshot.canvas.width;
|
|
1677
|
+
foreground.height = screenshot.canvas.height;
|
|
1678
|
+
paintForeground(foreground, strokeColor, drawCommands);
|
|
1679
|
+
paintImage(outputBuffer, foreground);
|
|
1680
|
+
});
|
|
1681
|
+
}, [drawCommands, screenshot, strokeColor]);
|
|
1682
|
+
const handleMouseDown = (e) => {
|
|
1683
|
+
if (!action || !mouseRef.current) {
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
const boundingRect = mouseRef.current.getBoundingClientRect();
|
|
1687
|
+
const startingPoint = {
|
|
1688
|
+
type: action,
|
|
1689
|
+
x: e.offsetX / scaleFactor,
|
|
1690
|
+
y: e.offsetY / scaleFactor};
|
|
1691
|
+
const getDrawCommand = (startingPoint2, e2) => {
|
|
1692
|
+
const x = (e2.clientX - boundingRect.x) / scaleFactor;
|
|
1693
|
+
const y = (e2.clientY - boundingRect.y) / scaleFactor;
|
|
1694
|
+
return {
|
|
1695
|
+
type: startingPoint2.type,
|
|
1696
|
+
x: Math.min(startingPoint2.x, x),
|
|
1697
|
+
y: Math.min(startingPoint2.y, y),
|
|
1698
|
+
w: Math.abs(x - startingPoint2.x),
|
|
1699
|
+
h: Math.abs(y - startingPoint2.y)
|
|
1700
|
+
};
|
|
1701
|
+
};
|
|
1702
|
+
const handleMouseMove = (e2) => {
|
|
1703
|
+
with2dContext(foregroundRef.current, { alpha: true }, (canvas, ctx) => {
|
|
1704
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1705
|
+
});
|
|
1706
|
+
paintForeground(foregroundRef.current, strokeColor, [...drawCommands, getDrawCommand(startingPoint, e2)]);
|
|
1707
|
+
};
|
|
1708
|
+
const handleMouseUp = (e2) => {
|
|
1709
|
+
const drawCommand = getDrawCommand(startingPoint, e2);
|
|
1710
|
+
if (drawCommand.w * scaleFactor >= 1 && drawCommand.h * scaleFactor >= 1) {
|
|
1711
|
+
setDrawCommands((prev) => [...prev, drawCommand]);
|
|
1712
|
+
}
|
|
1713
|
+
DOCUMENT.removeEventListener("mousemove", handleMouseMove);
|
|
1714
|
+
DOCUMENT.removeEventListener("mouseup", handleMouseUp);
|
|
1715
|
+
};
|
|
1716
|
+
DOCUMENT.addEventListener("mousemove", handleMouseMove);
|
|
1717
|
+
DOCUMENT.addEventListener("mouseup", handleMouseUp);
|
|
1718
|
+
};
|
|
1719
|
+
const deleteRect = hooks.useCallback((index) => {
|
|
1720
|
+
return (e) => {
|
|
1721
|
+
e.preventDefault();
|
|
1722
|
+
e.stopPropagation();
|
|
1723
|
+
setDrawCommands((prev) => {
|
|
1724
|
+
const updatedRects = [...prev];
|
|
1725
|
+
updatedRects.splice(index, 1);
|
|
1726
|
+
return updatedRects;
|
|
1727
|
+
});
|
|
1728
|
+
};
|
|
1729
|
+
}, []);
|
|
1730
|
+
const dimensions = {
|
|
1731
|
+
width: `${screenshot.canvas.width * scaleFactor}px`,
|
|
1732
|
+
height: `${screenshot.canvas.height * scaleFactor}px`
|
|
1733
|
+
};
|
|
1734
|
+
const handleStopPropagation = (e) => {
|
|
1735
|
+
e.stopPropagation();
|
|
1736
|
+
};
|
|
1737
|
+
return /* @__PURE__ */ h2("div", { class: "editor" }, /* @__PURE__ */ h2("style", { nonce: options.styleNonce, dangerouslySetInnerHTML: editorStyleInnerText }), /* @__PURE__ */ h2("div", { class: "editor__image-container" }, /* @__PURE__ */ h2("div", { class: "editor__canvas-container", ref: measurementRef }, /* @__PURE__ */ h2("canvas", { ref: backgroundRef, id: "background", style: dimensions }), /* @__PURE__ */ h2("canvas", { ref: foregroundRef, id: "foreground", style: dimensions }), /* @__PURE__ */ h2("div", { ref: mouseRef, onMouseDown: handleMouseDown, style: dimensions }, drawCommands.map((rect, index) => /* @__PURE__ */ h2(
|
|
1738
|
+
"div",
|
|
1739
|
+
{
|
|
1740
|
+
key: index,
|
|
1741
|
+
class: "editor__rect",
|
|
1742
|
+
style: {
|
|
1743
|
+
top: `${rect.y * scaleFactor}px`,
|
|
1744
|
+
left: `${rect.x * scaleFactor}px`,
|
|
1745
|
+
width: `${rect.w * scaleFactor}px`,
|
|
1746
|
+
height: `${rect.h * scaleFactor}px`
|
|
1747
|
+
}
|
|
1748
|
+
},
|
|
1749
|
+
/* @__PURE__ */ h2(
|
|
1750
|
+
"button",
|
|
1751
|
+
{
|
|
1752
|
+
"aria-label": options.removeHighlightText,
|
|
1753
|
+
onClick: deleteRect(index),
|
|
1754
|
+
onMouseDown: handleStopPropagation,
|
|
1755
|
+
onMouseUp: handleStopPropagation,
|
|
1756
|
+
type: "button"
|
|
1757
|
+
},
|
|
1758
|
+
/* @__PURE__ */ h2(IconClose, null)
|
|
1759
|
+
)
|
|
1760
|
+
))))), /* @__PURE__ */ h2(Toolbar, { options, action, setAction }));
|
|
1761
|
+
};
|
|
1762
|
+
return function Wrapper({ onError }) {
|
|
1763
|
+
const [screenshot, setScreenshot] = hooks.useState();
|
|
1764
|
+
useTakeScreenshot({
|
|
1765
|
+
onBeforeScreenshot: hooks.useCallback(() => {
|
|
1766
|
+
dialogStyle.display = "none";
|
|
1767
|
+
}, []),
|
|
1768
|
+
onScreenshot: hooks.useCallback((screenshotVideo, dpi) => {
|
|
1769
|
+
with2dContext(DOCUMENT.createElement("canvas"), { alpha: false }, (canvas, ctx) => {
|
|
1770
|
+
ctx.scale(dpi, dpi);
|
|
1771
|
+
canvas.width = screenshotVideo.videoWidth;
|
|
1772
|
+
canvas.height = screenshotVideo.videoHeight;
|
|
1773
|
+
ctx.drawImage(screenshotVideo, 0, 0, canvas.width, canvas.height);
|
|
1774
|
+
setScreenshot({ canvas, dpi });
|
|
1775
|
+
});
|
|
1776
|
+
outputBuffer.width = screenshotVideo.videoWidth;
|
|
1777
|
+
outputBuffer.height = screenshotVideo.videoHeight;
|
|
1778
|
+
}, []),
|
|
1779
|
+
onAfterScreenshot: hooks.useCallback(() => {
|
|
1780
|
+
dialogStyle.display = "block";
|
|
1781
|
+
}, []),
|
|
1782
|
+
onError: hooks.useCallback((error) => {
|
|
1783
|
+
dialogStyle.display = "block";
|
|
1784
|
+
onError(error);
|
|
1785
|
+
}, [])
|
|
1786
|
+
});
|
|
1787
|
+
if (screenshot) {
|
|
1788
|
+
return /* @__PURE__ */ h2(ScreenshotEditor, { screenshot });
|
|
1789
|
+
}
|
|
1790
|
+
return /* @__PURE__ */ h2("div", null);
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
const feedbackScreenshotIntegration = (() => {
|
|
1795
|
+
return {
|
|
1796
|
+
name: "FeedbackScreenshot",
|
|
1797
|
+
setupOnce() {
|
|
1798
|
+
},
|
|
1799
|
+
createInput: ({ h, hooks, dialog, options }) => {
|
|
1800
|
+
const outputBuffer = DOCUMENT.createElement("canvas");
|
|
1801
|
+
return {
|
|
1802
|
+
input: ScreenshotEditorFactory({
|
|
1803
|
+
h,
|
|
1804
|
+
hooks,
|
|
1805
|
+
outputBuffer,
|
|
1806
|
+
dialog,
|
|
1807
|
+
options
|
|
1808
|
+
}),
|
|
1809
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1810
|
+
value: async () => {
|
|
1811
|
+
const blob = await new Promise((resolve) => {
|
|
1812
|
+
outputBuffer.toBlob(resolve, "image/png");
|
|
1813
|
+
});
|
|
1814
|
+
if (blob) {
|
|
1815
|
+
const data = new Uint8Array(await blob.arrayBuffer());
|
|
1816
|
+
const attachment = {
|
|
1817
|
+
data,
|
|
1818
|
+
filename: "screenshot.png",
|
|
1819
|
+
contentType: "application/png"
|
|
1820
|
+
// attachmentType?: string;
|
|
1821
|
+
};
|
|
1822
|
+
return attachment;
|
|
1823
|
+
}
|
|
1824
|
+
return void 0;
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
});
|
|
1830
|
+
|
|
1831
|
+
exports.buildFeedbackIntegration = buildFeedbackIntegration;
|
|
1832
|
+
exports.feedbackModalIntegration = feedbackModalIntegration;
|
|
1833
|
+
exports.feedbackScreenshotIntegration = feedbackScreenshotIntegration;
|
|
1834
|
+
exports.getFeedback = getFeedback;
|
|
1835
|
+
exports.sendFeedback = sendFeedback;
|
|
1836
|
+
//# sourceMappingURL=index.js.map
|