Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/[lang]/(marketing)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HomeLayout } from 'fumadocs-ui/layouts/home'
import { baseOptions } from '@/lib/layout.shared'
import { isAppLocale } from '@/lib/i18n'

/** Standalone pages outside the docs tree (/plugins, /roadmap), in both languages. */
/** Standalone pages outside the docs tree (/plugins, /roadmap, /privacy), in both languages. */
export default async function MarketingLayout({
children,
params,
Expand Down
125 changes: 125 additions & 0 deletions app/[lang]/(marketing)/privacy/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import type { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { isAppLocale, type AppLocale } from '@/lib/i18n'
import { OptOut } from '@/components/analytics-opt-out'

type Props = { params: Promise<{ lang: string }> }

type Copy = {
metaTitle: string
title: string
intro: string
sections: Array<{ title: string; items: string[] }>
optOut: { title: string; body: string; off: string; on: string; disabled: string; enabled: string }
contact: string
}

const copy: Record<AppLocale, Copy> = {
en: {
metaTitle: 'Privacy',
title: 'Privacy',
intro:
'easyp.tech counts visits with Umami, an open-source analytics tool that we run on our own server (pulse.sipki.tech). No cookies, no advertising networks, nothing is sold or shared.',
sections: [
{
title: 'What is collected',
items: [
'Pages you open, the site you came from and UTM tags in the link.',
'Browser, operating system, device type, screen size, language, and country and city derived from the IP address. The IP address itself is not stored.',
'Clicks on a few buttons: copying the install command, code examples and plugin settings, switching language, opening search, links to other sites.',
'What you type into the plugin catalog search, so we can see which plugins people look for.',
'How fast pages load (Web Vitals) and JavaScript errors in your browser.',
'A recording of how you move around a page (scrolls, clicks, what is on the screen), used to find places where the docs are confusing. Input fields are hidden in the recording.',
],
},
{
title: 'What is not collected',
items: [
'Names, emails or accounts: the site has no sign-in.',
'Anything that follows you to other sites.',
],
},
],
optOut: {
title: 'Turning it off',
body: 'The switch below is remembered in this browser and stops both counting and recording.',
off: 'Turn off analytics in this browser',
on: 'Turn analytics back on',
disabled: 'Analytics is off in this browser.',
enabled: 'Analytics is on in this browser.',
},
contact:
'Questions, or want your data removed? Write to us in Telegram (t.me/easyptech) or open an issue on GitHub (github.com/easyp-tech/easyp).',
},
ru: {
metaTitle: 'Приватность',
title: 'Приватность',
intro:
'easyp.tech считает посещения с помощью Umami — открытой системы аналитики, которая работает на нашем собственном сервере (pulse.sipki.tech). Без cookie и рекламных сетей, данные никому не продаются и не передаются.',
sections: [
{
title: 'Что собирается',
items: [
'Какие страницы вы открываете, с какого сайта пришли и UTM-метки в ссылке.',
'Браузер, операционная система, тип устройства, размер экрана, язык, а также страна и город, определённые по IP-адресу. Сам IP-адрес не сохраняется.',
'Нажатия на несколько кнопок: копирование команды установки, примеров кода и настроек плагинов, смена языка, открытие поиска, ссылки на другие сайты.',
'Что вы ищете в каталоге плагинов, чтобы видеть, каких плагинов не хватает.',
'Скорость загрузки страниц (Web Vitals) и ошибки JavaScript в браузере.',
'Запись того, как вы двигаетесь по странице (прокрутка, нажатия, что на экране), чтобы находить места, где документация непонятна. Поля ввода в записи скрыты.',
],
},
{
title: 'Что не собирается',
items: [
'Имена, почта и учётные записи: входа на сайте нет.',
'Ничего, что следило бы за вами на других сайтах.',
],
},
],
optOut: {
title: 'Как отключить',
body: 'Переключатель ниже запоминается в этом браузере и выключает и подсчёт, и запись.',
off: 'Отключить аналитику в этом браузере',
on: 'Включить аналитику обратно',
disabled: 'Аналитика в этом браузере выключена.',
enabled: 'Аналитика в этом браузере включена.',
},
contact:
'Вопросы или хотите, чтобы мы удалили ваши данные? Напишите нам в Telegram (t.me/easyptech) или в issue на GitHub (github.com/easyp-tech/easyp).',
},
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { lang } = await params
if (!isAppLocale(lang)) notFound()
return { title: copy[lang].metaTitle }
}

export default async function PrivacyPage({ params }: Props) {
const { lang } = await params
if (!isAppLocale(lang)) notFound()
const c = copy[lang]

return (
<main className="mx-auto w-full max-w-3xl px-6 pt-24 pb-24 text-fd-foreground lg:pt-32">
<h1 className="mb-6 text-4xl font-bold tracking-tight">{c.title}</h1>
<p className="mb-10 leading-relaxed text-fd-muted-foreground">{c.intro}</p>
{c.sections.map((section) => (
<section key={section.title} className="mb-10">
<h2 className="mb-3 text-xl font-semibold">{section.title}</h2>
<ul className="list-disc space-y-2 pl-5 leading-relaxed text-fd-muted-foreground">
{section.items.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
</section>
))}
<section className="mb-10">
<h2 className="mb-3 text-xl font-semibold">{c.optOut.title}</h2>
<p className="mb-4 leading-relaxed text-fd-muted-foreground">{c.optOut.body}</p>
<OptOut labels={c.optOut} />
</section>
<p className="leading-relaxed text-fd-muted-foreground">{c.contact}</p>
</main>
)
}
2 changes: 1 addition & 1 deletion app/[lang]/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function Page({
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription className="mb-0">{page.data.description}</DocsDescription>
<div className="flex flex-row gap-2 items-center border-b pb-6">
<div data-page-actions className="flex flex-row gap-2 items-center border-b pb-6">
<MarkdownCopyButton markdownUrl={markdownUrl} />
<ViewOptionsPopover
markdownUrl={markdownUrl}
Expand Down
15 changes: 11 additions & 4 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import './global.css'
import { Inter, JetBrains_Mono } from 'next/font/google'
import Script from 'next/script'
import { Analytics } from '@/components/analytics'
import { siteHost, umamiHost, umamiWebsiteId } from '@/lib/analytics'
import type { ReactNode } from 'react'
import { I18nRootProvider } from '@/components/i18n-root'
import { i18n } from '@/lib/i18n'
Expand Down Expand Up @@ -47,13 +49,18 @@ export default function Layout({ children }: { children: ReactNode }) {
<body className="flex min-h-screen flex-col antialiased">
<I18nRootProvider locale={i18n.defaultLanguage}>{children}</I18nRootProvider>
{/* Umami on sipki.tech (pulse.sipki.tech, team EasyP). data-domains keeps
local runs and previews out of the stats. */}
local runs and previews out of the stats. Performance: Web Vitals of
real visits; errors: uncaught JS errors. What is collected is listed
on /privacy. */}
<Script
src="https://pulse.sipki.tech/u.js"
data-website-id="6a3c3583-67aa-49ed-8c19-837751e72374"
data-domains="easyp.tech"
src={`${umamiHost}/u.js`}
data-website-id={umamiWebsiteId}
data-domains={siteHost}
data-performance="true"
data-errors="true"
strategy="afterInteractive"
/>
<Analytics />
</body>
</html>
)
Expand Down
8 changes: 8 additions & 0 deletions app/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { MetadataRoute } from 'next'

export default function robots(): MetadataRoute.Robots {
return {
rules: { userAgent: '*', allow: '/' },
sitemap: 'https://easyp.tech/sitemap.xml',
}
}
40 changes: 40 additions & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { MetadataRoute } from 'next'
import { source } from '@/lib/source'
import { i18n, type AppLocale } from '@/lib/i18n'
import { hrefForLocale } from '@/lib/locale-path'
import { localizedPages } from '@/lib/shared'

const origin = 'https://easyp.tech'

function languages(paths: Partial<Record<AppLocale, string>>): Record<string, string> {
const out: Record<string, string> = {}
for (const [lang, path] of Object.entries(paths)) if (path) out[lang] = origin + path
return out
}

/** /sitemap.xml for search engines: home, standalone pages and every docs page in each language it exists in. */
export default function sitemap(): MetadataRoute.Sitemap {
const entries: MetadataRoute.Sitemap = [{ url: `${origin}/` }]

for (const page of localizedPages) {
const paths = Object.fromEntries(i18n.languages.map((lang) => [lang, hrefForLocale(lang, page)]))
for (const lang of i18n.languages) {
entries.push({ url: origin + paths[lang], alternates: { languages: languages(paths) } })
}
}

for (const lang of i18n.languages) {
for (const page of source.getPages(lang)) {
// With fallbackLanguage, a missing translation is served in English; list only real ones.
if ((page.locale ?? i18n.defaultLanguage) !== lang) continue
const paths: Partial<Record<AppLocale, string>> = {}
for (const other of i18n.languages) {
const translated = source.getPage(page.slugs, other)
if (translated && (translated.locale ?? i18n.defaultLanguage) === other) paths[other] = translated.url
}
entries.push({ url: origin + page.url, alternates: { languages: languages(paths) } })
}
}

return entries
}
49 changes: 49 additions & 0 deletions components/analytics-opt-out.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use client'

import { useEffect, useState } from 'react'

/** Umami's own opt-out flag: u.js checks it on every event, Analytics checks it before loading the recorder. */
const key = 'umami.disabled'

export function OptOut({
labels,
}: {
labels: { off: string; on: string; disabled: string; enabled: string }
}) {
const [disabled, setDisabled] = useState<boolean | null>(null)

useEffect(() => {
try {
setDisabled(Boolean(window.localStorage.getItem(key)))
} catch {
setDisabled(null)
}
}, [])

const toggle = () => {
try {
if (disabled) window.localStorage.removeItem(key)
else window.localStorage.setItem(key, '1')
setDisabled(!disabled)
} catch {
// Storage is blocked; nothing to remember the choice in.
}
}

if (disabled === null) return null

return (
<div className="flex flex-wrap items-center gap-4">
<button
type="button"
onClick={toggle}
className="cursor-pointer rounded-lg border border-fd-border px-4 py-2 text-sm font-medium transition-colors hover:border-fd-primary/50 hover:text-fd-primary"
>
{disabled ? labels.on : labels.off}
</button>
<span className="text-sm text-fd-muted-foreground" aria-live="polite">
{disabled ? labels.disabled : labels.enabled}
</span>
</div>
)
}
88 changes: 88 additions & 0 deletions components/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
'use client'

import { useEffect } from 'react'
import { siteHost, track, umamiHost, umamiWebsiteId } from '@/lib/analytics'

/**
* Clicks on elements fumadocs renders for us (code block copy, search, page
* actions) and on links that leave the site. Our own components call
* `track` directly. Mounted once in the root layout: I18nRootProvider is
* mounted twice, a listener there would count every click twice.
*/
function onClick(event: MouseEvent) {
const target = event.target
if (!(target instanceof Element)) return

const codeCopy = target.closest('figure.shiki button[aria-label]')
if (codeCopy) {
// After a copy the button shows "Copied" for a while; clicks then are not new copies.
if (!codeCopy.hasAttribute('data-checked')) track('copy-code')
return
}

if (target.closest('button[data-search], button[data-search-full]')) {
track('search-open')
return
}

// MarkdownCopyButton; the popover trigger next to it has aria-expanded.
const pageAction = target.closest('[data-page-actions] button')
if (pageAction) {
if (!pageAction.hasAttribute('aria-expanded')) track('docs-action', { action: 'copy-markdown' })
return
}

const link = target.closest('a[href]')
if (!(link instanceof HTMLAnchorElement)) return
let url: URL
try {
url = new URL(link.href, window.location.href)
} catch {
return
}
if (url.protocol !== 'https:' && url.protocol !== 'http:') return

if (url.host === window.location.host) {
if (url.pathname.startsWith('/llms.mdx/')) track('docs-action', { action: 'view-markdown' })
return
}

// Query strings are dropped: the "Open in ChatGPT/Claude" links carry the page as a prompt.
const href = `${url.host}${url.pathname}`.slice(0, 200)
if (url.host === 'github.com' && url.pathname.startsWith('/easyp-tech/')) {
track('outbound-github', { href })
} else {
track('outbound', { host: url.host, href })
}
}

/**
* Session replays and heatmaps (settings live on the website in Umami:
* masking, sample rate). Unlike u.js, recorder.js ignores data-domains, so it
* is only added on the real site.
*/
function loadRecorder() {
if (window.location.hostname !== siteHost) return
if (document.querySelector('script[data-umami-recorder]')) return
// The opt-out from /privacy; u.js honours it itself, recorder.js does not.
try {
if (window.localStorage.getItem('umami.disabled')) return
} catch {
// Storage blocked: carry on, u.js decides for itself.
}
const script = document.createElement('script')
script.src = `${umamiHost}/recorder.js`
script.defer = true
script.dataset.websiteId = umamiWebsiteId
script.dataset.umamiRecorder = ''
document.body.appendChild(script)
}

export function Analytics() {
useEffect(() => {
loadRecorder()
document.addEventListener('click', onClick, { capture: true })
return () => document.removeEventListener('click', onClick, { capture: true })
}, [])
return null
}
3 changes: 3 additions & 0 deletions components/home/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export function Footer() {
</div>
<div className="mt-16 flex flex-col items-center justify-between border-t border-fd-border pt-8 text-xs text-fd-muted-foreground md:flex-row">
<p>{t.rights}</p>
<Link href="/privacy" className="mt-4 transition-colors hover:text-fd-primary md:mt-0">
{t.privacy}
</Link>
</div>
</div>
</footer>
Expand Down
3 changes: 3 additions & 0 deletions components/home/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useState, useEffect, useRef } from 'react'
import { Shield, ChevronRight, ChevronDown, Copy, CheckCircle } from 'lucide-react'
import Link from 'next/link'
import { en } from '@/lib/home-copy'
import { track } from '@/lib/analytics'

interface InstallOption {
id: string
Expand Down Expand Up @@ -57,6 +58,7 @@ export function Hero({ version = 'vX.X.X' }: { version?: string }) {
try {
await navigator.clipboard.writeText(activeOption.cmd)
setCopied(true)
track('copy-install', { method: activeOption.id })
window.setTimeout(() => setCopied(false), 2000)
} catch {
setCopied(false)
Expand Down Expand Up @@ -148,6 +150,7 @@ export function Hero({ version = 'vX.X.X' }: { version?: string }) {
onClick={() => {
setInstallMethod(opt.id)
setIsDropdownOpen(false)
track('install-method', { method: opt.id })
}}
className={`group flex w-full cursor-pointer items-center justify-between px-4 py-3 text-left text-sm transition-colors ${
installMethod === opt.id
Expand Down
Loading
Loading