-
Notifications
You must be signed in to change notification settings - Fork 40
Stabilize normalized form submission context #1359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8a5ba9f
Normalize form integrations script for current lint rules
danieliser 219c8ba
Add normalized form submission context
danieliser e97b5e3
Harden normalized submission metadata
danieliser 2ca9fbe
Preserve zero submission IDs in replay
danieliser 0abd65a
Resolve source IDs from valid URLs
danieliser 4180973
Clear stale implicit source IDs
danieliser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Normalized form submission context | ||
|
|
||
| Popup Maker form integrations report successful submissions through | ||
| `pum_integrated_form_submission()` in PHP and | ||
| `PUM.integrations.formSubmission()` in JavaScript. The normalized envelope is | ||
| provider-independent, and extensions can attach their own namespaced data to | ||
| `context` without changing each provider integration. | ||
|
|
||
| ## Contract | ||
|
|
||
| PHP integrations use snake-cased keys: | ||
|
|
||
| ```php | ||
| pum_integrated_form_submission( [ | ||
| 'form_provider' => 'example', | ||
| 'form_id' => 12, | ||
| 'submission_id' => 'entry-456', | ||
| 'source_post_id' => 78, | ||
| 'source_url' => 'https://example.com/guide/', | ||
| 'context' => [ | ||
| 'my_extension' => [ | ||
| 'campaign_id' => 90, | ||
| ], | ||
| ], | ||
| ] ); | ||
| ``` | ||
|
|
||
| JavaScript integrations receive the camel-cased equivalents. When a provider | ||
| does not supply `submission_id` / `submissionId`, Popup Maker generates a UUID | ||
| for that one normalized event. Provider-native submission IDs are the reliable | ||
| correlation key when matching independently observed server and frontend | ||
| callbacks; independently generated IDs are not a cross-transport deduplication | ||
| mechanism. | ||
|
|
||
| `source_url` defaults to the sanitized request referrer in PHP and the current | ||
| page URL in JavaScript. PHP resolves `source_post_id` from the effective source | ||
| URL when an explicit numeric post ID is not supplied, including after an | ||
| extension replaces the URL. Both values remain nullable because referrers may | ||
| be unavailable and not every URL represents a WordPress post. A PHP `null` | ||
| source URL remains `null` when localized for browser replay rather than being | ||
| replaced with the post-redirect page URL. | ||
|
|
||
| ## Extension context | ||
|
|
||
| PHP extensions can use the existing | ||
| `pum_integrated_form_submission_args` filter. Frontend extensions use the | ||
| `pum.integration.form.submissionArgs` filter, which runs after defaults and | ||
| popup resolution but before the form key, conversion event, and normalized | ||
| success action are produced. | ||
|
|
||
| ```js | ||
| PUM.hooks.addFilter( | ||
| 'pum.integration.form.submissionArgs', | ||
| ( args ) => ( { | ||
| ...args, | ||
| context: { | ||
| ...args.context, | ||
| myExtension: { campaignId: 90 }, | ||
| }, | ||
| } ) | ||
| ); | ||
| ``` | ||
|
|
||
| Context and source values are descriptive metadata, not proof of identity or | ||
| authorization. Consumers must validate untrusted values before privileged | ||
| operations and apply their own privacy and retention policies before storing | ||
| submission data. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Normalize source metadata before and after the filter.
sourcePostIdandsourceUrlbypass validation at Lines 96-105 and Lines 121-129. A provider or filter can dispatch arrays or other invalid values throughpum.integration.form.success. This violates the documented nullablenumberandstringcontract. Normalize both fields before filtering and after filtering. Add invalid-value coverage.Also applies to: 121-129
🤖 Prompt for AI Agents