Path: blob/main/components/gitpod-protocol/src/analytics.ts
2498 views
/**1* Copyright (c) 2021 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56export const IAnalyticsWriter = Symbol("IAnalyticsWriter");78type Identity = { userId?: string | number; anonymousId?: string | number; subjectId?: string };910interface Message {11messageId?: string;12}1314export type IdentifyMessage = Message &15Identity & {16traits?: any;17timestamp?: Date;18context?: any;19};2021export type TrackMessage = Message &22Identity & {23event: string;24properties?: any;25timestamp?: Date;26context?: any;27};2829export type PageMessage = Message &30Identity & {31properties?: any;32timestamp?: Date;33context?: any;34};3536export type RemoteTrackMessage = Omit<TrackMessage, "timestamp" | "userId">;37export type RemotePageMessage = Omit<PageMessage, "timestamp" | "userId"> & {38includePII?: boolean;39};4041export type RemoteIdentifyMessage = Omit<IdentifyMessage, "timestamp" | "userId">;4243export interface IAnalyticsWriter {44identify(msg: IdentifyMessage): void;4546track(msg: TrackMessage): void;4748page(msg: PageMessage): void;49}5051export const NullAnalyticsWriter: IAnalyticsWriter = {52identify(msg: IdentifyMessage): void {53// noop54},55track(msg: TrackMessage): void {56// noop57},58page(msg: PageMessage): void {59// noop60},61};626364