Skip to content

Commit

Permalink
Fix: page event type (#20)
Browse files Browse the repository at this point in the history
* fix: page type

* add: page type

---------

Co-authored-by: Emil Sadek <[email protected]>
  • Loading branch information
esadek and esadek authored Nov 10, 2024
1 parent 4625a65 commit bb10323
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/trench/src/events/events.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ export class EventDTO {
timestamp?: string
@ApiProperty({
type: String,
description: 'The type of the event. Possible values: `track`, `identify`, `group`.',
description: 'The type of the event. Possible values: `page`, `track`, `identify`, `group`.',
example: 'track',
required: false,
})
type: 'track' | 'identify' | 'group'
type: 'page' | 'track' | 'identify' | 'group'
@ApiProperty({
type: String,
description: 'The ID of the user.',
Expand Down
2 changes: 1 addition & 1 deletion apps/trench/src/events/events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class EventsService {

async createEvents(eventDTOs: EventDTO[]): Promise<Event[]> {
// validate event types
const validEventTypes = ['track', 'identify', 'group']
const validEventTypes = ['page', 'track', 'identify', 'group']
eventDTOs.forEach((eventDTO) => {
if (!validEventTypes.includes(eventDTO.type)) {
throw new Error(
Expand Down
4 changes: 2 additions & 2 deletions apps/trench/src/webhooks/webhooks.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Webhook {

@ApiProperty({
description: 'The event types that the webhook will send. Use `*` to match all event types.',
example: ['track', 'identify'],
example: ['page', 'track', 'identify', 'group'],
})
eventTypes: string[]

Expand Down Expand Up @@ -56,7 +56,7 @@ export class WebhookDTO {
@ApiProperty({
description:
'The event types that the webhook will send. Defaults to `["*"] (all event types)`.',
example: ['track', 'identify'],
example: ['page', 'track', 'identify', 'group'],
required: false,
})
eventTypes?: string[]
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics-plugin-trench/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export interface BaseEvent {
receivedAt?: string;
sentAt?: string;
timestamp?: string;
type: 'track' | 'identify' | 'group';
type: 'page' | 'track' | 'identify' | 'group';
userId?: string;
groupId?: string;
properties?: {
Expand Down Expand Up @@ -227,7 +227,7 @@ export function trench(config: TrenchConfig) {
userId: payload.userId ?? getAnonymousId(),
event: '$pageview',
properties: payload.properties,
type: 'track',
type: 'page',
},
]);
},
Expand Down

0 comments on commit bb10323

Please sign in to comment.