Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions Example/Core/Tests/FIRAnalyticsConfigurationTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#import "FIRTestCase.h"

#import <FirebaseCore/FIRAnalyticsConfiguration+Internal.h>
#import <FirebaseCore/FIRAnalyticsConfiguration.h>

@interface FIRAnalyticsConfigurationTest : FIRTestCase
Expand Down Expand Up @@ -48,73 +47,6 @@ - (void)testSharedInstance {
XCTAssertNotNil(analyticsConfig);
}

/// Test that setting the minimum session interval on the singleton fires a notification.
- (void)testMinimumSessionIntervalNotification {
// Pick a value to set as the session interval and verify it's in the userInfo dictionary of the
// posted notification.
NSNumber *sessionInterval = @2601;

// Set up the expectation for the notification.
FIRAnalyticsConfiguration *config = [FIRAnalyticsConfiguration sharedInstance];
NSString *notificationName = kFIRAnalyticsConfigurationSetMinimumSessionIntervalNotification;
[self expectNotificationForObserver:self.observerMock
notificationName:notificationName
object:config
userInfo:@{notificationName : sessionInterval}];

// Trigger the notification.
[config setMinimumSessionInterval:[sessionInterval integerValue]];

// Verify the observer mock.
OCMVerifyAll(self.observerMock);
}

/// Test that setting the minimum session timeout interval on the singleton fires a notification.
- (void)testSessionTimeoutIntervalNotification {
// Pick a value to set as the timeout interval and verify it's in the userInfo dictionary of the
// posted notification.
NSNumber *timeoutInterval = @1000;

// Set up the expectation for the notification.
FIRAnalyticsConfiguration *config = [FIRAnalyticsConfiguration sharedInstance];
NSString *notificationName = kFIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification;
[self expectNotificationForObserver:self.observerMock
notificationName:notificationName
object:config
userInfo:@{notificationName : timeoutInterval}];

// Trigger the notification.
[config setSessionTimeoutInterval:[timeoutInterval integerValue]];

/// Verify the observer mock.
OCMVerifyAll(self.observerMock);
}

- (void)testSettingAnalyticsCollectionEnabled {
// Test setting to enabled. The ordering matters for these notifications.
FIRAnalyticsConfiguration *config = [FIRAnalyticsConfiguration sharedInstance];
NSString *notificationName = kFIRAnalyticsConfigurationSetEnabledNotification;
[self.notificationCenter addMockObserver:self.observerMock name:notificationName object:config];

[self.observerMock setExpectationOrderMatters:YES];
[[self.observerMock expect] notificationWithName:notificationName
object:config
userInfo:@{notificationName : @YES}];

// Test setting to enabled.
[config setAnalyticsCollectionEnabled:YES];

// Expect the second notification.
[[self.observerMock expect] notificationWithName:notificationName
object:config
userInfo:@{notificationName : @NO}];

// Test setting to disabled.
[config setAnalyticsCollectionEnabled:NO];

OCMVerifyAll(self.observerMock);
}

- (void)testSettingAnalyticsCollectionPersistence {
id userDefaultsMock = OCMPartialMock([NSUserDefaults standardUserDefaults]);
FIRAnalyticsConfiguration *config = [FIRAnalyticsConfiguration sharedInstance];
Expand Down
2 changes: 1 addition & 1 deletion Example/Core/Tests/FIRAppTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "FIRTestCase.h"
#import "FIRTestComponents.h"

#import <FirebaseCore/FIRAnalyticsConfiguration+Internal.h>
#import <FirebaseCore/FIRAnalyticsConfiguration.h>
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIROptionsInternal.h>

Expand Down
2 changes: 1 addition & 1 deletion Example/Core/Tests/FIRConfigurationTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import "FIRConfiguration.h"
#import <FirebaseCore/FIRConfigurationInternal.h>

#import "FIRTestCase.h"

Expand Down
18 changes: 2 additions & 16 deletions Firebase/Core/FIRAnalyticsConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import "FIRAnalyticsConfiguration.h"
#import <Foundation/Foundation.h>

#import "Private/FIRAnalyticsConfiguration+Internal.h"
#import "FIRAnalyticsConfiguration.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
Expand All @@ -39,20 +39,6 @@ - (void)postNotificationName:(NSString *)name value:(id)value {
userInfo:@{name : value}];
}

- (void)setMinimumSessionInterval:(NSTimeInterval)minimumSessionInterval {
[self postNotificationName:kFIRAnalyticsConfigurationSetMinimumSessionIntervalNotification
value:@(minimumSessionInterval)];
}

