generator-jhipster-sentry-module 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -151,20 +151,20 @@ After running the generator, verify that Sentry has been added successfully by c
151
151
  ```xml
152
152
  <dependency>
153
153
  <groupId>io.sentry</groupId>
154
- <artifactId>sentry-spring-boot-starter</artifactId>
155
- <version>7.3.0</version>
154
+ <artifactId>sentry-spring-boot-starter-jakarta</artifactId>
155
+ <version>8.29.0</version>
156
156
  </dependency>
157
157
  ```
158
158
 
159
159
  **Gradle Projects:**
160
160
  - ✅ Check `build.gradle` for Sentry dependency:
161
161
  ```gradle
162
- implementation 'io.sentry:sentry-spring-boot-starter:7.3.0'
162
+ implementation 'io.sentry:sentry-spring-boot-starter-jakarta:8.29.0'
163
163
  ```
164
164
 
165
165
  **Frontend (package.json):**
166
- - ✅ For React: Check for `@sentry/react: ^7.3.0`
167
- - ✅ For Angular: Check for `@sentry/angular: ^7.3.0`
166
+ - ✅ For React: Check for `@sentry/react: ^8.29.0`
167
+ - ✅ For Angular: Check for `@sentry/angular: ^8.29.0`
168
168
 
169
169
  ### 3. Check Module Registration
170
170
 
@@ -185,7 +185,7 @@ After running the generator, verify that Sentry has been added successfully by c
185
185
  **Backend (Spring Boot):**
186
186
  - ✅ Sentry should auto-configure when Spring Boot starts
187
187
  - ✅ Check application logs for Sentry initialization
188
- - ✅ Test by throwing an exception - it should appear in Sentry dashboard
188
+ - ✅ A `SentryTestResource` is added at `.../web/rest/SentryTestResource.java` with `GET /api/sentry-test/illegal-argument` and `GET /api/sentry-test/null-pointer` to test Sentry
189
189
 
190
190
  **Frontend:**
191
191
  - ✅ Import and initialize Sentry in your main app file:
@@ -200,14 +200,29 @@ After running the generator, verify that Sentry has been added successfully by c
200
200
 
201
201
  ### 5. Test Sentry Integration
202
202
 
203
- **Backend Test:**
204
- ```java
205
- // Create a test endpoint or add to existing controller
206
- @GetMapping("/api/test-sentry")
207
- public void testSentry() {
208
- throw new RuntimeException("Test Sentry integration");
209
- }
210
- ```
203
+ The module adds a **Sentry test REST controller** with two endpoints you can call to verify Sentry captures backend exceptions.
204
+
205
+ **Backend test endpoints** (in `SentryTestResource`):
206
+
207
+ | Endpoint | Description |
208
+ |----------|-------------|
209
+ | `GET /api/sentry-test/illegal-argument` | Throws `IllegalArgumentException` and sends it to Sentry |
210
+ | `GET /api/sentry-test/null-pointer` | Throws `NullPointerException`, logs a formatted message, and sends the exception to Sentry |
211
+
212
+ **How to test (backend):**
213
+
214
+ 1. Start your application (e.g. `./mvnw spring-boot:run` or `./gradlew bootRun`).
215
+ 2. Call one of the endpoints (they will return 500 and the error will appear in Sentry):
216
+
217
+ ```bash
218
+ # Test IllegalArgumentException
219
+ curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/sentry-test/illegal-argument
220
+
221
+ # Test NullPointerException (also sends a formatted log as breadcrumb)
222
+ curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/sentry-test/null-pointer
223
+ ```
224
+
225
+ 3. Check your Sentry project dashboard; you should see the two exceptions with stack traces.
211
226
 
212
227
  **Frontend Test:**
213
228
  ```typescript
@@ -71,12 +71,15 @@ module.exports = class extends Generator {
71
71
  const {
72
72
  baseName,
73
73
  packageName,
74
+ packageFolder,
74
75
  clientFramework,
75
76
  buildTool
76
77
  } = this.jhipsterAppConfig;
77
78
 
78
79
  const resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
80
+ const javaDir = 'src/main/java/';
79
81
  const webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
82
+ const packageFolderResolved = packageFolder || packageName.replace(/\./g, '/');
80
83
 
81
84
  this.log('\n--- JHipster Config ---');
82
85
  this.log(`baseName=${baseName}`);
@@ -114,6 +117,16 @@ module.exports = class extends Generator {
114
117
  }
115
118
  );
116
119
 
120
+ /* ============================
121
+ Sentry test REST controller
122
+ ============================= */
123
+
124
+ this.fs.copyTpl(
125
+ this.templatePath('server/java/SentryTestResource.java.ejs'),
126
+ this.destinationPath(`${javaDir}${packageFolderResolved}/web/rest/SentryTestResource.java`),
127
+ { packageName }
128
+ );
129
+
117
130
  /* ============================
118
131
  Backend Dependency Injection
119
132
  ============================= */
@@ -122,14 +135,14 @@ module.exports = class extends Generator {
122
135
  const pomPath = this.destinationPath('pom.xml');
123
136
  if (fs.existsSync(pomPath)) {
124
137
  let pom = fs.readFileSync(pomPath, 'utf8');
125
- if (!pom.includes('sentry-spring-boot-starter')) {
138
+ if (!pom.includes('sentry-spring-boot-starter-jakarta')) {
126
139
  pom = pom.replace(
127
140
  '</dependencies>',
128
141
  `
