Skip to main content
Version: Android SDK

Hooks

Set hooksโ€‹

You can define custom hooks to be executed on various events.

Thanks to this you will be able to interact with your website when a survey appears, or execute some custom code when a survey is submitted.

You can define hooks on Screeb.initSdk() and Screeb.startSurvey() commands. Hooks are all optional.

Available hooksโ€‹

Hook NameAvailable on Screeb.initSdk()Available on Screeb.startSurvey()
onSurveyShowedYes โœ…Yes โœ…
onSurveyStartedYes โœ…Yes โœ…
onQuestionRepliedYes โœ…Yes โœ…
onSurveyCompletedYes โœ…Yes โœ…
onSurveyHiddenYes โœ…Yes โœ…
onAppStoreRatingTriggeredYes โœ…Yes โœ…
onReadyYes โœ…No โŒ
onSurveyDisplayAllowedYes โœ…No โŒ

Set hooks on SDK initโ€‹

Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onReady" to { payload:Any -> Log.d("Screeb", "SDK Ready: $payload")},
"onSurveyDisplayAllowed" to { payload:Any -> true}
)
)

Set hooks on survey startโ€‹

Screeb.startSurvey(
surveyId = "<survey-id>",
allowMultipleResponses = true,
hiddenFields = HiddenFields().apply {
this["h1"] = "hidden_field1"
this["h_count"] = 75
},
hooks = hashMapOf(
"version" to "1.0.0",
"onSurveyShowed" to { payload:Any -> Log.d("Screeb", "Survey showed $payload")}
)
)

onSurveyShowedโ€‹

Called when a survey is showed.

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onSurveyShowed" to { payload:Any -> Log.d("Screeb", "Survey has been showed: $payload")},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyStartedโ€‹

Called when a survey is started.

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onSurveyStarted" to { payload:Any -> Log.d("Screeb", "Survey has been started: $payload")},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
},
user: {
anonymous_id: string,
user_id: string,
}
}

onQuestionRepliedโ€‹

Called when a question is replied.

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onQuestionReplied" to { payload:Any -> Log.d("Screeb", "Question has been replied: $payload")},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
status: "started" | "ended" | "closed" | "interrupted"
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
};
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyCompletedโ€‹

Called when a survey is completed.

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onSurveyCompleted" to { payload:Any -> Log.d("Screeb", "Survey has been completed: $payload")},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyHiddenโ€‹

Called when a survey is hidden.

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onSurveyHidden" to { payload:Any -> Log.d("Screeb", "Survey has been hidden: $payload")},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
survey: {
id: string,
survey_position: "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right",
survey_size: 25 | 50 | 75 | 100 | 125 | 150,
survey_format: "conversational" | "cards",
},
response: {
id: string,
hide_reason: "started" | "ended" | "closed" | "interrupted",
items: {
question: {
id: string;
title: string;
type: "text" | "video";
url: string;
};
answer: {
fields: {
type: "string" | "number" | "boolean" | "none" | "time" | "url";
},
text: string;
number: number;
boolean: boolean;
time: Date;
url: string;
}[] | undefined;
replied_at: Date | undefined;
}[];
},
user: {
anonymous_id: string,
user_id: string,
}
}

onAppStoreRatingTriggeredโ€‹

Called when an App Store Rating question is triggered.

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onAppStoreRatingTriggered" to { payload:Any -> Log.d("Screeb", "App store rating triggered: $payload")},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
user: {
anonymous_id: string,
user_id: string,
}
}

onReadyโ€‹

Called when the SDK is ready. Only available on Screeb.initSdk().

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onReady" to { payload:Any -> Log.d("Screeb", "SDK Ready: $payload")},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
user: {
anonymous_id: string,
user_id: string,
}
}

onSurveyDisplayAllowedโ€‹

Called before a survey display to allow it or not. Only available on Screeb.initSdk(). Return a boolean value. Return false to prevent display.

Example
Screeb.initSdk(this,
"<YOUR-CHANNEL-ID>",
hooks = hashMapOf(
"version" to "1.0.0",
"onSurveyDisplayAllowed" to { payload:Any -> Log.d("Screeb", "Survey display allowed: $payload"); true},
)
)
Payload definition
{
channel: {
id: string,
type: "android"
},
survey: {
id: string,
},
user: {
anonymous_id: string,
user_id: string,
}
}