Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api-service): Usage insights email #7346

Draft
wants to merge 34 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9f7b9dc
feat: insights
scopsy Dec 4, 2024
5728669
feat: wip
scopsy Dec 4, 2024
6eb853e
fix: hello world
scopsy Dec 4, 2024
099fea9
fix: email
scopsy Dec 4, 2024
8fb84e3
fix: email style
scopsy Dec 4, 2024
60a85a3
fix: add marketing section
scopsy Dec 4, 2024
a49b625
fix: upload
scopsy Dec 4, 2024
d56c811
fix: logo
scopsy Dec 4, 2024
8a89c1b
Merge branch 'next' into insights-email
scopsy Dec 22, 2024
747dffd
fix: items
scopsy Dec 22, 2024
5ee4ad9
fix: workflows
scopsy Dec 22, 2024
6d7c867
fix: items
scopsy Dec 22, 2024
63ef939
fix: items
scopsy Dec 22, 2024
836c44f
fix: items
scopsy Dec 22, 2024
0dd5361
fix: refactor
scopsy Dec 22, 2024
9570eff
fix: review
scopsy Dec 22, 2024
2be2bf1
fix: items
scopsy Dec 22, 2024
5464b96
fix: items
scopsy Dec 22, 2024
2945749
fix: bugs
scopsy Dec 22, 2024
4c9bd12
fix: working state
scopsy Dec 22, 2024
3b4e5a9
feat: add controller
scopsy Dec 22, 2024
4a4f6bc
feat: add insights tester
scopsy Dec 22, 2024
88f0530
fix: mixpanel
scopsy Dec 22, 2024
510860a
fix: remove cache
scopsy Dec 22, 2024
efc2df7
fix: remove unused import
scopsy Dec 22, 2024
bd7e05f
fix: trigger
scopsy Dec 22, 2024
65c3d67
fix: empty state
scopsy Dec 22, 2024
9ea8c3c
fix: refactpr
scopsy Dec 22, 2024
69a10f8
fix: r emov unused
scopsy Dec 22, 2024
3173273
fix: validation
scopsy Dec 22, 2024
465427d
fix: remove pr info
scopsy Dec 22, 2024
2c39098
Merge branch 'next' into insights-email
scopsy Dec 22, 2024
ed1d443
Merge branch 'next' into insights-email
scopsy Dec 22, 2024
325762b
fix: import
scopsy Dec 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: insights
  • Loading branch information
scopsy committed Dec 4, 2024
commit 9f7b9dc8485c899ae393be70e01a8ce730a586e7
10 changes: 10 additions & 0 deletions apps/api/src/app/insights/insights.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { USE_CASES } from './usecases';
import { SharedModule } from '../shared/shared.module';

@Module({
imports: [SharedModule],
providers: [...USE_CASES],
exports: [...USE_CASES],
})
export class InsightsModule {}
3 changes: 3 additions & 0 deletions apps/api/src/app/insights/usecases/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { UsageInsights } from './usage-insights/usage-insights.usecase';

export const USE_CASES = [UsageInsights];
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { IsString } from 'class-validator';
import { EnvironmentCommand } from '@novu/application-generic';

export class UsageInsightsCommand extends EnvironmentCommand {
@IsString()
organizationId: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Injectable } from '@nestjs/common';
import { MessageRepository, NotificationRepository } from '@novu/dal';
import { InstrumentUsecase } from '@novu/application-generic';

import { UsageInsightsCommand } from './usage-insights.command';

interface IUsageInsightsResponse {
totalNotifications: number;
totalMessages: number;
}

@Injectable()
export class UsageInsights {
constructor(
private notificationRepository: NotificationRepository,
private messageRepository: MessageRepository
) {}

@InstrumentUsecase()
async execute(command: UsageInsightsCommand): Promise<IUsageInsightsResponse> {
const query = {
_environmentId: command.environmentId,
_organizationId: command.organizationId,
};

const [totalNotifications, totalMessages] = await Promise.all([
this.notificationRepository.count(query),
this.messageRepository.count(query),
]);

return {
totalNotifications,
totalMessages,
};
}
}
Loading