Skip to content

Commit cf01bff

Browse files
author
Latitude Bot
committed
chore: add debug logging to LauncherSelectionPolicyFilterAware for channel switch debugging
Logs the following information when selectUpdateToLaunch is called: - filterByChannel flag value - config.requestHeaders (should contain expo-channel-name) - config.disableAntiBrickingMeasures value - Total and eligible update counts - Each update's branch vs target channel comparison - Final selection result This will help identify why channel switching is not working as expected. Bump version to 0.0.12.
1 parent 5d2c0d9 commit cf01bff

3 files changed

Lines changed: 49 additions & 9 deletions

File tree

packages/expo-updates/android/src/main/java/expo/modules/updates/selectionpolicy/LauncherSelectionPolicyFilterAware.kt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,32 @@ class LauncherSelectionPolicyFilterAware(
2323
updates: List<UpdateEntity>,
2424
filters: JSONObject?
2525
): UpdateEntity? {
26+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] selectUpdateToLaunch called")
27+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] filterByChannel: $filterByChannel")
28+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] config.requestHeaders: ${config?.requestHeaders}")
29+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] config.disableAntiBrickingMeasures: ${config?.disableAntiBrickingMeasures}")
30+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] total updates: ${updates.size}")
31+
2632
// Filter by runtime version and manifest filters first
2733
val eligibleUpdates = updates.filter {
2834
runtimeVersion == it.runtimeVersion && SelectionPolicies.matchesFilters(it, filters)
2935
}
36+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] eligible updates after runtime filter: ${eligibleUpdates.size}")
3037

3138
// Only apply channel filtering when explicitly requested (during channel switching)
3239
if (!filterByChannel) {
33-
return eligibleUpdates.maxByOrNull { it.commitTime }
40+
val selected = eligibleUpdates.maxByOrNull { it.commitTime }
41+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] filterByChannel is false, selecting by commitTime: ${selected?.id}")
42+
return selected
3443
}
3544

3645
// Get the target channel from config request headers
3746
val targetChannel = config?.requestHeaders?.get("expo-channel-name")
47+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] targetChannel from config: $targetChannel")
3848
if (targetChannel == null) {
39-
return eligibleUpdates.maxByOrNull { it.commitTime }
49+
val selected = eligibleUpdates.maxByOrNull { it.commitTime }
50+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] targetChannel is null, selecting by commitTime: ${selected?.id}")
51+
return selected
4052
}
4153

4254
// Filter by channel when switching environments
@@ -45,6 +57,8 @@ class LauncherSelectionPolicyFilterAware(
4557
val manifest = update.manifest
4658
val updateBranch = manifest.optString("branch", null)
4759
?: manifest.optJSONObject("extra")?.optJSONObject("expoClient")?.optJSONObject("extra")?.optString("LATITUDE_RELEASE_STAGE", null)
60+
61+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] update ${update.id} branch: $updateBranch, target: $targetChannel")
4862

4963
// If update has no branch info, it's an embedded or legacy update - accept it
5064
if (updateBranch == null) return@filter true
@@ -53,12 +67,18 @@ class LauncherSelectionPolicyFilterAware(
5367
updateBranch == targetChannel
5468
}
5569

70+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] channel filtered updates: ${channelFilteredUpdates.size}")
71+
5672
// If channel filtering removed all updates, fall back to non-filtered selection
5773
// This handles the case where the server returned updates from a different channel
5874
if (channelFilteredUpdates.isEmpty()) {
59-
return eligibleUpdates.maxByOrNull { it.commitTime }
75+
val selected = eligibleUpdates.maxByOrNull { it.commitTime }
76+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] no channel matches, fallback to commitTime: ${selected?.id}")
77+
return selected
6078
}
6179

62-
return channelFilteredUpdates.maxByOrNull { it.commitTime }
80+
val selected = channelFilteredUpdates.maxByOrNull { it.commitTime }
81+
android.util.Log.d("LauncherSelectionPolicy", "[ChannelSwitch] selected update: ${selected?.id} with branch matching $targetChannel")
82+
return selected
6383
}
6484
}

