fix: better validation of events + clean up (#267)
This commit is contained in:
@@ -1,36 +1 @@
|
||||
export * from './src/index';
|
||||
|
||||
// Deprecated types for beta version of the SDKs
|
||||
// Still used in api/event.controller.ts and api/profile.controller.ts
|
||||
|
||||
export interface OpenpanelEventOptions {
|
||||
profileId?: string;
|
||||
}
|
||||
|
||||
export interface PostEventPayload {
|
||||
name: string;
|
||||
timestamp: string;
|
||||
profileId?: string;
|
||||
properties?: Record<string, unknown> & OpenpanelEventOptions;
|
||||
}
|
||||
|
||||
export interface UpdateProfilePayload {
|
||||
profileId: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
email?: string;
|
||||
avatar?: string;
|
||||
properties?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface IncrementProfilePayload {
|
||||
profileId: string;
|
||||
property: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface DecrementProfilePayload {
|
||||
profileId?: string;
|
||||
property: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@openpanel/tsconfig": "workspace:*",
|
||||
"@openpanel/validation": "workspace:*",
|
||||
"@types/node": "catalog:",
|
||||
"tsup": "^7.2.0",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,20 @@
|
||||
import type {
|
||||
IAliasPayload as AliasPayload,
|
||||
IDecrementPayload as DecrementPayload,
|
||||
IIdentifyPayload as IdentifyPayload,
|
||||
IIncrementPayload as IncrementPayload,
|
||||
ITrackHandlerPayload as TrackHandlerPayload,
|
||||
ITrackPayload as TrackPayload,
|
||||
} from '@openpanel/validation';
|
||||
import { Api } from './api';
|
||||
|
||||
export type TrackHandlerPayload =
|
||||
| {
|
||||
type: 'track';
|
||||
payload: TrackPayload;
|
||||
}
|
||||
| {
|
||||
type: 'increment';
|
||||
payload: IncrementPayload;
|
||||
}
|
||||
| {
|
||||
type: 'decrement';
|
||||
payload: DecrementPayload;
|
||||
}
|
||||
| {
|
||||
type: 'alias';
|
||||
payload: AliasPayload;
|
||||
}
|
||||
| {
|
||||
type: 'identify';
|
||||
payload: IdentifyPayload;
|
||||
};
|
||||
|
||||
export type TrackPayload = {
|
||||
name: string;
|
||||
properties?: Record<string, unknown>;
|
||||
profileId?: string;
|
||||
export type {
|
||||
AliasPayload,
|
||||
DecrementPayload,
|
||||
IdentifyPayload,
|
||||
IncrementPayload,
|
||||
TrackHandlerPayload,
|
||||
TrackPayload,
|
||||
};
|
||||
|
||||
export type TrackProperties = {
|
||||
@@ -33,32 +22,6 @@ export type TrackProperties = {
|
||||
profileId?: string;
|
||||
};
|
||||
|
||||
export type IdentifyPayload = {
|
||||
profileId: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
email?: string;
|
||||
avatar?: string;
|
||||
properties?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type AliasPayload = {
|
||||
profileId: string;
|
||||
alias: string;
|
||||
};
|
||||
|
||||
export type IncrementPayload = {
|
||||
profileId: string;
|
||||
property: string;
|
||||
value?: number;
|
||||
};
|
||||
|
||||
export type DecrementPayload = {
|
||||
profileId: string;
|
||||
property: string;
|
||||
value?: number;
|
||||
};
|
||||
|
||||
export type OpenPanelOptions = {
|
||||
clientId: string;
|
||||
clientSecret?: string;
|
||||
|
||||
Reference in New Issue
Block a user