Documentation ¶
Index ¶
- Variables
- type Account
- type AccountRepository
- type AccountType
- type AppDestination
- type AudienceConf
- type ConnectedAccount
- type CreativeConf
- type DatabaseStudyConf
- type Destination
- type DestinationConf
- type DistributionVar
- type FacebookConnectedAccount
- type FacebookCredentials
- type FlyConnectedAccount
- type FlyDestination
- type GeneralConf
- type Lookalike
- type LookalikeSpec
- type Partioning
- type QuestionTargeting
- type RecruitmentConf
- type SegmentProgress
- type SegmentsProgress
- type Study
- type StudyConf
- type StudyConfRepository
- type StudyRepository
- type StudySegmentsRepository
- type TargetingConf
- type TargetingDistributionConf
- type TypeformConnectedAccount
- type TypeformCredentials
- type User
- type UserRepository
- type WebDestination
Constants ¶
This section is empty.
Variables ¶
var ErrAccountAlreadyExists = errors.New("Account Already Exists")
var ErrStudyAlreadyExist = errors.New("Study already exist")
var ErrStudyNotFound = errors.New("Study not found")
var ErrUserAlreadyExists = errors.New("User Already Exists")
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { UserID string `json:"userId"` AuthType string `json:"authType" validate:"required"` Name AccountType `json:"name" validate:"required"` // This is an interum structure to hold the credentials values // until it can be determined what kind of Connected Account // this is based on the name RawConnectedAccount json.RawMessage `json:"connectedAccount"` ConnectedAccount ConnectedAccount `json:"-"` }
func (*Account) SetRawConnectedAccount ¶
SetRawConnectedAccount takes the connected account and sets it to RawConnectedAccount to be used in responses
type AccountRepository ¶
type AccountType ¶
type AccountType string
const ( TypeformAccount AccountType = "typeform" FlyAccount AccountType = "fly" )
We currently Only Support a Limited amount of Accounts Through the API
type AppDestination ¶
type AppDestination struct { Name string `json:"name"` FacebookAppID string `json:"facebook_app_id"` AppInstallLink string `json:"app_install_link"` DeeplinkTemplate string `json:"deeplink_template"` AppInstallState string `json:"app_install_state"` UserDevice []string `json:"user_device"` UserOS []string `json:"user_os"` }
AppDestination
type AudienceConf ¶
type AudienceConf struct { Name string `json:"name"` SubType string `json:"subtype"` Lookalike *Lookalike `json:"lookalike,omitempty"` QuestionTargeting *QuestionTargeting `json:"question_targeting,omitempty"` Partioning *Partioning `json:"partioning,omitempty"` }
AudienceConf is how the audience is configured for the study
type ConnectedAccount ¶
ConnectedAccount is used to enable the frontend to not need complex logic in order to determine if an account has been "connected". if this is null, then no account is connected
type CreativeConf ¶
type CreativeConf struct { Body string `json:"body"` ButtonText string `json:"button_text"` Destination string `json:"destination"` ImageHash string `json:"image_hash"` LinkText string `json:"link_text"` Name string `json:"name"` WelcomeMessage string `json:"welcome_message"` Tags []string `json:"tags"` }
CreativeConf these are essential fields that relate to an ad and link to a destination
type DatabaseStudyConf ¶
type DatabaseStudyConf struct { Created time.Time StudyID string ConfType string Conf json.RawMessage }
DatabaseStudyConf is the structure used to store data in the database
type Destination ¶
type Destination interface{}
Destination is where to send a recruitee to we use a blank interface as it could be different types
type DestinationConf ¶
type DestinationConf []Destination
DestinationConf as we have multiple types of destination
func (*DestinationConf) UnmarshalJSON ¶
func (d *DestinationConf) UnmarshalJSON(data []byte) error
UnmarshalJSON is a custom unmarshaller to handle the different types of destinations
type DistributionVar ¶
type DistributionVar string
const ( Location DistributionVar = "location" Gender DistributionVar = "gender" Age DistributionVar = "age" )
type FacebookConnectedAccount ¶
type FacebookConnectedAccount struct { CreatedAt int `json:"createdAt"` Credentials FacebookCredentials `json:"credentials" validate:"required"` }
FacebookConnectedAccount is used to connect Vlabs to a facebook ad account
func (FacebookConnectedAccount) MarshalCredentials ¶
func (f FacebookConnectedAccount) MarshalCredentials() (string, error)
MarshalsCredentials is used to input data into the database as a JSONB field
type FacebookCredentials ¶
type FlyConnectedAccount ¶
type FlyConnectedAccount struct { CreatedAt int `json:"createdAt"` Credentials flytypes.FlyCredentials `json:"credentials" validate:"required"` }
func (FlyConnectedAccount) MarshalCredentials ¶
func (f FlyConnectedAccount) MarshalCredentials() (string, error)
MarshalsCredentials is used to input data into the database as a JSONB field
type FlyDestination ¶
type FlyDestination struct { Name string `json:"name"` InitialShortcode string `json:"initial_shortcode"` }
FlyDestination is used to direct users to the Fly survey
type GeneralConf ¶
type GeneralConf struct { Name string `json:"name"` Objective string `json:"objective"` OptimizationGoal string `json:"optimization_goal"` DestinationType string `json:"destination_type"` PageID string `json:"page_id"` MinBudget float32 `json:"min_budget"` OptInWindow int `json:"opt_window"` InstagramID string `json:"instagram_id"` AdAccount string `json:"ad_account"` }
GeneralConf is used to hold all general configuration for a study
type Lookalike ¶
type Lookalike struct { Target int `json:"target"` Spec LookalikeSpec `json:"spec"` }
Lookalike is reflective of the lookalike capabilities in facebook ads
type LookalikeSpec ¶
type LookalikeSpec struct { Country string `json:"country"` Ratio float64 `json:"ratio"` StartingRatio float64 `json:"starting_ratio"` }
LookalikeSpec is the specifications used in a lookalike
type Partioning ¶
type Partioning struct { MinUsers *int `json:"min_users"` MinDays *int `json:"min_days,omitempty"` MaxDays *int `json:"max_days,omitempty"` MaxUsers *int `json:"max_users,omitempty"` }
Partioning
type QuestionTargeting ¶
type QuestionTargeting map[string]interface{}
QuestionTargeting is set as an interface as it allows for a nested type structure with various types we use map[string]interface{} as we should be dealing with json
type RecruitmentConf ¶
type RecruitmentConf struct { // Common Fields // These are set to strings as they are in the following format // 2022-08-05T00:00:00 // Which is none standard in Golang and makes it cumbersome to // unmarshall to time.Time. We have no need for them to be // unmarshalled for now EndDate string `json:"end_date"` StartDate string `json:"start_date"` // Simple Recruitment Fields AdCampaignName string `json:"ad_campaign_name,omitempty"` Budget int `json:"budget,omitempty"` MaxSample int `json:"max_sample,omitempty"` // Experiment Recruitment Fields Arms int `json:"arms,omitempty"` RecruitmentDays int `json:"recruitment_days,omitempty"` OffsetDays int `json:"offset_days,omitempty"` //Destination Recruitment Fields Destinations []string `json:"destinations,omitempty"` //Common Destination and Experiment Fields AdCampaignNameBase string `json:"ad_campaign_name_base,omitempty"` BudgetPerArm int `json:"budget_per_arm,omitempty"` MaxSamplePerArm int `json:"max_sample_per_arm,omitempty"` }
Recruitment is the configuration used to work with the facebook campaign
type SegmentProgress ¶
type SegmentProgress struct { ID string `json:"id"` Name string `json:"name"` Datetime int64 `json:"datetime"` CurrentBudget float64 `json:"currentBudget"` DesiredPercentage float64 `json:"desiredPercentage"` CurrentPercentage float64 `json:"currentPercentage"` ExpectedPercentage float64 `json:"expectedPercentage"` DesiredParticipants *int64 `json:"desiredParticipants"` ExpectedParticipants int64 `json:"expectedParticipants"` CurrentParticipants int64 `json:"currentParticipants"` CurrentPricePerParticipant float64 `json:"currentPricePerParticipant"` PercentageDeviationFromGoal float64 `json:"percentageDeviationFromGoal"` }
type SegmentsProgress ¶
type SegmentsProgress struct { Segments []SegmentProgress `json:"segments"` Datetime int64 `json:"datetime"` }
type Study ¶
type StudyConf ¶
type StudyConf struct { StudyID string `json:"-"` UserID string `json:"-"` General *GeneralConf `json:"general"` Targeting *TargetingConf `json:"targeting"` TargetingDistribution *TargetingDistributionConf `json:"targeting_distribution"` Recruitment *RecruitmentConf `json:"recruitment"` Destinations *DestinationConf `json:"destinations"` Creatives []*CreativeConf `json:"creatives"` Audiences []*AudienceConf `json:"audiences"` }
StudyConf is the root config that holds the various different types of study configuration that can be applied to a study that gets sent by the frontend
func (*StudyConf) TransformForDatabase ¶
func (sc *StudyConf) TransformForDatabase() (res []DatabaseStudyConf, err error)
TransformForDatabase will take the StudyConfig that is passed from the frontend and transform it into a list that will be accepted by the database This is a Generic implementation as we have various types of configs that require the same transform to be done.
func (*StudyConf) TransformFromDatabase ¶
func (sc *StudyConf) TransformFromDatabase(dcs []*DatabaseStudyConf) error
TransformFromDatabase gets a list of DatabaseStudyConf and iterates through it, adding the relevant configs to the StudyConf struct
type StudyConfRepository ¶
type StudyConfRepository interface { Create(ctx context.Context, dsc DatabaseStudyConf) error GetByStudySlug( ctx context.Context, slug, userID string, ) ([]*DatabaseStudyConf, error) }
type StudyRepository ¶
type StudySegmentsRepository ¶
type StudySegmentsRepository interface { GetByStudySlug( ctx context.Context, slug, userID string, ) ([]SegmentsProgress, error) }
type TargetingConf ¶
type TargetingConf struct { TemplateCampaignName string `json:"template_campaign_name"` DistributionVars DistributionVar `json:"distribution_vars"` }
TargetingConf describes the variables for stratification and the desired joint distribution of respondents.
type TargetingDistributionConf ¶
type TargetingDistributionConf struct { //TODO verify if age should be a string Age string `json:"age"` Gender string `json:"gender"` Location string `json:"location"` }
TargetingDistributionConf proportion of people do you want in your final sample from each stratum
type TypeformConnectedAccount ¶
type TypeformConnectedAccount struct { CreatedAt int `json:"createdAt"` Credentials TypeformCredentials `json:"credentials" validate:"required"` }
func (TypeformConnectedAccount) MarshalCredentials ¶
func (t TypeformConnectedAccount) MarshalCredentials() (string, error)
MarshalsCredentials is used to input data into the database as a JSONB field
type TypeformCredentials ¶
type TypeformCredentials struct {
Key string `json:"key" validate:"required"`
}
type UserRepository ¶
type WebDestination ¶
WebDestination is a destination that you can pass a url to in order to redirect users to a specific survey platform