Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
96 changes: 96 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
# Codacy Configuration File
# https://docs.codacy.com/repositories-configure/codacy-configuration-file/

comment:
enabled: false

github_checks:
annotations: true

file_extensions:
- ".ts"
- ".js"
- ".svelte"
- ".scss"
- ".css"

duplication:
exclude_paths:
- "tests/**"

engines:
eslint:
config_file: eslintrc.config.js

# Exclude patterns - ignore test files and build artifacts from analysis
exclude_paths:
- "tests/**"
- "**/*.test.ts"
- "**/*.test.js"
- "**/*.spec.ts"
- "**/*.spec.js"
- ".svelte-kit/**"
- "build/**"
- "dist/**"
- "coverage/**"
- "playwright-report/**"
- "node_modules/**"
- "**/*.config.ts"
- "**/*.config.js"
- "**/*.d.ts"
- "static/**"
- ".github/**"

# Language-specific engines configuration
engines:
# ESLint configuration (if you want to customize)
eslint:
enabled: true
exclude_paths:
- "tests/**"

# TypeScript/TSLint
tslint:
enabled: true
exclude_paths:
- "tests/**"

# Additional configuration
duplication:
enabled: true
exclude_paths:
- "tests/**"

# Complexity and code style checks
metrics:
enabled: true
exclude_paths:
- "tests/**"

# Coverage configuration
coverage:
# Enable coverage tracking
enabled: true

# Exclude test files from coverage reports
exclude_paths:
- "tests/**"
- "**/*.test.ts"
- "**/*.spec.ts"

# Coverage thresholds (optional but recommended)
status:
# Project-wide coverage threshold
project:
default:
enabled: true
target: 80%
threshold: 10% # Allow 5% decrease

# Diff/patch coverage threshold (new code in PRs)
patch:
default:
enabled: true
target: 80%
threshold: 20% # Allow 10% decrease for patches
27 changes: 27 additions & 0 deletions .github/docs/app-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ environment:
- **Example:** `NTB_ALLOWED_DNS_SERVERS='8.8.8.8,1.1.1.1,9.9.9.9'`
- **Note:** Only used when `NTB_ALLOW_CUSTOM_DNS='false'`

### Analytics Settings

- **`NTB_ANALYTICS_DOMAIN`**
- **Description:** Domain for analytics tracking (for Plausible or similar)
- **Default:** `networking-toolbox.as93.net`
- **Example:** `NTB_ANALYTICS_DOMAIN='myapp.example.com'`
- **Disable:** Set to `false` to disable analytics: `NTB_ANALYTICS_DOMAIN='false'`

- **`NTB_ANALYTICS_DSN`**
- **Description:** URL to the analytics script
- **Default:** `https://no-track.as93.net/js/script.js`
- **Example:** `NTB_ANALYTICS_DSN='https://plausible.io/js/script.js'`
- **Disable:** Set to `false` to disable analytics: `NTB_ANALYTICS_DSN='false'`
- **Note:** Analytics is disabled if either `NTB_ANALYTICS_DOMAIN` or `NTB_ANALYTICS_DSN` is set to `false`

---

## Example Configurations
Expand All @@ -174,6 +189,8 @@ NTB_HOMEPAGE_LAYOUT='categories'
NTB_ALLOW_CUSTOM_DNS='false'
NTB_BLOCK_PRIVATE_DNS_IPS='true'
NTB_ALLOWED_DNS_SERVERS='8.8.8.8,1.1.1.1'
NTB_ANALYTICS_DOMAIN='false'
NTB_ANALYTICS_DSN='false'
```

### Full Customization
Expand All @@ -190,5 +207,15 @@ NTB_DEFAULT_LANGUAGE='en'
NTB_SHOW_TIPS_ON_HOMEPAGE='true'
NTB_ALLOW_CUSTOM_DNS='true'
NTB_BLOCK_PRIVATE_DNS_IPS='true'
NTB_ANALYTICS_DOMAIN='myapp.example.com'
NTB_ANALYTICS_DSN='https://plausible.io/js/script.js'
```

