Skip to content

Commit d83be74

Browse files
author
Lalit Sharma
committed
feat: add detailed parser instrumentation for Google Maps short-link expansion and bump mobile version to 1.1.51
1 parent edc89e7 commit d83be74

3 files changed

Lines changed: 48 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.51] — 2026-02-27
9+
10+
### Added
11+
- Added detailed `[share.debug]` parser instrumentation for Google Maps short-link expansion/fetch/parse steps to improve troubleshooting in Android logcat.
12+
13+
### Changed
14+
- Bumped `apps/mobile` version to `1.1.51`.
15+
816
## [1.1.50] — 2026-02-27
917

1018
### Added

apps/mobile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eclipse-timer/mobile",
3-
"version": "1.1.50",
3+
"version": "1.1.51",
44
"private": true,
55
"main": "index.js",
66
"scripts": {

apps/mobile/src/utils/sharedMapLink.ts

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,15 @@ async function expandShortMapUrlWithResponse(
226226
): Promise<ExpandedShortMapUrlResult> {
227227
const parsed = parseUrl(url);
228228
if (!parsed || !isGoogleShortHost(parsed.hostname)) {
229+
console.info("[share.debug] expand_not_short", url);
229230
return { expandedUrl: url, responseText: null };
230231
}
231232

232233
const fetchImpl =
233234
options.fetchImpl ??
234235
(typeof fetch === "function" ? (fetch as unknown as FetchLike) : undefined);
235236
if (!fetchImpl) {
237+
console.info("[share.debug] expand_no_fetch");
236238
return { expandedUrl: url, responseText: null };
237239
}
238240

@@ -241,6 +243,8 @@ async function expandShortMapUrlWithResponse(
241243
? Math.max(1, Math.floor(options.timeoutMs))
242244
: DEFAULT_EXPAND_TIMEOUT_MS;
243245

246+
console.info("[share.debug] expand_fetching", { url, timeoutMs });
247+
244248
try {
245249
const response = await withTimeout(
246250
fetchImpl(parsed.toString(), {
@@ -250,11 +254,18 @@ async function expandShortMapUrlWithResponse(
250254
timeoutMs,
251255
);
252256

257+
console.info("[share.debug] expand_response", {
258+
expandedUrl: response.url,
259+
hasText: typeof response.text === "function",
260+
});
261+
253262
let responseText: string | null = null;
254263
if (readResponseText && typeof response.text === "function") {
255264
try {
256265
responseText = await withTimeout(Promise.resolve(response.text()), timeoutMs);
257-
} catch {
266+
console.info("[share.debug] expand_text_length", responseText?.length ?? 0);
267+
} catch (err) {
268+
console.info("[share.debug] expand_text_error", err);
258269
responseText = null;
259270
}
260271
}
@@ -270,8 +281,9 @@ async function expandShortMapUrlWithResponse(
270281
expandedUrl: url,
271282
responseText,
272283
};
273-
} catch {
284+
} catch (err) {
274285
// Fall back to the original short URL on timeout/fetch failure.
286+
console.info("[share.debug] expand_fetch_error", err);
275287
return { expandedUrl: url, responseText: null };
276288
}
277289
}
@@ -389,26 +401,48 @@ export async function parseSharedMapLinkAsync(
389401

390402
if (!isGoogleShortHost(url.hostname)) return null;
391403

404+
console.info("[share.debug] parse_short_url", extracted);
392405
const { expandedUrl, responseText } = await expandShortMapUrlWithResponse(extracted, options);
406+
407+
console.info("[share.debug] after_expand", {
408+
expandedUrl,
409+
urlChanged: expandedUrl !== extracted,
410+
responseLength: responseText?.length ?? 0,
411+
});
412+
393413
if (expandedUrl !== extracted) {
394414
const expandedParsedUrl = parseUrl(expandedUrl);
395-
if (!expandedParsedUrl) return null;
415+
if (!expandedParsedUrl) {
416+
console.info("[share.debug] expanded_url_parse_failed", expandedUrl);
417+
return null;
418+
}
396419

397420
const parsedExpandedLink = parseSharedMapLinkFromUrl(expandedParsedUrl, extracted);
398-
if (parsedExpandedLink) return parsedExpandedLink;
421+
if (parsedExpandedLink) {
422+
console.info("[share.debug] parsed_from_expanded_url", parsedExpandedLink);
423+
return parsedExpandedLink;
424+
}
425+
console.info("[share.debug] expanded_url_no_coords", expandedUrl);
399426
}
400427

428+
console.info("[share.debug] try_parse_from_response_text", responseText?.substring(0, 200));
401429
let parsedFromPreviewPayload = parseGoogleCoordinatesFromText(responseText ?? "");
402430
if (!parsedFromPreviewPayload) {
431+
console.info("[share.debug] response_text_parse_failed_try_refetch");
403432
const fallbackText = await fetchMapPageText(
404433
expandedUrl !== extracted ? expandedUrl : extracted,
405434
options,
406435
);
436+
console.info("[share.debug] refetch_text_length", fallbackText?.length ?? 0);
407437
parsedFromPreviewPayload = parseGoogleCoordinatesFromText(fallbackText ?? "");
408438
}
409439

410-
if (!parsedFromPreviewPayload) return null;
440+
if (!parsedFromPreviewPayload) {
441+
console.info("[share.debug] all_parsing_failed");
442+
return null;
443+
}
411444

445+
console.info("[share.debug] parsed_from_text", parsedFromPreviewPayload);
412446
return {
413447
provider: "google",
414448
lat: parsedFromPreviewPayload.lat,

0 commit comments

Comments
 (0)