Signed-off-by: Anirudh Oppiliappan anirudh@tangled.org
+31
Diff
round #0
+4
appview/notify/db/db.go
+4
appview/notify/db/db.go
···
361
361
// no-op for now; webhooks are handled by the webhook notifier
362
362
}
363
363
364
+
func (n *databaseNotifier) Clone(ctx context.Context, repo *models.Repo) {
365
+
// no-op
366
+
}
367
+
364
368
func (n *databaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
365
369
l := log.FromContext(ctx)
366
370
+5
appview/notify/logging_notifier.go
+5
appview/notify/logging_notifier.go
···
118
118
ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "Push"))
119
119
l.inner.Push(ctx, repo, ref, oldSha, newSha, committerDid)
120
120
}
121
+
122
+
func (l *loggingNotifier) Clone(ctx context.Context, repo *models.Repo) {
123
+
ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "Clone"))
124
+
l.inner.Clone(ctx, repo)
125
+
}
+4
appview/notify/merged_notifier.go
+4
appview/notify/merged_notifier.go
···
105
105
func (m *mergedNotifier) Push(ctx context.Context, repo *models.Repo, ref, oldSha, newSha, committerDid string) {
106
106
m.fanout(func(n Notifier) { n.Push(ctx, repo, ref, oldSha, newSha, committerDid) })
107
107
}
108
+
109
+
func (m *mergedNotifier) Clone(ctx context.Context, repo *models.Repo) {
110
+
m.fanout(func(n Notifier) { n.Clone(ctx, repo) })
111
+
}
+4
appview/notify/notifier.go
+4
appview/notify/notifier.go
···
35
35
DeleteString(ctx context.Context, did, rkey string)
36
36
37
37
Push(ctx context.Context, repo *models.Repo, ref, oldSha, newSha, committerDid string)
38
+
39
+
Clone(ctx context.Context, repo *models.Repo)
38
40
}
39
41
40
42
// BaseNotifier is a listener that does nothing
···
72
74
73
75
func (m *BaseNotifier) Push(ctx context.Context, repo *models.Repo, ref, oldSha, newSha, committerDid string) {
74
76
}
77
+
78
+
func (m *BaseNotifier) Clone(ctx context.Context, repo *models.Repo) {}
+11
appview/notify/posthog/notifier.go
+11
appview/notify/posthog/notifier.go
···
180
180
}
181
181
}
182
182
183
+
func (n *posthogNotifier) Clone(ctx context.Context, repo *models.Repo) {
184
+
err := n.client.Enqueue(posthog.Capture{
185
+
DistinctId: repo.Did,
186
+
Event: "clone",
187
+
Properties: posthog.Properties{"repo": repo.Name, "repo_at": repo.RepoAt()},
188
+
})
189
+
if err != nil {
190
+
log.Println("failed to enqueue posthog event:", err)
191
+
}
192
+
}
193
+
183
194
func (n *posthogNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment, mentions []syntax.DID) {
184
195
err := n.client.Enqueue(posthog.Capture{
185
196
DistinctId: comment.Did,
+2
appview/notify/webhook_notifier.go
+2
appview/notify/webhook_notifier.go
···
69
69
}
70
70
}
71
71
72
+
func (w *WebhookNotifier) Clone(ctx context.Context, repo *models.Repo) {}
73
+
72
74
// buildPushPayload creates the webhook payload
73
75
func (w *WebhookNotifier) buildPushPayload(repo *models.Repo, ref, oldSha, newSha, committerDid string) (*models.WebhookPayload, error) {
74
76
owner := repo.Did
+1
appview/state/git_http.go
+1
appview/state/git_http.go
···
54
54
default:
55
55
// git-upload-pack is the default service for git-clone / git-fetch.
56
56
contentType = "application/x-git-upload-pack-advertisement"
57
+
go s.notifier.Clone(r.Context(), repo)
57
58
}
58
59
59
60
targetURL := fmt.Sprintf("%s://%s/%s/%s/info/refs?%s", scheme, repo.Knot, user.DID, repo.Name, r.URL.RawQuery)
History
3 rounds
2 comments
anirudh.fi
submitted
#2
1 commit
expand
collapse
appview/notify: add Clone notifier, enqueue posthog event for clones
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
3/3 failed
expand
collapse
expand 0 comments
pull request successfully merged
anirudh.fi
submitted
#1
1 commit
expand
collapse
appview/notify: add Clone notifier, enqueue posthog event for clones
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
1/3 failed, 1/3 timeout, 1/3 success
expand
collapse
expand 0 comments
anirudh.fi
submitted
#0
1 commit
expand
collapse
appview/notify: add Clone notifier, enqueue posthog event for clones
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
expand 2 comments
Good catch; it might be racy, although it's very likely that the Posthog request completes before the clone does.
appview/state/git_http.go:57I think it will be fine in most cases, but shouldn't we usecontext.Background()here?otherwise lgtm!