MCPcopy Create free account
hub / github.com/ampproject/amphtml / getConsentDataToForward

Function getConsentDataToForward

src/consent.js:90–111  ·  view source on GitHub ↗
(element, opt_policyId)

Source from the content-addressed store, hash-verified

88 * - consentPolicySharedData
89 */
90export function getConsentDataToForward(element, opt_policyId) {
91 return Services.consentPolicyServiceForDocOrNull(element).then((policy) => {
92 const gettersOrNull = {
93 'consentMetadata': policy && policy.getConsentMetadataInfo,
94 'consentString': policy && policy.getConsentStringInfo,
95 'consentPolicyState': policy && policy.whenPolicyResolved,
96 'consentPolicySharedData': policy && policy.getMergedSharedData,
97 };
98 if (!policy) {
99 return gettersOrNull;
100 }
101 return /** @type {!JsonObject} */ (
102 Promise.all(
103 Object.keys(gettersOrNull).map((key) =>
104 gettersOrNull[key]
105 .call(policy, opt_policyId || 'default')
106 .then((value) => ({[key]: value}))
107 )
108 ).then((objs) => Object.assign.apply({}, objs))
109 );
110 });
111}
112
113/**
114 * Determine if an element needs to be blocked by consent based on meta tags.

Callers 4

renderViaIframeGet_Method · 0.90
sendConsentData_Method · 0.90
postConsentData_Method · 0.90
sendConsentData_Method · 0.90

Calls 2

applyMethod · 0.80
thenMethod · 0.45

Tested by

no test coverage detected