@atlaskit/analytics-cross-product

中文文档
2.3.1发布于 2026/10/22Apache-2.0TypeScriptESM + CJS近 30 天下载 2.2万

Utilities to enable cross-product interaction session tracking

原始使用文档
文档目录6 节
  1. Overview
  2. Stream 3 observation contracts
  3. Usage within an Atlassian bridge
  4. Parameter generation and re-generation
  5. Relative URLs
  6. Usage with Identity

AnalyticsCrossProduct

Utilities to enable cross-product interaction session tracking

This repository is the public facing version of @atlassiansox/analytics-cross-product-interaction-client. Functionality has been duplicated from the private package to enable @atlaskit components to use our library, with the eventual goal of deprecating these functions in the existing package to avoid code duplication.

The functions in this library are designed to work in conjunction with analytics-web-client and analytics-cross-product-interaction-client on Atlassian products, and using these functions on their own will return a no-op.

Overview

The Analytics Web Client generates interaction session data and stores it in Session Storage. The data is in the following shape:

"interactionSession": {
    "id": "123456789",
    "prevId": "912345678",
    "bridge": "atlassianSwitcher",
    "source": "jira"
}

This package exposes: useCrossProductUrlWrapper, a React hook that can be used to retrieve interaction session data and append them as URL parameters onto cross-product navigation URLs

Stream 3 observation contracts

The package also exposes transport-independent building blocks for observing cross-product navigation without adding or changing XPIS:

  • xpcDestinationResolver provides controlled product, sub-product, route-family and matcher values plus four-outcome destination resolution: same, cross, unknown and excluded.
  • xpcNavigationObservation inspects XPIS presence and builds fresh, privacy-safe departure and arrival observations.
  • xpcActivationCoordinator ensures that native and owned final-sink observers complete a user activation at most once.
  • xpcNativeDepartureCapture installs delegated click and auxclick capture at a product-owned root while yielding to intercepted renderer sinks.
  • xpcFinalSinkDepartureCapture records authoritative renderer handoffs with controlled capture and navigation enums. The schema retains bounded imperative and router values for later, independently gated integrations.
  • xpcArrivalCapture inspects an arrival URL locally and reports only XPIS-bearing destination evidence; the URL never enters the observation.
  • xpcNavigationProvider composes one product-root native observer, initial-arrival capture, shared activation coordination and renderer final-sink hooks from a product's controlled configuration.
  • xpcAwcNavigationReporter is the candidate boundary to a product's existing Analytics Web Client. It deliberately omits the interaction-session ID until its production privacy treatment is approved.

Products supply their own controlled registry entries, source identity, rollout gate and reporter. The shared package does not register a GASv3 event. Product adapters may use the feature-gated candidate Analytics Web Client reporter for validation, but it must remain disabled until the event schema, channel, privacy controls and ownership are approved. Candidate code is not evidence that the event is registered or production-enabled.

Usage within an Atlassian bridge

A bridge is a component that provides a link/navigation to a different Atlassian page, for example:

return <Link href="https://hello.atlassian.net/wiki"> Confluence </Link>

To embed the interaction session properties into the link as a UTM parameter, call our hook useCrossProductUrlWrapper which generates a function to wrap the link with.

Then replace any instances of URLs with the URL wrapped in the hook

import { useCrossProductUrlWrapper }  from '@atlaskit/analytics-cross-product';

const withInteractionSession = useCrossProductUrlWrapper({
    bridge: 'Bridge Name', // The name of your bridge component e.g. atlassianSwitcher
    product: 'Product Name', // The product you are hosted on e.g. jira
    subProduct: 'SubProduct Name', // Optional - include if required
});

return (
    <Link href={withInteractionSession("https://hello.atlassian.net/wiki")}> Confluence </Link>
)

The useCrossProductUrlWrapper hook takes in options of type CrossProductUrlOptions which can be imported from our library if required

The returned wrapper function (withInteractionSession in the above example) takes a URL as a string, and returns a string as well. The return value of the above call would be something like:

https://hello.atlassian.net/wiki?xpis=e2JyaWRnZToiQnJpZGdlIE5hbWUiLGlkOiIxMjM0NTY3ODkiLHNvdXJjZToiUHJvZHVjdCBOYW1lLVN1YlByb2R1Y3QgTmFtZSJ9

with the interaction session data encoded in the ?xpis query parameter (cross-product interaction session)

See our example. To run the example locally:

yarn start @atlaskit/analytics-cross-product

Parameter generation and re-generation

Interaction session data will only be appended to the URL if it has already been generated by the Analytics Web Client and exists in Session Storage. If interaction session data cannot be found, the hook will not modify the URL. The hook is subscribed to a DOM event that will trigger a re-render if a new interaciton session is generated, and will dynamically update the URL to include the correct parameters

Relative URLs

The wrapper supports relative URLs, for example:

withInteractionSession("/wiki")

will return

"/wiki?xpis=e2Jya..."

We use the URL class to perform operations. Note:

  • The URL must not have a trailing slash (i.e. use /wiki instead of /wiki/)
  • A leading slash will be added to the return output (i.e. wiki will become /wiki?xpis=...)
  • Existing query parameters will be preserved (/wiki?a=b becomes /wiki?a=b&xpis=e2Jya...)

Usage with Identity

When a link is wrapped in Identity (passed as the continue paramater in the redirect), Identity encodes query parameters using percent encoding (i.e. &key=value becomes %26key%3Dvalue).

Ensure that our wrapper is called on the href before passing into identity. This will ensure our query parameters are also correctly percent encoded, and will persist after Identity redirect

版本与发布记录

@atlaskit/analytics-cross-product 共发布 10 个版本,首次发布于 2026/05/11;过去 12 个月发布了 10 个版本。

版本发布日期距今
2.3.1latest2026/10/2216 天前
2.3.02026/10/1919 天前
2.2.02026/09/101 个月前
2.1.12026/07/213 个月前
2.1.02026/07/074 个月前
2.0.02026/06/164 个月前

关于 @atlaskit/analytics-cross-product 的常见问题

@atlaskit/analytics-cross-product 是什么?

Utilities to enable cross-product interaction session tracking

如何安装 @atlaskit/analytics-cross-product?

在项目目录运行 npm install @atlaskit/analytics-cross-product,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atlaskit/analytics-cross-product 支持 TypeScript 吗?

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

@atlaskit/analytics-cross-product 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@atlaskit/analytics-cross-product 可以商用吗?

@atlaskit/analytics-cross-product 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@atlaskit/analytics-cross-product 的下载量有多少?

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

@atlaskit/analytics-cross-product 还在维护吗?

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