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

DBP: Add sleep duration on pixels #2771

Merged
merged 2 commits into from
May 15, 2024

Conversation

jotaemepereira
Copy link
Collaborator

Task/Issue URL: https://app.asana.com/0/1199230911884351/1207278682082256/f
Tech Design URL:
CC:

Description:
Creates a sleep observer that checks for each scan being run when the computer goest to sleep and calculates that time. Then the time that computer has been set to sleep is added as a parameter in the site and post site loading pixels.

Steps to test this PR:
This is not easy to test; I recommend doing the following because the timing of the sleep matters.

Add the following function to the ScanOperation and import IOKit. Then call the putComputerToSleep when the task starts after line 82.

func putComputerToSleep() {
        let task = Process()
        task.launchPath = "/usr/bin/pmset"
        task.arguments = ["sleepnow"]

        let pipe = Pipe()
        task.standardOutput = pipe
        task.launch()
        task.waitUntilExit()
    }
  • Start PIR from scratch and use a profile with many profile queries (two names and two addresses are okay).
  • Make sure you attach the debugger on Xcode to the background agent
  • Then, when the initial scans start, the computer will setup to sleep automatically.
  • Wait 10 minutes
  • Come back and kill the agent from the terminal (to avoid putting your sleep again), you should have this command in hand.
  • Check the logs on Xcode, you should see the sleep duration set in some of the brokers, you can also check the SleepObserver logs with some information.

@jotaemepereira jotaemepereira requested a review from Bunn May 13, 2024 19:32
@jotaemepereira jotaemepereira merged commit d6f9f50 into main May 15, 2024
19 checks passed
@jotaemepereira jotaemepereira deleted the juan/dbp/metrics-for-sleep-events branch May 15, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants