securenow 5.2.0 → 5.2.2
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/CONSUMING-APPS-GUIDE.md +17 -17
- package/README.md +7 -7
- package/cli.js +6 -6
- package/console-instrumentation.js +2 -2
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/AUTO-BODY-CAPTURE.md +1 -1
- package/docs/AUTO-SETUP-SUMMARY.md +2 -2
- package/docs/AUTO-SETUP.md +4 -4
- package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
- package/docs/BODY-CAPTURE-FIX.md +1 -1
- package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
- package/docs/CHANGELOG-NEXTJS.md +1 -1
- package/docs/COMPLETION-REPORT.md +5 -5
- package/docs/CUSTOMER-GUIDE.md +16 -16
- package/docs/EASIEST-SETUP.md +5 -5
- package/docs/EXPRESS-BODY-CAPTURE.md +10 -10
- package/docs/IMPLEMENTATION-SUMMARY.md +10 -10
- package/docs/LOGGING-GUIDE.md +27 -27
- package/docs/LOGGING-QUICKSTART.md +13 -13
- package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
- package/docs/NEXTJS-GUIDE.md +14 -14
- package/docs/NEXTJS-QUICKSTART.md +1 -1
- package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
- package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
- package/docs/REDACTION-EXAMPLES.md +1 -1
- package/docs/REQUEST-BODY-CAPTURE.md +4 -4
- package/docs/SOLUTION-SUMMARY.md +4 -4
- package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
- package/examples/README.md +6 -6
- package/examples/instrumentation-with-auto-capture.ts +1 -1
- package/examples/nextjs-env-example.txt +2 -2
- package/examples/nextjs-instrumentation.js +1 -1
- package/examples/nextjs-instrumentation.ts +1 -1
- package/examples/nextjs-with-logging-example.md +6 -6
- package/examples/nextjs-with-options.ts +1 -1
- package/examples/test-nextjs-setup.js +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +49 -7
- package/package.json +2 -3
- package/postinstall.js +6 -6
- package/register.d.ts +1 -1
- package/tracing.d.ts +1 -1
|
@@ -39,9 +39,9 @@ SECURENOW_LOGGING_ENABLED=1
|
|
|
39
39
|
SECURENOW_APPID=my-nextjs-app
|
|
40
40
|
SECURENOW_INSTANCE=http://localhost:4318
|
|
41
41
|
|
|
42
|
-
# For
|
|
43
|
-
# SECURENOW_INSTANCE=https://ingest.<region>.
|
|
44
|
-
# OTEL_EXPORTER_OTLP_HEADERS="
|
|
42
|
+
# For SecureNow or managed OTLP (example):
|
|
43
|
+
# SECURENOW_INSTANCE=https://ingest.<region>.securenow.ai:443
|
|
44
|
+
# OTEL_EXPORTER_OTLP_HEADERS="x-api-key=<your-key>"
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
### 4. Enable Instrumentation in `next.config.js`
|
|
@@ -239,9 +239,9 @@ You should see in the console:
|
|
|
239
239
|
SecureNow initialized with logging enabled
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
-
## View Logs in
|
|
242
|
+
## View Logs in SecureNow
|
|
243
243
|
|
|
244
|
-
1. Open your
|
|
244
|
+
1. Open your SecureNow dashboard
|
|
245
245
|
2. Navigate to **Logs** section
|
|
246
246
|
3. Filter by `service.name = my-nextjs-app`
|
|
247
247
|
4. See all your application logs with:
|
|
@@ -298,4 +298,4 @@ await import('securenow/console-instrumentation'); // Second
|
|
|
298
298
|
|
|
299
299
|
- [Complete Logging Guide](../docs/LOGGING-GUIDE.md)
|
|
300
300
|
- [Next.js Complete Guide](../docs/NEXTJS-GUIDE.md)
|
|
301
|
-
- [
|
|
301
|
+
- [SecureNow](https://securenow.ai/)
|
|
@@ -10,7 +10,7 @@ import { registerSecureNow } from 'securenow/nextjs';
|
|
|
10
10
|
export function register() {
|
|
11
11
|
registerSecureNow({
|
|
12
12
|
serviceName: 'my-nextjs-app',
|
|
13
|
-
endpoint: 'http://your-
|
|
13
|
+
endpoint: 'http://your-otlp-collector:4318',
|
|
14
14
|
noUuid: false,
|
|
15
15
|
disableInstrumentations: ['fs', 'dns'],
|
|
16
16
|
headers: {
|
|
@@ -58,7 +58,7 @@ setTimeout(() => {
|
|
|
58
58
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
59
59
|
console.log('✅ All tests passed!');
|
|
60
60
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
61
|
-
console.log('\nCheck your
|
|
61
|
+
console.log('\nCheck your SecureNow dashboard for traces from "test-nextjs-app"\n');
|
|
62
62
|
process.exit(0);
|
|
63
63
|
}, 2000);
|
|
64
64
|
|
package/nextjs.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface RegisterOptions {
|
|
|
51
51
|
* export function register() {
|
|
52
52
|
* registerSecureNow({
|
|
53
53
|
* serviceName: 'my-nextjs-app',
|
|
54
|
-
* endpoint: 'http://
|
|
54
|
+
* endpoint: 'http://your-otlp-backend.example.com:4318',
|
|
55
55
|
* noUuid: true,
|
|
56
56
|
* });
|
|
57
57
|
* }
|
package/nextjs.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* 2. Set environment variables:
|
|
16
16
|
* SECURENOW_APPID=my-nextjs-app
|
|
17
|
-
* SECURENOW_INSTANCE=http://your-
|
|
17
|
+
* SECURENOW_INSTANCE=http://your-otlp-backend:4318
|
|
18
18
|
*
|
|
19
19
|
* That's it! 🎉 No webpack warnings!
|
|
20
20
|
*/
|
|
@@ -548,8 +548,48 @@ function registerSecureNow(options = {}) {
|
|
|
548
548
|
|
|
549
549
|
console.log('[securenow] 📋 Logging: ENABLED → %s', logsUrl);
|
|
550
550
|
|
|
551
|
+
// Auto-log every incoming HTTP request/response
|
|
552
|
+
try {
|
|
553
|
+
const http = require('http');
|
|
554
|
+
const originalEmit = http.Server.prototype.emit;
|
|
555
|
+
http.Server.prototype.emit = function (event, req, res) {
|
|
556
|
+
if (event === 'request' && req && res) {
|
|
557
|
+
const start = Date.now();
|
|
558
|
+
const method = req.method;
|
|
559
|
+
const url = req.url;
|
|
560
|
+
|
|
561
|
+
res.on('finish', () => {
|
|
562
|
+
const duration = Date.now() - start;
|
|
563
|
+
const status = res.statusCode;
|
|
564
|
+
const ip = req.headers['x-forwarded-for'] || req.headers['x-real-ip'] || req.socket?.remoteAddress || '-';
|
|
565
|
+
const ua = req.headers['user-agent'] || '-';
|
|
566
|
+
const body = `${method} ${url} ${status} ${duration}ms ip=${ip} ua=${ua}`;
|
|
567
|
+
const severity = status >= 500 ? SeverityNumber.ERROR : status >= 400 ? SeverityNumber.WARN : SeverityNumber.INFO;
|
|
568
|
+
const severityText = status >= 500 ? 'ERROR' : status >= 400 ? 'WARN' : 'INFO';
|
|
569
|
+
origLog.call(console, '[securenow] %s %s %d %dms', method, url, status, duration);
|
|
570
|
+
try {
|
|
571
|
+
logger.emit({
|
|
572
|
+
severityNumber: severity,
|
|
573
|
+
severityText,
|
|
574
|
+
body,
|
|
575
|
+
attributes: {
|
|
576
|
+
'http.method': method,
|
|
577
|
+
'http.url': url,
|
|
578
|
+
'http.status_code': status,
|
|
579
|
+
'http.duration_ms': duration,
|
|
580
|
+
'http.client_ip': String(ip).split(',')[0].trim(),
|
|
581
|
+
'http.user_agent': ua,
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
} catch (_) {}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return originalEmit.apply(this, arguments);
|
|
588
|
+
};
|
|
589
|
+
console.log('[securenow] 📋 HTTP request logging: ENABLED');
|
|
590
|
+
} catch (_) {}
|
|
591
|
+
|
|
551
592
|
// Graceful shutdown for logs
|
|
552
|
-
const origShutdown = sdk.shutdown?.bind(sdk);
|
|
553
593
|
process.on('SIGTERM', async () => { try { await loggerProvider.shutdown(); } catch (_) {} });
|
|
554
594
|
process.on('SIGINT', async () => { try { await loggerProvider.shutdown(); } catch (_) {} });
|
|
555
595
|
} catch (e) {
|
|
@@ -562,11 +602,13 @@ function registerSecureNow(options = {}) {
|
|
|
562
602
|
|
|
563
603
|
isRegistered = true;
|
|
564
604
|
|
|
565
|
-
// Free trial banner
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
605
|
+
// Free trial banner (optional — may not be bundled in standalone builds)
|
|
606
|
+
try {
|
|
607
|
+
const { isFreeTrial, patchHttpForBanner } = require('./free-trial-banner');
|
|
608
|
+
if (isFreeTrial(endpointBase) && String(env('SECURENOW_HIDE_BANNER')) !== '1') {
|
|
609
|
+
patchHttpForBanner();
|
|
610
|
+
}
|
|
611
|
+
} catch (_) {}
|
|
570
612
|
|
|
571
613
|
console.log('[securenow] ✅ OpenTelemetry started for Next.js → %s', tracesUrl);
|
|
572
614
|
console.log('[securenow] 📊 Auto-capturing comprehensive request metadata:');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securenow",
|
|
3
|
-
"version": "5.2.
|
|
4
|
-
"description": "OpenTelemetry instrumentation for Node.js and Next.js - Send traces and logs to
|
|
3
|
+
"version": "5.2.2",
|
|
4
|
+
"description": "OpenTelemetry instrumentation for Node.js and Next.js - Send traces and logs to any OTLP-compatible backend",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "register.js",
|
|
7
7
|
"types": "register.d.ts",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"monitoring",
|
|
23
23
|
"nextjs",
|
|
24
24
|
"next.js",
|
|
25
|
-
"signoz",
|
|
26
25
|
"instrumentation",
|
|
27
26
|
"telemetry",
|
|
28
27
|
"distributed-tracing",
|
package/postinstall.js
CHANGED
|
@@ -53,7 +53,7 @@ export function register() {
|
|
|
53
53
|
* SECURENOW_APPID=my-nextjs-app
|
|
54
54
|
*
|
|
55
55
|
* Optional:
|
|
56
|
-
* SECURENOW_INSTANCE=http://your-
|
|
56
|
+
* SECURENOW_INSTANCE=http://your-otlp-backend:4318
|
|
57
57
|
* OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-key"
|
|
58
58
|
* OTEL_LOG_LEVEL=info
|
|
59
59
|
*/
|
|
@@ -77,7 +77,7 @@ export function register() {
|
|
|
77
77
|
* SECURENOW_APPID=my-nextjs-app
|
|
78
78
|
*
|
|
79
79
|
* Optional:
|
|
80
|
-
* SECURENOW_INSTANCE=http://your-
|
|
80
|
+
* SECURENOW_INSTANCE=http://your-otlp-backend:4318
|
|
81
81
|
* OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-key"
|
|
82
82
|
* OTEL_LOG_LEVEL=info
|
|
83
83
|
*
|
|
@@ -150,9 +150,9 @@ function createEnvTemplate(targetPath) {
|
|
|
150
150
|
# Required: Your application identifier
|
|
151
151
|
SECURENOW_APPID=my-nextjs-app
|
|
152
152
|
|
|
153
|
-
# Optional: Your
|
|
153
|
+
# Optional: Your OTLP-compatible backend / collector endpoint
|
|
154
154
|
# Default: https://freetrial.securenow.ai:4318
|
|
155
|
-
SECURENOW_INSTANCE=http://your-
|
|
155
|
+
SECURENOW_INSTANCE=http://your-otlp-backend:4318
|
|
156
156
|
|
|
157
157
|
# Optional: API key or authentication headers
|
|
158
158
|
# OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key-here"
|
|
@@ -270,14 +270,14 @@ async function setup() {
|
|
|
270
270
|
console.log('│ │');
|
|
271
271
|
console.log('│ 1. Edit .env.local and set: │');
|
|
272
272
|
console.log('│ SECURENOW_APPID=your-app-name │');
|
|
273
|
-
console.log('│ SECURENOW_INSTANCE=http://
|
|
273
|
+
console.log('│ SECURENOW_INSTANCE=http://your-otlp-backend:4318 │');
|
|
274
274
|
if (shouldCreateMiddleware) {
|
|
275
275
|
console.log('│ SECURENOW_CAPTURE_BODY=1 │');
|
|
276
276
|
}
|
|
277
277
|
console.log('│ │');
|
|
278
278
|
console.log('│ 2. Run your app: npm run dev │');
|
|
279
279
|
console.log('│ │');
|
|
280
|
-
console.log('│ 3. Check
|
|
280
|
+
console.log('│ 3. Check SecureNow for traces! │');
|
|
281
281
|
console.log('│ │');
|
|
282
282
|
if (shouldCreateMiddleware) {
|
|
283
283
|
console.log('│ 📝 Body capture enabled with auto-redaction │');
|
package/register.d.ts
CHANGED
package/tracing.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ export interface LoggerProvider {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
* Get a logger instance for sending structured logs to
|
|
115
|
+
* Get a logger instance for sending structured logs to any OTLP-compatible backend
|
|
116
116
|
*
|
|
117
117
|
* @param name - Logger name (e.g., 'my-service', 'auth-module')
|
|
118
118
|
* @param version - Logger version (optional, defaults to '1.0.0')
|