File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
android/src/main/java/com/formbricks/android Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,11 @@ object SurveyManager {
150150 val actionClasses = environmentDataHolder?.data?.data?.actionClasses ? : listOf ()
151151 val codeActionClasses = actionClasses.filter { it.type == " code" }
152152 val actionClass = codeActionClasses.firstOrNull { it.key == action }
153+ if (actionClass == null ) {
154+ val error = RuntimeException (" \" $action \" action unknown. Please add this action in Formbricks first in order to use it in your code." )
155+ Logger .e(error)
156+ return
157+ }
153158 val firstSurveyWithActionClass = filteredSurveys.firstOrNull { survey ->
154159 val triggers = survey.triggers ? : listOf ()
155160 triggers.firstOrNull { trigger ->
@@ -183,6 +188,10 @@ object SurveyManager {
183188 firstSurveyWithActionClass.id.let {
184189 isShowingSurvey = true
185190 val timeout = firstSurveyWithActionClass.delay ? : 0.0
191+ if (timeout > 0.0 ) {
192+ val surveyName = firstSurveyWithActionClass.name
193+ Logger .d(" Delaying survey \" $surveyName \" by $timeout seconds" )
194+ }
186195 stopDisplayTimer()
187196 displayTimer.schedule(object : TimerTask () {
188197 override fun run () {
Original file line number Diff line number Diff line change @@ -31,4 +31,14 @@ data class Survey(
3131 @SerializedName(" segment" ) val segment : Segment ? ,
3232 @SerializedName(" styling" ) val styling : Styling ? ,
3333 @SerializedName(" languages" ) val languages : List <SurveyLanguage >? ,
34+ @SerializedName(" projectOverwrites" ) val projectOverwrites : SurveyProjectOverwrites ? = null
35+ )
36+
37+ @Serializable
38+ data class SurveyProjectOverwrites (
39+ @SerializedName(" brandColor" ) val brandColor : String? = null ,
40+ @SerializedName(" highlightBorderColor" ) val highlightBorderColor : String? = null ,
41+ @SerializedName(" clickOutsideClose" ) val clickOutsideClose : Boolean? = null ,
42+ @SerializedName(" placement" ) val placement : String? = null ,
43+ @SerializedName(" darkOverlay" ) val darkOverlay : Boolean? = null
3444)
Original file line number Diff line number Diff line change @@ -129,8 +129,11 @@ class FormbricksViewModel : ViewModel() {
129129 jsonObject.addProperty(" contactId" , UserManager .contactId)
130130 jsonObject.addProperty(" isWebEnvironment" , false )
131131
132+ val matchedSurvey = environmentDataHolder.data?.data?.surveys?.first { it.id == surveyId }
133+ val project = environmentDataHolder.data?.data?.project
134+
132135 val isMultiLangSurvey =
133- (environmentDataHolder.data?.data?.surveys?.first { it.id == surveyId } ?.languages?.size
136+ (matchedSurvey ?.languages?.size
134137 ? : 0 ) > 1
135138
136139 if (isMultiLangSurvey) {
@@ -139,8 +142,15 @@ class FormbricksViewModel : ViewModel() {
139142 jsonObject.addProperty(" languageCode" , " default" )
140143 }
141144
142- val hasCustomStyling = environmentDataHolder.data?.data?.surveys?.first { it.id == surveyId }?.styling != null
143- val enabled = environmentDataHolder.data?.data?.project?.styling?.allowStyleOverwrite ? : false
145+ val hasCustomStyling = matchedSurvey?.styling != null
146+
147+ val placement = matchedSurvey?.projectOverwrites?.placement ? : project?.placement
148+ if (placement != null ) jsonObject.addProperty(" placement" , placement)
149+
150+ val darkOverlay = matchedSurvey?.projectOverwrites?.darkOverlay ? : project?.darkOverlay
151+ if (darkOverlay != null ) jsonObject.addProperty(" darkOverlay" , darkOverlay)
152+
153+ val enabled = project?.styling?.allowStyleOverwrite ? : false
144154 if (hasCustomStyling && enabled) {
145155 environmentDataHolder.getStyling(surveyId)?.let { jsonObject.add(" styling" , it) }
146156 } else {
You can’t perform that action at this time.
0 commit comments