mirror of
https://github.com/docmost/docmost.git
synced 2026-08-30 10:26:25 +08:00
page analytics init
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { PAGE_VIEW_SERVICE, NoopPageViewService } from './page-view.service';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [
|
||||
{
|
||||
provide: PAGE_VIEW_SERVICE,
|
||||
useClass: NoopPageViewService,
|
||||
},
|
||||
],
|
||||
exports: [PAGE_VIEW_SERVICE],
|
||||
})
|
||||
export class NoopPageViewModule {}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
export type PageViewPayload = {
|
||||
pageId: string;
|
||||
workspaceId?: string;
|
||||
spaceId?: string;
|
||||
shareId?: string;
|
||||
userId?: string | null;
|
||||
visitorId?: string;
|
||||
};
|
||||
|
||||
export const PAGE_VIEW_SERVICE = Symbol('PAGE_VIEW_SERVICE');
|
||||
|
||||
export interface IPageViewService {
|
||||
track(payload: PageViewPayload): void | Promise<void>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NoopPageViewService implements IPageViewService {
|
||||
track(_payload: PageViewPayload): void {}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export enum QueueName {
|
||||
HISTORY_QUEUE = '{history-queue}',
|
||||
NOTIFICATION_QUEUE = '{notification-queue}',
|
||||
AUDIT_QUEUE = '{audit-queue}',
|
||||
PAGE_VIEW_QUEUE = '{page-view-queue}',
|
||||
BASE_QUEUE = '{base-queue}',
|
||||
}
|
||||
|
||||
@@ -81,6 +82,8 @@ export enum QueueJob {
|
||||
|
||||
AUDIT_LOG = 'audit-log',
|
||||
AUDIT_CLEANUP = 'audit-cleanup',
|
||||
PAGE_VIEW_TRACK = 'page-view-track',
|
||||
PAGE_VIEW_CLEANUP = 'page-view-cleanup',
|
||||
|
||||
PDF_EXPORT_TASK = 'pdf-export-task',
|
||||
PDF_EXPORT_CLEANUP = 'pdf-export-cleanup',
|
||||
|
||||
@@ -92,6 +92,14 @@ import { GeneralQueueProcessor } from './processors/general-queue.processor';
|
||||
attempts: 3,
|
||||
},
|
||||
}),
|
||||
BullModule.registerQueue({
|
||||
name: QueueName.PAGE_VIEW_QUEUE,
|
||||
defaultJobOptions: {
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
attempts: 3,
|
||||
},
|
||||
}),
|
||||
BullModule.registerQueue({
|
||||
name: QueueName.BASE_QUEUE,
|
||||
defaultJobOptions: {
|
||||
|
||||
Reference in New Issue
Block a user