Skip to content

Commit

Permalink
Add types for custom events beforeSend. Export type (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiaslins committed Apr 26, 2023
1 parent 1b6d439 commit a598431
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/web/src/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ export default {
inject,
track,
};

export type { BeforeSendEvent } from './types';
8 changes: 6 additions & 2 deletions packages/web/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ interface PageViewEvent {
type: 'pageview';
url: string;
}
interface CustomEvent {
type: 'event';
url: string;
}

type Event = PageViewEvent;
export type BeforeSendEvent = PageViewEvent | CustomEvent;

export type Mode = 'auto' | 'development' | 'production';
export type AllowedPropertyValues = string | number | boolean | null;

export type BeforeSend = (event: Event) => Event | null;
export type BeforeSend = (event: BeforeSendEvent) => BeforeSendEvent | null;
export interface AnalyticsProps {
beforeSend?: BeforeSend;
debug?: boolean;
Expand Down

0 comments on commit a598431

Please sign in to comment.