Skip to content

Commit

Permalink
Add analytics events for newsletter subscription actions
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Jan 4, 2025
1 parent cab0694 commit 41a5807
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion internal/newsletter/newsletterstore/newsletter_store.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package newsletterstore

import (
"backend/internal/analytics"
"backend/internal/newsletter"
"context"
"fmt"
Expand Down Expand Up @@ -38,11 +39,26 @@ func (s *Store) Subscribe(ctx context.Context, e newsletter.Entry) error {
return fmt.Errorf("could not subscribe to newsletter: %w", err)
}

analytics.SendEvent(analytics.Event{
Name: "NewsletterSubscribed",
Properties: map[string]interface{}{},
})

return nil
}

func (s *Store) Unsubscribe(ctx context.Context, e newsletter.Entry) error {
return s.db.Unsubscribe(ctx, e)
err := s.db.Unsubscribe(ctx, e)
if err != nil {
return fmt.Errorf("could not unsubscribe from newsletter: %w", err)
}

analytics.SendEvent(analytics.Event{
Name: "NewsletterUnsubscribed",
Properties: map[string]interface{}{},
})

return nil
}

func (s *Store) GetSubscribers(ctx context.Context) ([]newsletter.Entry, error) {
Expand Down

0 comments on commit 41a5807

Please sign in to comment.