fix issues in core
This commit is contained in:
@@ -20,11 +20,11 @@ describe('GetEntityAnalyticsQuery', () => {
|
||||
pageViewRepository = {
|
||||
countByEntityId: vi.fn(),
|
||||
countUniqueVisitors: vi.fn(),
|
||||
} as unknown as IPageViewRepository as any;
|
||||
};
|
||||
|
||||
engagementRepository = {
|
||||
getSponsorClicksForEntity: vi.fn(),
|
||||
} as unknown as IEngagementRepository as any;
|
||||
};
|
||||
|
||||
logger = {
|
||||
debug: vi.fn(),
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('RecordEngagementUseCase', () => {
|
||||
beforeEach(() => {
|
||||
engagementRepository = {
|
||||
save: vi.fn(),
|
||||
} as unknown as IEngagementRepository as any;
|
||||
};
|
||||
|
||||
logger = {
|
||||
debug: vi.fn(),
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('RecordPageViewUseCase', () => {
|
||||
beforeEach(() => {
|
||||
pageViewRepository = {
|
||||
save: vi.fn(),
|
||||
} as unknown as IPageViewRepository as any;
|
||||
};
|
||||
|
||||
logger = {
|
||||
debug: vi.fn(),
|
||||
|
||||
@@ -31,26 +31,19 @@ export class RecordPageViewUseCase implements UseCase<RecordPageViewInput, void,
|
||||
|
||||
async execute(input: RecordPageViewInput): Promise<Result<void, ApplicationErrorCode<RecordPageViewErrorCode, { message: string }>>> {
|
||||
try {
|
||||
const props = {
|
||||
type PageViewCreateProps = Parameters<(typeof PageView)['create']>[0];
|
||||
|
||||
const props: PageViewCreateProps = {
|
||||
id: crypto.randomUUID(),
|
||||
entityType: input.entityType,
|
||||
entityId: input.entityId,
|
||||
visitorType: input.visitorType,
|
||||
sessionId: input.sessionId,
|
||||
} as any;
|
||||
|
||||
if (input.visitorId !== undefined) {
|
||||
props.visitorId = input.visitorId;
|
||||
}
|
||||
if (input.referrer !== undefined) {
|
||||
props.referrer = input.referrer;
|
||||
}
|
||||
if (input.userAgent !== undefined) {
|
||||
props.userAgent = input.userAgent;
|
||||
}
|
||||
if (input.country !== undefined) {
|
||||
props.country = input.country;
|
||||
}
|
||||
...(input.visitorId !== undefined ? { visitorId: input.visitorId } : {}),
|
||||
...(input.referrer !== undefined ? { referrer: input.referrer } : {}),
|
||||
...(input.userAgent !== undefined ? { userAgent: input.userAgent } : {}),
|
||||
...(input.country !== undefined ? { country: input.country } : {}),
|
||||
};
|
||||
|
||||
const pageView = PageView.create(props);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user