This directory holds the code for the Sentry Integration Tutorial.
You can either:
- install and use it as a Medusa application;
- or copy its source files into an existing Medusa application.
- Node.js v20+
- Git CLI
- PostgreSQL
- Sentry account with a Node.js project.
- Clone the repository and change to the
sentry-integrationdirectory:
git clone https://github.com/medusajs/examples.git
cd examples/sentry-integration2. Rename the .env.template file to .env.
3. If necessary, change the PostgreSQL username, password, and host in the DATABASE_URL environment variable.
4. Set the Sentry environment variable:
SENTRY_DSN=Where SENTRY_DSN is the Data Source Name (DSN) of your Sentry project.
Learn more about retrieving this variable in the tutorial
5. Install dependencies:
yarn # or npm install6. Setup and seed the database:
npx medusa db:setup
yarn seed # or npm run seed7. Start the Medusa application:
yarn dev # or npm run devYou can test it out by opening the Medusa Admin dashboard or sending a request to the /test-sentry API route. Then, check out the Sentry dashboard to see the requests and operations traced.
If you have an existing Medusa application, copy the instrumentation.ts file into your project.
Next, add the following environment variable:
SENTRY_DSN=Where SENTRY_DSN is the Data Source Name (DSN) of your Sentry project.
Learn more about retrieving this variable in the tutorial
After that, install the necessary Sentry an OpenTelemetry packages:
yarn add @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/sdk-trace-node @opentelemetry/instrumentation-pg @sentry/node @opentelemetry/api @opentelemetry/exporter-trace-otlp-grpc @sentry/opentelemetry-nodeYou can test it out by opening the Medusa Admin dashboard. Then, check out the Sentry dashboard to see the requests and operations traced.