From a9ca1fcf433b27186a8416d9557ce84f574fc0d9 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Thu, 29 Feb 2024 18:21:01 -0500 Subject: [PATCH] Tweaks for better local dev env --- esbuild.config.mjs | 23 ++++++++++++++--------- src/providers/twitter/conversation.ts | 8 ++++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/esbuild.config.mjs b/esbuild.config.mjs index fa4b29e..41c4c35 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -55,14 +55,10 @@ for (let envVar of envVariables) { defines['RELEASE_NAME'] = `"${releaseName}"`; -await esbuild.build({ - entryPoints: ['src/worker.ts'], - sourcemap: 'external', - outdir: 'dist', - minify: true, - bundle: true, - format: 'esm', - plugins: [ +const plugins = []; + +if (process.env.SENTRY_DSN) { + plugins.push( sentryEsbuildPlugin({ org: process.env.SENTRY_ORG, project: process.env.SENTRY_PROJECT, @@ -83,7 +79,16 @@ await esbuild.build({ // https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/ authToken: process.env.SENTRY_AUTH_TOKEN }) - ], + ) +} +await esbuild.build({ + entryPoints: ['src/worker.ts'], + sourcemap: 'external', + outdir: 'dist', + minify: true, + bundle: true, + format: 'esm', + plugins: plugins, define: defines }); diff --git a/src/providers/twitter/conversation.ts b/src/providers/twitter/conversation.ts index 9e5a336..3b3e332 100644 --- a/src/providers/twitter/conversation.ts +++ b/src/providers/twitter/conversation.ts @@ -60,14 +60,16 @@ export const fetchTweetDetail = async ( useElongator, (_conversation: unknown) => { const conversation = _conversation as TweetDetailResult; + const response = processResponse(conversation?.data?.threaded_conversation_with_injections_v2?.instructions); const tweet = findStatusInBucket( status, - processResponse(conversation?.data?.threaded_conversation_with_injections_v2?.instructions) + response ); if (tweet && isGraphQLTwitterStatus(tweet)) { return true; } - console.log('invalid graphql tweet', JSON.stringify(conversation)); + console.log('invalid graphql tweet', tweet); + console.log('from response', response) return Array.isArray(conversation?.errors); }, @@ -278,6 +280,8 @@ export const constructTwitterThread = async ( let response: TweetDetailResult | TweetResultsByRestIdResult | null = null; let status: APITwitterStatus; + + console.log('env', c.env) /* We can use TweetDetail on elongator accounts to increase per-account rate limit. We also use TweetDetail to process threads (WIP)