Skip to content

Commit

Permalink
Merge branch 'main' into workflow/auto-update-deps-195-20231213-090113
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsimantov authored Dec 20, 2023
2 parents e1073f4 + b136d04 commit ec3b3fa
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
8 changes: 8 additions & 0 deletions analytics/integration_test/src/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,20 @@ TEST_F(FirebaseAnalyticsTest, TestSetConsent) {
{firebase::analytics::kConsentTypeAnalyticsStorage,
firebase::analytics::kConsentStatusGranted},
{firebase::analytics::kConsentTypeAdStorage,
firebase::analytics::kConsentStatusGranted},
{firebase::analytics::kConsentTypeAdUserData,
firebase::analytics::kConsentStatusGranted},
{firebase::analytics::kConsentTypeAdPersonalization,
firebase::analytics::kConsentStatusGranted}};
std::map<firebase::analytics::ConsentType, firebase::analytics::ConsentStatus>
consent_settings_deny = {
{firebase::analytics::kConsentTypeAnalyticsStorage,
firebase::analytics::kConsentStatusDenied},
{firebase::analytics::kConsentTypeAdStorage,
firebase::analytics::kConsentStatusDenied},
{firebase::analytics::kConsentTypeAdUserData,
firebase::analytics::kConsentStatusDenied},
{firebase::analytics::kConsentTypeAdPersonalization,
firebase::analytics::kConsentStatusDenied}};
std::map<firebase::analytics::ConsentType, firebase::analytics::ConsentStatus>
consent_settings_empty;
Expand Down
30 changes: 30 additions & 0 deletions analytics/src/analytics_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ static const ::firebase::App* g_app = nullptr;
"Lcom/google/firebase/analytics/FirebaseAnalytics$ConsentType;", \
util::kFieldTypeStatic), \
X(AdStorage, "AD_STORAGE", \
"Lcom/google/firebase/analytics/FirebaseAnalytics$ConsentType;", \
util::kFieldTypeStatic), \
X(AdUserData, "AD_USER_DATA", \
"Lcom/google/firebase/analytics/FirebaseAnalytics$ConsentType;", \
util::kFieldTypeStatic), \
X(AdPersonalization, "AD_PERSONALIZATION", \
"Lcom/google/firebase/analytics/FirebaseAnalytics$ConsentType;", \
util::kFieldTypeStatic)

Expand Down Expand Up @@ -223,6 +229,30 @@ void SetConsent(const std::map<ConsentType, ConsentStatus>& consent_settings) {
return;
}
break;
case kConsentTypeAdUserData:
consent_type =
env->GetStaticObjectField(analytics_consent_type::GetClass(),
analytics_consent_type::GetFieldId(
analytics_consent_type::kAdUserData));

if (util::LogException(env, kLogLevelError,
"Failed to get ConsentTypeAdUserData")) {
env->DeleteLocalRef(consent_map);
return;
}
break;
case kConsentTypeAdPersonalization:
consent_type = env->GetStaticObjectField(
analytics_consent_type::GetClass(),
analytics_consent_type::GetFieldId(
analytics_consent_type::kAdPersonalization));

if (util::LogException(env, kLogLevelError,
"Failed to get ConsentTypeAdPersonalization")) {
env->DeleteLocalRef(consent_map);
return;
}
break;
default:
LogError("Unknown ConsentType value: %d", it->first);
env->DeleteLocalRef(consent_map);
Expand Down
6 changes: 6 additions & 0 deletions analytics/src/analytics_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ void SetConsent(const std::map<ConsentType, ConsentStatus>& consent_settings) {
case kConsentTypeAnalyticsStorage:
consent_type = FIRConsentTypeAnalyticsStorage;
break;
case kConsentTypeAdUserData:
consent_type = FIRConsentTypeAdUserData;
break;
case kConsentTypeAdPersonalization:
consent_type = FIRConsentTypeAdPersonalization;
break;
default:
LogError("Unknown ConsentType value: %d", it->first);
return;
Expand Down
11 changes: 8 additions & 3 deletions analytics/src/include/firebase/analytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,14 @@ void SetAnalyticsCollectionEnabled(bool enabled);

/// @brief The type of consent to set.
///
/// Supported consent types are kConsentTypeAdStorage and
/// kConsentTypeAnalyticsStorage. Omitting a type retains its previous status.
enum ConsentType { kConsentTypeAdStorage = 0, kConsentTypeAnalyticsStorage };
/// Supported consent types are mapped to coresponding constants in the Android
/// and iOS SDKs. Omitting a type retains its previous status.
enum ConsentType {
kConsentTypeAdStorage = 0,
kConsentTypeAnalyticsStorage,
kConsentTypeAdUserData,
kConsentTypeAdPersonalization
};

/// @brief The status value of the consent type.
///
Expand Down
1 change: 1 addition & 0 deletions release_build_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ code.
level 33 and Gradle 6.7.1.
- General (Android): Update to Firebase Android BoM version 32.3.1.
- General (iOS): Update to Firebase Cocoapods version 10.17.0.
- Analytics: Updated the consent management API to include new consent signals.
- GMA (Android) Updated dependency to play-services-ads version 22.4.0.

### 11.6.0
Expand Down

0 comments on commit ec3b3fa

Please sign in to comment.