+11
appview/notify/merged_notifier.go
+11
appview/notify/merged_notifier.go
···
38
38
notifier.NewIssue(ctx, issue)
39
39
}
40
40
}
41
+
func (m *mergedNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment) {
42
+
for _, notifier := range m.notifiers {
43
+
notifier.NewIssueComment(ctx, comment)
44
+
}
45
+
}
46
+
47
+
func (m *mergedNotifier) NewIssueClosed(ctx context.Context, issue *models.Issue) {
48
+
for _, notifier := range m.notifiers {
49
+
notifier.NewIssueClosed(ctx, issue)
50
+
}
51
+
}
41
52
42
53
func (m *mergedNotifier) NewFollow(ctx context.Context, follow *models.Follow) {
43
54
for _, notifier := range m.notifiers {
+5
-1
appview/notify/notifier.go
+5
-1
appview/notify/notifier.go
···
13
13
DeleteStar(ctx context.Context, star *models.Star)
14
14
15
15
NewIssue(ctx context.Context, issue *models.Issue)
16
+
NewIssueComment(ctx context.Context, comment *models.IssueComment)
17
+
NewIssueClosed(ctx context.Context, issue *models.Issue)
16
18
17
19
NewFollow(ctx context.Context, follow *models.Follow)
18
20
DeleteFollow(ctx context.Context, follow *models.Follow)
···
37
39
func (m *BaseNotifier) NewStar(ctx context.Context, star *models.Star) {}
38
40
func (m *BaseNotifier) DeleteStar(ctx context.Context, star *models.Star) {}
39
41
40
-
func (m *BaseNotifier) NewIssue(ctx context.Context, issue *models.Issue) {}
42
+
func (m *BaseNotifier) NewIssue(ctx context.Context, issue *models.Issue) {}
43
+
func (m *BaseNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment) {}
44
+
func (m *BaseNotifier) NewIssueClosed(ctx context.Context, issue *models.Issue) {}
41
45
42
46
func (m *BaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) {}
43
47
func (m *BaseNotifier) DeleteFollow(ctx context.Context, follow *models.Follow) {}
+58
-3
appview/posthog/notifier.go
appview/notify/posthog/notifier.go
+58
-3
appview/posthog/notifier.go
appview/notify/posthog/notifier.go
···
1
-
package posthog_service
1
+
package posthog
2
2
3
3
import (
4
4
"context"
···
98
98
}
99
99
}
100
100
101
+
func (n *posthogNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) {
102
+
err := n.client.Enqueue(posthog.Capture{
103
+
DistinctId: pull.OwnerDid,
104
+
Event: "pull_closed",
105
+
Properties: posthog.Properties{
106
+
"repo_at": pull.RepoAt,
107
+
"pull_id": pull.PullId,
108
+
},
109
+
})
110
+
if err != nil {
111
+
log.Println("failed to enqueue posthog event:", err)
112
+
}
113
+
}
114
+
101
115
func (n *posthogNotifier) NewFollow(ctx context.Context, follow *models.Follow) {
102
116
err := n.client.Enqueue(posthog.Capture{
103
117
DistinctId: follow.UserDid,
···
152
166
}
153
167
}
154
168
155
-
func (n *posthogNotifier) CreateString(ctx context.Context, string models.String) {
169
+
func (n *posthogNotifier) NewString(ctx context.Context, string *models.String) {
156
170
err := n.client.Enqueue(posthog.Capture{
157
171
DistinctId: string.Did.String(),
158
-
Event: "create_string",
172
+
Event: "new_string",
159
173
Properties: posthog.Properties{"rkey": string.Rkey},
160
174
})
161
175
if err != nil {
162
176
log.Println("failed to enqueue posthog event:", err)
163
177
}
164
178
}
179
+
180
+
func (n *posthogNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment) {
181
+
err := n.client.Enqueue(posthog.Capture{
182
+
DistinctId: comment.Did,
183
+
Event: "new_issue_comment",
184
+
Properties: posthog.Properties{
185
+
"issue_at": comment.IssueAt,
186
+
},
187
+
})
188
+
if err != nil {
189
+
log.Println("failed to enqueue posthog event:", err)
190
+
}
191
+
}
192
+
193
+
func (n *posthogNotifier) NewIssueClosed(ctx context.Context, issue *models.Issue) {
194
+
err := n.client.Enqueue(posthog.Capture{
195
+
DistinctId: issue.Did,
196
+
Event: "issue_closed",
197
+
Properties: posthog.Properties{
198
+
"repo_at": issue.RepoAt.String(),
199
+
"issue_id": issue.IssueId,
200
+
},
201
+
})
202
+
if err != nil {
203
+
log.Println("failed to enqueue posthog event:", err)
204
+
}
205
+
}
206
+
207
+
func (n *posthogNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) {
208
+
err := n.client.Enqueue(posthog.Capture{
209
+
DistinctId: pull.OwnerDid,
210
+
Event: "pull_merged",
211
+
Properties: posthog.Properties{
212
+
"repo_at": pull.RepoAt,
213
+
"pull_id": pull.PullId,
214
+
},
215
+
})
216
+
if err != nil {
217
+
log.Println("failed to enqueue posthog event:", err)
218
+
}
219
+
}
+2
appview/state/router.go
+2
appview/state/router.go
···
156
156
r.Mount("/strings", s.StringsRouter(mw))
157
157
r.Mount("/knots", s.KnotsRouter())
158
158
r.Mount("/spindles", s.SpindlesRouter())
159
+
r.Mount("/notifications", s.NotificationsRouter(mw))
160
+
159
161
r.Mount("/signup", s.SignupRouter())
160
162
r.Mount("/", s.OAuthRouter())
161
163
+2
-2
appview/state/state.go
+2
-2
appview/state/state.go
···
25
25
"tangled.org/core/appview/db"
26
26
"tangled.org/core/appview/models"
27
27
"tangled.org/core/appview/notify"
28
+
phnotify "tangled.org/core/appview/notify/posthog"
28
29
"tangled.org/core/appview/oauth"
29
30
"tangled.org/core/appview/pages"
30
-
posthogService "tangled.org/core/appview/posthog"
31
31
"tangled.org/core/appview/reporesolver"
32
32
"tangled.org/core/appview/validator"
33
33
xrpcclient "tangled.org/core/appview/xrpcclient"
···
149
149
150
150
var notifiers []notify.Notifier
151
151
if !config.Core.Dev {
152
-
notifiers = append(notifiers, posthogService.NewPosthogNotifier(posthog))
152
+
notifiers = append(notifiers, phnotify.NewPosthogNotifier(posthog))
153
153
}
154
154
notifier := notify.NewMergedNotifier(notifiers...)
155
155