Trek SDK 總覽
四個平台的現況,以及為 AI 時代設計的下一代 SDK。
平台
| 平台 | 安裝 | 識別碼 | 文件 |
|---|---|---|---|
| Web | static.aottercdn.com/trek/sdk/3.5.8/sdk.js | clientId · placeUid | Web |
| iOS 15+ | SPM AotterTrekSDK-iOS 5.x · CocoaPods | clientId · placeID | iOS |
| Android | Gradle com.aotter.android:trek-ads | clientId · placeUid | Android |
| Flutter | pub trek_gma_mediation(透過 Google Mobile Ads 中介) | AdMob 廣告單元+自訂事件 | Flutter |
下一代 SDK(設計提案)
設計提案以下是提供給 SDK 團隊的介面設計(issue 07),尚未發佈。目前請使用各平台的現行 SDK。
目標是三件事:AI 只要寫三行就能正確安裝、前端永遠碰不到 secret、同一份設定就能接 Trek、中介與第三方需求方。
// npm i @aotter/trek (proposal)
import { Trek } from '@aotter/trek';
Trek.init({ clientId: import.meta.env.VITE_TREK_CLIENT_ID }); // switches to test keys on localhost / previews
// <trek-ad place="article_inline"></trek-ad> // Web Component for React, Vue, Svelte…
設計原則
- 一個名稱、一種寫法:統一使用
clientId/placeUid,也接受版位名稱;橫幅不再借用suprAd指令。 - 預設安全:前端只接受公開 ID;clientId 由伺服器綁定網域或 App;開發環境自動使用測試金鑰。
- 預設不傷體驗:自動預留高度避免版面跳動、延遲載入、SPA 換頁自動清理。
- 可被機器驗證:
Trek.diagnose()回傳與verify_integration相同的四階段狀態。 - 同意與隱私:
Trek.consent({ tcf, gpp });Trek.setUser()只接受雜湊值。 - 可插拔的需求與驗證:
Trek.use(adapter)接第三方聯播網、header bidding 與驗證服務,見第三方整合。
Trek.use(prebid({ timeout: 800 })); // header bidding (bidder: aseal)
Trek.use(omid()); // IAB Open Measurement (OMSDK_Aotternet ships in the iOS SDK)
Trek.use(uid2({ consent: true })); // identity
const status = await Trek.diagnose(); // { configured, testRequestSeen, productionEligible, productionImpressionSeen }