···
+
package posthog_service
+
"github.com/posthog/posthog-go"
+
"tangled.sh/tangled.sh/core/appview/db"
+
"tangled.sh/tangled.sh/core/appview/notify"
+
type posthogNotifier struct {
+
func NewPosthogNotifier(client posthog.Client) notify.Notifier {
+
return &posthogNotifier{
+
var _ notify.Notifier = &posthogNotifier{}
+
func (n *posthogNotifier) NewRepo(ctx context.Context, repo *db.Repo) {
+
err := n.client.Enqueue(posthog.Capture{
+
Properties: posthog.Properties{"repo": repo.Name, "repo_at": repo.AtUri},
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) NewStar(ctx context.Context, star *db.Star) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: star.StarredByDid,
+
Properties: posthog.Properties{"repo_at": star.RepoAt.String()},
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) DeleteStar(ctx context.Context, star *db.Star) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: star.StarredByDid,
+
Properties: posthog.Properties{"repo_at": star.RepoAt.String()},
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) NewIssue(ctx context.Context, issue *db.Issue) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: issue.OwnerDid,
+
Properties: posthog.Properties{
+
"repo_at": issue.RepoAt.String(),
+
"issue_id": issue.IssueId,
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) NewPull(ctx context.Context, pull *db.Pull) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: pull.OwnerDid,
+
Properties: posthog.Properties{
+
"repo_at": pull.RepoAt,
+
"pull_id": pull.PullId,
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) NewPullComment(ctx context.Context, comment *db.PullComment) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: comment.OwnerDid,
+
Event: "new_pull_comment",
+
Properties: posthog.Properties{
+
"repo_at": comment.RepoAt,
+
"pull_id": comment.PullId,
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) NewFollow(ctx context.Context, follow *db.Follow) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: follow.UserDid,
+
Properties: posthog.Properties{"subject": follow.SubjectDid},
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) DeleteFollow(ctx context.Context, follow *db.Follow) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: follow.UserDid,
+
Properties: posthog.Properties{"subject": follow.SubjectDid},
+
log.Println("failed to enqueue posthog event:", err)
+
func (n *posthogNotifier) UpdateProfile(ctx context.Context, profile *db.Profile) {
+
err := n.client.Enqueue(posthog.Capture{
+
DistinctId: profile.Did,
+
log.Println("failed to enqueue posthog event:", err)