129
142
  <dependency>
130
143
  <groupId>io.sentry</groupId>
131
- <artifactId>sentry-spring-boot-starter</artifactId>
132
- <version>7.3.0</version>
144
+ <artifactId>sentry-spring-boot-starter-jakarta</artifactId>
145
+ <version>8.29.0</version>
133
146
  </dependency>
134
147
  </dependencies>`
135
148
  );
@@ -142,10 +155,10 @@ module.exports = class extends Generator {
142
155
  const gradlePath = this.destinationPath('build.gradle');
143
156
  if (fs.existsSync(gradlePath)) {
144
157
  let gradle = fs.readFileSync(gradlePath, 'utf8');
145
- if (!gradle.includes('sentry-spring-boot-starter')) {
158
+ if (!gradle.includes('sentry-spring-boot-starter-jakarta')) {
146
159
  gradle += `
147
160
  dependencies {
148
- implementation "io.sentry:sentry-spring-boot-starter:7.3.0"
161
+ implementation "io.sentry:sentry-spring-boot-starter-jakarta:8.29.0"
149
162
  }
150
163
  `;
151
164
  fs.writeFileSync(gradlePath, gradle);
@@ -163,7 +176,7 @@ dependencies {
163
176
  pkg.dependencies = pkg.dependencies || {};
164
177
 
165
178
  if (clientFramework === 'react') {
166
- pkg.dependencies['@sentry/react'] = '^7.3.0';
179
+ pkg.dependencies['@sentry/react'] = '^8.29.0';
167
180
 
168
181
  this.fs.copyTpl(
169
182
  this.templatePath('client/react/sentry.ts.ejs'),
@@ -173,7 +186,7 @@ dependencies {
173
186
  }
174
187
 
175
188
  if (clientFramework === 'angularX') {
176
- pkg.dependencies['@sentry/angular'] = '^7.3.0';
189
+ pkg.dependencies['@sentry/angular'] = '^8.29.0';
177
190
 
178
191
  this.fs.copyTpl(
179
192
  this.templatePath('client/angular/sentry.ts.ejs'),
@@ -0,0 +1,51 @@
1
+ package <%= packageName %>.web.rest;
2
+
3
+ import io.sentry.Sentry;
4
+ import org.slf4j.Logger;
5
+ import org.slf4j.LoggerFactory;
6
+ import org.springframework.http.ResponseEntity;
7
+ import org.springframework.web.bind.annotation.GetMapping;
8
+ import org.springframework.web.bind.annotation.RequestMapping;
9
+ import org.springframework.web.bind.annotation.RestController;
10
+
11
+ /**
12
+ * REST controller for testing Sentry error reporting.
13
+ * Exposes endpoints that trigger exceptions and send them to Sentry.
14
+ */
15
+ @RestController
16
+ @RequestMapping("/api/sentry-test")
17
+ public class SentryTestResource {
18
+
19
+ private static final Logger LOG = LoggerFactory.getLogger(SentryTestResource.class);
20
+
21
+ /**
22
+ * Triggers an IllegalArgumentException and sends it to Sentry.
23
+ * Use this endpoint to verify Sentry captures backend exceptions.
24
+ */
25
+ @GetMapping("/illegal-argument")
26
+ public ResponseEntity<Void> testIllegalArgument() {
27
+ LOG.error("Testing Sentry IllegalArgumentException");
28
+ try {
29
+ throw new IllegalArgumentException("This is a test IllegalArgumentException for Sentry");
30
+ } catch (Exception e) {
31
+ Sentry.captureException(e);
32
+ throw e;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Triggers a NullPointerException and sends it to Sentry, plus a formatted log message.
38
+ * Use this endpoint to verify Sentry captures backend exceptions and breadcrumbs.
39
+ */
40
+ @GetMapping("/null-pointer")
41
+ public ResponseEntity<Void> testNullPointer() {
42
+ LOG.error("Testing Sentry NullPointerException");
43
+ try {
44
+ throw new NullPointerException("This is a test NullPointerException for Sentry");
45
+ } catch (Exception e) {
46
+ Sentry.logger().error("A %s log message", "formatted");
47
+ Sentry.captureException(e);
48
+ throw e;
49
+ }
50
+ }
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-jhipster-sentry-module",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Adding Sentry integration to JHipster projects",
5
5
  "keywords": [
6
6
  "yeoman-generator",