360 Secure SkillHub
360 安全技能中心

Install invisit

该 Skill 指导在网站或 Web 应用中接入 invisit 无 Cookie 分析:获取 site id,使用安装器或手动添加脚本或 npm 包,可选自定义事件,并在仪表盘验证访问是否到达。

分类:开发
berkinory
berkinory
热度 6.01
最近更新 2026-11-09 02:18:21

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add berkinory/install-invisit
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
install-invisit
description
Add invisit cookieless web analytics to a website or web app with the script tag or the @invisitdev/web npm package, then check that visits arrive. Use when asked to add invisit, privacy-friendly analytics, or a cookie-free Google Analytics alternative to a project.

Install invisit

invisit is cookieless web analytics: no cookies, no consent banner, realtime visitors, AI assistant referrals, revenue and web vitals. Full docs as Markdown: https://invisit.dev/llms.txt

1. Get the site id

The person signs up at https://app.invisit.dev/auth, adds a site with its domain, and copies the site id from Settings → Installation. Ask them for it; never invent one. The id is public: it is safe in client code and in PUBLIC_ or NEXT_PUBLIC_ environment variables.

2. Add the tracker

Prefer the installer, once you have the id from the person: run npx invisit init --site <site id> in the project's directory. It detects the framework, installs the package and edits the right file; --dry-run shows the diff first. It exits 0 when done or already set up, and when it could not place an edit safely it changes nothing and prints the snippet and file to paste it into: follow those steps. It exits 1 when it needs input (a site id, or --dir <app> at a monorepo root). Otherwise, add it by hand.

Pick one, never both.

No build step (static HTML, WordPress, Webflow, Shopify themes): put this in the <head> of every page.

<script
  async
  src="https://api.invisit.dev/invisit.js"
  data-site="<site id>"
  data-collector="https://api.invisit.dev"
></script>

Keep data-collector: without it the script sends events to the page's own origin.

Bundled app (Next.js, React Router, TanStack Start, Nuxt, SvelteKit, Astro, Angular, SolidStart, Vite):

npm install @invisitdev/web
import { init } from '@invisitdev/web'

init({ site: '<site id>' })

Call init() once, in the browser, as early as the app allows. It follows client-side navigation by itself, and it is a no-op on the server, so importing it from shared code is safe. Where the line goes in each framework: https://invisit.dev/docs/web/frameworks.md

3. Custom events (optional)

import { track } from '@invisitdev/web'

track('signup', { plan: 'pro' })

Events from a backend go through @invisitdev/server: https://invisit.dev/docs/server/sdk.md. Event naming and properties: https://invisit.dev/docs/guides/events.md

4. Check that it works

Deploy, open the site, then open Realtime in the dashboard: the visit shows up within seconds. If nothing arrives, Settings → Blocked traffic lists what the collector refused and why; the usual cause is the site's domain missing from Settings → Collection. Settings → Debug opens the site in a sandbox, localhost included, and shows each event with the collector's verdict without counting it.

Reference