From d6b3c12a0c23e31b0e5bbe7b72e3bde8acd56ff0 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 <75730405+AuroraHuang22@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:08:45 +0800 Subject: [PATCH] Add Sentry --- web/app.js | 10 ++++++---- web/viewer-snippet.html | 4 ++++ web/viewer.js | 8 ++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/web/app.js b/web/app.js index daaf0a54f28e8..8ef838a5c46cd 100644 --- a/web/app.js +++ b/web/app.js @@ -3153,19 +3153,21 @@ function webViewerPostMessage(evt) { } else { ({ action, data } = evt.data); } + const filename = data.name ? `${data.name}.pdf` : "liker-land_ebook.pdf"; + const url = `https://liker.land/${filename}`; switch (action) { case "openBase64File": PDFViewerApplication.open({ data: atob(data.data), - originalUrl: data.name, - filename: data.name ? `${data.name}.pdf` : "liker-land_ebook.pdf", + url, + filename, }); break; case "openArrayBufferFile": PDFViewerApplication.open({ data: new Uint8Array(data.data), - originalUrl: data.name, - filename: data.name ? `${data.name}.pdf` : "liker-land_ebook.pdf", + url, + filename, }); break; } diff --git a/web/viewer-snippet.html b/web/viewer-snippet.html index 3baf94773bfd4..0491041485eed 100644 --- a/web/viewer-snippet.html +++ b/web/viewer-snippet.html @@ -1,3 +1,7 @@ + diff --git a/web/viewer.js b/web/viewer.js index 6f2b1aec31a77..c49368e13ec7d 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -263,6 +263,14 @@ function webViewerLoad() { PDFViewerApplication.run(config); } +if (window.Sentry) { + window.Sentry.onLoad(function () { + window.Sentry.init({ + tracesSampleRate: 0.1, + }); + }); +} + // Block the "load" event until all pages are loaded, to ensure that printing // works in Firefox; see https://bugzilla.mozilla.org/show_bug.cgi?id=1618553 document.blockUnblockOnload?.(true);