From d9ccb7dfb2242b0ba13786cdd456173ad34da595 Mon Sep 17 00:00:00 2001 From: Volod Date: Sun, 31 May 2026 13:47:12 -0700 Subject: [PATCH] feat(instagram): capture taken_at on posts Extract per-post capture time from the IG v1 feed media node (taken_at / taken_at_timestamp) and emit it as an ISO string on instagram.posts, plus add taken_at to the instagram.posts schema. Gives the Memory timeline real per-post dates instead of one collected-at pile. --- connectors/meta/instagram-playwright.js | 13 ++++++++++++- connectors/meta/schemas/instagram.posts.json | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/connectors/meta/instagram-playwright.js b/connectors/meta/instagram-playwright.js index adc2f5b..1ca9e54 100644 --- a/connectors/meta/instagram-playwright.js +++ b/connectors/meta/instagram-playwright.js @@ -1039,12 +1039,23 @@ const fetchWebInfo = async () => { id: liker.id || liker.pk || "", })); - return { + const post = { img_url: imgUrl, caption, num_of_likes: numOfLikes, who_liked: whoLiked, }; + + // Instagram v1 feed media nodes carry the capture time as `taken_at` + // (unix seconds). Only emit when present; never fabricate. + const takenAtRaw = node.taken_at ?? node.taken_at_timestamp; + if (typeof takenAtRaw === "number" && Number.isFinite(takenAtRaw)) { + // Values are in seconds; ms-scale values (>1e12) are passed through as-is. + const takenAtMs = takenAtRaw > 1e12 ? takenAtRaw : takenAtRaw * 1000; + post.taken_at = new Date(takenAtMs).toISOString(); + } + + return post; }); if (wantsProfile) { diff --git a/connectors/meta/schemas/instagram.posts.json b/connectors/meta/schemas/instagram.posts.json index 05dde38..6b28a92 100644 --- a/connectors/meta/schemas/instagram.posts.json +++ b/connectors/meta/schemas/instagram.posts.json @@ -15,6 +15,7 @@ "img_url": { "type": "string" }, "caption": { "type": "string" }, "num_of_likes": { "type": "number" }, + "taken_at": { "type": "string" }, "who_liked": { "type": "array", "items": {