doccupine 0.0.126 → 0.0.128
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/index.js +1 -3
- package/dist/templates/app/api/rag/route.d.ts +1 -1
- package/dist/templates/app/api/rag/route.js +1 -1
- package/dist/templates/components/PostHogProviderLazy.d.ts +1 -1
- package/dist/templates/components/PostHogProviderLazy.js +21 -1
- package/dist/templates/mdx/accordion.mdx.d.ts +1 -1
- package/dist/templates/mdx/accordion.mdx.js +0 -1
- package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/ai-assistant.mdx.js +0 -1
- package/dist/templates/mdx/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/analytics.mdx.js +23 -6
- package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
- package/dist/templates/mdx/authentication.mdx.js +0 -1
- package/dist/templates/mdx/buttons.mdx.d.ts +1 -1
- package/dist/templates/mdx/buttons.mdx.js +0 -1
- package/dist/templates/mdx/callouts.mdx.d.ts +1 -1
- package/dist/templates/mdx/callouts.mdx.js +0 -1
- package/dist/templates/mdx/cards.mdx.d.ts +1 -1
- package/dist/templates/mdx/cards.mdx.js +0 -1
- package/dist/templates/mdx/code.mdx.d.ts +1 -1
- package/dist/templates/mdx/code.mdx.js +0 -1
- package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
- package/dist/templates/mdx/color-swatches.mdx.js +0 -1
- package/dist/templates/mdx/columns.mdx.d.ts +1 -1
- package/dist/templates/mdx/columns.mdx.js +0 -1
- package/dist/templates/mdx/commands.mdx.d.ts +1 -1
- package/dist/templates/mdx/commands.mdx.js +0 -1
- package/dist/templates/mdx/components.mdx.d.ts +1 -1
- package/dist/templates/mdx/components.mdx.js +0 -1
- package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
- package/dist/templates/mdx/deployment-and-hosting.mdx.js +0 -1
- package/dist/templates/mdx/fields.mdx.d.ts +1 -1
- package/dist/templates/mdx/fields.mdx.js +0 -1
- package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
- package/dist/templates/mdx/fonts.mdx.js +0 -1
- package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
- package/dist/templates/mdx/footer-links.mdx.js +0 -1
- package/dist/templates/mdx/globals.mdx.d.ts +1 -1
- package/dist/templates/mdx/globals.mdx.js +0 -1
- package/dist/templates/mdx/headers-and-text.mdx.d.ts +1 -1
- package/dist/templates/mdx/headers-and-text.mdx.js +0 -1
- package/dist/templates/mdx/icons.mdx.d.ts +1 -1
- package/dist/templates/mdx/icons.mdx.js +0 -1
- package/dist/templates/mdx/image-and-embeds.mdx.d.ts +1 -1
- package/dist/templates/mdx/image-and-embeds.mdx.js +0 -1
- package/dist/templates/mdx/index.mdx.d.ts +1 -1
- package/dist/templates/mdx/index.mdx.js +0 -1
- package/dist/templates/mdx/lists-and-tables.mdx.d.ts +1 -1
- package/dist/templates/mdx/lists-and-tables.mdx.js +0 -1
- package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
- package/dist/templates/mdx/media-and-assets.mdx.js +0 -1
- package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
- package/dist/templates/mdx/mermaid.mdx.js +0 -1
- package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.js +0 -1
- package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
- package/dist/templates/mdx/navigation.mdx.js +0 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.js +0 -1
- package/dist/templates/mdx/platform/analytics.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/analytics.mdx.js +1 -2
- package/dist/templates/mdx/platform/billing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/billing.mdx.js +0 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.js +0 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/creating-a-project.mdx.js +0 -1
- package/dist/templates/mdx/platform/custom-domains.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/custom-domains.mdx.js +0 -1
- package/dist/templates/mdx/platform/external-links.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/external-links.mdx.js +0 -1
- package/dist/templates/mdx/platform/file-editor.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/file-editor.mdx.js +41 -2
- package/dist/templates/mdx/platform/fonts-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/fonts-settings.mdx.js +0 -1
- package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/index.mdx.js +0 -1
- package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/mcp.mdx.js +0 -1
- package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/navigation-settings.mdx.js +0 -1
- package/dist/templates/mdx/platform/project-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/project-settings.mdx.js +0 -1
- package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/publishing.mdx.js +0 -1
- package/dist/templates/mdx/platform/site-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/site-settings.mdx.js +0 -1
- package/dist/templates/mdx/platform/team-members.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/team-members.mdx.js +0 -1
- package/dist/templates/mdx/platform/theme-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/theme-settings.mdx.js +0 -1
- package/dist/templates/mdx/sections.mdx.d.ts +1 -1
- package/dist/templates/mdx/sections.mdx.js +0 -1
- package/dist/templates/mdx/steps.mdx.d.ts +1 -1
- package/dist/templates/mdx/steps.mdx.js +0 -1
- package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
- package/dist/templates/mdx/tabs.mdx.js +0 -1
- package/dist/templates/mdx/theme.mdx.d.ts +1 -1
- package/dist/templates/mdx/theme.mdx.js +0 -1
- package/dist/templates/mdx/update.mdx.d.ts +1 -1
- package/dist/templates/mdx/update.mdx.js +0 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
- package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -2
- package/dist/templates/next.config.js +5 -4
- package/dist/templates/package.js +6 -7
- package/dist/templates/proxy.js +118 -25
- package/package.json +1 -1
|
@@ -17,23 +17,22 @@ export const packageJsonTemplate = JSON.stringify({
|
|
|
17
17
|
"@langchain/openai": "^1.5.5",
|
|
18
18
|
"@mdx-js/react": "^3.1.1",
|
|
19
19
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
20
|
-
"@posthog/react": "^1.10.3",
|
|
21
20
|
"beautiful-mermaid": "^1.1.3",
|
|
22
21
|
"cherry-styled-components": "^0.2.11",
|
|
23
22
|
langchain: "^1.5.3",
|
|
24
|
-
"lucide-react": "^1.
|
|
23
|
+
"lucide-react": "^1.25.0",
|
|
25
24
|
minisearch: "^7.2.0",
|
|
26
25
|
next: "16.2.10",
|
|
27
26
|
"next-mdx-remote": "^6.0.0",
|
|
28
|
-
"posthog-js": "^1.
|
|
29
|
-
"posthog-node": "^5.45.
|
|
27
|
+
"posthog-js": "^1.404.1",
|
|
28
|
+
"posthog-node": "^5.45.2",
|
|
30
29
|
react: "19.2.7",
|
|
31
30
|
"react-dom": "19.2.7",
|
|
32
31
|
"rehype-highlight": "^7.0.2",
|
|
33
32
|
"rehype-parse": "^9.0.1",
|
|
34
33
|
"rehype-stringify": "^10.0.1",
|
|
35
34
|
"remark-gfm": "^4.0.1",
|
|
36
|
-
"styled-components": "^6.4.
|
|
35
|
+
"styled-components": "^6.4.4",
|
|
37
36
|
unified: "^11.0.5",
|
|
38
37
|
zod: "^4.4.3",
|
|
39
38
|
},
|
|
@@ -43,8 +42,8 @@ export const packageJsonTemplate = JSON.stringify({
|
|
|
43
42
|
"@types/node": "^26",
|
|
44
43
|
"@types/react": "^19",
|
|
45
44
|
"@types/react-dom": "^19",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
47
|
-
"@typescript-eslint/parser": "^8.
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
46
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
48
47
|
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|
|
49
48
|
eslint: "^10",
|
|
50
49
|
"eslint-plugin-import": "^2.32.0",
|
package/dist/templates/proxy.js
CHANGED
|
@@ -8,36 +8,96 @@ export const proxyTemplate = (analyticsConfig = null) => {
|
|
|
8
8
|
? `
|
|
9
9
|
const SKIP_PAGEVIEW_PATTERN = /^\\/(api|ingest|_next)\\//;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
/**
|
|
12
|
+
* First-party anonymous id.
|
|
13
|
+
*
|
|
14
|
+
* posthog-js keeps its own id in \`ph_<key>_posthog\`, but an ad blocker stops
|
|
15
|
+
* that script from ever running, so a blocked reader never gets one. Without an
|
|
16
|
+
* id of our own we minted a fresh UUID per request, which made every single
|
|
17
|
+
* pageview a brand-new "person" and badly inflated unique-visitor counts. This
|
|
18
|
+
* cookie is what makes one anonymous reader one person across requests.
|
|
19
|
+
*
|
|
20
|
+
* It is first-party and httpOnly: only the edge reads it, and it never leaves
|
|
21
|
+
* your domain except as a PostHog distinct_id.
|
|
22
|
+
*/
|
|
23
|
+
const ANON_ID_COOKIE = "dcp_anon_id";
|
|
24
|
+
|
|
25
|
+
const ANON_ID_MAX_AGE = 60 * 60 * 24 * 365;
|
|
26
|
+
|
|
27
|
+
interface TrackingIdentity {
|
|
28
|
+
distinctId: string;
|
|
29
|
+
/** Set only when the id was just minted and still needs writing to a cookie. */
|
|
30
|
+
anonIdToPersist?: string;
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
deviceId?: string;
|
|
33
|
+
}
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Resolves who this pageview belongs to: whatever posthog-js already
|
|
37
|
+
* established for this browser, else our own anonymous cookie, else a fresh id
|
|
38
|
+
* that the caller persists.
|
|
39
|
+
*/
|
|
40
|
+
function resolveTrackingIdentity(req: NextRequest): TrackingIdentity {
|
|
41
|
+
let distinctId: string | undefined;
|
|
42
|
+
let sessionId: string | undefined;
|
|
43
|
+
let deviceId: string | undefined;
|
|
23
44
|
|
|
24
45
|
const phCookie = req.cookies.get(
|
|
25
46
|
"ph_${analyticsConfig.posthog.key}_posthog",
|
|
26
47
|
)?.value;
|
|
27
|
-
let distinctId: string | undefined;
|
|
28
48
|
if (phCookie) {
|
|
29
49
|
try {
|
|
30
|
-
|
|
50
|
+
const parsed = JSON.parse(phCookie);
|
|
51
|
+
if (typeof parsed.distinct_id === "string") distinctId = parsed.distinct_id;
|
|
52
|
+
// \`$sesid\` is [lastActivityTs, sessionId, sessionStartTs]. Forwarding it
|
|
53
|
+
// keeps server events inside the client's session instead of floating free.
|
|
54
|
+
if (Array.isArray(parsed.$sesid) && typeof parsed.$sesid[1] === "string") {
|
|
55
|
+
sessionId = parsed.$sesid[1];
|
|
56
|
+
}
|
|
57
|
+
if (typeof parsed.$device_id === "string") deviceId = parsed.$device_id;
|
|
31
58
|
} catch {
|
|
32
59
|
// ignore malformed cookie
|
|
33
60
|
}
|
|
34
61
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
62
|
+
|
|
63
|
+
if (distinctId) return { distinctId, sessionId, deviceId };
|
|
64
|
+
|
|
65
|
+
const anonId = req.cookies.get(ANON_ID_COOKIE)?.value;
|
|
66
|
+
if (anonId) return { distinctId: anonId, sessionId, deviceId };
|
|
67
|
+
|
|
68
|
+
const minted = crypto.randomUUID();
|
|
69
|
+
return { distinctId: minted, anonIdToPersist: minted, sessionId, deviceId };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Server captures document loads; the client tracker captures soft navigations.
|
|
74
|
+
* Splitting by navigation type is what stops the two from both counting the
|
|
75
|
+
* same view — previously every page load produced two \`$pageview\` events.
|
|
76
|
+
*/
|
|
77
|
+
function captureServerPageview(
|
|
78
|
+
req: NextRequest,
|
|
79
|
+
event: NextFetchEvent,
|
|
80
|
+
): TrackingIdentity | null {
|
|
81
|
+
const pathname = req.nextUrl.pathname;
|
|
82
|
+
|
|
83
|
+
if (SKIP_PAGEVIEW_PATTERN.test(pathname)) return null;
|
|
84
|
+
|
|
85
|
+
const isPrefetch =
|
|
86
|
+
req.headers.get("next-router-prefetch") === "1" ||
|
|
87
|
+
req.headers.get("purpose") === "prefetch";
|
|
88
|
+
if (isPrefetch) return null;
|
|
89
|
+
|
|
90
|
+
// A soft navigation fetches an RSC payload rather than a document, and
|
|
91
|
+
// carries this header. The client tracker owns those.
|
|
92
|
+
if (req.headers.get("RSC")) return null;
|
|
93
|
+
|
|
94
|
+
const posthog = getPostHogServerClient();
|
|
95
|
+
if (!posthog) return null;
|
|
96
|
+
|
|
97
|
+
const identity = resolveTrackingIdentity(req);
|
|
38
98
|
|
|
39
99
|
posthog.capture({
|
|
40
|
-
distinctId,
|
|
100
|
+
distinctId: identity.distinctId,
|
|
41
101
|
event: "$pageview",
|
|
42
102
|
properties: {
|
|
43
103
|
$current_url: req.url,
|
|
@@ -45,16 +105,46 @@ function captureServerPageview(req: NextRequest, event: NextFetchEvent) {
|
|
|
45
105
|
$host: req.headers.get("host") ?? undefined,
|
|
46
106
|
$referrer: req.headers.get("referer") ?? undefined,
|
|
47
107
|
$user_agent: req.headers.get("user-agent") ?? undefined,
|
|
108
|
+
$session_id: identity.sessionId,
|
|
109
|
+
$device_id: identity.deviceId,
|
|
48
110
|
_server_side: true,
|
|
49
111
|
},
|
|
50
112
|
});
|
|
51
113
|
event.waitUntil(posthog.flush());
|
|
114
|
+
|
|
115
|
+
return identity;
|
|
52
116
|
}
|
|
53
117
|
`
|
|
54
118
|
: "";
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
119
|
+
// Applied at every exit so the anonymous id is persisted whichever branch the
|
|
120
|
+
// request takes (gate rewrite, redirect, or the normal response). Without it
|
|
121
|
+
// a reader stuck behind the password gate would keep minting new ids.
|
|
122
|
+
const applyTrackingFn = hasPostHog
|
|
123
|
+
? `
|
|
124
|
+
function applyTracking(
|
|
125
|
+
res: NextResponse,
|
|
126
|
+
tracking: TrackingIdentity | null,
|
|
127
|
+
): NextResponse {
|
|
128
|
+
if (tracking?.anonIdToPersist) {
|
|
129
|
+
res.cookies.set(ANON_ID_COOKIE, tracking.anonIdToPersist, {
|
|
130
|
+
path: "/",
|
|
131
|
+
maxAge: ANON_ID_MAX_AGE,
|
|
132
|
+
sameSite: "lax",
|
|
133
|
+
httpOnly: true,
|
|
134
|
+
secure: process.env.NODE_ENV === "production",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return res;
|
|
138
|
+
}
|
|
139
|
+
`
|
|
140
|
+
: `
|
|
141
|
+
function applyTracking(res: NextResponse, _tracking: null): NextResponse {
|
|
142
|
+
return res;
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
const trackingInit = hasPostHog
|
|
146
|
+
? ` const tracking = captureServerPageview(req, event);\n`
|
|
147
|
+
: ` const tracking = null;\n`;
|
|
58
148
|
const fnSignature = hasPostHog
|
|
59
149
|
? `export async function proxy(req: NextRequest, event: NextFetchEvent)`
|
|
60
150
|
: `export async function proxy(req: NextRequest)`;
|
|
@@ -73,9 +163,9 @@ function captureServerPageview(req: NextRequest, event: NextFetchEvent) {
|
|
|
73
163
|
const matcher = `["/:path*"]`;
|
|
74
164
|
return `import { NextResponse } from "next/server";
|
|
75
165
|
import type { NextRequest${eventImport} } from "next/server";
|
|
76
|
-
${gateImport}${posthogImport}${posthogPageviewFn}
|
|
166
|
+
${gateImport}${posthogImport}${posthogPageviewFn}${applyTrackingFn}
|
|
77
167
|
${fnSignature} {
|
|
78
|
-
${
|
|
168
|
+
${trackingInit} const pathname = req.nextUrl.pathname;
|
|
79
169
|
const sitePassword = process.env.SITE_PASSWORD;
|
|
80
170
|
|
|
81
171
|
// API key auth for /api/mcp when DOCS_API_KEY is configured
|
|
@@ -119,12 +209,15 @@ ${posthogCall} const pathname = req.nextUrl.pathname;
|
|
|
119
209
|
if (!unlocked && !pathname.startsWith("/api") && pathname !== "/gate") {
|
|
120
210
|
const res = NextResponse.rewrite(new URL("/gate", req.url));
|
|
121
211
|
res.headers.set("X-Robots-Tag", "noindex, nofollow");
|
|
122
|
-
return res;
|
|
212
|
+
return applyTracking(res, tracking);
|
|
123
213
|
}
|
|
124
214
|
|
|
125
215
|
// Unlocked visitors never need the gate screen.
|
|
126
216
|
if (unlocked && pathname === "/gate") {
|
|
127
|
-
return
|
|
217
|
+
return applyTracking(
|
|
218
|
+
NextResponse.redirect(new URL("/", req.url)),
|
|
219
|
+
tracking,
|
|
220
|
+
);
|
|
128
221
|
}
|
|
129
222
|
}
|
|
130
223
|
|
|
@@ -136,7 +229,7 @@ ${posthogCall} const pathname = req.nextUrl.pathname;
|
|
|
136
229
|
res.headers.set("X-Robots-Tag", "noindex, nofollow");
|
|
137
230
|
}
|
|
138
231
|
|
|
139
|
-
return res;
|
|
232
|
+
return applyTracking(res, tracking);
|
|
140
233
|
}
|
|
141
234
|
|
|
142
235
|
export const config = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doccupine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.128",
|
|
4
4
|
"description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|