### Self-Hosted (No Analytics)
```bash
NTB_SITE_TITLE='Internal Network Tools'
NTB_DEFAULT_THEME='dark'
NTB_ANALYTICS_DOMAIN='false'
NTB_ANALYTICS_DSN='false'
```

Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
<h2>Customizing</h2>
<p>You can customize the branding of your instance, by setting a few environment variables. All are optional.</p>
<ul>
<li><code>NTB_SITE_NAME</code> - Change sitename</li>
<li><code>NTB_SITE_TITLE</code> - Change site name</li>
<li><code>NTB_SITE_DESCRIPTION</code> - Change site tagline</li>
<li><code>NTB_SITE_ICON</code> - Set site icon</li>
<li><code>NTB_HOMEPAGE_LAYOUT</code> - Set homepage layout</li>
<li><code>NTB_NAVBAR_DISPLAY</code> - Set navbar display option</li>
<li><code>NTB_DEFAULT_THEME</code> - Set default theme</li>
<li><code>NTB_DEFAULT_LANGUAGE</code> - Set default lang</li>
<li><code>NTB_DEFAULT_LANGUAGE</code> - Set default language</li>
<li><code>NTB_ANALYTICS_DOMAIN</code> - Analytics domain (or set to <code>false</code> to disable)</li>
<li><code>NTB_ANALYTICS_DSN</code> - Analytics script URL (or set to <code>false</code> to disable)</li>
</ul>

<p>
Expand Down
27 changes: 27 additions & 0 deletions src/lib/config/customizable-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,31 @@ export const ALLOWED_DNS_SERVERS = env.NTB_ALLOWED_DNS_SERVERS
? env.NTB_ALLOWED_DNS_SERVERS.split(',').map((ip) => ip.trim())
: DEFAULT_TRUSTED_DNS_SERVERS;

/**
* Analytics Settings
* Configure analytics tracking for self-hosted instances
*/

/**
* Analytics domain (for Plausible or similar analytics)
* Set to 'false' to disable analytics entirely
* Default: 'networking-toolbox.as93.net'
*/
export const ANALYTICS_DOMAIN = env.NTB_ANALYTICS_DOMAIN ?? 'networking-toolbox.as93.net';

/**
* Analytics script URL (for Plausible or similar analytics)
* Set to 'false' to disable analytics entirely
* Default: 'https://no-track.as93.net/js/script.js'
*/
export const ANALYTICS_DSN = env.NTB_ANALYTICS_DSN ?? 'https://no-track.as93.net/js/script.js';

/**
* Check if analytics is enabled
* Analytics is disabled if either ANALYTICS_DOMAIN or ANALYTICS_DSN is set to 'false'
*/
export const ANALYTICS_ENABLED = ANALYTICS_DOMAIN !== 'false' && ANALYTICS_DSN !== 'false';

/**
* Get user settings list with values prioritized as:
* 1. User-set value from localStorage
Expand Down Expand Up @@ -153,5 +178,7 @@ export function getUserSettingsList(): Array<{ name: string; value: string }> {
{ name: 'NTB_ALLOW_CUSTOM_DNS', value: env.NTB_ALLOW_CUSTOM_DNS || '' },
{ name: 'NTB_BLOCK_PRIVATE_DNS_IPS', value: env.NTB_BLOCK_PRIVATE_DNS_IPS || '' },
{ name: 'NTB_ALLOWED_DNS_SERVERS', value: env.NTB_ALLOWED_DNS_SERVERS || '' },
{ name: 'NTB_ANALYTICS_DOMAIN', value: env.NTB_ANALYTICS_DOMAIN || '' },
{ name: 'NTB_ANALYTICS_DSN', value: env.NTB_ANALYTICS_DSN || '' },
];
}
7 changes: 5 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { ALL_PAGES } from '$lib/constants/nav';
import { initializeOfflineSupport } from '$lib/stores/offline';
import { bookmarks } from '$lib/stores/bookmarks';
import { ANALYTICS_ENABLED, ANALYTICS_DOMAIN, ANALYTICS_DSN } from '$lib/config/customizable-settings';

import Header from '$lib/components/furniture/Header.svelte';
import SubHeader from '$lib/components/furniture/SubHeader.svelte';
Expand Down Expand Up @@ -400,8 +401,10 @@
})}
{/if}

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

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