Open
Conversation
Collaborator
ThbPS
commented
Mar 26, 2026
| Questions | Answers |
|---|---|
| Description? | This PR migrates the latest One Page Checkout changes implemented in Core OPC into the native module. It centralizes OPC JS events and shared selectors, reorganizes AJAX checkout handlers by domain, and keeps the module aligned with Core behavior without changing public routes or JSON contracts. |
| Type? | improvement / refacto |
| BC breaks? | no |
| Deprecations? | no |
| Fixed ticket? | N/A. |
| How to test? | Verify checkout behaviors are unchanged: address refresh, carrier refresh, payment refresh, guest init, final submit, and address modal flows. |
Feat: finish opc migration
- Add segmentio/analytics-php dependency and PHP bootstrap (Segment::init) - Bootstrap from BO configuration context when module is enabled - Add Segment documentation and adjust tests accordingly
… rule
phpstan-strict-rules flags bare array-access expressions whose result is
discarded. Replace $arr['key']; with $arr->offsetGet('key'); — method
calls are not subject to the same rule while still forcing CartLazyArray
to eagerly compute tax-sensitive properties.
…-lazy-array fix: eager-evaluate tax-sensitive cart properties before temp address cleanup
Move Segment PHP write key out of the repository by reading it from PS_OPC_SEGMENT_WRITE_KEY. This prevents local/preprod environments from sending events to the production Segment source when the prod key is not present.
Read Segment write keys from environment variables and select the correct one using APP_ENV. - APP_ENV=prod|production -> SEGMENT_PROD_KEY - otherwise -> SEGMENT_PREPROD_KEY
kevin-carangeot
approved these changes
Apr 9, 2026
Use _PS_MODE_DEV_ to select which Segment write key to load from env. - _PS_MODE_DEV_=true -> SEGMENT_PREPROD_KEY - _PS_MODE_DEV_=false -> SEGMENT_PROD_KEY Also stop tracking .env and provide .env.dist template.
…cher-sync fix(opc): SPE-110 sync pay button amount on voucher changes
- add gift wrapping support - make submit validation state survive reloads and failed submit roundtrips - harden address, carrier, payment and guest flows in the frontend
Introduce Analytics::trackEvent() which bootstraps Segment lazily and tracks events in best-effort mode. Remove Segment bootstrap from hookActionAdminControllerSetMedia so analytics init no longer depends on a PrestaShop hook. Update docs and unit tests accordingly.
[SPE-105] feat(analytics): add Segment PHP client bootstrap
* feat: update decisions documentation and add tests for module lifecyle * fix: integration & unit tests for module lifecycle * feat(analytics): add Segment PHP client bootstrap - Add segmentio/analytics-php dependency and PHP bootstrap (Segment::init) - Bootstrap from BO configuration context when module is enabled - Add Segment documentation and adjust tests accordingly * style: apply PHP CS Fixer (constructor, blank lines) * fix(analytics): read Segment write key from env Move Segment PHP write key out of the repository by reading it from PS_OPC_SEGMENT_WRITE_KEY. This prevents local/preprod environments from sending events to the production Segment source when the prod key is not present. * fix(analytics): select Segment key by APP_ENV Read Segment write keys from environment variables and select the correct one using APP_ENV. - APP_ENV=prod|production -> SEGMENT_PROD_KEY - otherwise -> SEGMENT_PREPROD_KEY * docs(analytics): document APP_ENV key selection * chore: add .env with Segment keys and APP_ENV * fix(analytics): select Segment key by _PS_MODE_DEV_ Use _PS_MODE_DEV_ to select which Segment write key to load from env. - _PS_MODE_DEV_=true -> SEGMENT_PREPROD_KEY - _PS_MODE_DEV_=false -> SEGMENT_PROD_KEY Also stop tracking .env and provide .env.dist template. * chore: remove .env.dist * fix Env * feat(analytics): track OPC critical errors Emit a Segment event when a technical/blocking error is caught in OPC AJAX endpoints. Event: [OPC] Checkout Error Occurred Payload props: - error_type (enum) - guest_checkout_active (yes|no) Common props (auto-enriched): - device_type - prestashop_version - module_version Why module_version stays a parameter: - In frontend controllers we already have ->module->version available. - Avoids re-instantiating the module (Module::getInstanceByName) inside a catch/error path. - Prevents adding extra DB/context dependencies to the error handler. * refactor(analytics): init Segment on-demand Introduce Analytics::trackEvent() which bootstraps Segment lazily and tracks events in best-effort mode. Remove Segment bootstrap from hookActionAdminControllerSetMedia so analytics init no longer depends on a PrestaShop hook. Update docs and unit tests accordingly. * Fix md translation * refactor(analytics): address PR review — device type constants and remove unused Analytics import Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: ThbPS <thomas.broussoux@prestashop.com> Co-authored-by: ThbPS <109082310+ThbPS@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
[SPE-25] - Add confirmation modale for payout layout switch
[SPE-30] - Multicarrier => Vérifier le bon affichage des transporteurs lorsque le feature flag “Improved shipment” est actif
…out events (#32) * feat(analytics): track OPC module lifecycle and checkout layout events Implements 7 Segment events for BUC-58 (OPC activation tracking): - [OPC] Module Enabled / Disabled / Uninstalled / Updated - [OPC] Module Configured - [OPC] Checkout Layout Selected / Published Adds buildCommonProps() and detectDeviceType() to Analytics (aligned with PR #28) so all events carry device_type, prestashop_version and module_version automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(analytics): cast module version to string for PHPStan and fix CS - Cast $this->version and $this->module->version to (string) in all Analytics::buildCommonProps() calls — Module stub types version as mixed, PHPStan level 5 rejects mixed where string is expected. - Remove trailing blank line before closing brace in ps_onepagecheckout.php to satisfy PHP CS Fixer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(analytics): merge common props inside trackEvent Add moduleVersion param to trackEvent — common props are now merged internally, keeping buildCommonProps private. Remove per-event wrapper methods in favor of direct trackEvent calls from callers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(analytics): add public constants for all event names Replace magic strings with named constants on Analytics class, consistent with the existing EVENT_OPC_CRITICAL_ERROR pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(analytics): add checkout type constants to BackOfficeConfigurationForm Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(analytics): add missing Analytics use statement in main module file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(module): add actionModuleUpgradeAfter to expected hooks in install test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…ed (#36) * [SPE-82] feat(analytics): track Checkout Started and Checkout Completed Emit Segment events at the two key moments of the OPC checkout tunnel: - [OPC] Checkout Started: fired in hookActionFrontControllerSetMedia when the OPC page is loaded and the tunnel is active. - [OPC] Checkout Completed: fired in opcsubmit after a successful submit, capturing the selected payment method. Both events share the common props auto-enriched by Analytics::buildCommonProps (device_type, prestashop_version, module_version) plus guest_checkout_active. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(analytics): make checkout event constants private EVENT_OPC_CHECKOUT_STARTED and EVENT_OPC_CHECKOUT_COMPLETED are only used internally via their dedicated track methods — private is the correct visibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(cs): remove trailing blank line before closing brace Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
… with wrong number of arguments Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…arity [fix] Analytics: fix trackCheckoutStarted/Completed calling trackEvent with wrong number of arguments
Move shared OPC availability and runtime exception handling to the JSON front controller parent so child controllers only implement their successful request path. Keep opcsubmit thin by delegating failed-submit state persistence to OnePageCheckoutSubmitHandler, including technical reload errors and active cart validation. Remove the ModuleTranslation helper and use the translator contract directly across handlers and checkout form code. Update unit coverage for submit error persistence and controller behavior.
Feat: improve checkout robustness and error recovery
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.