Make analytics and error reporting optional

This commit is contained in:
Jon Staab
2025-03-03 15:09:58 -08:00
parent b399fa8dcc
commit ffb36af734
5 changed files with 69 additions and 10 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
/* eslint prefer-rest-params: 0 */
import {page} from "$app/stores"
import {getSetting} from "@app/state"
const w = window as any
@@ -12,7 +13,7 @@ w.plausible =
export const setupAnalytics = () => {
page.subscribe($page => {
if ($page.route) {
if ($page.route && getSetting("report_usage")) {
w.plausible("pageview", {u: $page.route.id})
}
})
+4
View File
@@ -305,6 +305,8 @@ export type Settings = {
values: {
show_media: boolean
hide_sensitive: boolean
report_usage: boolean
report_errors: boolean
send_delay: number
upload_type: "nip96" | "blossom"
nip96_urls: string[]
@@ -315,6 +317,8 @@ export type Settings = {
export const defaultSettings = {
show_media: true,
hide_sensitive: true,
report_usage: true,
report_errors: false,
send_delay: 3000,
upload_type: "nip96",
nip96_urls: ["https://nostr.build"],
+8 -1
View File
@@ -1,10 +1,17 @@
import * as Sentry from "@sentry/browser"
import {getSetting} from "@app/state"
export const setupTracking = () => {
if (import.meta.env.VITE_GLITCHTIP_API_KEY) {
Sentry.init({
dsn: import.meta.env.VITE_GLITCHTIP_API_KEY,
tracesSampleRate: 0.01,
beforeSend(event: any) {
if (!getSetting("report_errors")) {
return null
}
return event
},
integrations(integrations) {
return integrations.filter(integration => integration.name !== "Breadcrumbs")
},