Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@financial-times/n-tracking
Advanced tools
This package provides tracking initialisation and custom events for FT.com. On the client-side it configures o-tracking (which is used to capture and send tracking events to Spoor) and for the server-side it provides components which render fallback tracking pixels .
This package is for client-side and server-side use and is distributed on npm.
npm install -S @financial-times/n-tracking
After installing the package you can import the tracking component into your code:
Configure o-tracking
This package can be used on the client-side. Initialise the component with configuration options.
import * as nTracking from '@financial-times/n-tracking';
const options = {}
const oTracking = nTracking.init(options);
Send custom events
import * as nTracking from '@financial-times/n-tracking';
const context = { customData: 12345 }
nTracking.broadcast('oTracking.event', {
category: 'page',
action: 'custom-event',
...context
});
On the server-side a JSX component embeds tracking pixels into the page which send page view events for any visitors which do not support JS or fail to cut the mustard.
const { CoreTracking } = require('@financial-times/n-tracking');
<CoreTracking {...options} />
To initialise the component you'll need to provide it with several configuration options.
init(options)
Configures o-tracking with the given options, triggers a page view event, initialises click tracking, and returns the instance of o-tracking.
broadcast(name, data)
Creates a CustomEvent
with the given name and data and dispatches it from the document <body>
element. It is intended to be used to trigger oTracking.event
events.
trackers.{tracker}()
There are several custom tracking features provided by this library. See the docs folder for more information about these.
<CoreTracking />
Renders a <noscript>
and inline <script>
element to embed fallback tracking pixels into the page which can be used when the client-side JS fails to run. It accepts the same options as the client-side code.
Property | Type | Required | Description |
---|---|---|---|
appContext | Object | Yes | FT.com App Context data describing the current page which will be appended to all captured events. |
extraContext | Object | No | Additional data describing the current page which will be appended to all captured events. |
pageViewContext | Object | No | Additional data to append to the page view event only |
FAQs
Client-side tracking initialisation for FT.com apps
The npm package @financial-times/n-tracking receives a total of 1,095 weekly downloads. As such, @financial-times/n-tracking popularity was classified as popular.
We found that @financial-times/n-tracking demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.