Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error codes to site breakage reports #642

Merged
merged 32 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ebd0e6b
tap close enabled in privacy dashboard for macOS
federicocappelli Dec 14, 2023
f342036
Merge branch 'main' into fcappelli/breakage_improvement_mac
federicocappelli Dec 20, 2023
c131332
privacy dashboard code cleanup and model shared
federicocappelli Dec 20, 2023
12e535f
updated to latest dashboard
Jan 9, 2024
c49e72d
Report broken site refactored, all business logic and models are now …
federicocappelli Jan 9, 2024
d1a5357
Merge branch 'fcappelli/breakage_improvement_mac' of https://github.c…
federicocappelli Jan 9, 2024
6394810
Merge branch 'main' into fcappelli/breakage_improvement_mac
federicocappelli Jan 9, 2024
f1e796a
swiftlint --fix
federicocappelli Jan 10, 2024
7e1a7a4
Merge branch 'main' into fcappelli/breakage_improvement_mac
federicocappelli Jan 10, 2024
f4560fc
submodule updated
federicocappelli Jan 10, 2024
a9551e1
swiftlint violations fixed
federicocappelli Jan 10, 2024
3b8ac06
Website breakage init differentiated for iOS and macOS
federicocappelli Jan 10, 2024
e3d2ddd
swiftlint fix
federicocappelli Jan 10, 2024
b235408
debug logs sanithised
federicocappelli Jan 10, 2024
dc60cf4
unit tests fixed
federicocappelli Jan 10, 2024
1f8b8df
folder name reverted
federicocappelli Jan 10, 2024
6f7f380
schemes removed
federicocappelli Jan 10, 2024
37c369a
bsk scheme
federicocappelli Jan 10, 2024
fe51d88
.swiftpm/xcode/xcshareddata/xcschemes/BrowserServicesKit.xcscheme rev…
federicocappelli Jan 10, 2024
20fff59
allowedQueryReservedCharacters moved
federicocappelli Jan 10, 2024
252ebde
accessibility fix
federicocappelli Jan 10, 2024
7dd2e92
swiftlint fix
federicocappelli Jan 10, 2024
690024c
manufacturer: "Apple" added
federicocappelli Jan 10, 2024
18b7151
report broken site history url privacy sanitisation improved
federicocappelli Jan 11, 2024
d10308a
url sanitation and unit test improved
federicocappelli Jan 11, 2024
887e144
Merge branch 'main' into fcappelli/breakage_improvement_mac
federicocappelli Jan 17, 2024
0d5a890
Change types and names
jaceklyp Jan 25, 2024
742fa13
Merge branch 'main' into jacek/error-codes
jaceklyp Jan 29, 2024
bbef20e
Merge branch 'main' into jacek/error-codes
jaceklyp Jan 30, 2024
b3c3851
Fix issues
jaceklyp Jan 30, 2024
3d10d5c
Send swift error localized description
jaceklyp Jan 30, 2024
6ee63e2
Fix tests
jaceklyp Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions Sources/PrivacyDashboard/WebsiteBreakage/WebsiteBreakage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public struct WebsiteBreakage {
let reportFlow: Source
let protectionsState: Bool
var lastSentDay: String?
let error: Error?
let httpStatusCode: Int?
#if os(iOS)
let siteType: SiteType // ?? not in documentation
let atb: String
Expand All @@ -73,7 +75,9 @@ public struct WebsiteBreakage {
ampURL: String,
urlParametersRemoved: Bool,
protectionsState: Bool,
reportFlow: Source
reportFlow: Source,
error: Error?,
httpStatusCode: Int?
) {
self.siteUrl = siteUrl
self.category = category
Expand All @@ -89,6 +93,8 @@ public struct WebsiteBreakage {
self.protectionsState = protectionsState
self.urlParametersRemoved = urlParametersRemoved
self.reportFlow = reportFlow
self.error = error
self.httpStatusCode = httpStatusCode
}
#endif

Expand All @@ -110,7 +116,9 @@ public struct WebsiteBreakage {
reportFlow: Source,
siteType: SiteType,
atb: String,
model: String
model: String,
error: Error?,
httpStatusCode: Int?
) {
self.siteUrl = siteUrl
self.category = category
Expand All @@ -129,12 +137,14 @@ public struct WebsiteBreakage {
self.siteType = siteType
self.atb = atb
self.model = model
self.error = error
self.httpStatusCode = httpStatusCode
}
#endif

/// A dictionary containing all the parameters needed from the Report Broken Site Pixel
public var requestParameters: [String: String] {
var result = [
var result: [String: String] = [
"siteUrl": siteUrl.trimmingQueryItemsAndFragment().absoluteString,
"category": category,
"description": description ?? "",
Expand All @@ -155,6 +165,17 @@ public struct WebsiteBreakage {
result["lastSentDay"] = lastSentDay
}

if let httpStatusCode {
result["httpErrorCode"] = String(httpStatusCode)
}

if let error = error as NSError? {
let errorDescription = "\(error.code) - \(error.localizedDescription)"
federicocappelli marked this conversation as resolved.
Show resolved Hide resolved
result["errorDescription"] = errorDescription
} else if let error {
result["errorDescription"] = error.localizedDescription
}

#if os(iOS)
result["siteType"] = siteType.rawValue
result["atb"] = atb
Expand Down
12 changes: 9 additions & 3 deletions Tests/PrivacyDashboardTests/WebsiteBreakageMoks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ struct WebsiteBreakageMoks {
ampURL: "test",
urlParametersRemoved: true,
protectionsState: true,
reportFlow: .appMenu)
reportFlow: .appMenu,
error: nil,
httpStatusCode: nil)
}

static var testBreakage2: WebsiteBreakage {
Expand All @@ -52,7 +54,9 @@ struct WebsiteBreakageMoks {
ampURL: "test",
urlParametersRemoved: true,
protectionsState: true,
reportFlow: .appMenu)
reportFlow: .appMenu,
error: nil,
httpStatusCode: nil)
}

static var testBreakage3: WebsiteBreakage {
Expand All @@ -69,6 +73,8 @@ struct WebsiteBreakageMoks {
ampURL: "test",
urlParametersRemoved: true,
protectionsState: true,
reportFlow: .appMenu)
reportFlow: .appMenu,
error: nil,
httpStatusCode: nil)
}
}
Loading