Skip to content

Commit b7c2652

Browse files
authored
Merge pull request #32 from Lissy93/feat/disable-hit-count
Disable Plausible analytic (#30) Fixes #31
2 parents b7dd395 + baf980d commit b7c2652

6 files changed

Lines changed: 504 additions & 4 deletions

File tree

.codacy.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
# Codacy Configuration File
3+
# https://docs.codacy.com/repositories-configure/codacy-configuration-file/
4+
5+
comment:
6+
enabled: false
7+
8+
github_checks:
9+
annotations: true
10+
11+
file_extensions:
12+
- ".ts"
13+
- ".js"
14+
- ".svelte"
15+
- ".scss"
16+
- ".css"
17+
18+
duplication:
19+
exclude_paths:
20+
- "tests/**"
21+
22+
engines:
23+
eslint:
24+
config_file: eslintrc.config.js
25+
26+
# Exclude patterns - ignore test files and build artifacts from analysis
27+
exclude_paths:
28+
- "tests/**"
29+
- "**/*.test.ts"
30+
- "**/*.test.js"
31+
- "**/*.spec.ts"
32+
- "**/*.spec.js"
33+
- ".svelte-kit/**"
34+
- "build/**"
35+
- "dist/**"
36+
- "coverage/**"
37+
- "playwright-report/**"
38+
- "node_modules/**"
39+
- "**/*.config.ts"
40+
- "**/*.config.js"
41+
- "**/*.d.ts"
42+
- "static/**"
43+
- ".github/**"
44+
45+
# Language-specific engines configuration
46+
engines:
47+
# ESLint configuration (if you want to customize)
48+
eslint:
49+
enabled: true
50+
exclude_paths:
51+
- "tests/**"
52+
53+
# TypeScript/TSLint
54+
tslint:
55+
enabled: true
56+
exclude_paths:
57+
- "tests/**"
58+
59+
# Additional configuration
60+
duplication:
61+
enabled: true
62+
exclude_paths:
63+
- "tests/**"
64+
65+
# Complexity and code style checks
66+
metrics:
67+
enabled: true
68+
exclude_paths:
69+
- "tests/**"
70+
71+
# Coverage configuration
72+
coverage:
73+
# Enable coverage tracking
74+
enabled: true
75+
76+
# Exclude test files from coverage reports
77+
exclude_paths:
78+
- "tests/**"
79+
- "**/*.test.ts"
80+
- "**/*.spec.ts"
81+
82+
# Coverage thresholds (optional but recommended)
83+
status:
84+
# Project-wide coverage threshold
85+
project:
86+
default:
87+
enabled: true
88+
target: 80%
89+
threshold: 10% # Allow 5% decrease
90+
91+
# Diff/patch coverage threshold (new code in PRs)
92+
patch:
93+
default:
94+
enabled: true
95+
target: 80%
96+
threshold: 20% # Allow 10% decrease for patches

.github/docs/app-customization.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ environment:
157157
- **Example:** `NTB_ALLOWED_DNS_SERVERS='8.8.8.8,1.1.1.1,9.9.9.9'`
158158
- **Note:** Only used when `NTB_ALLOW_CUSTOM_DNS='false'`
159159

160+
### Analytics Settings
161+
162+
- **`NTB_ANALYTICS_DOMAIN`**
163+
- **Description:** Domain for analytics tracking (for Plausible or similar)
164+
- **Default:** `networking-toolbox.as93.net`
165+
- **Example:** `NTB_ANALYTICS_DOMAIN='myapp.example.com'`
166+
- **Disable:** Set to `false` to disable analytics: `NTB_ANALYTICS_DOMAIN='false'`
167+
168+
- **`NTB_ANALYTICS_DSN`**
169+
- **Description:** URL to the analytics script
170+
- **Default:** `https://no-track.as93.net/js/script.js`
171+
- **Example:** `NTB_ANALYTICS_DSN='https://plausible.io/js/script.js'`
172+
- **Disable:** Set to `false` to disable analytics: `NTB_ANALYTICS_DSN='false'`
173+
- **Note:** Analytics is disabled if either `NTB_ANALYTICS_DOMAIN` or `NTB_ANALYTICS_DSN` is set to `false`
174+
160175
---
161176

162177
## Example Configurations
@@ -174,6 +189,8 @@ NTB_HOMEPAGE_LAYOUT='categories'
174189
NTB_ALLOW_CUSTOM_DNS='false'
175190
NTB_BLOCK_PRIVATE_DNS_IPS='true'
176191
NTB_ALLOWED_DNS_SERVERS='8.8.8.8,1.1.1.1'
192+
NTB_ANALYTICS_DOMAIN='false'
193+
NTB_ANALYTICS_DSN='false'
177194
```
178195

179196
### Full Customization
@@ -190,5 +207,15 @@ NTB_DEFAULT_LANGUAGE='en'
190207
NTB_SHOW_TIPS_ON_HOMEPAGE='true'
191208
NTB_ALLOW_CUSTOM_DNS='true'
192209
NTB_BLOCK_PRIVATE_DNS_IPS='true'
210+
NTB_ANALYTICS_DOMAIN='myapp.example.com'
211+
NTB_ANALYTICS_DSN='https://plausible.io/js/script.js'
212+
```
213+
214+
### Self-Hosted (No Analytics)
215+
```bash
216+
NTB_SITE_TITLE='Internal Network Tools'
217+
NTB_DEFAULT_THEME='dark'
218+
NTB_ANALYTICS_DOMAIN='false'
219+
NTB_ANALYTICS_DSN='false'
193220
```
194221

src/lib/components/page-specific/about/DeployingSection.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@
5252
<h2>Customizing</h2>
5353
<p>You can customize the branding of your instance, by setting a few environment variables. All are optional.</p>
5454
<ul>
55-
<li><code>NTB_SITE_NAME</code> - Change sitename</li>
55+
<li><code>NTB_SITE_TITLE</code> - Change site name</li>
5656
<li><code>NTB_SITE_DESCRIPTION</code> - Change site tagline</li>
5757
<li><code>NTB_SITE_ICON</code> - Set site icon</li>
5858
<li><code>NTB_HOMEPAGE_LAYOUT</code> - Set homepage layout</li>
5959
<li><code>NTB_NAVBAR_DISPLAY</code> - Set navbar display option</li>
6060
<li><code>NTB_DEFAULT_THEME</code> - Set default theme</li>
61-
<li><code>NTB_DEFAULT_LANGUAGE</code> - Set default lang</li>
61+
<li><code>NTB_DEFAULT_LANGUAGE</code> - Set default language</li>
62+
<li><code>NTB_ANALYTICS_DOMAIN</code> - Analytics domain (or set to <code>false</code> to disable)</li>
63+
<li><code>NTB_ANALYTICS_DSN</code> - Analytics script URL (or set to <code>false</code> to disable)</li>
6264
</ul>
6365

6466
<p>

src/lib/config/customizable-settings.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,31 @@ export const ALLOWED_DNS_SERVERS = env.NTB_ALLOWED_DNS_SERVERS
110110
? env.NTB_ALLOWED_DNS_SERVERS.split(',').map((ip) => ip.trim())
111111
: DEFAULT_TRUSTED_DNS_SERVERS;
112112

113+
/**
114+
* Analytics Settings
115+
* Configure analytics tracking for self-hosted instances
116+
*/
117+
118+
/**
119+
* Analytics domain (for Plausible or similar analytics)
120+
* Set to 'false' to disable analytics entirely
121+
* Default: 'networking-toolbox.as93.net'
122+
*/
123+
export const ANALYTICS_DOMAIN = env.NTB_ANALYTICS_DOMAIN ?? 'networking-toolbox.as93.net';
124+
125+
/**
126+
* Analytics script URL (for Plausible or similar analytics)
127+
* Set to 'false' to disable analytics entirely
128+
* Default: 'https://no-track.as93.net/js/script.js'
129+
*/
130+
export const ANALYTICS_DSN = env.NTB_ANALYTICS_DSN ?? 'https://no-track.as93.net/js/script.js';
131+
132+
/**
133+
* Check if analytics is enabled
134+
* Analytics is disabled if either ANALYTICS_DOMAIN or ANALYTICS_DSN is set to 'false'
135+
*/
136+
export const ANALYTICS_ENABLED = ANALYTICS_DOMAIN !== 'false' && ANALYTICS_DSN !== 'false';
137+
113138
/**
114139
* Get user settings list with values prioritized as:
115140
* 1. User-set value from localStorage
@@ -153,5 +178,7 @@ export function getUserSettingsList(): Array<{ name: string; value: string }> {
153178
{ name: 'NTB_ALLOW_CUSTOM_DNS', value: env.NTB_ALLOW_CUSTOM_DNS || '' },
154179
{ name: 'NTB_BLOCK_PRIVATE_DNS_IPS', value: env.NTB_BLOCK_PRIVATE_DNS_IPS || '' },
155180
{ name: 'NTB_ALLOWED_DNS_SERVERS', value: env.NTB_ALLOWED_DNS_SERVERS || '' },
181+
{ name: 'NTB_ANALYTICS_DOMAIN', value: env.NTB_ANALYTICS_DOMAIN || '' },
182+
{ name: 'NTB_ANALYTICS_DSN', value: env.NTB_ANALYTICS_DSN || '' },
156183
];
157184
}

src/routes/+layout.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import { ALL_PAGES } from '$lib/constants/nav';
2525
import { initializeOfflineSupport } from '$lib/stores/offline';
2626
import { bookmarks } from '$lib/stores/bookmarks';
27+
import { ANALYTICS_ENABLED, ANALYTICS_DOMAIN, ANALYTICS_DSN } from '$lib/config/customizable-settings';
2728
2829
import Header from '$lib/components/furniture/Header.svelte';
2930
import SubHeader from '$lib/components/furniture/SubHeader.svelte';
@@ -400,8 +401,10 @@
400401
})}
401402
{/if}
402403

403-
<!-- Plausible Analytics -->
404-
<script defer data-domain="networking-toolbox.as93.net" src="https://no-track.as93.net/js/script.js"></script>
404+
<!-- Analytics (Plausible or custom) -->
405+
{#if ANALYTICS_ENABLED}
406+
<script defer data-domain={ANALYTICS_DOMAIN} src={ANALYTICS_DSN}></script>
407+
{/if}
405408

406409
<!-- Custom Styles for Self-Hosted Instances -->
407410
<!-- This loads last to ensure custom styles can override defaults -->

0 commit comments

Comments
 (0)