Skip to content

Commit 992b45d

Browse files
joe-lombrozo-s-bot[bot]djeebotdjeebus
authored
fix: fire created_volume PostHog event before token generation (#2283)
Co-authored-by: djeebot <djeebot@users.noreply.github.com> Co-authored-by: Joe Lombrozo <joe.lombrozo@e2b.dev>
1 parent 4520979 commit 992b45d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/api/internal/handlers/volume_create.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/gin-gonic/gin"
1111
"github.com/google/uuid"
12-
"github.com/posthog/posthog-go"
1312

1413
"github.com/e2b-dev/infra/packages/api/internal/api"
1514
"github.com/e2b-dev/infra/packages/api/internal/clusters"
@@ -141,6 +140,14 @@ func (a *APIStore) PostVolumes(c *gin.Context) {
141140
return
142141
}
143142

143+
a.posthog.IdentifyAnalyticsTeam(ctx, team.ID.String(), team.Name)
144+
properties := a.posthog.GetPackageToPosthogProperties(&c.Request.Header)
145+
a.posthog.CreateAnalyticsTeamEvent(ctx, team.ID.String(), "created_volume", properties.
146+
Set("volume_id", volume.ID.String()).
147+
Set("volume_name", volume.Name).
148+
Set("volume_type", volumeType),
149+
)
150+
144151
token, err := generateVolumeContentToken(a.config.VolumesToken, volume, team)
145152
if err != nil {
146153
a.sendAPIStoreError(c, http.StatusInternalServerError, "Volume created, but failed to generate volume content token")
@@ -149,12 +156,6 @@ func (a *APIStore) PostVolumes(c *gin.Context) {
149156
return
150157
}
151158

152-
a.posthog.CreateAnalyticsTeamEvent(ctx, team.ID.String(), "created_volume", posthog.NewProperties().
153-
Set("volume_id", volume.ID.String()).
154-
Set("volume_name", volume.Name).
155-
Set("volume_type", volumeType),
156-
)
157-
158159
result := api.VolumeAndToken{
159160
VolumeID: volume.ID.String(),
160161
Name: volume.Name,

0 commit comments

Comments
 (0)