当前位置: 首页 > Skill >

Outlit SDK

Outlit SDK

1.0.3 2026.11.16 浏览:306
获取Skill文件查看使用说明
作者:周澄许可证:
本文目录展开

Outlit SDK Integration

Decision-tree guide for adding product and website tracking to the Outlit customer context graph. Detect first, ask only when needed, keep changes small, and prefer official docs for framework-specific code.

Branching Check

Before anything else, check whether Outlit is already installed:

  1. Look for @outlit/browser, @outlit/node, outlit in Cargo.toml, https://cdn.outlit.ai, or existing outlit.init(...) / new Outlit(...) calls.
  2. If not installed, go to Phase 1: Quick Connect.
  3. If installed, go to Already Installed.

Already Installed

Ask what they need help with, then run detection before changing code:

  • Add event tracking -> Decision 6: Event Tracking
  • Add/change auth identity -> Decision 2: Identity
  • Add consent management -> Decision 1: Consent
  • Add server/native tracking -> Decision 7: Server and Native Tracking
  • Configure activation in Core -> Decision 4: Activation
  • Connect a billing integration -> Decision 5: Billing
  • Migrate from other analytics -> Decision 3: Existing Analytics
  • Debug/troubleshoot -> Troubleshooting

Current API Guardrails

These points prevent the most common stale integrations:

  • All current ingest SDKs use publicKey values that start with pk_. Do not use privateKey, OUTLIT_PRIVATE_KEY, visitorId, or event for @outlit/node examples.
  • Node server events use new Outlit({ publicKey }) and track({ eventName, email | userId | fingerprint | customerId, properties }).
  • Browser events use track(eventName, properties?); browser anonymous events are valid without identity because the SDK manages visitorId.
  • Server track() requires at least one of email, userId, fingerprint, or customerId.
  • Server identify() requires email or userId. customerId is optional account/workspace attribution, not a user identity by itself.
  • Use customerId for your system-owned account/workspace/customer ID. The TypeScript SDK no longer uses customerDomain; do not add it.
  • Browser setUser() can be called before tracking is enabled and will be applied after consent. Browser identify() requires tracking to already be enabled.
  • Send ordinary identify() and track() events. Outlit Core derives activation from the configured activation event and derives engagement and inactivity from product activity.
  • Billing status is account-level context supplied by verified billing integrations. Do not send SDK lifecycle or billing-status events as authoritative state.
  • Event names should be snake_case.

Phase 1: Quick Connect

Goal: get data flowing quickly so the user can see Outlit connection/activity without making product-strategy decisions.

Step 1: Detect Framework and Package Manager

Check:

Signal How to detect
Framework package.json deps: next, react, vue, nuxt, svelte, @sveltejs/kit, @angular/core, astro, express, fastify, electron, react-native; Cargo.toml deps: tauri, outlit
Package manager bun.lockb, bun.lock, pnpm-lock.yaml, yarn.lock, package-lock.json
Current Outlit @outlit/browser, @outlit/node, CDN script, Rust crate, outlit.init, OutlitProvider, OutlitPlugin, new Outlit

Step 2: Choose SDK

App surface Use
Browser app: React, Next.js, Vue, Nuxt, SvelteKit, Angular, Astro, vanilla, script tag @outlit/browser
Node backend: API routes, server actions, Express, Fastify, jobs, webhooks @outlit/node
Native JS without browser storage: React Native, CLI, desktop main process @outlit/node with a stable fingerprint
Rust backend, CLI, or Tauri backend Rust crate outlit
Electron renderer or webview @outlit/browser; use @outlit/node in main process only if tracking native/background events

Install with the detected manager. Prefer bun add when the repo is a Bun workspace.

Step 3: Add Public Key

Ask for the Outlit public key from Outlit dashboard -> Settings -> Website Tracking or onboarding.

Use the framework's public env convention:

