Skip to content

Commit

Permalink
nudgeEventLaunchDelay is now nudgeMajorUpgradeEventLaunchDelay and nu…
Browse files Browse the repository at this point in the history
…dgeMinorUpdateEventLaunchDelay
  • Loading branch information
erikng committed Jul 11, 2024
1 parent 29ce1c6 commit ba31645
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Requires macOS 12.0 and higher. Further releases and feature requests may make t
- `standardMajorUpgradeSLA` under the `osVersionRequirement` key will default to 28 days
- `standardMinorUpdateSLA` under the `osVersionRequirement` key will default to 28 days
- These dates are calculated against the `ReleaseDate` key in the SOFA feed, which is UTC formatted. Local timezones will **not be supported** with the automatic sofa feed unless you use a custom feed and change this value yourself, following ISO-8601 date formats
- To artificially delay the SOFA nudge events, see the details below for `nudgeEventLaunchDelay`
- To artificially delay the SOFA nudge events, see the details below for `nudgeMajorUpgradeEventLaunchDelay` and `nudgeMinorUpdateEventLaunchDelay`
- If you'd like to not have nudge events for releases without any known CVEs, please configure the `disableNudgeForStandardInstalls` key under `optionalFeatures` to true
- You can now disable the `Days Remaining To Update:` item on the left side of the UI.
- Configure the `showDaysRemainingToUpdate` key under `userInterface` to false
Expand All @@ -47,7 +47,7 @@ Requires macOS 12.0 and higher. Further releases and feature requests may make t
- Issue [475](https://github.com/macadmins/nudge/issues/475)

### Added
- To artificially change the `requredInstallationDate` thereby giving your users a default grace period for all Nudge events updates, please configure the `nudgeEventLaunchDelay` key under `userExperience`
- To artificially change the `requredInstallationDate` thereby giving your users a default grace period for all Nudge events updates, please configure the `nudgeMajorUpgradeEventLaunchDelay` and `nudgeMinorUpdateEventLaunchDelay` keys under `userExperience` in amount of days.
- A local image path can now be specified for the notification event when Nudge terminates and application
- Please configure the `applicationTerminatedNotificationImagePath` key under `userInterface`
- Due to limitations within Apple's API, a local path is only supported at this time
Expand Down
12 changes: 9 additions & 3 deletions Nudge/Preferences/DefaultPreferencesNudge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,15 @@ struct UserExperienceVariables {
false
}

static var nudgeEventLaunchDelay: Int {
userExperienceProfile?["nudgeEventLaunchDelay"] as? Int ??
userExperienceJSON?.nudgeEventLaunchDelay ??
static var nudgeMinorUpdateEventLaunchDelay: Int {
userExperienceProfile?["nudgeMinorUpdateEventLaunchDelay"] as? Int ??
userExperienceJSON?.nudgeMinorUpdateEventLaunchDelay ??
0
}

static var nudgeMajorUpgradeEventLaunchDelay: Int {
userExperienceProfile?["nudgeMajorUpgradeEventLaunchDelay"] as? Int ??
userExperienceJSON?.nudgeMajorUpgradeEventLaunchDelay ??
0
}

Expand Down
9 changes: 6 additions & 3 deletions Nudge/Preferences/PreferencesStructure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ struct UserExperience: Codable {
var loadLaunchAgent: Bool?
var maxRandomDelayInSeconds: Int?
var noTimers: Bool?
var nudgeEventLaunchDelay: Int?
var nudgeMajorUpgradeEventLaunchDelay: Int?
var nudgeMinorUpdateEventLaunchDelay: Int?
var nudgeRefreshCycle: Int?
var randomDelay: Bool?
}
Expand Down Expand Up @@ -414,7 +415,8 @@ extension UserExperience {
loadLaunchAgent: Bool? = nil,
maxRandomDelayInSeconds: Int? = nil,
noTimers: Bool? = nil,
nudgeEventLaunchDelay: Int? = nil,
nudgeMajorUpgradeEventLaunchDelay: Int? = nil,
nudgeMinorUpdateEventLaunchDelay: Int? = nil,
nudgeRefreshCycle: Int? = nil,
randomDelay: Bool? = nil
) -> UserExperience {
Expand All @@ -439,7 +441,8 @@ extension UserExperience {
loadLaunchAgent: loadLaunchAgent ?? self.loadLaunchAgent,
maxRandomDelayInSeconds: maxRandomDelayInSeconds ?? self.maxRandomDelayInSeconds,
noTimers: noTimers ?? self.noTimers,
nudgeEventLaunchDelay: nudgeEventLaunchDelay ?? self.nudgeEventLaunchDelay,
nudgeMajorUpgradeEventLaunchDelay: nudgeMajorUpgradeEventLaunchDelay ?? self.nudgeMajorUpgradeEventLaunchDelay,
nudgeMinorUpdateEventLaunchDelay: nudgeMinorUpdateEventLaunchDelay ?? self.nudgeMinorUpdateEventLaunchDelay,
nudgeRefreshCycle: nudgeRefreshCycle ?? self.nudgeRefreshCycle,
randomDelay: randomDelay ?? self.randomDelay
)
Expand Down
14 changes: 10 additions & 4 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,21 @@ struct AppStateManager {
}

func delayNudgeEventLogic(currentDate: Date = DateManager().getCurrentDate(), testFileDate: Date? = nil) -> Date {
if UserExperienceVariables.nudgeEventLaunchDelay == 0 {
let isMajorUpgradeRequired = AppStateManager().requireMajorUpgrade()
let launchDelay = isMajorUpgradeRequired ? UserExperienceVariables.nudgeMajorUpgradeEventLaunchDelay : UserExperienceVariables.nudgeMinorUpdateEventLaunchDelay

if launchDelay == 0 {
return PrefsWrapper.requiredInstallationDate
}
if releaseDate.addingTimeInterval(TimeInterval(UserExperienceVariables.nudgeEventLaunchDelay * 86400)) > currentDate {
LogManager.info("Device within nudgeEventLaunchDelay, exiting Nudge", logger: uiLog)

if releaseDate.addingTimeInterval(TimeInterval(launchDelay * 86400)) > currentDate {
let eventType = isMajorUpgradeRequired ? "nudgeMajorUpgradeEventLaunchDelay" : "nudgeMinorUpdateEventLaunchDelay"
LogManager.info("Device within \(eventType)", logger: uiLog)
nudgePrimaryState.shouldExit = true
return currentDate
} else {
LogManager.info("Device outside nudgeEventLaunchDelay", logger: uiLog)
let eventType = isMajorUpgradeRequired ? "nudgeMajorUpgradeEventLaunchDelay" : "nudgeMinorUpdateEventLaunchDelay"
LogManager.info("Device outside \(eventType)", logger: uiLog)
return PrefsWrapper.requiredInstallationDate
}
}
Expand Down
23 changes: 21 additions & 2 deletions Schema/jamf/com.github.macadmins.Nudge.json
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,27 @@
}
]
},
"nudgeEventLaunchDelay": {
"description": "When a new update is posted to the SOFA feed, this can artificially delay the SOFA nudge events by x amount of days. (Note: This key is only used with Nudge v2.0 and higher)",
"nudgeMajorUpgradeEventLaunchDelay": {
"description": "When a new major upgrade is posted to the SOFA feed, this can artificially delay the SOFA nudge events by x amount of days. (Note: This key is only used with Nudge v2.0 and higher)",
"anyOf": [
{
"title": "Not Configured",
"type": "null"
},
{
"title": "Configured",
"default": 0,
"type": "integer",
"options": {
"inputAttributes": {
"placeholder": "0"
}
}
}
]
},
"nudgeMinorUpdateEventLaunchDelay": {
"description": "When a new minor update is posted to the SOFA feed, this can artificially delay the SOFA nudge events by x amount of days. (Note: This key is only used with Nudge v2.0 and higher)",
"anyOf": [
{
"title": "Not Configured",
Expand Down

0 comments on commit ba31645

Please sign in to comment.