Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
2 changes: 1 addition & 1 deletion .source
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax type

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS step_runs (
subscriber_id String,
external_subscriber_id Nullable(String),
message_id Nullable(String),
context_keys Array(String) DEFAULT []
context_keys Array(String) DEFAULT [],
step_type LowCardinality(String),
step_name String,
provider_id Nullable(String),
Expand All @@ -28,12 +28,12 @@ CREATE TABLE IF NOT EXISTS step_runs (
error_message Nullable(String),
transaction_id String,
expires_at DateTime64(3, 'UTC'),
schedule_extensions_count UInt8 DEFAULT 0,
schedule_extensions_count UInt8 DEFAULT 0
)
ENGINE = ReplacingMergeTree(updated_at)
PARTITION BY toYYYYMM(created_at)
ORDER BY (organization_id, step_run_id)
TTL toDateTime(expires_at)
TTL toDateTime(expires_at);

-- Traces Table
-- Stores event traces for debugging and monitoring workflow/step execution
Expand Down Expand Up @@ -122,4 +122,4 @@ CREATE TABLE IF NOT EXISTS workflow_runs (
ENGINE = ReplacingMergeTree(updated_at)
PARTITION BY toYYYYMM(created_at)
ORDER BY (organization_id, workflow_run_id)
TTL toDateTime(expires_at)
TTL toDateTime(expires_at);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Add workflow_id column to step_runs table
-- This column stores the workflow template ID for each step execution
ALTER TABLE step_runs
ADD COLUMN IF NOT EXISTS workflow_id String DEFAULT '';


-- Add workflow_id column to traces table
-- This column stores the workflow template ID for each trace
ALTER TABLE traces
ADD COLUMN IF NOT EXISTS workflow_id String DEFAULT '';
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"test:e2e:novu-v0": "cross-env TS_NODE_COMPILER_OPTIONS='{\"strictNullChecks\": false}' NODE_ENV=test mocha --timeout 15000 --retries 3 --grep '#novu-v0' --require ts-node/register --exit --file e2e/setup.ts src/**/*.e2e{,-ee}.ts",
"test:e2e:novu-v2": "cross-env NODE_ENV=test CI_EE_TEST=true CLERK_ENABLED=true NODE_OPTIONS=--max_old_space_size=8192 mocha --timeout 30000 --retries 3 --grep '#novu-v2' --require ./swc-register.js --exit --file e2e/setup.ts 'src/**/*.e2e{,-ee}.ts' 'e2e/enterprise/**/*.e2e.ts'",
"migration": "cross-env NODE_ENV=local MIGRATION=true ts-node --transpileOnly",
"clickhouse:migrate": "clickhouse-migrations migrate --host=http://localhost:8123 --user=default --password= --db=novu-local --migrations-home=./migrations/clickhouse-migrations",
"clickhouse:migrate:local": "clickhouse-migrations migrate --host=http://localhost:8123 --user=default --password= --db=novu-local --migrations-home=./migrations/clickhouse-migrations",
"clickhouse:migrate:prod": "clickhouse-migrations migrate --migrations-home=./migrations/clickhouse-migrations",
"link:submodules": "pnpm link ../../enterprise/packages/auth && pnpm link ../../enterprise/packages/translation && pnpm link ../../enterprise/packages/billing",
"admin:remove-user-account": "cross-env NODE_ENV=local MIGRATION=true ts-node --transpileOnly ./admin/remove-user-account.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildActiveSubscribersChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildActiveSubscribersChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class BuildActiveSubscribersChart {

@InstrumentUsecase()
async execute(command: BuildActiveSubscribersChartCommand): Promise<ActiveSubscribersDataPointDto> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

// Calculate previous period dates
const periodDuration = endDate.getTime() - startDate.getTime();
Expand All @@ -27,7 +27,8 @@ export class BuildActiveSubscribersChart {
startDate,
endDate,
previousStartDate,
previousEndDate
previousEndDate,
workflowIds
);

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildActiveSubscribersTrendChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildActiveSubscribersTrendChartCommand extends EnvironmentCommand
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export class BuildActiveSubscribersTrendChart {

@InstrumentUsecase()
async execute(command: BuildActiveSubscribersTrendChartCommand): Promise<ActiveSubscribersTrendDataPointDto[]> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

const activeSubscribers = await this.workflowRunRepository.getActiveSubscribersTrendData(
environmentId,
organizationId,
startDate,
endDate
endDate,
workflowIds
);

const chartDataMap = new Map<string, number>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildAvgMessagesPerSubscriberChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildAvgMessagesPerSubscriberChartCommand extends EnvironmentComman
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class BuildAvgMessagesPerSubscriberChart {

@InstrumentUsecase()
async execute(command: BuildAvgMessagesPerSubscriberChartCommand): Promise<AvgMessagesPerSubscriberDataPointDto> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

// Calculate previous period dates
const periodDuration = endDate.getTime() - startDate.getTime();
Expand All @@ -27,7 +27,8 @@ export class BuildAvgMessagesPerSubscriberChart {
startDate,
endDate,
previousStartDate,
previousEndDate
previousEndDate,
workflowIds
);

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildDeliveryTrendChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildDeliveryTrendChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export class BuildDeliveryTrendChart {

@InstrumentUsecase()
async execute(command: BuildDeliveryTrendChartCommand): Promise<ChartDataPointDto[]> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

const stepRuns = await this.stepRunRepository.getDeliveryTrendData(
environmentId,
organizationId,
startDate,
endDate
endDate,
workflowIds
);

const chartDataMap = new Map<string, Map<string, number>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildInteractionTrendChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildInteractionTrendChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export class BuildInteractionTrendChart {

@InstrumentUsecase()
async execute(command: BuildInteractionTrendChartCommand): Promise<InteractionTrendDataPointDto[]> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

const traces = await this.traceLogRepository.getInteractionTrendData(
environmentId,
organizationId,
startDate,
endDate
endDate,
workflowIds
);

const chartDataMap = new Map<string, Map<string, number>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildMessagesDeliveredChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildMessagesDeliveredChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class BuildMessagesDeliveredChart {

@InstrumentUsecase()
async execute(command: BuildMessagesDeliveredChartCommand): Promise<MessagesDeliveredDataPointDto> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

// Calculate previous period dates
const periodDuration = endDate.getTime() - startDate.getTime();
Expand All @@ -27,7 +27,8 @@ export class BuildMessagesDeliveredChart {
startDate,
endDate,
previousStartDate,
previousEndDate
previousEndDate,
workflowIds
);

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildProviderByVolumeChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildProviderByVolumeChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export class BuildProviderByVolumeChart {

@InstrumentUsecase()
async execute(command: BuildProviderByVolumeChartCommand): Promise<ProviderVolumeDataPointDto[]> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

const providerData = await this.stepRunRepository.getProviderVolumeData(
environmentId,
organizationId,
startDate,
endDate
endDate,
workflowIds
);

return providerData.map((dataPoint) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildTotalInteractionsChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildTotalInteractionsChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class BuildTotalInteractionsChart {

@InstrumentUsecase()
async execute(command: BuildTotalInteractionsChartCommand): Promise<TotalInteractionsDataPointDto> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

// Calculate previous period dates
const periodDuration = endDate.getTime() - startDate.getTime();
Expand All @@ -27,7 +27,8 @@ export class BuildTotalInteractionsChart {
startDate,
endDate,
previousStartDate,
previousEndDate
previousEndDate,
workflowIds
);

return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildWorkflowByVolumeChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildWorkflowByVolumeChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export class BuildWorkflowByVolumeChart {

@InstrumentUsecase()
async execute(command: BuildWorkflowByVolumeChartCommand): Promise<WorkflowVolumeDataPointDto[]> {
const { environmentId, organizationId, startDate, endDate } = command;
const { environmentId, organizationId, startDate, endDate, workflowIds } = command;

const workflowRuns = await this.workflowRunRepository.getWorkflowVolumeData(
environmentId,
organizationId,
startDate,
endDate
endDate,
workflowIds
);

const chartData: WorkflowVolumeDataPointDto[] = workflowRuns.map((workflowRun) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentCommand } from '@novu/application-generic';
import { IsDate, IsDefined } from 'class-validator';
import { IsArray, IsDate, IsDefined, IsOptional, IsString } from 'class-validator';

export class BuildWorkflowRunsMetricChartCommand extends EnvironmentCommand {
@IsDate()
Expand All @@ -9,4 +9,9 @@ export class BuildWorkflowRunsMetricChartCommand extends EnvironmentCommand {
@IsDate()
@IsDefined()
endDate: Date;

@IsOptional()
@IsArray()
@IsString({ each: true })
workflowIds?: string[];
}
Loading
Loading