Skip to content

Commit f6cd072

Browse files
Feature/integrate breadcrumbs (#76)
Enable breadcrumb for iOS Co-authored-by: MinPD126 <meenup@bitheads.com>
1 parent 71b1fc0 commit f6cd072

23 files changed

+1145
-272
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
name: Run tests
22

3-
on:
3+
on:
4+
workflow_dispatch:
45
pull_request:
56
branches:
67
- develop
78
- master
89

910
jobs:
10-
build:
11+
12+
test:
13+
runs-on: macos-latest
14+
15+
strategy:
16+
matrix:
17+
platform: [ios, mac, tvos]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Install dependencies
22+
run: sh scripts/install.sh
23+
- name: Run test
24+
run: fastlane ${{ matrix.platform }} tests
25+
26+
pod-lint:
1127
runs-on: macos-latest
28+
1229
steps:
1330
- uses: actions/checkout@v2
1431
- name: Install dependencies
1532
run: sh scripts/install.sh
16-
- name: Run tests
17-
run: sh scripts/test.sh
33+
- name: Run pod lib lint
34+
run: pod lib lint --verbose --allow-warnings --sources='https://cdn.cocoapods.org/'
35+

Backtrace.podspec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@ Pod::Spec.new do |s|
1818
s.source = { :git => "https://github.com/backtrace-labs/backtrace-cocoa.git", :tag => "#{s.version}" }
1919

2020
s.ios.deployment_target = "10.0"
21-
s.osx.deployment_target = "10.10"
21+
s.osx.deployment_target = "10.11"
2222
s.tvos.deployment_target = "10.0"
2323

2424
s.ios.source_files = ["Sources/**/*.{swift}", "Backtrace-iOS/**/*.{h*,swift}"]
2525
s.osx.source_files = ["Sources/**/*.{swift}", "Backtrace-macOS/**/*.{h*,swift}"]
2626
s.tvos.source_files = ["Sources/**/*.{swift}", "Backtrace-tvOS/**/*.{h*,swift}"]
27-
27+
28+
s.osx.exclude_files = ["Sources/Features/Breadcrumb/**/*.{swift}"]
29+
s.tvos.exclude_files = ["Sources/Features/Breadcrumb/**/*.{swift}"]
30+
2831
s.ios.public_header_files = ["Backtrace-iOS/**/*.h*"]
2932
s.osx.public_header_files = ["Backtrace-macOS/**/*.h*"]
3033
s.tvos.public_header_files = ["Backtrace-tvOS/**/*.h*"]
3134

35+
s.ios.dependency "Cassette", "1.0.0-beta5"
3236
s.dependency "Backtrace-PLCrashReporter", '1.5.3'
37+
3338
s.resources = 'Sources/**/*.xcdatamodeld'
3439

3540
s.swift_version = '4.2'

Backtrace.xcodeproj/project.pbxproj

Lines changed: 254 additions & 214 deletions
Large diffs are not rendered by default.

Examples/Example-iOS-ObjC/AppDelegate.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2727
reportsPerMin: 3
2828
allowsAttachingDebugger: TRUE
2929
detectOOM: FALSE];
30+
[configuration enableBreadCrumbs:@[@(BacktraceBreadcrumbTypeManual), @(BacktraceBreadcrumbTypeLog)]];
3031
BacktraceClient.shared = [[BacktraceClient alloc] initWithConfiguration: configuration error: nil];
3132
BacktraceClient.shared.delegate = self;
3233

@@ -50,6 +51,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5051
NSLog(@"%@", result);
5152
}];
5253

54+
55+
56+
NSDictionary *attributes = @{@"My Attribute":@"My Attribute Value"};
57+
[[BacktraceClient shared] addBreadcrumb:@"My Native Breadcrumb"
58+
attributes:attributes
59+
type:BacktraceBreadcrumbTypeUser
60+
level:BacktraceBreadcrumbLevelError];
5361
return YES;
5462
}
5563

Examples/Example-iOS/AppDelegate.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
3131
reportsPerMin: 10,
3232
allowsAttachingDebugger: true)
3333

