securenow 3.0.13 → 4.0.1

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,369 @@
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 Instrumented?
103
+
104
+ SecureNow uses OpenTelemetry's auto-instrumentation to capture:
105
+
106
+ ### Next.js Built-in Spans
107
+ - ✅ HTTP requests (`[http.method] [next.route]`)
108
+ - ✅ API routes execution
109
+ - ✅ Page rendering (App Router & Pages Router)
110
+ - ✅ `getServerSideProps` / `getStaticProps`
111
+ - ✅ Metadata generation
112
+ - ✅ Server component loading
113
+ - ✅ TTFB (Time to First Byte)
114
+
115
+ ### Backend Calls
116
+ - ✅ HTTP/HTTPS requests (via `fetch`, `axios`, `node-fetch`, etc.)
117
+ - ✅ Database queries:
118
+ - PostgreSQL
119
+ - MySQL / MySQL2
120
+ - MongoDB
121
+ - Redis
122
+ - ✅ GraphQL queries
123
+ - ✅ Other Node.js libraries
124
+
125
+ ---
126
+
127
+ ## ⚙️ Advanced Configuration
128
+
129
+ ### Option 1: Environment Variables (Recommended)
130
+
131
+ ```bash
132
+ # .env.local
133
+
134
+ # Required
135
+ SECURENOW_APPID=my-nextjs-app
136
+
137
+ # Optional Configuration
138
+ SECURENOW_INSTANCE=http://your-signoz-server:4318
139
+ SECURENOW_NO_UUID=1 # Don't append UUID (useful for dev)
140
+ OTEL_LOG_LEVEL=info # debug|info|warn|error
141
+ SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns # Disable specific instrumentations
142
+ SECURENOW_TEST_SPAN=1 # Create test span on startup
143
+
144
+ # Authentication
145
+ OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-key,authorization=Bearer token"
146
+
147
+ # Alternative endpoint configuration
148
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://... # Base endpoint
149
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://... # Full traces URL
150
+ ```
151
+
152
+ ### Option 2: Programmatic Configuration
153
+
154
+ ```typescript
155
+ // instrumentation.ts
156
+ import { registerSecureNow } from 'securenow/nextjs';
157
+
158
+ export function register() {
159
+ registerSecureNow({
160
+ serviceName: 'my-nextjs-app',
161
+ endpoint: 'http://your-signoz-server:4318',
162
+ noUuid: false,
163
+ disableInstrumentations: ['fs', 'dns'],
164
+ headers: {
165
+ 'x-api-key': process.env.SECURENOW_API_KEY || '',
166
+ },
167
+ });
168
+ }
169
+ ```
170
+
171
+ **Options:**
172
+ - `serviceName` (string): Service name (overrides `SECURENOW_APPID`)
173
+ - `endpoint` (string): Base URL for OTLP collector (overrides `SECURENOW_INSTANCE`)
174
+ - `noUuid` (boolean): Don't append UUID to service name
175
+ - `disableInstrumentations` (string[]): List of instrumentations to disable
176
+ - `headers` (object): Additional headers for authentication
177
+
178
+ ---
179
+
180
+ ## 🔧 Next.js Version Compatibility
181
+
182
+ ### Next.js 15+ (Recommended)
183
+ ✅ Works out of the box. Just create `instrumentation.ts`.
184
+
185
+ ### Next.js 14 and Below
186
+ ⚠️ You need to enable the instrumentation hook in `next.config.js`:
187
+
188
+ ```javascript
189
+ // next.config.js
190
+ const nextConfig = {
191
+ experimental: {
192
+ instrumentationHook: true, // Required for Next.js 14 and below
193
+ },
194
+ };
195
+
196
+ module.exports = nextConfig;
197
+ ```
198
+
199
+ ---
200
+
201
+ ## 🎯 Deployment
202
+
203
+ ### Vercel
204
+
205
+ SecureNow works seamlessly on Vercel:
206
+
207
+ 1. Add environment variables in Vercel dashboard
208
+ 2. Deploy normally
209
+
210
+ The instrumentation runs during both build and runtime.
211
+
212
+ ### Docker
213
+
214
+ ```dockerfile
215
+ FROM node:20-alpine
216
+
217
+ WORKDIR /app
218
+
219
+ COPY package*.json ./
220
+ RUN npm ci --production
221
+
222
+ COPY . .
223
+ RUN npm run build
224
+
225
+ ENV SECURENOW_APPID=my-nextjs-app
226
+ ENV SECURENOW_INSTANCE=http://signoz:4318
227
+
228
+ EXPOSE 3000
229
+ CMD ["npm", "start"]
230
+ ```
231
+
232
+ ### Self-Hosted / VPS
233
+
234
+ Just set environment variables and run:
235
+
236
+ ```bash
237
+ export SECURENOW_APPID=my-nextjs-app
238
+ export SECURENOW_INSTANCE=http://your-signoz-server:4318
239
+ npm start
240
+ ```
241
+
242
+ ---
243
+
244
+ ## 🐛 Troubleshooting
245
+
246
+ ### Not seeing traces?
247
+
248
+ **Check 1: Is instrumentation loading?**
249
+ ```bash
250
+ npm run dev
251
+ # Look for: [securenow] Next.js integration loading
252
+ ```
253
+
254
+ **Check 2: Enable debug logging**
255
+ ```bash
256
+ OTEL_LOG_LEVEL=debug npm run dev
257
+ ```
258
+
259
+ **Check 3: Create a test span**
260
+ ```bash
261
+ SECURENOW_TEST_SPAN=1 npm run dev
262
+ ```
263
+
264
+ ### `Cannot find module 'securenow/nextjs'`
265
+
266
+ Make sure you're on the latest version:
267
+ ```bash
268
+ npm install securenow@latest
269
+ ```
270
+
271
+ ### Traces not appearing in SigNoz
272
+
273
+ 1. **Check endpoint:**
274
+ ```bash
275
+ curl http://your-signoz-server:4318/v1/traces
276
+ ```
277
+
278
+ 2. **Verify connectivity:** Make sure your app can reach SigNoz
279
+
280
+ 3. **Check authentication:** If using API keys, verify headers
281
+
282
+ ### Too many spans / noisy logs
283
+
284
+ Disable specific instrumentations:
285
+ ```bash
286
+ SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net
287
+ ```
288
+
289
+ ---
290
+
291
+ ## 📖 Comparison with Other Solutions
292
+
293
+ ### vs. `@vercel/otel`
294
+ - ✅ **SecureNow**: Pre-configured for SigNoz, includes auto-instrumentations
295
+ - ⚠️ **@vercel/otel**: Requires manual instrumentation setup
296
+
297
+ ### vs. Manual OpenTelemetry Setup
298
+ - ✅ **SecureNow**: 3 lines of code, works immediately
299
+ - ⚠️ **Manual**: 50+ lines, complex configuration
300
+
301
+ ### vs. Other APM Solutions (DataDog, New Relic)
302
+ - ✅ **SecureNow**: Open-source, self-hosted, vendor-neutral
303
+ - ⚠️ **Commercial APM**: Expensive, vendor lock-in
304
+
305
+ ---
306
+
307
+ ## 🔥 Best Practices
308
+
309
+ ### 1. Use Meaningful Service Names
310
+ ```bash
311
+ # Good ✅
312
+ SECURENOW_APPID=checkout-service
313
+ SECURENOW_APPID=user-dashboard
314
+
315
+ # Bad ❌
316
+ SECURENOW_APPID=app
317
+ SECURENOW_APPID=test
318
+ ```
319
+
320
+ ### 2. Set Deployment Environment
321
+ ```bash
322
+ # Vercel automatically sets VERCEL_ENV
323
+ # For other platforms:
324
+ NODE_ENV=production
325
+ ```
326
+
327
+ ### 3. Use Service Instance IDs in Production
328
+ ```bash
329
+ # Default behavior (recommended for production)
330
+ # Each worker gets a unique instance ID
331
+
332
+ # For development (easier to filter)
333
+ SECURENOW_NO_UUID=1
334
+ ```
335
+
336
+ ### 4. Disable Noisy Instrumentations
337
+ ```bash
338
+ # File system operations can be too verbose
339
+ SECURENOW_DISABLE_INSTRUMENTATIONS=fs
340
+ ```
341
+
342
+ ---
343
+
344
+ ## 🎓 Examples
345
+
346
+ Check the `examples/` folder for:
347
+ - `nextjs-instrumentation.ts` - Basic TypeScript setup
348
+ - `nextjs-instrumentation.js` - Basic JavaScript setup
349
+ - `nextjs-with-options.ts` - Advanced configuration
350
+ - `nextjs-env-example.txt` - Complete environment variables reference
351
+
352
+ ---
353
+
354
+ ## 🆘 Support
355
+
356
+ - **Issues:** [GitHub Issues](https://github.com/your-repo/securenow/issues)
357
+ - **Documentation:** [Full Documentation](https://your-docs-site.com)
358
+ - **SigNoz Docs:** [SigNoz OpenTelemetry Docs](https://signoz.io/docs/)
359
+
360
+ ---
361
+
362
+ ## 📝 License
363
+
364
+ ISC
365
+
366
+ ---
367
+
368
+ **Made with ❤️ for the Next.js and SigNoz community**
369
+
@@ -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