securenow 3.0.14 → 4.0.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.
@@ -0,0 +1,379 @@
1
+ # SecureNow for Next.js - Complete Integration Guide
2
+
3
+ Send traces and logs from your Next.js app to SigNoz (or any OpenTelemetry-compatible backend) in under 2 minutes.
4
+
5
+ ## 🚀 Quick Start (2 Simple Steps!)
6
+
7
+ ### Step 1: Install SecureNow
8
+
9
+ ```bash
10
+ npm install securenow
11
+ # or
12
+ yarn add securenow
13
+ # or
14
+ pnpm add securenow
15
+ ```
16
+
17
+ **🎉 The installer will automatically:**
18
+ - Detect your Next.js project
19
+ - Offer to create `instrumentation.ts` (or `.js`)
20
+ - Create `.env.local` template
21
+ - **Zero webpack warnings** (uses @vercel/otel under the hood)
22
+
23
+ **Just answer "Y" when prompted!**
24
+
25
+ ### Step 2: Configure Environment Variables
26
+
27
+ Edit the `.env.local` file that was created:
28
+
29
+ ```bash
30
+ # Required: Your app name (shows up in SigNoz)
31
+ SECURENOW_APPID=my-nextjs-app
32
+
33
+ # Required: Your SigNoz server endpoint
34
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
35
+
36
+ # Optional: API key for authentication
37
+ OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key-here"
38
+ ```
39
+
40
+ ### That's It! 🎉
41
+
42
+ **No webpack warnings!** SecureNow uses `@vercel/otel` under the hood, which is specifically designed for Next.js and handles all the bundling correctly.
43
+
44
+ ---
45
+
46
+ ## 🔧 Alternative Setup Methods
47
+
48
+ ### If You Skipped Auto-Setup
49
+
50
+ **Option 1: Use the CLI (Recommended)**
51
+
52
+ ```bash
53
+ npx securenow init
54
+ ```
55
+
56
+ **Option 2: Create Manually**
57
+
58
+ Create `instrumentation.ts` at the **root** of your Next.js project (or inside `src/`):
59
+
60
+ ```typescript
61
+ // instrumentation.ts
62
+ import { registerSecureNow } from 'securenow/nextjs';
63
+
64
+ export function register() {
65
+ registerSecureNow();
66
+ }
67
+ ```
68
+
69
+ **JavaScript version:**
70
+ ```javascript
71
+ // instrumentation.js
72
+ const { registerSecureNow } = require('securenow/nextjs');
73
+
74
+ export function register() {
75
+ registerSecureNow();
76
+ }
77
+ ```
78
+
79
+ See [AUTO-SETUP.md](./AUTO-SETUP.md) for detailed setup options.
80
+
81
+ ---
82
+
83
+ ## ▶️ Run Your App
84
+
85
+ Run your Next.js app:
86
+
87
+ ```bash
88
+ npm run dev
89
+ # or
90
+ npm run build && npm start
91
+ ```
92
+
93
+ You should see:
94
+ ```
95
+ [securenow] Next.js integration loading
96
+ [securenow] 🚀 Next.js App → service.name=my-nextjs-app-xxx
97
+ [securenow] ✅ OpenTelemetry started for Next.js → http://...
98
+ ```
99
+
100
+ ---
101
+
102
+ ## 📊 What Gets Automatically Captured?
103
+
104
+ SecureNow automatically captures comprehensive request data:
105
+
106
+ ### 🌐 User Information (Automatic!)
107
+ - **IP Address** - From x-forwarded-for, x-real-ip, etc.
108
+ - **User Agent** - Browser and device info
109
+ - **Referer** - Where users came from
110
+ - **Geographic Data** - Country, region, city (Vercel/Cloudflare)
111
+ - **Request Metadata** - Headers, host, scheme
112
+ - **Response Data** - Status codes, timing
113
+
114
+ See [AUTOMATIC-IP-CAPTURE.md](./AUTOMATIC-IP-CAPTURE.md) for full details.
115
+
116
+ ### Next.js Built-in Spans
117
+ - ✅ HTTP requests (`[http.method] [next.route]`)
118
+ - ✅ API routes execution
119
+ - ✅ Page rendering (App Router & Pages Router)
120
+ - ✅ `getServerSideProps` / `getStaticProps`
121
+ - ✅ Metadata generation
122
+ - ✅ Server component loading
123
+ - ✅ TTFB (Time to First Byte)
124
+
125
+ ### Backend Calls
126
+ - ✅ HTTP/HTTPS requests (via `fetch`, `axios`, `node-fetch`, etc.)
127
+ - ✅ Database queries:
128
+ - PostgreSQL
129
+ - MySQL / MySQL2
130
+ - MongoDB
131
+ - Redis
132
+ - ✅ GraphQL queries
133
+ - ✅ Other Node.js libraries
134
+
135
+ ---
136
+
137
+ ## ⚙️ Advanced Configuration
138
+
139
+ ### Option 1: Environment Variables (Recommended)
140
+
141
+ ```bash
142
+ # .env.local
143
+
144
+ # Required
145
+ SECURENOW_APPID=my-nextjs-app
146
+
147
+ # Optional Configuration
148
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
149
+ SECURENOW_NO_UUID=1 # Don't append UUID (useful for dev)
150
+ OTEL_LOG_LEVEL=info # debug|info|warn|error
151
+ SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns # Disable specific instrumentations
152
+ SECURENOW_TEST_SPAN=1 # Create test span on startup
153
+
154
+ # Authentication
155
+ OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-key,authorization=Bearer token"
156
+
157
+ # Alternative endpoint configuration
158
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://... # Base endpoint
159
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://... # Full traces URL
160
+ ```
161
+
162
+ ### Option 2: Programmatic Configuration
163
+
164
+ ```typescript
165
+ // instrumentation.ts
166
+ import { registerSecureNow } from 'securenow/nextjs';
167
+
168
+ export function register() {
169
+ registerSecureNow({
170
+ serviceName: 'my-nextjs-app',
171
+ endpoint: 'http://your-signoz-server:4318',
172
+ noUuid: false,
173
+ disableInstrumentations: ['fs', 'dns'],
174
+ headers: {
175
+ 'x-api-key': process.env.SECURENOW_API_KEY || '',
176
+ },
177
+ });
178
+ }
179
+ ```
180
+
181
+ **Options:**
182
+ - `serviceName` (string): Service name (overrides `SECURENOW_APPID`)
183
+ - `endpoint` (string): Base URL for OTLP collector (overrides `SECURENOW_INSTANCE`)
184
+ - `noUuid` (boolean): Don't append UUID to service name
185
+ - `disableInstrumentations` (string[]): List of instrumentations to disable
186
+ - `headers` (object): Additional headers for authentication
187
+
188
+ ---
189
+
190
+ ## 🔧 Next.js Version Compatibility
191
+
192
+ ### Next.js 15+ (Recommended)
193
+ ✅ Works out of the box. Just create `instrumentation.ts`.
194
+
195
+ ### Next.js 14 and Below
196
+ ⚠️ You need to enable the instrumentation hook in `next.config.js`:
197
+
198
+ ```javascript
199
+ // next.config.js
200
+ const nextConfig = {
201
+ experimental: {
202
+ instrumentationHook: true, // Required for Next.js 14 and below
203
+ },
204
+ };
205
+
206
+ module.exports = nextConfig;
207
+ ```
208
+
209
+ ---
210
+
211
+ ## 🎯 Deployment
212
+
213
+ ### Vercel
214
+
215
+ SecureNow works seamlessly on Vercel:
216
+
217
+ 1. Add environment variables in Vercel dashboard
218
+ 2. Deploy normally
219
+
220
+ The instrumentation runs during both build and runtime.
221
+
222
+ ### Docker
223
+
224
+ ```dockerfile
225
+ FROM node:20-alpine
226
+
227
+ WORKDIR /app
228
+
229
+ COPY package*.json ./
230
+ RUN npm ci --production
231
+
232
+ COPY . .
233
+ RUN npm run build
234
+
235
+ ENV SECURENOW_APPID=my-nextjs-app
236
+ ENV SECURENOW_INSTANCE=http://signoz:4318
237
+
238
+ EXPOSE 3000
239
+ CMD ["npm", "start"]
240
+ ```
241
+
242
+ ### Self-Hosted / VPS
243
+
244
+ Just set environment variables and run:
245
+
246
+ ```bash
247
+ export SECURENOW_APPID=my-nextjs-app
248
+ export SECURENOW_INSTANCE=http://your-signoz-server:4318
249
+ npm start
250
+ ```
251
+
252
+ ---
253
+
254
+ ## 🐛 Troubleshooting
255
+
256
+ ### Not seeing traces?
257
+
258
+ **Check 1: Is instrumentation loading?**
259
+ ```bash
260
+ npm run dev
261
+ # Look for: [securenow] Next.js integration loading
262
+ ```
263
+
264
+ **Check 2: Enable debug logging**
265
+ ```bash
266
+ OTEL_LOG_LEVEL=debug npm run dev
267
+ ```
268
+
269
+ **Check 3: Create a test span**
270
+ ```bash
271
+ SECURENOW_TEST_SPAN=1 npm run dev
272
+ ```
273
+
274
+ ### `Cannot find module 'securenow/nextjs'`
275
+
276
+ Make sure you're on the latest version:
277
+ ```bash
278
+ npm install securenow@latest
279
+ ```
280
+
281
+ ### Traces not appearing in SigNoz
282
+
283
+ 1. **Check endpoint:**
284
+ ```bash
285
+ curl http://your-signoz-server:4318/v1/traces
286
+ ```
287
+
288
+ 2. **Verify connectivity:** Make sure your app can reach SigNoz
289
+
290
+ 3. **Check authentication:** If using API keys, verify headers
291
+
292
+ ### Too many spans / noisy logs
293
+
294
+ Disable specific instrumentations:
295
+ ```bash
296
+ SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net
297
+ ```
298
+
299
+ ---
300
+
301
+ ## 📖 Comparison with Other Solutions
302
+
303
+ ### vs. `@vercel/otel`
304
+ - ✅ **SecureNow**: Pre-configured for SigNoz, includes auto-instrumentations
305
+ - ⚠️ **@vercel/otel**: Requires manual instrumentation setup
306
+
307
+ ### vs. Manual OpenTelemetry Setup
308
+ - ✅ **SecureNow**: 3 lines of code, works immediately
309
+ - ⚠️ **Manual**: 50+ lines, complex configuration
310
+
311
+ ### vs. Other APM Solutions (DataDog, New Relic)
312
+ - ✅ **SecureNow**: Open-source, self-hosted, vendor-neutral
313
+ - ⚠️ **Commercial APM**: Expensive, vendor lock-in
314
+
315
+ ---
316
+
317
+ ## 🔥 Best Practices
318
+
319
+ ### 1. Use Meaningful Service Names
320
+ ```bash
321
+ # Good ✅
322
+ SECURENOW_APPID=checkout-service
323
+ SECURENOW_APPID=user-dashboard
324
+
325
+ # Bad ❌
326
+ SECURENOW_APPID=app
327
+ SECURENOW_APPID=test
328
+ ```
329
+
330
+ ### 2. Set Deployment Environment
331
+ ```bash
332
+ # Vercel automatically sets VERCEL_ENV
333
+ # For other platforms:
334
+ NODE_ENV=production
335
+ ```
336
+
337
+ ### 3. Use Service Instance IDs in Production
338
+ ```bash
339
+ # Default behavior (recommended for production)
340
+ # Each worker gets a unique instance ID
341
+
342
+ # For development (easier to filter)
343
+ SECURENOW_NO_UUID=1
344
+ ```
345
+
346
+ ### 4. Disable Noisy Instrumentations
347
+ ```bash
348
+ # File system operations can be too verbose
349
+ SECURENOW_DISABLE_INSTRUMENTATIONS=fs
350
+ ```
351
+
352
+ ---
353
+
354
+ ## 🎓 Examples
355
+
356
+ Check the `examples/` folder for:
357
+ - `nextjs-instrumentation.ts` - Basic TypeScript setup
358
+ - `nextjs-instrumentation.js` - Basic JavaScript setup
359
+ - `nextjs-with-options.ts` - Advanced configuration
360
+ - `nextjs-env-example.txt` - Complete environment variables reference
361
+
362
+ ---
363
+
364
+ ## 🆘 Support
365
+
366
+ - **Issues:** [GitHub Issues](https://github.com/your-repo/securenow/issues)
367
+ - **Documentation:** [Full Documentation](https://your-docs-site.com)
368
+ - **SigNoz Docs:** [SigNoz OpenTelemetry Docs](https://signoz.io/docs/)
369
+
370
+ ---
371
+
372
+ ## 📝 License
373
+
374
+ ISC
375
+
376
+ ---
377
+
378
+ **Made with ❤️ for the Next.js and SigNoz community**
379
+
@@ -0,0 +1,67 @@
1
+ # Next.js + SecureNow Quick Start
2
+
3
+ ## Installation (30 seconds)
4
+
5
+ ```bash
6
+ npm install securenow
7
+ ```
8
+
9
+ **🎉 The installer will automatically offer to create the instrumentation file!**
10
+
11
+ Just answer "Y" when prompted, and it's done!
12
+
13
+ ---
14
+
15
+ ## Alternative: Manual Setup
16
+
17
+ If you skipped auto-setup or want to do it manually:
18
+
19
+ ### Option 1: Use CLI (Recommended)
20
+
21
+ ```bash
22
+ npx securenow init
23
+ ```
24
+
25
+ ### Option 2: Create File Manually
26
+
27
+ Create `instrumentation.ts` at project root:
28
+
29
+ ```typescript
30
+ import { registerSecureNow } from 'securenow/nextjs';
31
+ export function register() { registerSecureNow(); }
32
+ ```
33
+
34
+ ### 2. Create `.env.local`:
35
+
36
+ ```bash
37
+ SECURENOW_APPID=my-nextjs-app
38
+ SECURENOW_INSTANCE=http://your-signoz:4318
39
+ ```
40
+
41
+ ### 3. (Next.js 14 only) Update `next.config.js`:
42
+
43
+ ```javascript
44
+ module.exports = {
45
+ experimental: { instrumentationHook: true }
46
+ }
47
+ ```
48
+
49
+ ## Run
50
+
51
+ ```bash
52
+ npm run dev
53
+ ```
54
+
55
+ ## Verify
56
+
57
+ Look for:
58
+ ```
59
+ [securenow] ✅ OpenTelemetry started for Next.js
60
+ ```
61
+
62
+ Open SigNoz → check for traces from `my-nextjs-app`
63
+
64
+ ---
65
+
66
+ **That's it!** See [NEXTJS-GUIDE.md](./NEXTJS-GUIDE.md) for advanced configuration.
67
+
package/README.md CHANGED
@@ -1,22 +1,145 @@
1
- # securenow
2
- [npm package for securenow] : (http://securenow.ai/)
3
-
4
- # installation
5
- To install SecureNow, follow these steps:
6
-
7
- 1. Request your API key from [SecureNow](http://securenow.ai/).
8
- 2. Install the package using npm:
9
- ```
10
- npm i --save securenow
11
- ```
12
-
13
- set the api key in your environement variable :
14
- ```bash
15
- export securenow=<API-KEY>
16
- ```
17
-
18
- if you have a dedicated securenow instance :
19
-
20
- ```bash
21
- export securenow_instance='http://<dedicated_instance>:4318'
22
- ```
1
+ # SecureNow
2
+
3
+ OpenTelemetry instrumentation for Node.js and Next.js applications - send traces to SigNoz or any OTLP-compatible backend.
4
+
5
+ **Official npm package:** [securenow](http://securenow.ai/)
6
+
7
+ ---
8
+
9
+ ## 🚀 Quick Start
10
+
11
+ ### For Next.js Applications
12
+
13
+ **The easiest way to add observability to Next.js!**
14
+
15
+ ```bash
16
+ # Just install - setup is automatic!
17
+ npm install securenow
18
+ ```
19
+
20
+ **🎉 The installer will automatically:**
21
+ - Detect your Next.js project
22
+ - Create `instrumentation.ts` (or `.js`)
23
+ - Create `.env.local` template
24
+
25
+ **Just answer "Y" when prompted!**
26
+
27
+ Then configure your `.env.local`:
28
+
29
+ ```bash
30
+ SECURENOW_APPID=my-nextjs-app
31
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
32
+ ```
33
+
34
+ **Alternative:** Use the CLI command
35
+ ```bash
36
+ npx securenow init
37
+ ```
38
+
39
+ **Done!** 🎉 See [Next.js Complete Guide](./NEXTJS-GUIDE.md) for details.
40
+
41
+ ---
42
+
43
+ ### For Node.js Applications (Express, Fastify, NestJS, etc.)
44
+
45
+ ```bash
46
+ # 1. Install
47
+ npm install securenow
48
+
49
+ # 2. Set environment variables
50
+ export SECURENOW_APPID=my-app
51
+ export SECURENOW_INSTANCE=http://your-signoz-server:4318
52
+
53
+ # 3. Run with preload
54
+ NODE_OPTIONS="-r securenow/register" node app.js
55
+ # or
56
+ NODE_OPTIONS="-r securenow/register" npm start
57
+ ```
58
+
59
+ ---
60
+
61
+ ## 📦 Installation
62
+
63
+ ```bash
64
+ npm install securenow
65
+ # or
66
+ yarn add securenow
67
+ # or
68
+ pnpm add securenow
69
+ ```
70
+
71
+ ---
72
+
73
+ ## ⚙️ Configuration
74
+
75
+ ### Environment Variables
76
+
77
+ ```bash
78
+ # Required: Your application identifier
79
+ SECURENOW_APPID=my-app-name
80
+
81
+ # Optional: Your SigNoz/OTLP collector endpoint
82
+ # Default: http://46.62.173.237:4318
83
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
84
+
85
+ # Optional: Additional configuration
86
+ SECURENOW_NO_UUID=1 # Don't append UUID to service name
87
+ OTEL_LOG_LEVEL=info # debug|info|warn|error
88
+ SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns # Disable specific instrumentations
89
+ OTEL_EXPORTER_OTLP_HEADERS="x-api-key=..." # Authentication headers
90
+ ```
91
+
92
+ ### Legacy Environment Variables (still supported)
93
+
94
+ ```bash
95
+ export securenow=<API-KEY>
96
+ export securenow_instance='http://<dedicated_instance>:4318'
97
+ ```
98
+
99
+ ---
100
+
101
+ ## 🎯 Supported Frameworks & Libraries
102
+
103
+ SecureNow automatically instruments:
104
+
105
+ ### Web Frameworks
106
+ - ✅ Next.js (App Router & Pages Router)
107
+ - ✅ Express.js
108
+ - ✅ Fastify
109
+ - ✅ NestJS
110
+ - ✅ Koa
111
+ - ✅ Hapi
112
+
113
+ ### Databases
114
+ - ✅ PostgreSQL
115
+ - ✅ MySQL / MySQL2
116
+ - ✅ MongoDB
117
+ - ✅ Redis
118
+
119
+ ### Other
120
+ - ✅ HTTP/HTTPS requests
121
+ - ✅ GraphQL
122
+ - ✅ gRPC
123
+ - ✅ And many more via OpenTelemetry auto-instrumentation
124
+
125
+ ---
126
+
127
+ ## 📚 Documentation
128
+
129
+ - **[Next.js Quick Start](./NEXTJS-QUICKSTART.md)** - Get started in 30 seconds
130
+ - **[Next.js Complete Guide](./NEXTJS-GUIDE.md)** - Full Next.js integration guide
131
+ - **[Examples](./examples/)** - Code examples for different setups
132
+
133
+ ---
134
+
135
+ ## 🆘 Support
136
+
137
+ - **Website:** [securenow.ai](http://securenow.ai/)
138
+ - **Issues:** Report bugs and request features
139
+ - **Documentation:** Full documentation and guides
140
+
141
+ ---
142
+
143
+ ## 📄 License
144
+
145
+ ISC