Skip to content

Commit

Permalink
fix: networkConfig.requestTimeoutInSec change to requestTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed Nov 15, 2023
1 parent 1ba8d75 commit 8e88e61
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (void)testDefaultConfiguration_Autotracker {
XCTAssertEqual(configuration.encryptEnabled, NO);
XCTAssertEqual(configuration.impressionScale, 0);
XCTAssertEqualObjects(configuration.dataSourceId, nil);
XCTAssertEqualObjects(configuration.networkConfig, nil);
XCTAssertEqual(configuration.requestTimeout, 30);
}

- (void)testSetConfiguration_Autotracker {
Expand All @@ -136,9 +136,7 @@ - (void)testSetConfiguration_Autotracker {
config.encryptEnabled = YES;
config.impressionScale = 0.5;
config.dataSourceId = @"12345";
GrowingNetworkConfig *networkConfig = [GrowingNetworkConfig config];
networkConfig.requestTimeoutInSec = 0.3f;
config.networkConfig = networkConfig;
config.requestTimeout = 0.3f;
[GrowingRealAutotracker trackerWithConfiguration:config launchOptions:nil];

GrowingAutotrackConfiguration *configuration = (GrowingAutotrackConfiguration *)GrowingConfigurationManager.sharedInstance.trackConfiguration;
Expand All @@ -156,8 +154,7 @@ - (void)testSetConfiguration_Autotracker {
XCTAssertEqual(configuration.encryptEnabled, YES);
XCTAssertEqual(configuration.impressionScale, 0.5);
XCTAssertEqualObjects(configuration.dataSourceId, @"12345");
XCTAssertNotNil(configuration.networkConfig);
XCTAssertEqual(configuration.networkConfig.requestTimeoutInSec, 0.3f);
XCTAssertEqual(configuration.requestTimeout, 0.3f);
}

- (void)testDefaultConfiguration_Tracker {
Expand All @@ -178,7 +175,7 @@ - (void)testDefaultConfiguration_Tracker {
XCTAssertEqualObjects(configuration.urlScheme, nil);
XCTAssertEqual(configuration.encryptEnabled, NO);
XCTAssertEqualObjects(configuration.dataSourceId, nil);
XCTAssertEqualObjects(configuration.networkConfig, nil);
XCTAssertEqual(configuration.requestTimeout, 30);
}

- (void)testSetConfiguration_Tracker {
Expand All @@ -196,9 +193,7 @@ - (void)testSetConfiguration_Tracker {
config.urlScheme = @"growing.tracker";
config.encryptEnabled = YES;
config.dataSourceId = @"12345";
GrowingNetworkConfig *networkConfig = [GrowingNetworkConfig config];
networkConfig.requestTimeoutInSec = 0.3f;
config.networkConfig = networkConfig;
config.requestTimeout = 0.3f;
[GrowingRealTracker trackerWithConfiguration:config launchOptions:nil];

GrowingTrackConfiguration *configuration = GrowingConfigurationManager.sharedInstance.trackConfiguration;
Expand All @@ -215,8 +210,7 @@ - (void)testSetConfiguration_Tracker {
XCTAssertEqualObjects(configuration.urlScheme, @"growing.tracker");
XCTAssertEqual(configuration.encryptEnabled, YES);
XCTAssertEqualObjects(configuration.dataSourceId, @"12345");
XCTAssertNotNil(configuration.networkConfig);
XCTAssertEqual(configuration.networkConfig.requestTimeoutInSec, 0.3f);
XCTAssertEqual(configuration.requestTimeout, 0.3f);
}

- (void)testVersionNameAndVersionCode {
Expand Down
25 changes: 23 additions & 2 deletions GrowingTrackerCore/GrowingTrackConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ - (instancetype)initWithProjectId:(NSString *)projectId {
_idMappingEnabled = NO;
_urlScheme = nil;
_encryptEnabled = NO;
_networkConfig = nil;
_requestTimeout = 30;

// Advert
_ASAEnabled = NO;
Expand Down Expand Up @@ -90,7 +90,7 @@ - (id)copyWithZone:(NSZone *)zone {
configuration->_idMappingEnabled = _idMappingEnabled;
configuration->_urlScheme = _urlScheme;
configuration->_encryptEnabled = _encryptEnabled;
configuration->_networkConfig = [_networkConfig copy];
configuration->_requestTimeout = _requestTimeout;

// Advert
configuration->_ASAEnabled = _ASAEnabled;
Expand All @@ -103,4 +103,25 @@ - (id)copyWithZone:(NSZone *)zone {
return configuration;
}

- (void)setDataUploadInterval:(NSTimeInterval)dataUploadInterval {
if (dataUploadInterval <= 0) {
return;
}
_dataUploadInterval = dataUploadInterval;
}

- (void)setSessionInterval:(NSTimeInterval)sessionInterval {
if (sessionInterval <= 0) {
return;
}
_sessionInterval = sessionInterval;
}

- (void)setRequestTimeout:(NSTimeInterval)requestTimeout {
if (requestTimeout <= 0) {
return;
}
_requestTimeout = requestTimeout;
}

@end
7 changes: 1 addition & 6 deletions GrowingTrackerCore/Network/Request/GrowingEventRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#import "GrowingTrackerCore/Manager/GrowingConfigurationManager.h"
#import "GrowingTrackerCore/Network/Request/Adapter/GrowingEventRequestAdapters.h"
#import "GrowingTrackerCore/Network/Request/Adapter/GrowingRequestAdapter.h"
#import "GrowingTrackerCore/Public/GrowingNetworkConfig.h"
#import "GrowingULTimeUtil.h"

@implementation GrowingEventRequest
Expand Down Expand Up @@ -76,11 +75,7 @@ - (NSDictionary *)query {
}

- (NSTimeInterval)timeoutInSeconds {
GrowingNetworkConfig *networkConfig = GrowingConfigurationManager.sharedInstance.trackConfiguration.networkConfig;
if (networkConfig && networkConfig.requestTimeoutInSec > 0) {
return networkConfig.requestTimeoutInSec;
}
return 60.0f;
return [GrowingConfigurationManager sharedInstance].trackConfiguration.requestTimeout;
}

@end
34 changes: 0 additions & 34 deletions GrowingTrackerCore/Network/Request/GrowingNetworkConfig.m

This file was deleted.

28 changes: 0 additions & 28 deletions GrowingTrackerCore/Public/GrowingNetworkConfig.h

This file was deleted.

3 changes: 1 addition & 2 deletions GrowingTrackerCore/Public/GrowingTrackConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#import <Foundation/Foundation.h>
#import "GrowingEventFilter.h"
#import "GrowingFieldsIgnore.h"
#import "GrowingNetworkConfig.h"

FOUNDATION_EXPORT NSString *const kGrowingDefaultDataCollectionServerHost;

Expand All @@ -40,7 +39,7 @@ FOUNDATION_EXPORT NSString *const kGrowingDefaultDataCollectionServerHost;
@property (nonatomic, assign) BOOL idMappingEnabled;
@property (nonatomic, copy) NSString *urlScheme;
@property (nonatomic, assign) BOOL encryptEnabled;
@property (nonatomic, copy) GrowingNetworkConfig *networkConfig;
@property (nonatomic, assign) NSTimeInterval requestTimeout;

- (instancetype)initWithProjectId:(NSString *)projectId;

Expand Down

0 comments on commit 8e88e61

Please sign in to comment.