@@ -68,6 +68,9 @@ type STDashboardConfig struct {
6868 OperatorTypes OperatorTypes `json:"operator_types"`
6969}
7070
71+ // GetSTRules provides session targeting rules
72+ // that matches various filter criteria
73+ // in a paginated fashion.
7174func GetSTRules (ctx context.Context , af * filter.AppFilter ) (rules []SessionTargetingRule , next , previous bool , err error ) {
7275 stmt := sqlf .PostgreSQL .From ("session_targeting_rules" ).
7376 Select ("id" ).
@@ -164,10 +167,9 @@ func GetSTRules(ctx context.Context, af *filter.AppFilter) (rules []SessionTarge
164167 return rules , next , previous , nil
165168}
166169
167- // GetSTRule constructs and returns a
168- // session targeting rule for a
169- // given ruleId
170- func GetSTRule (ctx context.Context , ruleId string ) (rule SessionTargetingRule , err error ) {
170+ // GetSTRuleById fetches a session targeting
171+ // rule by its ruleId.
172+ func GetSTRuleById (ctx context.Context , ruleId string ) (rule SessionTargetingRule , err error ) {
171173 stmt := sqlf .PostgreSQL .From ("session_targeting_rules" ).
172174 Select ("id" ).
173175 Select ("team_id" ).
@@ -205,6 +207,9 @@ func GetSTRule(ctx context.Context, ruleId string) (rule SessionTargetingRule, e
205207 return rule , nil
206208}
207209
210+ // CreateSTRule validates and creates
211+ // a new session targeting rule for
212+ // an app.
208213func CreateSTRule (ctx context.Context , teamId string , appId string , userId string , payload CreateSTRulePayload ) (rule SessionTargetingRule , err error ) {
209214 now := time .Now ()
210215 ruleId := uuid .New ()
@@ -257,6 +262,8 @@ func CreateSTRule(ctx context.Context, teamId string, appId string, userId strin
257262 return rule , nil
258263}
259264
265+ // UpdateSTRule updates an existing
266+ // session targeting rule.
260267func UpdateSTRule (ctx context.Context , teamId string , appId string , userId string , ruleId string , payload UpdateSTRulePayload ) error {
261268 now := time .Now ()
262269
@@ -299,6 +306,9 @@ func UpdateSTRule(ctx context.Context, teamId string, appId string, userId strin
299306 return nil
300307}
301308
309+ // GetSTDashboardConfig creates and returns
310+ // the config required to render session
311+ // targeting rule creation page.
302312func GetSTDashboardConfig (ctx context.Context , appId uuid.UUID , osName string ) (STDashboardConfig , error ) {
303313 eventUdAttrs , err := getUDAttrKeys (ctx , appId )
304314 if err != nil {
@@ -349,7 +359,8 @@ func getUDAttrKeys(ctx context.Context, appId uuid.UUID) (attributes []Attribute
349359 return
350360}
351361
352- // newEventsConfig creates OS-specific events configuration
362+ // newEventsConfig creates OS-specific
363+ // events configuration
353364func newEventsConfig (os string ) []Event {
354365 // Common events for both iOS and Android
355366 events := []Event {
@@ -443,6 +454,8 @@ func newEventsConfig(os string) []Event {
443454 return events
444455}
445456
457+ // newEventsConfig creates OS-specific
458+ // session attributes configuration.
446459func newSessionConfig (osName string ) []Attribute {
447460 switch opsys .ToFamily (osName ) {
448461 case opsys .Android :
0 commit comments