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
Prev Previous commit
Next Next commit
fix: review
  • Loading branch information
scopsy committed Dec 22, 2024
commit 9570eff4b554421bdad83c02a9c7ebcae05f1b7b
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class OrganizationNotificationService {
Logger.debug(`Processing metrics for organization: ${metrics.id}`);
try {
const organization = await this.organizationRepository.findById(metrics.id);

if (!organization) {
Logger.warn(`Organization not found in repository: ${metrics.id}`);

Expand Down Expand Up @@ -50,7 +51,7 @@ export class OrganizationNotificationService {
await usageInsightsWorkflow.trigger({
to: {
subscriberId: '675fe9bcab6a05bb6dcb7dab_11',
email: `george+testing-${organization._id}@novu.co`,
email: `dima+testing-${organization._id}@novu.co`,
},
payload: {
period: {
Expand Down

This file was deleted.

47 changes: 37 additions & 10 deletions libs/notifications/src/workflows/usage-insights/email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ function MetricCard({
current: number;
previous: number;
change: number;
padding?: string;
}) {
const isPositive = change > 0;
const changeColor = isPositive ? 'text-emerald-600' : 'text-rose-600';

const formatNumber = (num: number) => Math.floor(num).toLocaleString('en-US', { maximumFractionDigits: 0 });

return (
<div className="h-[75px] rounded-lg border border-gray-100 bg-gray-50/50 p-3">
<div className={`h-[75px] rounded-lg border border-gray-100 bg-gray-50/50 p-2`}>
<Row className="flex items-start justify-between gap-2">
<Column align="left" className="w-full">
<Text className="mb-0 mt-0 min-h-[28px] text-xs font-medium capitalize leading-tight text-gray-600">
Expand Down Expand Up @@ -80,11 +81,30 @@ function ChannelBreakdown({ channels }: { channels: IUsageEmailData['channelBrea
<Section className="mt-6">
<SectionHeader title="Channel Breakdown" />
<Row>
{Object.entries(channels).map(([channel, metrics]) => (
<Column key={channel} className="p-2">
<MetricCard title={channel} current={metrics.current} previous={metrics.previous} change={metrics.change} />
</Column>
))}
<Column className="p-2 pl-0">
<MetricCard
title="Email"
current={channels.email.current}
previous={channels.email.previous}
change={channels.email.change}
/>
</Column>
<Column className="p-2">
<MetricCard
title="SMS"
current={channels.sms.current}
previous={channels.sms.previous}
change={channels.sms.change}
/>
</Column>
<Column className="p-2 pr-0">
<MetricCard
title="Push"
current={channels.push.current}
previous={channels.push.previous}
change={channels.push.change}
/>
</Column>
</Row>
</Section>
);
Expand All @@ -95,7 +115,7 @@ function InboxMetrics({ metrics }: { metrics: IUsageEmailData['inboxMetrics'] })
<Section className="mt-6">
<SectionHeader title="Inbox Activity" />
<Row>
<Column className="p-2">
<Column className="p-2 pl-0">
<MetricCard
title="Sessions"
current={metrics.sessionInitialized.current}
Expand All @@ -111,7 +131,7 @@ function InboxMetrics({ metrics }: { metrics: IUsageEmailData['inboxMetrics'] })
change={metrics.updatePreferences.change}
/>
</Column>
<Column className="p-2">
<Column className="p-2 pr-0">
<MetricCard
title="Notifications Marked"
current={metrics.markNotification.current}
Expand All @@ -136,11 +156,14 @@ function WorkflowStats({ workflows }: { workflows: IUsageEmailData['workflowStat
{topWorkflows?.map(([name, metrics], index) => {
const isPositive = metrics.change > 0;
const changeColor = isPositive ? 'text-emerald-600' : 'text-rose-600';
const isLast = index === topWorkflows.length - 1;

return (
<Row
key={index}
className={`mb-2 flex items-center justify-between rounded-lg border border-gray-100 bg-gray-50/50 p-2`}
className={`flex items-center justify-between rounded-lg border border-gray-100 bg-gray-50/50 p-2 ${
!isLast ? 'mb-2' : ''
}`}
>
<Column align="left" className="w-full">
<Text className="mb-0.5 mt-0 text-sm font-medium text-gray-900">{name}</Text>
Expand All @@ -164,7 +187,11 @@ function WorkflowStats({ workflows }: { workflows: IUsageEmailData['workflowStat

interface IMarketingConfig {
title: string;
links: IMarketingLink[];
links: {
text: string;
href: string;
emoji: string;
}[];
cta: {
text: string;
buttonText: string;
Expand Down