Skip to content

Commit

Permalink
Send app language in NetMetrix request headers
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Aug 28, 2017
1 parent 84d213d commit e4dc805
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Framework/Sources/Core/SRGAnalyticsNetMetrixTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ - (void)trackView
NSString *userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (iOS-%@; U; CPU %@ like Mac OS X)", self.device, self.operatingSystem];
[request setValue:userAgent forHTTPHeaderField:@"User-Agent"];

// The app language must be sent, not the device language. This is sadly not documented in https://www.net-metrix.ch/fr/service/directives/directives-supplementaires-pour-les-applications,
// but this information was obtained from a NetMetrix technician.
[request setValue:[NSBundle mainBundle].preferredLocalizations.firstObject forHTTPHeaderField:@"Accept-Language"];

SRGAnalyticsLogDebug(@"NetMetrix", @"Request %@ started", request.URL);
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
SRGAnalyticsLogDebug(@"NetMetrix", @"Request %@ ended with error %@", request.URL, error);
Expand Down

0 comments on commit e4dc805

Please sign in to comment.