-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBugSplatUploadService.h
More file actions
133 lines (116 loc) · 4.88 KB
/
BugSplatUploadService.h
File metadata and controls
133 lines (116 loc) · 4.88 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//
// BugSplatUploadService.h
//
// Copyright © BugSplat, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BugSplatAttachment.h"
#import "BugSplatTestSupport.h"
NS_ASSUME_NONNULL_BEGIN
/**
* Metadata to include with crash report upload.
* All values represent crash-time context - they may differ from current app values
* if the app was updated between when the crash occurred and when it's uploaded.
*/
@interface BugSplatCrashMetadata : NSObject
/**
* Crash-time context - these values are captured when the crash occurs and may
* differ from current app values if the app was updated before the crash is uploaded.
*/
@property (nonatomic, copy, nullable) NSString *database;
@property (nonatomic, copy, nullable) NSString *applicationName;
@property (nonatomic, copy, nullable) NSString *applicationVersion;
@property (nonatomic, copy, nullable) NSString *userName;
@property (nonatomic, copy, nullable) NSString *userEmail;
@property (nonatomic, copy, nullable) NSString *userDescription;
@property (nonatomic, copy, nullable) NSString *applicationLog;
@property (nonatomic, copy, nullable) NSString *applicationKey;
@property (nonatomic, copy, nullable) NSString *notes;
@property (nonatomic, copy, nullable) NSDictionary<NSString *, NSString *> *attributes;
/**
* The time the crash occurred (ISO 8601 formatted string).
* This may differ from upload time if the crash couldn't be sent immediately.
*/
@property (nonatomic, copy, nullable) NSString *crashTime;
/**
* The crash type ID to use for this upload.
* When set, overrides the default platform-specific crash type ID.
* Use @"36" for user feedback submissions.
*/
@property (nonatomic, copy, nullable) NSString *crashTypeId;
@end
/**
* Completion handler for upload operations.
*
* @param success YES if the upload was successful.
* @param error Error object if the upload failed, nil otherwise.
* @param infoUrl URL to the crash report details page (only provided on success).
*/
typedef void(^BugSplatUploadCompletion)(BOOL success, NSError * _Nullable error, NSString * _Nullable infoUrl);
/**
* Service for uploading crash reports to BugSplat servers.
* Implements the S3 presigned URL upload flow.
*/
@interface BugSplatUploadService : NSObject
/**
* Creates a new upload service instance.
*
* @param database The BugSplat database name.
* @param applicationName The application name.
* @param applicationVersion The application version string.
* @return A configured upload service instance.
*/
- (instancetype)initWithDatabase:(NSString *)database
applicationName:(NSString *)applicationName
applicationVersion:(NSString *)applicationVersion;
/**
* Creates a new upload service instance with a custom URL session (for testing).
*
* @param database The BugSplat database name.
* @param applicationName The application name.
* @param applicationVersion The application version string.
* @param urlSession A custom URL session conforming to BugSplatURLSessionProtocol.
* @return A configured upload service instance.
*/
- (instancetype)initWithDatabase:(NSString *)database
applicationName:(NSString *)applicationName
applicationVersion:(NSString *)applicationVersion
urlSession:(id<BugSplatURLSessionProtocol>)urlSession;
/**
* Uploads a crash report to BugSplat.
*
* @param crashData The crash report data (will be zipped before upload).
* @param crashFilename The filename to use for the crash report inside the zip.
* @param attachments Optional array of attachments to include.
* @param metadata Optional metadata (user info, description, etc).
* @param completion Called when upload completes or fails.
*/
- (void)uploadCrashReport:(NSData *)crashData
crashFilename:(NSString *)crashFilename
attachments:(nullable NSArray<BugSplatAttachment *> *)attachments
metadata:(nullable BugSplatCrashMetadata *)metadata
completion:(BugSplatUploadCompletion)completion;
/**
* Uploads user feedback to BugSplat.
*
* Creates a feedback.json file containing the title and description,
* zips it along with any attachments, and uploads using the standard
* 3-step presigned URL flow with crashTypeId=36 (User.Feedback).
*
* @param title The feedback title.
* @param description Optional feedback description.
* @param attachments Optional array of file attachments to include.
* @param metadata Metadata (database, app info, user info, etc).
* @param completion Called when upload completes or fails.
*/
- (void)uploadFeedback:(NSString *)title
description:(nullable NSString *)description
attachments:(nullable NSArray<BugSplatAttachment *> *)attachments
metadata:(BugSplatCrashMetadata *)metadata
completion:(void (^)(NSError * _Nullable error))completion;
/**
* Cancels any in-progress upload.
*/
- (void)cancelUpload;
@end
NS_ASSUME_NONNULL_END