34+
backtraceConfiguration.enableBreadCrumbs(breadCrumbTypes: [BacktraceBreadcrumbType.system, BacktraceBreadcrumbType.log])
3435
BacktraceClient.shared = try? BacktraceClient(configuration: backtraceConfiguration)
3536
BacktraceClient.shared?.delegate = self
3637
BacktraceClient.shared?.attributes = ["foo": "bar", "testing": true]
@@ -53,7 +54,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
5354
print("AppDelegate:Result:\(result)")
5455
}
5556
}
56-
57+
let attributes = ["My Attribute":"My Attribute Value"]
58+
BacktraceClient.shared?.addBreadcrumb("My Native Breadcrumb",
59+
attributes: attributes,
60+
type: .user,
61+
level: .error)
5762
return true
5863
}
5964

Podfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,35 @@ end
1010

1111
def shared_test_pods
1212
shared_pods
13-
pod 'Nimble'
14-
pod 'Quick'
13+
pod 'Nimble', '9.2.1'
14+
pod 'Quick', '4.0.0'
15+
end
16+
17+
def shared_iOS_pods
18+
shared_pods
19+
pod 'Cassette', '1.0.0-beta5'
20+
end
21+
22+
def shared_test_iOS_pods
23+
shared_test_pods
24+
shared_iOS_pods
1525
end
1626

1727
inhibit_all_warnings!
1828

1929
## Framework iOS
2030
target 'Backtrace-iOS' do
2131
use_frameworks!
22-
shared_pods
23-
32+
shared_iOS_pods
2433
target 'Backtrace-iOSTests' do
2534
inherit! :search_paths
26-
shared_test_pods
35+
shared_test_iOS_pods
2736
end
2837
end
2938

3039
## Framework macOS
3140
target 'Backtrace-macOS' do
41+
platform :osx, '10.11'
3242
use_frameworks!
3343
shared_pods
3444
target 'Backtrace-macOSTests' do
@@ -49,7 +59,7 @@ end
4959

5060
# Examples
5161

52-
## Definitions
62+
## Definitions
5363
def local_backtrace
5464
pod 'Backtrace', :path => "./Backtrace.podspec"
5565
end
@@ -66,6 +76,7 @@ target 'Example-iOS-ObjC' do
6676
end
6777

6878
target 'Example-macOS-ObjC' do
79+
platform :osx, '10.11'
6980
use_frameworks!
7081
local_backtrace
7182
end
@@ -80,6 +91,7 @@ post_install do |installer|
8091
installer.pods_project.targets.each do |target|
8192
target.build_configurations.each do |config|
8293
config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
94+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
8395
end
8496
end
8597
end

Podfile.lock

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
PODS:
2-
- Backtrace (1.7.1):
3-
- Backtrace-PLCrashReporter
4-
- Backtrace-PLCrashReporter (1.5.4)
2+
- Backtrace (1.7.2):
3+
- Backtrace-PLCrashReporter (= 1.5.3)
4+
- Cassette (= 1.0.0-beta5)
5+
- Backtrace-PLCrashReporter (1.5.3)
6+
- Cassette (1.0.0-beta5)
57
- Nimble (9.2.1)
68
- Quick (4.0.0)
79

810
DEPENDENCIES:
911
- Backtrace (from `./Backtrace.podspec`)
10-
- Backtrace-PLCrashReporter
11-
- Nimble
12-
- Quick
12+
- Backtrace-PLCrashReporter (= 1.5.3)
13+
- Cassette (= 1.0.0-beta5)
14+
- Nimble (= 9.2.1)
15+
- Quick (= 4.0.0)
1316

1417
SPEC REPOS:
1518
trunk:
1619
- Backtrace-PLCrashReporter
20+
- Cassette
1721
- Nimble
1822
- Quick
1923

@@ -22,11 +26,12 @@ EXTERNAL SOURCES:
2226
:path: "./Backtrace.podspec"
2327

