This repository was archived by the owner on Feb 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathNewTabBackgroundPixel.swift
172 lines (154 loc) · 7.15 KB
/
NewTabBackgroundPixel.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//
// NewTabBackgroundPixel.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import PixelKit
/**
* This enum keeps pixels related to New Tab page background customization.
*
* > Related links:
* [Privacy Triage](https://app.asana.com/0/69071770703008/1208146890364172/f)
* [Detailed Pixels description](https://app.asana.com/0/1201621708115095/1207983904350396/f)
*/
enum NewTabBackgroundPixel: PixelKitEventV2 {
/**
* Event Trigger: User selects gradient as custom NTP background.
*
* Anomaly Investigation:
* - `customBackground` is updated with this value from `HomePage.Models.SettingsModel` and `HomePage.Views.BackgroundPickerView`.
* - Check the above places in code and make sure nothing got broken to cause the update to be fired repeatedly.
*/
case newTabBackgroundSelectedGradient
/**
* Event Trigger: User selects solid color as custom NTP background.
*
* Anomaly Investigation:
* - `customBackground` is updated with this value from `HomePage.Models.SettingsModel` and `HomePage.Views.BackgroundPickerView`.
* - Check the above places in code and make sure nothing got broken to cause the update to be fired repeatedly.
*/
case newTabBackgroundSelectedSolidColor
/**
* Event Trigger: User selects a user-uploaded image as custom NTP background.
*
* Anomaly Investigation:
* - `customBackground` is updated with this value from `HomePage.Models.SettingsModel` and `HomePage.Views.BackgroundPickerView`.
* - Check the above places in code and make sure nothing got broken to cause the update to be fired repeatedly.
*/
case newTabBackgroundSelectedUserImage
/**
* Event Trigger: User removes custom NTP background.
*
* Anomaly Investigation:
* - `customBackground` is updated with this value from `HomePage.Models.SettingsModel` and `HomePage.Views.SettingsView`.
* - Check the above places in code and make sure nothing got broken to cause the update to be fired repeatedly.
*/
case newTabBackgroundReset
/**
* Event Trigger: User uploads new image to be used as custom NTP background.
*
* Anomaly Investigation:
* - Check `UserBackgroundImagesManager.addImage(with:)` where this pixel is fired.
* - Check `HomePage.Models.SettingsModel.addNewImage()` where images manager's `addImage(with:)` is called.
*/
case newTabBackgroundAddedUserImage
/**
* Event Trigger: User deletes an image from the list of user-provided backgrounds.
*
* Anomaly Investigation:
* - Check `UserBackgroundImagesManager.deleteImage(_:)` where this pixel is fired.
* - Check `BackgroundThumbnailView` where images manager's `deleteImage(_:)` is called.
*/
case newTabBackgroundDeletedUserImage
// MARK: - Debug
/**
* Event Trigger: User images storage directory can't be set up properly.
*
* Anomaly Investigation:
* - Check `UserBackgroundImagesManager`'s initializer, where this pixel is fired.
* - The pixel is fired when calls to `setUpStorageDirectory(at:)` throw an error.
* - If the logic looks good, the anomaly may be coming from a single user with permissions
* issue or no space left on disk, restarting the app frequently.
*/
case newTabBackgroundInitializeStorageError
/**
* Event Trigger: Adding user's own image fails (i.e. file name has image extension but the file itself is not an image).
*
* Anomaly Investigation:
* - This will likely be an error with either `FileManager` and disk access,
* or with `ImageProcessor` and image manipulation logic.
* - Consult the error parameter to learn more. `ImageProcessingError` should give you more visibility into what got broken.
*/
case newTabBackgroundAddImageError
/**
* Event Trigger: Generating thumbnail for an image fails.
*
* Anomaly Investigation:
* - This will likely be an error with either `FileManager` and disk access,
* or with `ImageProcessor` and image manipulation logic.
* - Consult the error parameter to learn more. `ImageProcessingError` should give you more visibility into what got broken.
*/
case newTabBackgroundThumbnailGenerationError
/**
* Event Trigger: Previously uploaded user's own image couldn't be loaded from disk.
*
* > Note: This pixel should only be fired once per file per app session.
*
* Anomaly Investigation:
* - This could happen when a user modifies their app data directory and removes files.
* - If there's an anomaly, it may be related to the logic in our code getting broken.
* See `UserBackgroundImagesManager.image(for:)` and verify that the logic is correct.
*/
case newTabBackgroundImageNotFound
/**
* Event Trigger: Previously uploaded user's own image thumbnail couldn't be loaded from disk
*
* > Note: This pixel should only be fired once per file per app session.
*
* Anomaly Investigation:
* - This could happen when a user modifies their app data directory and removes files.
* - If there's an anomaly, it may be related to the logic in our code getting broken.
* See `UserBackgroundImagesManager.thumbnailImage(for:)` and verify that the logic is correct.
*/
case newTabBackgroundThumbnailNotFound
var name: String {
switch self {
case .newTabBackgroundSelectedGradient:
return "m_mac_newtab_background_selected-gradient"
case .newTabBackgroundSelectedSolidColor:
return "m_mac_newtab_background_selected-solid-color"
case .newTabBackgroundSelectedUserImage:
return "m_mac_newtab_background_selected-user-image"
case .newTabBackgroundAddedUserImage:
return "m_mac_newtab_background_added-user-image"
case .newTabBackgroundDeletedUserImage:
return "m_mac_newtab_background_deleted-user-image"
case .newTabBackgroundReset:
return "m_mac_newtab_background_reset"
case .newTabBackgroundInitializeStorageError: return "newtab_background_initialize-storage-error"
case .newTabBackgroundAddImageError: return "newtab_background_add-image-error"
case .newTabBackgroundThumbnailGenerationError: return "newtab_background_thumbnail-generation-error"
case .newTabBackgroundImageNotFound: return "newtab_background_image-not-found"
case .newTabBackgroundThumbnailNotFound: return "newtab_background_thumbnail-not-found"
}
}
var parameters: [String: String]? {
nil
}
var error: (any Error)? {
nil
}
}