packages/expo-updates/ios/EXUpdates/SelectionPolicy/LauncherSelectionPolicyFilterAware.swift

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,32 @@ public final class LauncherSelectionPolicyFilterAware: NSObject, LauncherSelecti
2525
}
2626

2727
public func launchableUpdate(fromUpdates updates: [Update], filters: [String: Any]?) -> Update? {
28+
NSLog("[ChannelSwitch] launchableUpdate called")
29+
NSLog("[ChannelSwitch] filterByChannel: \(filterByChannel)")
30+
NSLog("[ChannelSwitch] config.requestHeaders: \(String(describing: config?.requestHeaders))")
31+
NSLog("[ChannelSwitch] config.disableAntiBrickingMeasures: \(String(describing: config?.disableAntiBrickingMeasures))")
32+
NSLog("[ChannelSwitch] total updates: \(updates.count)")
33+
2834
// Filter by runtime version and manifest filters first
2935
let eligibleUpdates = updates.filter {
3036
runtimeVersion == $0.runtimeVersion && SelectionPolicies.doesUpdate($0, matchFilters: filters)
3137
}
38+
NSLog("[ChannelSwitch] eligible updates after runtime filter: \(eligibleUpdates.count)")
3239

3340
// Only apply channel filtering when explicitly requested (during channel switching)
3441
guard filterByChannel else {
35-
return eligibleUpdates.sorted { $0.commitTime > $1.commitTime }.first
42+
let selected = eligibleUpdates.sorted { $0.commitTime > $1.commitTime }.first
43+
NSLog("[ChannelSwitch] filterByChannel is false, selecting by commitTime: \(String(describing: selected?.updateId))")
44+
return selected
3645
}
3746

3847
// Get the target channel from config request headers
3948
guard let targetChannel = config?.requestHeaders["expo-channel-name"] else {
40-
return eligibleUpdates.sorted { $0.commitTime > $1.commitTime }.first
49+
let selected = eligibleUpdates.sorted { $0.commitTime > $1.commitTime }.first
50+
NSLog("[ChannelSwitch] targetChannel is nil, selecting by commitTime: \(String(describing: selected?.updateId))")
51+
return selected
4152
}
53+
NSLog("[ChannelSwitch] targetChannel from config: \(targetChannel)")
4254

4355
// Filter by channel when switching environments
4456
let channelFilteredUpdates = eligibleUpdates.filter { update in
@@ -58,6 +70,8 @@ public final class LauncherSelectionPolicyFilterAware: NSObject, LauncherSelecti
5870
}
5971
return nil
6072
}()
73+
74+
NSLog("[ChannelSwitch] update \(update.updateId) branch: \(String(describing: updateBranch)), target: \(targetChannel)")
6175

6276
// If update has no branch info, it's an embedded or legacy update - accept it
6377
guard let updateBranch = updateBranch else { return true }
@@ -66,12 +80,18 @@ public final class LauncherSelectionPolicyFilterAware: NSObject, LauncherSelecti
6680
return updateBranch == targetChannel
6781
}
6882

83+
NSLog("[ChannelSwitch] channel filtered updates: \(channelFilteredUpdates.count)")
84+
6985
// If channel filtering removed all updates, fall back to non-filtered selection
7086
// This handles the case where the server returned updates from a different channel
7187
if channelFilteredUpdates.isEmpty {
72-
return eligibleUpdates.sorted { $0.commitTime > $1.commitTime }.first
88+
let selected = eligibleUpdates.sorted { $0.commitTime > $1.commitTime }.first
89+
NSLog("[ChannelSwitch] no channel matches, fallback to commitTime: \(String(describing: selected?.updateId))")
90+
return selected
7391
}
7492

75-
return channelFilteredUpdates.sorted { $0.commitTime > $1.commitTime }.first
93+
let selected = channelFilteredUpdates.sorted { $0.commitTime > $1.commitTime }.first
94+
NSLog("[ChannelSwitch] selected update: \(String(describing: selected?.updateId)) with branch matching \(targetChannel)")
95+
return selected
7696
}
7797
}

packages/expo-updates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@latitudegames/expo-updates",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"description": "Fetches and manages remotely-hosted assets and updates to your app's JS bundle.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

0 commit comments

Comments
 (0)