From a65c1959ead1bdf73ac0151cc2e2704a29b1213e Mon Sep 17 00:00:00 2001 From: "kiran.kunigiri" Date: Mon, 24 Jun 2024 02:10:58 -0700 Subject: [PATCH 1/3] Added session downloader for chrome extension - The session list now has a button to download sessions as .json files for use with rrweb-player - Improved styling for the delete and download buttons --- .../web-extension/src/pages/SessionList.tsx | 52 ++++++++++++------- packages/web-extension/src/utils/storage.ts | 19 +++++++ 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/packages/web-extension/src/pages/SessionList.tsx b/packages/web-extension/src/pages/SessionList.tsx index b4b5c27cb2..d285932029 100644 --- a/packages/web-extension/src/pages/SessionList.tsx +++ b/packages/web-extension/src/pages/SessionList.tsx @@ -31,7 +31,7 @@ import { VscTriangleDown, VscTriangleUp } from 'react-icons/vsc'; import { useNavigate } from 'react-router-dom'; import { type Session, EventName } from '~/types'; import Channel from '~/utils/channel'; -import { deleteSessions, getAllSessions } from '~/utils/storage'; +import { deleteSessions, getAllSessions, downloadSessions } from '~/utils/storage'; import { FiChevronLeft, FiChevronRight, @@ -292,24 +292,38 @@ export function SessionList() { ))} {Object.keys(rowSelection).length > 0 && ( - + + + + )} diff --git a/packages/web-extension/src/utils/storage.ts b/packages/web-extension/src/utils/storage.ts index cfd2f1ee18..766ba86fba 100644 --- a/packages/web-extension/src/utils/storage.ts +++ b/packages/web-extension/src/utils/storage.ts @@ -88,3 +88,22 @@ export async function deleteSessions(ids: string[]) { return Promise.all([eventTransition.done, sessionTransition.done]); }); } + +export async function downloadSessions(ids: string[]) { + for (const sessionId of ids) { + const events = await getEvents(sessionId); + const session = await getSession(sessionId); + const blob = new Blob([JSON.stringify({ session, events }, null, 2)], { + type: 'application/json', + }); + + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = `${session.name}.json`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + } +} From e68945318330de9fe3347f4de695783651b82aa4 Mon Sep 17 00:00:00 2001 From: Justin Halsall Date: Fri, 2 Aug 2024 10:09:00 +0200 Subject: [PATCH 2/3] Create wicked-dolphins-tie.md --- .changeset/wicked-dolphins-tie.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wicked-dolphins-tie.md diff --git a/.changeset/wicked-dolphins-tie.md b/.changeset/wicked-dolphins-tie.md new file mode 100644 index 0000000000..6d83ee114e --- /dev/null +++ b/.changeset/wicked-dolphins-tie.md @@ -0,0 +1,5 @@ +--- +"@rrweb/web-extension": patch +--- + +Added session downloader for chrome extension From f23ccc5156ed17a55537fa151af20ace39833d51 Mon Sep 17 00:00:00 2001 From: Justin Halsall Date: Fri, 2 Aug 2024 10:10:17 +0200 Subject: [PATCH 3/3] Update wicked-dolphins-tie.md --- .changeset/wicked-dolphins-tie.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/wicked-dolphins-tie.md b/.changeset/wicked-dolphins-tie.md index 6d83ee114e..9726195671 100644 --- a/.changeset/wicked-dolphins-tie.md +++ b/.changeset/wicked-dolphins-tie.md @@ -1,5 +1,5 @@ --- -"@rrweb/web-extension": patch +"@rrweb/web-extension": minor --- Added session downloader for chrome extension