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

🔉[developer-extension] bootstrap monitoring #2337

Merged
merged 6 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ typecheck:
interruptible: true
script:
- yarn
- yarn build
bcaudan marked this conversation as resolved.
Show resolved Hide resolved
- yarn typecheck

build-and-lint:
Expand Down
2 changes: 2 additions & 0 deletions developer-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"webpack": "5.88.1"
},
"dependencies": {
"@datadog/browser-logs": "workspace:*",
"@datadog/browser-rum": "workspace:*",
"@emotion/react": "11.11.1",
"@mantine/core": "6.0.16",
"@mantine/hooks": "6.0.16",
Expand Down
2 changes: 1 addition & 1 deletion developer-extension/src/panel/components/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function Alert({
}) {
const color = level === 'warning' ? ('orange' as const) : ('red' as const)
return (
<Center mt="xl">
<Center mt="xl" className={'dd-privacy-allow'}>
bcaudan marked this conversation as resolved.
Show resolved Hide resolved
<MantineAlert color={color} title={title}>
{message}
{button && (
Expand Down
2 changes: 1 addition & 1 deletion developer-extension/src/panel/components/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function Panel() {
defaultValue={PanelTabs.Events}
sx={{ height: '100vh', display: 'flex', flexDirection: 'column' }}
>
<Tabs.List>
<Tabs.List className={'dd-privacy-allow'}>
<Tabs.Tab value={PanelTabs.Events}>Events</Tabs.Tab>
<Tabs.Tab value={PanelTabs.Infos}>
<Text>Infos</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function EventTab({ events, filters, onFiltered, clear }: EventTabProps)
return (
<TabBase
top={
<Group>
<Group className={'dd-privacy-allow'}>
<Chip.Group
multiple
value={filters.sdk}
Expand All @@ -49,6 +49,7 @@ export function EventTab({ events, filters, onFiltered, clear }: EventTabProps)
value={filters.query}
style={{ flexGrow: 1 }}
onChange={(event) => onFiltered({ ...filters, query: event.currentTarget.value })}
className={'dd-privacy-mask'}
/>

<Button color="violet" variant="light" onClick={flushEvents}>
Expand Down
24 changes: 13 additions & 11 deletions developer-extension/src/panel/components/tabs/infosTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function InfosTab() {
<Entry name="Created" value={formatDate(Number(infos.cookie.created))} />
<Entry name="Expire" value={formatDate(Number(infos.cookie.expire))} />
<Space h="sm" />
<Button color="violet" variant="light" onClick={endSession}>
<Button color="violet" variant="light" onClick={endSession} className={'dd-privacy-allow'}>
End current session
</Button>
</>
Expand All @@ -47,7 +47,7 @@ export function InfosTab() {
{infos.rum && (
<>
{sessionId && (
<Group>
<Group className={'dd-privacy-allow'}>
<AppLink
config={infos.rum.config}
path="rum/explorer"
Expand Down Expand Up @@ -76,15 +76,17 @@ export function InfosTab() {
{infos.logs && (
<>
{sessionId && (
<AppLink
config={infos.logs.config}
path="logs"
params={{
query: `source:browser @session_id:${sessionId}`,
}}
>
Explorer
</AppLink>
<div className={'dd-privacy-allow'}>
<AppLink
config={infos.logs.config}
path="logs"
params={{
query: `source:browser @session_id:${sessionId}`,
}}
>
Explorer
</AppLink>
</div>
)}
<Entry name="Version" value={infos.logs.version} />
<Entry name="Configuration" value={infos.logs.config} />
Expand Down
214 changes: 108 additions & 106 deletions developer-extension/src/panel/components/tabs/settingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,121 +13,123 @@ export function SettingsTab() {

return (
<TabBase>
<Columns>
<Columns.Column title="Request interception">
<SettingItem
input={
<Group align="start">
<div className={'dd-privacy-allow'}>
<Columns>
<Columns.Column title="Request interception">
<SettingItem
input={
<Group align="start">
<Checkbox
label="Use development bundles"
checked={useDevBundles}
onChange={(e) => setSetting('useDevBundles', isChecked(e.target))}
color="violet"
/>
{devServerStatus === DevServerStatus.AVAILABLE ? (
<Badge color="green">Available</Badge>
) : devServerStatus === DevServerStatus.CHECKING ? (
<Badge color="yellow">Checking...</Badge>
) : (
<Badge color="red">Unavailable</Badge>
)}
</Group>
}
description={
<>
Use the local development bundles served by the Browser SDK development server. To start the
development server, run <Code>yarn dev</Code> in the Browser SDK root folder.
</>
}
/>

<SettingItem
input={
<Checkbox
label="Use development bundles"
checked={useDevBundles}
onChange={(e) => setSetting('useDevBundles', isChecked(e.target))}
label="Use RUM Slim"
checked={useRumSlim}
onChange={(e) => setSetting('useRumSlim', isChecked(e.target))}
color="violet"
/>
{devServerStatus === DevServerStatus.AVAILABLE ? (
<Badge color="green">Available</Badge>
) : devServerStatus === DevServerStatus.CHECKING ? (
<Badge color="yellow">Checking...</Badge>
) : (
<Badge color="red">Unavailable</Badge>
)}
</Group>
}
description={
<>
Use the local development bundles served by the Browser SDK development server. To start the development
server, run <Code>yarn dev</Code> in the Browser SDK root folder.
</>
}
/>
}
description={
<>If the page is using the RUM CDN bundle, this bundle will be replaced by the RUM Slim CDN bundle.</>
}
/>

<SettingItem
input={
<Checkbox
label="Use RUM Slim"
checked={useRumSlim}
onChange={(e) => setSetting('useRumSlim', isChecked(e.target))}
color="violet"
/>
}
description={
<>If the page is using the RUM CDN bundle, this bundle will be replaced by the RUM Slim CDN bundle.</>
}
/>
<SettingItem
input={
<Checkbox
label="Block intake requests"
checked={blockIntakeRequests}
onChange={(e) => setSetting('blockIntakeRequests', isChecked(e.target))}
color="violet"
/>
}
description={<>Block requests made to the intake, preventing any data to be sent to Datadog.</>}
/>
</Columns.Column>

<SettingItem
input={
<Checkbox
label="Block intake requests"
checked={blockIntakeRequests}
onChange={(e) => setSetting('blockIntakeRequests', isChecked(e.target))}
color="violet"
/>
}
description={<>Block requests made to the intake, preventing any data to be sent to Datadog.</>}
/>
</Columns.Column>
<Columns.Column title="Events list">
<SettingItem
input={
<Checkbox
label="Preserve events"
checked={preserveEvents}
onChange={(e) => setSetting('preserveEvents', isChecked(e.target))}
color="violet"
/>
}
description={<>Don't clear events when reloading the page or navigating away.</>}
/>

<Columns.Column title="Events list">
<SettingItem
input={
<Checkbox
label="Preserve events"
checked={preserveEvents}
onChange={(e) => setSetting('preserveEvents', isChecked(e.target))}
color="violet"
/>
}
description={<>Don't clear events when reloading the page or navigating away.</>}
/>
<SettingItem
input={
<Group>
<Text size="sm">Events source:</Text>
<Select
data={[
{ label: 'Requests', value: 'requests' },
{ label: 'SDK', value: 'sdk' },
]}
value={eventSource}
onChange={(value) => setSetting('eventSource', value as EventSource)}
color="violet"
sx={{ flex: 1 }}
/>
</Group>
}
description={
<>
{eventSource === 'requests' && (
<>
Collect events by listening to intake HTTP requests: events need to be flushed to be collected.
Any SDK setup is supported.
</>
)}
{eventSource === 'sdk' && (
<>
Collect events by listening to messages sent from the SDK: events are available as soon as they
happen. Only newer versions of the SDK are supported.
</>
)}
</>
}
/>

<SettingItem
input={
<Group>
<Text size="sm">Events source:</Text>
<Select
data={[
{ label: 'Requests', value: 'requests' },
{ label: 'SDK', value: 'sdk' },
]}
value={eventSource}
onChange={(value) => setSetting('eventSource', value as EventSource)}
<SettingItem
input={
<Checkbox
label="Auto Flush"
checked={autoFlush}
onChange={(e) => setSetting('autoFlush', isChecked(e.target))}
color="violet"
sx={{ flex: 1 }}
/>
</Group>
}
description={
<>
{eventSource === 'requests' && (
<>
Collect events by listening to intake HTTP requests: events need to be flushed to be collected. Any
SDK setup is supported.
</>
)}
{eventSource === 'sdk' && (
<>
Collect events by listening to messages sent from the SDK: events are available as soon as they
happen. Only newer versions of the SDK are supported.
</>
)}
</>
}
/>

<SettingItem
input={
<Checkbox
label="Auto Flush"
checked={autoFlush}
onChange={(e) => setSetting('autoFlush', isChecked(e.target))}
color="violet"
/>
}
description={<>Force the SDK to flush events periodically.</>}
/>
</Columns.Column>
</Columns>
}
description={<>Force the SDK to flush events periodically.</>}
/>
</Columns.Column>
</Columns>
</div>
</TabBase>
)
}
Expand Down
2 changes: 2 additions & 0 deletions developer-extension/src/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { createRoot } from 'react-dom/client'
import React from 'react'

import { App } from './components/app'
import { initMonitoring } from './monitoring'

const main = document.createElement('main')
document.body.append(main)
const root = createRoot(main)
root.render(<App />)
initMonitoring()
37 changes: 37 additions & 0 deletions developer-extension/src/panel/monitoring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { datadogRum } from '@datadog/browser-rum'
import { datadogLogs } from '@datadog/browser-logs'
import packageJson from '../../package.json'

export function initMonitoring() {
datadogRum.init({
applicationId: '235202fa-3da1-4aeb-abc4-d01b10ca1539',
clientToken: 'pub74fd472504982beb427b647893758040',
site: 'datadoghq.com',
service: 'browser-sdk-developer-extension',
env: 'prod',
version: packageJson.version,
allowFallbackToLocalStorage: true,
sessionSampleRate: 100,
sessionReplaySampleRate: 100,
telemetrySampleRate: 100,
trackUserInteractions: true,
trackResources: true,
trackLongTasks: true,
defaultPrivacyLevel: 'mask',
})
datadogRum.startSessionReplayRecording()

datadogLogs.init({
clientToken: 'pub74fd472504982beb427b647893758040',
site: 'datadoghq.com',
service: 'browser-sdk-developer-extension',
env: 'prod',
version: packageJson.version,
allowFallbackToLocalStorage: true,
forwardErrorsToLogs: true,
forwardConsoleLogs: 'all',
forwardReports: 'all',
sessionSampleRate: 100,
telemetrySampleRate: 100,
})
}
Loading