Skip to content

Commit b7f8432

Browse files
authored
1 parent dbfd1da commit b7f8432

File tree

9 files changed

+171
-191
lines changed

9 files changed

+171
-191
lines changed

pir/pir-internal/src/main/java/com/duckduckgo/pir/internal/common/PirRunStateHandler.kt

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class RealPirRunStateHandler @Inject constructor(
171171
}
172172

173173
private suspend fun handleBrokerManualScanStarted(state: BrokerManualScanStarted) {
174-
pixelSender.reportManualScanBrokerStarted(state.brokerName)
174+
pixelSender.reportBrokerScanStarted(state.brokerName)
175175
repository.saveBrokerScanLog(
176176
PirBrokerScanLog(
177177
eventTimeInMillis = state.eventTimeInMillis,
@@ -183,7 +183,11 @@ class RealPirRunStateHandler @Inject constructor(
183183

184184
private suspend fun handleBrokerManualScanCompleted(state: BrokerManualScanCompleted) {
185185
handleScanError(state.isSuccess, state.brokerName, state.profileQueryId)
186-
186+
pixelSender.reportBrokerScanCompleted(
187+
brokerName = state.brokerName,
188+
totalTimeInMillis = state.totalTimeMillis,
189+
isSuccess = state.isSuccess,
190+
)
187191
repository.saveBrokerScanLog(
188192
PirBrokerScanLog(
189193
eventTimeInMillis = state.eventTimeInMillis,
@@ -198,16 +202,10 @@ class RealPirRunStateHandler @Inject constructor(
198202
endTimeInMillis = state.eventTimeInMillis,
199203
isSuccess = state.isSuccess,
200204
)
201-
202-
pixelSender.reportManualScanBrokerCompleted(
203-
brokerName = state.brokerName,
204-
totalTimeInMillis = state.totalTimeMillis,
205-
isSuccess = state.isSuccess,
206-
)
207205
}
208206

209207
private suspend fun handleBrokerScheduledScanStarted(state: BrokerScheduledScanStarted) {
210-
pixelSender.reportScheduledScanBrokerStarted(state.brokerName)
208+
pixelSender.reportBrokerScanStarted(state.brokerName)
211209
repository.saveBrokerScanLog(
212210
PirBrokerScanLog(
213211
eventTimeInMillis = state.eventTimeInMillis,
@@ -218,7 +216,8 @@ class RealPirRunStateHandler @Inject constructor(
218216
}
219217

220218
private suspend fun handleBrokerScheduledScanCompleted(state: BrokerScheduledScanCompleted) {
221-
pixelSender.reportScheduledScanBrokerCompleted(
219+
handleScanError(state.isSuccess, state.brokerName, state.profileQueryId)
220+
pixelSender.reportBrokerScanCompleted(
222221
brokerName = state.brokerName,
223222
totalTimeInMillis = state.totalTimeMillis,
224223
isSuccess = state.isSuccess,
@@ -237,8 +236,6 @@ class RealPirRunStateHandler @Inject constructor(
237236
endTimeInMillis = state.eventTimeInMillis,
238237
isSuccess = state.isSuccess,
239238
)
240-
241-
handleScanError(state.isSuccess, state.brokerName, state.profileQueryId)
242239
}
243240

244241
private suspend fun handleBrokerScanActionSucceeded(state: BrokerScanActionSucceeded) {
@@ -280,27 +277,25 @@ class RealPirRunStateHandler @Inject constructor(
280277
private suspend fun handleRecordOptOutStarted(state: BrokerRecordOptOutStarted) {
281278
jobRecordUpdater.markOptOutAsAttempted(state.extractedProfile.dbId)
282279

283-
pixelSender.reportRecordOptOutStarted(
280+
pixelSender.reportOptOutStarted(
284281
brokerName = state.brokerName,
285282
)
286283
}
287284

288285
private suspend fun handleRecordOptOutCompleted(state: BrokerRecordOptOutCompleted) {
289286
updateOptOutRecord(state.isSubmitSuccess, state.extractedProfile.dbId)
290-
287+
pixelSender.reportOptOutCompleted(
288+
brokerName = state.brokerName,
289+
totalTimeInMillis = state.endTimeInMillis - state.startTimeInMillis,
290+
isSuccess = state.isSubmitSuccess,
291+
)
291292
repository.saveOptOutCompleted(
292293
brokerName = state.brokerName,
293294
extractedProfile = state.extractedProfile,
294295
startTimeInMillis = state.startTimeInMillis,
295296
endTimeInMillis = state.endTimeInMillis,
296297
isSubmitSuccess = state.isSubmitSuccess,
297298
)
298-
299-
pixelSender.reportRecordOptOutCompleted(
300-
brokerName = state.brokerName,
301-
totalTimeInMillis = state.endTimeInMillis - state.startTimeInMillis,
302-
isSuccess = state.isSubmitSuccess,
303-
)
304299
}
305300

306301
private suspend fun handleBrokerOptOutActionSucceeded(state: BrokerOptOutActionSucceeded) {

pir/pir-internal/src/main/java/com/duckduckgo/pir/internal/pixels/PirPixel.kt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,56 +28,56 @@ enum class PirPixel(
2828
) {
2929
PIR_INTERNAL_MANUAL_SCAN_STARTED(
3030
baseName = "pir_internal_manual-scan_started",
31-
types = setOf(Count, Unique()),
31+
type = Count,
3232
),
3333

3434
PIR_INTERNAL_MANUAL_SCAN_COMPLETED(
3535
baseName = "pir_internal_manual-scan_completed",
36-
types = setOf(Count, Unique()),
37-
),
38-
39-
PIR_INTERNAL_MANUAL_SCAN_BROKER_STARTED(
40-
baseName = "pir_internal_manual-scan_broker_started",
41-
type = Count,
42-
),
43-
44-
PIR_INTERNAL_MANUAL_SCAN_BROKER_COMPLETED(
45-
baseName = "pir_internal_manual-scan_broker_completed",
4636
type = Count,
4737
),
4838

4939
PIR_INTERNAL_SCHEDULED_SCAN_SCHEDULED(
5040
baseName = "pir_internal_scheduled-scan_scheduled",
51-
types = setOf(Count, Unique()),
41+
type = Count,
5242
),
5343

5444
PIR_INTERNAL_SCHEDULED_SCAN_STARTED(
5545
baseName = "pir_internal_scheduled-scan_started",
56-
types = setOf(Count, Unique()),
46+
type = Count,
5747
),
5848

5949
PIR_INTERNAL_SCHEDULED_SCAN_COMPLETED(
6050
baseName = "pir_internal_scheduled-scan_completed",
61-
types = setOf(Count, Unique()),
51+
type = Count,
52+
),
53+
54+
PIR_INTERNAL_SCAN_STATS(
55+
baseName = "pir_internal_scan-stats",
56+
type = Count,
57+
),
58+
59+
PIR_INTERNAL_OPT_OUT_STATS(
60+
baseName = "pir_internal_opt-out-stats",
61+
type = Count,
6262
),
6363

64-
PIR_INTERNAL_SCHEDULED_SCAN_BROKER_STARTED(
65-
baseName = "pir_internal_scheduled-scan_broker_started",
64+
PIR_INTERNAL_BROKER_SCAN_STARTED(
65+
baseName = "pir_internal_broker_scan_started",
6666
type = Count,
6767
),
6868

69-
PIR_INTERNAL_SCHEDULED_SCAN_BROKER_COMPLETED(
70-
baseName = "pir_internal_scheduled-scan_broker_completed",
69+
PIR_INTERNAL_BROKER_SCAN_COMPLETED(
70+
baseName = "pir_internal_broker_scan_completed",
7171
type = Count,
7272
),
7373

74-
PIR_INTERNAL_OPT_OUT_RECORD_STARTED(
75-
baseName = "pir_internal_optout_record_started",
74+
PIR_INTERNAL_BROKER_OPT_OUT_STARTED(
75+
baseName = "pir_internal_opt-out_started",
7676
type = Count,
7777
),
7878

79-
PIR_INTERNAL_OPT_OUT_RECORD_COMPLETED(
80-
baseName = "pir_internal_optout_record_completed",
79+
PIR_INTERNAL_BROKER_OPT_OUT_COMPLETED(
80+
baseName = "pir_internal_opt-out_completed",
8181
type = Count,
8282
),
8383

pir/pir-internal/src/main/java/com/duckduckgo/pir/internal/pixels/PirPixelInterceptor.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import org.json.JSONObject
3535
class PirPixelInterceptor @Inject constructor(
3636
private val context: Context,
3737
private val appBuildConfig: AppBuildConfig,
38-
private val networkInfoProvider: NetworkInfoProvider,
3938
) : PixelInterceptorPlugin, Interceptor {
4039
override fun intercept(chain: Interceptor.Chain): Response {
4140
val request = chain.request().newBuilder()
@@ -49,7 +48,6 @@ class PirPixelInterceptor @Inject constructor(
4948
.put("os", appBuildConfig.sdkInt)
5049
.put("batteryOptimizations", (!isIgnoringBatteryOptimizations()).toString())
5150
.put("man", appBuildConfig.manufacturer)
52-
.put("networkInfo", networkInfoProvider.getCurrentNetworkInfo())
5351
.toString().toByteArray().run {
5452
Base64.encodeToString(this, Base64.NO_WRAP or Base64.NO_PADDING or Base64.URL_SAFE)
5553
},

0 commit comments

Comments
 (0)