diff --git a/packages/hub/node-tests/routes/profile-purchases-test.ts b/packages/hub/node-tests/routes/profile-purchases-test.ts index 5e460472d4..18889495be 100644 --- a/packages/hub/node-tests/routes/profile-purchases-test.ts +++ b/packages/hub/node-tests/routes/profile-purchases-test.ts @@ -2,6 +2,7 @@ import { registry, setupHub } from '../helpers/server'; import CardSpaceQueries from '../../queries/card-space'; import MerchantInfoQueries from '../../queries/merchant-info'; import shortUUID from 'short-uuid'; +import { setupSentry, waitForSentryReport } from '../helpers/sentry'; import { setupStubWorkerClient } from '../helpers/stub-worker-client'; import JobTicketsQueries from '../../queries/job-tickets'; @@ -30,6 +31,7 @@ class StubInAppPurchases { } describe('POST /api/profile-purchases', function () { + setupSentry(this); let { getJobIdentifiers, getJobPayloads, getJobSpecs } = setupStubWorkerClient(this); this.beforeEach(function () { @@ -352,6 +354,16 @@ describe('POST /api/profile-purchases', function () { }, ], }); + + let sentryReport = await waitForSentryReport(); + + expect(sentryReport.tags).to.deep.equal({ + action: 'profile-purchases-route', + }); + + expect(sentryReport.error?.message).to.equal( + `Unable to validate purchase, response: ${JSON.stringify(purchaseValidationResponse)}` + ); }); it('rejects when the merchant information is incomplete', async function () { diff --git a/packages/hub/routes/profile-purchases.ts b/packages/hub/routes/profile-purchases.ts index 3c6d4a47c4..3c85968fea 100644 --- a/packages/hub/routes/profile-purchases.ts +++ b/packages/hub/routes/profile-purchases.ts @@ -8,6 +8,7 @@ import { MerchantInfo } from './merchant-infos'; import { validateRequiredFields } from './utils/validation'; import shortUuid from 'short-uuid'; import { JobTicket } from './job-tickets'; +import * as Sentry from '@sentry/node'; export default class ProfilePurchasesRoute { databaseManager = inject('database-manager', { as: 'databaseManager' }); @@ -174,6 +175,11 @@ export default class ProfilePurchasesRoute { ); if (!purchaseValidationResult) { + let error = new Error(`Unable to validate purchase, response: ${JSON.stringify(purchaseValidationResponse)}`); + Sentry.captureException(error, { + tags: { action: 'profile-purchases-route' }, + }); + ctx.status = 422; ctx.body = { errors: [