| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117 |
- 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
- }
- // ProjectConnectTrack returns a track for when a project is connected
- func ProjectConnectTrack(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, ProjectConnect),
- )
- }
- // 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),
- )
- }
- // QuotaIncreaseAttemptTrack returns a track for when a user attempts provisioning
- func QuotaIncreaseAttemptTrack(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, QuotaIncreaseRequested),
- )
- }
- // 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
- B64BuildLogs 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
- additionalProps["b64_build_logs"] = opts.B64BuildLogs
- 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),
- )
- }
- // CloudProviderPermissionsGrantedTrackOpts are the options for creating a track when a user grants permission to use porter
- type CloudProviderPermissionsGrantedTrackOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- CloudProvider string
- CloudProviderCredentialIdentifier string
- }
- // CloudProviderPermissionsGrantedTrack returns a track for when a user grants permission to use porter
- func CloudProviderPermissionsGrantedTrack(opts *CloudProviderPermissionsGrantedTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["cloud_provider"] = opts.CloudProvider
- additionalProps["cloud_provider_credential_identifier"] = opts.CloudProviderCredentialIdentifier
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, CloudProviderPermissionsGranted),
- )
- }
- // ClusterPreflightChecksFailedTrackOpts are the options for creating a track when a user fails preflight checks
- type ClusterPreflightChecksFailedTrackOpts struct {
- *ProjectScopedTrackOpts
- Email string
- FirstName string
- LastName string
- CompanyName string
- ErrorMessage string
- }
- // ClusterPreflightChecksFailedTrack returns a track for when a user fails preflight checks
- func ClusterPreflightChecksFailedTrack(opts *ClusterPreflightChecksFailedTrackOpts) 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
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterPreflightChecksFailed),
- )
- }
- // ClusterUpdateFailedTrackOpts are the options for creating a track when a user fails to update a cluster
- type ClusterUpdateFailedTrackOpts struct {
- *ProjectScopedTrackOpts
- ClusterName string
- Email string
- FirstName string
- LastName string
- CompanyName string
- ErrorMessage string
- }
- // ClusterUpdateFailedTrack returns a track for when a user fails to update a cluster
- func ClusterUpdateFailedTrack(opts *ClusterUpdateFailedTrackOpts) segmentTrack {
- additionalProps := make(map[string]interface{})
- additionalProps["cluster_name"] = opts.ClusterName
- additionalProps["email"] = opts.Email
- additionalProps["name"] = opts.FirstName + " " + opts.LastName
- additionalProps["company"] = opts.CompanyName
- additionalProps["error_message"] = opts.ErrorMessage
- return getSegmentProjectTrack(
- opts.ProjectScopedTrackOpts,
- getDefaultSegmentTrack(additionalProps, ClusterUpdateFailed),
- )
- }
|