generator-jhipster-sentry-module 1.0.11 → 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
@@ -1,4 +1,3 @@
1
- const path = require('path');
2
1
  const fs = require('fs');
3
2
  const chalk = require('chalk');
4
3
  const semver = require('semver');
@@ -8,7 +7,6 @@ const packageJson = require('../../package.json');
8
7
  const JHIPSTER_CONFIG_KEY = 'generator-jhipster';
9
8
 
10
9
  const jhipsterConstants = {
11
- SERVER_MAIN_SRC_DIR: 'src/main/java/',
12
10
  SERVER_MAIN_RES_DIR: 'src/main/resources/',
13
11
  CLIENT_MAIN_SRC_DIR: 'src/main/webapp/'
14
12
  };
@@ -27,7 +25,7 @@ module.exports = class extends Generator {
27
25
  this.jhipsterAppConfig = yoRc[JHIPSTER_CONFIG_KEY];
28
26
 
29
27
  if (!this.jhipsterAppConfig) {
30
- this.log(chalk.red('❌ JHipster configuration missing inside .yo-rc.json'));
28
+ this.log(chalk.red('❌ JHipster config missing in .yo-rc.json'));
31
29
  process.exit(1);
32
30
  }
33
31
 
@@ -38,7 +36,6 @@ module.exports = class extends Generator {
38
36
  );
39
37
 
40
38
  const currentVersion = this.jhipsterAppConfig.jhipsterVersion;
41
-
42
39
  if (currentVersion && !semver.satisfies(currentVersion, '>=8.0.0')) {
43
40
  this.log(
44
41
  chalk.yellow(
@@ -79,7 +76,10 @@ module.exports = class extends Generator {
79
76
  buildTool
80
77
  } = this.jhipsterAppConfig;
81
78
 
79
+ const resourceDir = jhipsterConstants.SERVER_MAIN_RES_DIR;
80
+ const javaDir = 'src/main/java/';
82
81
  const webappDir = jhipsterConstants.CLIENT_MAIN_SRC_DIR;
82
+ const packageFolderResolved = packageFolder || packageName.replace(/\./g, '/');
83
83
 
84
84
  this.log('\n--- JHipster Config ---');
85
85
  this.log(`baseName=${baseName}`);
@@ -99,9 +99,34 @@ module.exports = class extends Generator {
99
99
  enabled: true,
100
100
  dsn: this.promptAnswers.sentryDsn
101
101
  };
102
-
103
102
  this.fs.writeJSON(yoRcPath, yoRc, null, 2);
104
103
 
104
+ /* ============================
105
+ Create sentry.yml
106
+ ============================= */
107
+
108
+ this.fs.copyTpl(
109
+ this.templatePath('server/sentry-application.yml.ejs'),
110
+ this.destinationPath(`${resourceDir}config/sentry.yml`),
111
+ {
112
+ jhipsterAppConfig: {
113
+ sentry: {
114
+ dsn: this.promptAnswers.sentryDsn
115
+ }
116
+ }
117
+ }
118
+ );
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
+
105
130
  /* ============================
106
131
  Backend Dependency Injection
107
132
  ============================= */
@@ -110,14 +135,14 @@ module.exports = class extends Generator {
110
135
  const pomPath = this.destinationPath('pom.xml');
111
136
  if (fs.existsSync(pomPath)) {
112
137
  let pom = fs.readFileSync(pomPath, 'utf8');
113
- if (!pom.includes('sentry-spring-boot-starter')) {
138
+ if (!pom.includes('sentry-spring-boot-starter-jakarta')) {
114
139
  pom = pom.replace(
115
140
  '</dependencies>',
116
141
  `
117
142
  <dependency>
118
143
  <groupId>io.sentry</groupId>
119
- <artifactId>sentry-spring-boot-starter</artifactId>
120
- <version>7.3.0</version>
144
+ <artifactId>sentry-spring-boot-starter-jakarta</artifactId>
145
+ <version>8.29.0</version>
121
146
  </dependency>
122
147
  </dependencies>`
123
148
  );
@@ -130,10 +155,10 @@ module.exports = class extends Generator {
130
155
  const gradlePath = this.destinationPath('build.gradle');
131
156
  if (fs.existsSync(gradlePath)) {
132
157
  let gradle = fs.readFileSync(gradlePath, 'utf8');
133
- if (!gradle.includes('sentry-spring-boot-starter')) {
158
+ if (!gradle.includes('sentry-spring-boot-starter-jakarta')) {
134
159
  gradle += `
135
160
  dependencies {
136
- implementation "io.sentry:sentry-spring-boot-starter:7.3.0"
161
+ implementation "io.sentry:sentry-spring-boot-starter-jakarta:8.29.0"
137
162
  }
138
163
  `;
139
164
  fs.writeFileSync(gradlePath, gradle);
@@ -142,7 +167,7 @@ dependencies {
142
167
  }
143
168
 
144
169
  /* ============================
145
- Frontend Dependency Injection
170
+ Frontend Dependency + File
146
171
  ============================= */
147
172
 
148
173
  const packagePath = this.destinationPath('package.json');
@@ -151,7 +176,7 @@ dependencies {
151
176
  pkg.dependencies = pkg.dependencies || {};
152
177
 
153
178
  if (clientFramework === 'react') {
154
- pkg.dependencies['@sentry/react'] = '^7.3.0';
179
+ pkg.dependencies['@sentry/react'] = '^8.29.0';
155
180
 
156
181
  this.fs.copyTpl(
157
182
  this.templatePath('client/react/sentry.ts.ejs'),
@@ -161,7 +186,7 @@ dependencies {
161
186
  }
162
187
 
163
188
  if (clientFramework === 'angularX') {
164
- pkg.dependencies['@sentry/angular'] = '^7.3.0';
189
+ pkg.dependencies['@sentry/angular'] = '^8.29.0';
165
190
 
166
191
  this.fs.copyTpl(
167
192
  this.templatePath('client/angular/sentry.ts.ejs'),
@@ -177,17 +202,15 @@ dependencies {
177
202
  install() {
178
203
  if (!this.promptAnswers.enableSentry) return;
179
204
 
180
- const clientPackageManager =
205
+ const pkgManager =
181
206
  this.jhipsterAppConfig.clientPackageManager || 'npm';
182
207
 
183
208
  if (this.options['skip-install']) {
184
- this.log(
185
- `Run ${clientPackageManager} install manually to install dependencies`
186
- );
209
+ this.log(`Run ${pkgManager} install manually.`);
187
210
  return;
188
211
  }
189
212
 
190
- this.spawnCommandSync(clientPackageManager, ['install']);
213
+ this.spawnCommandSync(pkgManager, ['install']);
191
214
  }
192
215
 
193
216
  end() {
@@ -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.11",
3
+ "version": "1.0.13",
4
4
  "description": "Adding Sentry integration to JHipster projects",
5
5
  "keywords": [
6
6
  "yeoman-generator",