@adobe/aio-lib-analytics

中文文档
4.0.2发布于 2025/09/04CommonJS近 30 天下载 2.6万

Adobe Analytics SDK

原始使用文档
文档目录26 节
  1. Installing
  2. Usage
  3. Classes
  4. Functions
  5. AnalyticsCoreAPI
  6. analyticsCoreAPI.init(companyId, apiKey, token) ⇒ Analytics…
  7. analyticsCoreAPI.getCalculatedMetrics(options)
  8. analyticsCoreAPI.getCalculatedMetricById(id, options)
  9. analyticsCoreAPI.getCollections(options)
  10. analyticsCoreAPI.getCollectionById(rsid, options)
  11. analyticsCoreAPI.getDateRanges(options)
  12. analyticsCoreAPI.getDateRangeById(dateRangeId, options)
  13. analyticsCoreAPI.getDimensions(rsid, options)
  14. analyticsCoreAPI.getDimensionById(dimensionId, rsid, option…
  15. analyticsCoreAPI.getMetrics(rsid, options)
  16. analyticsCoreAPI.getMetricById(id, rsid, options)
  17. analyticsCoreAPI.getReport(body)
  18. analyticsCoreAPI.getSegments(options)
  19. analyticsCoreAPI.validateSegment(rsid, body)
  20. analyticsCoreAPI.getUsers(options)
  21. analyticsCoreAPI.getCurrentUser()
  22. analyticsCoreAPI.getUsageLogs(startDate, endDate, options)
  23. init(companyId, apiKey, token) ⇒ Promise.<AnalyticsCoreAPI>
  24. Debug Logs
  25. Contributing
  26. Licensing

Version Downloads/week Node.js CI License Codecov Coverage

Adobe I/O Adobe Analytics SDK

Node Javascript Core SDK wrapping Adobe Analytics 2.0 APIs.

Installing

$ npm install

Usage

  1. Initialize the SDK
var sdk = require('@adobe/aio-lib-analytics');

async function sdkTest() {
  //initialize sdk
  const analyticsClient = await sdk.init('<companyID>', 'x-api-key', '<valid auth token>')
}

Init method returns an Instance of Class AnalyticsCoreAPI

  1. Call methods using initialized sdk
var sdk = require('@adobe/aio-lib-analytics');

async function sdkTest() {
    //initialize sdk
    const analyticsClient = await sdk.init('<companyID>', '<x-api-key>', '<valid auth token>')

    //get report suites
    const collections = await analyticsClient.getCollections({limit:5, page:0})

    //get metrics
    const metrics = await analyticsClient.getMetrics(rsid)

    //generate report
    const report = await analyticsClient.getReport(queryJSON)
}

All Methods available under sdk are documented here

Classes

AnalyticsCoreAPI

This class provides methods to call Adobe Analytics APIs. Before calling any method initialize the instance by calling init method on it with valid company id, apiKey and auth token

Functions

init(companyId, apiKey, token) ⇒ Promise.<AnalyticsCoreAPI>

Returns a Promise that resolves with a new AnalyticsCoreAPI object.

AnalyticsCoreAPI

This class provides methods to call Adobe Analytics APIs. Before calling any method initialize the instance by calling init method on it with valid company id, apiKey and auth token

Kind: global class

analyticsCoreAPI.init(companyId, apiKey, token) ⇒ AnalyticsCoreAPI

Initialize sdk.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
companyIdstringcompany ID to be used with Adobe Analytics.
apiKeystringYour api key
tokenstringValid auth token

analyticsCoreAPI.getCalculatedMetrics(options)

Retrieve many calculated metrics. A calculated metric response will always include these default items: id, name, description, rsid, owner, polarity, precision, type Other attributes can be optionally requested through the 'expansion' field:\n\n modified: Date that the metric was last modified (ISO 8601) definition: Calculated metric definition as JSON object compatibility: Products that the metric is compatible with reportSuiteName*: Also return the friendly Report Suite name for the RSID tags*: Gives all existing tags associated with the calculated metric

For more information about calculated metrics go here

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
optionsObjectto control calculated metrics search.
options.calculatedMetricFilterFilter list to only include calculated metrics in the specified list\n(comma-delimited list of IDs).
options.expansionComma-delimited list of additional metadata fields\nto include on response.
options.limitNumber of results per page. Default 10.
options.localeLocale.
options.nameFilter list to only include calculated metrics that contains the Name.
options.ownerIdFilter list to only include calculated metrics owned by the\nspecified loginId.
options.pagePage number (base 0 - first page is "0"). Default 0.
options.rsidsFilter list to only include calculated metrics tied to specified\nRSID list (comma-delimited).
options.tagNamesFilter list to only include calculated metrics that contains one of\nthe tags.

analyticsCoreAPI.getCalculatedMetricById(id, options)

Retrieve a single calculated metric by id. A calculated metric response will always include these default items: id, name, description, rsid, owner, polarity, precision, type Other attributes can be optionally requested through the 'expansion' field:\n\n modified: Date that the metric was last modified (ISO 8601) definition: Calculated metric definition as JSON object compatibility: Products that the metric is compatible with reportSuiteName*: Also return the friendly Report Suite name for the RSID tags*: Gives all existing tags associated with the calculated metric

For more information about calculated metrics go here

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
idstringThe calculated metric ID to retrieve.
optionsObjectto control calculated metric result
options.expansionComma-delimited list of additional metadata fields\nto include on response.
options.localeLocale.

analyticsCoreAPI.getCollections(options)

Retrieves report suites that match the given filters. Returns all report suite types in a single collection.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
optionsObjectto control report suites search.
options.expansionComma-delimited list of additional metadata fields to include on\nresponse.
options.limitNumber of results per page. Default 10.
options.pagePage number (base 0 - first page is "0"). Default 0.
options.rsidsFilter list to only include suites in this RSID list\n(comma-delimited).
options.rsidContainsFilter list to only include suites whose rsid contains rsidContains.

analyticsCoreAPI.getCollectionById(rsid, options)

Retrieves report suite by id. Returns all report suite types in a single collection.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
rsidstringThe rsid of the suite to return.
optionsObjectto control eport suites search.
options.expansionComma-delimited list of additional metadata fields to include on\nresponse.

analyticsCoreAPI.getDateRanges(options)

Returns a list of dateranges for the user. This function allows users to store commonly used date ranges so that they\ncan be reused throughout the product.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
optionsObjectto control date range search.
options.expansionComma-delimited list of additional metadata fields to include on\nresponse.
options.filterByIdsFilter list to only include date ranges in the specified list\n(comma-delimited list of IDs).
options.limitNumber of results per page. Default 10.
options.localeLocale.
options.pagePage number (base 0 - first page is "0"). Default 0.

analyticsCoreAPI.getDateRangeById(dateRangeId, options)

Retrieves configuration for a DateRange..

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
dateRangeIdstringThe DateRange id for which to retrieve information.
optionsObjectto control date range result.
options.expansionComma-delimited list of additional metadata fields to include on\nresponse.
options.localeLocale.

analyticsCoreAPI.getDimensions(rsid, options)

Returns a list of dimensions for a given report suite.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
rsidstringA Report Suite ID.
optionsObjectto control dimensions search.
options.classifiableOnly include classifiable dimensions.
options.expansionComma-delimited list of additional metadata fields\nto include on response.
options.localeLocale.
options.reportableOnly include dimensions that are valid within a report.
options.segmentableOnly include dimensions that are valid within a segment.

analyticsCoreAPI.getDimensionById(dimensionId, rsid, options)

Returns a dimension for the given report suite and dimension Id.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
dimensionIdstringThe dimension ID. For example a valid id is a value like 'evar1'.
rsidstringA Report Suite ID.
optionsObjectto control dimension result.
options.expansionComma-delimited list of additional metadata fields\nto include on response.
options.localeLocale.

analyticsCoreAPI.getMetrics(rsid, options)

Returns a list of metrics for the given report suite. This returns the metrics list primarily for the Analytics product. The platform identity API Returns a list of all possible metrics for the supported systems.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
rsidstringA Report Suite ID.
optionsObjectto control dimension result.
options.expansionComma-delimited list of additional metadata fields\nto include on response.
options.localeLocale that system named metrics should be returned in.
options.segmentableFilter the metrics by if they are valid in a segment.

analyticsCoreAPI.getMetricById(id, rsid, options)

Returns a metric for the given report suite. This returns the metrics list primarily for the Analytics product. The platform identity API Returns a list of all possible metrics for the supported systems.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
idstringThe id of the metric for which to retrieve info. Note ids are values\nlike pageviews, not metrics/pageviews.
rsidstringA Report Suite ID.
optionsObjectto control dimension result.
options.expansionComma-delimited list of additional metadata fields\nto include on response.
options.localeLocale that system named metrics should be returned in.

analyticsCoreAPI.getReport(body)

Runs a report for the request. See the Reporting User\nGuide for details.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
bodyObjectreport query.

analyticsCoreAPI.getSegments(options)

Retrieve All Segments.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
optionsObjectto control segments search.
options.expansionComma-delimited list of additional metadata fields\nto include on response.
options.includeTypeInclude additional segments not owned by user. The "all" option\ntakes precedence over "shared".
options.limitNumber of results per page. Default 10.
options.localeLocale that system named metrics should be returned in.
options.nameFilter list to only include segments that contains the Name.
options.pagePage number (base 0 - first page is "0"). Default 0.
options.rsidsFilter list to only include segments tied to specified RSID list\n(comma-delimited).
options.segmentFilterFilter list to only include segments in the specified list\n(comma-delimited list of IDs).
options.tagNamesFilter list to only include segments that contains one of the tags.

analyticsCoreAPI.validateSegment(rsid, body)

Validate a Segment. Returns a segment validation for the segment contained in the post body of the report.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
rsidstringA Report Suite ID.
bodyObjectJSON Segment Definition.

analyticsCoreAPI.getUsers(options)

Returns a list of users for the current user's login company. Retrieves a list of all users for the company designated by the auth\ntoken.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
optionsObjectto control user search.
options.limitNumber of results per page. Default 10.
options.pagePage number (base 0 - first page is "0"). Default 0.

analyticsCoreAPI.getCurrentUser()

Get the current user.

Kind: instance method of AnalyticsCoreAPI

analyticsCoreAPI.getUsageLogs(startDate, endDate, options)

Retrieves usage and access logs for the search criteria provided. This API returns the usage and access logs for a given date range within a 3 month period. This API authenticates with an IMS user token.

Kind: instance method of AnalyticsCoreAPI

ParamTypeDescription
startDatestringStart date in ISO-8601 format for the maximum of a 3 month period.
endDatestringEnd date in ISO-8601 format for the maximum of a 3 month period.
optionsObjectoptions to filter logs.
options.loginstringThe login value of the user you want to filter logs by.
options.ipstringThe IP address you want to filter logs by.
options.rsidstringThe report suite ID you want to filter logs by.
options.eventTypestringThe numeric id for the event type you want to filter logs by.
options.eventstringThe event description you want to filter logs by. No wildcards permitted.
options.limitnumberNumber of results per page. Default 10.
options.pagenumberPage number (base 0 - first page is "0"). Default 0.

init(companyId, apiKey, token) ⇒ Promise.<AnalyticsCoreAPI>

Returns a Promise that resolves with a new AnalyticsCoreAPI object.

Kind: global function

ParamTypeDescription
companyIdstringcompany ID to be used with Adobe Analytics.
apiKeystringYour api key
tokenstringValid auth token

Debug Logs

LOG_LEVEL=debug <your_call_here>

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

版本与发布记录

@adobe/aio-lib-analytics 共发布 14 个版本,首次发布于 2019/10/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.0.2latest2025/09/041.2 年前
4.0.12024/02/082 年前
4.0.02024/01/112 年前
3.0.1-pre.2024-01-08.sha-195ecf6anext2024/01/082 年前
3.0.12023/06/283 年前
3.0.02022/08/194 年前

关于 @adobe/aio-lib-analytics 的常见问题

@adobe/aio-lib-analytics 是什么?

Adobe Analytics SDK

如何安装 @adobe/aio-lib-analytics?

在项目目录运行 npm install @adobe/aio-lib-analytics,或使用 pnpm add / yarn add / bun add。

@adobe/aio-lib-analytics 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/adobe__aio-lib-analytics 是否存在。

@adobe/aio-lib-analytics 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@adobe/aio-lib-analytics 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adobe/aio-lib-analytics 可以商用吗?

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

@adobe/aio-lib-analytics 的下载量有多少?

根据 npm 官方下载统计,@adobe/aio-lib-analytics 在 2026/10/05 – 2026/11/03 这 30 天内被下载 25,846 次,日均约 862 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adobe/aio-lib-analytics 还在维护吗?

最新版本 4.0.2 发布于 2025/09/04(1.2 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/10/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。