| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007 |
- package analytics
- import (
- "github.com/porter-dev/porter/api/types"
- segment "gopkg.in/segmentio/analytics-go.v3"
- )
- type segmentTrack interface {
- getUserId() string
- getEvent() SegmentEvent
- getProperties() segment.Properties
- }
- type defaultTrackOpts struct {
- AdditionalProps map[string]interface{}
- }
- type defaultSegmentTrack struct {
- event SegmentEvent
- properties segmentProperties
- }
- func getDefaultSegmentTrack(additionalProps map[string]interface{}, event SegmentEvent) *defaultSegmentTrack {
- props := newSegmentProperties()
- props.addAdditionalProperties(additionalProps)
- return &defaultSegmentTrack{
- event: event,
- properties: props,
- }
- }
- func (t *defaultSegmentTrack) getEvent() SegmentEvent {
- return t.event
- }
- func (t *defaultSegmentTrack) getProperties() segment.Properties {
- props := segment.NewProperties()
- for key, val := range t.properties {
- props = props.Set(key, val)
- }
- return props
- }
- type segmentProperties map[string]interface{}
- func newSegmentProperties() segmentProperties {
- props := make(map[string]interface{})
- return props
- }
- func (p segmentProperties) addProjectProperties(opts *ProjectScopedTrackOpts) {
- p["proj_id"] = opts.ProjectID
- }
- func (p segmentProperties) addClusterProperties(opts *ClusterScopedTrackOpts) {
- p["cluster_id"] = opts.ClusterID
- }
- func (p segmentProperties) addRegistryProperties(opts *RegistryScopedTrackOpts) {
- p["registry_id"] = opts.RegistryID
- }
- func (p segmentProperties) addApplicationProperties(opts *ApplicationScopedTrackOpts) {
- p["app_name"] = opts.Name
- p["app_namespace"] = opts.Namespace
- p["chart_name"] = opts.ChartName
- }
- func (p segmentProperties) addAdditionalProperties(props map[string]interface{}) {
- for key, val := range props {
- p[key] = val
- }
- }
- // UserCreateTrackOpts are the options for creating a track when a user is created
- type UserCreateTrackOpts struct {
- *UserScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- ReferralMethod string
- }
- // UserCreateTrack returns a track for when a user is created
- func UserCreateTrack(opts *UserCreateTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["referral_method"] = opts.ReferralMethod
- return getSegmentUserTrack(
- opts.UserScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, UserCreate),
- )
- }
- // UserCreateTrackOpts are the options for creating a track when a user's email is verified
- type UserVerifyEmailTrackOpts struct {
- *UserScopedTrackOpts
- Email string
- }
- // UserVerifyEmailTrack returns a track for when a user's email is verified
- func UserVerifyEmailTrack(opts *UserVerifyEmailTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- return getSegmentUserTrack(
- opts.UserScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, UserVerifyEmail),
- )
- }
- // ProjectCreateDeleteTrackOpts are the options for creating a track when a project is created or deleted
- type ProjectCreateDeleteTrackOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- }
- // ProjectCreateTrack returns a track for when a project is created
- func ProjectCreateTrack(opts *ProjectCreateDeleteTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ProjectCreate),
- )
- }
- // ProjectDeleteTrack returns a track for when a project is deleted
- func ProjectDeleteTrack(opts *ProjectCreateDeleteTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ProjectDelete),
- )
- }
- // ClusterDeleteTrackOpts are the options for creating a track when a cluster is deleted
- type ClusterDeleteTrackOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- }
- // ClusterDeleteTrack returns a track for when a cluster is deleted
- func ClusterDeleteTrack(opts *ClusterDeleteTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterDelete),
- )
- }
- // CostConsentOpenedTrackOpts are the options for creating a track when a user opens the cost consent
- type CostConsentOpenedTrackOpts struct {
- *UserScopedTrackOpts
- Provider string
- Email string
- FirstName string
- LastName string
- CompanyName string
- }
- // CostConsentCompletedTrack returns a track for when a user completes the cost consent
- func CostConsentOpenedTrack(opts *CostConsentOpenedTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["provider"] = opts.Provider
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- return getSegmentUserTrack(
- opts.UserScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, CostConsentOpened),
- )
- }
- // CostConsentCompletedTrackOpts are the options for creating a track when a user completes the cost consent
- type CostConsentCompletedTrackOpts struct {
- *UserScopedTrackOpts
- Provider string
- Email string
- FirstName string
- LastName string
- CompanyName string
- }
- // CostConsentCompletedTrack returns a track for when a user completes the cost consent
- func CostConsentCompletedTrack(opts *CostConsentCompletedTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["provider"] = opts.Provider
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- return getSegmentUserTrack(
- opts.UserScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, CostConsentComplete),
- )
- }
- // AWSInputTrackOpts are the options for creating a track when a user inputs a complete AWS account ID
- type AWSInputTrackOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- AccountId string
- }
- // AWSInputTrack returns a track for when a user inputs a complete AWS account ID
- func AWSInputTrack(opts *AWSInputTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["account_id"] = opts.AccountId
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, AWSInputted),
- )
- }
- type AWSRedirectOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- AccountId string
- CloudformationURL string
- LoginURL string
- ExternalId string
- }
- // AWSCloudformationRedirectSuccess returns a track for when a user clicks 'grant permissions' and gets redirected to cloudformation
- func AWSCloudformationRedirectSuccess(opts *AWSRedirectOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["account_id"] = opts.AccountId
- additionalProps["cloudformation_url"] = opts.CloudformationURL
- additionalProps["external_id"] = opts.ExternalId
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, AWSCloudformationRedirect),
- )
- }
- // AWSLoginRedirectSuccess returns a track for when a user is prompted to login to AWS
- func AWSLoginRedirectSuccess(opts *AWSRedirectOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["account_id"] = opts.AccountId
- additionalProps["login_url"] = opts.LoginURL
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, AWSLoginRedirect),
- )
- }
- type AWSCreateIntegrationOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- AccountId string
- ExternalId string
- ErrorMessage string
- }
- // AWSCreateIntegrationSucceeded returns a track for when a user succeeds in creating an aws integration
- func AWSCreateIntegrationSucceeded(opts *AWSCreateIntegrationOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["account_id"] = opts.AccountId
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, AWSCreateIntegrationSuccess),
- )
- }
- // AWSCreateIntegrationSucceeded returns a track for when a user succeeds in creating an aws integration
- func AWSCreateIntegrationFailed(opts *AWSCreateIntegrationOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["account_id"] = opts.AccountId
- additionalProps["error_message"] = opts.ErrorMessage
- additionalProps["external_id"] = opts.ExternalId
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, AWSCreateIntegrationFailure),
- )
- }
- // CredentialStepTrackOpts are the options for creating a track when a user completes the credential step
- type CredentialStepTrackOpts struct {
- *UserScopedTrackOpts
- }
- // CredentialStepTrack returns a track for when a user completes the credential step
- func CredentialStepTrack(opts *CredentialStepTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- return getSegmentUserTrack(
- opts.UserScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, CredentialStepComplete),
- )
- }
- // PreProvisionCheckTrackOpts are the options for creating a track when a user checks if they can provision
- type PreProvisionCheckTrackOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- }
- // PreProvisionCheckTrack returns a track for when a user attempts provisioning
- func PreProvisionCheckTrack(opts *PreProvisionCheckTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, PreProvisionCheck),
- )
- }
- // ProvisioningAttemptedTrackOpts are the options for creating a track when a user attempts provisioning
- type ProvisioningAttemptTrackOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- ErrorMessage string
- Region string
- Provider string
- }
- // ProvisioningAttemptTrack returns a track for when a user attempts provisioning
- func ProvisioningAttemptTrack(opts *ProvisioningAttemptTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["region"] = opts.Region
- additionalProps["provider"] = opts.Provider
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ProvisioningAttempted),
- )
- }
- // PreProvisionCheckTrack returns a track for when a user attempts provisioning
- func ProvisionFailureTrack(opts *ProvisioningAttemptTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["error_message"] = opts.ErrorMessage
- additionalProps["region"] = opts.Region
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ProvisioningFailure),
- )
- }
- // ClusterProvisioningStartTrackOpts are the options for creating a track when a cluster
- // has started provisioning
- type ClusterProvisioningStartTrackOpts struct {
- // note that this is a project-scoped track, since the cluster has not been created yet
- *ProjectScopedTrackOpts
- ClusterType types.InfraKind
- InfraID uint
- }
- // ClusterProvisioningStartTrack returns a track for when a cluster
- // has started provisioning
- func ClusterProvisioningStartTrack(opts *ClusterProvisioningStartTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cluster_type"] = opts.ClusterType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterProvisioningStart),
- )
- }
- // ClusterProvisioningErrorTrackOpts are the options for creating a track when a cluster
- // has experienced a provisioning error
- type ClusterProvisioningErrorTrackOpts struct {
- // note that this is a project-scoped track, since the cluster has not been created yet
- *ProjectScopedTrackOpts
- ClusterType types.InfraKind
- InfraID uint
- }
- // ClusterProvisioningErrorTrack returns a track for when a cluster
- // has experienced a provisioning error
- func ClusterProvisioningErrorTrack(opts *ClusterProvisioningErrorTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cluster_type"] = opts.ClusterType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterProvisioningError),
- )
- }
- // ClusterProvisioningSuccessTrackOpts are the options for creating a track when a cluster
- // has successfully provisioned
- type ClusterProvisioningSuccessTrackOpts struct {
- *ClusterScopedTrackOpts
- ClusterType types.InfraKind
- InfraID uint
- }
- // ClusterProvisioningSuccessTrack returns a new track for when a cluster
- // has successfully provisioned
- func ClusterProvisioningSuccessTrack(opts *ClusterProvisioningSuccessTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cluster_type"] = opts.ClusterType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentClusterTrack(
- opts.ClusterScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterProvisioningSuccess),
- )
- }
- // ClusterConnectionStartTrackOpts are the options for creating a track when a cluster
- // connection has started
- type ClusterConnectionStartTrackOpts struct {
- // note that this is a project-scoped track, since the cluster has not been created yet
- *ProjectScopedTrackOpts
- ClusterCandidateID uint
- }
- // ClusterConnectionStartTrack returns a new track for when a cluster
- // connection has started
- func ClusterConnectionStartTrack(opts *ClusterConnectionStartTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cc_id"] = opts.ClusterCandidateID
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterConnectionStart),
- )
- }
- // ClusterConnectionSuccessTrackOpts are the options for creating a track when a cluster
- // connection has finished
- type ClusterConnectionSuccessTrackOpts struct {
- *ClusterScopedTrackOpts
- ClusterCandidateID uint
- }
- // ClusterConnectionSuccessTrack returns a new track for when a cluster
- // connection has finished
- func ClusterConnectionSuccessTrack(opts *ClusterConnectionSuccessTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cc_id"] = opts.ClusterCandidateID
- return getSegmentClusterTrack(
- opts.ClusterScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterConnectionSuccess),
- )
- }
- // RegistryConnectionStartTrackOpts are the options for creating a track when a registry
- // connection has started
- type RegistryConnectionStartTrackOpts struct {
- // note that this is a project-scoped track, since the cluster has not been created yet
- *ProjectScopedTrackOpts
- // a random id assigned to this connection request
- FlowID string
- }
- // RegistryConnectionStartTrack returns a new track for when a registry
- // connection has started
- func RegistryConnectionStartTrack(opts *RegistryConnectionStartTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["flow_id"] = opts.FlowID
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, RegistryConnectionStart),
- )
- }
- // RegistryConnectionSuccessTrackOpts are the options for creating a track when a registry
- // connection has completed
- type RegistryConnectionSuccessTrackOpts struct {
- *RegistryScopedTrackOpts
- // a random id assigned to this connection request
- FlowID string
- }
- // RegistryConnectionSuccessTrack returns a new track for when a registry
- // connection has completed
- func RegistryConnectionSuccessTrack(opts *RegistryConnectionSuccessTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["flow_id"] = opts.FlowID
- return getSegmentRegistryTrack(
- opts.RegistryScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, RegistryConnectionSuccess),
- )
- }
- // GithubConnectionStartTrackOpts are the options for creating a track when a github account
- // connection has started
- type GithubConnectionStartTrackOpts struct {
- // note that this is a user-scoped track, since github repos are tied to the user
- *UserScopedTrackOpts
- }
- // GithubConnectionStartTrack returns a new track for when a github account
- // connection has started
- func GithubConnectionStartTrack(opts *GithubConnectionStartTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- return getSegmentUserTrack(
- opts.UserScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, GithubConnectionStart),
- )
- }
- // GithubConnectionSuccessTrackOpts are the options for creating a track when a github account
- // connection has completed
- type GithubConnectionSuccessTrackOpts struct {
- // note that this is a user-scoped track, since github repos are tied to the user
- *UserScopedTrackOpts
- }
- // GithubConnectionSuccessTrack returns a new track when a github account
- // connection has completed
- func GithubConnectionSuccessTrack(opts *GithubConnectionSuccessTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- return getSegmentUserTrack(
- opts.UserScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, GithubConnectionSuccess),
- )
- }
- // ApplicationLaunchStartTrackOpts are the options for creating a track when an application
- // launch has started
- type ApplicationLaunchStartTrackOpts struct {
- *ClusterScopedTrackOpts
- FlowID string
- }
- // ApplicationLaunchStartTrack returns a new track for when an application
- // launch has started
- func ApplicationLaunchStartTrack(opts *ApplicationLaunchStartTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["flow_id"] = opts.FlowID
- return getSegmentClusterTrack(
- opts.ClusterScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ApplicationLaunchStart),
- )
- }
- // ApplicationLaunchSuccessTrackOpts are the options for creating a track when an application
- // launch has completed
- type ApplicationLaunchSuccessTrackOpts struct {
- *ApplicationScopedTrackOpts
- FlowID string
- }
- // ApplicationLaunchSuccessTrack returns a new track for when an application
- // launch has completed
- func ApplicationLaunchSuccessTrack(opts *ApplicationLaunchSuccessTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["flow_id"] = opts.FlowID
- return getSegmentApplicationTrack(
- opts.ApplicationScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ApplicationLaunchSuccess),
- )
- }
- // ApplicationDeploymentWebhookTrackOpts are the options for creating a track when an application
- // launch has completed from a webhook
- type ApplicationDeploymentWebhookTrackOpts struct {
- *ApplicationScopedTrackOpts
- ImageURI string
- }
- // ApplicationDeploymentWebhookTrack returns a new track for when an application
- // launch has completed from a webhook
- func ApplicationDeploymentWebhookTrack(opts *ApplicationDeploymentWebhookTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["image_uri"] = opts.ImageURI
- return getSegmentApplicationTrack(
- opts.ApplicationScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ApplicationDeploymentWebhook),
- )
- }
- // RegistryProvisioningStartTrackOpts are the options for creating a track when a registry
- // provisioning has started
- type RegistryProvisioningStartTrackOpts struct {
- // note that this is a project-scoped track, since the registry has not been created yet
- *ProjectScopedTrackOpts
- RegistryType types.InfraKind
- InfraID uint
- }
- // RegistryProvisioningStartTrack returns a new track for when a registry
- // provisioning has started
- func RegistryProvisioningStartTrack(opts *RegistryProvisioningStartTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["registry_type"] = opts.RegistryType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, RegistryProvisioningStart),
- )
- }
- // RegistryProvisioningErrorTrackOpts are the options for creating a track when a registry
- // provisioning has failed
- type RegistryProvisioningErrorTrackOpts struct {
- // note that this is a project-scoped track, since the registry has not been created yet
- *ProjectScopedTrackOpts
- RegistryType types.InfraKind
- InfraID uint
- }
- // RegistryProvisioningErrorTrack returns a new track for when a registry
- // provisioning has failed
- func RegistryProvisioningErrorTrack(opts *RegistryProvisioningErrorTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["registry_type"] = opts.RegistryType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, RegistryProvisioningError),
- )
- }
- // RegistryProvisioningSuccessTrackOpts are the options for creating a track when a registry
- // provisioning has completed
- type RegistryProvisioningSuccessTrackOpts struct {
- *RegistryScopedTrackOpts
- RegistryType types.InfraKind
- InfraID uint
- }
- // RegistryProvisioningSuccessTrack returns a new track for when a registry
- // provisioning has completed
- func RegistryProvisioningSuccessTrack(opts *RegistryProvisioningSuccessTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["registry_type"] = opts.RegistryType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentRegistryTrack(
- opts.RegistryScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, RegistryProvisioningSuccess),
- )
- }
- // ClusterDestroyingStartTrackOpts are the options for creating a track when a cluster
- // has started destroying
- type ClusterDestroyingStartTrackOpts struct {
- *ClusterScopedTrackOpts
- ClusterType types.InfraKind
- InfraID uint
- }
- // ClusterDestroyingStartTrack returns a track for when a cluster
- // has started destroying
- func ClusterDestroyingStartTrack(opts *ClusterDestroyingStartTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cluster_type"] = opts.ClusterType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentClusterTrack(
- opts.ClusterScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterDestroyingStart),
- )
- }
- // ClusterDestroyingSuccessTrackOpts are the options for creating a track when a cluster
- // has successfully provisioned
- type ClusterDestroyingSuccessTrackOpts struct {
- *ClusterScopedTrackOpts
- ClusterType types.InfraKind
- InfraID uint
- }
- // ClusterDestroyingSuccessTrack returns a new track for when a cluster
- // has successfully provisioned
- func ClusterDestroyingSuccessTrack(opts *ClusterDestroyingSuccessTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cluster_type"] = opts.ClusterType
- additionalProps["infra_id"] = opts.InfraID
- return getSegmentClusterTrack(
- opts.ClusterScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterDestroyingSuccess),
- )
- }
- // StackLaunchStartOpts are the options for creating a track when a user starts creating a stack
- type StackLaunchStartOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- ValidateApplyV2 bool
- }
- // StackLaunchStartTrack returns a track for when a user starts creating a stack
- func StackLaunchStartTrack(opts *StackLaunchStartOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackLaunchStart),
- )
- }
- // StackLaunchCompleteOpts are the options for creating a track when a user completes creating a stack
- type StackLaunchCompleteOpts struct {
- *ProjectScopedTrackOpts
- StackName string
- Email string
- FirstName string
- LastName string
- CompanyName string
- ValidateApplyV2 bool
- }
- // StackLaunchCompleteTrack returns a track for when a user completes creating a stack
- func StackLaunchCompleteTrack(opts *StackLaunchCompleteOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackLaunchComplete),
- )
- }
- // StackLaunchSuccessOpts are the options for creating a track when a user succeeds in creating a stack
- type StackLaunchSuccessOpts struct {
- *ProjectScopedTrackOpts
- StackName string
- Email string
- FirstName string
- LastName string
- CompanyName string
- ValidateApplyV2 bool
- }
- // StackLaunchCompleteTrack returns a track for when a user completes creating a stack
- func StackLaunchSuccessTrack(opts *StackLaunchSuccessOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackLaunchSuccess),
- )
- }
- // StackLaunchFailureOpts are the options for creating a track when a user fails in creating a stack
- type StackLaunchFailureOpts struct {
- *ProjectScopedTrackOpts
- StackName string
- Email string
- FirstName string
- LastName string
- CompanyName string
- ErrorMessage string
- ValidateApplyV2 bool
- }
- // StackLaunchFailureTrack returns a track for when a user fails creating a stack
- func StackLaunchFailureTrack(opts *StackLaunchFailureOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["error_message"] = opts.ErrorMessage
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackLaunchFailure),
- )
- }
- // StackDeletionOpts are the options for creating a track when a user deletes a stack
- type StackDeletionOpts struct {
- *ProjectScopedTrackOpts
- StackName string
- Email string
- FirstName string
- LastName string
- CompanyName string
- DeleteWorkflowFile bool
- ValidateApplyV2 bool
- }
- // StackDeletionTrack returns a track for when a user deletes a stack
- func StackDeletionTrack(opts *StackDeletionOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["delete_workflow_file"] = opts.DeleteWorkflowFile
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackDeletion),
- )
- }
- // StackBuildOpts are the options for creating a track when a stack builds
- type StackBuildOpts struct {
- *ProjectScopedTrackOpts
- StackName string
- ErrorMessage string
- Email string
- FirstName string
- LastName string
- CompanyName string
- ValidateApplyV2 bool
- }
- // StackBuildFailureTrack returns a track for when a stack fails to build
- func StackBuildFailureTrack(opts *StackBuildOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["error_message"] = opts.ErrorMessage
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackBuildFailure),
- )
- }
- // StackBuildSuccessTrack returns a track for when a stack succeeds to build
- func StackBuildSuccessTrack(opts *StackBuildOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackBuildSuccess),
- )
- }
- // StackBuildProgressingTrack returns a track for when a stack starts to build
- func StackBuildProgressingTrack(opts *StackBuildOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, StackBuildProgressing),
- )
- }
- // PorterAppUpdateOpts are the options for creating a track when a user updates a porter app
- type PorterAppUpdateOpts struct {
- *ProjectScopedTrackOpts
- StackName string
- Email string
- FirstName string
- LastName string
- CompanyName string
- ErrorMessage string
- ErrorStackTrace string
- ValidateApplyV2 bool
- }
- // PorterAppUpdateFailureTrack returns a track for when a user attempts to update an app and receives an error
- func PorterAppUpdateFailureTrack(opts *PorterAppUpdateOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["stack_name"] = opts.StackName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["error_message"] = opts.ErrorMessage
- additionalProps["error_stack_trace"] = opts.ErrorStackTrace
- additionalProps["validate_apply_v2"] = opts.ValidateApplyV2
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, PorterAppUpdateFailure),
- )
- }
|