Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

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

appview/oauth: restore posthog

Signed-off-by: oppiliappan <me@oppi.li>

+24 -10
+11
appview/oauth/handler.go
··· 7 7 8 8 "github.com/go-chi/chi/v5" 9 9 "github.com/lestrrat-go/jwx/v2/jwk" 10 + "github.com/posthog/posthog-go" 10 11 ) 11 12 12 13 func (o *OAuth) Router() http.Handler { ··· 60 59 if err := o.SaveSession(w, r, sessData); err != nil { 61 60 http.Error(w, err.Error(), http.StatusInternalServerError) 62 61 return 62 + } 63 + 64 + if !o.Config.Core.Dev { 65 + err = o.Posthog.Enqueue(posthog.Capture{ 66 + DistinctId: sessData.AccountDID.String(), 67 + Event: "signin", 68 + }) 69 + if err != nil { 70 + log.Println("failed to enqueue posthog event:", err) 71 + } 63 72 } 64 73 65 74 http.Redirect(w, r, "/", http.StatusFound)
+4 -1
appview/oauth/oauth.go
··· 13 13 xrpc "github.com/bluesky-social/indigo/xrpc" 14 14 "github.com/gorilla/sessions" 15 15 "github.com/lestrrat-go/jwx/v2/jwk" 16 + "github.com/posthog/posthog-go" 16 17 "tangled.org/core/appview/config" 17 18 ) 18 19 19 - func New(config *config.Config) (*OAuth, error) { 20 + func New(config *config.Config, ph posthog.Client) (*OAuth, error) { 20 21 21 22 var oauthConfig oauth.ClientConfig 22 23 var clientUri string ··· 47 46 Config: config, 48 47 SessStore: sessStore, 49 48 JwksUri: jwksUri, 49 + Posthog: ph, 50 50 }, nil 51 51 } 52 52 ··· 56 54 SessStore *sessions.CookieStore 57 55 Config *config.Config 58 56 JwksUri string 57 + Posthog posthog.Client 59 58 } 60 59 61 60 func (o *OAuth) SaveSession(w http.ResponseWriter, r *http.Request, sessData *oauth.ClientSessionData) error {
+9 -9
appview/state/state.go
··· 77 77 res = idresolver.DefaultResolver() 78 78 } 79 79 80 - pages := pages.NewPages(config, res) 81 - cache := cache.New(config.Redis.Addr) 82 - sess := session.New(cache) 83 - oauth2, err := oauth.New(config) 84 - if err != nil { 85 - return nil, fmt.Errorf("failed to start oauth handler: %w", err) 86 - } 87 - validator := validator.New(d, res, enforcer) 88 - 89 80 posthog, err := posthog.NewWithConfig(config.Posthog.ApiKey, posthog.Config{Endpoint: config.Posthog.Endpoint}) 90 81 if err != nil { 91 82 return nil, fmt.Errorf("failed to create posthog client: %w", err) 92 83 } 84 + 85 + pages := pages.NewPages(config, res) 86 + cache := cache.New(config.Redis.Addr) 87 + sess := session.New(cache) 88 + oauth2, err := oauth.New(config, posthog) 89 + if err != nil { 90 + return nil, fmt.Errorf("failed to start oauth handler: %w", err) 91 + } 92 + validator := validator.New(d, res, enforcer) 93 93 94 94 repoResolver := reporesolver.New(config, enforcer, res, d) 95 95