[ios] Statistics for banners.

This commit is contained in:
VladiMihaylenko 2016-12-14 11:39:07 +03:00 committed by Илья Гречухин
parent 11d277a24f
commit 4e90440a94
11 changed files with 57 additions and 30 deletions

@ -1 +1 @@
Subproject commit a3e1659ba90ed079b3021ea2fa45a628a832b8e3
Subproject commit 28f74496e58213dd0bc7d793fd17ba0e7f3d89ba

View file

@ -19,6 +19,7 @@ public:
string GetMessageBase() const { return m_messageBase; }
string GetIconName() const { return m_iconName; }
string GetDefaultUrl() const { return m_defaultUrl; }
string GetId() const { return m_id; }
bool IsActive() const;
/// Replaces inline variables in the URL, uses the default banner URL if url is not specified.

View file

@ -1,9 +1,8 @@
@class MWMPlacePageData;
@interface MWMPPPreviewBannerCell : UITableViewCell
- (void)configWithTitle:(NSString *)title
content:(NSString *)content
adURL:(NSURL *)adURL
imageURL:(NSURL *)imageURL;
- (void)configWithData:(MWMPlacePageData *)data;
- (void)configImageInOpenState;
- (void)configImageInPreviewState;

View file

@ -1,7 +1,9 @@
#import "MWMPPPreviewBannerCell.h"
#import "Common.h"
#import "MapViewController.h"
#import "MWMPlacePageData.h"
#import "MWMPlacePageLayoutImpl.h"
#import "Statistics.h"
#import "UIColor+MapsMeColor.h"
#import "UIFont+MapsMeFonts.h"
@ -23,7 +25,7 @@ CGFloat const kLineSpacing = 5;
@property(weak, nonatomic) IBOutlet UIImageView * icon;
@property(weak, nonatomic) IBOutlet UILabel * body;
@property(weak, nonatomic) IBOutlet UIButton * button;
@property(nonatomic) NSURL * adURL;
@property(weak, nonatomic) MWMPlacePageData * data;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * imageWidth;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * imageHeight;
@ -34,23 +36,20 @@ CGFloat const kLineSpacing = 5;
@implementation MWMPPPreviewBannerCell
- (void)configWithTitle:(NSString *)title
content:(NSString *)content
adURL:(NSURL *)adURL
imageURL:(NSURL *)imageURL
- (void)configWithData:(MWMPlacePageData *)data
{
NSAssert(title.length, @"Title must be not empty!");
self.adURL = adURL;
auto full = [[NSMutableAttributedString alloc] initWithString:title attributes:
@{NSForegroundColorAttributeName : [UIColor blackPrimaryText],
NSFontAttributeName : [UIFont medium16]}];
self.data = data;
auto full = [[NSMutableAttributedString alloc] initWithString:data.bannerTitle attributes:
@{NSForegroundColorAttributeName : [UIColor blackPrimaryText],
NSFontAttributeName : [UIFont medium16]}];
[full appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
auto content = data.bannerContent;
if (content.length)
{
auto attrContent = [[NSAttributedString alloc] initWithString:content attributes:
@{NSForegroundColorAttributeName : [UIColor blackSecondaryText],
NSFontAttributeName : [UIFont regular13]}];
@{NSForegroundColorAttributeName : [UIColor blackSecondaryText],
NSFontAttributeName : [UIFont regular13]}];
[full appendAttributedString:attrContent];
}
@ -67,6 +66,7 @@ CGFloat const kLineSpacing = 5;
self.bodyLeftOffset.constant = kDefaultBodyLeftOffset;
self.button.hidden = !IPAD;
auto imageURL = data.bannerIconURL;
if (!imageURL)
return;
@ -124,8 +124,13 @@ CGFloat const kLineSpacing = 5;
- (IBAction)tap
{
if (self.adURL)
[[MapViewController controller] openUrl:self.adURL];
MWMPlacePageData * data = self.data;
[Statistics logEvent:kStatPlacePageBannerClick withParameters:@{kStatTags : data.statisticsTags,
kStatBanner : data.bannerId,
kStatState : @1}];
auto bannerURL = data.bannerURL;
if (bannerURL)
[[MapViewController controller] openUrl:bannerURL];
}
@end

View file

@ -4,6 +4,7 @@
#import "MWMPlacePageData.h"
#import "MWMPPPreviewBannerCell.h"
#import "MWMTableViewCell.h"
#import "Statistics.h"
#import "UIColor+MapsmeColor.h"
#include "std/array.hpp"
@ -228,11 +229,11 @@ array<NSString *, 8> const kPreviewCells = {{@"_MWMPPPTitle", @"_MWMPPPExternalT
case PreviewRows::Space:
return c;
case PreviewRows::Banner:
[Statistics logEvent:kStatPlacePageBannerShow withParameters:@{kStatTags : data.statisticsTags,
kStatBanner : data.bannerId,
kStatState : IPAD ? @1 : @0}];
auto bannerCell = static_cast<MWMPPPreviewBannerCell *>(c);
[bannerCell configWithTitle:data.bannerTitle
content:data.bannerContent
adURL:data.bannerURL
imageURL:data.bannerIconURL];
[bannerCell configWithData:data];
self.cachedBannerCell = bannerCell;
return bannerCell;
}

View file

@ -85,6 +85,7 @@ enum class OpeningHours
- (NSString *)bannerContent;
- (NSURL *)bannerIconURL;
- (NSURL *)bannerURL;
- (NSString *)bannerId;
- (void)assignOnlinePriceToLabel:(UILabel *)label;
// API

View file

@ -227,22 +227,32 @@ using namespace place_page;
- (NSString *)bannerTitle
{
return m_info.HasBanner() ? L(@(m_info.GetBannerTitleId().c_str())) : nil;
NSAssert(m_info.HasBanner(), @"Incorrect banner state!");
return L(@(m_info.GetBannerTitleId().c_str()));
}
- (NSString *)bannerContent
{
return m_info.HasBanner() ? L(@(m_info.GetBannerMessageId().c_str())) : nil;
NSAssert(m_info.HasBanner(), @"Incorrect banner state!");
return L(@(m_info.GetBannerMessageId().c_str()));
}
- (NSURL *)bannerIconURL
{
return m_info.HasBanner() ? [NSURL URLWithString:@(m_info.GetBannerIconId().c_str())] : nil;
NSAssert(m_info.HasBanner(), @"Incorrect banner state!");
return [NSURL URLWithString:@(m_info.GetBannerIconId().c_str())];
}
- (NSURL *)bannerURL
{
return m_info.HasBanner() ? [NSURL URLWithString:@(m_info.GetBannerUrl().c_str())] : nil;
NSAssert(m_info.HasBanner(), @"Incorrect banner state!");
return [NSURL URLWithString:@(m_info.GetBannerUrl().c_str())];
}
- (NSString *)bannerId
{
NSAssert(m_info.HasBanner(), @"Incorrect banner state!");
return @(m_info.GetBannerId().c_str());
}
- (void)assignOnlinePriceToLabel:(UILabel *)label

View file

@ -18,8 +18,7 @@ static NSString * const kStatAuthorization = @"Authorization";
static NSString * const kStatAutoDownload = @"Auto download";
static NSString * const kStatAutoZoom = @"Autozoom";
static NSString * const kStatBack = @"Back";
static NSString * const kStatBannerDescription = @"Banner description";
static NSString * const kStatBannerTitle = @"Banner title";
static NSString * const kStatBanner = @"banner";
static NSString * const kStatBicycle = @"Bicycle";
static NSString * const kStatBooking = @"Booking.com";
static NSString * const kStatBookmarks = @"Bookmarks";
@ -153,6 +152,8 @@ static NSString * const kStatOther = @"Other";
static NSString * const kStatOut = @"Out";
static NSString * const kStatPedestrian = @"Pedestrian";
static NSString * const kStatPlacePage = @"Place page";
static NSString * const kStatPlacePageBannerClick = @"Placepage_Banner_click";
static NSString * const kStatPlacePageBannerShow = @"Placepage_Banner_show";
static NSString * const kPlacePageHotelBook = @"Placepage_Hotel_book";
static NSString * const kPlacePageHotelDetails = @"Placepage_Hotel_details";
static NSString * const kStatPlacePageNonBuilding = @"placepage_nonbuilding";
@ -195,6 +196,7 @@ static NSString * const kStatSignup = @"Signup";
static NSString * const kStatSocial = @"Social";
static NSString * const kStatSource = @"Source";
static NSString * const kStatStart = @"Start";
static NSString * const kStatState = @"state";
static NSString * const kStatSwapRoutingPoints = @"Swap routing points";
static NSString * const kStatTTS = @"TTS";
static NSString * const kStatTTSSettings = @"TTS settings";

View file

@ -199,6 +199,13 @@ string Info::GetBannerUrl() const
return m_banner.GetFormattedUrl(m_metadata.Get(feature::Metadata::FMD_BANNER_URL));
}
string Info::GetBannerId() const
{
if (m_banner.IsEmpty())
return {};
return m_banner.GetId();
}
bool Info::IsReachableByTaxi() const
{
return IsReachableByTaxiChecker::Instance()(m_types);

View file

@ -84,6 +84,7 @@ public:
string GetBannerMessageId() const;
string GetBannerIconId() const;
string GetBannerUrl() const;
string GetBannerId() const;
bool IsReachableByTaxi() const;

@ -1 +1 @@
Subproject commit c32d9c5e22d6f42c582c2234e9881cda5f6db4f5
Subproject commit 1ffa4306fe949c6345414823946ee7b1bbf8a07e