mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-15 20:03:12 +00:00
chore: retire unused service
This commit is contained in:
parent
9d6d93ab39
commit
784d91ab75
@ -14,7 +14,6 @@ import (
|
||||
|
||||
"github.com/yourselfhosted/slash/server"
|
||||
"github.com/yourselfhosted/slash/server/common"
|
||||
"github.com/yourselfhosted/slash/server/metric"
|
||||
"github.com/yourselfhosted/slash/server/profile"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
"github.com/yourselfhosted/slash/store/db"
|
||||
@ -67,11 +66,6 @@ var (
|
||||
return
|
||||
}
|
||||
|
||||
if serverProfile.Metric {
|
||||
// nolint
|
||||
metric.NewMetricClient(s.Secret, *serverProfile)
|
||||
}
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
// Trigger graceful shutdown on SIGINT or SIGTERM.
|
||||
// The default signal sent by the `kill` command is SIGTERM,
|
||||
|
1
go.mod
1
go.mod
@ -74,7 +74,6 @@ require (
|
||||
github.com/mssola/useragent v1.0.0
|
||||
github.com/nyaruka/phonenumbers v1.4.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/posthog/posthog-go v1.2.18
|
||||
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
|
||||
golang.org/x/mod v0.20.0
|
||||
golang.org/x/oauth2 v0.22.0
|
||||
|
2
go.sum
2
go.sum
@ -294,8 +294,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/posthog/posthog-go v1.2.18 h1:2CBA0LOB0up+gon+xpeXuhFw69gZpjAYxQoBBGwiDWw=
|
||||
github.com/posthog/posthog-go v1.2.18/go.mod h1:QjlpryJtfYLrZF2GUkAhejH4E7WlDbdKkvOi5hLmkdg=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
|
@ -1,51 +0,0 @@
|
||||
package metric
|
||||
|
||||
import (
|
||||
"github.com/posthog/posthog-go"
|
||||
|
||||
"github.com/yourselfhosted/slash/server/profile"
|
||||
)
|
||||
|
||||
const (
|
||||
PostHogAPIKey = "phc_YFEi1aqUBW9sX2KDzdvMtK43DNu0mkeoKMKc0EQum2t"
|
||||
)
|
||||
|
||||
var (
|
||||
client *MetricClient
|
||||
)
|
||||
|
||||
type MetricClient struct {
|
||||
workspaceID string
|
||||
profile *profile.Profile
|
||||
phClient *posthog.Client
|
||||
}
|
||||
|
||||
func NewMetricClient(workspaceID string, profile profile.Profile) (*MetricClient, error) {
|
||||
phClient, err := posthog.NewWithConfig(PostHogAPIKey, posthog.Config{
|
||||
Endpoint: "https://app.posthog.com",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client = &MetricClient{
|
||||
workspaceID: workspaceID,
|
||||
profile: &profile,
|
||||
phClient: &phClient,
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func Enqueue(event string) {
|
||||
if client == nil {
|
||||
return
|
||||
}
|
||||
if client.profile.Mode != "prod" {
|
||||
return
|
||||
}
|
||||
|
||||
// nolint
|
||||
(*client.phClient).Enqueue(posthog.Capture{
|
||||
DistinctId: `slash-` + client.workspaceID,
|
||||
Event: event,
|
||||
})
|
||||
}
|
@ -24,8 +24,6 @@ type Profile struct {
|
||||
Driver string
|
||||
// Version is the current version of server.
|
||||
Version string
|
||||
// Metric indicate the metric collection is enabled or not.
|
||||
Metric bool
|
||||
}
|
||||
|
||||
func (p *Profile) IsDev() bool {
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"github.com/yourselfhosted/slash/plugin/idp/oauth2"
|
||||
v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
"github.com/yourselfhosted/slash/server/metric"
|
||||
"github.com/yourselfhosted/slash/server/service/license"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
)
|
||||
@ -53,7 +52,6 @@ func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest)
|
||||
if err := s.doSignIn(ctx, user, time.Now().Add(AccessTokenDuration)); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to sign in, err: %s", err))
|
||||
}
|
||||
metric.Enqueue("user sign in")
|
||||
return convertUserFromStore(user), nil
|
||||
}
|
||||
|
||||
@ -181,7 +179,6 @@ func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to create user, err: %s", err))
|
||||
}
|
||||
metric.Enqueue("user sign up")
|
||||
if err := s.doSignIn(ctx, user, time.Now().Add(AccessTokenDuration)); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to sign in, err: %s", err))
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
|
||||
v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
"github.com/yourselfhosted/slash/server/metric"
|
||||
"github.com/yourselfhosted/slash/server/service/license"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
)
|
||||
@ -131,7 +130,6 @@ func (s *APIV1Service) CreateCollection(ctx context.Context, request *v1pb.Creat
|
||||
return nil, status.Errorf(codes.Internal, "failed to create collection, err: %v", err)
|
||||
}
|
||||
|
||||
metric.Enqueue("collection create")
|
||||
return convertCollectionFromStore(collection), nil
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
|
||||
v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
"github.com/yourselfhosted/slash/server/metric"
|
||||
"github.com/yourselfhosted/slash/server/service/license"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
)
|
||||
@ -175,7 +174,6 @@ func (s *APIV1Service) CreateShortcut(ctx context.Context, request *v1pb.CreateS
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
||||
}
|
||||
metric.Enqueue("shortcut create")
|
||||
return composedShortcut, nil
|
||||
}
|
||||
|
||||
@ -322,7 +320,6 @@ func (s *APIV1Service) GetShortcutAnalytics(ctx context.Context, request *v1pb.G
|
||||
browserMap[browserName]++
|
||||
}
|
||||
|
||||
metric.Enqueue("shortcut analytics")
|
||||
response := &v1pb.GetShortcutAnalyticsResponse{
|
||||
References: mapToAnalyticsSlice(referenceMap),
|
||||
Devices: mapToAnalyticsSlice(deviceMap),
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
"github.com/yourselfhosted/slash/internal/util"
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
"github.com/yourselfhosted/slash/server/common"
|
||||
"github.com/yourselfhosted/slash/server/metric"
|
||||
"github.com/yourselfhosted/slash/server/profile"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
)
|
||||
@ -96,7 +95,6 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
|
||||
if err := s.createShortcutViewActivity(ctx, c.Request(), shortcut); err != nil {
|
||||
slog.Warn("failed to create shortcut view activity", slog.String("error", err.Error()))
|
||||
}
|
||||
metric.Enqueue("shortcut view")
|
||||
|
||||
// Inject shortcut metadata into `index.html`.
|
||||
indexHTML := strings.ReplaceAll(rawIndexHTML, headerMetadataPlaceholder, generateShortcutMetadata(shortcut).String())
|
||||
@ -114,7 +112,6 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
|
||||
return c.HTML(http.StatusOK, rawIndexHTML)
|
||||
}
|
||||
|
||||
metric.Enqueue("collection view")
|
||||
// Inject collection metadata into `index.html`.
|
||||
indexHTML := strings.ReplaceAll(rawIndexHTML, headerMetadataPlaceholder, generateCollectionMetadata(collection).String())
|
||||
return c.HTML(http.StatusOK, indexHTML)
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
"github.com/yourselfhosted/slash/server/metric"
|
||||
"github.com/yourselfhosted/slash/server/profile"
|
||||
apiv1 "github.com/yourselfhosted/slash/server/route/api/v1"
|
||||
"github.com/yourselfhosted/slash/server/route/frontend"
|
||||
@ -93,7 +92,6 @@ func (s *Server) Start(ctx context.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
metric.Enqueue("server start")
|
||||
return s.e.Start(fmt.Sprintf(":%d", s.Profile.Port))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user