forked from coracle/flotilla
Make analytics and error reporting optional
This commit is contained in:
@@ -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})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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
@@ -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")
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user