Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Move extension settings to a Settings panel #1847

Merged
merged 5 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions developer-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"dependencies": {
"@emotion/react": "11.10.0",
"@mantine/core": "5.0.2",
"@mantine/hooks": "5.0.2",
"@mantine/core": "5.8.4",
"@mantine/hooks": "5.8.4",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-json-view": "1.21.3"
Expand Down
5 changes: 5 additions & 0 deletions developer-extension/src/panel/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export function App() {
<MantineProvider
theme={{
colorScheme,
globalStyles: () => ({
body: {
margin: 0,
},
}),
}}
withGlobalStyles
>
Expand Down
79 changes: 0 additions & 79 deletions developer-extension/src/panel/components/actionsBar.tsx

This file was deleted.

19 changes: 19 additions & 0 deletions developer-extension/src/panel/components/columns.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Grid, Space, Title } from '@mantine/core'
import React from 'react'

export function Columns({ children }: { children: React.ReactNode }) {
return <Grid>{children}</Grid>
}

function Column({ children, title }: { children: React.ReactNode; title: string }) {
return (
<Grid.Col md={4} sm={12}>
<Title order={3}>{title}</Title>
<Space h="sm" />
{children || '(empty)'}
<Space h="sm" />
</Grid.Col>
)
}

Columns.Column = Column
64 changes: 35 additions & 29 deletions developer-extension/src/panel/components/eventsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Badge, Button, Chip, Group, Space, Table, TextInput } from '@mantine/core'
import { Badge, Button, Chip, Group, Table, TextInput } from '@mantine/core'
import React from 'react'
import type { TelemetryEvent } from '../../../../packages/core/src/domain/telemetry'
import type { RumEvent } from '../../../../packages/rum-core/src/rumEvent.types'
import type { EventFilters, StoredEvent } from '../hooks/useEvents'
import { safeTruncate } from '../../../../packages/core/src/tools/utils'
import { flushEvents } from '../flushEvents'
import { Json } from './json'
import { TabBase } from './tabBase'

