Skip to content

Commit

Permalink
Merge branch '8.0.0' into ref/2395-remove-options-dict
Browse files Browse the repository at this point in the history
* 8.0.0:
  ref: Mark [SpanProtocol setExtraValue:forKey] as deprecated (#2413)
  typos (#2421)
  test: Disable NSDataTracker in clearTestState (#2418)
  • Loading branch information
kevinrenskers committed Nov 22, 2022
2 parents 0dfdfed + dcac8ad commit 0bf85b3
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This version adds a dependency on Swift.
- Remove `- [SentryOptions initWithDict:didFailWithError:]` (#2404)
- Rename `- [SentrySDK startWithOptionsObject:]` to `- [SentrySDK startWithOptions:]` (#2404)
- Remove `- [SentryOptions sdkInfo]` (#2404)
- Mark `- [SpanProtocol setExtraValue:forKey:]` as deprecated (#2413)

## 7.31.2

Expand Down
5 changes: 3 additions & 2 deletions Sources/Sentry/Public/SentrySpanProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ NS_SWIFT_NAME(Span)

/**
* Use setDataValue instead. This method calls setDataValue, was added by mistake, and will be
* deprecated in a future version.
* removed in a future version.
*/
- (void)setExtraValue:(nullable id)value forKey:(NSString *)key NS_SWIFT_NAME(setExtra(value:key:));
- (void)setExtraValue:(nullable id)value
forKey:(NSString *)key DEPRECATED_ATTRIBUTE NS_SWIFT_NAME(setExtra(value:key:));

/**
* Removes a data value.
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryNoOpSpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SENTRY_NO_INIT
@property (nullable, readonly) NSDictionary<NSString *, id> *data;
@property (readonly) NSDictionary<NSString *, NSString *> *tags;

- (void)setExtraValue:(nullable id)value forKey:(NSString *)key DEPRECATED_ATTRIBUTE;
@end

NS_ASSUME_NONNULL_END
12 changes: 6 additions & 6 deletions Sources/Sentry/SentryUIEventTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,21 @@ - (NSString *)getOperation:(id)sender
*/
- (NSString *)getTransactionName:(NSString *)action target:(NSString *)target
{
NSArray<NSString *> *componens = [action componentsSeparatedByString:@":"];
if (componens.count > 2) {
NSArray<NSString *> *components = [action componentsSeparatedByString:@":"];
if (components.count > 2) {
NSMutableString *result =
[[NSMutableString alloc] initWithFormat:@"%@.%@(", target, componens.firstObject];
[[NSMutableString alloc] initWithFormat:@"%@.%@(", target, components.firstObject];

for (int i = 1; i < (componens.count - 1); i++) {
[result appendFormat:@"%@:", componens[i]];
for (int i = 1; i < (components.count - 1); i++) {
[result appendFormat:@"%@:", components[i]];
}

[result appendFormat:@")"];

return result;
}

return [NSString stringWithFormat:@"%@.%@", target, componens.firstObject];
return [NSString stringWithFormat:@"%@.%@", target, components.firstObject];
}

NS_ASSUME_NONNULL_END
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/include/SentrySpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SENTRY_NO_INIT
*/
- (instancetype)initWithTracer:(SentryTracer *)transaction context:(SentrySpanContext *)context;

- (void)setExtraValue:(nullable id)value forKey:(NSString *)key DEPRECATED_ATTRIBUTE;
@end

NS_ASSUME_NONNULL_END
2 changes: 2 additions & 0 deletions Sources/Sentry/include/SentryTracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ static NSTimeInterval const SentryTracerDefaultTimeout = 3.0;
*/
- (void)spanFinished:(id<SentrySpan>)finishedSpan;

- (void)setExtraValue:(nullable id)value forKey:(NSString *)key DEPRECATED_ATTRIBUTE;

/**
* Get the tracer from a span.
*/
Expand Down
2 changes: 2 additions & 0 deletions Tests/SentryTests/ClearTestState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ func clearTestState() {
SentryDependencyContainer.reset()
Dynamic(SentryGlobalEventProcessor.shared()).removeAllProcessors()
SentrySwizzleWrapper.sharedInstance.removeAllCallbacks()

SentryNSDataTracker.sharedInstance.disable()
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SentrySubClassFinderTests: XCTestCase {
assertActOnSubclassesOfViewController(expected: [], imageName: "OtherImage")
}

func testGettingSublcasses_DoesNotCallInitializer() {
func testGettingSubclasses_DoesNotCallInitializer() {
let sut = SentrySubClassFinder(dispatchQueue: TestSentryDispatchQueueWrapper(), objcRuntimeWrapper: fixture.runtimeWrapper)

var actual: [AnyClass] = []
Expand Down
5 changes: 3 additions & 2 deletions Tests/SentryTests/Performance/SentryTracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,13 @@ class SentryTracerTests: XCTestCase {

XCTAssertEqual(transactions, fixture.hub.capturedEventsWithScopes.count)

let transactionsWithAppStartMeasrurement = fixture.hub.capturedEventsWithScopes.filter { pair in
let transactionsWithAppStartMeasurement = fixture.hub.capturedEventsWithScopes.filter { pair in
let serializedTransaction = pair.event.serialize()
let measurements = serializedTransaction["measurements"] as? [String: [String: Int]]
return measurements == ["app_start_warm": ["value": 500]]
}

XCTAssertEqual(1, transactionsWithAppStartMeasrurement.count)
XCTAssertEqual(1, transactionsWithAppStartMeasurement.count)
}

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
Expand Down Expand Up @@ -810,6 +810,7 @@ class SentryTracerTests: XCTestCase {
}
#endif

@available(*, deprecated)
func testSetExtra_ForwardsToSetData() {
let sut = fixture.getSut()
sut.setExtra(value: 0, key: "key")
Expand Down
14 changes: 7 additions & 7 deletions Tests/SentryTests/SentryCrash/SentryCrashReportSinkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class SentryCrashReportSinkTests: SentrySDKIntegrationTestsBase {
filterReportWithAttachment()

let client = getTestClient()
XCTAssertEqual(1, client.flushInvoctions.count)
XCTAssertEqual(5, client.flushInvoctions.first)
XCTAssertEqual(1, client.flushInvocations.count)
XCTAssertEqual(5, client.flushInvocations.first)
XCTAssertEqual(0, fixture.dispatchQueue.dispatchAsyncCalled)
}

Expand All @@ -63,8 +63,8 @@ class SentryCrashReportSinkTests: SentrySDKIntegrationTestsBase {
filterReportWithAttachment()

let client = getTestClient()
XCTAssertEqual(1, client.flushInvoctions.count)
XCTAssertEqual(5, client.flushInvoctions.first)
XCTAssertEqual(1, client.flushInvocations.count)
XCTAssertEqual(5, client.flushInvocations.first)
XCTAssertEqual(0, fixture.dispatchQueue.dispatchAsyncCalled)
}

Expand All @@ -74,7 +74,7 @@ class SentryCrashReportSinkTests: SentrySDKIntegrationTestsBase {
filterReportWithAttachment()

let client = getTestClient()
XCTAssertEqual(0, client.flushInvoctions.count)
XCTAssertEqual(0, client.flushInvocations.count)
XCTAssertEqual(1, fixture.dispatchQueue.dispatchAsyncCalled)
}

Expand All @@ -84,7 +84,7 @@ class SentryCrashReportSinkTests: SentrySDKIntegrationTestsBase {
filterReportWithAttachment()

let client = getTestClient()
XCTAssertEqual(0, client.flushInvoctions.count)
XCTAssertEqual(0, client.flushInvocations.count)
XCTAssertEqual(1, fixture.dispatchQueue.dispatchAsyncCalled)
}

Expand All @@ -94,7 +94,7 @@ class SentryCrashReportSinkTests: SentrySDKIntegrationTestsBase {
filterReportWithAttachment()

let client = getTestClient()
XCTAssertEqual(0, client.flushInvoctions.count)
XCTAssertEqual(0, client.flushInvocations.count)
XCTAssertEqual(1, fixture.dispatchQueue.dispatchAsyncCalled)
}

Expand Down
18 changes: 9 additions & 9 deletions Tests/SentryTests/SentryCrash/SentryThreadInspectorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import XCTest
var testMachineContextWrapper = TestMachineContextWrapper()
var stacktraceBuilder = TestSentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: [])))

func getSut(testWithRealMachineConextWrapper: Bool = false) -> SentryThreadInspector {
func getSut(testWithRealMachineContextWrapper: Bool = false) -> SentryThreadInspector {

let machineContextWrapper = testWithRealMachineConextWrapper ? SentryCrashDefaultMachineContextWrapper() : testMachineContextWrapper as SentryCrashMachineContextWrapper
let stacktraceBuilder = testWithRealMachineConextWrapper ? SentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: []))) : self.stacktraceBuilder
let machineContextWrapper = testWithRealMachineContextWrapper ? SentryCrashDefaultMachineContextWrapper() : testMachineContextWrapper as SentryCrashMachineContextWrapper
let stacktraceBuilder = testWithRealMachineContextWrapper ? SentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: []))) : self.stacktraceBuilder

return SentryThreadInspector(
stacktraceBuilder: stacktraceBuilder,
Expand All @@ -31,7 +31,7 @@ import XCTest
}

func testStacktraceHasFrames() {
let actual = fixture.getSut(testWithRealMachineConextWrapper: true).getCurrentThreads()
let actual = fixture.getSut(testWithRealMachineContextWrapper: true).getCurrentThreads()
let stacktrace = actual[0].stacktrace

// The stacktrace has usually more than 40 frames. Feel free to change the number if the tests are failing
Expand All @@ -57,7 +57,7 @@ import XCTest
let expect = expectation(description: "Read every thread")
expect.expectedFulfillmentCount = 10

let sut = self.fixture.getSut(testWithRealMachineConextWrapper: true)
let sut = self.fixture.getSut(testWithRealMachineContextWrapper: true)
for _ in 0..<10 {

queue.async {
Expand All @@ -84,7 +84,7 @@ import XCTest
}

func testOnlyCurrentThreadHasStacktrace() {
let actual = fixture.getSut(testWithRealMachineConextWrapper: true).getCurrentThreads()
let actual = fixture.getSut(testWithRealMachineContextWrapper: true).getCurrentThreads()
XCTAssertEqual(true, actual[0].current)
XCTAssertNotNil(actual[0].stacktrace)

Expand All @@ -93,7 +93,7 @@ import XCTest
}

func testOnlyFirstThreadIsCurrent() {
let actual = fixture.getSut(testWithRealMachineConextWrapper: true).getCurrentThreads()
let actual = fixture.getSut(testWithRealMachineContextWrapper: true).getCurrentThreads()

let thread0 = actual[0]
XCTAssertEqual(true, thread0.current)
Expand All @@ -105,7 +105,7 @@ import XCTest
}

func testStacktraceOnlyForCurrentThread() {
let actual = fixture.getSut(testWithRealMachineConextWrapper: true).getCurrentThreads()
let actual = fixture.getSut(testWithRealMachineContextWrapper: true).getCurrentThreads()

XCTAssertNotNil(actual[0].stacktrace)

Expand All @@ -117,7 +117,7 @@ import XCTest
}

func testCrashedIsFalseForAllThreads() {
let actual = fixture.getSut(testWithRealMachineConextWrapper: true).getCurrentThreads()
let actual = fixture.getSut(testWithRealMachineContextWrapper: true).getCurrentThreads()

let threadCount = actual.count
for i in 0..<threadCount {
Expand Down
4 changes: 2 additions & 2 deletions Tests/SentryTests/TestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ class TestClient: Client {
recordLostEvents.record((category, reason))
}

var flushInvoctions = Invocations<TimeInterval>()
var flushInvocations = Invocations<TimeInterval>()
override func flush(timeout: TimeInterval) {
flushInvoctions.record(timeout)
flushInvocations.record(timeout)
}
}

Expand Down
1 change: 0 additions & 1 deletion Tests/SentryTests/Transaction/SentryNoOpSpanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class SentryNoOpSpanTests: XCTestCase {
let sut = SentryNoOpSpan.shared()
XCTAssertNil(sut.data)
sut.setData(value: "tet", key: "key")
sut.setExtra(value: "tet", key: "key")
sut.removeData(key: "any")
XCTAssertNil(sut.data)
}
Expand Down
15 changes: 8 additions & 7 deletions Tests/SentryTests/Transaction/SentrySpanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ class SentrySpanTests: XCTestCase {
XCTAssertFalse(logOutput.loggedMessages.filter({ $0.contains(" Starting a child on a finished span is not supported; it won\'t be sent to Sentry.") }).isEmpty)
}

func testAddAndRemoveExtras() {
func testAddAndRemoveData() {
let span = fixture.getSut()

span.setExtra(value: fixture.extraValue, key: fixture.extraKey)
span.setData(value: fixture.extraValue, key: fixture.extraKey)

XCTAssertEqual(span.data!.count, 1)
XCTAssertEqual(span.data![fixture.extraKey] as! String, fixture.extraValue)
Expand All @@ -214,7 +214,7 @@ class SentrySpanTests: XCTestCase {
func testSerialization() {
let span = fixture.getSut()

span.setExtra(value: fixture.extraValue, key: fixture.extraKey)
span.setData(value: fixture.extraValue, key: fixture.extraKey)
span.setTag(value: fixture.extraValue, key: fixture.extraKey)
span.finish()

Expand All @@ -234,7 +234,7 @@ class SentrySpanTests: XCTestCase {
func testSanitizeData() {
let span = fixture.getSut()

span.setExtra(value: Date(timeIntervalSince1970: 10), key: "date")
span.setData(value: Date(timeIntervalSince1970: 10), key: "date")
span.finish()

let serialization = span.serialize()
Expand All @@ -244,7 +244,7 @@ class SentrySpanTests: XCTestCase {
func testSanitizeDataSpan() {
let span = SentrySpan(tracer: fixture.tracer, context: SpanContext(operation: fixture.someOperation, sampled: .undecided))

span.setExtra(value: Date(timeIntervalSince1970: 10), key: "date")
span.setData(value: Date(timeIntervalSince1970: 10), key: "date")
span.finish()

let serialization = span.serialize()
Expand Down Expand Up @@ -305,13 +305,14 @@ class SentrySpanTests: XCTestCase {
XCTAssertEqual(header.value(), "\(span.context.traceId)-\(span.context.spanId)")
}

@available(*, deprecated)
func testSetExtra_ForwardsToSetData() {
let sut = SentrySpan(tracer: fixture.tracer, context: SpanContext(operation: "test"))
sut.setExtra(value: 0, key: "key")

XCTAssertEqual(["key": 0], sut.data as! [String: Int])
}

func testSpanWithoutTracer_StartChild_ReturnsNoOpSpan() {
// Span has a weak reference to tracer. If we don't keep a reference
// to the tracer ARC will deallocate the tracer.
Expand Down Expand Up @@ -349,7 +350,7 @@ class SentrySpanTests: XCTestCase {
queue.async {

for j in 0..<innerLoop {
span.setExtra(value: value, key: "\(i)-\(j)")
span.setData(value: value, key: "\(i)-\(j)")
span.setTag(value: value, key: "\(i)-\(j)")
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/SentryTests/Transaction/TestSentrySpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface TestSentrySpan : NSObject <SentrySpan>

- (void)setExtraValue:(nullable id)value forKey:(nonnull NSString *)key DEPRECATED_ATTRIBUTE;

@end

NS_ASSUME_NONNULL_END

0 comments on commit 0bf85b3

Please sign in to comment.