このページでは

For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

Verify Browser Unified SDK events

このページはまだあなたの言語に翻訳されていません。 現在取り組んでいますので、後でもう一度確認してください。

The Browser Unified SDK sends analytics events through the bundled Browser SDK 2. An analytics event moves through the same four stages as in Browser SDK 2: captured, transformed, sent, and received. This page covers the checks specific to the Unified SDK, starting with initialization, and links to the Browser SDK 2 steps for the other stages.

For problems common to every Amplitude SDK, go to SDK troubleshooting and debugging. For changes between versions, go to the @amplitude/unified changelog.

Turn on debug logging

Pass logLevel inside analytics. Session Replay logs through the same logger, so its messages appear with the analytics messages.

ts
amplitude.initAll("YOUR_API_KEY", {
  analytics: { logLevel: amplitude.Types.LogLevel.Debug },
});

For log levels and what each message contains, go to Turn on debug logging in Browser SDK 2. Return logLevel to Warn before you ship.

Check that each product initialized

Await initAll(), then check each product through its accessor:

ts
await amplitude.initAll("YOUR_API_KEY", {
  sessionReplay: { sampleRate: 1 },
});

console.log(amplitude.sessionReplay()?.getSessionReplayProperties());
// { "[Amplitude] Session Replay ID": "..." } while recording; {} when not

console.log(typeof amplitude.experiment()?.fetch);
// "function"

In the browser Network tab, filter on amplitude.com and look for these requests:

If getSessionReplayProperties() returns {}, Session Replay isn't recording. Check the log for this message: Session ... not being captured due to capture being disabled for project or because the remote config could not be fetched. Then confirm that sampleRate is above 0.

Check what the SDK sent

Find the request to api2.amplitude.com/2/httpapi (api.eu.amplitude.com for EU) and open its payload. The library field of each Unified SDK event contains two version numbers:

json
{
  "event_type": "Sign Up Clicked",
  "library": "amplitude-ts-unified/1.1.43-amplitude-ts/2.48.1"
}

The first version is @amplitude/unified. The second is the bundled Browser SDK 2. Use the second version when you compare behavior against the Browser SDK 2 release notes. For payload fields and compression, go to Check what the SDK sent in Browser SDK 2.

これは役に立ちましたか?