@crvouga/mockingbird-service-meta

中文文档
1.11.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 2944

Stateful emulator of Meta's Conversions and Marketing APIs: server events, deduplication, campaign objects, insights, pagination and Graph error envelopes.

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Routes
  4. Admin and faults
  5. API
  6. Deliberately not modelled

@crvouga/mockingbird-service-meta

Local emulators. Real API contracts. Part of Mockingbird.

Stateful Meta Graph v26 emulator for server-side Conversions API events and marketing reporting. It preserves privacy-safe hashed user fields, event deduplication, ambiguous writes, Graph errors, campaign objects, dated insights, breakdowns, and cursor pagination without contacting Meta.

Install

npm install -D @crvouga/mockingbird-service-meta

ESM only. Node >= 22 or Bun >= 1.2. Serve with npx mockingbird-meta serve, createServer from ./server, or mount createRuntime() in any Fetch-compatible process.

Usage

Make the Graph origin injectable and point it at the emulator. Any non-empty synthetic Bearer token or access_token query value authenticates unless /__admin/settings restricts tokens.

import { createServer } from "@crvouga/mockingbird-service-meta/server"

const server = await createServer()

// The application's own Conversions API request. Only the Graph origin changes:
// server.url instead of https://graph.facebook.com.
const response = await fetch(`${server.url}/v26.0/pixel_test/events`, {
  method: "POST",
  headers: { authorization: "Bearer meta_test", "content-type": "application/json" },
  body: JSON.stringify({ data: [{
    event_name: "Purchase",
    event_time: Math.floor(Date.now() / 1000),
    event_id: "order_42",
    action_source: "website",
    user_data: { em: ["a".repeat(64)] },
    custom_data: { currency: "USD", value: 42 },
  }] }),
})
console.log(await response.json())
// → {events_received: 1, messages: [], fbtrace_id: "trace_…"}

await server.close()

Routes

RouteBehaviour
POST /v26.0/:pixelId/eventsAccepts CAPI data[] and test_event_code; keeps event name/time/id, action source, source URL, hashed user data and custom data. Repeated event_id values are acknowledged without a second stored event. Events older than seven days, future events, malformed hashes and invalid bodies receive Graph error envelopes.
GET /v26.0/:accountId/insightsFilters seeded or admin-inserted insight rows by inclusive JSON time_range, paginates with limit/after, and includes country when requested as a breakdown.
GET /v26.0/:objectIdReads seeded/admin-inserted campaign, ad-set, or ad records.

Seed fixtures are act_mockingbird, cmp_mockingbird, set_mockingbird, and ad_mockingbird, with three dated insight rows from 2026-01-01 through 2026-01-03.

Admin and faults

GET /__admin/events returns the namespace's privacy-safe stored requests. GET/PUT /__admin/settings controls accessTokens and maxEventAgeSeconds. Standard /__admin/state routes seed or edit events, objects, and insights directly.

Presets: expired_token, rate_limited, server_error, partial_event_acceptance, accepted_then_drop, and slow. The ambiguous-write preset persists the event before dropping the connection; retrying the same event_id remains deduplicated.

Namespaces use x-mockingbird-namespace, /__admin/ns/<name>/…, or credential mapping through PUT /__admin/credentials.

API

The main entry exports MetaAPI, MetaState, createRuntime, META_NAMESPACE, META_PRESETS, DEFAULT_SETTINGS, accessTokenCredential, the generated document, operationIds, supportedOperationIds, and their public option/state/event/insight types. @crvouga/mockingbird-service-meta/server exports createServer, serveTarget, DEFAULT_PORT, and server option/result types.

Deliberately not modelled

  • Real ad delivery, attribution calculation, hashing of plaintext PII, app-secret proof, or OAuth.
  • Campaign/ad-set/ad mutation, creatives, audiences, pixels configuration, dashboards, or billing.
  • The complete Insights fields/breakdowns matrix and asynchronous report jobs.
  • Meta-side probabilistic matching: the emulator records only the supplied synthetic hashed fields.

版本与发布记录

@crvouga/mockingbird-service-meta 共发布 23 个版本,首次发布于 2026/10/05;过去 12 个月发布了 23 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.11.0latest2026/11/11今天
1.10.92026/11/038 天前
1.10.82026/11/038 天前
1.10.72026/11/038 天前
1.10.62026/11/038 天前
1.10.52026/11/038 天前

关于 @crvouga/mockingbird-service-meta 的常见问题

@crvouga/mockingbird-service-meta 是什么?

Stateful emulator of Meta's Conversions and Marketing APIs: server events, deduplication, campaign objects, insights, pagination and Graph error envelopes.

如何安装 @crvouga/mockingbird-service-meta?

在项目目录运行 npm install @crvouga/mockingbird-service-meta,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-meta,可以用 npx mockingbird-meta 直接运行。

@crvouga/mockingbird-service-meta 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crvouga/mockingbird-service-meta 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@crvouga/mockingbird-service-meta 可以商用吗?

@crvouga/mockingbird-service-meta 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@crvouga/mockingbird-service-meta 的下载量有多少?

根据 npm 官方下载统计,@crvouga/mockingbird-service-meta 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,944 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crvouga/mockingbird-service-meta 还在维护吗?

最新版本 1.11.0 发布于 2026/11/11(今天);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/10/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。