Skip to content

Commit ff9a786

Browse files
committed
Try to fix loading of Feedback
1 parent a9fbdb9 commit ff9a786

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

frontend/src/entrypoints/__tests__/sentryBrowser.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ describe("sentryBrowser entrypoint", () => {
3535
);
3636
});
3737

38+
it("binds immediately when the module loads after DOMContentLoaded at interactive readyState", async () => {
39+
vi.spyOn(document, "readyState", "get").mockReturnValue("interactive");
40+
document.body.innerHTML = `
41+
<footer>
42+
<a href="mailto:support@example.com" data-sentry-feedback-link="">Contact Support</a>
43+
</footer>
44+
`;
45+
46+
await import("../sentryBrowser");
47+
48+
expect(attachSentryFeedbackTrigger).toHaveBeenCalledTimes(1);
49+
expect(attachSentryFeedbackTrigger).toHaveBeenCalledWith(
50+
document.body,
51+
{
52+
allowScreenshot: true,
53+
surface: "global-footer",
54+
},
55+
);
56+
});
57+
3858
it("does not bind the shared footer support control on blocked pages", async () => {
3959
document.head.innerHTML = '<meta name="sentry-capture-disabled" content="true">';
4060
document.body.innerHTML = `

frontend/src/entrypoints/sentryBrowser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function bindGlobalFooterFeedback(): void {
2323
});
2424
}
2525

26-
if (document.readyState === "complete") {
26+
if (document.readyState !== "loading") {
2727
bindGlobalFooterFeedback();
2828
} else {
2929
document.addEventListener("DOMContentLoaded", () => {

0 commit comments

Comments
 (0)