Skip to content

Commit

Permalink
refactor: show warning if trackLocalhost is used
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Aug 6, 2024
1 parent 79e8ae4 commit 5dfe3b9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default defineNuxtModule<ModuleOptions>({
domain: '',
ignoredHostnames: undefined,
ignoreSubDomains: false,
trackLocalhost: false,
trackLocalhost: undefined,
apiHost: 'https://plausible.io',
autoPageviews: true,
autoOutboundTracking: false,
Expand All @@ -123,9 +123,11 @@ export default defineNuxtModule<ModuleOptions>({
// Dedupe `ignoredHostnames` items
options.ignoredHostnames = Array.from(new Set(options.ignoredHostnames))

// Migrate `trackLocalhost` to `ignoredHostnames`
if (options.trackLocalhost) {
if (options.trackLocalhost !== undefined) {
logger.warn('The `trackLocalhost` option has been deprecated. Please use `ignoredHostnames` instead.')
}
// Migrate `trackLocalhost` to `ignoredHostnames`
else if (options.trackLocalhost) {
options.ignoredHostnames = options.ignoredHostnames.filter(
domain => domain !== 'localhost',
)
Expand Down

0 comments on commit 5dfe3b9

Please sign in to comment.