Skip to content

Commit 25150e2

Browse files
committed
chore: cleanup
1 parent a9b4412 commit 25150e2

30 files changed

+1485
-938
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./packages/nuxt/README.md
1+
./packages/nuxt/README.md

examples/nuxt-v3/app.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
22
if (import.meta.server) {
3-
console.log('app.vue');
43
await trackPageview();
54
}
65
</script>
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
export default defineNuxtRouteMiddleware(async (to) => {
2-
console.log('tracking-middleware', to);
32
// We track pageviews on the server only
43
if (import.meta.client) {
54
return;
65
}
76

8-
if (to.path.startsWith('/api/')) {
7+
if (to.path.startsWith("/api/")) {
98
return;
109
}
1110

1211
await trackPageview();
13-
})
12+
});

examples/nuxt-v3/nuxt.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// https://nuxt.com/docs/api/configuration/nuxt-config
22
export default defineNuxtConfig({
3-
compatibilityDate: '2025-05-15',
3+
compatibilityDate: "2025-05-15",
44
devtools: { enabled: true },
5-
modules: ['@simpleanalytics/nuxt'],
5+
modules: ["@simpleanalytics/nuxt"],
66
simpleAnalytics: {
7-
hostname: 'test.example.com' // Replace with your actual domain
8-
}
9-
})
7+
hostname: "test.example.com", // Replace with your actual domain
8+
},
9+
});

examples/nuxt-v3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@simpleanalytics/nuxt": "workspace:*",
1414
"nuxt": "^3.17.5",
15-
"vue": "^3.5.17",
15+
"vue": "^3.5.18",
1616
"vue-router": "^4.5.1"
1717
}
1818
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
import { defineEventHandler, createError } from 'h3'
1+
import { defineEventHandler, createError } from "h3";
22

33
export default defineEventHandler(async (event) => {
44
try {
5-
await trackEvent('button_clicked', {
5+
await trackEvent("button_clicked", {
66
event,
77
metadata: {
8-
source: 'test_page',
9-
timestamp: new Date().toISOString()
10-
}
11-
})
8+
source: "test_page",
9+
},
10+
});
1211

1312
return {
1413
success: true,
15-
message: 'Button click event tracked successfully'
16-
}
14+
message: "Button click event tracked successfully",
15+
};
1716
} catch (error) {
18-
console.error('Error tracking event:', error)
17+
console.error("Error tracking event:", error);
1918
throw createError({
2019
statusCode: 500,
21-
statusMessage: 'Failed to track event'
22-
})
20+
statusMessage: "Failed to track event",
21+
});
2322
}
24-
})
23+
});

examples/nuxt-v4/nuxt.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// https://nuxt.com/docs/api/configuration/nuxt-config
22
export default defineNuxtConfig({
3-
compatibilityDate: '2025-07-15',
4-
devtools: { enabled: true }
5-
})
3+
compatibilityDate: "2025-07-15",
4+
devtools: { enabled: true },
5+
});

examples/nuxt-v4/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"type": "module",
55
"scripts": {
66
"build": "nuxt build",
7-
"dev-v4": "nuxt dev",
7+
"dev": "nuxt dev",
88
"generate": "nuxt generate",
99
"preview": "nuxt preview",
1010
"postinstall": "nuxt prepare"
1111
},
1212
"dependencies": {
1313
"@simpleanalytics/nuxt": "workspace:*",
1414
"nuxt": "^4.0.1",
15-
"vue": "^3.5.17",
15+
"vue": "^3.5.18",
1616
"vue-router": "^4.5.1"
1717
}
1818
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
"build": "turbo run build",
55
"dev": "turbo run dev",
66
"build:package": "turbo run build --filter=@simpleanalytics/nuxt",
7+
"postinstall": "turbo run postinstall",
78
"dev:prepare": "turbo run dev:prepare --filter=@simpleanalytics/nuxt",
89
"lint": "turbo run lint",
910
"format": "prettier --write \"**/*.{ts,tsx,md}\""
1011
},
1112
"devDependencies": {
12-
"@changesets/cli": "^2.28.1",
13-
"turbo": "^2.4.4"
13+
"@changesets/cli": "^2.29.5",
14+
"turbo": "^2.5.5"
1415
},
1516
"packageManager": "[email protected]"
1617
}

packages/nuxt/README.md

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Add the module to your `nuxt.config.ts`:
1414

1515
```ts
1616
export default defineNuxtConfig({
17-
modules: ['@simpleanalytics/nuxt'],
17+
modules: ["@simpleanalytics/nuxt"],
1818
simpleAnalytics: {
19-
hostname: 'your-domain.com',
19+
hostname: "your-domain.com",
2020
enabled: true,
21-
proxy: true
22-
}
23-
})
21+
proxy: true,
22+
},
23+
});
2424
```
2525

