From 45d00eb047f4edbcad71268ce81be775fd0bbcb5 Mon Sep 17 00:00:00 2001 From: William Chong Date: Fri, 15 Nov 2024 16:11:36 +0800 Subject: [PATCH] Add user id and class id logging in sentry --- web/app.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/web/app.js b/web/app.js index 8ef838a5c46cd..92ab547291d99 100644 --- a/web/app.js +++ b/web/app.js @@ -3153,24 +3153,36 @@ function webViewerPostMessage(evt) { } else { ({ action, data } = evt.data); } - const filename = data.name ? `${data.name}.pdf` : "liker-land_ebook.pdf"; + const { data: fileData, name, classId, nftId, wallet } = data; + const filename = name ? `${name}.pdf` : "liker-land_ebook.pdf"; const url = `https://liker.land/${filename}`; switch (action) { case "openBase64File": PDFViewerApplication.open({ - data: atob(data.data), + data: atob(fileData), url, filename, }); break; case "openArrayBufferFile": PDFViewerApplication.open({ - data: new Uint8Array(data.data), + data: new Uint8Array(fileData), url, filename, }); break; } + if (window.Sentry) { + if (wallet) { + window.Sentry.setUser({ id: wallet }); + } + if (classId) { + window.Sentry.setTag("classId", classId); + } + if (nftId) { + window.Sentry.setTag("nftId", nftId); + } + } } catch (ex) { console.error(`webViewerPostMessage: ${ex}`); }