satellite/analytics: Track event "Credit Card Added" (#4749)

satellite/analytics: Track event "Credit Card Added"
This commit is contained in:
prerna-parashar 2022-04-28 11:12:42 -07:00 committed by GitHub
parent 04b22f24eb
commit 894b7b1cf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,7 @@ const (
eventLinkShared = "Link Shared"
eventObjectUploaded = "Object Uploaded"
eventAPIKeyGenerated = "API Key Generated"
eventCreditCardAdded = "Credit Card Added"
)
var (
@ -338,3 +339,20 @@ func (service *Service) TrackLinkEvent(eventName string, userID uuid.UUID, email
"link": link,
})
}
// TrackCreditCardAdded sends an "Credit Card Added" event to Segment.
func (service *Service) TrackCreditCardAdded(userID uuid.UUID, email string) {
if !service.config.Enabled {
return
}
props := segment.NewProperties()
props.Set("email", email)
service.enqueueMessage(segment.Track{
UserId: userID.String(),
Event: service.satelliteName + " " + eventCreditCardAdded,
Properties: props,
})
}

View File

@ -271,6 +271,8 @@ func (paymentService PaymentsService) AddCreditCard(ctx context.Context, creditC
return Error.Wrap(err)
}
paymentService.service.analytics.TrackCreditCardAdded(auth.User.ID, auth.User.Email)
if !auth.User.PaidTier {
// put this user into the paid tier and convert projects to upgraded limits.
err = paymentService.service.store.Users().UpdatePaidTier(ctx, auth.User.ID, true,