Giter Site home page Giter Site logo

cohesion's Introduction

Cohesion CircleCI npm version

Artsy's analytics schema & event helpers

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/Event.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/Event.ts, 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/ActionType.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/Event.ts, add the new interface to the valid events master 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.

  2. Data analysts should request an engineer to construct a new event helper for the /Events directory (see below).

Events

The /Events directory contains javascript helpers that return schema-compliant analytics events, and provide some useful default values. Each helper corresponds to one event from /Schema/Events.ts.

Engineers should use these helpers whenever sending analytics data to Segment, for example, when creating an analytics event with react-tracking.

cohesion's People

Contributors

abhitip avatar artsy-peril[bot] avatar artsyit avatar brainbicycle avatar damassi avatar eessex avatar jonallured avatar lilyfromseattle avatar louislecluse avatar mikehrom avatar renovate-bot avatar zephraph avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.