Classes
Adrop
The main SDK class. Works as a singleton.
Static Methods
| Method | Return Type | Description |
|---|
observe(config) | Adrop | Initialize SDK and start automatic DOM detection |
instance() | Adrop | Return existing instance |
Instance Methods
| Method | Return Type | Description |
|---|
renderAd(container, request?) | Promise<void> | Render ad |
requestAd(request) | Promise<AdropAdResponse> | Request ad data only (single) |
requestAds(request) | Promise<AdropAdsResponse> | Request multiple ads data only |
clear(container) | void | Remove ad |
setConfig(config) | void | Update configuration |
on(event, callback, filter?) | void | Register event listener |
off(event, callback) | void | Unregister event listener |
Instance Properties
| Property | Type | Description |
|---|
uid | string | User identifier (getter/setter) |
appKey | string | API authentication key (getter/setter) |
metrics | AdropMetrics | User property management |
AdropMetrics
User property management class.
Methods
| Method | Return Type | Description |
|---|
setUserProperties(props) | AdropMetrics | Set user properties (chainable) |
setAppProperties(props) | AdropMetrics | Set app properties (chainable) |
commit() | Promise<void> | Save properties to server |
properties() | Properties | Return currently set properties (user + app + device) |
clear() | void | Clear user and app properties (device properties are retained) |
Interfaces
AdropConfig
SDK initialization options.
interface AdropConfig {
appId: string; // App ID (required)
uid?: string; // User identifier
appKey?: string; // API authentication key
debug?: boolean; // Debug logging (default: false)
}
AdropAdRequest
Ad request parameters.
interface AdropAdRequest {
unit: string; // Unit ID (required)
uid?: string; // User identifier
contextId?: string; // Contextual targeting ID
trackMode?: 0 | 1; // 0: auto, 1: manual (native)
isEntireClick?: boolean; // Entire area click (native)
theme?: AdTheme; // Theme
useCustomClick?: boolean; // Custom click handling
}
AdropAdResponse
Ad response object (single ad).
interface AdropAdResponse {
code: AdropErrorCode; // Response code
msg: string; // Response message
result?: AdData; // Ad data (on success)
}
AdropAdsResponse
Ad response object (multiple ads).
interface AdropAdsResponse {
code: AdropErrorCode; // Response code
msg: string; // Response message
results?: AdData[]; // Ad data array (on success)
}
AdData
Ad data object.
interface AdData {
// Common
format: AdFormat; // Ad format
unit: string; // Unit ID
ad: string; // Ad HTML content
w: number; // Ad width
h: number; // Ad height
type?: string; // Ad type
target?: string; // Target URL open method
// Native ad fields
headline?: string; // Ad title
body?: string; // Ad description
callToAction?: string; // CTA button text
asset?: string; // Main image URL
destinationURL?: string; // Click destination URL
// Identifier fields
id?: string; // Ad ID
cpId?: string; // Campaign ID
creativeId?: string; // Creative ID
accountTag?: string; // Account-level tag
creativeTag?: string; // Creative-level tag
// Tracker fields (trackMode=1)
pixelTracker?: string; // Pixel tracker URL (1x1 image for impression)
imprTracker?: string; // Impression tracker URL
clickTracker?: string; // Click tracker URL
// Advertiser profile
profile?: {
displayLogo?: string; // Advertiser logo URL
displayName?: string; // Advertiser name
link?: string; // Advertiser profile link
};
// Extra text items
extra?: Record<string, string>;
}
AdropEventFilter
Event filter options.
interface AdropEventFilter {
unit?: string; // Filter specific unit only
}
Constants
Adrop.Events
Event constants. Access via Adrop.Events.
| Constant | Value | Description |
|---|
AD_RECEIVED | 'adReceived' | Ad received successfully |
AD_NO_FILL | 'adNoFill' | No direct ads |
AD_IMPRESSION | 'adImpression' | Ad impression |
AD_CLICKED | 'adClicked' | Ad click |
AD_FAILED | 'adFailed' | Ad request failed |
AD_BACKFILL_NO_FILL | 'adBackfillNoFill' | No backfill ads |
Adrop.ErrorCode
Error codes. Access via Adrop.ErrorCode.
| Constant | Value | Description |
|---|
OK | 0 | Success |
ERROR_CODE_INVALID_UNIT | 4000 | Invalid unit ID |
ERROR_CODE_AD_INACTIVE | 4001 | No active campaigns |
ERROR_CODE_AD_NO_FILL | 4002 | No matching ads |
ERROR_CODE_INVALID_PARAMS | 4003 | Invalid parameters |
Types
Ad format type.
type AdFormat = 'banner' | 'nativeAd' | 'backfill';
AdTheme
Theme type.
type AdTheme = 'light' | 'dark';
Event Callbacks
Callback signatures for each event.
// Ad received, impression, click
type AdReceivedCallback = (unit: string, adData: AdData) => void;
type AdImpressionCallback = (unit: string, adData: AdData) => void;
type AdClickedCallback = (unit: string, adData: AdData) => void;
// No ad, failed, backfill no fill
type AdNoFillCallback = (unit: string) => void;
type AdFailedCallback = (unit: string) => void;
type AdBackfillNoFillCallback = (unit: string) => void;
All event callbacks receive unit as the first argument. Events AD_RECEIVED, AD_IMPRESSION, and AD_CLICKED also receive adData as the second argument.