Skip to content

Commit b6e802c

Browse files
committed
refactor(repo): run prettier
1 parent 1b96529 commit b6e802c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Simple Analytics for Next.js
22

3-
43
This package provides a simple way to add privacy-friendly pageview and event tracking using Simple Analytics to your Next.js application.
54

65
## Documentation
@@ -48,7 +47,7 @@ export default function RootLayout({
4847
<html lang="en">
4948
<body>
5049
{children}
51-
<SimpleAnalytics/>
50+
<SimpleAnalytics />
5251
</body>
5352
</html>
5453
);
@@ -58,6 +57,7 @@ export default function RootLayout({
5857
### Tracking events
5958

6059
#### Usage in client components
60+
6161
To start tracking programmatically tracking events in client components use the `trackEvent` function.
6262
This requires the `<SimpleAnalytics />` component to be present on the page or layout.
6363

@@ -84,7 +84,7 @@ export default function Page() {
8484

8585
#### Usage in Server Actions
8686

87-
To track events in server actions, use the `trackEvent` function from `@simpleanalytics/next/server`.
87+
To track events in server actions, use the `trackEvent` function from `@simpleanalytics/next/server`.
8888
This function requires you to pass the request headers that can be obtained using `headers`.
8989

9090
```typescript

packages/analytics/src/server/headers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export function parseUserAgent(headers: Headers) {
3838
return headers.get("User-Agent") ?? "";
3939
}
4040

41-
export function parseHeaders(headers: Headers, ignoredMetrics: IgnoredMetrics = {}) {
41+
export function parseHeaders(
42+
headers: Headers,
43+
ignoredMetrics: IgnoredMetrics = {},
44+
) {
4245
return {
4346
ua: !ignoredMetrics.userAgent ? parseUserAgent(headers) : "",
4447

packages/analytics/src/server/simple-analytics.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "server-only";
22

3-
import {
3+
import type {
44
AnalyticsEvent,
55
AnalyticsPageview,
66
TrackingOptions,
@@ -97,8 +97,10 @@ export async function trackPageview(options: TrackPageviewOptions) {
9797
event: "pageview",
9898
path,
9999
...parseHeaders(headers, options.ignoreMetrics),
100-
...(searchParams
101-
? parseUtmParameters(searchParams, { strictUtm: options.strictUtm ?? true })
100+
...(searchParams && !options.ignoreMetrics?.utm
101+
? parseUtmParameters(searchParams, {
102+
strictUtm: options.strictUtm ?? true,
103+
})
102104
: {}),
103105
};
104106

0 commit comments

Comments
 (0)