Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUMM-1530 Add Datadog.isInitialized variable #566

Merged
merged 2 commits into from
Aug 20, 2021
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
5 changes: 5 additions & 0 deletions Sources/Datadog/Datadog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public class Datadog {
}
}

/// Returns `true` if the Datadog SDK is already initialized, `false` otherwise.
public static var isInitialized: Bool {
return instance != nil
}

/// Sets current user information.
/// Those will be added to logs, traces and RUM events automatically.
/// - Parameters:
Expand Down
10 changes: 5 additions & 5 deletions Tests/DatadogTests/Datadog/DatadogTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class DatadogTests: XCTestCase {

override func setUp() {
super.setUp()
XCTAssertNil(Datadog.instance)
XCTAssertFalse(Datadog.isInitialized)
printFunction = PrintFunctionMock()
consolePrint = printFunction.print
}

override func tearDown() {
consolePrint = { print($0) }
printFunction = nil
XCTAssertNil(Datadog.instance)
XCTAssertFalse(Datadog.isInitialized)
super.tearDown()
}

Expand All @@ -38,7 +38,7 @@ class DatadogTests: XCTestCase {
trackingConsent: .mockRandom(),
configuration: defaultBuilder.build()
)
XCTAssertNotNil(Datadog.instance)
XCTAssertTrue(Datadog.isInitialized)
Datadog.flushAndDeinitialize()
}

Expand All @@ -48,7 +48,7 @@ class DatadogTests: XCTestCase {
trackingConsent: .mockRandom(),
configuration: rumBuilder.build()
)
XCTAssertNotNil(Datadog.instance)
XCTAssertTrue(Datadog.isInitialized)
Datadog.flushAndDeinitialize()
}

Expand All @@ -67,7 +67,7 @@ class DatadogTests: XCTestCase {
printFunction.printedMessage,
"🔥 Datadog SDK usage error: `clientToken` cannot be empty."
)
XCTAssertNil(Datadog.instance)
XCTAssertFalse(Datadog.isInitialized)
}

func testGivenValidConfiguration_whenInitializedMoreThanOnce_itPrintsError() {
Expand Down