const RUM_EVENT_TYPE_COLOR = {
action: 'violet',
Expand All @@ -31,8 +33,8 @@ interface EventTabProps {

export function EventTab({ events, filters, onFiltered, clear }: EventTabProps) {
return (
events && (
<>
<TabBase
top={
<Group>
<Chip.Group
multiple
Expand All @@ -48,36 +50,40 @@ export function EventTab({ events, filters, onFiltered, clear }: EventTabProps)
style={{ flexGrow: 1 }}
onChange={(event) => onFiltered({ ...filters, query: event.currentTarget.value })}
/>

<Button color="violet" variant="light" onClick={flushEvents}>
Flush
</Button>
<Button color="red" variant="light" onClick={clear}>
Clear
</Button>
</Group>
<Space h="sm" />
<Table striped verticalSpacing="xs" fontSize="xs">
<tbody>
{events.map((event) => (
<tr key={event.id}>
<td width="20">{new Date(event.date).toLocaleTimeString()}</td>
<td width="20">
{isRumEvent(event) ? (
<Badge variant="outline" color={RUM_EVENT_TYPE_COLOR[event.type]}>
{event.type}
</Badge>
) : (
<Badge variant="dot" color={LOG_STATUS_COLOR[event.status]}>
{event.origin as string} {event.status as string}
</Badge>
)}
</td>
<td>
<Json src={event} collapsed={true} name={getRumEventDescription(event)} />
</td>
</tr>
))}
</tbody>
</Table>
</>
)
}
>
<Table striped verticalSpacing="xs" fontSize="xs">
<tbody>
{events.map((event) => (
<tr key={event.id}>
<td width="20">{new Date(event.date).toLocaleTimeString()}</td>
<td width="20">
{isRumEvent(event) ? (
<Badge variant="outline" color={RUM_EVENT_TYPE_COLOR[event.type]}>
{event.type}
</Badge>
) : (
<Badge variant="dot" color={LOG_STATUS_COLOR[event.status]}>
{event.origin as string} {event.status as string}
</Badge>
)}
</td>
<td>
<Json src={event} collapsed={true} name={getRumEventDescription(event)} />
</td>
</tr>
))}
</tbody>
</Table>
</TabBase>
)
}

Expand Down
139 changes: 67 additions & 72 deletions developer-extension/src/panel/components/infosTab.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Anchor, Divider, Grid, Group, Text, Title } from '@mantine/core'
import { Anchor, Divider, Group, Text } from '@mantine/core'
import type { ReactNode } from 'react'
import React from 'react'
import { useSdkInfos } from '../hooks/useSdkInfos'
import { Columns } from './columns'
import { Json } from './json'
import { TabBase } from './tabBase'

export function InfosTab() {
const infos = useSdkInfos()
Expand All @@ -12,75 +14,77 @@ export function InfosTab() {
const sessionId = infos.cookie?.id

return (
<Grid>
<Section name="Session">
{infos.cookie && (
<>
<Entry name="Id" value={infos.cookie.id} />
<Entry name="Logs" value={formatSessionType(infos.cookie.logs, 'Not tracked', 'Tracked')} />
<Entry
name="RUM"
value={formatSessionType(
infos.cookie.rum,
'Not tracked',
'Tracked with Session Replay',
'Tracked without Session Replay'
<TabBase>
<Columns>
<Columns.Column title="Session">
{infos.cookie && (
<>
<Entry name="Id" value={infos.cookie.id} />
<Entry name="Logs" value={formatSessionType(infos.cookie.logs, 'Not tracked', 'Tracked')} />
<Entry
name="RUM"
value={formatSessionType(
infos.cookie.rum,
'Not tracked',
'Tracked with Session Replay',
'Tracked without Session Replay'
)}
/>
<Entry name="Created" value={formatDate(Number(infos.cookie.created))} />
<Entry name="Expire" value={formatDate(Number(infos.cookie.expire))} />
</>
)}
</Columns.Column>
<Columns.Column title="RUM">
{infos.rum && (
<>
{sessionId && (
<Group>
<AppLink
config={infos.rum.config}
path="rum/explorer"
params={{
query: `@session.id:${sessionId}`,
live: 'true',
}}
>
Explorer
</AppLink>
<Divider sx={{ height: '24px' }} orientation="vertical" />
<AppLink config={infos.rum.config} path={`rum/replay/sessions/${sessionId}`} params={{}}>
Session Replay
</AppLink>
</Group>
)}
/>
<Entry name="Created" value={formatDate(Number(infos.cookie.created))} />
<Entry name="Expire" value={formatDate(Number(infos.cookie.expire))} />
</>
)}
</Section>
<Section name="RUM">
{infos.rum && (
<>
{sessionId && (
<Group>
<Entry name="Version" value={infos.rum.version} />
<Entry name="Configuration" value={infos.rum.config} />
<Entry name="Internal context" value={infos.rum.internalContext} />
<Entry name="Global context" value={infos.rum.globalContext} />
</>
)}
</Columns.Column>
<Columns.Column title="Logs">
{infos.logs && (
<>
{sessionId && (
<AppLink
config={infos.rum.config}
path="rum/explorer"
config={infos.logs.config}
path="logs"
params={{
query: `@session.id:${sessionId}`,
live: 'true',
query: `source:browser @session_id:${sessionId}`,
}}
>
Explorer
</AppLink>
<Divider sx={{ height: '24px' }} orientation="vertical" />
<AppLink config={infos.rum.config} path={`rum/replay/sessions/${sessionId}`} params={{}}>
Session Replay
</AppLink>
</Group>
)}
<Entry name="Version" value={infos.rum.version} />
<Entry name="Configuration" value={infos.rum.config} />
<Entry name="Internal context" value={infos.rum.internalContext} />
<Entry name="Global context" value={infos.rum.globalContext} />
</>
)}
</Section>
<Section name="Logs">
{infos.logs && (
<>
{sessionId && (
<AppLink
config={infos.logs.config}
path="logs"
params={{
query: `source:browser @session_id:${sessionId}`,
}}
>
Explorer
</AppLink>
)}
<Entry name="Version" value={infos.logs.version} />
<Entry name="Configuration" value={infos.logs.config} />
<Entry name="Global context" value={infos.logs.globalContext} />
</>
)}
</Section>
</Grid>
)}
<Entry name="Version" value={infos.logs.version} />
<Entry name="Configuration" value={infos.logs.config} />
<Entry name="Global context" value={infos.logs.globalContext} />
</>
)}
</Columns.Column>
</Columns>
</TabBase>
)
}

Expand All @@ -104,15 +108,6 @@ function AppLink({
)
}

function Section({ name, children }: { name: string; children: ReactNode | undefined }) {
return (
<Grid.Col md={4} sm={12}>
<Title order={3}>{name}</Title>
{children || '(empty)'}
</Grid.Col>
)
}

function Entry({ name, value }: { name: string; value: any }) {
return (
<Text size="sm" component="div">
Expand Down
Loading