Skip to content

Commit 55af18e

Browse files
authored
Update docs for v1.6.1 release (#62)
1 parent f4dd272 commit 55af18e

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Backtrace Cocoa Release Notes
22

3+
## Version 1.6.1
4+
- Allows default file attachments which will be sent for all live reports as well as crash reports
5+
- This allows sending file attachments with crash reports
6+
37
## Version 1.6.0
48
- Support for Out of memory detection - Backtrace-cocoa now allows to send information about low memory warnings that application received before application was killed by operating system.
59
- Backtrace-cocoa sets `error.type` attribute that our users can use to filter specific type of reports generated by libraries. List of possible error.types:
@@ -13,8 +17,7 @@
1317
- Allows injecting an instance of PLCrashReporter.
1418
- Resolves the compilation issue on Xcode 10.
1519

16-
## Version 1.5.5
20+
## Version 1.5.5
1721
- Fix issue in Xcode 11 caused by URLSession response being captured before initialization.
1822
- Fix dangling pointer - use withUnsafeMutableBytes in order to explicitly convert the argument to buffer pointer valid for a defined scope.
1923
- Update dependencies, Fastfile and Travis CI configuration.
20-

README.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
9393
3. [Events handling](#documentation-events-handling)
9494
4. [Attributes](#documentation-attributes)
9595
5. [Attachments](#documentation-attachments)
96+
1. [For crash reports/all reports](#documentation-attachments-all)
97+
2. [Per-report](#documentation-attachments-per-report)
9698
6. [Sending reports](#documentation-sending-report)
9799
1. [Error/NSError](#documentation-sending-error)
98100
2. [NSException](#documentation-sending-exception)
@@ -185,7 +187,7 @@ BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration all
185187
BacktraceClient.shared = [[BacktraceClient alloc] initWithConfiguration: configuration error: nil];
186188
```
187189
188-
**Note on parameters**
190+
**Note on parameters**
189191
- `initWithCredentials` and `BacktraceCredentials` see [here](#documentation-client-initialization)
190192
- `dbSettings` see [here](#documentation-database-settings)
191193
- `reportsPerMin` indicates the upper limit of how many reports per minute should be sent to the Backtrace endpoint
@@ -245,7 +247,7 @@ let backtraceConfiguration = BacktraceClientConfiguration(credentials: backtrace
245247
BacktraceClient.shared = try? BacktraceClient(
246248
configuration: backtraceConfiguration,
247249
crashReporter: BacktraceCrashReporter(config: PLCrashReporterConfig.defaultConfiguration()))
248-
// or
250+
// or
249251
BacktraceClient.shared = try? BacktraceClient(
250252
configuration: backtraceConfiguration,
251253
crashReporter: BacktraceCrashReporter(reporter: PLCrashReporter.shared()))
@@ -257,14 +259,14 @@ BacktraceCredentials *credentials = [[BacktraceCredentials alloc]
257259
initWithEndpoint: [NSURL URLWithString: @"https://backtrace.io"]
258260
token: @"token"];
259261

260-
BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration alloc]
262+
BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration alloc]
261263
initWithCredentials: credentials];
262264

263265
BacktraceClient.shared = [[BacktraceClient alloc]
264266
initWithConfiguration: configuration
265267
crashReporter: [[BacktraceCrashReporter alloc] initWithConfig: PLCrashReporterConfig.defaultConfiguration]
266268
error: nil];
267-
269+
268270
// or
269271
BacktraceClient.shared = [[BacktraceClient alloc]
270272
initWithConfiguration: configuration
@@ -332,22 +334,57 @@ BacktraceClient.shared.attributes = @{@"foo": @"bar", @"testing": YES};
332334
Set attributes are attached to each report. You can specify unique set of attributes for specific report in `willSend(_:)` method of `BacktraceClientDelegate`. See [events handling](#documentation-events-handling) for more information.
333335
334336
## Attachments <a name="documentation-attachments"></a>
335-
For each report you can attach files by supplying an array of file paths.
337+
### For crash reports/all reports <a name="documentation-attachments-all"></a>
338+
339+
You can specify file attachments to be sent with every report (including crash reports). File attachments are specified as a `Dictonary` where the keys are a `String` containing the filename (including the extension), and the values are a `URL` containing the path to the file.
340+
- Swift
341+
```swift
342+
guard let libraryDirectoryUrl = try? FileManager.default.url(
343+
for: .libraryDirectory, in: .userDomainMask, appropriateFor: nil, create: true) else {
344+
throw CustomError.runtimeError
345+
}
346+
347+
let fileName = "sample.txt"
348+
let fileUrl = libraryDirectoryUrl.appendingPathComponent(fileName)
349+
350+
var crashAttachments = Attachments()
351+
crashAttachments[fileName] = fileUrl
352+
353+
BacktraceClient.shared?.attachments = crashAttachments
354+
```
355+
- Objective-C
356+
```objective-c
357+
NSString *fileName = @"myCustomFile.txt";
358+
NSURL *libraryUrl = [[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory
359+
inDomains:NSUserDomainMask] lastObject];
360+
NSURL *fileUrl = [libraryUrl URLByAppendingPathComponent:fileName)];
361+
362+
NSArray *attachmentKeys = [NSArray arrayWithObjects:fileName, nil];
363+
NSArray *attachmentObjects = [NSArray arrayWithObjects:fileUrl, nil];
364+
NSDictionary *attachmentDictionary = [NSDictionary dictionaryWithObjects:attachmentObjects
365+
forKeys:attachmentKeys];
366+
367+
BacktraceClient.shared.attachments = attachmentDictionary;
368+
```
369+
370+
### Per Report <a name="documentation-attachments-per-report"></a>
371+
372+
You can also specify per-report file attachments by supplying an array of file paths when sending reports
336373
- Swift
337374
```swift
338375
let filePath = Bundle.main.path(forResource: "test", ofType: "txt")!
339376
BacktraceClient.shared?.send(attachmentPaths: [filePath]) { (result) in
340377
print(result)
341378
}
342379
```
343-
- Objectice-C
380+
- Objective-C
344381
```objective-c
345382
NSArray *paths = @[[[NSBundle mainBundle] pathForResource: @"test" ofType: @"txt"]];
346383
[[BacktraceClient shared] sendWithAttachmentPaths:paths completion:^(BacktraceResult * _Nonnull result) {
347384
NSLog(@"%@", result);
348385
}];
349386
```
350-
Supplied files are attached for each report. You can specify unique set of files for specific report in `willSend(_:)` method of `BacktraceClientDelegate`. See [events handling](#documentation-events-handling) for more information.
387+
Supplied files are attached for each report. You can specify a unique set of files for specific reports in the `willSend(_:)` method of `BacktraceClientDelegate`. See [events handling](#documentation-events-handling) for more information.
351388
352389
## Sending an error report <a name="documentation-sending-report"></a>
353390
Registered `BacktraceClient` will be able to send a crash reports. Error report is automatically generated based.
@@ -443,4 +480,3 @@ Make sure your project is configured to generate the debug symbols:
443480
* Search for `dSYMs` directory
444481
![alt text](https://github.com/backtrace-labs/backtrace-cocoa/blob/master/docs/screenshots/finder-dsyms-archive.png)
445482
* Zip all the `dSYM` files and upload to Backtrace services (see: <a href="https://help.backtrace.io/product-guide/symbolification">Symbolification</a>)
446-

0 commit comments

Comments
 (0)