@akinon/next 1.26.0-rc.7 → 1.26.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/api/web-vitals.ts +15 -0
- package/components/pz-root.tsx +2 -0
- package/components/web-vitals.tsx +33 -0
- package/middlewares/default.ts +14 -0
- package/middlewares/index.ts +1 -0
- package/middlewares/pretty-url.ts +2 -0
- package/package.json +1 -1
- package/types/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.26.0-rc.9
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6d4aadb: ZERO-2476: Auto install recommendenent extension
|
|
8
|
+
- a7e432f: ZERO-2534: Fix for recapthca regex for replacing the special chars.
|
|
9
|
+
- 02fa342: ZERO-2507: Add web vitals endpoint
|
|
10
|
+
- 7e41bdc: BRDG-9158: Remove redirect-three-d page endpoint
|
|
11
|
+
- f0c23bc: ZERO-2135: add custom not found page
|
|
12
|
+
- 1289982: ZERO-2521: Add x-forwarded-for header to requests
|
|
13
|
+
- 3690d3b: ZERO-2485: Check ESLint peerDependency version
|
|
14
|
+
- 40ad73e: ZERO-2504: add cookie filter to api client request
|
|
15
|
+
- b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
|
|
16
|
+
- b2da5e4: Revert ZERO-2435
|
|
17
|
+
- f76f079: ZERO-2493: Add redirect util function
|
|
18
|
+
- d6d2533: ZERO-2560: Add installment count to masterpass payment forms
|
|
19
|
+
- ff89630: ZERO-2498: Add script for env control
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- da1e501: ZERO-2296: Fix ROUTES import
|
|
24
|
+
- 073fbd2: ZERO-2503: Add check changeset control script
|
|
25
|
+
- 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
|
|
26
|
+
- 183674f: BRDG-9158: Handle locale prefix
|
|
27
|
+
- 8c7f5bc: ZERO-2440: Pipeline test
|
|
28
|
+
- Updated dependencies [073fbd2]
|
|
29
|
+
- @akinon/eslint-plugin-projectzero@1.26.0-rc.9
|
|
30
|
+
|
|
31
|
+
## 1.26.0-rc.8
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- f0c23bc: ZERO-2135: add custom not found page
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- @akinon/eslint-plugin-projectzero@1.26.0-rc.8
|
|
40
|
+
|
|
3
41
|
## 1.26.0-rc.7
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { trace, context } from '@opentelemetry/api';
|
|
3
|
+
|
|
4
|
+
export async function POST(req: Request) {
|
|
5
|
+
const { name, value, rating, page, pathname } = await req.json();
|
|
6
|
+
const span = trace.getSpan(context.active());
|
|
7
|
+
|
|
8
|
+
span?.setAttribute('page', page);
|
|
9
|
+
span?.setAttribute(name, value);
|
|
10
|
+
span?.setAttribute('rating', rating);
|
|
11
|
+
span?.setAttribute('pathname', pathname);
|
|
12
|
+
span?.end();
|
|
13
|
+
|
|
14
|
+
return NextResponse.json({ success: true });
|
|
15
|
+
}
|
package/components/pz-root.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import 'server-only';
|
|
|
2
2
|
import ClientRoot from './client-root';
|
|
3
3
|
import { cookies } from 'next/headers';
|
|
4
4
|
import PzProviders from './pz-providers';
|
|
5
|
+
import { WebVitals } from './web-vitals';
|
|
5
6
|
|
|
6
7
|
export default function PzRoot({
|
|
7
8
|
translations,
|
|
@@ -15,6 +16,7 @@ export default function PzRoot({
|
|
|
15
16
|
|
|
16
17
|
return (
|
|
17
18
|
<PzProviders translations={translations}>
|
|
19
|
+
<WebVitals />
|
|
18
20
|
<ClientRoot sessionId={sessionid}>{children}</ClientRoot>
|
|
19
21
|
</PzProviders>
|
|
20
22
|
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useReportWebVitals } from 'next/web-vitals';
|
|
4
|
+
import { useSelectedLayoutSegment } from 'next/navigation';
|
|
5
|
+
import { usePathname } from 'next/navigation';
|
|
6
|
+
|
|
7
|
+
export function WebVitals() {
|
|
8
|
+
let layoutSegment = useSelectedLayoutSegment();
|
|
9
|
+
const pathname = usePathname();
|
|
10
|
+
|
|
11
|
+
if (pathname === '/' && layoutSegment === null) {
|
|
12
|
+
layoutSegment = 'home';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
useReportWebVitals((metric) => {
|
|
16
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { name, value, rating } = metric;
|
|
21
|
+
const page = layoutSegment || 'unknown';
|
|
22
|
+
|
|
23
|
+
fetch(`${process.env.NEXT_PUBLIC_URL}/api/web-vitals`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json'
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({ name, value, rating, page, pathname })
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
package/middlewares/default.ts
CHANGED
|
@@ -153,6 +153,7 @@ const withPzDefault =
|
|
|
153
153
|
|
|
154
154
|
req.middlewareParams = {
|
|
155
155
|
commerceUrl,
|
|
156
|
+
found: true,
|
|
156
157
|
rewrites: {}
|
|
157
158
|
};
|
|
158
159
|
|
|
@@ -186,6 +187,19 @@ const withPzDefault =
|
|
|
186
187
|
locale.length ? `${locale}/` : ''
|
|
187
188
|
}${currency}${prettyUrl ?? pathnameWithoutLocale}`;
|
|
188
189
|
|
|
190
|
+
if (
|
|
191
|
+
!req.middlewareParams.found &&
|
|
192
|
+
Settings.customNotFoundEnabled
|
|
193
|
+
) {
|
|
194
|
+
let pathname = url.pathname
|
|
195
|
+
.replace(/\/+$/, '')
|
|
196
|
+
.split('/');
|
|
197
|
+
url.pathname = url.pathname.replace(
|
|
198
|
+
pathname.pop(),
|
|
199
|
+
'pz-not-found'
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
189
203
|
Settings.rewrites.forEach((rewrite) => {
|
|
190
204
|
url.pathname = url.pathname.replace(
|
|
191
205
|
rewrite.source,
|
package/middlewares/index.ts
CHANGED
package/package.json
CHANGED