Migrating to 0.9
Response metadata is sanitized instead of rejecting the response, and onFinished can receive the response result.
Version 0.9 changes how the widget and the server handle invalid response metadata. They now keep valid entries, repair or remove invalid entries, and submit the response with warnings.
You can upgrade from 0.8 without changing your code. The server continues to accept requests from 0.8 widgets, so you do not need a coordinated rollout.
Update the package
npm install @opengovsg/confetti@^0.9.0
# or
pnpm add @opengovsg/confetti@^0.9.0
# or
yarn add @opengovsg/confetti@^0.9.0Handle the response result
The optional onFinished argument contains the saved response on a successful
submission. Existing callbacks that accept no arguments continue to work.
<PopoverConfetti
surveyId="<your-survey-id>"
publishableKey="<your-publishable-key>"
onFinished={(result) => {
if (!result) return
console.log(result.id, result.createdAt)
if (result.warnings?.metadata) {
console.warn(result.warnings.metadata)
}
}}
/>If the network request fails, onFinished still runs and receives undefined.
Allow optional webhook warnings
When Confetti sanitizes metadata, the response webhook includes an optional
data.response.warnings object. Existing webhook payloads do not otherwise
change.
If your webhook parser rejects unknown fields, allow the optional warnings
field before upgrading. Parsers that ignore unknown fields need no changes.
Metadata sanitation
Version 0.9 applies the same rules in the widget and on the server:
- Valid entries are preserved.
- Values longer than 1,000 characters are truncated and end with
[truncated]. - Invalid keys and non-string values are removed.
- Metadata after the first 20 entries is removed.
- The server logs sanitation warnings and returns them to the widget.
The server remains the trust boundary. Client-side sanitation reduces request size but does not replace server validation.
Was this page helpful?