From 123d8aa4c98efefd913b58e16b4ffbc162b11a4f Mon Sep 17 00:00:00 2001 From: mp4symitri Date: Mon, 9 Sep 2024 22:05:46 +0530 Subject: [PATCH] Symetri RTD module: OnBidResponse method added (#12214) * OnBidResponse listener added to add pixel for deals matching to the user deals stored in local storage * Adding support for simpleId, compositeId & hashedId * Solved Linter errors. Made some changes to reduce integration errors * Rolled back the default case as it was generating test errors. * Testing onBidResponseEvent * Pass pixel URL as module config parameter * Added extra attributes to Pixel URL. Documentation Updated. * Bidder Name & Code both added * Fixed Tests Fixed Linter Errors Updated Example --------- Co-authored-by: Manan Co-authored-by: Jeff Palladino <1226357+jpalladino84@users.noreply.github.com> --- .../gpt/symitridap_segments_example.html | 3 +- modules/symitriDapRtdProvider.js | 30 +++++++++++++++++-- modules/symitriDapRtdProvider.md | 15 ++++++++-- .../modules/symitriDapRtdProvider_spec.js | 16 +++++++++- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/integrationExamples/gpt/symitridap_segments_example.html b/integrationExamples/gpt/symitridap_segments_example.html index 8ec7958dd0d..1f5a654cfdb 100644 --- a/integrationExamples/gpt/symitridap_segments_example.html +++ b/integrationExamples/gpt/symitridap_segments_example.html @@ -78,7 +78,8 @@ apiVersion: "x1", domain: "prebid.org", identityValue: "test@invalid.com", - identityType: "hid" + identityType: "simpleid", + pixelUrl: 'https://www.test.com/pixel' } } ] diff --git a/modules/symitriDapRtdProvider.js b/modules/symitriDapRtdProvider.js index aed583cbdfa..aeb42226470 100644 --- a/modules/symitriDapRtdProvider.js +++ b/modules/symitriDapRtdProvider.js @@ -151,13 +151,30 @@ export function createRtdProvider(moduleName, moduleCode, headerPrefix) { return true; } + function onBidResponse(bidResponse, config, userConsent) { + if (bidResponse.dealId && typeof (bidResponse.dealId) != typeof (undefined)) { + let membership = dapUtils.dapGetMembershipFromLocalStorage(); // Get Membership details from Local Storage + let deals = membership.deals; // Get list of Deals the user is mapped to + deals.forEach((deal) => { + deal = JSON.parse(deal); + if (bidResponse.dealId == deal.id) { // Check if the bid response deal Id matches to the deals mapped to the user + let token = dapUtils.dapGetTokenFromLocalStorage(); + let url = config.params.pixelUrl + '?token=' + token + '&ad_id=' + bidResponse.adId + '&bidder=' + bidResponse.bidder + '&bidder_code=' + bidResponse.bidderCode + '&cpm=' + bidResponse.cpm + '&creative_id=' + bidResponse.creativeId + '&deal_id=' + bidResponse.dealId + '&media_type=' + bidResponse.mediaType + '&response_timestamp=' + bidResponse.responseTimestamp; + bidResponse.ad = `${bidResponse.ad}