-
-
Notifications
You must be signed in to change notification settings - Fork 333
/
TestHub.swift
59 lines (46 loc) · 2.3 KB
/
TestHub.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import _SentryPrivate
import Foundation
@testable import Sentry
public class TestHub: SentryHub {
public var startSessionInvocations: Int = 0
public var closeCachedSessionInvocations: Int = 0
public var endSessionTimestamp: Date?
public var closeCachedSessionTimestamp: Date?
public override func startSession() {
startSessionInvocations += 1
}
public func setTestSession() {
self.session = SentrySession(releaseName: "Test Release", distinctId: "123")
}
public override func closeCachedSession(withTimestamp timestamp: Date?) {
closeCachedSessionTimestamp = timestamp
closeCachedSessionInvocations += 1
}
public override func endSession(withTimestamp timestamp: Date) {
endSessionTimestamp = timestamp
}
public var sentCrashEvents = Invocations<Event>()
public override func captureCrash(_ event: Event) {
sentCrashEvents.record(event)
}
public var sentCrashEventsWithScope = Invocations<(event: Event, scope: Scope)>()
public override func captureCrash(_ event: Event, with scope: Scope) {
sentCrashEventsWithScope.record((event, scope))
}
public var capturedEventsWithScopes = Invocations<(event: Event, scope: Scope, additionalEnvelopeItems: [SentryEnvelopeItem])>()
public override func capture(event: Event, scope: Scope, additionalEnvelopeItems: [SentryEnvelopeItem]) -> SentryId {
self.capturedEventsWithScopes.record((event, scope, additionalEnvelopeItems))
return event.eventId
}
public var capturedTransactionsWithScope = Invocations<(transaction: [String: Any], scope: Scope)>()
public override func capture(_ transaction: Transaction, with scope: Scope) {
capturedTransactionsWithScope.record((transaction.serialize(), scope))
super.capture(transaction, with: scope)
}
public var onReplayCapture: (() -> Void)?
public var capturedReplayRecordingVideo = Invocations<(replay: SentryReplayEvent, recording: SentryReplayRecording, video: URL)>()
public override func capture(_ replayEvent: SentryReplayEvent, replayRecording: SentryReplayRecording, video videoURL: URL) {
capturedReplayRecordingVideo.record((replayEvent, replayRecording, videoURL))
onReplayCapture?()
}
}