forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track backend events (twentyhq#5405)
Add tracking to backend events, we might disable frontend tracking which doesn't bring much value to improve the product
- Loading branch information
1 parent
ffdd3a7
commit a53ce1c
Showing
5 changed files
with
52 additions
and
23 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...enty-server/src/engine/api/graphql/workspace-query-runner/listeners/telemetry.listener.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { OnEvent } from '@nestjs/event-emitter'; | ||
|
||
import { AnalyticsService } from 'src/engine/core-modules/analytics/analytics.service'; | ||
import { CreateAnalyticsInput } from 'src/engine/core-modules/analytics/dto/create-analytics.input'; | ||
import { ObjectRecordCreateEvent } from 'src/engine/integrations/event-emitter/types/object-record-create.event'; | ||
|
||
@Injectable() | ||
export class TelemetryListener { | ||
constructor(private readonly analyticsService: AnalyticsService) {} | ||
|
||
@OnEvent('*.created') | ||
async handleAllCreate(payload: ObjectRecordCreateEvent<any>) { | ||
this.analyticsService.create( | ||
{ | ||
type: 'track', | ||
name: payload.name, | ||
data: JSON.parse(`{ | ||
"eventName": "${payload.name}" | ||
}`), | ||
} as CreateAnalyticsInput, | ||
payload.userId, | ||
payload.workspaceId, | ||
'', // voluntarely not retrieving this | ||
'', // to avoid slowing down | ||
'', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters