diff --git a/src/app/concepts/[id]/page.tsx b/src/app/concepts/[id]/page.tsx index 5a7614e..fc5a2df 100644 --- a/src/app/concepts/[id]/page.tsx +++ b/src/app/concepts/[id]/page.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { notFound } from 'next/navigation' import React from 'react' import { App } from '@/concept/service/Service' @@ -62,9 +63,13 @@ export default async function Page({ params }: { params: { id: string } }) { notFound() } + Sentry.captureException(e) + return

{e.message}

} + Sentry.captureException(e) + return

An unexpected error occurred

} } diff --git a/src/app/ideas/[id]/page.tsx b/src/app/ideas/[id]/page.tsx index e5abba0..804f325 100644 --- a/src/app/ideas/[id]/page.tsx +++ b/src/app/ideas/[id]/page.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { notFound } from 'next/navigation' import React from 'react' import { App } from '@/idea/service/Service' @@ -18,9 +19,13 @@ export default async function Page({ params }: { params: { id: string } }) { notFound() } + Sentry.captureException(e) + return

{e.message}

} + Sentry.captureException(e) + return

An unexpected error occurred

} } diff --git a/src/app/ideas/[id]/social_media_campaigns/page.tsx b/src/app/ideas/[id]/social_media_campaigns/page.tsx index bd1ad74..943e50a 100644 --- a/src/app/ideas/[id]/social_media_campaigns/page.tsx +++ b/src/app/ideas/[id]/social_media_campaigns/page.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/nextjs' import { notFound } from 'next/navigation' import React from 'react' import { App } from '@/idea/service/Service' @@ -18,9 +19,13 @@ export default async function Page({ params }: { params: { id: string } }) { notFound() } + Sentry.captureException(e) + return

{e.message}

} + Sentry.captureException(e) + return

An unexpected error occurred

} } diff --git a/src/concept/app/queries/GetConcept.ts b/src/concept/app/queries/GetConcept.ts index c091b91..08b56ad 100644 --- a/src/concept/app/queries/GetConcept.ts +++ b/src/concept/app/queries/GetConcept.ts @@ -19,22 +19,16 @@ export class GetConceptHandler { Sentry.setTag('query_type', 'GetConcept') Sentry.setTag('concept_id', query.id) - try { - const concept = await this.readModel.getById(query.id) + const concept = await this.readModel.getById(query.id) - if (!concept) { - throw new NotFoundError(`Concept ${query.id} does not exist`) - } - - if (!concept.isAvailable()) { - throw new ApplicationError('Concept is not available anymore') - } - - return concept - } catch (e) { - Sentry.captureException(e) + if (!concept) { + throw new NotFoundError(`Concept ${query.id} does not exist`) + } - throw e + if (!concept.isAvailable()) { + throw new ApplicationError('Concept is not available anymore') } + + return concept } } diff --git a/src/idea/app/queries/GetIdea.ts b/src/idea/app/queries/GetIdea.ts index 2e6cc7e..a92f1fb 100644 --- a/src/idea/app/queries/GetIdea.ts +++ b/src/idea/app/queries/GetIdea.ts @@ -93,112 +93,106 @@ export class GetIdeaHandler { Sentry.setTag('query_type', 'GetIdea') Sentry.setTag('idea_id', query.id) - try { - const idea = await this.readModel.getById(query.id) + const idea = await this.readModel.getById(query.id) - if (!idea) { - throw new NotFoundError(`Idea ${query.id} does not exist`) - } - - const valueProposition = idea.getValueProposition() - const targetAudiences = idea.getTargetAudiences() - const marketAnalysis = idea.getMarketAnalysis() - const competitorAnalysis = idea.getCompetitorAnalysis() - const productNames = idea.getProductNames() - const swotAnalysis = idea.getSWOTAnalysis() - const elevatorPitches = idea.getElevatorPitches() - const googleTrendsKeywords = idea.getGoogleTrendsKeywords() - const contentIdeasForMarketing = idea.getContentIdeasForMarketing() + if (!idea) { + throw new NotFoundError(`Idea ${query.id} does not exist`) + } - return { - id: idea.getId().getValue(), - problem: idea.getProblem().getValue(), - marketExistence: idea.getMarketExistence(), - valueProposition: valueProposition - ? { - mainBenefit: valueProposition.getMainBenefit(), - problemSolving: valueProposition.getProblemSolving(), - differentiation: valueProposition.getDifferentiation(), - } - : null, - targetAudiences: targetAudiences.map((audience) => ({ - id: audience.getId().getValue(), - segment: audience.getSegment(), - description: audience.getDescription(), - why: audience.getWhy(), - painPoints: audience.getPainPoints(), - targetingStrategy: audience.getTargetingStrategy(), - })), - marketAnalysis: marketAnalysis - ? { - trends: marketAnalysis.getTrends(), - userBehaviors: marketAnalysis.getUserBehaviors(), - marketGaps: marketAnalysis.getMarketGaps(), - innovationOpportunities: - marketAnalysis.getInnovationOpportunities(), - strategicDirection: marketAnalysis.getStrategicDirection(), - } - : null, - competitorAnalysis: competitorAnalysis - ? { - competitors: competitorAnalysis.getCompetitors(), - comparison: competitorAnalysis.getComparison(), - differentiationSuggestions: - competitorAnalysis.getDifferentiationSuggestions(), - } - : null, - productNames: productNames - ? productNames.map((product) => ({ - productName: product.getProductName(), - domains: product.getDomains(), - why: product.getWhy(), - tagline: product.getTagline(), - targetAudienceInsight: product.getTargetAudienceInsight(), - similarNames: product.getSimilarNames(), - brandingPotential: product.getBrandingPotential(), - })) - : null, - swotAnalysis: swotAnalysis - ? { - strengths: swotAnalysis.getStrengths(), - weaknesses: swotAnalysis.getWeaknesses(), - opportunities: swotAnalysis.getOpportunities(), - threats: swotAnalysis.getThreats(), - } - : null, - elevatorPitches: elevatorPitches - ? elevatorPitches.map((pitch) => ({ - hook: pitch.getHook(), - problem: pitch.getProblem(), - solution: pitch.getSolution(), - valueProposition: pitch.getValueProposition(), - cta: pitch.getCTA(), - })) - : null, - googleTrendsKeywords: googleTrendsKeywords - ? googleTrendsKeywords.map((keyword) => keyword.getKeyword()) - : null, - contentIdeasForMarketing: contentIdeasForMarketing - ? contentIdeasForMarketing.getContentIdeas().reduce( - (acc, contentIdea) => { - const section = contentIdea.getSection().getName() + const valueProposition = idea.getValueProposition() + const targetAudiences = idea.getTargetAudiences() + const marketAnalysis = idea.getMarketAnalysis() + const competitorAnalysis = idea.getCompetitorAnalysis() + const productNames = idea.getProductNames() + const swotAnalysis = idea.getSWOTAnalysis() + const elevatorPitches = idea.getElevatorPitches() + const googleTrendsKeywords = idea.getGoogleTrendsKeywords() + const contentIdeasForMarketing = idea.getContentIdeasForMarketing() - acc[section] = { - platforms: contentIdea.getPlatforms(), - ideas: contentIdea.getIdeas(), - benefits: contentIdea.getBenefits(), - } + return { + id: idea.getId().getValue(), + problem: idea.getProblem().getValue(), + marketExistence: idea.getMarketExistence(), + valueProposition: valueProposition + ? { + mainBenefit: valueProposition.getMainBenefit(), + problemSolving: valueProposition.getProblemSolving(), + differentiation: valueProposition.getDifferentiation(), + } + : null, + targetAudiences: targetAudiences.map((audience) => ({ + id: audience.getId().getValue(), + segment: audience.getSegment(), + description: audience.getDescription(), + why: audience.getWhy(), + painPoints: audience.getPainPoints(), + targetingStrategy: audience.getTargetingStrategy(), + })), + marketAnalysis: marketAnalysis + ? { + trends: marketAnalysis.getTrends(), + userBehaviors: marketAnalysis.getUserBehaviors(), + marketGaps: marketAnalysis.getMarketGaps(), + innovationOpportunities: + marketAnalysis.getInnovationOpportunities(), + strategicDirection: marketAnalysis.getStrategicDirection(), + } + : null, + competitorAnalysis: competitorAnalysis + ? { + competitors: competitorAnalysis.getCompetitors(), + comparison: competitorAnalysis.getComparison(), + differentiationSuggestions: + competitorAnalysis.getDifferentiationSuggestions(), + } + : null, + productNames: productNames + ? productNames.map((product) => ({ + productName: product.getProductName(), + domains: product.getDomains(), + why: product.getWhy(), + tagline: product.getTagline(), + targetAudienceInsight: product.getTargetAudienceInsight(), + similarNames: product.getSimilarNames(), + brandingPotential: product.getBrandingPotential(), + })) + : null, + swotAnalysis: swotAnalysis + ? { + strengths: swotAnalysis.getStrengths(), + weaknesses: swotAnalysis.getWeaknesses(), + opportunities: swotAnalysis.getOpportunities(), + threats: swotAnalysis.getThreats(), + } + : null, + elevatorPitches: elevatorPitches + ? elevatorPitches.map((pitch) => ({ + hook: pitch.getHook(), + problem: pitch.getProblem(), + solution: pitch.getSolution(), + valueProposition: pitch.getValueProposition(), + cta: pitch.getCTA(), + })) + : null, + googleTrendsKeywords: googleTrendsKeywords + ? googleTrendsKeywords.map((keyword) => keyword.getKeyword()) + : null, + contentIdeasForMarketing: contentIdeasForMarketing + ? contentIdeasForMarketing.getContentIdeas().reduce( + (acc, contentIdea) => { + const section = contentIdea.getSection().getName() - return acc - }, - {} as Record - ) - : null, - } - } catch (e) { - Sentry.captureException(e) + acc[section] = { + platforms: contentIdea.getPlatforms(), + ideas: contentIdea.getIdeas(), + benefits: contentIdea.getBenefits(), + } - throw e + return acc + }, + {} as Record + ) + : null, } } } diff --git a/src/idea/app/queries/GetSocialMediaCampaigns.ts b/src/idea/app/queries/GetSocialMediaCampaigns.ts index 2d245de..7ae1868 100644 --- a/src/idea/app/queries/GetSocialMediaCampaigns.ts +++ b/src/idea/app/queries/GetSocialMediaCampaigns.ts @@ -53,29 +53,23 @@ export class GetSocialMediaCampaignsHandler { Sentry.setTag('query_type', 'GetSocialMediaCampaigns') Sentry.setTag('idea_id', query.id) - try { - const idea = await this.readModel.getById(query.id) + const idea = await this.readModel.getById(query.id) - if (!idea) { - throw new NotFoundError(`Idea ${query.id} does not exist`) - } - - const socialMediaCampaigns = idea.getSocialMediaCampaigns() + if (!idea) { + throw new NotFoundError(`Idea ${query.id} does not exist`) + } - return { - id: idea.getId().getValue(), - contents: socialMediaCampaigns - ? { - shortFormContent: socialMediaCampaigns.getShortFormContents(), - longFormContent: socialMediaCampaigns.getLongFormContents(), - videoContent: socialMediaCampaigns.getVideoContents(), - } - : null, - } - } catch (e) { - Sentry.captureException(e) + const socialMediaCampaigns = idea.getSocialMediaCampaigns() - throw e + return { + id: idea.getId().getValue(), + contents: socialMediaCampaigns + ? { + shortFormContent: socialMediaCampaigns.getShortFormContents(), + longFormContent: socialMediaCampaigns.getLongFormContents(), + videoContent: socialMediaCampaigns.getVideoContents(), + } + : null, } } }