@artsy/cohesion

中文文档
4.420.0发布于 2026/11/04MITCommonJS近 30 天下载 4万

Analytics schema

原始使用文档
文档目录5 节
  1. Cohesion
  2. Artsy's analytics schema
  3. Contributing
  4. Schema
  5. Add a new event to the schema (For data analysts)

Cohesion CircleCI npm version

Artsy's analytics schema

Contributing

Requirements: Yarn

Set up:

yarn install

Run tests:

yarn test

Generate docs:

yarn docs

To view docs locally, visit the full filepath of docs/index.html in your browser, i.e, file:///Users/<MY_USER>/<MY_LOCAL_DIRECTORY>/cohesion/doc/index.html

Schema

The /Schema directory represents the Artsy's analytics schema, and describes expectations for data consumed by Redshift and Segment.

This schema is maintained by Artsy's data team, engineers should not expect to change these files.

Valid analytics events are described in /Schema/Events/index.ts, and individual event schemas live in the Schema/Events directory, divided by concern.

Typings for all allowed values, such as ContextModule, are exported for use by engineers in consuming projects.

Add a new event to the schema (For data analysts)

  1. In Schema/Events, add the name of the new event. This name defines the corresponding downstream table's name in Redshift, and should use the lowerCamelCase naming convention.
// Schema/Events/index.ts

export enum ActionType {
  ...
  myNewEvent = "myNewEvent",
  ...
}

  1. In Schema/Events directory, create a new interface describing the shape of the new event, as it is received in Segment/Redshift.
  • The name of the interface should match the ActionType created in step 1, but use the UpperCamelCase naming convention.
  • The action key is required and should match the ActionType created in step 1.
  • If your event uses values not yet in the schema, such as a new ContextModule, add new values to the existing typings in the Schema directory.
// Schema/Events/MyNewEvent.ts

export interface MyNewEvent {
  action: ActionType.myNewEvent
  context_module: ContextModule
  optional_property?: string
  required_property: number
}
  1. In Schema/Events/index.ts, add the new interface to the valid events main list, Event

  2. Add descriptive comments with examples to explain the use of your new event. Our documentation is generated automatically from in-code comments, find more information on syntax in the typedoc docs.

  3. If you have created any new files, add an export statement to Schema/index.ts like so:

// Schema/index.ts

export * from "./Events/MyNewEvent"
  1. PR your changes. Once merged, the schema will be updated and your new event and values will be available to consumers of this package.

版本与发布记录

@artsy/cohesion 共发布 710 个版本,首次发布于 2020/04/15;过去 12 个月发布了 130 个版本。

版本发布日期距今
4.420.0latest2026/11/043 天前
4.419.1--canary.770.16991.0canary2026/11/043 天前
4.419.02026/10/309 天前
4.418.02026/10/299 天前
4.417.02026/10/2711 天前
4.416.02026/10/2711 天前

关于 @artsy/cohesion 的常见问题

@artsy/cohesion 是什么?

Analytics schema

如何安装 @artsy/cohesion?

在项目目录运行 npm install @artsy/cohesion,或使用 pnpm add / yarn add / bun add。

@artsy/cohesion 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/artsy__cohesion 是否存在。

@artsy/cohesion 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@artsy/cohesion 可以商用吗?

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

@artsy/cohesion 的下载量有多少?

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

@artsy/cohesion 还在维护吗?

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