Framework Env var
Next.js NEXT_PUBLIC_OUTLIT_KEY
Vite / Vue / React+Vite / Svelte VITE_OUTLIT_KEY
SvelteKit PUBLIC_OUTLIT_KEY
Nuxt NUXT_PUBLIC_OUTLIT_KEY
Astro PUBLIC_OUTLIT_KEY
Create React App REACT_APP_OUTLIT_KEY
Angular environment.ts or equivalent
Server/native OUTLIT_KEY or OUTLIT_PUBLIC_KEY

Step 4: Minimal Setup

Fetch the framework doc from the Doc URL Map and implement only startup initialization:

  • React/Next: prefer OutlitProvider from @outlit/browser/react in a client boundary.
  • Vue/Nuxt: use OutlitPlugin from @outlit/browser/vue.
  • Plain browser/script: use @outlit/browser or CDN script.
  • Server/native: create one Outlit instance where the process can reuse it.

Do not add custom events, activation configuration, billing integrations, auth, or consent until basic tracking is working unless the user asked for a full integration immediately.

Step 5: Verify Connection

Verify with one or more:

  • DevTools Network has https://app.outlit.ai/api/i/v1/<publicKey>/events returning success.
  • Browser console has no [Outlit] warnings.
  • Server code calls await outlit.flush() or await outlit.shutdown() before process/serverless exit.
  • Outlit onboarding/dashboard shows recent activity or connected tracking.

Then ask whether to continue with the full integration.

Phase 2: Full Integration

Run detection and present what you found before changing behavior:

