Skip to content

Commit

Permalink
Merge branch 'release/8.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Aug 23, 2023
2 parents 438f5cf + d37b1d7 commit c92014c
Show file tree
Hide file tree
Showing 23 changed files with 207 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Version information
MARKETING_VERSION = 8.1.0
MARKETING_VERSION = 8.2.0

// Deployment targets
IPHONEOS_DEPLOYMENT_TARGET = 12.0
Expand Down
5 changes: 4 additions & 1 deletion Demo/SRGAnalytics-demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@
9F1518B31AC2F1CE00AE051D /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
CLASSPREFIX = SRG;
LastUpgradeCheck = 1400;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "SRG SSR";
TargetAttributes = {
E6FC7E871D61F95C00A55085 = {
Expand Down Expand Up @@ -343,6 +344,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -402,6 +404,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1430"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
"repositoryURL": "https://github.com/SRGSSR/srgmediaplayer-apple.git",
"state": {
"branch": null,
"revision": "63a8b41213360f625f2171a18718a7e5f14c4874",
"version": "7.2.0"
"revision": "717608146d3787bd269d5a524e109ee30be828e4",
"version": "7.2.1"
}
},
{
Expand Down
21 changes: 19 additions & 2 deletions Demo/Sources/Application/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
@import SRGLogger;
@import TCCore;

@interface AppDelegate() <SRGAnalyticsTrackerDataSource>
@end

@implementation AppDelegate

#pragma mark Application lifecycle
Expand All @@ -31,8 +34,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
SRGAnalyticsConfiguration *configuration = [[SRGAnalyticsConfiguration alloc] initWithBusinessUnitIdentifier:SRGAnalyticsBusinessUnitIdentifierRTS
container:10
siteName:@"rts-app-test-v"];
[SRGAnalyticsTracker.sharedTracker startWithConfiguration:configuration identityService:SRGIdentityService.currentIdentityService];

[SRGAnalyticsTracker.sharedTracker startWithConfiguration:configuration
dataSource:self
identityService:SRGIdentityService.currentIdentityService];

if (@available(iOS 13, tvOS 13, *)) {}
else {
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
Expand All @@ -47,4 +52,16 @@ - (UISceneConfiguration *)application:(UIApplication *)application configuration
return [[UISceneConfiguration alloc] initWithName:@"Default" sessionRole:connectingSceneSession.role];
}

- (SRGAnalyticsLabels *)srg_globalLabels
{
SRGAnalyticsLabels *labels = [[SRGAnalyticsLabels alloc] init];
labels.comScoreCustomInfo = @{
@"cs_ucfr": @"1"
};
labels.customInfo = @{
@"consent_services": @"service1,service2,service3"
};
return labels;
}

@end
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
"repositoryURL": "https://github.com/SRGSSR/srgmediaplayer-apple.git",
"state": {
"branch": null,
"revision": "63a8b41213360f625f2171a18718a7e5f14c4874",
"version": "7.2.0"
"revision": "717608146d3787bd269d5a524e109ee30be828e4",
"version": "7.2.1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import PackageDescription

struct ProjectSettings {
static let marketingVersion: String = "8.1.0"
static let marketingVersion: String = "8.2.0"
}

let package = Package(
Expand Down
1 change: 1 addition & 0 deletions Sources/SRGAnalytics/SRGAnalyticsTracker+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SRGAnalyticsTracker (Private)

@property (nonatomic, nullable) SRGAnalyticsLabels *globalLabels;
@property (nonatomic, nullable) SRGAnalyticsLabels *dataSourceLabels;

- (void)trackPageViewWithTitle:(NSString *)title
levels:(nullable NSArray<NSString *> *)levels
Expand Down
58 changes: 46 additions & 12 deletions Sources/SRGAnalytics/SRGAnalyticsTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void SRGAnalyticsRenewUnitTestingIdentifier(void)
@interface SRGAnalyticsTracker ()

@property (nonatomic, copy) SRGAnalyticsConfiguration *configuration;
@property (nonatomic, weak) id<SRGAnalyticsTrackerDataSource> dataSource;

@property (nonatomic) TagCommander *tagCommander;
@property (nonatomic) SCORStreamingAnalytics *streamSense;
Expand All @@ -66,14 +67,21 @@ + (instancetype)sharedTracker
#pragma mark Startup

- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
{
[self startWithConfiguration:configuration dataSource:nil];
}

- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
dataSource:(id<SRGAnalyticsTrackerDataSource>)dataSource
{
if (self.configuration) {
SRGAnalyticsLogWarning(@"tracker", @"The tracker is already started");
return;
}

self.configuration = configuration;

self.dataSource = dataSource;

if (configuration.unitTesting) {
SRGAnalyticsEnableRequestInterceptor();
}
Expand All @@ -82,14 +90,11 @@ - (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
builder.publisherId = @"6036016";
builder.secureTransmissionEnabled = YES;
builder.persistentLabels = [self persistentComScoreLabels];

builder.startLabels = [self defaultComScoreLabels];

// See https://confluence.srg.beecollaboration.com/display/INTFORSCHUNG/ComScore+-+Media+Metrix+Report
// Coding Document for Video Players, page 16
builder.httpRedirectCachingEnabled = NO;

if (configuration.unitTesting) {
builder.startLabels = @{ @"srg_test_id" : SRGAnalyticsUnitTestingIdentifier() };
}
}];

SCORConfiguration *comScoreConfiguration = [SCORAnalytics configuration];
Expand All @@ -106,22 +111,51 @@ - (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration

#pragma mark Labels

- (NSDictionary *)persistentComScoreLabels
- (NSDictionary<NSString *, NSString *> *)persistentComScoreLabels
{
NSMutableDictionary *labels = [NSMutableDictionary dictionary];
NSMutableDictionary<NSString *, NSString *> *labels = [NSMutableDictionary dictionary];
labels[@"mp_v"] = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
labels[@"mp_brand"] = self.configuration.businessUnitIdentifier.uppercaseString;
return labels.copy;
}

- (NSDictionary *)defaultComScoreLabels
- (NSDictionary<NSString *, NSString *> *)defaultComScoreLabels
{
return self.globalLabels.comScoreLabelsDictionary ?: [NSDictionary dictionary];
NSMutableDictionary<NSString *, NSString *> *labels = [NSMutableDictionary dictionary];

NSDictionary<NSString *, NSString *> *globalLabels = self.globalLabels.comScoreLabelsDictionary;
if (globalLabels) {
[labels addEntriesFromDictionary:globalLabels];
}

NSDictionary<NSString *, NSString *> *dataSourceLabels = self.dataSource.srg_globalLabels.comScoreLabelsDictionary;
if (dataSourceLabels) {
[labels addEntriesFromDictionary:dataSourceLabels];
}

return labels.copy;
}

- (NSDictionary<NSString *, NSString *> *)defaultLabels
{
NSMutableDictionary<NSString *, NSString *> *labels = [NSMutableDictionary dictionary];

NSDictionary<NSString *, NSString *> *globalLabels = self.globalLabels.labelsDictionary;
if (globalLabels) {
[labels addEntriesFromDictionary:globalLabels];
}

NSDictionary<NSString *, NSString *> *dataSourceLabels = self.dataSourceLabels.labelsDictionary;
if (dataSourceLabels) {
[labels addEntriesFromDictionary:dataSourceLabels];
}

return labels.copy;
}

- (NSDictionary *)defaultLabels
- (SRGAnalyticsLabels *)dataSourceLabels
{
return self.globalLabels.labelsDictionary ?: [NSDictionary dictionary];
return self.dataSource.srg_globalLabels;
}

- (NSString *)pageIdWithTitle:(NSString *)title levels:(NSArray<NSString *> *)levels
Expand Down
12 changes: 12 additions & 0 deletions Sources/SRGAnalytics/include/SRGAnalyticsTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import "SRGAnalyticsConfiguration.h"
#import "SRGAnalyticsHiddenEventLabels.h"
#import "SRGAnalyticsPageViewLabels.h"
#import "SRGAnalyticsTrackerDataSource.h"

@import Foundation;

Expand Down Expand Up @@ -78,6 +79,17 @@ NS_EXTENSION_UNAVAILABLE("SRG Analytics does not support application extensions"
*/
- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration;

/**
* Start the tracker. This is required to specify for which business unit you are tracking events, as well as to
* where they must be sent on the comScore and TagCommander services. Attempting to track view, hidden or stream
* events without starting the tracker has no effect.
*
* @param configuration The configuration to use. This configuration is copied and cannot be changed afterwards.
* @param dataSource The data source for the global labels.
*/
- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
dataSource:(nullable id<SRGAnalyticsTrackerDataSource>)dataSource;

/**
* The tracker configuration with which the tracker was started.
*/
Expand Down
17 changes: 17 additions & 0 deletions Sources/SRGAnalytics/include/SRGAnalyticsTrackerDataSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import "SRGAnalyticsLabels.h"

NS_ASSUME_NONNULL_BEGIN

@protocol SRGAnalyticsTrackerDataSource <NSObject>

@property (nonatomic, readonly, copy) SRGAnalyticsLabels *srg_globalLabels;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ @implementation SRGAnalyticsTracker (SRGAnalyticsIdentity)

#pragma mark Startup

- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration identityService:(SRGIdentityService *)identityService
- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
identityService:(SRGIdentityService *)identityService
{
[self startWithConfiguration:configuration dataSource:nil identityService:identityService];
}

- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
dataSource:(id<SRGAnalyticsTrackerDataSource>)dataSource
identityService:(SRGIdentityService *)identityService
{
self.identityService = identityService;
[self startWithConfiguration:configuration];
[self startWithConfiguration:configuration dataSource:dataSource];
}

#pragma mark Getters and Setters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
identityService:(nullable SRGIdentityService *)identityService;
/**
* Start the tracker. Same as `-startWithConfiguration:` SRGAnalyticsTracker method, with an optional identity service.
*
* @param configuration The configuration to use. This configuration is copied and cannot be changed afterwards.
* @param dataSource The data source for the global labels.
* @param identityService The service which identities can be retrieved from.
*/
- (void)startWithConfiguration:(SRGAnalyticsConfiguration *)configuration
dataSource:(nullable id<SRGAnalyticsTrackerDataSource>)dataSource
identityService:(nullable SRGIdentityService *)identityService;

/**
* The identity service associated with the tracker, if any.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "SRGAnalyticsLabels+Private.h"
#import "SRGAnalyticsMediaPlayerLogger.h"
#import "SRGAnalyticsStreamLabels.h"
#import "SRGAnalyticsTracker+Private.h"
#import "SRGMediaAnalytics.h"
#import "SRGMediaPlayerController+SRGAnalyticsMediaPlayer.h"

Expand Down Expand Up @@ -77,7 +78,12 @@ + (SCORStreamingAnalytics *)streamingAnalyticsForMediaPlayerController:(SRGMedia

SCORStreamingContentMetadata *streamingMetadata = [SCORStreamingContentMetadata contentMetadataWithBuilderBlock:^(SCORStreamingContentMetadataBuilder *builder) {
NSMutableDictionary<NSString *, NSString *> *customLabels = [labelsDictionary mutableCopy];


NSDictionary<NSString *, NSString *> *dataSourceLabels = SRGAnalyticsTracker.sharedTracker.dataSourceLabels.comScoreCustomInfo;
if (dataSourceLabels) {
[customLabels addEntriesFromDictionary:dataSourceLabels];
}

if (SRGAnalyticsTracker.sharedTracker.configuration.unitTesting) {
customLabels[@"srg_test_id"] = SRGAnalyticsUnitTestingIdentifier();
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/SRGAnalyticsIdentity-tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@
9F1518B31AC2F1CE00AE051D /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
CLASSPREFIX = SRG;
LastUpgradeCheck = 1400;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "SRG SSR";
TargetAttributes = {
08EF593B2221B7B4000E7446 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
"repositoryURL": "https://github.com/SRGSSR/srgmediaplayer-apple.git",
"state": {
"branch": null,
"revision": "63a8b41213360f625f2171a18718a7e5f14c4874",
"version": "7.2.0"
"revision": "717608146d3787bd269d5a524e109ee30be828e4",
"version": "7.2.1"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions Tests/SRGAnalyticsTests/ComScoreMediaPlayerTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ - (void)testCommonLabels
XCTAssertEqualObjects(labels[@"ns_st_mv"], SRGMediaPlayerMarketingVersion());
XCTAssertEqualObjects(labels[@"ns_st_it"], @"c");
XCTAssertEqualObjects(labels[@"test_label"], @"test_value");
XCTAssertEqualObjects(labels[@"cs_ucfr"], @"1");
return YES;
}];

Expand Down
1 change: 1 addition & 0 deletions Tests/SRGAnalyticsTests/MediaPlayerTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ - (void)testCommonLabels
XCTAssertEqualObjects(labels[@"media_player_display"], @"SRGMediaPlayer");
XCTAssertEqualObjects(labels[@"media_player_version"], SRGMediaPlayerMarketingVersion());
XCTAssertEqualObjects(labels[@"test_label"], @"test_value");
XCTAssertEqualObjects(labels[@"consent_services"], @"service1,service2,service3");
return YES;
}];

Expand Down
Loading

0 comments on commit c92014c

Please sign in to comment.