Lines 320-357javascript
322`}function wn(e,t){if(!e.startsWith(`${xn}\n`))return!1;let n=[`export async function onRequest(context: EventContext): Promise<Response>`,"const targetUrl = `${apiBase}/fp/${path}${new URL(request.url).search}`",`const apiBase = env.NEXT_PUBLIC_API_URL || '${t}'`,`responseHeaders.set('X-Zenovay-Proxied', 'true')`,`export async function onRequestOptions`];return n.every(t=>e.includes(t))}async function Tn(e,t){let n=(t.apiBase||bn).replace(/\/+$/,``),r=C.join(e,`functions`,`api`,`_z`),i=C.join(r,`[[path]].ts`),a=Cn(n);try{let e=await w.readFile(i,`utf8`);return e===a?{file:i,action:`exists`}:w ...
324 source: '/api/_z/:path*',
325 destination: '${e}/fp/:path*',
326 },`}function kn(e){return`/** @type {import('next').NextConfig} */
335export default nextConfig;
336`}async function An(e,t={}){let n=t.apiBase??En,r=null;for(let t of Dn){let n=C.join(e,t);try{await j.access(n),r=n;break}catch{}}if(!r){let r=C.join(e,`next.config.mjs`);return await t.beforeWrite?.(r),await j.writeFile(r,kn(n),`utf8`),{file:r,action:`created`}}let i=await j.readFile(r,`utf8`),a=i.includes(`source: '/api/_z/:path*'`)||i.includes(`source: "/api/_z/:path*"`),o=i.includes(`destination: '${n}/fp/:path*'`)||i.includes(`destination: "${n}/fp/:path*"`);if(a&&o)return{file:r,action:`exists`};if(i.includes(`/api/_z/:path*`)||i.includes(`/_z/:path*`)||/\brewrites\s*(?::|=|\()/.test(i)| ...
341 },`,p=`${u}${f}${d}`;return await t.beforeWrite?.(r),await j.writeFile(r,p,`utf8`),{file:r,action:`updated`}}const jn=`https://api.zenovay.com`;async function Mn(e,t={}){let n=t.apiBase??jn,r=
344`);else{let e=a.length>0&&!a.endsWith(`
346`:``;f=`${a}${e}${l}\n${i}\n`}return await t.beforeWrite?.(r),await j.writeFile(r,f,`utf8`),{file:r,action:`updated`}}const In="Your tracker is already live and working — it counts visitors in Chrome, Firefox and most browsers, no further setup required. First-party tracking is OPTIONAL and adds the rest: Safari, Brave, and browsers with strict tracking prevention block analytics loaded from another company's domain, so to capture those visitors too you serve Zenovay from your OWN domain. That last step is wired at your hosting provider — enable it any time with `zenovay init --host cloudflare ...
347`)[0]:`unknown git error`;return{committed:!0,pushed:!1,shortSha:p,branch:d,reason:`push-failed`,pushError:t,message:`Commit ${p} was created locally, but it was not pushed. Run: git push origin ${d}`,unstagedPaths:o}}return e.onPhase?.(`done`),{committed:!0,pushed:!0,shortSha:p,branch:d,message:`Pushed ${p} to origin/${d}.`,unstagedPaths:o}}const ur=/<script\b[^>]*\bsrc\s*=\s*["'][^"']*(?:(?:api|cdn)\.zenovay\.com\/|\/(?:api\/)?_z\/script\.js)[^"']*["'][^>]*>/gi,dr=/\bsrc\s*=\s*["']([^"']+)["']/i,fr=/data-id
348`),0;let r;for(let t of n)if(await ge(t,e.cwd).catch(()=>!1)){r=t;break}if(!r){let t=`Nothing to undo — no init session belongs to this project.`;return c(e)?(s({type:`info`,message:t}),s({type:`done`
3503. Insert the tracker using the snippet below.
3514. Confirm the change with a diff before writing.
353Snippet reference (anchored by anchorKind — adapt to the actual file):
354`+_.map(e=>` ${e.anchorKind} @ ${e.targetPath}:\n ${e.code.replace(/\n/g,`
357`);c.setTasks([{id:`detect`,label:`Detect framework`,status:`active`},{id:`read`,label:`Read project entry files`,status:`pending`},{id:`write`,label:`Insert tracker snippet`,status:`pending`},{id:`env`,label:`Write env vars (.env.local)`,status:`pending`},{id:`mcp`,label:`Install MCP clients (Claude Code/Cursor/VS Code)`,status:`pending`},{id:`verify`,label:`
Long lines were clipped for display.