Skip to content

Commit 2b03031

Browse files
committed
INIT Sentry - error tracking
1 parent 14466dc commit 2b03031

File tree

8 files changed

+3058
-245
lines changed

8 files changed

+3058
-245
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ SPREE_API_KEY=your_publishable_api_key
77
# Set these to your store's default_country_iso and default_locale
88
NEXT_PUBLIC_DEFAULT_COUNTRY=us
99
NEXT_PUBLIC_DEFAULT_LOCALE=en
10+
11+
# Sentry Error Tracking (optional - set DSN to enable)
12+
SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0
13+
SENTRY_ORG=your-org
14+
SENTRY_PROJECT=your-project
15+
SENTRY_AUTH_TOKEN=your-auth-token

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A modern, headless e-commerce storefront built with Next.js 16, React 19, and th
1212
- **React 19** - Latest React with improved Server Components
1313
- **Tailwind CSS 4** - Utility-first styling
1414
- **TypeScript 5** - Full type safety
15+
- **Sentry** - Error tracking and performance monitoring with source maps
1516
- [@spree/sdk](https://github.com/spree/spree/tree/main/packages/sdk) - Official Spree Commerce SDK
1617
- [@spree/next](https://github.com/spree/spree/tree/main/packages/next) - Server actions, caching, and cookie-based auth
1718

@@ -30,6 +31,7 @@ A modern, headless e-commerce storefront built with Next.js 16, React 19, and th
3031
- Saved payment methods
3132
- **Multi-Region Support** - Country and currency switching via URL segments
3233
- **Responsive Design** - Mobile-first Tailwind CSS styling
34+
- **Error Tracking** - Sentry integration for both server-side and client-side error monitoring with source maps
3335

3436
## Architecture
3537

@@ -75,6 +77,15 @@ SPREE_API_KEY=your_publishable_api_key_here
7577

7678
> Note: These are server-side only variables (no `NEXT_PUBLIC_` prefix needed).
7779
80+
#### Optional variables
81+
82+
| Variable | Description | Default |
83+
|----------|-------------|---------|
84+
| `SENTRY_DSN` | Sentry DSN for error tracking (e.g. `https://key@o0.ingest.sentry.io/0`) | _(disabled)_ |
85+
| `SENTRY_ORG` | Sentry organization slug (for source map uploads) | _(none)_ |
86+
| `SENTRY_PROJECT` | Sentry project slug (for source map uploads) | _(none)_ |
87+
| `SENTRY_AUTH_TOKEN` | Sentry auth token (for source map uploads in CI) | _(none)_ |
88+
7889
### Development
7990

8091
```bash
@@ -217,7 +228,9 @@ The easiest way to deploy is using [Vercel](https://vercel.com/new):
217228

218229
1. Push your code to GitHub
219230
2. Import the repository in Vercel
220-
3. Add environment variables (`SPREE_API_URL`, `SPREE_API_KEY`)
231+
3. Add environment variables:
232+
- `SPREE_API_URL` and `SPREE_API_KEY` (required)
233+
- `SENTRY_DSN`, `SENTRY_ORG`, `SENTRY_PROJECT`, `SENTRY_AUTH_TOKEN` (optional — for error tracking with readable stack traces)
221234
4. Deploy
222235

223236
## License

next.config.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import { withSentryConfig } from "@sentry/nextjs";
12
import type { NextConfig } from "next";
23

34
const nextConfig: NextConfig = {
5+
env: {
6+
NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN || "",
7+
},
48
transpilePackages: ["@spree/next", "@spree/sdk"],
59
turbopack: {
610
rules: {
@@ -51,4 +55,23 @@ const nextConfig: NextConfig = {
5155
},
5256
};
5357

54-
export default nextConfig;
58+
export default process.env.SENTRY_DSN
59+
? withSentryConfig(nextConfig, {
60+
org: process.env.SENTRY_ORG,
61+
project: process.env.SENTRY_PROJECT,
62+
authToken: process.env.SENTRY_AUTH_TOKEN,
63+
silent: !process.env.CI,
64+
65+
// Upload a larger set of source maps for prettier stack traces (increases build time)
66+
widenClientFileUpload: true,
67+
68+
// Automatically delete source maps after uploading to Sentry
69+
// so they are not served publicly
70+
sourcemaps: {
71+
deleteSourcemapsAfterUpload: true,
72+
},
73+
74+
// Disables the Sentry SDK build-time telemetry
75+
telemetry: false,
76+
})
77+
: nextConfig;

0 commit comments

Comments
 (0)