# SDK diagnostics and troubleshooting

> Current Froomle documentation · [View canonical page](https://docs.froomle.com/froomle-doc-main/v2/js_lib/diagnostics.html)

Use the checklist to separate setup problems, failed requests, rendering, and event delivery. If you are new to the SDK, start with the [integration overview](https://docs.froomle.com/froomle-doc-main/v2/js_lib/jslib.html#Overview).

<a id="BrowserRuntime"></a>

## Diagnostics

Open the browser console and inspect the SDK’s live runtime. Reading it does not send an event or fetch recommendations.

```js
window.FroomleFrontendSdkRuntime
```

Treat diagnostics as a view of the current browser state, not as SDK configuration, an event log, or proof of backend ingestion. Use the runtime to inspect SDK state and the browser’s Network panel to verify the requests.

<a id="sdk-diagnostic-checklist"></a>

### Check setup, rendering, and tracking

1.  **Did the SDK start?** Check `integration.primaryMode`, `init.status`, and `diagnostics.config.sdkVersion`. For DOM integrations, use `diagnostics.config.domRequestContext.missingFields` to find missing environment or page type. A ready SDK can still have no recommendation request, a failed request, or an empty result.
    
2.  **Which content did the list select?** Check `diagnostics.benchmark.owner`, `stableGroup`, and the entry for that list in `recentResolutions`. Compare the list’s show set and selected `experience`; group names do not tell you what that placement displayed. If no result resolved, check `failures` and `rejectedMutations`.
    
3.  **What actually appeared?** Inspect the visible card and its `data-froomle-id` and `data-froomle-request-id` if present. For automatic tracking, look for the matching item, type, list, and request in `diagnostics.trackingLifecycle.placements`. Original CMS cards can also be registered. A resolved list or copied DOM attributes alone do not prove that the SDK displayed or registered a card.
    
4.  **Was the event sent and acknowledged?** Check `diagnostics.config.consent`, then `currentPageTracking` for page events or `trackingLifecycle` for recommendation events. Inspect the corresponding Events API request and response in Network. For recommendation events, compare `action_item`, `action_item_type`, `list_name`, and `request_id` with the card you saw or clicked. A browser-queued event is not a server acknowledgement, and an API acknowledgement does not establish that the event appears in reporting.
    

<a id="sdk-diagnostic-setup"></a>

### Setup and identity

| Field | What to check |
| --- | --- |
| `integration` | `primaryMode` is the runtime’s primary owner (`dom`, `framework`, `programmatic`, or `null`). `observedModes`, `sources`, and `lastSource` describe observed usage; an observed mode does not necessarily own initialization. |
| `init` | The DOM initializer’s `scope`, `trigger` (`auto` or `manual`), `status`, `error`, and readiness promise. `status` is `idle`, `before-init`, `initializing`, `ready`, or `failed`. A React or standalone programmatic integration need not run DOM init. |
| `diagnostics.config` | Check `environment`, `pageType`, `channel`, `siteContext`, `subscriptionLevel`, and `contextItem` / `contextItemType` against the current page. `requestDomain` and `requestOrigin` report explicit routing; `null` does not rule out SDK default routing. Use Network to verify the actual destination. |
| `diagnostics.config.domRequestContext` | `complete` or `incomplete` for DOM ownership, with `missingFields` if required context is absent; `not-applicable` otherwise. This validates page context, not credentials or the response. |
| `diagnostics.config.consent`, `hasUserId`, `hasDeviceId` | Effective SDK consent and identity presence. `hasUserId` indicates a usable account ID at consent level 2; `hasDeviceId` indicates a current device ID, not that it is persisted. These flags do not expose the IDs. |
| `diagnostics.config.deviceIdOwnership`, `deviceIdSource`, `deviceIdStorageFailure` | Ownership is `froomle` or `customer`; the source can be `generated`, `cookie`, or `explicit`. They are `null` if no device ID is available. The storage failure is `read`, `write`, `clear`, or `null`. Reading diagnostics does not create an ID or touch storage. Use [the identity contract](https://docs.froomle.com/froomle-doc-main/v2/js_lib/configuration.html#Users) when interpreting changes across page loads. |
| `diagnostics.lifecycle` | Observed `froomle:before-init` and `froomle:init` dispatch, and `inferredLoadingMode` (`blocking`, `defer`, `async`, `custom`, or `null`). |

<a id="sdk-diagnostic-benchmark"></a>

### Benchmark selection

In `diagnostics.benchmark`:

-   `startupStatus` and `sealed` show whether startup configuration can still be registered. `externalAssignmentStatus` distinguishes no external registration from pending, resolved, and failed. With Froomle assignment, `status: "awaiting-group"` can be normal before the first valid response.
    
-   `effectiveConfigurationSource`, `configurationSources`, and `assignmentSources` show what configured the SDK and where the group was registered. Check `owner`, `stableGroup`, `assignmentGeneration`, and `assignmentRefreshPending` before comparing results on different requests.
    
-   `allowedGroups` and `showFroomleContentFor` describe the effective defaults. `registeredListShowSets` shows the selected policy per logical list. `recentResolutions` links a list and `requestId` to its policy, group, surface, and resolved `experience`. Match the request and current generation rather than assuming the last row is your placement.
    
-   `failures` lists bounded diagnostics for issues such as missing configuration or a contradictory response group. Inspect `code`, `field`, `surface`, `listName`, and `requestId` where available. `rejectedMutations` shows configuration attempts that did not take effect, including protected fields and late or conflicting changes. Neither array is an exhaustive history.
    
-   `controlIdentity` describes the original-card selectors and recent identity resolution in the DOM. Check `lastResults` for `explicit`, `selector`, `missing`, or `ambiguous`, and verify that the resolved item matches the CMS card. This is separate from group assignment.
    

<a id="sdk-diagnostic-delivery"></a>

### Requests and events

`diagnostics.traffic` reports the latest attempt for recommendations and for events separately: a request timestamp, an outcome, and an error summary when available. It is not a history of all in-flight requests. In Network, use the specific request for the card or interaction you are testing.

-   `lastRecommendationsOutcome` can be `in-flight`, `succeeded`, `failed`, or `superseded`, or `null` before a request. A successful response may still select original content or contain no items.
    
-   `lastEventsOutcome` can be `in-flight`, `acknowledged`, `browser-queued`, `failed`, `uncertain`, or `suppressed`, or `null` before a request. `acknowledged` means the SDK accepted the HTTP/API response. `browser-queued` means the browser accepted a beacon without confirming receipt. `uncertain` means the SDK could not establish delivery. `suppressed` means current tracking no longer permitted the attempt; an action blocked before dispatch need not create a traffic entry.
    

Use [`currentPageTracking`](https://docs.froomle.com/froomle-doc-main/v2/js_lib/diagnostics.html#current-page-tracking-diagnostics) for page-event ownership and consent, and [`trackingLifecycle`](https://docs.froomle.com/froomle-doc-main/v2/js_lib/diagnostics.html#tracking-lifecycle-diagnostics) for current automatic placements and shared delivery counters. The counters include other event types, not just recommendation impressions and clicks.

<a id="_other_diagnostic_signals"></a>

### Other diagnostic signals

-   `diagnostics.autoExclusions.globalConfig` is the live default; `effectiveConfig` and `lastCollectedCount` describe the latest selector collection. `lastSentExclusions` and its `origins` describe the last dispatched recommendation POST, not that collection. See [Verify what was sent](https://docs.froomle.com/froomle-doc-main/v2/js_lib/exclusions.html#verify-exclusions) for comparing these with the request.
    
-   `diagnostics.emailCampaignAttribution` describes the most recent URL or helper invocation, not the most recent completion. Check `status`, `blockedReason`, and `validationErrors`. `dispatched` can mean the browser accepted a beacon; it does not prove receipt. See [Email attribution diagnostics](https://docs.froomle.com/froomle-doc-main/v2/js_lib/email-campaign-attribution.html#EmailCampaignAttributionDiagnostics).
    
-   `diagnostics.smartSorting` summarizes the latest ranking resolution. See [Smart Sort diagnostics](https://docs.froomle.com/froomle-doc-main/v2/js_lib/smart-sorting-reranking.html#SmartSortDiagnostics).
    
-   `diagnostics.utmTracking` and `diagnostics.referrerTracking` distinguish current browser inputs from the fields last applied to an event. They are not evidence that the event reached the API.
    

When sharing a support example, include the SDK version, surface, placement name, relevant outcome or error code, and reproduction steps. Remove credentials, account and device IDs, and personal URL or payload data.

<a id="_runtime_aliases_and_live_script_attributes"></a>

### Runtime aliases and live script attributes

-   `window.FroomleFrontendSdkReady` remains available and aliases `window.FroomleFrontendSdkRuntime.init.ready`.
    
-   `window.FroomleFrontendSdkDiagnostics` remains available as a convenience alias to `window.FroomleFrontendSdkRuntime.integration`.
    
-   For new browser-side diagnostics and support tooling, prefer `window.FroomleFrontendSdkRuntime` and treat `diagnostics` as observational support state, not as a new control surface.
    

> **IMPORTANT:**
> 
> Script-tag/global DOM attribute contract:
> 
> -   Treat `window.FroomleFrontendSdkRuntime` as the canonical live runtime state.
>     
> -   In script-tag/global mode, the live SDK `<script>` element mirrors only:
>     
>     -   `data-froomle-consent` to reflect the effective startup level and later consent setter calls
>         
>     -   `data-froomle-user-id` after `setUserId(…​)`
>         
>     -   `data-froomle-channel` after `setChannel(…​)`
>         
>     -   `data-froomle-site-context` after `setSiteContext(…​)`
>         
>     -   `data-froomle-subscription-level` after `setSubscriptionLevel(…​)`
>         
>     -   `data-froomle-utm-tracking` after `setUtmTrackingEnabled(…​)`
>         
>     -   `data-froomle-referrer-tracking` after `setReferrerTrackingEnabled(…​)`
>         
>     
> -   This live mirroring applies both in `froomle:before-init` and later same-page setter calls.
>     
> -   Other `data-froomle-…​` attributes remain boot inputs unless explicitly documented otherwise.
>     
> -   In particular, `data-froomle-device-id` stays an explicit customer override input and is not backfilled from SDK-managed browser identity.
>     

<a id="current-page-tracking-diagnostics"></a>

## Current-page tracking diagnostics

Inspect this read-only state without initiating tracking:

```js
window.FroomleFrontendSdkRuntime.diagnostics.currentPageTracking
// Example after a late identified consent grant:
// {
//   automatic: true,
//   pending: false,
//   status: 'sent',
//   consent: 2,
//   lastConsentTransition: { from: 0, to: 2 }
// }
```

| Field | Meaning |
| --- | --- |
| `automatic` | An active DOM or React initializer owns automatic page tracking. `false` is expected in pure programmatic usage, before automatic readiness, or after the last React initializer unmounts. |
| `pending` | Automatic page work remains pending. This is not a general network-in-flight flag; a purely manual request can be in flight while this is `false`. |
| `status` | Latest tracker status: `idle`, `consent-required`, `missing-page-type`, `in-flight`, `sent`, `already-tracked`, `superseded`, or `failed`. `superseded` means the attempt is no longer current. |
| `consent` | Consent level observed by the page tracker, or `null` before it has observed state. Use `diagnostics.config.consent` for the effective SDK configuration. |
| `lastConsentTransition` | Latest actual change as `{ from, to }`, or `null`. Repeated same-level callbacks do not replace it. This is not a consent-history log. |

For a missing automatic page event, check the loaded SDK version, `automatic`, `consent`, `status`, and configured page context first. A `failed` send can be retried explicitly with `trackCurrentPage()` without rerunning recommendation initialization. Diagnostics describe client behavior, not confirmation that the analytics pipeline ingested the event.

<a id="tracking-lifecycle-diagnostics"></a>

## Recommendation tracking diagnostics

Inspect the automatic recommendation registry and shared event-delivery state without initiating tracking:

```js
window.FroomleFrontendSdkRuntime.diagnostics.trackingLifecycle
// {
//   consent: 2,
//   revision: 2,
//   period: 1,
//   lastConsentTransition: { from: 0, to: 2 },
//   registeredPlacements: 1,
//   status: 'observing',
//   pendingImpressions: 0,
//   placements: [{
//     item: 'article-123',
//     itemType: 'article',
//     request: 'request-456',
//     list: 'recommended_for_you',
//     period: 1,
//     status: 'acknowledged'
//   }],
//   placementsTruncated: false,
//   acknowledgedEvents: 2,
//   browserQueuedEvents: 0,
//   failedEvents: 0,
//   uncertainEvents: 0,
//   suppressedEvents: 0,
//   lastOutcome: 'acknowledged'
// }
```

| Field | Meaning |
| --- | --- |
| `consent` | Consent level currently used by the tracking lifecycle, or `null` before state is available. |
| `revision` | Current consent/identity revision. It changes when consent or effective tracking identity changes so stale work can be rejected. |
| `period` | Current consent period. It changes only on an actual consent-level change; repeating the same level keeps the period and impression deduplication. |
| `lastConsentTransition` | Latest actual consent change as `{ from, to }`, or `null`. This is not a consent-history log. |
| `registeredPlacements` | Number of currently registered automatic recommendation placements. Registrations can remain present while tracking is suspended at consent level `0`. |
| `status` | Registry state: `inactive`, `suspended`, `hidden`, `pending`, or `observing`. |
| `pendingImpressions` | Current impression candidates awaiting dispatch within active observation work. This is not a consent backlog or retry queue. |
| `placements` | At most 20 current placement summaries with item, item type, request, list, period, and state (`waiting`, `pending`, `in-flight`, `acknowledged`, `failed`, or `uncertain`). The entries contain no DOM references or identity history. |
| `placementsTruncated` | `true` when more placements are registered than the bounded `placements` sample contains. |
| `acknowledgedEvents`, `browserQueuedEvents`, `failedEvents`, `uncertainEvents`, `suppressedEvents` | Aggregate outcomes from the shared SDK event transport. These counters can include page, recommendation, and explicit helper events; do not treat them as recommendation-only totals or backend reporting confirmation. |
| `lastOutcome` | Most recent shared transport outcome: `acknowledged`, `browser-queued`, `failed`, `uncertain`, `suppressed`, or `null`. |

Use placement summaries to verify the item, list, and request registered for automatic tracking. `suspended` with registrations at consent level `0` is normal. When consent changes, the SDK can refresh mounted placements and register them against a new request. An old request is not proof of current attribution. Verify the Events API request and analytics ingestion separately.

<a id="Advanced"></a>

## Advanced Integration Notes

<a id="Comb"></a>

### Troubleshooting and Validation

Use the [SDK diagnostics checklist](https://docs.froomle.com/froomle-doc-main/v2/js_lib/diagnostics.html#sdk-diagnostic-checklist) to separate missing setup, a failed request, a content-policy decision, and a card that did not render or track.

If the expected list resolved but its card did not render, check the placement’s list name, the field mappings (such as `uri`, `images[0]`, and `title`), and the actual DOM. In consent tests, use a local HTTP server rather than `file://` so browser storage behaves normally.

When automatic events are missing or appear duplicated after a consent change:

-   Confirm that the CMP forwards every state, including withdrawal. It should not rerun `init()`, remount `FroomleSdkInit`, fetch recommendations, or send compensating events. The SDK manages mounted placements.
    
-   An explicit `trackCurrentPage()` call shares automatic page-event deduplication. Arbitrary `sendEvent(…​)` calls do not.
    
-   Distinguish duplicates from a deliberate new consent-period observation. `1 → 2` can create fresh identified page and recommendation events after anonymous delivery; `2 → 1` starts a fresh anonymous recommendation period but does not initiate another page event.
    

Stack-specific checks:

-   Plain HTML: confirm SDK script loads (no CSP/CORS blocking in console).
    
-   Module/import DOM: confirm that shared settings are in place and `init()` is called. If hot reload interferes with debugging, repeat the check on a clean page load.
    
-   JSP + TS: confirm the compiled JS bundle is generated and loaded by the JSP page.
    
-   JSP + TS: for server `503` responses, inspect application server logs and verify JSP/web configuration.
    
-   Programmatic: if UI renders but events are missing, verify SDK state is initialized (`setEnvironment`, `setPageVisit`, consent), and verify helper arguments or `sendEvent(…​)` extras include the required event fields for your flow.
    
-   React: verify `FroomleSdkInit` is mounted for page events. For recommendation events, check the hook’s list and filters and pass its original result to `FroomleReco`. With `asChild`, confirm props and the ref reach the card’s DOM root.
    

> **NOTE:**
> 
> For full end-to-end sample projects, see [frontend-sdk-examples](https://bitbucket.org/froomle/frontend-sdk-examples).

<a id="Perf"></a>

## Performance

The Froomle frontend SDK is designed to keep browser-side recommendation startup and rendering costs small compared with normal page, CMS, ad, and application work. Froomle continuously guards this with browser performance tests across Chromium, Firefox, and WebKit.

> **IMPORTANT:**
> 
> The numbers below are reference lab values, not an SLA and not a guarantee for customer pages. Real-world performance depends on the customer’s page, browser, device, network, CMS, consent layer, ads, and rendering code. Use these values as an SDK-side reference point, then validate the final site with your own Real User Monitoring, Core Web Vitals, and launch checks.

| SDK version | 0.4.0 |
| --- | --- |
| Browser harness | Playwright 1.59.1 |
| Runs | 5 repeated local runs |
| Hardware | Model Name: MacBook Pro<br>Model Identifier: MacBookPro18,3<br>Chip: Apple M1 Pro<br>Total Number of Cores: 10 (8 performance and 2 efficiency)<br>Memory: 32 GB |
| Method | Median of per-run medians across repeated local Playwright perf runs. Public values use the worst browser median across Chromium, Firefox, and WebKit. Recommendation responses are mocked by the test harness, so backend latency and customer network latency are excluded. |

| Integration path | SDK ready | Reco render after response | p95 frame gap | p95 timer lag | Memory cleanup |
| --- | --- | --- | --- | --- | --- |
| DOM / script tag startup (blocking) | 24 ms | n/a | n/a | 6 ms | n/a |
| DOM / script tag recommendation render (blocking) | 35 ms | <1 ms | 17 ms | 6 ms | pass |
| DOM / script tag startup (defer) | 32 ms | n/a | n/a | 6 ms | n/a |
| DOM / script tag recommendation render (defer) | 35 ms | <1 ms | 18 ms | 6 ms | pass |
| DOM / script tag startup (async) | 34 ms | n/a | n/a | 6 ms | n/a |
| DOM / script tag recommendation render (async) | 36 ms | <1 ms | 17 ms | 8 ms | pass |
| React SDK startup | 17 ms | n/a | n/a | 6 ms | n/a |
| React list recommendation render | 16 ms | 4 ms | 17 ms | 6 ms | pass |
| Programmatic recommendation request | n/a | <1 ms | 17 ms | 6 ms | pass |

Metric interpretation:

-   **SDK ready** measures time from scenario start until the SDK/runtime is ready for the scenario.
    
-   **Reco render after response** measures browser-side recommendation handling after the mocked recommendation response is available. It excludes backend and network latency.
    
-   **p95 frame gap** is a main-thread pacing signal. Lower values mean fewer visible long-frame risks during SDK work.
    
-   **p95 timer lag** is an event-loop delay signal. Lower values mean less sustained browser-main-thread pressure.
    
-   **Memory cleanup** is a cross-browser smoke check that SDK-owned recommendation DOM can be collected after teardown.
    
-   Deeper CPU and heap counters are kept as internal engineering diagnostics because browser engines expose them differently. The public table uses browser-neutral signals wherever possible.
    

Implementation guidance:

-   Prefer `defer`, `async`, or framework-native initialization over a blocking script tag unless the page has a specific reason to block parsing.
    
-   Do not block the primary page render on recommendation availability. Render the page shell first and let recommendation modules fill asynchronously.
    
-   Keep customer card rendering lightweight. The SDK can deliver and insert recommendations quickly, but expensive customer templates, images, ads, or layout work can dominate the final user-visible cost.
    
-   Keep compatible recommendation request shapes aligned so batching can avoid extra browser and backend round trips.
    
-   Provide original content in declarative placements if you want it to remain visible when the initial recommendation request fails. If your application renders the recommendations, define its loading, error, and empty states. See [Frontend SDK resilience](https://docs.froomle.com/froomle-doc-main/v2/guide/topics/resilience-and-fallbacks.html#FrontendSdkResilience).
    
-   Use `window.FroomleFrontendSdkRuntime.diagnostics` during integration QA to verify request split behavior, runtime mode, and recent recommendation or event errors.
