Skip to content

Conversation

quanganhdo
Copy link
Member

@quanganhdo quanganhdo commented Oct 16, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1205591970852438/task/1210937517613810?focus=true
Tech Design URL:
CC: @THISISDINOSAUR

Description

Adds action id and action type to pixels

Testing Steps

  1. CI passes
  2. Go through the PIR flow and catch m_mac_dbp_search_stage_main_status_error pixel logs (don’t use the Debug tool)

Expect something like this:

👾[Standard-Fired] m_mac_dbp_search_stage_main_status_error ["action_id": "c9babcb9-540e-48ac-900b-b32229e28124", "action_type": "extract", "appVersion": "1.161.0", "broker_version": "0.6.0", "data_broker": "curadvisor.com", "duration": "66900.0", "error_category": "validation-error", "error_details": "Action failed: Action timed out", "is_manual_scan": "true", "pixelSource": "dbpBackgroundAgent", "vpn_bypass": "off", "vpn_connection_state": "disconnected”]

Impact and Risks

Low

What could go wrong?


Note

Enriches scan error pixels with action_id and action_type, updates stage tracking to accept full Action, and propagates this through runners, tests, mocks, and pixel definitions.

  • Pixels/Telemetry:
    • Extend DataBrokerProtectionSharedPixels.scanError to include actionId and actionType; update params mapping to emit action_id and action_type.
    • Add new pixel definitions m_ios_dbp_search_stage_main_status_error and m_mac_dbp_search_stage_main_status_error with action context.
  • Stage tracking:
    • Replace StageDurationCalculator.setLastActionId(_:) with setLastAction(_:); DataBrokerProtectionStageDurationCalculator now tracks actionID and actionType and includes them in scanError (defaults to unknown).
  • Runners:
    • Call stageCalculator.setLastAction(action) when selecting/processing actions in BrokerProfileOptOutSubJobWebRunner, BrokerProfileScanSubJobWebRunner, and SubJobWebRunner.runNextAction.
  • Tests/Mocks:
    • Update tests to assert new scanError shape and added action context; adjust mocks/protocols to setLastAction(_:) and capture actionID/actionType.
  • App debug code:
    • Conform iOS/macOS debug view models to new StageDurationCalculator API.

Written by Cursor Bugbot for commit 93000f4. This will update automatically on new commits. Configure here.

@quanganhdo quanganhdo requested review from Copilot and edulpn October 16, 2025 01:36
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds action id and action type context to scan error pixels for both macOS and iOS, enabling richer diagnostics when PIR scans fail.

  • Introduces new pixel definitions including action metadata.
  • Extends scanError pixel payload and updates calculators, runners, mocks, and tests accordingly.
  • Adds test coverage validating presence and defaulting of action context.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
macOS/PixelDefinitions/pixels/data_broker_protection.json5 Adds macOS scan error pixel definition with action_id and action_type parameters.
iOS/PixelDefinitions/pixels/data_broker_protection.json5 Adds iOS scan error pixel definition with action_id and action_type parameters.
DataBrokerRunCustomJSONViewModel.swift Updates FakeStageDurationCalculator API to new setLastAction signature.
RunDBPDebugModeViewController.swift Updates iOS fake calculator to new setLastAction signature.
DataBrokerProtectionStageDurationCalculatorTests.swift Adjusts pattern matches for added scanError payload fields and adds new tests for action context.
BrokerProfileOptOutSubJobTests.swift Updates test to use new setLastAction API.
Mocks.swift Updates mock to track action id/type with new API.
DataBrokerProtectionStageDurationCalculator.swift Adds actionType storage and includes action id/type in scanError pixel emission.
DataBrokerProtectionSharedPixels.swift Extends scanError case and payload dictionary with action id/type.
SubJobWebRunner.swift Sets last action before running each action (now potentially duplicated).
BrokerProfileScanSubJobWebRunner.swift Adds explicit setLastAction call before runNextAction (duplicate).
BrokerProfileOptOutSubJobWebRunner.swift Replaces setLastActionId with setLastAction (duplicate with runNextAction).

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


let shouldContinue = self.shouldRunNextStep()
if let action = actionsHandler?.nextAction(), shouldContinue {
stageCalculator.setLastAction(action)
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setLastAction(action) is called here and runNextAction(action) also calls stageCalculator.setLastAction(action), resulting in duplicate state updates. Remove one of the calls (prefer keeping it inside runNextAction for a single point of responsibility) to avoid redundant work and keep logic centralized.

Suggested change
stageCalculator.setLastAction(action)

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving it here alone would be similar to how opt-out runner does, but there’s no harm in setting this twice. No strong opinion tho.

Comment on lines +85 to 87
stageCalculator.setLastAction(action)

switch action {
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runNextAction sets the last action directly, but callers (e.g., BrokerProfileScanSubJobWebRunner and BrokerProfileOptOutSubJobWebRunner) also invoke setLastAction before calling runNextAction, causing duplicate calls. Consider removing this call from either the callers or here (keeping it only inside runNextAction is clearer and prevents drift).

Copilot uses AI. Check for mistakes.

let shouldContinue = self.shouldRunNextStep()
if let action = actionsHandler?.nextAction(), shouldContinue {
stageCalculator.setLastActionId(action.id)
stageCalculator.setLastAction(action)
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate setting of last action: runNextAction(action) also invokes stageCalculator.setLastAction(action). Remove one of the invocations to avoid redundant state assignments and keep behavior centralized.

Suggested change
stageCalculator.setLastAction(action)

Copilot uses AI. Check for mistakes.

cursor[bot]

This comment was marked as outdated.

Copy link

Privacy Review task: https://app.asana.com/0/69071770703008/1211655752169607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant