@financial-times/ads-personalised-consent

中文文档
7.5.2发布于 2026/10/07TypeScriptES Module近 30 天下载 3037

ads-personalised-consent =================

原始使用文档
文档目录13 节
  1. Functionality Overview
  2. Use
  3. API
  4. getPersonalisedConsent()
  5. personalisedConsent.isAllowed()
  6. personalisedConsent.getLegislation()
  7. personalisedConsent.getRegion()
  8. personalisedConsent.getGpcValue()
  9. personalisedConsent.getConsentCookie()
  10. personalisedConsent.update()
  11. personalisedConsent.updatePrivacyLegislation()
  12. personalisedConsent.updateGpcValue()
  13. personalisedConsent.updateConsentCookie()

ads-personalised-consent

A client side package to provide consent settings of personalised advertisement.

Functionality Overview

This package collects all the information related to privacy and generates an answer on whether different types of personalised advertisement is allowed. It takes into account of:

  • The privacy policy of the location which the user is in (e.g. California Consumer Privacy Act (CCPA) for California, US), which is collected from Privacy Legislation Client
  • The browser settings - e.g. Global Privacy Control (GPC).
  • The consents settings for behavioral, demographic and programmatic ads retrieved via the FTConsent cookie. Users can configure these settings via the Manage Cookies page in FT.com, the Manage Cookies page on the FT App and the Manage Cookies pages on the specialist titles websites. These values can also be configured via the Cookie Banner displayed on FT.com, FT App or specialist titles. Yet another way to configure ads consent is via the Privacy page on FT.com

Use

Typical usage would be to add the module to your app, call the imported method and then check whether the personalised advertisement is allowed:

import { getPersonalisedConsent } from "@financial-times/ads-personalised-consent";

async function onPageLoad() {
  // create a fresh, updated instance of PersonalisedConsent, and get the privacy properties via getters
  const pc = await getPersonalisedConsent();
  const personalisedConsent = pc.isAllowed();
  // check whether a certain type of personalised ads is allowed or not
  if (personalisedConsent.behavioral) {
    setupBehavioralAds();
  } else {
    blockBehavioralAds();
  }
  
  // alternatively, only update the privacy legislation properties and retrieve the new values
  await pc.updatePrivacyLegislation();
  const legislation = pc.getLegislation();
  const region = pc.getRegion();
  // similar for GPC value and consent cookie
  pc.updateGpcValue();
  const gpc = pc.getGpcValue();
  pc.updateConsentCookie();
  const consentCookie = pc.getConsentCookie();
  ...
}

API

getPersonalisedConsent()

Initialise the instance of PersaonalisedConsent and update all the privacy related properties. Returns a Promise which always resolves with the said instance.

personalisedConsent.isAllowed()

Returns an Object identifying whether different types of personalised ads (behavioural, demographic and programmatic) are allowed or not, based on

  • The privacy policy obtained from Privacy Legislation Client (If Privacy Legislation Client returns error, it will consider the user is subject to all the policies available.)
  • The browser settings for Global Privacy Control (GPC)
  • The consents settings for behavioral, demographic and programmatic ads retrieved via the FTConsent cookie.
NameData-structureNotes
behavioralbooleanwhether behavioral ads is allowed
demographicbooleanwhether demographic ads is allowed
programmaticbooleanwhether programmatic ads is allowed

personalisedConsent.getLegislation()

Returns the legislation stored in the instance since last update, which is either

  • a Set of legislation which the user is subject to if Privacy Legislation Client succeeds, or;
  • undefined if Privacy Legislation Client throws error.

personalisedConsent.getRegion()

Returns the region stored in the instance since last update, which is either

  • a string identifying the region which the user is in if Privacy Legislation Client succeeds, or;
  • undefined if Privacy Legislation Client throws error.

personalisedConsent.getGpcValue()

Returns a boolean showing the GPC settings on the browser (which is Navigator.globalPrivacyControl) stored in the instance since last update.

personalisedConsent.getConsentCookie()

Returns an Object identifying user's settings in FTConsent cookie for different types of personalised ads (behavioural, demographic and programmatic) stored in the instance since last update.

NameData-structureNotes
behavioralbooleanFTConsent cookie exists and behaviouraladsOnsite:on is set
demographicbooleanFTConsent cookie exists and demographicadsOnsite:on is set
programmaticbooleanFTConsent cookie exists and programmaticadsOnsite:on is set

personalisedConsent.update()

Update all the privacy related properties. Returns a Promise which always resolves.

personalisedConsent.updatePrivacyLegislation()

Updates only legislation and region, and returns a Promise containing

NameData-structureNotes
legislationSet of string OR undefineda Set of legislation which the user is subject to if Privacy Legislation Client succeeds, otherwise undefined
regionstring OR undefineda string identifying the region which the user is in if Privacy Legislation Client succeeds, otherwise undefined

personalisedConsent.updateGpcValue()

Updates only the GPC settings, and return a boolean showing the latest GPC settings on the browser.

personalisedConsent.updateConsentCookie()

Updates only the user's settings in FTConsent cookie for different types of personalised ads, and return an Object identifying the settings.

NameData-structureNotes
behavioralbooleanFTConsent cookie exists and behaviouraladsOnsite:on is set
demographicbooleanFTConsent cookie exists and demographicadsOnsite:on is set
programmaticbooleanFTConsent cookie exists and programmaticadsOnsite:on is set

版本与发布记录

@financial-times/ads-personalised-consent 共发布 85 个版本,首次发布于 2021/12/17;过去 12 个月发布了 4 个版本。

版本发布日期距今
7.5.2latest2026/10/071 个月前
7.5.12026/05/185 个月前
7.5.02026/05/086 个月前
7.4.02026/03/177 个月前
7.3.02025/10/221.1 年前
7.2.12025/06/191.4 年前

其他发布通道:pre-release → 5.4.0-beta.5。

关于 @financial-times/ads-personalised-consent 的常见问题

@financial-times/ads-personalised-consent 是什么?

ads-personalised-consent =================

如何安装 @financial-times/ads-personalised-consent?

在项目目录运行 npm install @financial-times/ads-personalised-consent,或使用 pnpm add / yarn add / bun add。

@financial-times/ads-personalised-consent 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@financial-times/ads-personalised-consent 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@financial-times/ads-personalised-consent 可以商用吗?

@financial-times/ads-personalised-consent 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@financial-times/ads-personalised-consent 的下载量有多少?

根据 npm 官方下载统计,@financial-times/ads-personalised-consent 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,037 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@financial-times/ads-personalised-consent 还在维护吗?

最新版本 7.5.2 发布于 2026/10/07(1 个月前);至今共发布 85 个版本,其中过去 12 个月发布了 4 个;首次发布于 2021/12/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。