securenow 7.2.0 → 7.2.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.
package/app-config.js CHANGED
@@ -157,6 +157,30 @@ function resolveAll() {
157
157
  };
158
158
  }
159
159
 
160
+ // Decide whether to append a per-worker UUID suffix to service.name.
161
+ //
162
+ // The dashboard filters traces with an exact match on service.name
163
+ // (`resource_string_service$$name IN (...)`), so when appId IS the routing
164
+ // UUID (customer is logged in → credentials file provides app.key), the
165
+ // suffix guarantees a miss. Per-worker disambiguation still happens via
166
+ // service.instance.id, which is never used for filtering.
167
+ //
168
+ // Precedence:
169
+ // 1. Explicit opts.noUuid (caller passed it) — wins
170
+ // 2. Explicit SECURENOW_NO_UUID env var (0/1/true/false) — wins
171
+ // 3. appKey resolved (logged-in, appId is routing UUID) → true
172
+ // 4. Otherwise (pre-login, appId = package.json#name) → false
173
+ function resolveNoUuid(opts = {}) {
174
+ if (opts.noUuid !== undefined && opts.noUuid !== null) return !!opts.noUuid;
175
+
176
+ const raw = process.env.SECURENOW_NO_UUID;
177
+ if (raw !== undefined && raw !== '') {
178
+ return /^(1|true)$/i.test(String(raw).trim());
179
+ }
180
+
181
+ return !!resolveAppKey();
182
+ }
183
+
160
184
  module.exports = {
161
185
  FREE_TRIAL_INSTANCE,
162
186
  resolveAppKey,
@@ -165,6 +189,7 @@ module.exports = {
165
189
  resolveApiKey,
166
190
  resolveInstance,
167
191
  resolveAll,
192
+ resolveNoUuid,
168
193
  loadCredentials,
169
194
  loadLocalCredentials,
170
195
  loadGlobalCredentials,
@@ -8,12 +8,20 @@ const config = require('./config');
8
8
  // ── Config resolution (mirrors tracing.js priority order) ──
9
9
 
10
10
  function resolvedConfig() {
11
- const serviceName =
12
- process.env.OTEL_SERVICE_NAME ||
13
- process.env.SECURENOW_APPID ||
14
- '(auto-generated)';
11
+ // Mirror the SDK's resolution: env → credentials file → package.json#name.
12
+ // Doing it here means `securenow doctor` reports what the SDK will actually
13
+ // send — critical for diagnosing "my traces don't show up" (the common
14
+ // cause is a service.name mismatch with the dashboard's exact-match filter).
15
+ const appConfig = require('../app-config');
16
+ const resolvedApp = appConfig.resolveAll();
17
+ const noUuid = appConfig.resolveNoUuid();
18
+
19
+ const baseName = (process.env.OTEL_SERVICE_NAME || resolvedApp.appId || '').trim().replace(/^['"]|['"]$/g, '') || null;
20
+ const serviceName = baseName
21
+ ? (noUuid ? baseName : `${baseName}-<uuid-per-worker>`)
22
+ : '(auto-generated)';
15
23
  const instance =
16
- process.env.SECURENOW_INSTANCE || 'https://freetrial.securenow.ai:4318';
24
+ resolvedApp.instance || 'https://freetrial.securenow.ai:4318';
17
25
  const tracesEndpoint =
18
26
  process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ||
19
27
  (process.env.OTEL_EXPORTER_OTLP_ENDPOINT
@@ -297,7 +305,7 @@ function env(_args, flags) {
297
305
  SECURENOW_API_URL: cfg.apiUrl,
298
306
  SECURENOW_LOGGING_ENABLED: cfg.loggingEnabled ? '1' : '0',
299
307
  SECURENOW_CAPTURE_BODY: cfg.captureBody ? '1' : '0',
300
- SECURENOW_NO_UUID: process.env.SECURENOW_NO_UUID || '0',
308
+ SECURENOW_NO_UUID: process.env.SECURENOW_NO_UUID || `(auto: ${require('../app-config').resolveNoUuid() ? '1' : '0'})`,
301
309
  SECURENOW_FIREWALL_TCP: process.env.SECURENOW_FIREWALL_TCP || '0',
302
310
  SECURENOW_FIREWALL_IPTABLES: process.env.SECURENOW_FIREWALL_IPTABLES || '0',
303
311
  SECURENOW_FIREWALL_CLOUD: process.env.SECURENOW_FIREWALL_CLOUD || null,
package/nextjs.js CHANGED
@@ -150,7 +150,10 @@ function registerSecureNow(options = {}) {
150
150
 
151
151
  const rawBase = (options.serviceName || resolvedApp.appId || '').trim().replace(/^['"]|['"]$/g, '');
152
152
  const baseName = rawBase || null;
153
- const noUuid = options.noUuid ?? (String(env('SECURENOW_NO_UUID')) === '1' || String(env('SECURENOW_NO_UUID')).toLowerCase() === 'true');
153
+ // Default: auto-disable suffix when logged in (appId is the routing UUID
154
+ // and the dashboard does exact match). opts.noUuid or SECURENOW_NO_UUID
155
+ // override.
156
+ const noUuid = appConfig.resolveNoUuid({ noUuid: options.noUuid });
154
157
 
155
158
  // service.name
156
159
  let serviceName;
@@ -83,10 +83,10 @@ export default defineNitroPlugin((nitroApp) => {
83
83
  // ── Naming ──
84
84
  const rawBase = (opts.serviceName || resolvedApp.appId || '').trim().replace(/^['"]|['"]$/g, '');
85
85
  const baseName = rawBase || null;
86
- const noUuid =
87
- opts.noUuid ??
88
- (String(env('SECURENOW_NO_UUID')) === '1' ||
89
- String(env('SECURENOW_NO_UUID')).toLowerCase() === 'true');
86
+ // Default: auto-disable per-worker suffix when logged in (appId is the
87
+ // routing UUID and the dashboard does exact match). opts.noUuid or
88
+ // SECURENOW_NO_UUID override.
89
+ const noUuid = appConfig.resolveNoUuid({ noUuid: opts.noUuid });
90
90
 
91
91
  let serviceName;
92
92
  if (baseName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securenow",
3
- "version": "7.2.0",
3
+ "version": "7.2.1",
4
4
  "description": "OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt - Send traces and logs to any OTLP-compatible backend",
5
5
  "type": "commonjs",
6
6
  "main": "register.js",
package/tracing.js CHANGED
@@ -10,7 +10,11 @@
10
10
  *
11
11
  * Env:
12
12
  * SECURENOW_APPID=logical-name # or OTEL_SERVICE_NAME=logical-name
13
- * SECURENOW_NO_UUID=1 # one service.name across all workers
13
+ * SECURENOW_NO_UUID=1|0 # override. Default: auto — 1 when
14
+ * logged in (appId is routing UUID,
15
+ * dashboard does exact match),
16
+ * 0 pre-login (use suffix to
17
+ * distinguish PM2 cluster workers).
14
18
  * SECURENOW_INSTANCE=http://host:4318 # OTLP/HTTP base (default https://freetrial.securenow.ai:4318)
15
19
  * OTEL_EXPORTER_OTLP_ENDPOINT=... # alternative base
16
20
  * OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=... # full traces URL
@@ -288,7 +292,10 @@ const headers = parseHeaders(env('OTEL_EXPORTER_OTLP_HEADERS'));
288
292
  // -------- naming rules --------
289
293
  const rawBase = (resolvedApp.appId || '').trim().replace(/^['"]|['"]$/g, '');
290
294
  const baseName = rawBase || null;
291
- const noUuid = String(env('SECURENOW_NO_UUID')) === '1' || String(env('SECURENOW_NO_UUID')).toLowerCase() === 'true';
295
+ // Auto-disables the per-worker suffix when we resolved a routing UUID from
296
+ // credentials — the dashboard does exact-match IN on service.name, so any
297
+ // suffix breaks routing. Env SECURENOW_NO_UUID=0|1 still overrides.
298
+ const noUuid = appConfig.resolveNoUuid();
292
299
  const strict = String(env('SECURENOW_STRICT')) === '1' || String(env('SECURENOW_STRICT')).toLowerCase() === 'true';
293
300
  const inPm2Cluster = !!(process.env.NODE_APP_INSTANCE || process.env.pm_id);
294
301
 
package/web-vite.mjs CHANGED
@@ -52,7 +52,15 @@ const headers = parseHeaders(env('OTEL_EXPORTER_OTLP_HEADERS'));
52
52
  // ---- naming rules (mirrors tracing.js) ----
53
53
  const rawBase = (env('OTEL_SERVICE_NAME') || env('SECURENOW_APPID') || '').trim().replace(/^['"]|['"]$/g, '');
54
54
  const baseName = rawBase || null;
55
- const noUuid = String(env('SECURENOW_NO_UUID')) === '1' || String(env('SECURENOW_NO_UUID')).toLowerCase() === 'true';
55
+ // Default to no suffix whenever a baseName is resolved: the dashboard filters
56
+ // service.name by exact match, and browsers have no PM2 cluster problem
57
+ // (each tab has its own service.instance.id). Explicit SECURENOW_NO_UUID=0
58
+ // still re-enables the suffix if someone really wants it.
59
+ const noUuidEnv = env('SECURENOW_NO_UUID');
60
+ const noUuid =
61
+ (noUuidEnv !== undefined && noUuidEnv !== '')
62
+ ? /^(1|true)$/i.test(String(noUuidEnv).trim())
63
+ : !!baseName;
56
64
  const strict = String(env('SECURENOW_STRICT')) === '1' || String(env('SECURENOW_STRICT')).toLowerCase() === 'true';
57
65
 
58
66
  function uuidv4(): string {