See the best posts from any Bluesky account
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Track like/repost engagement events in PostHog

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+21
+21
app/controllers/engagement_controller.ts
··· 2 2 import type { HttpContext } from '@adonisjs/core/http' 3 3 import vine from '@vinejs/vine' 4 4 import AtprotoOAuthService from '#services/atproto_oauth' 5 + import { getPostHogClient } from '#services/posthog' 5 6 6 7 const createValidator = vine.compile( 7 8 vine.object({ ··· 27 28 try { 28 29 const agent = await this.oauthService.getAgent(did) 29 30 const result = await agent.like(uri, cid) 31 + getPostHogClient()?.capture({ 32 + distinctId: did, 33 + event: 'engagement_created', 34 + properties: { type: 'like', target_uri: uri }, 35 + }) 30 36 return response.json({ uri: result.uri }) 31 37 } catch (error) { 32 38 return response.status(502).json({ message: 'Failed to create like on Bluesky' }) ··· 40 46 try { 41 47 const agent = await this.oauthService.getAgent(did) 42 48 await agent.deleteLike(uri) 49 + getPostHogClient()?.capture({ 50 + distinctId: did, 51 + event: 'engagement_removed', 52 + properties: { type: 'like', target_uri: uri }, 53 + }) 43 54 return response.json({}) 44 55 } catch (error) { 45 56 return response.status(502).json({ message: 'Failed to delete like on Bluesky' }) ··· 53 64 try { 54 65 const agent = await this.oauthService.getAgent(did) 55 66 const result = await agent.repost(uri, cid) 67 + getPostHogClient()?.capture({ 68 + distinctId: did, 69 + event: 'engagement_created', 70 + properties: { type: 'repost', target_uri: uri }, 71 + }) 56 72 return response.json({ uri: result.uri }) 57 73 } catch (error) { 58 74 return response.status(502).json({ message: 'Failed to create repost on Bluesky' }) ··· 66 82 try { 67 83 const agent = await this.oauthService.getAgent(did) 68 84 await agent.deleteRepost(uri) 85 + getPostHogClient()?.capture({ 86 + distinctId: did, 87 + event: 'engagement_removed', 88 + properties: { type: 'repost', target_uri: uri }, 89 + }) 69 90 return response.json({}) 70 91 } catch (error) { 71 92 return response.status(502).json({ message: 'Failed to delete repost on Bluesky' })