Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion libraries/nexx360Utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { StorageManager } from '../../src/storageManager.js';
import { BidRequest, ORTBImp, ORTBRequest, ORTBResponse } from '../../src/prebid.public.js';
import { AdapterResponse, ServerResponse } from '../../src/adapters/bidderFactory.js';
import { Nexx360ServerAuction } from './types.js';

const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';

Expand Down Expand Up @@ -79,8 +80,8 @@
width: number,
height: number
) => (bidResponse: VideoBidResponse) => {
bidResponse.renderer.push(() => {
(window as any).ANOutstreamVideo.renderAd({

Check warning on line 84 in libraries/nexx360Utils/index.ts

View workflow job for this annotation

GitHub Actions / Coverage

83-84 lines are not covered with tests
sizes: [width, height],
targetId: divId,
adResponse: bidResponse.vastXml,
Expand Down Expand Up @@ -108,8 +109,8 @@
{ requestId, vastXml, divId, width, height }: CreateRenderPayload
): Renderer | undefined => {
if (!vastXml) {
logInfo('No VAST in bidResponse');
return;

Check warning on line 113 in libraries/nexx360Utils/index.ts

View workflow job for this annotation

GitHub Actions / Coverage

112-113 lines are not covered with tests
}
const installPayload = {
id: requestId,
Expand Down Expand Up @@ -201,7 +202,7 @@
response.renderer = renderer;
response.divId = bid.ext.divId;
} else {
logInfo('Could not create renderer for outstream bid');

Check warning on line 205 in libraries/nexx360Utils/index.ts

View workflow job for this annotation

GitHub Actions / Coverage

205 line is not covered with tests
}
};

Expand All @@ -213,10 +214,38 @@
return response as BidResponse;
}

// --- Server auction data extraction ---

let lastServerAuctionData: Nexx360ServerAuction | null = null;

function extractServerAuction(responseBody: any): void {
const serverAuction = deepAccess(responseBody, 'ext.serverAuction');
if (serverAuction && typeof serverAuction === 'object' && serverAuction.auctionId) {
lastServerAuctionData = serverAuction as Nexx360ServerAuction;
Comment on lines +223 to +224

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope server auction data to the producing response

When a Nexx360 response includes ext.serverAuction but produces no accepted bid response, for example an empty seatbid response, this stores the server auction in a single module-level slot and no BID_RESPONSE path runs to clear it. The next unrelated Nexx360 bid response can then emit that stale serverAuction under the wrong client auction, so this data needs to be keyed to the response/request or cleared when no bid responses are produced.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 59f6343. interpretResponse now clears any stored server-auction data when a response produces no bid responses (empty seatbid), and only stores ext.serverAuction when the response actually yields bids that a bidResponse will consume. A stale value can therefore no longer leak into a later, unrelated auction. Added tests for both the store-then-consume and clear-on-no-bids paths.

}
}

export function getLastServerAuctionData(): Nexx360ServerAuction | null {
return lastServerAuctionData;
}

export function clearLastServerAuctionData(): void {
lastServerAuctionData = null;
}

export const interpretResponse = (serverResponse: ServerResponse): AdapterResponse => {
if (!serverResponse.body) return [];
const respBody = serverResponse.body as ORTBResponse;
if (!respBody.seatbid || respBody.seatbid.length === 0) return [];

if (!respBody.seatbid || respBody.seatbid.length === 0) {
// No bid responses will be produced, so no analytics `bidResponse` will
// consume server-auction data. Clear it rather than let a stale value leak
// into a later, unrelated auction.
clearLastServerAuctionData();
return [];
}

extractServerAuction(respBody);

const responses: BidResponse[] = [];
for (let i = 0; i < respBody.seatbid.length; i++) {
Expand Down
48 changes: 48 additions & 0 deletions libraries/nexx360Utils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/** Per-SSP bid attempt for a specific impression */
export interface Nexx360SSPBid {
ssp: string;
status: 'bid' | 'noBid' | 'timeout' | 'error';
responseTimeMs?: number;
cpm?: number;
currency?: string;
size?: string;
dealId?: string;
bidId?: string;
error?: string;
}

/** Auction summary for a single impression */
export interface Nexx360ImpressionAuction {
impId: string;
adUnitCode: string;
bids: Nexx360SSPBid[];
totalSsps: number;
bidsReceived: number;
timeouts: number;
errors: number;
auctionTimeMs: number;
winner?: {
ssp: string;
cpm: number;
currency: string;
};
}

/** Server-side auction data attached to Nexx360 OpenRTB response ext */
export interface Nexx360ServerAuction {
auctionId: string;
timestamp: number;
impressions: Nexx360ImpressionAuction[];
totalImpressions: number;
totalSspsCalled: number;
totalBidsReceived: number;
totalTimeouts: number;
totalErrors: number;
auctionTimeMs: number;
}

/** Top-level Nexx360 response extension */
export interface Nexx360ResponseExt {
cookies?: unknown[];
serverAuction?: Nexx360ServerAuction;
}
5 changes: 5 additions & 0 deletions metadata/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -6532,6 +6532,11 @@
"componentName": "mobkoi",
"gvlid": null
},
{
"componentType": "analytics",
"componentName": "nexx360",
"gvlid": null
},
{
"componentType": "analytics",
"componentName": "nobid",
Expand Down
12 changes: 12 additions & 0 deletions metadata/modules/nexx360AnalyticsAdapter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"NOTICE": "do not edit - this file is autogenerated by `gulp update-metadata`",
"disclosures": {},
"purposes": {},
"components": [
{
"componentType": "analytics",
"componentName": "nexx360",
"gvlid": null
}
]
}
80 changes: 80 additions & 0 deletions modules/nexx360AnalyticsAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Overview

Module Name: Nexx360 Analytics Adapter
Module Type: Analytics Adapter
Maintainer: tech@nexx360.io

# Description

The Nexx360 Analytics Adapter collects Prebid.js auction data and sends it to the Nexx360 analytics platform for monitoring and reporting. It tracks auction lifecycle events, bid requests, bid responses, wins, timeouts, and ad render events.

# Registration

The Nexx360 Analytics adapter requires a publisher ID from Nexx360. Please contact Nexx360 to obtain your publisher credentials.

```javascript
pbjs.enableAnalytics({
provider: 'nexx360',
options: {
publisherId: 'your-publisher-id',
endpoint: 'https://monitoring.nexx360.io'
}
});
```

Sampling is applied server-side (by the Nexx360 collector), so the adapter sends
all events and exposes no sampling option.

# Analytics Options

{: .table .table-bordered .table-striped }
| Name | Scope | Description | Example | Type |
|------|-------|-------------|---------|------|
| publisherId | required | Your Nexx360 publisher identifier | `"pub-12345"` | string |
| endpoint | optional | Analytics endpoint URL (defaults to `https://monitoring.nexx360.io`) | `"https://monitoring.nexx360.io"` | string |
| abTestLabel | optional | A/B test variant label, attached to every event for slicing analytics by test arm | `"variantA"` | string |

# Events Tracked

The adapter tracks the following Prebid.js events:

- **auctionInit** - When an auction starts
- **bidRequested** - When bid requests are sent to bidders
- **bidResponse** - When bid responses are received
- **bidWon** - When a bid wins the auction
- **bidTimeout** - When bidders timeout
- **adRenderSucceeded** - When an ad renders successfully
- **adRenderFailed** - When an ad fails to render

# Example Configuration

## Basic Setup

```javascript
pbjs.enableAnalytics({
provider: 'nexx360',
options: {
publisherId: 'your-publisher-id'
}
});
```

## Production Setup

```javascript
pbjs.enableAnalytics({
provider: 'nexx360',
options: {
publisherId: 'your-publisher-id',
endpoint: 'https://monitoring.nexx360.io'
}
});
```

# Build

To include this analytics adapter in your Prebid.js build:

```bash
gulp build --modules=nexx360AnalyticsAdapter,...
```
Loading
Loading