-/// Add Payment Info event. This event signifies that a user has submitted their payment information
-/// to your app.
+/// Add Payment Info event. This event signifies that a user has submitted their payment
+/// information. Note: If you supply the @c kFIRParameterValue parameter, you must also supply the
+/// @c kFIRParameterCurrency parameter so that revenue metrics can be computed accurately. Params:
+///
+///
+/// - @c kFIRParameterCoupon (NSString) (optional)
+/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterPaymentType (NSString) (optional)
+/// - @c kFIRParameterValue (double as NSNumber) (optional)
+///
static NSString *const kFIREventAddPaymentInfo NS_SWIFT_NAME(AnalyticsEventAddPaymentInfo) =
@"add_payment_info";
-/// E-Commerce Add To Cart event. This event signifies that an item was added to a cart for
-/// purchase. Add this event to a funnel with kFIREventEcommercePurchase to gauge the effectiveness
-/// of your checkout process. Note: If you supply the @c kFIRParameterValue parameter, you must
-/// also supply the @c kFIRParameterCurrency parameter so that revenue metrics can be computed
+/// E-Commerce Add To Cart event. This event signifies that an item(s) was added to a cart for
+/// purchase. Add this event to a funnel with @c kFIREventPurchase to gauge the effectiveness of
+/// your checkout process. Note: If you supply the @c kFIRParameterValue parameter, you must also
+/// supply the @c kFIRParameterCurrency parameter so that revenue metrics can be computed
/// accurately. Params:
///
///
-/// - @c kFIRParameterQuantity (signed 64-bit integer as NSNumber)
-/// - @c kFIRParameterItemID (NSString)
-/// - @c kFIRParameterItemName (NSString)
-/// - @c kFIRParameterItemCategory (NSString)
-/// - @c kFIRParameterItemLocationID (NSString) (optional)
-/// - @c kFIRParameterPrice (double as NSNumber) (optional)
/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
/// - @c kFIRParameterValue (double as NSNumber) (optional)
-/// - @c kFIRParameterOrigin (NSString) (optional)
-/// - @c kFIRParameterDestination (NSString) (optional)
-/// - @c kFIRParameterStartDate (NSString) (optional)
-/// - @c kFIRParameterEndDate (NSString) (optional)
///
static NSString *const kFIREventAddToCart NS_SWIFT_NAME(AnalyticsEventAddToCart) = @"add_to_cart";
-/// E-Commerce Add To Wishlist event. This event signifies that an item was added to a wishlist.
-/// Use this event to identify popular gift items in your app. Note: If you supply the
-/// @c kFIRParameterValue parameter, you must also supply the @c kFIRParameterCurrency
-/// parameter so that revenue metrics can be computed accurately. Params:
+/// E-Commerce Add To Wishlist event. This event signifies that an item was added to a wishlist. Use
+/// this event to identify popular gift items. Note: If you supply the @c kFIRParameterValue
+/// parameter, you must also supply the @c kFIRParameterCurrency parameter so that revenue metrics
+/// can be computed accurately. Params:
///
///
-/// - @c kFIRParameterQuantity (signed 64-bit integer as NSNumber)
-/// - @c kFIRParameterItemID (NSString)
-/// - @c kFIRParameterItemName (NSString)
-/// - @c kFIRParameterItemCategory (NSString)
-/// - @c kFIRParameterItemLocationID (NSString) (optional)
-/// - @c kFIRParameterPrice (double as NSNumber) (optional)
/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
/// - @c kFIRParameterValue (double as NSNumber) (optional)
///
static NSString *const kFIREventAddToWishlist NS_SWIFT_NAME(AnalyticsEventAddToWishlist) =
@@ -81,26 +76,16 @@ static NSString *const kFIREventAddToWishlist NS_SWIFT_NAME(AnalyticsEventAddToW
static NSString *const kFIREventAppOpen NS_SWIFT_NAME(AnalyticsEventAppOpen) = @"app_open";
/// E-Commerce Begin Checkout event. This event signifies that a user has begun the process of
-/// checking out. Add this event to a funnel with your kFIREventEcommercePurchase event to gauge the
-/// effectiveness of your checkout process. Note: If you supply the @c kFIRParameterValue
-/// parameter, you must also supply the @c kFIRParameterCurrency parameter so that revenue
-/// metrics can be computed accurately. Params:
+/// checking out. Add this event to a funnel with your @c kFIREventPurchase event to gauge the
+/// effectiveness of your checkout process. Note: If you supply the @c kFIRParameterValue parameter,
+/// you must also supply the @c kFIRParameterCurrency parameter so that revenue metrics can be
+/// computed accurately. Params:
///
///
-/// - @c kFIRParameterValue (double as NSNumber) (optional)
+/// - @c kFIRParameterCoupon (NSString) (optional)
/// - @c kFIRParameterCurrency (NSString) (optional)
-/// - @c kFIRParameterTransactionID (NSString) (optional)
-/// - @c kFIRParameterStartDate (NSString) (optional)
-/// - @c kFIRParameterEndDate (NSString) (optional)
-/// - @c kFIRParameterNumberOfNights (signed 64-bit integer as NSNumber) (optional) for
-/// hotel bookings
-/// - @c kFIRParameterNumberOfRooms (signed 64-bit integer as NSNumber) (optional) for
-/// hotel bookings
-/// - @c kFIRParameterNumberOfPassengers (signed 64-bit integer as NSNumber) (optional)
-/// for travel bookings
-/// - @c kFIRParameterOrigin (NSString) (optional)
-/// - @c kFIRParameterDestination (NSString) (optional)
-/// - @c kFIRParameterTravelClass (NSString) (optional) for travel bookings
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterValue (double as NSNumber) (optional)
///
static NSString *const kFIREventBeginCheckout NS_SWIFT_NAME(AnalyticsEventBeginCheckout) =
@"begin_checkout";
@@ -127,6 +112,7 @@ static NSString *const kFIREventCampaignDetails NS_SWIFT_NAME(AnalyticsEventCamp
/// @c kFIRParameterCheckoutStep (unsigned 64-bit integer as NSNumber)
/// @c kFIRParameterCheckoutOption (NSString) (optional)
///
+/// This constant has been deprecated.
static NSString *const kFIREventCheckoutProgress NS_SWIFT_NAME(AnalyticsEventCheckoutProgress) =
@"checkout_progress";
@@ -167,6 +153,7 @@ static NSString *const kFIREventEarnVirtualCurrency
/// @c kFIRParameterDestination (NSString) (optional)
/// @c kFIRParameterTravelClass (NSString) (optional) for travel bookings
///
+/// This constant has been deprecated. Use @c kFIREventPurchase constant instead.
static NSString *const kFIREventEcommercePurchase NS_SWIFT_NAME(AnalyticsEventEcommercePurchase) =
@"ecommerce_purchase";
@@ -190,6 +177,21 @@ static NSString *const kFIREventGenerateLead NS_SWIFT_NAME(AnalyticsEventGenerat
///
static NSString *const kFIREventJoinGroup NS_SWIFT_NAME(AnalyticsEventJoinGroup) = @"join_group";
+/// Level End event. Log this event when the user finishes a level. Params:
+///
+///
+/// - @c kFIRParameterLevelName (NSString)
+/// - @c kFIRParameterSuccess (NSString)
+///
+static NSString *const kFIREventLevelEnd NS_SWIFT_NAME(AnalyticsEventLevelEnd) = @"level_end";
+
+/// Level Start event. Log this event when the user starts a new level. Params:
+///
+///
+/// - @c kFIRParameterLevelName (NSString)
+///
+static NSString *const kFIREventLevelStart NS_SWIFT_NAME(AnalyticsEventLevelStart) = @"level_start";
+
/// Level Up event. This event signifies that a player has leveled up in your gaming app. It can
/// help you gauge the level distribution of your userbase and help you identify certain levels that
/// are difficult to pass. Params:
@@ -231,6 +233,7 @@ static NSString *const kFIREventPostScore NS_SWIFT_NAME(AnalyticsEventPostScore)
/// @c kFIRParameterCurrency (NSString) (optional)
/// @c kFIRParameterValue (double as NSNumber) (optional)
///
+/// This constant has been deprecated. Use @c kFIREventViewPromotion constant instead.
static NSString *const kFIREventPresentOffer NS_SWIFT_NAME(AnalyticsEventPresentOffer) =
@"present_offer";
@@ -244,24 +247,18 @@ static NSString *const kFIREventPresentOffer NS_SWIFT_NAME(AnalyticsEventPresent
/// @c kFIRParameterValue (double as NSNumber) (optional)
/// @c kFIRParameterTransactionID (NSString) (optional)
///
+/// This constant has been deprecated. Use @c kFIREventRefund constant instead.
static NSString *const kFIREventPurchaseRefund NS_SWIFT_NAME(AnalyticsEventPurchaseRefund) =
@"purchase_refund";
-/// Remove from cart event. Params:
+/// E-Commerce Remove from Cart event. This event signifies that an item(s) was removed from a cart.
+/// Note: If you supply the @c kFIRParameterValue parameter, you must also supply the @c
+/// kFIRParameterCurrency parameter so that revenue metrics can be computed accurately. Params:
///
///
-/// - @c kFIRParameterQuantity (signed 64-bit integer as NSNumber)
-/// - @c kFIRParameterItemID (NSString)
-/// - @c kFIRParameterItemName (NSString)
-/// - @c kFIRParameterItemCategory (NSString)
-/// - @c kFIRParameterItemLocationID (NSString) (optional)
-/// - @c kFIRParameterPrice (double as NSNumber) (optional)
/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
/// - @c kFIRParameterValue (double as NSNumber) (optional)
-/// - @c kFIRParameterOrigin (NSString) (optional)
-/// - @c kFIRParameterDestination (NSString) (optional)
-/// - @c kFIRParameterStartDate (NSString) (optional)
-/// - @c kFIRParameterEndDate (NSString) (optional)
///
static NSString *const kFIREventRemoveFromCart NS_SWIFT_NAME(AnalyticsEventRemoveFromCart) =
@"remove_from_cart";
@@ -303,6 +300,7 @@ static NSString *const kFIREventSelectContent NS_SWIFT_NAME(AnalyticsEventSelect
/// @c kFIRParameterCheckoutStep (unsigned 64-bit integer as NSNumber)
/// @c kFIRParameterCheckoutOption (NSString)
///
+/// This constant has been deprecated.
static NSString *const kFIREventSetCheckoutOption NS_SWIFT_NAME(AnalyticsEventSetCheckoutOption) =
@"set_checkout_option";
@@ -357,43 +355,24 @@ static NSString *const kFIREventTutorialComplete NS_SWIFT_NAME(AnalyticsEventTut
static NSString *const kFIREventUnlockAchievement NS_SWIFT_NAME(AnalyticsEventUnlockAchievement) =
@"unlock_achievement";
-/// View Item event. This event signifies that some content was shown to the user. This content may
-/// be a product, a webpage or just a simple image or text. Use the appropriate parameters to
-/// contextualize the event. Use this event to discover the most popular items viewed in your app.
-/// Note: If you supply the @c kFIRParameterValue parameter, you must also supply the
-/// @c kFIRParameterCurrency parameter so that revenue metrics can be computed accurately.
-/// Params:
+/// View Item event. This event signifies that a user has viewed an item. Use the appropriate
+/// parameters to contextualize the event. Use this event to discover the most popular items viewed
+/// in your app. Note: If you supply the @c kFIRParameterValue parameter, you must also supply the
+/// @c kFIRParameterCurrency parameter so that revenue metrics can be computed accurately. Params:
///
///
-/// - @c kFIRParameterItemID (NSString)
-/// - @c kFIRParameterItemName (NSString)
-/// - @c kFIRParameterItemCategory (NSString)
-/// - @c kFIRParameterItemLocationID (NSString) (optional)
-/// - @c kFIRParameterPrice (double as NSNumber) (optional)
-/// - @c kFIRParameterQuantity (signed 64-bit integer as NSNumber) (optional)
/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
/// - @c kFIRParameterValue (double as NSNumber) (optional)
-/// - @c kFIRParameterStartDate (NSString) (optional)
-/// - @c kFIRParameterEndDate (NSString) (optional)
-/// - @c kFIRParameterFlightNumber (NSString) (optional) for travel bookings
-/// - @c kFIRParameterNumberOfPassengers (signed 64-bit integer as NSNumber) (optional)
-/// for travel bookings
-/// - @c kFIRParameterNumberOfNights (signed 64-bit integer as NSNumber) (optional) for
-/// travel bookings
-/// - @c kFIRParameterNumberOfRooms (signed 64-bit integer as NSNumber) (optional) for
-/// travel bookings
-/// - @c kFIRParameterOrigin (NSString) (optional)
-/// - @c kFIRParameterDestination (NSString) (optional)
-/// - @c kFIRParameterSearchTerm (NSString) (optional) for travel bookings
-/// - @c kFIRParameterTravelClass (NSString) (optional) for travel bookings
///
static NSString *const kFIREventViewItem NS_SWIFT_NAME(AnalyticsEventViewItem) = @"view_item";
-/// View Item List event. Log this event when the user has been presented with a list of items of a
-/// certain category. Params:
+/// View Item List event. Log this event when a user sees a list of items or offerings. Params:
///
///
-/// - @c kFIRParameterItemCategory (NSString)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterItemListID (NSString) (optional)
+/// - @c kFIRParameterItemListName (NSString) (optional)
///
static NSString *const kFIREventViewItemList NS_SWIFT_NAME(AnalyticsEventViewItemList) =
@"view_item_list";
@@ -407,18 +386,103 @@ static NSString *const kFIREventViewItemList NS_SWIFT_NAME(AnalyticsEventViewIte
static NSString *const kFIREventViewSearchResults NS_SWIFT_NAME(AnalyticsEventViewSearchResults) =
@"view_search_results";
-/// Level Start event. Log this event when the user starts a new level. Params:
+/// Add Shipping Info event. This event signifies that a user has submitted their shipping
+/// information. Note: If you supply the @c kFIRParameterValue parameter, you must also supply the
+/// @c kFIRParameterCurrency parameter so that revenue metrics can be computed accurately. Params:
///
///
-/// - @c kFIRParameterLevelName (NSString)
+/// - @c kFIRParameterCoupon (NSString) (optional)
+/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterShippingTier (NSString) (optional)
+/// - @c kFIRParameterValue (double as NSNumber) (optional)
///
-static NSString *const kFIREventLevelStart NS_SWIFT_NAME(AnalyticsEventLevelStart) =
- @"level_start";
+static NSString *const kFIREventAddShippingInfo NS_SWIFT_NAME(AnalyticsEventAddShippingInfo) =
+ @"add_shipping_info";
-/// Level End event. Log this event when the user finishes a level. Params:
+/// E-Commerce Purchase event. This event signifies that an item(s) was purchased by a user. Note:
+/// This is different from the in-app purchase event, which is reported automatically for App
+/// Store-based apps. Note: If you supply the @c kFIRParameterValue parameter, you must also supply
+/// the @c kFIRParameterCurrency parameter so that revenue metrics can be computed accurately.
+/// Params:
///
///
-/// - @c kFIRParameterLevelName (NSString)
-/// - @c kFIRParameterSuccess (NSString)
+/// - @c kFIRParameterAffiliation (NSString) (optional)
+/// - @c kFIRParameterCoupon (NSString) (optional)
+/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterShipping (double as NSNumber) (optional)
+/// - @c kFIRParameterTax (double as NSNumber) (optional)
+/// - @c kFIRParameterTransactionID (NSString) (optional)
+/// - @c kFIRParameterValue (double as NSNumber) (optional)
///
-static NSString *const kFIREventLevelEnd NS_SWIFT_NAME(AnalyticsEventLevelEnd) = @"level_end";
+static NSString *const kFIREventPurchase NS_SWIFT_NAME(AnalyticsEventPurchase) = @"purchase";
+
+/// E-Commerce Refund event. This event signifies that a refund was issued. Note: If you supply the
+/// @c kFIRParameterValue parameter, you must also supply the @c kFIRParameterCurrency parameter so
+/// that revenue metrics can be computed accurately. Params:
+///
+///
+/// - @c kFIRParameterAffiliation (NSString) (optional)
+/// - @c kFIRParameterCoupon (NSString) (optional)
+/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterShipping (double as NSNumber) (optional)
+/// - @c kFIRParameterTax (double as NSNumber) (optional)
+/// - @c kFIRParameterTransactionID (NSString) (optional)
+/// - @c kFIRParameterValue (double as NSNumber) (optional)
+///
+static NSString *const kFIREventRefund NS_SWIFT_NAME(AnalyticsEventRefund) = @"refund";
+
+/// Select Item event. This event signifies that an item was selected by a user from a list. Use the
+/// appropriate parameters to contextualize the event. Use this event to discover the most popular
+/// items selected. Params:
+///
+///
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterItemListID (NSString) (optional)
+/// - @c kFIRParameterItemListName (NSString) (optional)
+///
+static NSString *const kFIREventSelectItem NS_SWIFT_NAME(AnalyticsEventSelectItem) = @"select_item";
+
+/// Select promotion event. This event signifies that a user has selected a promotion offer. Use the
+/// appropriate parameters to contextualize the event, such as the item(s) for which the promotion
+/// applies. Params:
+///
+///
+/// - @c kFIRParameterCreativeName (NSString) (optional)
+/// - @c kFIRParameterCreativeSlot (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterLocationID (NSString) (optional)
+/// - @c kFIRParameterPromotionID (NSString) (optional)
+/// - @c kFIRParameterPromotionName (NSString) (optional)
+///
+static NSString *const kFIREventSelectPromotion NS_SWIFT_NAME(AnalyticsEventSelectPromotion) =
+ @"select_promotion";
+
+/// E-commerce View Cart event. This event signifies that a user has viewed their cart. Use this to
+/// analyze your purchase funnel. Note: If you supply the @c kFIRParameterValue parameter, you must
+/// also supply the @c kFIRParameterCurrency parameter so that revenue metrics can be computed
+/// accurately. Params:
+///
+///
+/// - @c kFIRParameterCurrency (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterValue (double as NSNumber) (optional)
+///
+static NSString *const kFIREventViewCart NS_SWIFT_NAME(AnalyticsEventViewCart) = @"view_cart";
+
+/// View Promotion event. This event signifies that a promotion was shown to a user. Add this event
+/// to a funnel with the @c kFIREventAddToCart and @c kFIREventPurchase to gauge your conversion
+/// process. Params:
+///
+///
+/// - @c kFIRParameterCreativeName (NSString) (optional)
+/// - @c kFIRParameterCreativeSlot (NSString) (optional)
+/// - @c kFIRParameterItems (NSArray) (optional)
+/// - @c kFIRParameterLocationID (NSString) (optional)
+/// - @c kFIRParameterPromotionID (NSString) (optional)
+/// - @c kFIRParameterPromotionName (NSString) (optional)
+///
+static NSString *const kFIREventViewPromotion NS_SWIFT_NAME(AnalyticsEventViewPromotion) =
+ @"view_promotion";
diff --git a/analytics/ios_headers/FIRParameterNames.h b/analytics/ios_headers/FIRParameterNames.h
index c162daa67b..3432044517 100644
--- a/analytics/ios_headers/FIRParameterNames.h
+++ b/analytics/ios_headers/FIRParameterNames.h
@@ -49,8 +49,8 @@ static NSString *const kFIRParameterAchievementID NS_SWIFT_NAME(AnalyticsParamet
static NSString *const kFIRParameterAdNetworkClickID
NS_SWIFT_NAME(AnalyticsParameterAdNetworkClickID) = @"aclid";
-/// The store or affiliation from which this transaction occurred (NSString).
-///
+/// A product affiliation to designate a supplying company or brick and mortar store location
+/// (NSString).
/// NSDictionary *params = @{
/// kFIRParameterAffiliation : @"Google Store",
/// // ...
@@ -88,6 +88,7 @@ static NSString *const kFIRParameterCharacter NS_SWIFT_NAME(AnalyticsParameterCh
/// // ...
/// };
///
+/// This constant has been deprecated.
static NSString *const kFIRParameterCheckoutStep NS_SWIFT_NAME(AnalyticsParameterCheckoutStep) =
@"checkout_step";
@@ -98,6 +99,7 @@ static NSString *const kFIRParameterCheckoutStep NS_SWIFT_NAME(AnalyticsParamete
/// // ...
/// };
///
+/// This constant has been deprecated.
static NSString *const kFIRParameterCheckoutOption
NS_SWIFT_NAME(AnalyticsParameterCheckoutOption) = @"checkout_option";
@@ -114,10 +116,10 @@ static NSString *const kFIRParameterContent NS_SWIFT_NAME(AnalyticsParameterCont
static NSString *const kFIRParameterContentType NS_SWIFT_NAME(AnalyticsParameterContentType) =
@"content_type";
-/// Coupon code for a purchasable item (NSString).
+/// Coupon code used for a purchase (NSString).
///
/// NSDictionary *params = @{
-/// kFIRParameterCoupon : @"zz123",
+/// kFIRParameterCoupon : @"SUMMER_FUN",
/// // ...
/// };
///
@@ -153,8 +155,8 @@ static NSString *const kFIRParameterCreativeName NS_SWIFT_NAME(AnalyticsParamete
static NSString *const kFIRParameterCreativeSlot NS_SWIFT_NAME(AnalyticsParameterCreativeSlot) =
@"creative_slot";
-/// Purchase currency in 3-letter
-/// ISO_4217 format (NSString).
+/// Currency of the purchase or items associated with the event, in 3-letter
+/// ISO_4217 format (NSString).
///
/// NSDictionary *params = @{
/// kFIRParameterCurrency : @"USD",
@@ -203,10 +205,10 @@ static NSString *const kFIRParameterFlightNumber NS_SWIFT_NAME(AnalyticsParamete
///
static NSString *const kFIRParameterGroupID NS_SWIFT_NAME(AnalyticsParameterGroupID) = @"group_id";
-/// Index of an item in a list (signed 64-bit integer as NSNumber).
+/// The index of the item in a list (signed 64-bit integer as NSNumber).
///
/// NSDictionary *params = @{
-/// kFIRParameterIndex : @(1),
+/// kFIRParameterIndex : @(5),
/// // ...
/// };
///
@@ -222,20 +224,20 @@ static NSString *const kFIRParameterIndex NS_SWIFT_NAME(AnalyticsParameterIndex)
static NSString *const kFIRParameterItemBrand NS_SWIFT_NAME(AnalyticsParameterItemBrand) =
@"item_brand";
-/// Item category (NSString).
+/// Item category (context-specific) (NSString).
///
/// NSDictionary *params = @{
-/// kFIRParameterItemCategory : @"t-shirts",
+/// kFIRParameterItemCategory : @"pants",
/// // ...
/// };
///
static NSString *const kFIRParameterItemCategory NS_SWIFT_NAME(AnalyticsParameterItemCategory) =
@"item_category";
-/// Item ID (NSString).
+/// Item ID (context-specific) (NSString).
///
/// NSDictionary *params = @{
-/// kFIRParameterItemID : @"p7654",
+/// kFIRParameterItemID : @"SKU_12345",
/// // ...
/// };
///
@@ -249,13 +251,14 @@ static NSString *const kFIRParameterItemID NS_SWIFT_NAME(AnalyticsParameterItemI
/// // ...
/// };
///
+/// This constant has been deprecated. Use @c kFIRParameterLocationID constant instead.
static NSString *const kFIRParameterItemLocationID
NS_SWIFT_NAME(AnalyticsParameterItemLocationID) = @"item_location_id";
-/// Item name (NSString).
+/// Item Name (context-specific) (NSString).
///
/// NSDictionary *params = @{
-/// kFIRParameterItemName : @"abc",
+/// kFIRParameterItemName : @"jeggings",
/// // ...
/// };
///
@@ -269,13 +272,14 @@ static NSString *const kFIRParameterItemName NS_SWIFT_NAME(AnalyticsParameterIte
/// // ...
/// };
///
+/// This constant has been deprecated. Use @c kFIRParameterItemListName constant instead.
static NSString *const kFIRParameterItemList NS_SWIFT_NAME(AnalyticsParameterItemList) =
@"item_list";
/// Item variant (NSString).
///
/// NSDictionary *params = @{
-/// kFIRParameterItemVariant : @"Red",
+/// kFIRParameterItemVariant : @"Black",
/// // ...
/// };
///
@@ -391,11 +395,11 @@ static NSString *const kFIRParameterScore NS_SWIFT_NAME(AnalyticsParameterScore)
static NSString *const kFIRParameterSearchTerm NS_SWIFT_NAME(AnalyticsParameterSearchTerm) =
@"search_term";
-/// Shipping cost (double as NSNumber).
+/// Shipping cost associated with a transaction (double as NSNumber).
///
/// NSDictionary *params = @{
-/// kFIRParameterShipping : @(9.50),
-/// kFIRParameterCurrency : @"USD", // e.g. $9.50 USD
+/// kFIRParameterShipping : @(5.99),
+/// kFIRParameterCurrency : @"USD", // e.g. $5.99 USD
/// // ...
/// };
///
@@ -446,11 +450,11 @@ static NSString *const kFIRParameterSource NS_SWIFT_NAME(AnalyticsParameterSourc
static NSString *const kFIRParameterStartDate NS_SWIFT_NAME(AnalyticsParameterStartDate) =
@"start_date";
-/// Tax amount (double as NSNumber).
+/// Tax cost associated with a transaction (double as NSNumber).
///
/// NSDictionary *params = @{
-/// kFIRParameterTax : @(1.0),
-/// kFIRParameterCurrency : @"USD", // e.g. $1.00 USD
+/// kFIRParameterTax : @(2.43),
+/// kFIRParameterCurrency : @"USD", // e.g. $2.43 USD
/// // ...
/// };
///
@@ -466,10 +470,10 @@ static NSString *const kFIRParameterTax NS_SWIFT_NAME(AnalyticsParameterTax) = @
///
static NSString *const kFIRParameterTerm NS_SWIFT_NAME(AnalyticsParameterTerm) = @"term";
-/// A single ID for a ecommerce group transaction (NSString).
+/// The unique identifier of a transaction (NSString).
///
/// NSDictionary *params = @{
-/// kFIRParameterTransactionID : @"ab7236dd9823",
+/// kFIRParameterTransactionID : @"T12345",
/// // ...
/// };
///
@@ -547,3 +551,137 @@ static NSString *const kFIRParameterSuccess NS_SWIFT_NAME(AnalyticsParameterSucc
///
static NSString *const kFIRParameterExtendSession NS_SWIFT_NAME(AnalyticsParameterExtendSession) =
@"extend_session";
+
+/// Monetary value of discount associated with a purchase (double as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterDiscount : @(2.0),
+/// kFIRParameterCurrency : @"USD", // e.g. $2.00 USD
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterDiscount NS_SWIFT_NAME(AnalyticsParameterDiscount) =
+ @"discount";
+
+/// Item Category (context-specific) (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemCategory2 : @"pants",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemCategory2 NS_SWIFT_NAME(AnalyticsParameterItemCategory2) =
+ @"item_category2";
+
+/// Item Category (context-specific) (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemCategory3 : @"pants",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemCategory3 NS_SWIFT_NAME(AnalyticsParameterItemCategory3) =
+ @"item_category3";
+
+/// Item Category (context-specific) (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemCategory4 : @"pants",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemCategory4 NS_SWIFT_NAME(AnalyticsParameterItemCategory4) =
+ @"item_category4";
+
+/// Item Category (context-specific) (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemCategory5 : @"pants",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemCategory5 NS_SWIFT_NAME(AnalyticsParameterItemCategory5) =
+ @"item_category5";
+
+/// The ID of the list in which the item was presented to the user (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemListID : @"ABC123",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemListID NS_SWIFT_NAME(AnalyticsParameterItemListID) =
+ @"item_list_id";
+
+/// The name of the list in which the item was presented to the user (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemListName : @"Related products",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemListName NS_SWIFT_NAME(AnalyticsParameterItemListName) =
+ @"item_list_name";
+
+/// The list of items involved in the transaction. (NSArray).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItems : @[
+/// @{kFIRParameterItemName : @"jeggings", kFIRParameterItemCategory : @"pants"},
+/// @{kFIRParameterItemName : @"boots", kFIRParameterItemCategory : @"shoes"},
+/// ],
+/// };
+///
+static NSString *const kFIRParameterItems NS_SWIFT_NAME(AnalyticsParameterItems) = @"items";
+
+/// The location associated with the event. Preferred to be the Google
+/// Place ID that corresponds to the
+/// associated item but could be overridden to a custom location ID string.(NSString).
+/// NSDictionary *params = @{
+/// kFIRParameterLocationID : @"ChIJiyj437sx3YAR9kUWC8QkLzQ",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterLocationID NS_SWIFT_NAME(AnalyticsParameterLocationID) =
+ @"location_id";
+
+/// The chosen method of payment (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterPaymentType : @"Visa",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterPaymentType NS_SWIFT_NAME(AnalyticsParameterPaymentType) =
+ @"payment_type";
+
+/// The ID of a product promotion (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterPromotionID : @"ABC123",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterPromotionID NS_SWIFT_NAME(AnalyticsParameterPromotionID) =
+ @"promotion_id";
+
+/// The name of a product promotion (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterPromotionName : @"Summer Sale",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterPromotionName NS_SWIFT_NAME(AnalyticsParameterPromotionName) =
+ @"promotion_name";
+
+/// The shipping tier (e.g. Ground, Air, Next-day) selected for delivery of the purchased item
+/// (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterShippingTier : @"Ground",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterShippingTier NS_SWIFT_NAME(AnalyticsParameterShippingTier) =
+ @"shipping_tier";
diff --git a/analytics/src/analytics_android.cc b/analytics/src/analytics_android.cc
index 22b89166a3..8f1d28b548 100644
--- a/analytics/src/analytics_android.cc
+++ b/analytics/src/analytics_android.cc
@@ -402,22 +402,23 @@ Future GetAnalyticsInstanceId() {
if (future_data) {
bool success =
result_code == util::kFutureResultSuccess && result != nullptr;
+ FutureHandleId future_id =
+ reinterpret_cast(callback_data);
+ FutureHandle handle(future_id);
future_data->api()->CompleteWithResult(
- SafeFutureHandle(
- *(reinterpret_cast(&callback_data))),
- success ? 0 : -1,
+ handle, success ? 0 : -1,
success ? ""
: status_message ? status_message
: "Unknown error occurred",
- // Both JStringToString and GetMessageFromException are able to
- // handle a nullptr being passed in, and neither deletes the
- // object passed in (so delete it below).
+ // Both JStringToString and GetMessageFromException are
+ // able to handle a nullptr being passed in, and neither
+ // deletes the object passed in (so delete it below).
success ? util::JStringToString(env, result)
: util::GetMessageFromException(env, result));
}
if (result) env->DeleteLocalRef(result);
},
- *(reinterpret_cast(&future_handle)),
+ reinterpret_cast(safe_future_handle.get().id()),
internal::kAnalyticsModuleName);
env->DeleteLocalRef(task);
} else {
diff --git a/analytics/src_ios/fake/FIRAnalytics.h b/analytics/src_ios/fake/FIRAnalytics.h
new file mode 100644
index 0000000000..060b712c6a
--- /dev/null
+++ b/analytics/src_ios/fake/FIRAnalytics.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import
+
+@interface FIRAnalytics : NSObject
+
++ (void)logEventWithName:(nonnull NSString *)name
+ parameters:(nullable NSDictionary *)parameters;
+
++ (void)setUserPropertyString:(nullable NSString *)value forName:(nonnull NSString *)name;
+
++ (void)setUserID:(nullable NSString *)userID;
+
++ (void)setScreenName:(nullable NSString *)screenName
+ screenClass:(nullable NSString *)screenClassOverride;
+
++ (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled;
+
++ (void)setSessionTimeoutInterval:(NSTimeInterval)sessionTimeoutInterval;
+
++ (nullable NSString *)appInstanceID;
+
++ (void)resetAnalyticsData;
+
+@end
diff --git a/analytics/src_ios/fake/FIRAnalytics.mm b/analytics/src_ios/fake/FIRAnalytics.mm
new file mode 100644
index 0000000000..6e2508f276
--- /dev/null
+++ b/analytics/src_ios/fake/FIRAnalytics.mm
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "analytics/src_ios/fake/FIRAnalytics.h"
+
+#include "testing/reporter_impl.h"
+
+@implementation FIRAnalytics
+
++ (NSString *)stringForValue:(id)value {
+ return [NSString stringWithFormat:@"%@", value];
+}
+
++ (NSString *)stringForParameters:(NSDictionary *)parameters {
+ if ([parameters count] == 0) {
+ return @"";
+ }
+
+ NSArray *sortedKeys =
+ [parameters.allKeys sortedArrayUsingSelector:@selector(compare:)];
+ NSMutableString *parameterString = [NSMutableString string];
+ for (NSString *key in sortedKeys) {
+ [parameterString appendString:key];
+ [parameterString appendString:@"="];
+ [parameterString appendString:[self stringForValue:parameters[key]]];
+ [parameterString appendString:@","];
+ }
+ // Remove trailing comma from string.
+ [parameterString deleteCharactersInRange:NSMakeRange([parameterString length] - 1, 1)];
+ return parameterString;
+}
+
++ (void)logEventWithName:(nonnull NSString *)name
+ parameters:(nullable NSDictionary *)parameters {
+ NSString *parameterString = [self stringForParameters:parameters];
+ if (parameterString) {
+ FakeReporter->AddReport("+[FIRAnalytics logEventWithName:parameters:]",
+ { [name UTF8String], [parameterString UTF8String] });
+ } else {
+ FakeReporter->AddReport("+[FIRAnalytics logEventWithName:parameters:]",
+ { [name UTF8String] });
+ }
+}
+
++ (void)setUserPropertyString:(nullable NSString *)value forName:(nonnull NSString *)name {
+ FakeReporter->AddReport("+[FIRAnalytics setUserPropertyString:forName:]",
+ { [name UTF8String], value ? [value UTF8String] : "nil" });
+}
+
++ (void)setUserID:(nullable NSString *)userID {
+ FakeReporter->AddReport("+[FIRAnalytics setUserID:]", { userID ? [userID UTF8String] : "nil" });
+}
+
++ (void)setScreenName:(nullable NSString *)screenName
+ screenClass:(nullable NSString *)screenClassOverride {
+ FakeReporter->AddReport("+[FIRAnalytics setScreenName:screenClass:]",
+ { screenName ? [screenName UTF8String] : "nil",
+ screenClassOverride ? [screenClassOverride UTF8String] : "nil" });
+}
+
++ (void)setSessionTimeoutInterval:(NSTimeInterval)sessionTimeoutInterval {
+ FakeReporter->AddReport(
+ "+[FIRAnalytics setSessionTimeoutInterval:]",
+ {[[NSString stringWithFormat:@"%.03f", sessionTimeoutInterval] UTF8String]});
+}
+
++ (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled {
+ FakeReporter->AddReport("+[FIRAnalytics setAnalyticsCollectionEnabled:]",
+ {analyticsCollectionEnabled ? "YES" : "NO"});
+}
+
++ (NSString *)appInstanceID {
+ FakeReporter->AddReport("+[FIRAnalytics appInstanceID]", {});
+ return @"FakeAnalyticsInstanceId0";
+}
+
++ (void)resetAnalyticsData {
+ FakeReporter->AddReport("+[FIRAnalytics resetAnalyticsData]", {});
+}
+
+@end
diff --git a/analytics/src_java/fake/com/google/firebase/analytics/FirebaseAnalytics.java b/analytics/src_java/fake/com/google/firebase/analytics/FirebaseAnalytics.java
new file mode 100644
index 0000000000..ef6f0495f8
--- /dev/null
+++ b/analytics/src_java/fake/com/google/firebase/analytics/FirebaseAnalytics.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.firebase.analytics;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import com.google.android.gms.tasks.Task;
+import com.google.firebase.testing.cppsdk.FakeReporter;
+import com.google.firebase.testing.cppsdk.TickerAndroid;
+
+import java.util.TreeSet;
+
+/**
+ * Fake for FirebaseAnalytics.
+ */
+public final class FirebaseAnalytics {
+
+ public static FirebaseAnalytics getInstance(Context context) {
+ FakeReporter.addReport("FirebaseAnalytics.getInstance");
+ return new FirebaseAnalytics();
+ }
+
+ public Task getAppInstanceId() {
+ FakeReporter.addReport("FirebaseAnalytics.getAppInstanceId");
+ Task result = Task.forResult("FakeAnalyticsInstanceId0");
+ TickerAndroid.register(result);
+ return result;
+ }
+
+ public void setAnalyticsCollectionEnabled(boolean enabled) {
+ FakeReporter.addReport("FirebaseAnalytics.setAnalyticsCollectionEnabled",
+ Boolean.toString(enabled));
+ }
+
+ public void logEvent(String name, Bundle params) {
+ StringBuilder paramsString = new StringBuilder();
+ // Sort keys for predictable ordering.
+ for (String key : new TreeSet<>(params.keySet())) {
+ paramsString.append(key);
+ paramsString.append("=");
+ paramsString.append(params.get(key));
+ paramsString.append(",");
+ }
+ paramsString.setLength(Math.max(0, paramsString.length() - 1));
+ FakeReporter.addReport("FirebaseAnalytics.logEvent", name, paramsString.toString());
+ }
+
+ public void resetAnalyticsData() {
+ FakeReporter.addReport("FirebaseAnalytics.resetAnalyticsData");
+ }
+
+ public void setUserProperty(String name, String value) {
+ FakeReporter.addReport("FirebaseAnalytics.setUserProperty", name, String.valueOf(value));
+ }
+
+ public void setCurrentScreen(Activity activity, String screenName,
+ String screenClassOverride) {
+ FakeReporter.addReport("FirebaseAnalytics.setCurrentScreen", activity.getClass().getName(),
+ String.valueOf(screenName), String.valueOf(screenClassOverride));
+ }
+
+ public void setUserId(String userId) {
+ FakeReporter.addReport("FirebaseAnalytics.setUserId", String.valueOf(userId));
+ }
+
+ public void setMinimumSessionDuration(long milliseconds) {
+ FakeReporter.addReport("FirebaseAnalytics.setMinimumSessionDuration",
+ Long.toString(milliseconds));
+ }
+
+ public void setSessionTimeoutDuration(long milliseconds) {
+ FakeReporter.addReport("FirebaseAnalytics.setSessionTimeoutDuration",
+ Long.toString(milliseconds));
+ }
+
+}
diff --git a/analytics/tests/CMakeLists.txt b/analytics/tests/CMakeLists.txt
new file mode 100644
index 0000000000..51e72f2490
--- /dev/null
+++ b/analytics/tests/CMakeLists.txt
@@ -0,0 +1,41 @@
+# Copyright 2019 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+
+
+firebase_cpp_cc_test(
+ firebase_analytics_test
+ SOURCES
+ analytics_test.cc
+ DEPENDS
+ firebase_app_for_testing
+ firebase_analytics
+ firebase_testing
+)
+
+firebase_cpp_cc_test_on_ios(
+ firebase_analytics_test
+ HOST
+ firebase_app_for_testing_ios
+ SOURCES
+ ${FIREBASE_SOURCE_DIR}/analytics/tests/analytics_test.cc
+ DEPENDS
+ firebase_app_for_testing
+ firebase_analytics
+ firebase_testing
+ "-lsqlite3"
+ CUSTOM_FRAMEWORKS
+ StoreKit
+)
diff --git a/analytics/tests/analytics_test.cc b/analytics/tests/analytics_test.cc
new file mode 100644
index 0000000000..3e608cc447
--- /dev/null
+++ b/analytics/tests/analytics_test.cc
@@ -0,0 +1,310 @@
+/*
+ * Copyright 2017 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if defined(FIREBASE_ANDROID_FOR_DESKTOP)
+#define __ANDROID__
+#include
+
+#include "testing/run_all_tests.h"
+#endif // defined(FIREBASE_ANDROID_FOR_DESKTOP)
+
+#include "analytics/src/analytics_common.h"
+#include "analytics/src/include/firebase/analytics.h"
+#include "app/src/include/firebase/app.h"
+#include "app/src/time.h"
+#include "app/tests/include/firebase/app_for_testing.h"
+
+#ifdef __ANDROID__
+#include "app/src/semaphore.h"
+#include "app/src/util_android.h"
+#endif // __ANDROID__
+
+#if defined(FIREBASE_ANDROID_FOR_DESKTOP)
+#undef __ANDROID__
+#endif // defined(FIREBASE_ANDROID_FOR_DESKTOP)
+
+#include "testing/config.h"
+#include "testing/reporter.h"
+#include "testing/ticker.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+namespace firebase {
+namespace analytics {
+
+class AnalyticsTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ firebase::testing::cppsdk::TickerReset();
+ firebase::testing::cppsdk::ConfigSet("{}");
+ reporter_.reset();
+
+ firebase_app_ = testing::CreateApp();
+ AddExpectationAndroid("FirebaseAnalytics.getInstance", {});
+ analytics::Initialize(*firebase_app_);
+ }
+
+ void TearDown() override {
+ firebase::testing::cppsdk::ConfigReset();
+ Terminate();
+ delete firebase_app_;
+ firebase_app_ = nullptr;
+ EXPECT_THAT(reporter_.getFakeReports(),
+ ::testing::Eq(reporter_.getExpectations()));
+ }
+
+ void AddExpectationAndroid(const char* fake,
+ std::initializer_list args) {
+ reporter_.addExpectation(fake, "", firebase::testing::cppsdk::kAndroid,
+ args);
+ }
+
+ void AddExpectationApple(const char* fake,
+ std::initializer_list args) {
+ reporter_.addExpectation(fake, "", firebase::testing::cppsdk::kIos, args);
+ }
+
+ // Wait for a task executing on the main thread.
+ void WaitForMainThreadTask() {
+#if defined(FIREBASE_ANDROID_FOR_DESKTOP)
+ Semaphore main_thread_signal(0);
+ util::RunOnMainThread(
+ firebase_app_->GetJNIEnv(), firebase_app_->activity(),
+ [](void* data) { reinterpret_cast(data)->Post(); },
+ &main_thread_signal);
+ main_thread_signal.Wait();
+#endif // defined(FIREBASE_ANDROID_FOR_DESKTOP)
+ }
+
+ // Wait for a future up to the specified number of milliseconds.
+ template
+ static void WaitForFutureWithTimeout(const Future& future,
+ int timeout_milliseconds,
+ FutureStatus expected_status) {
+ while (future.status() != expected_status && timeout_milliseconds-- > 0) {
+ ::firebase::internal::Sleep(1);
+ }
+ }
+
+ App* firebase_app_ = nullptr;
+
+ firebase::testing::cppsdk::Reporter reporter_;
+};
+
+TEST_F(AnalyticsTest, TestDestroyDefaultApp) {
+ EXPECT_TRUE(internal::IsInitialized());
+ delete firebase_app_;
+ firebase_app_ = nullptr;
+ EXPECT_FALSE(internal::IsInitialized());
+}
+
+TEST_F(AnalyticsTest, TestSetAnalyticsCollectionEnabled) {
+ AddExpectationAndroid("FirebaseAnalytics.setAnalyticsCollectionEnabled",
+ {"true"});
+ AddExpectationApple("+[FIRAnalytics setAnalyticsCollectionEnabled:]",
+ {"YES"});
+ SetAnalyticsCollectionEnabled(true);
+}
+
+TEST_F(AnalyticsTest, TestSetAnalyticsCollectionDisabled) {
+ AddExpectationAndroid("FirebaseAnalytics.setAnalyticsCollectionEnabled",
+ {"false"});
+ AddExpectationApple("+[FIRAnalytics setAnalyticsCollectionEnabled:]", {"NO"});
+ SetAnalyticsCollectionEnabled(false);
+}
+
+TEST_F(AnalyticsTest, TestLogEventString) {
+ AddExpectationAndroid("FirebaseAnalytics.logEvent",
+ {"my_event", "my_param=my_value"});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event", "my_param=my_value"});
+
+ LogEvent("my_event", "my_param", "my_value");
+}
+
+TEST_F(AnalyticsTest, TestLogEventDouble) {
+ AddExpectationAndroid("FirebaseAnalytics.logEvent",
+ {"my_event", "my_param=1.01"});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event", "my_param=1.01"});
+ LogEvent("my_event", "my_param", 1.01);
+}
+
+TEST_F(AnalyticsTest, TestLogEventInt64) {
+ int64_t value = 101;
+ AddExpectationAndroid("FirebaseAnalytics.logEvent",
+ {"my_event", "my_param=101"});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event", "my_param=101"});
+
+ LogEvent("my_event", "my_param", value);
+}
+
+TEST_F(AnalyticsTest, TestLogEventInt) {
+ AddExpectationAndroid("FirebaseAnalytics.logEvent",
+ {"my_event", "my_param=101"});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event", "my_param=101"});
+
+ LogEvent("my_event", "my_param", 101);
+}
+
+TEST_F(AnalyticsTest, TestLogEvent) {
+ AddExpectationAndroid("FirebaseAnalytics.logEvent", {"my_event", ""});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event", ""});
+
+ LogEvent("my_event");
+}
+
+TEST_F(AnalyticsTest, TestLogEvent40CharName) {
+ AddExpectationAndroid("FirebaseAnalytics.logEvent",
+ {"0123456789012345678901234567890123456789", ""});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"0123456789012345678901234567890123456789", ""});
+
+ LogEvent("0123456789012345678901234567890123456789");
+}
+
+TEST_F(AnalyticsTest, TestLogEventString40CharName) {
+ AddExpectationAndroid(
+ "FirebaseAnalytics.logEvent",
+ {"my_event", "0123456789012345678901234567890123456789=my_value"});
+ AddExpectationApple(
+ "+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event", "0123456789012345678901234567890123456789=my_value"});
+ LogEvent("my_event", "0123456789012345678901234567890123456789", "my_value");
+}
+
+TEST_F(AnalyticsTest, TestLogEventString100CharValue) {
+ const std::string long_string =
+ "0123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789";
+ const std::string result = "my_event=" + long_string;
+ AddExpectationAndroid("FirebaseAnalytics.logEvent",
+ {"my_event", result.c_str()});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event", result.c_str()});
+ LogEvent("my_event", "my_event", long_string.c_str());
+}
+
+TEST_F(AnalyticsTest, TestLogEventParameters) {
+ // Params are sorted alphabetically by mock.
+ AddExpectationAndroid(
+ "FirebaseAnalytics.logEvent",
+ {"my_event",
+ "my_param_bool=1,my_param_double=1.01,my_param_int=101,"
+ "my_param_string=my_value"});
+ AddExpectationApple("+[FIRAnalytics logEventWithName:parameters:]",
+ {"my_event",
+ "my_param_bool=1,my_param_double=1.01,my_param_int=101,"
+ "my_param_string=my_value"});
+
+ Parameter parameters[] = {
+ Parameter("my_param_string", "my_value"),
+ Parameter("my_param_double", 1.01),
+ Parameter("my_param_int", 101),
+ Parameter("my_param_bool", true),
+ };
+ LogEvent("my_event", parameters, sizeof(parameters) / sizeof(parameters[0]));
+}
+
+TEST_F(AnalyticsTest, TestSetUserProperty) {
+ AddExpectationAndroid("FirebaseAnalytics.setUserProperty",
+ {"my_property", "my_value"});
+ AddExpectationApple("+[FIRAnalytics setUserPropertyString:forName:]",
+ {"my_property", "my_value"});
+
+ SetUserProperty("my_property", "my_value");
+}
+
+TEST_F(AnalyticsTest, TestSetUserPropertyNull) {
+ AddExpectationAndroid("FirebaseAnalytics.setUserProperty",
+ {"my_property", "null"});
+ AddExpectationApple("+[FIRAnalytics setUserPropertyString:forName:]",
+ {"my_property", "nil"});
+ SetUserProperty("my_property", nullptr);
+}
+
+TEST_F(AnalyticsTest, TestSetUserId) {
+ AddExpectationAndroid("FirebaseAnalytics.setUserId", {"my_user_id"});
+ AddExpectationApple("+[FIRAnalytics setUserID:]", {"my_user_id"});
+ SetUserId("my_user_id");
+}
+
+TEST_F(AnalyticsTest, TestSetUserIdNull) {
+ AddExpectationAndroid("FirebaseAnalytics.setUserId", {"null"});
+ AddExpectationApple("+[FIRAnalytics setUserID:]", {"nil"});
+ SetUserId(nullptr);
+}
+
+TEST_F(AnalyticsTest, TestSetSessionTimeoutDuration) {
+ AddExpectationAndroid("FirebaseAnalytics.setSessionTimeoutDuration",
+ {"1000"});
+ AddExpectationApple("+[FIRAnalytics setSessionTimeoutInterval:]", {"1.000"});
+
+ SetSessionTimeoutDuration(1000);
+}
+
+TEST_F(AnalyticsTest, TestSetCurrentScreen) {
+ AddExpectationAndroid("FirebaseAnalytics.setCurrentScreen",
+ {"android.app.Activity", "my_screen", "my_class"});
+ AddExpectationApple("+[FIRAnalytics setScreenName:screenClass:]",
+ {"my_screen", "my_class"});
+
+ SetCurrentScreen("my_screen", "my_class");
+ WaitForMainThreadTask();
+}
+
+TEST_F(AnalyticsTest, TestSetCurrentScreenNullScreen) {
+ AddExpectationAndroid("FirebaseAnalytics.setCurrentScreen",
+ {"android.app.Activity", "null", "my_class"});
+ AddExpectationApple("+[FIRAnalytics setScreenName:screenClass:]",
+ {"nil", "my_class"});
+
+ SetCurrentScreen(nullptr, "my_class");
+ WaitForMainThreadTask();
+}
+
+TEST_F(AnalyticsTest, TestSetCurrentScreenNullClass) {
+ AddExpectationAndroid("FirebaseAnalytics.setCurrentScreen",
+ {"android.app.Activity", "my_screen", "null"});
+ AddExpectationApple("+[FIRAnalytics setScreenName:screenClass:]",
+ {"my_screen", "nil"});
+
+ SetCurrentScreen("my_screen", nullptr);
+ WaitForMainThreadTask();
+}
+
+TEST_F(AnalyticsTest, TestResetAnalyticsData) {
+ AddExpectationAndroid("FirebaseAnalytics.resetAnalyticsData", {});
+ AddExpectationApple("+[FIRAnalytics resetAnalyticsData]", {});
+ AddExpectationApple("+[FIRAnalytics appInstanceID]", {});
+ ResetAnalyticsData();
+}
+
+TEST_F(AnalyticsTest, TestGetAnalyticsInstanceId) {
+ AddExpectationAndroid("FirebaseAnalytics.getAppInstanceId", {});
+ AddExpectationApple("+[FIRAnalytics appInstanceID]", {});
+ auto result = GetAnalyticsInstanceId();
+ // Wait for up to a second to fetch the ID.
+ WaitForFutureWithTimeout(result, 1000, firebase::kFutureStatusComplete);
+ EXPECT_EQ(firebase::kFutureStatusComplete, result.status());
+ EXPECT_EQ(std::string("FakeAnalyticsInstanceId0"), *result.result());
+}
+
+} // namespace analytics
+} // namespace firebase
diff --git a/android_build_files/generate_proguard.gradle b/android_build_files/generate_proguard.gradle
index 8908b2239e..082e157d42 100644
--- a/android_build_files/generate_proguard.gradle
+++ b/android_build_files/generate_proguard.gradle
@@ -64,7 +64,7 @@ def generateFinalProguard(Set proguardSet, String outputProguard) {
def defineGenerateProguardFile(String subproject, String buildType,
Action callback) {
Task t = tasks.getByName("externalNativeBuild$buildType").with {
- String outputProguard = "$buildDir/${subproject}.pro"
+ String outputProguard = "$buildDir/$buildType/${subproject}.pro"
outputs.file "$outputProguard"
doLast {
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 4d1b16e721..536e16a800 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -67,8 +67,12 @@ add_custom_command(
# Build the google_services_generated.h header from the flatbuffer schema file.
set(FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS
"--no-union-value-namespacing"
+ "--gen-generated"
"--gen-object-api"
"--cpp-ptr-type" "flatbuffers::unique_ptr")
+# Because of a bug in the version of Flatbuffers we are pinned to,
+# additional flags need to be set.
+set(FLATC_ARGS "${FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS}")
build_flatbuffers("${CMAKE_CURRENT_LIST_DIR}/google_services.fbs"
""
"app_generated_includes"
@@ -191,6 +195,11 @@ else()
systems via: \
apt-get install libsecret-1-dev")
endif()
+ # If building for 32 bit, the include directories might need to be fixed.
+ if("${CMAKE_CXX_FLAGS}" MATCHES "-m32")
+ string(REGEX REPLACE "x86_64" "i386"
+ LIBSECRET_INCLUDE_DIRS "${LIBSECRET_INCLUDE_DIRS}")
+ endif()
set(app_desktop_extra_SRCS
src/secure/user_secure_linux_internal.cc
src/locale.cc
@@ -207,6 +216,7 @@ set(internal_HDRS
src/include/firebase/future.h
src/include/firebase/internal/common.h
src/include/firebase/internal/future_impl.h
+ src/include/firebase/internal/type_traits.h
src/include/firebase/log.h
src/include/firebase/util.h
src/include/firebase/variant.h
@@ -289,7 +299,6 @@ add_library(firebase_app STATIC
${app_platform_HDRS}
${FIREBASE_GEN_FILE_DIR}/app/google_services_generated.h
memory/atomic.h
- meta/type_traits.h
meta/move.h
memory/unique_ptr.h
memory/shared_ptr.h)
@@ -329,12 +338,6 @@ else()
add_definitions(-include assert.h -include string.h)
endif()
-# Ensure min/max macros don't get declared on Windows
-# (so we can use std::min/max)
-if(MSVC)
- add_definitions(-DNOMINMAX)
-endif()
-
if(ANDROID)
firebase_cpp_proguard_file(app)
elseif(IOS)
diff --git a/app/app_resources/build.gradle b/app/app_resources/build.gradle
index f396acb1d0..581dc3c59c 100644
--- a/app/app_resources/build.gradle
+++ b/app/app_resources/build.gradle
@@ -46,7 +46,7 @@ android {
}
dependencies {
- implementation 'com.google.firebase:firebase-analytics:17.2.1'
+ implementation 'com.google.firebase:firebase-analytics:17.4.1'
}
afterEvaluate {
diff --git a/app/build.gradle b/app/build.gradle
index 829c90d641..1c500011fa 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -62,6 +62,8 @@ android {
externalNativeBuild {
cmake {
targets 'firebase_app'
+ // Don't configure all the cmake subprojects.
+ arguments '-DFIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF'
}
}
}
diff --git a/app/google_api_resources/build.gradle b/app/google_api_resources/build.gradle
index 841231e6b3..559b37a315 100644
--- a/app/google_api_resources/build.gradle
+++ b/app/google_api_resources/build.gradle
@@ -49,7 +49,7 @@ android {
}
dependencies {
- implementation 'com.google.firebase:firebase-analytics:17.2.1'
+ implementation 'com.google.firebase:firebase-analytics:17.4.1'
implementation project(':app:app_resources')
}
diff --git a/app/instance_id/CMakeLists.txt b/app/instance_id/CMakeLists.txt
index a70de662b6..5c4ed0860f 100644
--- a/app/instance_id/CMakeLists.txt
+++ b/app/instance_id/CMakeLists.txt
@@ -24,8 +24,12 @@ enable_language(CXX)
# Build the iid_data_generated.h header from the flatbuffer schema file.
set(FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS
"--no-union-value-namespacing"
+ "--gen-generated"
"--gen-object-api"
"--cpp-ptr-type" "firebase::UniquePtr")
+# Because of a bug in the version of Flatbuffers we are pinned to,
+# additional flags need to be set.
+set(FLATC_ARGS "${FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS}")
build_flatbuffers("${CMAKE_CURRENT_LIST_DIR}/iid_data.fbs"
""
"iid_data_generated_includes"
diff --git a/app/instance_id/instance_id_desktop_impl_test.cc b/app/instance_id/instance_id_desktop_impl_test.cc
new file mode 100644
index 0000000000..3c46ddd188
--- /dev/null
+++ b/app/instance_id/instance_id_desktop_impl_test.cc
@@ -0,0 +1,819 @@
+// Copyright 2019 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "app/instance_id/instance_id_desktop_impl.h"
+
+#include