- (void)setSessionTimeoutInterval:(NSTimeInterval)sessionTimeoutInterval {
[self postNotificationName:kFIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification
value:@(sessionTimeoutInterval)];
}

- (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled {
[self setAnalyticsCollectionEnabled:analyticsCollectionEnabled persistSetting:YES];
}

- (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled
persistSetting:(BOOL)shouldPersist {
// Persist the measurementEnabledState. Use FIRAnalyticsEnabledState values instead of YES/NO.
Expand Down
4 changes: 2 additions & 2 deletions Firebase/Core/FIRApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include <sys/utsname.h>

#import "FIRApp.h"
#import "FIRConfiguration.h"
#import "Private/FIRAnalyticsConfiguration+Internal.h"
#import "Private/FIRAnalyticsConfiguration.h"
#import "Private/FIRAppInternal.h"
#import "Private/FIRBundleUtil.h"
#import "Private/FIRComponentContainerInternal.h"
#import "Private/FIRConfigurationInternal.h"
#import "Private/FIRLibrary.h"
#import "Private/FIRLogger.h"
#import "Private/FIROptionsInternal.h"
Expand Down
8 changes: 4 additions & 4 deletions Firebase/Core/FIRConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import "FIRConfiguration.h"
#import "FIRConfigurationInternal.h"
#import "Private/FIRConfigurationInternal.h"

#import "FIRAnalyticsConfiguration.h"

extern void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);

Expand All @@ -30,10 +33,7 @@ + (instancetype)sharedInstance {
- (instancetype)init {
self = [super init];
if (self) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
_analyticsConfiguration = [FIRAnalyticsConfiguration sharedInstance];
#pragma clang diagnostic pop
}
return self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#import "FIRAnalyticsConfiguration.h"
#import <Foundation/Foundation.h>

/// Values stored in analyticsEnabledState. Never alter these constants since they must match with
/// values persisted to disk.
Expand All @@ -38,7 +38,10 @@ static NSString *const kFIRAnalyticsConfigurationSetMinimumSessionIntervalNotifi
static NSString *const kFIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification =
@"FIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification";

@interface FIRAnalyticsConfiguration (Internal)
@interface FIRAnalyticsConfiguration : NSObject

/// Returns the shared instance of FIRAnalyticsConfiguration.
+ (FIRAnalyticsConfiguration *)sharedInstance;

/// Sets whether analytics collection is enabled for this app on this device, and a flag to persist
/// the value or not. The setting should not be persisted if being set by the global data collection
Expand Down
29 changes: 29 additions & 0 deletions Firebase/Core/Private/FIRConfigurationInternal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2019 Google
*
* 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 "FIRConfiguration.h"

@class FIRAnalyticsConfiguration;

@interface FIRConfiguration ()

/**
* The configuration class for Firebase Analytics. This should be removed once the logic for
* enabling and disabling Analytics is moved to Analytics.
*/
@property(nonatomic, readwrite) FIRAnalyticsConfiguration *analyticsConfiguration;

@end
56 changes: 0 additions & 56 deletions Firebase/Core/Public/FIRAnalyticsConfiguration.h

This file was deleted.

9 changes: 1 addition & 8 deletions Firebase/Core/Public/FIRConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,19 @@

#import <Foundation/Foundation.h>

#import "FIRAnalyticsConfiguration.h"
#import "FIRLoggerLevel.h"

NS_ASSUME_NONNULL_BEGIN

/**
* This interface provides global level properties that the developer can tweak, and the singleton
* of the Firebase Analytics configuration class.
* This interface provides global level properties that the developer can tweak.
*/
NS_SWIFT_NAME(FirebaseConfiguration)
@interface FIRConfiguration : NSObject

/** Returns the shared configuration object. */
@property(class, nonatomic, readonly) FIRConfiguration *sharedInstance NS_SWIFT_NAME(shared);

/** The configuration class for Firebase Analytics. */
@property(nonatomic, readwrite)
FIRAnalyticsConfiguration *analyticsConfiguration DEPRECATED_MSG_ATTRIBUTE(
"Use the methods available here directly on the `Analytics` class.");

/**
* Sets the logging level for internal Firebase logging. Firebase will only log messages
* that are logged at or below loggerLevel. The messages are logged both to the Xcode
Expand Down
1 change: 0 additions & 1 deletion Firebase/Core/Public/FirebaseCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

#import "FIRAnalyticsConfiguration.h"
#import "FIRApp.h"
#import "FIRConfiguration.h"
#import "FIRLoggerLevel.h"
Expand Down