Created
November 18, 2022 18:24
-
-
Save joelhooks/94b3b25b062868a79b07bb42a0fd8e33 to your computer and use it in GitHub Desktop.
Revisions
-
joelhooks created this gist
Nov 18, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ // Name: ck stats for site // Snippet: ;ck import "@johnlindquist/kit" const sites = [ { name: "Some Account", ck_secret: await env("SOME_ACCOUNT_CK_SECRET"), } ] // load subscriber count from convertkit api async function loadSubscriberCount(apiSecret: string): Promise<number> { const url = `https://api.convertkit.com/v3/subscribers?api_secret=${apiSecret}`; const response = await fetch(url).then(response => { return response.json(); }) return response.total_subscribers; } let report = `* [[active partner products]]\n\n` for (let index = 0; index < sites.length; index++) { const site = sites[index]; const siteSubscriberCount = await loadSubscriberCount(site.ck_secret); report += ` * [[${site.name}]]\n * convertkit subscribers:: ${siteSubscriberCount}\n\n`; } copy(report); // let html = await highlight(report) // await div(html) await setSelectedText(report)