Skip to content

Commit

Permalink
fix: lint and format issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoweii committed Mar 21, 2024
1 parent 5c97b0c commit 505ba2b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
8 changes: 7 additions & 1 deletion Sources/Clickstream/AWSClickstreamPlugin+Configure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ extension AWSClickstreamPlugin {
} else if amplifyConfigure.isCompressEvents != nil {
defaultConfiguration.isCompressEvents = amplifyConfigure.isCompressEvents
}

mergeDefaultConfiguration(defaultConfiguration)
configuration = defaultConfiguration
}

/// Internal method to merge the default configurations
func mergeDefaultConfiguration(_ defaultConfiguration: ClickstreamConfiguration) {
if let isTrackScreenViewEvents = configuration.isTrackScreenViewEvents {
defaultConfiguration.isTrackScreenViewEvents = isTrackScreenViewEvents
}
Expand All @@ -135,7 +142,6 @@ extension AWSClickstreamPlugin {
if configuration.globalAttributes != nil {
defaultConfiguration.globalAttributes = configuration.globalAttributes
}
configuration = defaultConfiguration
}

/// Internal method to add global attributes
Expand Down
8 changes: 5 additions & 3 deletions Sources/Clickstream/ClickstreamAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public enum ClickstreamAnalytics {
var amplifyConfiguraion: AmplifyConfiguration!
do {
guard let path = bundle.path(forResource: "amplifyconfiguration", ofType: "json") else {
throw ConfigurationError.invalidAmplifyConfigurationFile("Could not load default `amplifyconfiguration.json` file", "please check if you added the correct configuration file")
throw ConfigurationError.invalidAmplifyConfigurationFile(
"Could not load default `amplifyconfiguration.json` file",
"please check if you added the correct configuration file")
}
let url = URL(fileURLWithPath: path)
amplifyConfiguraion = try AmplifyConfiguration(configurationFile: url)
Expand All @@ -103,8 +105,8 @@ public enum ClickstreamAnalytics {
let plugins: [String: JSONValue] = [
"awsClickstreamPlugin": [
"appId": JSONValue.string(""),
"endpoint": JSONValue.string(""),
],
"endpoint": JSONValue.string("")
]
]
let analyticsConfiguration = AnalyticsCategoryConfiguration(plugins: plugins)
amplifyConfiguraion = AmplifyConfiguration(analytics: analyticsConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AutoRecordEventClientTest: XCTestCase {
UserDefaults.standard.removePersistentDomain(forName: Bundle.main.bundleIdentifier!)
let mockNetworkMonitor = MockNetworkMonitor()
activityTracker = MockActivityTracker()

let contextConfiguration = ClickstreamConfiguration.getDefaultConfiguration()
.withAppId(testAppId)
.withEndpoint(testEndpoint)
Expand Down
2 changes: 1 addition & 1 deletion Tests/ClickstreamTests/Clickstream/EventRecorderTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class EventRecorderTest: XCTestCase {
}
try! server.start()
let appId = testAppId + String(describing: Date().millisecondsSince1970)

let contextConfiguration = ClickstreamConfiguration.getDefaultConfiguration()
.withAppId(appId)
.withEndpoint(testSuccessEndpoint)
Expand Down
6 changes: 3 additions & 3 deletions Tests/ClickstreamTests/Clickstream/SessionClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ class SessionClientTests: XCTestCase {
let state1 = ApplicationState.Resolver.resolve(currentState: ApplicationState.terminated,
event: ActivityEvent.applicationWillMoveToForeground)
XCTAssertEqual(ApplicationState.terminated, state1)

let state2 = ApplicationState.Resolver.resolve(currentState: ApplicationState.runningInBackground,
event: ActivityEvent.applicationWillTerminate)
XCTAssertEqual(ApplicationState.terminated, state2)

let state3 = ApplicationState.Resolver.resolve(currentState: ApplicationState.runningInBackground,
event: ActivityEvent.applicationDidMoveToBackground)
XCTAssertEqual(ApplicationState.runningInBackground, state3)

let state4 = ApplicationState.Resolver.resolve(currentState: ApplicationState.runningInForeground,
event: ActivityEvent.applicationWillMoveToForeground)
XCTAssertEqual(ApplicationState.runningInForeground, state4)
Expand Down
2 changes: 1 addition & 1 deletion Tests/ClickstreamTests/ClickstreamPluginTestBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ClickstreamPluginTestBase: XCTestCase {
override func setUp() async throws {
mockNetworkMonitor = MockNetworkMonitor()
analyticsPlugin = AWSClickstreamPlugin()

let contextConfiguration = ClickstreamConfiguration.getDefaultConfiguration()
.withAppId(testAppId)
.withEndpoint(testEndpoint)
Expand Down
16 changes: 8 additions & 8 deletions Tests/ClickstreamTests/SDKInitialTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class SDKInitialTest: XCTestCase {
.withEndpoint("https://example.com/collect")
.withLogEvents(true)
.withCompressEvents(false)
.withSessionTimeoutDuration(100000)
.withSendEventInterval(15000)
.withSessionTimeoutDuration(100_000)
.withSendEventInterval(15_000)
.withTrackAppExceptionEvents(true)
.withTrackScreenViewEvents(false)
.withTrackUserEngagementEvents(false)
Expand All @@ -58,8 +58,8 @@ class SDKInitialTest: XCTestCase {
.withEndpoint("https://example.com/collect1")
.withLogEvents(true)
.withCompressEvents(false)
.withSessionTimeoutDuration(100000)
.withSendEventInterval(15000)
.withSessionTimeoutDuration(100_000)
.withSendEventInterval(15_000)
.withTrackAppExceptionEvents(true)
.withTrackScreenViewEvents(false)
.withTrackUserEngagementEvents(false)
Expand All @@ -79,8 +79,8 @@ class SDKInitialTest: XCTestCase {
let configure = ClickstreamConfiguration()
.withLogEvents(true)
.withCompressEvents(false)
.withSessionTimeoutDuration(100000)
.withSendEventInterval(15000)
.withSessionTimeoutDuration(100_000)
.withSendEventInterval(15_000)
.withTrackScreenViewEvents(false)
.withTrackUserEngagementEvents(false)
.withAuthCookie("testAuthCookie")
Expand All @@ -92,8 +92,8 @@ class SDKInitialTest: XCTestCase {
XCTAssertEqual("http://example.com/collect", resultConfig.endpoint)
XCTAssertEqual(true, resultConfig.isLogEvents)
XCTAssertEqual(false, resultConfig.isCompressEvents)
XCTAssertEqual(100000, resultConfig.sessionTimeoutDuration)
XCTAssertEqual(15000, resultConfig.sendEventsInterval)
XCTAssertEqual(100_000, resultConfig.sessionTimeoutDuration)
XCTAssertEqual(15_000, resultConfig.sendEventsInterval)
XCTAssertEqual(false, resultConfig.isTrackScreenViewEvents)
XCTAssertEqual(false, resultConfig.isTrackUserEngagementEvents)
XCTAssertEqual("testAuthCookie", resultConfig.authCookie)
Expand Down

0 comments on commit 505ba2b

Please sign in to comment.