IntimateMerger Analytics Adapter : initial release#21
Conversation
|
Tread carefully! This PR adds 1 linter error (possibly disabled through directives):
|
|
Tread carefully! This PR adds 1 linter error (possibly disabled through directives):
|
|
Tread carefully! This PR adds 1 linter error (possibly disabled through directives):
|
fecker
left a comment
There was a problem hiding this comment.
ちともろもろ確認したいのと、意識合わせしたいです。
各社のAnalytics Adaptor は、bid の分析をもろもろしているのですが、
IMでは不要なので、そのあたりは調整が必要かなと。
今の実装ならキャッシュは不要な気がしつつ、バッファリング送信機能をつけるなら必要になるかなと思っています。
- AUCTION_INIT
- cache の初期化(auctionId の管理用)
- Consent データの初期化 (auctionId に紐づけて管理)
- pvデータのみを送信(ちょっと悩み中。データとして使わないなら、ぶっちゃけまとめて送ってもいいかも? 調整中)
- AUCTION_END
- setTimeout で遅延実行(800 ms くらい?)
- cache[auctionId] に入ってるものを送る
- cache[auctionId] で、データ送信フラグ を管理
- setTimeout で遅延実行(3分後くらい?)
- cache[auctionId] を削除する
− SPA でたまらないようにする
- cache[auctionId] を削除する
- setTimeout で遅延実行(800 ms くらい?)
- BID_WON
- cache[auctionId] に 情報を蓄積する
- データ送信済だったら(フラグがたってたら)全データを再送する
実装イメージ
case EVENTS.AUCTION_END:
setTimeout(() => {
analyticsAdapter.sendEvents(args.auctionId);
}, BID_WON_WAIT); // 800ms ?
break;
こんなことを書いてる Adaptor がいるので、バッファリングいけるんじゃないかと思ってます。
case EVENTS.BID_WON:
const auction = cache.auctions[args.auctionId];
if (!auction) return;
// transactionId 単位で、cache するか
// 配列に push した方が楽かもしれない
// 再送を考えて、Timestamp も入れてもいいかも
if (auction.sendStatus & REQUEST_SENT) { // すでに送信済だったら
analyticsAdapter.sendEvents(args.auctionId); // 再送する
}
みたいな感じでいけたりしないかなぁと思ってきました。
許諾のデータは、
libraries/intentIqUtils/getCmpData.js を参考にして
gdpr と usp (ccpa) だけとっておくと幸せになれるかなとおもってきました。
import { allConsent } from '../../src/consentHandler.js';
/**
* Retrieves consent data from the Consent Management Platform (CMP).
* @return {Object} An object containing the following fields:
* - `gdprString` (string): GDPR consent string if available.
* - `uspString` (string): USP consent string if available.
* - `gppString` (string): GPP consent string if available.
*/
export function getCmpData() {
const consentData = allConsent.getConsentData();
return {
gdprApplies: consentData?.gdpr?.gdprApplies || false,
gdprString: typeof consentData?.gdpr?.consentString === 'string' ? consentData.gdpr.consentString : null,
uspString: typeof consentData?.usp === 'string' ? consentData.usp : null,
gppString: typeof consentData?.gpp?.gppString === 'string' ? consentData.gpp.gppString : null,
};
}
|
|
Tread carefully! This PR adds 2 linter errors (possibly disabled through directives):
|
|
Tread carefully! This PR adds 2 linter errors (possibly disabled through directives):
|
|
Tread carefully! This PR adds 2 linter errors (possibly disabled through directives):
|
| gdprApplies: gdprConsent.gdprApplies, | ||
| gdpr: gdprConsent.consentString, |
There was a problem hiding this comment.
gdpr の consent はいらないかなと思ってきました・・・・(対応するつもりがほぼない)
他の adapter でやってたのですが gdpr に true / false (gdprApplies) を渡して、あげるのが幸せになれるかと思いました。
| return { | ||
| gdprApplies: gdprConsent.gdprApplies, | ||
| gdpr: gdprConsent.consentString, | ||
| usp: uspConsent |
There was a problem hiding this comment.
coppa も念の為取得しておいて頂けるとうれしいです。
coppa = Number(coppaDataHandler.getCoppa());
| const gdprConsent = request.gdprConsent || {}; | ||
| const uspConsent = request.uspConsent; | ||
|
|
||
| return { |
There was a problem hiding this comment.
アメリカ・カナダがそこそこ入っていたので、
ggp: gppDataHandler.getConsentData().applicableSections; (Number が入ります)
ggpString: gppDataHandler.getConsentData().gppString;
で取得をお願いします。
(真面目にやるとここを見るのが良さげ?)
|
|
||
| case EVENTS.AUCTION_END: | ||
| logMessage('IM Analytics: AUCTION_END', args); | ||
| this.scheduleWonBidsSend(args.auctionId); |
There was a problem hiding this comment.
細かいのですが、handleActionEnd() の方が良いのかなと思ったり。
で、その中で 2つの処理を schedule するのが良いのでは?って思いました。
別のAdapterでやってたのですが、
(あまりユースケースはないかもですが、)Cache の肥大化対策をしてるものがいました。
一定時間後(5秒 〜 10秒後)に、cache[auctions] をクリアする処理があってもいいかもす。
| * @param {Object} auctionArgs - Auction arguments | ||
| * @param {Object} consentData - Consent data object | ||
| */ | ||
| handleAucInitData(auctionArgs, consentData) { |
There was a problem hiding this comment.
consentData って、auction の中でキャッシュされてるので、それを使いまわした方が良いのではと思ったのですが、どうすか?
handleAuction で、引数があわないのが気持ちわるい感じがします。
| */ | ||
| transformAucInitData(auctionArgs) { | ||
| return { | ||
| timestamp: auctionArgs.timestamp, |
There was a problem hiding this comment.
細かいですが、ボリュームが増えるので、short にした方がエコかもです。
(僕なら ts とかにしちゃいます w)
| pageUrl: window.location.href, | ||
| referrer: document.referrer || '', |
There was a problem hiding this comment.
細かいですが、url とか短くしちゃって良いかなと。少しでもネットワークコストを下げる的な。
(まぁ、payload なので圧縮かかるかなと思いつつ)
| return; | ||
| } | ||
|
|
||
| const consentData = auction.consentData || getConsentData(null); |
| */ | ||
| sendWonBidsData(auctionId) { | ||
| const auction = cache.auctions[auctionId]; | ||
| if (!auction || !auction.wonBids || auction.wonBids.length === 0 || (auction.sendStatus & WON_SENT)) { |
There was a problem hiding this comment.
全部一緒に送ることを考えると最後の条件はいらないかなと。
(送れてきても、全部一緒に送ることで集計が楽になるはず)の
| }); | ||
|
|
||
| // Clear cached bids after sending to prevent duplicates | ||
| auction.sendStatus |= WON_SENT; |
There was a problem hiding this comment.
細かいですが、sendToApi する前に、セットした方が良かったりしますか?
(時間がかかったたときに微妙なので)の
| function getConsentData(bidderRequests) { | ||
| if (!bidderRequests || !bidderRequests[0]) { | ||
| return EMPTY_CONSENT_DATA; | ||
| } | ||
|
|
There was a problem hiding this comment.
bidderRequests から取るより、Adapter から取得した方が分かりやすいかなと思ったのですが、どっちがいいっすかね・・?(0番目から取るよりという意味で。他のAnalytics Adapter はどうですか?)
| timestamp, | ||
| wonBids: auction.wonBids |
There was a problem hiding this comment.
少しでも小さくと・・・ ts, bids あたりで良いかもです。
|
|
||
| const DEFAULT_BID_WON_TIMEOUT = 800; // 0.8 second for initial batch | ||
| const DEFAULT_CID = 5126; | ||
| const API_BASE_URL = 'https://b6.im-apps.net/bids'; |
There was a problem hiding this comment.
(完全に趣味ですが)Prebid にあわせて、bid にしませんか?
Type of change
Bugfix
Feature
New bidder adapter
Updated bidder adapter
Code style update (formatting, local variables)
Refactoring (no functional changes, no api changes)
Build related changes
CI related changes
Does this change affect user-facing APIs or examples documented on http://prebid.org?
Other
Description of change
Other information