Skip to content

Commit

Permalink
fix: rename projectId to accountId (#285)
Browse files Browse the repository at this point in the history
* fix: rename projectId to accountId

* style: code format

* ci: update ci

---------

Co-authored-by: GIOSDK <[email protected]>
  • Loading branch information
YoloMao and GIOSDK authored Oct 20, 2023
1 parent f807243 commit 0de68d1
Show file tree
Hide file tree
Showing 28 changed files with 233 additions and 67 deletions.
4 changes: 4 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
34BF77C92795571000CA18BA /* MockEventQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4962653324DA66B600032551 /* MockEventQueue.m */; };
34BF77CB279562AC00CA18BA /* ManualTrackHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4962653224DA66B600032551 /* ManualTrackHelper.m */; };
34C0BF3A277EA7C90047ADC4 /* DataTrafficTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 34C0BF39277EA7C90047ADC4 /* DataTrafficTest.m */; };
34ECD0FF2AE22F3A00DA3EBD /* GrowingAnalyticsStartTests2.m in Sources */ = {isa = PBXBuildFile; fileRef = 34ECD0FE2AE22F3A00DA3EBD /* GrowingAnalyticsStartTests2.m */; };
34ECFDBF2A5C082A0059F87C /* GrowingAutotrackPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34ECFDBE2A5C082A0059F87C /* GrowingAutotrackPageViewController.m */; };
34FCF7E12A937ECA009611B3 /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34FCF7E02A937ECA009611B3 /* SwiftUIView.swift */; };
34FCF7E42A937F4F009611B3 /* GIOSwiftUIContentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34FCF7E32A937F4F009611B3 /* GIOSwiftUIContentViewController.m */; };
Expand Down Expand Up @@ -408,6 +409,7 @@
34BF77C52795568B00CA18BA /* GrowingKeyChainTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GrowingKeyChainTest.m; sourceTree = "<group>"; };
34C0BF39277EA7C90047ADC4 /* DataTrafficTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DataTrafficTest.m; sourceTree = "<group>"; };
34C0BF3C277EA9BA0047ADC4 /* MobileDebuggerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MobileDebuggerTest.m; sourceTree = "<group>"; };
34ECD0FE2AE22F3A00DA3EBD /* GrowingAnalyticsStartTests2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GrowingAnalyticsStartTests2.m; sourceTree = "<group>"; };
34ECFDBD2A5C082A0059F87C /* GrowingAutotrackPageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GrowingAutotrackPageViewController.h; sourceTree = "<group>"; };
34ECFDBE2A5C082A0059F87C /* GrowingAutotrackPageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GrowingAutotrackPageViewController.m; sourceTree = "<group>"; };
34F94ED82A938725002CB9FC /* Example-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Example-Bridging-Header.h"; path = "Example/Example-Bridging-Header.h"; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -982,6 +984,7 @@
isa = PBXGroup;
children = (
34AB4E49279000F5002549FF /* GrowingAnalyticsStartTests.m */,
34ECD0FE2AE22F3A00DA3EBD /* GrowingAnalyticsStartTests2.m */,
);
path = GrowingAnalyticsStartTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -2224,6 +2227,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
34ECD0FF2AE22F3A00DA3EBD /* GrowingAnalyticsStartTests2.m in Sources */,
34AB4E4A279000F5002549FF /* GrowingAnalyticsStartTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

- (void)SDK3rdStart {
GrowingSDKConfiguration *configuration = [GrowingSDKConfiguration configurationWithProjectId:@"0a1b4118dd954ec3bcc69da5138bdb96"];
GrowingSDKConfiguration *configuration = [GrowingSDKConfiguration configurationWithAccountId:@"0a1b4118dd954ec3bcc69da5138bdb96"];
configuration.debugEnabled = YES;
configuration.idMappingEnabled = YES;
configuration.dataSourceId = @"ab555003531e0fd1";
Expand Down
4 changes: 1 addition & 3 deletions Example/ExampleiOS13/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
@import GrowingAnalytics;
#import "GrowingAdvertising.h"

static NSString *const kGrowingProjectId = @"bc675c65b3b0290e";

@interface AppDelegate ()

@end
Expand All @@ -33,7 +31,7 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
GrowingAutotrackConfiguration *configuration = [GrowingAutotrackConfiguration configurationWithProjectId:kGrowingProjectId];
GrowingAutotrackConfiguration *configuration = [GrowingAutotrackConfiguration configurationWithAccountId:@"bc675c65b3b0290e"];
configuration.dataSourceId = @"1234567890";
configuration.debugEnabled = YES;
// 暂时设置host为mocky链接,防止请求404,实际是没有上传到服务器的,正式使用请去掉,或设置正确的host
Expand Down
2 changes: 1 addition & 1 deletion Example/GrowingAnalyticsTests/A0GrowingAnalyticsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ - (void)growingEventManagerEventDidBuild:(GrowingBaseEvent *)event {
- (void)test01InitializedSuccessfully {
XCTAssertFalse([GrowingAutotracker isInitializedSuccessfully]);

GrowingAutotrackConfiguration *configuration = [GrowingAutotrackConfiguration configurationWithProjectId:@"test"];
GrowingAutotrackConfiguration *configuration = [GrowingAutotrackConfiguration configurationWithAccountId:@"test"];
configuration.dataSourceId = @"test";
configuration.idMappingEnabled = YES;
configuration.sessionInterval = 3.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
@implementation NSNotificationCenterAutotrackTest

+ (void)setUp {
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithAccountId:@"test"];
// 避免不执行readPropertyInTrackThread
config.dataCollectionEnabled = YES;
GrowingConfigurationManager.sharedInstance.trackConfiguration = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ @interface UICollectionViewAutotrackTest : XCTestCase <UICollectionViewDelegate>
@implementation UICollectionViewAutotrackTest

+ (void)setUp {
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithAccountId:@"test"];
// 避免不执行readPropertyInTrackThread
config.dataCollectionEnabled = YES;
GrowingConfigurationManager.sharedInstance.trackConfiguration = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ @interface UITableViewAutotrackTest : XCTestCase <UITableViewDelegate>
@implementation UITableViewAutotrackTest

+ (void)setUp {
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithAccountId:@"test"];
// 避免不执行readPropertyInTrackThread
config.dataCollectionEnabled = YES;
GrowingConfigurationManager.sharedInstance.trackConfiguration = config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)tearDown {
- (void)testGrowingTrackerStart {
XCTAssertThrowsSpecificNamed(GrowingTracker.sharedInstance, NSException, @"GrowingTracker未初始化");

GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"xctest"];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithAccountId:@"xctest"];
XCTAssertThrowsSpecificNamed([GrowingTracker startWithConfiguration:config launchOptions:nil],
NSException,
@"初始化异常");
Expand All @@ -64,16 +64,21 @@ - (void)testGrowingTrackerStart {
}
waitUntilDone:YES];

GrowingTrackConfiguration *config2 = [GrowingTrackConfiguration configurationWithProjectId:@""];
GrowingTrackConfiguration *config2 = [GrowingTrackConfiguration configurationWithAccountId:@""];
XCTAssertThrowsSpecificNamed([GrowingTracker startWithConfiguration:config2 launchOptions:nil],
NSException,
@"初始化异常");

GrowingTrackConfiguration *config3 = [GrowingTrackConfiguration configurationWithAccountId:nil];
XCTAssertThrowsSpecificNamed([GrowingTracker startWithConfiguration:config3 launchOptions:nil],
NSException,
@"初始化异常");
}

- (void)testGrowingAutotrackerStart {
XCTAssertThrowsSpecificNamed(GrowingAutotracker.sharedInstance, NSException, @"GrowingAutotracker未初始化");

GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithProjectId:@"xctest"];
GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithAccountId:@"xctest"];
XCTAssertThrowsSpecificNamed([GrowingAutotracker startWithConfiguration:config launchOptions:nil],
NSException,
@"初始化异常");
Expand All @@ -89,16 +94,21 @@ - (void)testGrowingAutotrackerStart {
}
waitUntilDone:YES];

GrowingAutotrackConfiguration *config2 = [GrowingAutotrackConfiguration configurationWithProjectId:@""];
GrowingAutotrackConfiguration *config2 = [GrowingAutotrackConfiguration configurationWithAccountId:@""];
XCTAssertThrowsSpecificNamed([GrowingAutotracker startWithConfiguration:config2 launchOptions:nil],
NSException,
@"初始化异常");

GrowingAutotrackConfiguration *config3 = [GrowingAutotrackConfiguration configurationWithAccountId:nil];
XCTAssertThrowsSpecificNamed([GrowingAutotracker startWithConfiguration:config3 launchOptions:nil],
NSException,
@"初始化异常");
}

#pragma clang diagnostic pop

- (void)testDefaultConfiguration_Autotracker {
GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithProjectId:@"test"];
GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithAccountId:@"test"];
[GrowingRealAutotracker trackerWithConfiguration:config launchOptions:nil];

GrowingAutotrackConfiguration *configuration =
Expand All @@ -120,7 +130,7 @@ - (void)testDefaultConfiguration_Autotracker {
}

- (void)testSetConfiguration_Autotracker {
GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithProjectId:@"test"];
GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithAccountId:@"test"];
config.debugEnabled = YES;
config.cellularDataLimit = 5;
config.dataUploadInterval = 10;
Expand Down Expand Up @@ -156,7 +166,7 @@ - (void)testSetConfiguration_Autotracker {
}

- (void)testDefaultConfiguration_Tracker {
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithAccountId:@"test"];
[GrowingRealTracker trackerWithConfiguration:config launchOptions:nil];

GrowingTrackConfiguration *configuration = GrowingConfigurationManager.sharedInstance.trackConfiguration;
Expand All @@ -176,7 +186,7 @@ - (void)testDefaultConfiguration_Tracker {
}

- (void)testSetConfiguration_Tracker {
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithAccountId:@"test"];
config.debugEnabled = YES;
config.cellularDataLimit = 5;
config.dataUploadInterval = 10;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
//
// GrowingAnalyticsStartTests2.m
// GrowingAnalytics
//
// Created by YoloMao on 2023/10/20.
// Copyright (C) 2023 Beijing Yishu Technology Co., Ltd.
//
// 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 <XCTest/XCTest.h>

#import "GrowingAutotrackConfiguration.h"
#import "GrowingAutotracker.h"
#import "GrowingAutotrackerCore/GrowingRealAutotracker.h"
#import "GrowingTrackConfiguration.h"
#import "GrowingTracker.h"
#import "GrowingTrackerCore/GrowingRealTracker.h"
#import "GrowingTrackerCore/Manager/GrowingConfigurationManager.h"
#import "GrowingTrackerCore/Thread/GrowingDispatchManager.h"

// 对老版本API configurationWithProjectId的测试
@interface GrowingAnalyticsStartTests2 : XCTestCase

@end

@implementation GrowingAnalyticsStartTests2

- (void)setUp {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

- (void)testDefaultConfiguration_Autotracker {
GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithProjectId:@"test"];
[GrowingRealAutotracker trackerWithConfiguration:config launchOptions:nil];

GrowingAutotrackConfiguration *configuration =
(GrowingAutotrackConfiguration *)GrowingConfigurationManager.sharedInstance.trackConfiguration;
XCTAssertEqual(configuration.debugEnabled, NO);
XCTAssertEqual(configuration.cellularDataLimit, 10);
XCTAssertEqual(configuration.dataUploadInterval, 15);
XCTAssertEqual(configuration.sessionInterval, 30);
XCTAssertEqual(configuration.dataCollectionEnabled, YES);
XCTAssertEqual(configuration.uploadExceptionEnable, YES);
XCTAssertEqualObjects(configuration.dataCollectionServerHost, @"https://napi.growingio.com");
XCTAssertEqual(configuration.excludeEvent, 0);
XCTAssertEqual(configuration.ignoreField, 0);
XCTAssertEqual(configuration.idMappingEnabled, NO);
XCTAssertEqualObjects(configuration.urlScheme, nil);
XCTAssertEqual(configuration.encryptEnabled, NO);
XCTAssertEqual(configuration.impressionScale, 0);
XCTAssertEqualObjects(configuration.dataSourceId, nil);
}

- (void)testSetConfiguration_Autotracker {
GrowingAutotrackConfiguration *config = [GrowingAutotrackConfiguration configurationWithProjectId:@"test"];
config.debugEnabled = YES;
config.cellularDataLimit = 5;
config.dataUploadInterval = 10;
config.sessionInterval = 10;
config.dataCollectionEnabled = NO;
config.uploadExceptionEnable = NO;
config.dataCollectionServerHost = @"https://autotracker.growingio.com";
config.excludeEvent = 1;
config.ignoreField = 1;
config.idMappingEnabled = YES;
config.urlScheme = @"growing.autotracker";
config.encryptEnabled = YES;
config.impressionScale = 0.5;
config.dataSourceId = @"12345";
[GrowingRealAutotracker trackerWithConfiguration:config launchOptions:nil];

GrowingAutotrackConfiguration *configuration =
(GrowingAutotrackConfiguration *)GrowingConfigurationManager.sharedInstance.trackConfiguration;
XCTAssertEqual(configuration.debugEnabled, YES);
XCTAssertEqual(configuration.cellularDataLimit, 5);
XCTAssertEqual(configuration.dataUploadInterval, 10);
XCTAssertEqual(configuration.sessionInterval, 10);
XCTAssertEqual(configuration.dataCollectionEnabled, NO);
XCTAssertEqual(configuration.uploadExceptionEnable, NO);
XCTAssertEqualObjects(configuration.dataCollectionServerHost, @"https://autotracker.growingio.com");
XCTAssertEqual(configuration.excludeEvent, 1);
XCTAssertEqual(configuration.ignoreField, 1);
XCTAssertEqual(configuration.idMappingEnabled, YES);
XCTAssertEqualObjects(configuration.urlScheme, @"growing.autotracker");
XCTAssertEqual(configuration.encryptEnabled, YES);
XCTAssertEqual(configuration.impressionScale, 0.5);
XCTAssertEqualObjects(configuration.dataSourceId, @"12345");
}

- (void)testDefaultConfiguration_Tracker {
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
[GrowingRealTracker trackerWithConfiguration:config launchOptions:nil];

GrowingTrackConfiguration *configuration = GrowingConfigurationManager.sharedInstance.trackConfiguration;
XCTAssertEqual(configuration.debugEnabled, NO);
XCTAssertEqual(configuration.cellularDataLimit, 10);
XCTAssertEqual(configuration.dataUploadInterval, 15);
XCTAssertEqual(configuration.sessionInterval, 30);
XCTAssertEqual(configuration.dataCollectionEnabled, YES);
XCTAssertEqual(configuration.uploadExceptionEnable, YES);
XCTAssertEqualObjects(configuration.dataCollectionServerHost, @"https://napi.growingio.com");
XCTAssertEqual(configuration.excludeEvent, 0);
XCTAssertEqual(configuration.ignoreField, 0);
XCTAssertEqual(configuration.idMappingEnabled, NO);
XCTAssertEqualObjects(configuration.urlScheme, nil);
XCTAssertEqual(configuration.encryptEnabled, NO);
XCTAssertEqualObjects(configuration.dataSourceId, nil);
}

- (void)testSetConfiguration_Tracker {
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
config.debugEnabled = YES;
config.cellularDataLimit = 5;
config.dataUploadInterval = 10;
config.sessionInterval = 10;
config.dataCollectionEnabled = NO;
config.uploadExceptionEnable = NO;
config.dataCollectionServerHost = @"https://tracker.growingio.com";
config.excludeEvent = 1;
config.ignoreField = 1;
config.idMappingEnabled = YES;
config.urlScheme = @"growing.tracker";
config.encryptEnabled = YES;
config.dataSourceId = @"12345";
[GrowingRealTracker trackerWithConfiguration:config launchOptions:nil];

GrowingTrackConfiguration *configuration = GrowingConfigurationManager.sharedInstance.trackConfiguration;
XCTAssertEqual(configuration.debugEnabled, YES);
XCTAssertEqual(configuration.cellularDataLimit, 5);
XCTAssertEqual(configuration.dataUploadInterval, 10);
XCTAssertEqual(configuration.sessionInterval, 10);
XCTAssertEqual(configuration.dataCollectionEnabled, NO);
XCTAssertEqual(configuration.uploadExceptionEnable, NO);
XCTAssertEqualObjects(configuration.dataCollectionServerHost, @"https://tracker.growingio.com");
XCTAssertEqual(configuration.excludeEvent, 1);
XCTAssertEqual(configuration.ignoreField, 1);
XCTAssertEqual(configuration.idMappingEnabled, YES);
XCTAssertEqualObjects(configuration.urlScheme, @"growing.tracker");
XCTAssertEqual(configuration.encryptEnabled, YES);
XCTAssertEqualObjects(configuration.dataSourceId, @"12345");
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ - (void)tearDown {
}

- (void)test00SendActivateEvent {
GrowingAutotrackConfiguration *configuration = [GrowingAutotrackConfiguration configurationWithProjectId:@"test"];
GrowingAutotrackConfiguration *configuration = [GrowingAutotrackConfiguration configurationWithAccountId:@"test"];
configuration.dataSourceId = @"test";
configuration.urlScheme = @"growing.530c8231345c492d";
configuration.readClipboardEnabled = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ - (void)setUp {
[GrowingServiceManager.sharedInstance registerService:@protocol(GrowingPBEventDatabaseService)
implClass:GrowingEventProtobufDatabase.class];
[GrowingSession startSession];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithProjectId:@"test"];
GrowingTrackConfiguration *config = [GrowingTrackConfiguration configurationWithAccountId:@"test"];
config.idMappingEnabled = YES;
GrowingConfigurationManager.sharedInstance.trackConfiguration = config;
}
Expand Down
Loading

0 comments on commit 0de68d1

Please sign in to comment.