# Install the PulseAI Node.js request collector

This downloadable server module works with a persistent Node.js application on your own hosting provider. Cloudflare is not required for your website. It records completed, allowlisted GET requests reaching that Node process and forwards minimized events to your private PulseAI dashboard. It does not block visitors or reliably identify AI controlling an ordinary browser.

## Check compatibility before subscribing

- **Runtime:** Node.js 22.13 or later with the built-in `node:sqlite` module enabled. Use a supported, maintained Node release. No additional npm dependency is required for this module.
- **Application access:** you or your developer can add middleware or a request hook before your website handler. Express/Connect-style applications and custom Node HTTP servers can use the examples below.
- **Persistent private storage:** an absolute writable directory outside every publicly served directory. Use one collector process per directory, on a local persistent disk. The module refuses a directory within the configured public root and locks its outbox against concurrent processes.
- **Network:** outbound HTTPS access to `https://pulseaianalytics.com/api/events`.
- **PulseAI:** an ownership-verified domain, its Website ID, a server-only collector key and a current server-confirmed subscription. Preparing a domain or returning from checkout does not itself activate ingestion.

This version is **not** an installer for Vercel/Netlify serverless functions, edge runtimes, read-only or ephemeral filesystems, shared network filesystems or a multi-process Node cluster sharing one queue. For a multi-process service, each process needs its own private persistent outbox and must observe a given request only once. Container deployments must mount a persistent private volume for each process. A static website without a Node application needs another supported collector or access-log import.

The collector sees requests that actually reach its middleware. A CDN, full-page cache, reverse proxy or static handler positioned before it may answer requests without reaching the application. Configure collection at the relevant layer or use supported access logs, and report this coverage honestly. Cloudflare, WordPress, Shopify, Wix, Squarespace and other platforms have different installation paths; a generic browser script is not equivalent to server request collection.

## 1. Prepare the PulseAI property

