@nextlytics/core 0.6.0 → 0.7.0-canary.117
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/dist/middleware.js +8 -1
- package/dist/uitils.d.ts +11 -0
- package/dist/uitils.js +3 -0
- package/package.json +1 -1
package/dist/middleware.js
CHANGED
|
@@ -59,6 +59,8 @@ function createNextlyticsMiddleware(config, dispatchEvent, updateEvent, collectT
|
|
|
59
59
|
integrity: request.integrity,
|
|
60
60
|
isPrefetch: reqInfo.isPrefetch,
|
|
61
61
|
isRsc: reqInfo.isRsc,
|
|
62
|
+
isDocumentRequest: reqInfo.isDocumentRequest,
|
|
63
|
+
isBrowserSubrequest: reqInfo.isBrowserSubrequest,
|
|
62
64
|
isPageNavigation: reqInfo.isPageNavigation,
|
|
63
65
|
isStaticFile: reqInfo.isStaticFile,
|
|
64
66
|
isNextjsInternal: reqInfo.isNextjsInternal,
|
|
@@ -76,7 +78,12 @@ function createNextlyticsMiddleware(config, dispatchEvent, updateEvent, collectT
|
|
|
76
78
|
response2.headers.set(import_server_component_context.headerNames.active, "1");
|
|
77
79
|
return response2;
|
|
78
80
|
}
|
|
79
|
-
if (
|
|
81
|
+
if (reqInfo.isBrowserSubrequest && !config.isApiPath(pathname)) {
|
|
82
|
+
const response2 = import_server.NextResponse.next();
|
|
83
|
+
response2.headers.set(import_server_component_context.headerNames.active, "1");
|
|
84
|
+
return response2;
|
|
85
|
+
}
|
|
86
|
+
if (request.method !== "GET" && !reqInfo.isDocumentRequest && !config.isApiPath(pathname)) {
|
|
80
87
|
const response2 = import_server.NextResponse.next();
|
|
81
88
|
response2.headers.set(import_server_component_context.headerNames.active, "1");
|
|
82
89
|
return response2;
|
package/dist/uitils.d.ts
CHANGED
|
@@ -16,6 +16,17 @@ type RequestInfo = {
|
|
|
16
16
|
isPrefetch: boolean;
|
|
17
17
|
/** True if this is an RSC (React Server Components) navigation */
|
|
18
18
|
isRsc: boolean;
|
|
19
|
+
/** True if this is a hard document navigation (sec-fetch-dest=document or
|
|
20
|
+
* sec-fetch-mode=navigate) — the strong signal, distinct from the weaker
|
|
21
|
+
* accepts-HTML heuristic folded into isPageNavigation. */
|
|
22
|
+
isDocumentRequest: boolean;
|
|
23
|
+
/** True if this is a browser-initiated sub-request (RSC soft-navigation, XHR,
|
|
24
|
+
* fetch(), or a subresource) — Sec-Fetch-Dest is present and is not
|
|
25
|
+
* "document". Modern browsers always send Sec-Fetch-Dest (it's a forbidden
|
|
26
|
+
* header, so it can't be spoofed); non-browser clients (curl, agents, bots,
|
|
27
|
+
* server-to-server) omit it. Used to skip soft-navigation RSC fetches, which
|
|
28
|
+
* carry no reliable RSC header in Next 15.5+ yet must not be double-counted. */
|
|
29
|
+
isBrowserSubrequest: boolean;
|
|
19
30
|
/** True if this is a standard document or RSC navigation */
|
|
20
31
|
isPageNavigation: boolean;
|
|
21
32
|
/** True if this is a static file (ico, png, css, js, etc.) */
|
package/dist/uitils.js
CHANGED
|
@@ -81,6 +81,7 @@ function getRequestInfo(request) {
|
|
|
81
81
|
const secFetchMode = headers.get("sec-fetch-mode");
|
|
82
82
|
const accept = headers.get("accept") || "";
|
|
83
83
|
const isDocumentRequest = secFetchDest === "document" || secFetchMode === "navigate";
|
|
84
|
+
const isBrowserSubrequest = secFetchDest !== null && !isDocumentRequest;
|
|
84
85
|
const acceptsHtml = accept.includes("text/html");
|
|
85
86
|
const isPageNavigation = isDocumentRequest || acceptsHtml;
|
|
86
87
|
const isRscPrefetch = nextUrl !== null && nextUrl !== pathname;
|
|
@@ -88,6 +89,8 @@ function getRequestInfo(request) {
|
|
|
88
89
|
return {
|
|
89
90
|
isPrefetch,
|
|
90
91
|
isRsc,
|
|
92
|
+
isDocumentRequest,
|
|
93
|
+
isBrowserSubrequest,
|
|
91
94
|
isPageNavigation,
|
|
92
95
|
isStaticFile,
|
|
93
96
|
isNextjsInternal
|