Skip to content

Commit

Permalink
feature: add debugger statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
june07 committed Aug 28, 2024
1 parent 4134dc0 commit 643c76d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 29 deletions.
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,5 +321,8 @@
},
"themeOverride": {
"message": "Override system theme"
},
"statistics": {
"message": "Statistics"
}
}
19 changes: 15 additions & 4 deletions src/devtoolsProtocolClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@
//delete cache.tabs[dtpSocket.socket]?.promise
delete cache.tabs[dtpSocket.socket]
})
dtpSocket.ws.addEventListener('message', (event) => {
console.log('event: ', event)
dtpSocket.ws.addEventListener('open', (event) => {
if (!settings.debuggingStatistics) return
event.currentTarget.send('{"id": 1, "method": "Debugger.enable"}')
})
dtpSocket.ws.addEventListener('error', (event) => {
console.log('event: ', event)
dtpSocket.ws.addEventListener('message', (event) => {
const data = JSON.parse(event.data)
const { method, params } = data

if (/Debugger\.(paused|resumed)/.test(method)) {
let details = { method, timestamp: Date.now() }

if (method === 'Debugger.paused') {
details = { ...details, 'params.callFrames[0].location': params.callFrames[0]?.location }
}
googleAnalytics.fireEvent('Debugger Event', details)
}
})
async function logReadyState() {
try {
Expand Down
3 changes: 2 additions & 1 deletion src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
],
removeSessionOnTabRemoved: false,
pin: true,
themeOverride: false
themeOverride: false,
debuggingStatistics: true
}
settings.userSettings = async () => await chrome.storage.local.get('userSettings')
settings.get = async () => {
Expand Down
61 changes: 37 additions & 24 deletions src/ui/components/NiSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</v-tabs>
<v-window v-model="tab">
<v-window-item value="ui">
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pb-0 text-body-1">
{{ i18nString('openInspectorNewWindow') }}
</v-col>
Expand All @@ -21,7 +21,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center" v-if="inputs.newWindow">
<v-row class="d-flex align-center mt-0" v-if="inputs.newWindow">
<v-col class="py-0 text-body-1">
{{ i18nString('makeInspectorWindowFocused') }}
</v-col>
Expand All @@ -33,7 +33,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center" v-if="inputs.newWindow">
<v-row class="d-flex align-center mt-0" v-if="inputs.newWindow">
<v-col class="py-0 text-body-1">
{{ i18nString('inspectorWindowStyle') }}
</v-col>
Expand All @@ -45,7 +45,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center" v-if="inputs.newWindow">
<v-row class="d-flex align-center mt-0" v-if="inputs.newWindow">
<v-col class="py-0 text-body-1">
{{ i18nString('optionsWindowStateMaximized') }}
</v-col>
Expand All @@ -57,7 +57,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center" v-if="!inputs.newWindow">
<v-row class="d-flex align-center mt-0" v-if="!inputs.newWindow">
<v-col class="py-0 text-body-1">
{{ i18nString('makeInspectorTabActive') }}
</v-col>
Expand All @@ -69,7 +69,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="py-0 text-body-1">
{{ i18nString('focusOnBreakpoint') }}
</v-col>
Expand All @@ -81,7 +81,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="py-0 text-body-1">
{{ i18nString('autoCloseInspector') }}
</v-col>
Expand All @@ -93,7 +93,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="py-0 text-body-1">
{{ i18nString('groupInspectorTabs') }}
</v-col>
Expand All @@ -105,7 +105,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pt-0 text-body-1 text-capitalize">
{{ i18nString('themeOverride') }}
</v-col>
Expand All @@ -118,7 +118,7 @@
</v-col>
</v-row>

<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pt-0 text-body-1" cols="7">
{{ i18nString('debugVerbosity') }}
</v-col>
Expand All @@ -134,19 +134,31 @@
</v-window-item>

<v-window-item value="debugger">
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pb-0 text-body-1">
DevTools Compat
{{ i18nString('statistics') }}
</v-col>
<v-col class="pb-0" cols="2">
<v-switch name="debuggingStatistics" v-model="inputs.debuggingStatistics" hide-details @change="update" inset density="compact" class="small-switch" color="primary">
<template v-slot:label>
<div class="text-no-wrap" style="width: 40px">{{ inputs.debuggingStatistics ? `${i18nString('on')}` : `${i18nString('off')}` }}</div>
</template>
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center mt-0">
<v-col class="py-0 text-body-1">
DevTools Compat
</v-col>
<v-col class="py-0" cols="2">
<v-switch name="devToolsCompat" v-model="inputs.devToolsCompat" hide-details @change="update" inset density="compact" class="small-switch" color="primary">
<template v-slot:label>
<div class="text-no-wrap" style="width: 40px">{{ inputs.devToolsCompat ? `${i18nString('on')}` : `${i18nString('off')}` }}</div>
</template>
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="py-0 text-body-1">
{{ i18nString('defaultDevTools') }}
</v-col>
Expand All @@ -158,8 +170,8 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center">
<v-col class="py-0 text-body-1" cols="4">
<v-row class="d-flex align-center mt-0">
<v-col class="py-0 text-body-1" cols="3">
DevTools Version ({{ inputs.localDevtoolsOptionsSelected.name }})
</v-col>
<v-col class="py-0 text-no-wrap" cols="6">
Expand All @@ -173,17 +185,17 @@
</v-col>
<v-spacer cols="2"></v-spacer>
</v-row>
<v-row class="d-flex align-center" v-if="inputs.localDevtoolsOptionsSelected.id == 3">
<v-col class="text-body-1">
<v-row class="d-flex align-center mt-0" v-if="inputs.localDevtoolsOptionsSelected.id == 3">
<v-col class="text-body-1" cols="3">
{{ i18nString('optionsCustomDevToolsURL') }}
</v-col>
<v-col cols="6">
<v-text-field name="customDevtoolsURL" class="rounded-xl" :rules="rules.customDevtoolsURL" density="compact" variant="solo" flat v-model="inputs.localDevtoolsOptionsSelected.url" @change="update" placeholder="https://" bg-color="green-lighten-4">
</v-text-field>
</v-col>
<v-spacer></v-spacer>
<v-spacer cols="2"></v-spacer>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pt-0 text-body-1" cols="7">
{{ i18nString('secondsBetweenInspectorChecks') }}
</v-col>
Expand All @@ -199,7 +211,7 @@
</v-window-item>

<v-window-item value="notifications">
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pb-0 text-body-1">
{{ i18nString('optionsChromeNotificationsGeneral') }}
</v-col>
Expand All @@ -211,7 +223,7 @@
</v-switch>
</v-col>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pt-0 text-body-1">
{{ i18nString('optionsChromeNotificationsExternal') }}
</v-col>
Expand All @@ -226,7 +238,7 @@
</v-window-item>

<v-window-item value="brakecode">
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="text-body-1" cols="6">
BrakeCODE API Key
</v-col>
Expand All @@ -235,7 +247,7 @@
</v-col>
<v-spacer></v-spacer>
</v-row>
<v-row class="d-flex align-center">
<v-row class="d-flex align-center mt-0">
<v-col class="pt-0 text-body-1" cols="6">
{{ i18nString('nodeReportMaxMessages') }}
</v-col>
Expand Down Expand Up @@ -296,7 +308,8 @@ let inputs = ref({
checkInterval: settings.value.checkInterval,
debugVerbosity: settings.value.debugVerbosity,
maxMessages: settings.value.diagnosticReports.maxMessages,
themeOverride: settings.value.themeOverride
themeOverride: settings.value.themeOverride,
debuggingStatistics: settings.value.debuggingStatistics,
})
const rules = {
customDevtoolsURL: [
Expand Down

0 comments on commit 643c76d

Please sign in to comment.