Skip to content

Commit 8cc1c80

Browse files
committed
feat: the example project provides a button to download all the events as json - useful for debugging.
1 parent 859acdb commit 8cc1c80

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

apps/browser-example/src/components/EventList.tsx

+20-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,21 @@ export function EventList({ events }: { events: any[] }) {
3636
}
3737
}, [events])
3838

39+
function saveEvents() {
40+
const blob = new Blob([JSON.stringify(events, null, 2)], {
41+
type: "application/json",
42+
})
43+
const url = URL.createObjectURL(blob)
44+
const a = document.createElement("a")
45+
a.href = url
46+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-")
47+
a.download = `events-${timestamp}.json`
48+
a.click()
49+
}
50+
3951
return (
4052
<div className="card my-2">
41-
<div className="card-header">
53+
<div className="card-header d-flex gap-2">
4254
<div className="dropdown">
4355
<button
4456
type="button"
@@ -49,6 +61,13 @@ export function EventList({ events }: { events: any[] }) {
4961
>
5062
Filter
5163
</button>
64+
<button
65+
type="button"
66+
className="btn btn-secondary"
67+
onClick={() => saveEvents()}
68+
>
69+
Save Events to File
70+
</button>
5271
<span className="mx-2">Event Count: {events.length}</span>
5372

5473
<form

0 commit comments

Comments
 (0)