1. Sign in at [your dashboard](https://pulseaianalytics.com/dashboard).
2. Add the exact hostname, such as `www.example.com`, and publish the ownership proof at the URL shown in setup. The verification file must be publicly reachable over HTTPS without redirects.
3. Complete ownership verification. Apex and `www` are different hostnames.
4. Save the Website ID and create or recover the collector key through the owning account. The key is shown only when created or rotated. Rotation immediately invalidates the previous key.
5. Check the current [Starter offer and installation requirements](https://pulseaianalytics.com/pricing) before purchasing. An active server-verified subscription is required before PulseAI accepts reports.

Keep the ownership file served by your application; the module does not fabricate domain proof.

## 2. Download the module and configure server secrets

Download [pulseai-node-collector.mjs](https://pulseaianalytics.com/downloads/pulseai-node-collector.mjs) into a server-only directory in your application. The file uses ESM imports; CommonJS applications can load it with dynamic `import()` during startup.

Configure these values in your hosting provider's **server environment/secrets** interface:

| Name | Example / meaning |
| --- | --- |
| `PULSEAI_SITE_ID` | The Website ID shown by PulseAI; not your account email. |
| `PULSEAI_CUSTOMER_HOSTNAME` | `www.example.com`, exact lowercase public hostname, no scheme or path. |
| `PULSEAI_INGESTION_KEY` | The private per-site collector key. Never put it in a browser bundle or public environment variable. |
| `PULSEAI_DATA_DIRECTORY` | `/var/lib/my-website/pulseai`, a private persistent directory outside your web root. |

Do not put keys in downloaded code, public source repositories, client scripts, screenshots or support messages. On Linux the collector restricts its data directory to mode `0700` and SQLite file to `0600`. On Windows also configure the directory's NTFS access permissions for the service account; POSIX-style modes do not replace Windows ACLs. Verify that your server has no static route or backup-download route exposing the private directory.

## 3. Attach the collector before your application routes

Express example:

```js
import express from 'express';
import path from 'node:path';
import { createPulseCollector } from './server/pulseai-node-collector.mjs';

const app = express();
// This must be the actual directory your website serves publicly.
const publicDirectory = path.resolve('./public');
let pulse;
try {
  pulse = createPulseCollector({
    siteId: process.env.PULSEAI_SITE_ID,
    hostname: process.env.PULSEAI_CUSTOMER_HOSTNAME,
    ingestionKey: process.env.PULSEAI_INGESTION_KEY,
    dataDirectory: process.env.PULSEAI_DATA_DIRECTORY,
    publicDirectory,
    publicPaths: ['/', '/pricing', '/about'],
  });
  app.use(pulse.middleware);
} catch {
  // Keep website delivery available; report a static diagnostic internally.
  console.error('PulseAI collector unavailable; check server configuration.');
}

app.use(express.static(publicDirectory));
app.get('/pricing', (req, res) => res.send('Your existing pricing page'));
// Keep the rest of your existing middleware, security and routes intact.
const server = app.listen(process.env.PORT || 3000);

process.once('SIGTERM', () => {
  server.close(() => {
    void (async () => {
      if (pulse) { await pulse.flush(); await pulse.close(); }
      process.exit(0);
    })();
  });
});
```

Use your existing application shutdown deadline and process supervisor; do not discard the persisted queue to shut down faster. A final flush attempts one due batch, not a guaranteed full queue drain. Events remain for the next process startup.

For a plain Node HTTP server, call `pulse.observe(req, res)` before the existing handler, once for each request:

```js
import http from 'node:http';
// Create pulse with the same checked options as above.
const server = http.createServer((req, res) => {
  pulse?.observe(req, res);
  existingWebsiteHandler(req, res);
});
```

The module attaches one `finish` listener to each eligible response and does not consume request bodies, alter headers/cookies/cache behavior, replace the website response or wait for a network request before responding. Keep the original handler's authentication, routing and error handling.

If a reverse proxy forwards to Node, configure it to preserve the public `Host` header for this hostname. The collector intentionally does not trust arbitrary `X-Forwarded-Host` values. Node requests with a different Host are ignored. The public website itself should remain HTTPS; a private HTTP hop to your Node application may be used behind your existing trusted TLS proxy.

## 4. Select safe public paths

Only completed **GET** requests on the configured exact hostname and exact `publicPaths` are collected. All other methods and paths are ignored. Query strings are removed before the allowlist comparison and are not persisted. Use only reviewed static public paths, at most 100 paths and 200 characters per path.

Do not allowlist account, admin, checkout, customer-specific, search-query or personalized routes. Never put names, emails, order numbers or secret tokens in the allowlist. The collector stores/transmits only a producer event ID, original observation time, approved path, request kind, source/classification label, observation action, response status and bounded response latency. It examines user-agent text transiently but does not transmit the raw string. It does not store IPs, cookies, authorization, request/response bodies, prompts, page contents or full URLs.

The labels are **declared**, **suspected** and **unknown**. A known name in the supplied user agent is an unverified declaration. Suspicion of automation does not prove AI. The dashboard shows unknown as Estimated human; it does not prove a person. There is no verified-operator or underlying-model claim from this collector.

## 5. Validate on staging, then deploy

1. Keep your previous application deployment and routing configuration for rollback.
2. Install on an authorized staging application with the correct verified PulseAI property. Do not send staging traffic under another customer's domain or invent a paid entitlement.
3. Load one allowlisted public page. Confirm its original content, status, cookies and cache headers are unchanged.
4. Inspect `pulse.status()` through your protected application administration or server console. Do **not** expose it at an unauthenticated public diagnostics route.
5. A pending queue means local recording, not successful delivery. The background timer attempts a due batch every five seconds. Confirm `counters.acknowledged` increases and `pending` drains. In your actual dashboard confirm the expected page, observation time and count, then inspect the CSV evidence.
6. Make one request to an unlisted/private path and confirm it adds no event. Reconcile all incidental allowed requests rather than treating every event as a separate person.
7. Test an outage on your staging configuration, restart the Node process with the same private volume, and confirm queued IDs/times are preserved and retries do not duplicate dashboard usage.
8. Deploy your existing app normally and repeat the response/delivery check on the intended hostname.

Do not use fake card details or artificial real charges against live checkout to test the integration. For a commercial installation use a genuine subscription; a local/sandbox receiver test alone is not proof of a customer's hosted deployment.

## Delivery, health and recovery

- At most **10,000 pending events**, **50 per batch**, **32 KiB per request**, a **10-second** send timeout and a bounded acknowledgement response. Queue overflow is counted in `counters.queueOverflow`; those new observations were not saved.
- Events are persisted in SQLite before delivery, with stable ID/time across retries. Retry delays increase from about five seconds to at most about one hour. Only explicit acknowledgement IDs remove pending events. Redirects are refused and the collector key is never forwarded to a redirect destination.
- Billing/key/domain failures and quota responses pause retries for about an hour. Check `health.lastHttpStatus`, `health.lastFailure` and `health.blockedUntil`, resolve the account/key problem and allow the next scheduled attempt. Unacknowledged events remain queued.
- Events older than seven days are removed as explicitly rejected/undeliverable, not counted as delivered; at most 100 rejection IDs are retained locally. Time-range rejection from the receiver is handled only for the explicitly rejected IDs.
- `status().pending === null` means the outbox could not be read; it does not mean zero backlog. Investigate storage availability and backups. Website responses should continue while analytics is unavailable.
- `pulse.flush()` attempts one due batch. It respects persisted backoff and subscription pauses. `pulse.close()` stops the timer and closes local storage after an in-flight attempt, preserving unacknowledged events.
- An outbox is permanently bound to its original Website ID and hostname. It may reopen with a rotated key for the same site. Do not reuse a queue for another domain or owner. The process lock refuses **every existing lock**, including after a crash. For crash recovery, have the administrator stop the application and its automatic restarts, confirm that no process uses this exact private outbox, inspect the recorded PID in `collector.lock`, and remove **only that lock file** before restarting. Preserve `outbox.sqlite` and all SQLite sidecar files. PID absence alone is insufficient on a shared filesystem; shared/network filesystems are unsupported. Never remove a lock while a collector may still be running.

## Server/log integration API

The supported programmatic recording API is:

```js
const saved = pulse.record({
  method: 'GET',
  host: 'www.example.com',
  path: '/pricing',
  userAgent: 'the incoming request user-agent', // examined, not stored
  observedAt: new Date().toISOString(),
  statusCode: 200,
  latencyMs: 5,
  // Optional stable producer ID for log replay; otherwise generated once.
  id: 'your-stable-event-id-123',
});
```

`record()` returns true for a persisted observation or identical already-pending ID; false means ignored, invalid, full or unavailable. Do not count false as delivered. Supplying your own ID requires preserving the original timestamp/content on retries. IDs must be 8–128 letters, numbers, underscores or hyphens. Observations must be within seven days and no more than five minutes in the future. Never supply a browser visitor ID or an identity override. The module still performs hostname, path, timestamp, field and size checks and owns source classification.

## Rollback

Remove or disable the collector middleware/hook and deploy your prior application version. Keep the private outbox intact while investigating, and protect its permissions and backups. Remove the optional shutdown hook if it referred only to the collector. The collector does not change DNS, customer authentication or visitor access policy.

For help contact [PulseAI Support](mailto:insights@pulseaianalytics.com), giving the hosting/runtime type, nonsecret error code and relevant aggregate health counters. Never send the ingestion key, private database, full access logs or personal visitor data.

## November 1 operator verification update

Read the [verification, privacy and upgrade guide](https://pulseaianalytics.com/downloads/pulseai-operator-verification.md) before enabling the new network checks. The current catalog includes 227 reviewed names. This version also records browser-consistency signals, the type and name of the referring source (never the URL) and, where your edge supplies one, a country code. Signed agents such as ChatGPT's browser agent can be verified. More than 20 requests in 10 seconds from one browser user agent are flagged as suspected. A country is read from `cf-ipcountry` only for requests from a configured `trustedProxyCidrs` peer. Supported recent requests can obtain a request-bound official-network verification receipt; raw IPs never enter the durable queue or event records. Preserve your existing IDs, keys and pending queue when upgrading. Node uses the socket peer unless trustedProxyCidrs and clientIpHeader are explicitly configured. Set operatorVerification:false to disable network verification.

## Browser visits and Visitors

This collector reports requests in its collection scope. To also see browser-visit estimates in **Visitors**, install the complementary [page tag](https://pulseaianalytics.com/downloads/pulseai-page-tag.md) on your public pages using the same verified Website ID. The tag adds page views, sessions, engagement and browser-input signals; it does not replace the collector or verify that a visitor is a person. Unrecognized agents can remain in Estimated human totals, and false positives can exclude people.

The tag uses localStorage and sends per-page IDs for updates, without a persistent visitor ID. Review your privacy notice and applicable consent requirements before installing it. Each tag page view uses one event from your monthly allowance in addition to collector request events; tag updates use no additional events.