2626
## Usage
@@ -34,11 +34,11 @@ Track pageviews automatically on the server:
3434
// This will run on the server and track the pageview
3535
if (import.meta.server) {
3636
await trackPageview({
37-
hostname: 'your-domain.com',
37+
hostname: "your-domain.com",
3838
metadata: {
39-
source: 'homepage',
40-
}
41-
})
39+
source: "homepage",
40+
},
41+
});
4242
}
4343
</script>
4444
```
@@ -50,17 +50,18 @@ Track custom events from API routes or server-side code:
5050
```ts
5151
// In a server API route
5252
export default defineEventHandler(async (event) => {
53-
await trackEvent('user_signup', {
53+
await trackEvent("user_signup", {
5454
event,
5555
metadata: {
56-
source: 'registration_form',
57-
user_type: 'new'
58-
}
59-
})
60-
61-
return { success: true }
62-
})
56+
source: "registration_form",
57+
user_type: "new",
58+
},
59+
});
60+
61+
return { success: true };
62+
});
6363
```
64+
6465
## Configuration
6566

6667
### Module Options
@@ -69,23 +70,23 @@ export default defineEventHandler(async (event) => {
6970
export default defineNuxtConfig({
7071
simpleAnalytics: {
7172
// Your Simple Analytics hostname
72-
hostname: 'your-domain.com',
73-
73+
hostname: "your-domain.com",
74+
7475
// Enable/disable the module
7576
enabled: true,
76-
77+
7778
// Enable/disable proxy
7879
proxy: true,
79-
80+
8081
// Auto-collect events
8182
autoCollect: true,
82-
83+
8384
// Collect data even when DNT is enabled
8485
collectDnt: false,
85-
86+
8687
// Dashboard mode
87-
mode: 'dash',
88-
88+
mode: "dash",
89+
8990
// Ignore specific metrics
9091
ignoreMetrics: {
9192
referrer: false,
@@ -97,22 +98,22 @@ export default defineNuxtConfig({
9798
useragent: false,
9899
screensize: false,
99100
viewportsize: false,
100-
language: false
101+
language: false,
101102
},
102-
103+
103104
// Ignore specific pages
104-
ignorePages: ['/admin', '/private'],
105-
105+
ignorePages: ["/admin", "/private"],
106+
106107
// Allow specific URL parameters
107-
allowParams: ['ref', 'source'],
108-
108+
allowParams: ["ref", "source"],
109+
109110
// Non-unique parameters
110-
nonUniqueParams: ['utm_source'],
111-
111+
nonUniqueParams: ["utm_source"],
112+
112113
// Strict UTM parameter parsing
113-
strictUtm: true
114-
}
115-
})
114+
strictUtm: true,
115+
},
116+
});
116117
```
117118

118119
### Environment Variables
@@ -129,6 +130,7 @@ SIMPLE_ANALYTICS_HOSTNAME=your-domain.com
129130
Track a pageview on the server.
130131

131132
**Parameters:**
133+
132134
- `options` (object):
133135
- `hostname` (string): Your Simple Analytics hostname
134136
- `metadata` (object): Additional metadata to track
@@ -141,6 +143,7 @@ Track a pageview on the server.
141143
Track a custom event on the server.
142144

143145
**Parameters:**
146+
144147
- `eventName` (string): Name of the event to track
145148
- `options` (object):
146149
- `headers` (Headers): Request headers
@@ -154,14 +157,12 @@ Track a custom event on the server.
154157
MIT License - see the [LICENSE](LICENSE) file for details.
155158

156159
<!-- Badges -->
160+
157161
[npm-version-src]: https://img.shields.io/npm/v/@simpleanalytics/nuxt/latest.svg?style=flat&colorA=020420&colorB=00DC82
158162
[npm-version-href]: https://npmjs.com/package/@simpleanalytics/nuxt
159-
160163
[npm-downloads-src]: https://img.shields.io/npm/dm/@simpleanalytics/nuxt.svg?style=flat&colorA=020420&colorB=00DC82
161164
[npm-downloads-href]: https://npm.chart.dev/@simpleanalytics/nuxt
162-
163165
[license-src]: https://img.shields.io/npm/l/@simpleanalytics/nuxt.svg?style=flat&colorA=020420&colorB=00DC82
164166
[license-href]: https://npmjs.com/package/@simpleanalytics/nuxt
165-
166167
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
167168
[nuxt-href]: https://nuxt.com

0 commit comments

Comments
 (0)