2428
SPEC CHECKSUMS:
25-
Backtrace: 950ea8d861a84c527bb7c0a5adf64b887d95ffaf
26-
Backtrace-PLCrashReporter: 65b9aae5468bb6af6b55b88de22b49e031331054
29+
Backtrace: 2e15d95101a5b3039b9e3522d737e01d4b3f124c
30+
Backtrace-PLCrashReporter: 71ddeba11834d2bcc3c19f357aaec7bf87131f89
31+
Cassette: 074c6991391733888990dba728b7ffe00299a0a6
2732
Nimble: e7e615c0335ee4bf5b0d786685451e62746117d5
2833
Quick: 6473349e43b9271a8d43839d9ba1c442ed1b7ac4
2934

30-
PODFILE CHECKSUM: afc46274bf1938dc457973360b3e30ff7b342057
35+
PODFILE CHECKSUM: 3659ce9927e652b0aedb698c2246b8e773aeb391
3136

32-
COCOAPODS: 1.11.2
37+
COCOAPODS: 1.11.3

README.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
9999
1. [Error/NSError](#documentation-sending-error)
100100
2. [NSException](#documentation-sending-exception)
101101
3. [macOS note](#documentation-sending-report-macOS)
102-
7. [Enable error-free metrics](#documentation-metrics)
103-
4. [FAQ](#faq)
102+
4. [Beta](#beta)
103+
1. [Breadcrumbs](#documentation-breadcrumbs)
104+
2. [Error-free metrics](#documentation-metrics)
105+
5. [FAQ](#faq)
104106
1. [Missing dSYM files](#faq-missing-dsym)
105107
* [Finding dSYMs while building project](#faq-finding-dsym-building)
106108
* [Finding dSYMs while archiving project](#faq-finding-dsym-archiving)
@@ -418,6 +420,51 @@ UserDefaults.standard.register(defaults: ["NSApplicationCrashOnExceptions": true
418420
```
419421
but it crashes your app if you don't use `@try ... @catch`.
420422
423+
# Beta functionality <a name="beta"></a>
424+
425+
The underlying features are available in BETA. This means they are not covered by the normal Backtrace SLAs.
426+
427+
## Breadcrumbs <a name="documentation-breadcrumbs"><a/>
428+
429+
Breadcrumbs help you track events leading up to your crash, error, or other submitted object.
430+
431+
When breadcrumbs are enabled, any captured breadcrumbs will automatically be attached as a file to your crash, error, or other submitted object (including native crashes) and displayed in the UI in the Breadcrumbs tab.
432+
433+
### Enable Breadcrumbs <a name="documentation-breadcrumbs"><a/>
434+
- Swift
435+
```swift
436+
let backtraceCredentials = BacktraceCredentials(endpoint: URL(string: "https://backtrace.io")!, token: "token")
437+
let backtraceConfiguration = BacktraceClientConfiguration(credentials: backtraceCredentials)
438+
backtraceConfiguration.enableBreadCrumbs(breadCrumbTypes: [BacktraceBreadcrumbType.manual, BacktraceBreadcrumbType.log])
439+
```
440+
- Objective-C
441+
```objective-c
442+
BacktraceCredentials *credentials = [[BacktraceCredentials alloc]
443+
initWithEndpoint: [NSURL URLWithString: @"https://backtrace.io"]
444+
token: @"token"];
445+
BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration alloc]
446+
initWithCredentials: credentials];
447+
[configuration enableBreadCrumbs:@[@(BacktraceBreadcrumbTypeManual), @(BacktraceBreadcrumbTypeLog)]];
448+
```
449+
450+
### Add Breadcrumbs <a name="documentation-add-breadcrumbs"><a/>
451+
- Swift
452+
```swift
453+
let attributes = ["My Attribute":"My Attribute Value"]
454+
BacktraceClient.shared?.addBreadcrumb("My Native Breadcrumb",
455+
attributes: attributes,
456+
type: .user,
457+
level: .error)
458+
```
459+
- Objective-C
460+
```objective-c
461+
NSDictionary *attributes = @{@"My Attribute":@"My Attribute Value"};
462+
[[BacktraceClient shared] addBreadcrumb:@"My Native Breadcrumb"
463+
attributes:attributes
464+
type:BacktraceBreadcrumbTypeUser
465+
level:BacktraceBreadcrumbLevelError];
466+
```
467+
421468
## Error-free metrics <a name="documentation-metrics"><a/>
422469
423470
Error free metrics can be used to answer the following questions:

0 commit comments

Comments
 (0)