title: HostContextData
Interface: HostContextData
Data object accepted by HostContext.set.
- Static fields — last write wins.
providers— merged per-name; passnullto remove.userIds— merged per-name; passnullto remove.
interface HostContextData { appBundleId?: string; appName?: string; appStoreId?: string; appStoreUrl?: string; appVersion?: string; b2bContext?: string; deviceId?: { id: string; name: DeviceIdName | "aaid" | "afai" | "asia" | "asid" | "tifa" | "vaid" | "idfa" | "idfv" | "lgudid" | "msai" | "oaid" | "psnai" | "rida" | "vida" | "waid" }; presentationalContext?: "curated-list" | "discovery-page"; providers?: { [providerName: string]: (context: { consent?: Consent; environment?: string }) => MediaProviderContext | Promise<MediaProviderContext> | null }; userIds?: HostContextUserIds;}
Properties
appBundleId?
optionalappBundleId:string
Bundle id — required for iOS apps.
appName?
optionalappName:string
Name of the app or website project.
appStoreId?
optionalappStoreId:string
App store id — required for apps. IAB Tech Lab App Identification Guidelines
appStoreUrl?
optionalappStoreUrl:string
App store URL — required for apps. IAB Tech Lab App Identification Guidelines
appVersion?
optionalappVersion:string
Deployed version of the app or website.
b2bContext?
optionalb2bContext:string
Business-to-business context identifier.
deviceId?
optionaldeviceId:object
Device id — required for app environments. Use a ppid user id when no device id is available.
id
id:
string
name
name:
DeviceIdName|"aaid"|"afai"|"asia"|"asid"|"tifa"|"vaid"|"idfa"|"idfv"|"lgudid"|"msai"|"oaid"|"psnai"|"rida"|"vida"|"waid"
presentationalContext?
optionalpresentationalContext:"curated-list"|"discovery-page"
Presentational context of the integration. Omit when not applicable.
providers?
optionalproviders:object
Media-provider resolvers keyed by provider name. Merged per-name; pass null to remove.
Index Signature
[providerName: string]: (context) => MediaProviderContext | Promise<MediaProviderContext> | null
Example
hostContext.set({
providers: { myProvider: async () => ({ token: await myAuth.getFreshToken() }) },
});userIds?
optionaluserIds:HostContextUserIds
User-id resolvers keyed by HostContextUserIdKey. Merged per-name; pass null to remove.
Each entry may be a static value or a sync/async resolver that receives { consent, environment }.
Resolvers are invoked fresh each time the player needs user IDs, so they always reflect the
current consent state. Return null or undefined if the value isn’t available yet; call
hostContext.set() again once it is — because entries are merged per-name, the replacement
is picked up on the next resolution.
Example
hostContext.set({
userIds: {
ppid: { id: 'abc-…' }, // static
netId: () => ({ id: window.netId }), // sync resolver
liverampId: async ({ consent }) => { // async, consent-aware
if (!consent?.vendorConsents[97]) return null;
return { id: await ats.getEnvelope() };
},
},
});
// Once an async SDK resolves, re-register as a static value so the next
// resolution picks it up immediately instead of calling the resolver again.
ats.retrieveEnvelope().then((envelope) => {
if (envelope) hostContext.set({ userIds: { liverampId: { id: envelope } } });
});