Add verbose INFO logging to TimeSafariNativeFetcher for dual-notification debugging
Log configure-time starred plan count, fetchContent entry (trigger, scheduledTime, thread), worker start, POST summary (plan count, truncated afterId), and HTTP status at INFO so logcat shows clearly when the native fetcher runs versus plugin-only DNP-FETCH paths.
This commit is contained in:
@@ -65,12 +65,22 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
|
|||||||
this.apiBaseUrl = apiBaseUrl;
|
this.apiBaseUrl = apiBaseUrl;
|
||||||
this.activeDid = activeDid;
|
this.activeDid = activeDid;
|
||||||
this.jwtToken = jwtToken;
|
this.jwtToken = jwtToken;
|
||||||
Log.i(TAG, "Configured with API: " + apiBaseUrl);
|
int starredCount = getStarredPlanIds().size();
|
||||||
|
Log.i(TAG, "Configured with API: " + apiBaseUrl + ", starredPlanIds count=" + starredCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<List<NotificationContent>> fetchContent(@NonNull FetchContext fetchContext) {
|
public CompletableFuture<List<NotificationContent>> fetchContent(@NonNull FetchContext fetchContext) {
|
||||||
|
Long scheduled = fetchContext.scheduledTime;
|
||||||
|
Log.i(
|
||||||
|
TAG,
|
||||||
|
"fetchContent START trigger="
|
||||||
|
+ fetchContext.trigger
|
||||||
|
+ " scheduledTime="
|
||||||
|
+ (scheduled != null ? scheduled : "null")
|
||||||
|
+ " callerThread="
|
||||||
|
+ Thread.currentThread().getName());
|
||||||
Log.d(TAG, "Fetching notification content, trigger: " + fetchContext.trigger);
|
Log.d(TAG, "Fetching notification content, trigger: " + fetchContext.trigger);
|
||||||
return fetchContentWithRetry(fetchContext, 0);
|
return fetchContentWithRetry(fetchContext, 0);
|
||||||
}
|
}
|
||||||
@@ -79,6 +89,7 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
|
|||||||
@NonNull FetchContext context, int retryCount) {
|
@NonNull FetchContext context, int retryCount) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
try {
|
||||||
|
Log.i(TAG, "fetchContent worker thread=" + Thread.currentThread().getName());
|
||||||
if (apiBaseUrl == null || activeDid == null || jwtToken == null) {
|
if (apiBaseUrl == null || activeDid == null || jwtToken == null) {
|
||||||
Log.e(TAG, "Not configured. Call configureNativeFetcher() from TypeScript first.");
|
Log.e(TAG, "Not configured. Call configureNativeFetcher() from TypeScript first.");
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@@ -95,12 +106,21 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
|
|||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
|
|
||||||
Map<String, Object> requestBody = new HashMap<>();
|
Map<String, Object> requestBody = new HashMap<>();
|
||||||
requestBody.put("planIds", getStarredPlanIds());
|
List<String> planIds = getStarredPlanIds();
|
||||||
|
requestBody.put("planIds", planIds);
|
||||||
String afterId = getLastAcknowledgedJwtId();
|
String afterId = getLastAcknowledgedJwtId();
|
||||||
if (afterId == null || afterId.isEmpty()) {
|
if (afterId == null || afterId.isEmpty()) {
|
||||||
afterId = "0";
|
afterId = "0";
|
||||||
}
|
}
|
||||||
requestBody.put("afterId", afterId);
|
requestBody.put("afterId", afterId);
|
||||||
|
Log.i(
|
||||||
|
TAG,
|
||||||
|
"POST "
|
||||||
|
+ ENDORSER_ENDPOINT
|
||||||
|
+ " planCount="
|
||||||
|
+ planIds.size()
|
||||||
|
+ " afterId="
|
||||||
|
+ (afterId.length() > 12 ? afterId.substring(0, 12) + "…" : afterId));
|
||||||
|
|
||||||
String jsonBody = gson.toJson(requestBody);
|
String jsonBody = gson.toJson(requestBody);
|
||||||
try (OutputStream os = connection.getOutputStream()) {
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
@@ -109,7 +129,7 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
|
|||||||
}
|
}
|
||||||
|
|
||||||
int responseCode = connection.getResponseCode();
|
int responseCode = connection.getResponseCode();
|
||||||
Log.d(TAG, "HTTP response code: " + responseCode);
|
Log.i(TAG, "HTTP response code: " + responseCode);
|
||||||
|
|
||||||
if (responseCode == 200) {
|
if (responseCode == 200) {
|
||||||
StringBuilder response = new StringBuilder();
|
StringBuilder response = new StringBuilder();
|
||||||
|
|||||||
Reference in New Issue
Block a user