--- title: "Interfaces" slug: "nodejs-interfaces" description: "Interfaces of the Node.js Library: IMappIntelligenceCookie, IMappIntelligenceLogger and IMappIntelligenceConsumer for custom loggers and consumers." status: "update" updated: 2026-11-02T16:54:32Z published: 2026-11-02T16:54:32Z canonical: "docs.mapp.com/nodejs-interfaces" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.mapp.com/llms.txt > Use this file to discover all available pages before exploring further. # Interfaces **IMappIntelligenceCookie** ## Methods ### setDomain ```javascript /** * @param domain Specifies the domain within which this cookie should be presented. */ setDomain(domain: string) => void; ``` ### getDomain ```javascript /** * @return Gets the domain name of this cookie. */ getDomain() => string; ``` ### setMaxAge ```javascript /** * Sets the maximum age in seconds for this cookie. * * @param expiry Sets the maximum age in seconds for this cookie. */ setMaxAge(expiry: number) => void; ``` ### getMaxAge ```javascript /** * Gets the maximum age in seconds of this cookie. * * @return Gets the maximum age in seconds of this cookie. */ getMaxAge() => number; ``` > [!WARNING] > Warning > > The value is in **seconds**. Express (`response.cookie()`) expects `maxAge` in **milliseconds**: pass `getMaxAge() * 1000`, otherwise the everID cookie expires after about 4 hours instead of 6 months and every visitor is counted again and again. A value of -1 means a session cookie: do not pass `maxAge` at all. ### setPath ```javascript /** * @param uri Specifies a path for the cookie to which the client should return the cookie. */ setPath(uri: string) => void; ``` ### getPath ```javascript /** * @return Returns the path on the server to which the browser returns this cookie. */ getPath() => string; ``` ### setSecure ```javascript /** * @param flag Indicates to the browser whether the cookie should only be sent using a secure protocol, such as *             HTTPS or SSL. */ setSecure(flag: boolean) => void; ``` ### isSecure ```javascript /** * @return  Returns true if the browser is sending cookies only over a secure protocol, or false if the browser *          can send cookies using any protocol. */ isSecure() => boolean; ``` ### getName ```javascript /** * @return Returns the name of the cookie. */ getName() => string; ``` ### getValue ```javascript /** * @return Gets the current value of this cookie. */ getValue() => string; ``` ### setHttpOnly ```javascript /** * @param isHttpOnly Marks or unmarks this cookie as HttpOnly. */ setHttpOnly(isHttpOnly: boolean) => void; ``` ### isHttpOnly ```javascript /** * @return Checks whether this cookie has been marked as HttpOnly. */ isHttpOnly() => boolean; ``` **IMappIntelligenceLogger** Create your own LoggerClass to debug our Mapp Intelligence js library. ## Methods ### log ```javascript /** * @param msg Debug message */ log(...msg: Array) => void; ``` ### Example ```javascript class CustomLogger implements IMappIntelligenceLogger { public log(...msg: Array): void { console.log(...msg); } } ``` **IMappIntelligenceConsumer** Create your own ConsumerClass to use for data transfer to Intelligence. ## Methods ### sendBatch Required by the TypeScript interface, also for a consumer that implements `send()`. Resolves to `true` (`SENT`) or `false` (`RETRY`). ```javascript /** * @param batchContent List of tracking requests * * @return Promise */ sendBatch(batchContent: Array): Promise; ``` ### send (optional) Sends a batch and reports what happened to it: `MappIntelligenceBatchResult.SENT`, `RETRY` or `DISCARDED` (see [Data Transfer: Consumer](/v1/docs/nodejs-data-transfer-consumer)). If `send()` exists, the library calls it instead of `sendBatch()`; `sendBatch()` is still required by the TypeScript interface (it is not called then). A consumer that never discards a batch can keep implementing `sendBatch()` only: `true` means `SENT`, `false` means `RETRY`. A consumer that throws or rejects, or resolves to anything else, is treated as `RETRY`: the batch stays in the queue and the error is logged. The library does not log a `DISCARDED` batch of a custom consumer: log the reason in your consumer, the flush only resolves to `false`. ```javascript /** * @param batchContent List of tracking requests * * @return Promise */ send?(batchContent: Array): Promise; ``` ### close (optional) Releases the resources of the consumer. The library only closes the consumers it created itself: a consumer that you pass in via `setConsumer` may be shared by several tracking instances, so closing it is up to you. ```javascript /** * @return Promise */ close?(): Promise; ``` ### Example ```javascript class TestCustomPrintConsumer implements IMappIntelligenceConsumer {    public async sendBatch(batchContent: Array): Promise {        for (const request of batchContent) {            console.log(request);        }        return true;    } } ``` A consumer that can discard a batch implements `send()` as well: ```javascript class TestCustomDiscardingConsumer implements IMappIntelligenceConsumer {    public async send(batchContent: Array): Promise {        // implement custom consumer logic        return MappIntelligenceBatchResult.SENT; // or RETRY, DISCARDED    }    public async sendBatch(batchContent: Array): Promise {        return (await this.send(batchContent)) === MappIntelligenceBatchResult.SENT;    } } ```