Signal How to detect
Auth provider @clerk/*, next-auth, @auth/core, @supabase/*, @auth0/*, firebase, custom session/auth files
Account model organization, workspace, team, account, tenant, customerId, Stripe customer mapping
Billing provider stripe, @stripe/stripe-js, paddle, chargebee, webhook routes
Existing analytics posthog-js, @posthog/node, Amplitude, Mixpanel, Segment, analytics wrappers
Consent Cookiebot, OneTrust, cookie banner components, CMP callbacks
Native/device Tauri, Electron main process, React Native, CLI, mobile storage
Activation first workspace/project/resource, first successful integration, invite sent, report generated, first meaningful feature success
Calendar embeds Cal.com or Calendly embed code

Decision 1: Consent

Detection Recommendation
Existing CMP/cookie banner Initialize with autoTrack: false; call enableTracking() from the CMP accept callback and disableTracking() on revoke/decline
EU/privacy signals but no CMP Use autoTrack: false and tell the user they need a consent decision; do not build a CMP unless asked
No consent requirement found Use default autoTrack: true

Explain the tradeoff: autoTrack: true creates browser visitor storage immediately. autoTrack: false waits until enableTracking() is called.

If identity is known before consent, use the React user prop or setUser() so identity is queued and applied after tracking starts. Do not call browser identify() before tracking is enabled.

Decision 2: Identity

Use the strongest identifiers available:

  • email: primary person identifier.
  • userId: the app/auth-provider user or contact ID.
  • customerId: the app's account/workspace/customer/team ID.
  • customerTraits: account/workspace metadata such as plan or seats.
  • traits: user/contact metadata such as name or role.
  • fingerprint: stable device/install ID for native or non-browser tracking.

Recommendations:

Context Pattern
React/Next Pass user={{ email, userId, customerId, traits, customerTraits }} to OutlitProvider once auth resolves
Vue/Nuxt Use useOutlitUser(refOrComputedUser) or plugin setUser()
SPA without framework helpers Call setUser({ email, userId, customerId }) after auth, and clearUser() on logout
Script tag Call window.outlit.setUser(...) after auth, or identify(...) after tracking is enabled
Server Node Call identify({ email, userId, customerId }) for user/profile updates; call track({ customerId, eventName }) for account-scoped events
Native/device Track with a persistent fingerprint; later call identify({ email, fingerprint }) or Rust .fingerprint(...) to link history

Critical distinction: browser identify/setUser links anonymous visitor history. Server identify attributes server-side identity and can link fingerprints/customer IDs, but it does not link browser visitor cookies unless the browser also identifies.

Decision 3: Existing Analytics

Detection Recommendation
Existing analytics wrapper Add Outlit to the wrapper
Direct analytics calls scattered across files Count them and ask whether to add Outlit alongside existing calls or introduce a wrapper
PostHog connected as data source Do not duplicate every PostHog event by default; use SDK for missing product/website/customer identity gaps
No analytics Add Outlit directly

Keep event names snake_case and avoid reorganizing unrelated analytics code.

Decision 4: Activation

Activation means a user reached the product's meaningful value moment. Outlit Core derives it from one configured ordinary product event; it is not automatically "completed onboarding" unless onboarding itself delivers value.

  1. Scan for first-value actions: first project/resource created, first integration connected, first report/export generated, first invite, first successful core workflow.
  2. Suggest the strongest candidate and ask for confirmation if ambiguous.
  3. Reuse or add an ordinary track() event after the action is confirmed complete, usually after the backend succeeds.
  4. Ensure the user is identified before that event when possible so Core can attribute it correctly.
  5. Configure that exact event as the activation event in Outlit Core. Core derives engagement and inactivity from ongoing tracked activity.

Decision 5: Billing

Billing is verified account-level context, separate from ordinary identity and product activity events.

Detection Recommendation
Stripe connected in Outlit Verify the connection and customer mapping; let the integration supply billing status
Stripe in app but not connected Recommend connecting Stripe in Outlit and verifying the customer mapping
Other/custom billing Use a supported verified billing integration or source connector; do not turn webhook state into authoritative SDK events
No billing Skip

Use identify() and track() only for identity and ordinary product activity. Billing status must come from a verified billing integration rather than SDK lifecycle methods, billing enums, or custom status events.

Decision 6: Event Tracking

Browser SDK defaults already capture:

  • pageviews, including SPA navigation
  • form submissions with sensitive fields removed
  • auto-identify from email/name form fields
  • engagement time and sessions
  • Cal.com/Calendly booking events, without attendee email/name from client-side embeds

Add custom track() calls only for meaningful product actions that are not covered by automatic capture or connected integrations. Use properties for useful context, not PII or secrets.

Browser example:

outlit.track("project_created", { template: "blank" })

Server example:

outlit.track({
  customerId: "cust_123",
  eventName: "workspace_synced",
  properties: { provider: "github" },
})

Calendar embed limitation: Cal.com and Calendly client events do not expose attendee email/name. Use provider webhooks plus server identify() when booked-meeting identity matters.

Hash-routed SPAs, file:// routes, and Electron-style hash paths are handled by the core path extractor; do not add custom path parsing unless the app has a special router.

Decision 7: Server and Native Tracking

Use server/native tracking for backend-confirmed product activity, background jobs, native apps, CLIs, and device-based activity.

Node example:

import { Outlit } from "@outlit/node"

const outlit = new Outlit({ publicKey: process.env.OUTLIT_KEY! })

outlit.track({
  customerId: "cust_123",
  eventName: "workspace_synced",
  properties: { provider: "github" },
})

await outlit.flush()

Use fingerprint for native/desktop/mobile activity before login:

outlit.track({
  fingerprint: deviceId,
  eventName: "app_opened",
})

outlit.identify({
  email: user.email,
  fingerprint: deviceId,
  userId: user.id,
})

Serverless rule: await outlit.flush() before returning. Long-lived process rule: reuse one client and call shutdown() on graceful shutdown.

Doc URL Map

Fetch docs as needed. Prefer docs over hardcoding long framework patterns, but apply the API guardrails above if examples conflict.

Topic URL
Quickstart https://docs.outlit.ai/tracking/quickstart
How tracking works https://docs.outlit.ai/tracking/how-it-works
Customer context graph https://docs.outlit.ai/concepts/customer-context-graph
Website visitors https://docs.outlit.ai/concepts/website-visitors
Identity resolution https://docs.outlit.ai/concepts/identity-resolution
Customer journey https://docs.outlit.ai/concepts/customer-journey
NPM/browser package https://docs.outlit.ai/tracking/browser/npm
React https://docs.outlit.ai/tracking/browser/react
Next.js https://docs.outlit.ai/tracking/browser/nextjs
Vue 3 https://docs.outlit.ai/tracking/browser/vue
Nuxt https://docs.outlit.ai/tracking/browser/nuxt
SvelteKit https://docs.outlit.ai/tracking/browser/sveltekit
Angular https://docs.outlit.ai/tracking/browser/angular
Astro https://docs.outlit.ai/tracking/browser/astro
Script tag https://docs.outlit.ai/tracking/browser/script
Calendar embeds https://docs.outlit.ai/tracking/browser/calendar-embeds
Node.js https://docs.outlit.ai/tracking/server/nodejs
Rust / Tauri https://docs.outlit.ai/tracking/server/rust
Ingest API https://docs.outlit.ai/api-reference/ingest
Full docs index https://docs.outlit.ai/llms.txt

Troubleshooting

No browser events

  1. Confirm the public env var prefix is correct and exposed to the client bundle.
  2. Confirm provider/init runs once at app startup and wraps the app.
  3. If autoTrack: false, call enableTracking() after consent.
  4. Check Network for /api/i/v1/<publicKey>/events.
  5. Check console warnings such as tracking not enabled, already initialized, or multiple instances.

Events not linked to users

  • Prefer OutlitProvider user, useOutlitUser, or setUser() for auth state.
  • Send both email and userId when available.
  • Include customerId for account/workspace-scoped products.
  • Browser identity links visitor history; server identity does not replace browser identity.
  • For native/device history, reuse the same persistent fingerprint before and after login.

Server events missing

  • Use publicKey, not privateKey.
  • Use eventName, not event.
  • Provide at least one of email, userId, fingerprint, or customerId to track().
  • identify() needs email or userId.
  • Always await outlit.flush() before serverless handlers return.
  • Non-retryable ingest errors stop automatic retries until restart; fix credentials/config instead of waiting.

Activation missing or delayed

  • Confirm the configured activation event name exactly matches the event sent with track().
  • Confirm identity is set before the event when possible and that the event reaches Outlit.
  • Core derives activation from that configured event and engagement/inactivity from activity; do not send separate lifecycle state.

Key Principles

  • Minimal changes: instrument the existing app shape.
  • Detect first, ask second.
  • Use customerId for account/workspace context.
  • Use setUser/provider user for auth lifecycle.
  • Use track() for product activity; configure the activation event in Core and let Core derive lifecycle state.
  • Let verified billing integrations supply billing status.
  • Flush server/native queues before exit.
  • Keep events snake_case.

Installation

Install this skill through the Outlit CLI when possible:

outlit setup skills

Or with the Skills CLI:

npx -y skills add https://github.com/OutlitAI/outlit-agent-skills --skill outlit-sdk -g

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,039
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,033
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,021
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,020
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,019
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,016
Skill 文件
  • SKILL.md
    • Outlit SDK Integration
    • Branching Check
    • Already Installed
    • Current API Guardrails
    • Phase 1: Quick Connect
      • Step 1: Detect Framework and Package Manager
      • Step 2: Choose SDK
      • Step 3: Add Public Key
      • Step 4: Minimal Setup
      • Step 5: Verify Connection
    • Phase 2: Full Integration
    • Decision 1: Consent
    • Decision 2: Identity
    • Decision 3: Existing Analytics
    • Decision 4: Activation
    • Decision 5: Billing
    • Decision 6: Event Tracking
    • Decision 7: Server and Native Tracking
    • Doc URL Map
    • Troubleshooting
      • No browser events
      • Events not linked to users
      • Server events missing
      • Activation missing or delayed
    • Key Principles
    • Installation
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期