Events
const registration = oneSygnal.on('survey:shown', (data) => {
console.log(data.surveyId);
});
// unsubscribe either way:
registration.cancel();
// or:
oneSygnal.off('survey:shown', callback);on() returns a Registration; call .cancel() to stop receiving that event. off() is
a second mechanism that removes by callback reference (first match). On the loader,
on() returns undefined instead of a Registration if called before the bundle is
ready — see API Reference.
Event names and payloads
| Event | Payload | Notes |
|---|---|---|
survey:shown | { surveyId } | Fires once a survey overlay is confirmed attached/rendered. |
survey:completed | { surveyId } | Fires once a survey is fully completed. |
survey:dismissed | { surveyId } | Fires when a survey is dismissed without completion. |
survey:step | { surveyId, questionId, step } | Fires once per answered question. Web’s payload includes the step index — the natives’ equivalent (survey:question_answered) doesn’t. |
Android/iOS’s survey:shown/completed/dismissed payloads are a bare String survey
ID, not an object — web’s are all objects. Don’t assume the shape is the same across
platforms if you’re sharing analytics-forwarding code.
What’s absent on web
There is no ready event on web. The natives fire ready once initialize settles
successfully; web’s structural equivalent is init()’s Promise resolving (on the CDN
bundle — the loader’s init() isn’t a Promise at all, so it isn’t an equivalent there).
This is a structural difference from the natives’ callback-plus-event pair, not a missing
feature.
There is no survey:question_answered on web — that’s the natives’ name for what web
calls survey:step, with a narrower payload (no step index). One name/payload should
probably win eventually, but renaming either breaks existing integrators of that platform,
so both are documented as-is. See Platform Parity.