Skip to content

Commit 88be6b8

Browse files
feat(reactotron-app): add exports for timeline logs (#1533 by @denis-remitly)
[skip ci]
1 parent a4bbe6d commit 88be6b8

File tree

1 file changed

+28
-1
lines changed
  • apps/reactotron-app/src/renderer/pages/timeline

1 file changed

+28
-1
lines changed

apps/reactotron-app/src/renderer/pages/timeline/index.tsx

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { useCallback, useContext, useMemo } from "react"
22
import { clipboard, shell } from "electron"
33
import fs from "fs"
4+
import os from "os"
5+
import path from "path"
46
import debounce from "lodash.debounce"
57
import {
68
Header,
@@ -12,7 +14,14 @@ import {
1214
TimelineContext,
1315
RandomJoke,
1416
} from "reactotron-core-ui"
15-
import { MdSearch, MdDeleteSweep, MdFilterList, MdSwapVert, MdReorder } from "react-icons/md"
17+
import {
18+
MdSearch,
19+
MdDeleteSweep,
20+
MdFilterList,
21+
MdSwapVert,
22+
MdReorder,
23+
MdDownload,
24+
} from "react-icons/md"
1625
import { FaTimes } from "react-icons/fa"
1726
import styled from "styled-components"
1827

@@ -110,6 +119,17 @@ function Timeline() {
110119
shell.openExternal("https://docs.infinite.red/reactotron/quick-start/react-native/")
111120
}
112121

122+
function downloadLog() {
123+
const homeDir = os.homedir()
124+
const downloadDir = path.join(homeDir, "Downloads")
125+
fs.writeFileSync(
126+
path.resolve(downloadDir, `timeline-log-${Date.now()}.json`),
127+
JSON.stringify(commands || []),
128+
"utf8"
129+
)
130+
console.log(`Exported timeline log to ${downloadDir}`)
131+
}
132+
113133
const { searchString, handleInputChange } = useDebouncedSearchInput(search, setSearch, 300)
114134

115135
return (
@@ -118,6 +138,13 @@ function Timeline() {
118138
title="Timeline"
119139
isDraggable
120140
actions={[
141+
{
142+
tip: "Export Log",
143+
icon: MdDownload,
144+
onClick: () => {
145+
downloadLog()
146+
},
147+
},
121148
{
122149
tip: "Search",
123150
icon: MdSearch,

0 commit comments

Comments
 (0)