1/** 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/** 18 * Returns the bid passed in the user_bidding_signals, if empty then generates 19 * a bid of 10 for the shoes CA or 20 * a bid of 15 for app_install CA or 21 * a bid of 5 otherwise 22 */ 23 function generateBid(custom_audience, auction_signals, per_buyer_signals, 24 trusted_bidding_signals, contextual_signals) { 25 forDebuggingOnly.reportAdAuctionWin('<buyer-win-debug-reporting-uri>' 26 + "?ca_name=" + custom_audience.name 27 + "&wb=${winningBid}&madeWb=${madeWinningBid}" 28 + "&hob=${highestScoringOtherBid}&madeHob=${madeHighestScoringOtherBid}"); 29 forDebuggingOnly.reportAdAuctionLoss('<buyer-loss-debug-reporting-uri>' 30 + "?ca_name=" + custom_audience.name 31 + "&wb=${winningBid}&madeWb=${madeWinningBid}" 32 + "&hob=${highestScoringOtherBid}&madeHob=${madeHighestScoringOtherBid}" 33 + "&rejectReason=${rejectReason}"); 34 var bid = 5; 35 if (custom_audience.name === "shoes") { 36 bid = 10; 37 } 38 return { 39 'status': 0, 40 'ad': custom_audience.ads[0], 41 'bid': bid, 42 'render': custom_audience.ads[0].render_uri 43 }; 44} 45 46function reportWin(ad_selection_signals, per_buyer_signals, signals_for_buyer, 47 contextual_signals, custom_audience_signals) { 48 let reporting_address = '<buyer-reporting-uri>'; 49 return {'status': 0, 'results': {'reporting_uri': 50 reporting_address + '?ca=' + custom_audience_signals.name} }; 51} 52