forked from organicmaps/organicmaps
[ios] Booking stats.
This commit is contained in:
parent
4f4fad3f51
commit
0bd24ddcdb
6 changed files with 43 additions and 16 deletions
|
@ -65,6 +65,7 @@ using MWMPlacePageCellTypeValueMap = map<MWMPlacePageCellType, string>;
|
|||
- (m2::PointD const &)mercator;
|
||||
- (NSString *)apiURL;
|
||||
- (NSURL *)bookingUrl;
|
||||
- (NSString * )hotelId;
|
||||
- (string)titleForNewBookmark;
|
||||
|
||||
- (instancetype)initWithInfo:(place_page::Info const &)info;
|
||||
|
|
|
@ -255,6 +255,11 @@ void initFieldsMap()
|
|||
return m_info.IsSponsoredHotel();
|
||||
}
|
||||
|
||||
- (NSString * )hotelId
|
||||
{
|
||||
return self.isBooking ? @(m_info.GetMetadata().Get(Metadata::FMD_SPONSORED_ID).c_str()) : nil;
|
||||
}
|
||||
|
||||
- (ms::LatLon)latlon
|
||||
{
|
||||
return m_info.GetLatLon();
|
||||
|
|
|
@ -250,21 +250,16 @@ extern NSString * const kBookmarksChangedNotification;
|
|||
{
|
||||
NSMutableDictionary * stat = [@{kStatProvider : kStatBooking} mutableCopy];
|
||||
LocationManager * lm = MapsAppDelegate.theApp.locationManager;
|
||||
if (lm.lastLocationIsValid)
|
||||
{
|
||||
CLLocation * loc = lm.lastLocation;
|
||||
stat[kStatLat] = @(loc.coordinate.latitude);
|
||||
stat[kStatLon] = @(loc.coordinate.longitude);
|
||||
}
|
||||
else
|
||||
{
|
||||
stat[kStatLat] = @0;
|
||||
stat[kStatLon] = @0;
|
||||
}
|
||||
CLLocation * loc = lm.lastLocationIsValid ? lm.lastLocation : nil;
|
||||
MWMPlacePageEntity * en = self.entity;
|
||||
auto const latLon = en.latlon;
|
||||
stat[kStatHotel] = @{kStatName : en.title, kStatLat : @(latLon.lat), kStatLon : @(latLon.lon)};
|
||||
[Statistics logEvent:isDescription ? kPlacePageHotelDetails : kPlacePageHotelBook withParameters:stat];
|
||||
stat[kStatHotel] = en.hotelId;
|
||||
stat[kStatHotelLat] = @(latLon.lat);
|
||||
stat[kStatHotelLon] = @(latLon.lon);
|
||||
[Statistics logEvent:isDescription ? kPlacePageHotelDetails : kPlacePageHotelBook
|
||||
withParameters:stat
|
||||
atLocation:loc];
|
||||
|
||||
UIViewController * vc = static_cast<UIViewController *>(MapsAppDelegate.theApp.mapViewController);
|
||||
NSURL * url = isDescription ? [NSURL URLWithString:[self.entity getCellValue:MWMPlacePageCellTypeBookingMore]] : self.entity.bookingUrl;
|
||||
NSAssert(url, @"Booking url can't be nil!");
|
||||
|
|
|
@ -16,5 +16,6 @@
|
|||
+ (instancetype)instance;
|
||||
+ (void)logEvent:(NSString *)eventName;
|
||||
+ (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters;
|
||||
+ (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters atLocation:(CLLocation *)location;
|
||||
|
||||
@end
|
||||
|
|
|
@ -115,6 +115,25 @@ char const * kStatisticsEnabledSettingsKey = "StatisticsEnabled";
|
|||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
NSMutableDictionary * params = [self addDefaultAttributesToParameters:parameters];
|
||||
[Flurry logEvent:eventName withParameters:params];
|
||||
[Alohalytics logEvent:eventName withDictionary:params];
|
||||
}
|
||||
|
||||
- (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters atLocation:(CLLocation *)location
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
NSMutableDictionary * params = [self addDefaultAttributesToParameters:parameters];
|
||||
[Alohalytics logEvent:eventName withDictionary:params atLocation:location];
|
||||
auto const & coordinate = location ? location.coordinate : kCLLocationCoordinate2DInvalid;
|
||||
params[kStatLat] = @(coordinate.latitude);
|
||||
params[kStatLon] = @(coordinate.longitude);
|
||||
[Flurry logEvent:eventName withParameters:params];
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)addDefaultAttributesToParameters:(NSDictionary *)parameters
|
||||
{
|
||||
NSMutableDictionary * params = [parameters mutableCopy];
|
||||
params[kStatDeviceType] = IPAD ? kStatiPad : kStatiPhone;
|
||||
BOOL isLandscape = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation);
|
||||
|
@ -123,8 +142,7 @@ char const * kStatisticsEnabledSettingsKey = "StatisticsEnabled";
|
|||
params[kStatCountry] = info.countryCode;
|
||||
if (info.languageId)
|
||||
params[kStatLanguage] = info.languageId;
|
||||
[Flurry logEvent:eventName withParameters:parameters];
|
||||
[Alohalytics logEvent:eventName withDictionary:parameters];
|
||||
return params;
|
||||
}
|
||||
|
||||
- (void)logEvent:(NSString *)eventName
|
||||
|
@ -172,4 +190,9 @@ char const * kStatisticsEnabledSettingsKey = "StatisticsEnabled";
|
|||
[[self instance] logEvent:eventName withParameters:parameters];
|
||||
}
|
||||
|
||||
+ (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters atLocation:(CLLocation *)location
|
||||
{
|
||||
[[self instance] logEvent:eventName withParameters:parameters atLocation:location];
|
||||
}
|
||||
|
||||
@end
|
|
@ -101,7 +101,9 @@ static NSString * const kStatGoogle = @"Google";
|
|||
static NSString * const kStatHelp = @"Help";
|
||||
static NSString * const kStatHidden = @"Hidden";
|
||||
static NSString * const kStatHistory = @"History";
|
||||
static NSString * const kStatHotel = @"Hotel";
|
||||
static NSString * const kStatHotel = @"hotel";
|
||||
static NSString * const kStatHotelLat = @"hotel_lat";
|
||||
static NSString * const kStatHotelLon = @"hotel_lon";
|
||||
static NSString * const kStatImport = @"Import";
|
||||
static NSString * const kStatIn = @"In";
|
||||
static NSString * const kStatIsAuto = @"is_auto";
|
||||
|
|
Loading…
Add table
Reference in a new issue