analytics/types.ts

morphic · lib/analytics/types.ts · typescript · Apache-2.0
analytics

Defines TypeScript interfaces for tracking chat interactions and query analytics.

// Source: https://github.com/miurla/morphic | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Analytics module types
 */

/** Length bucket of the user query. Avoids sending the raw text. */
export type QueryLenBucket = '0-20' | '21-50' | '51-120' | '120+'

/** Coarse language of the user query. */
export type QueryLang = 'en' | 'other'

/**
 * Privacy-preserving "shape" of a user query. The raw query stays in the DB;
 * only these derived signals are sent to analytics.
 */
export interface QueryShape {
  queryLenBucket: QueryLenBucket
  hasUrl: boolean
  lang: QueryLang
}

/**
 * Chat event data structure
 * Contains all information needed to track a chat interaction
 */
ex

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key