Skip to content

Conversation

escopecz
Copy link
Member

@escopecz escopecz commented Mar 7, 2024

Q A
Bug fix? Y
New feature? Y
Automated tests included? Y
Related user documentation PR URL
Related developer documentation PR URL
Issues addressed (#s or URLs) #2856
BC breaks?
Deprecations?

Description:

Add ability to use segment filters in dynamic content.

Steps to test this PR:

  1. Not needed in beta - Run dcp bin/console mautic:assets:generate if you don't want to use dev local env.
  2. Create segment to match contact in step 5
  3. Create dynamic content
    • Is campaign based? = NO
      Snímek obrazovky 2020-10-29 v 12 31 39
    • then click filter in the top > select Segment membership
    • use existing segment in which is created contact added
      Snímek obrazovky 2020-10-29 v 12 31 50
  4. Create dynamic content page in Components > Landing pages
    • Fill required info
    • Go to Builder
    • Drag Dynamic content into page content
    • Click on it
    • In right box select your dynamic content by name and use test as requested slot name
      Snímek obrazovky 2020-10-29 v 12 36 43
    • Close builder and save
    • with url https://yourmautic.coml/test check landing page
    • You 'll see content from step 5
  5. Create form with possibility to add contact Components > Forms
    • mapped and required fields Firstname, Lastname, Email
  6. Use this form in anonymous browser session
    • with url https://mautic-cloud.local/form/[ID] to add contact with criteria matching created segment in step 1
    • keep this browser window open
    • open new tab with landing page from step 3
    • You'll see dynamic content defined in step 2

Other areas of Mautic that may be affected by the change:

  1. CustomObjectsBundle\EventListener\DynamicContentSubscriber::evaluateFilters() is using stopPropagation method. This could eliminate further listeners from running if incorrect priority is set- https://github.com/mautic-inc/plugin-custom-objects/blob/b2ed6c064e3e256f2640fdb456bbf2cfb879300b/EventListener/DynamicContentSubscriber.php#L117

TODO

  • Frontend (form handling, js)
  • PHP Notice - Array to string conversion``$choice contains [] in
/vendor/symfony/form/ChoiceList/ArrayChoiceList.php:68 at 

When saving form kwith operator empty/not empty. Selected value before is saved in the same way as in lead_list table

lukassykora and others added 2 commits March 7, 2024 10:03
MAUT 3809 - Use segment membership as a filter for dynamic content for web
@escopecz escopecz requested a review from mabumusa1 as a code owner March 7, 2024 10:22
rohitp19 and others added 3 commits March 7, 2024 11:34
MAUT-5498 EAB - Segment Membership Filter in Dynamic Content Breaks Landing Pages
@escopecz escopecz added feature A new feature for inclusion in minor or major releases segments Anything related to segments dynamic-content unforking Used for PRs in the Acquia's unforking initiative labels Mar 7, 2024
@escopecz escopecz changed the title Use segment membership as a filter for dynamic content for web Segment membership as a new filter for dynamic web content Mar 7, 2024
Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 61.42%. Comparing base (5a7cd96) to head (3f1c84a).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                5.x   #13526      +/-   ##
============================================
+ Coverage     61.39%   61.42%   +0.03%     
- Complexity    34035    34050      +15     
============================================
  Files          2240     2240              
  Lines        101719   101773      +54     
============================================
+ Hits          62450    62518      +68     
+ Misses        39269    39255      -14     
Files Coverage Δ
...tBundle/EventListener/DynamicContentSubscriber.php 84.41% <100.00%> (ø)
...micContentBundle/Form/Type/DwcEntryFiltersType.php 95.65% <100.00%> (+0.19%) ⬆️
...amicContentBundle/Form/Type/DynamicContentType.php 95.78% <100.00%> (+0.23%) ⬆️
...namicContentBundle/Helper/DynamicContentHelper.php 79.76% <ø> (+11.90%) ⬆️
...ndles/EmailBundle/Helper/StatsCollectionHelper.php 6.66% <ø> (ø)
app/bundles/EmailBundle/Model/EmailModel.php 50.41% <ø> (-0.06%) ⬇️
...pp/bundles/LeadBundle/Entity/OperatorListTrait.php 91.66% <ø> (ø)
...dBundle/EventListener/DynamicContentSubscriber.php 100.00% <100.00%> (ø)
...dBundle/EventListener/FilterOperatorSubscriber.php 100.00% <100.00%> (ø)
...le/Form/DataTransformer/FieldFilterTransformer.php 87.09% <100.00%> (ø)
... and 4 more

... and 2 files with indirect coverage changes

@escopecz escopecz requested review from a team and rohitpavaskar and removed request for a team March 7, 2024 13:48
rohitpavaskar
rohitpavaskar previously approved these changes Mar 11, 2024
Copy link
Member

@RCheesley RCheesley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this with sample data, when I search for a segment none are found:

screenshot-mautic ddev site-2024 04 19-15_35_21

@RCheesley
Copy link
Member

I checked it on GitPod and I got something different - the ID rather than the name of the segment:

screenshot-8080-escopecz-mautic-mi0gs1eb5fq ws-eu110 gitpod io-2024 04 19-15_44_14

@escopecz
Copy link
Member Author

Interesting. It works well for existing DWC but when creating one from scratch I also see this issue.

@escopecz
Copy link
Member Author

It looks like it's not a bug in this PR but in general When loading the select type of filters when creating a DWC from scratch then all the values are switched with keys. See for example locale:
Screenshot 2024-04-22 at 10 52 26

@escopecz
Copy link
Member Author

Wow, this was quite a long trip to fix it all. The select type fields were broken and not only in 1 place but 3. Each different type of select field on a different place. It originates from Mautic 3 refactoring where we had to swap all select keys with labels and this was broken ever since. It suggests something about the usage of these fields in DWC as no one noticed for years?

Some field choices are generated via jS. so I fixed it there. Others are generated via HTML templates so I fixed it there. A special case is for States which use index instead of the normal key. The rest of the template fields are using keys.

And then there are custom field selects, multiselects and booleans. Those were swapped twice on one place so I removed the additional swap. It seems that the code is used only for DWC, not for segments anymore so it shouldn't break anything else.

Field types to test:

  • State
  • Preferred Locale
  • Preferred Timezone
  • Segment Membership
  • Custom selects, multiselects, boolean fields.

@escopecz escopecz force-pushed the segment-improvements branch from b7fbc0f to 514b0ef Compare April 22, 2024 13:28
@escopecz escopecz force-pushed the segment-improvements branch from 514b0ef to 8686a76 Compare April 22, 2024 13:32
@escopecz escopecz requested review from rohitp19 and RCheesley April 22, 2024 13:43
@escopecz escopecz added the bug Issues or PR's relating to bugs label Apr 22, 2024
@RCheesley
Copy link
Member

I reported the locale bug when it happened as we have had this issue since then in our download form on mautic.org/download. See #12851 :) Hurrah for fixing it finally!

@escopecz
Copy link
Member Author

@RCheesley I'm not sure it will fix #12851 but it would be a nice side effect.

Copy link
Contributor

@rohitp19 rohitp19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @escopecz

@escopecz escopecz added the pending-test-confirmation PR's that require one test before they can be merged label Apr 25, 2024
Copy link
Member

@RCheesley RCheesley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing those issues @escopecz - checked and it's indeed working as expected for include and exclude on segment membership and the other things.

Sadly it doesn't fix #12851 in forms but I guess it's a very similar issue responsible!

@RCheesley RCheesley added user-testing-passed PRs which have been successfully tested by the required number of people. code-review-needed PR's that require a code review before merging and removed pending-test-confirmation PR's that require one test before they can be merged labels Apr 25, 2024
@escopecz escopecz added code-review-passed PRs which have passed code review and removed code-review-needed PR's that require a code review before merging user-testing-passed PRs which have been successfully tested by the required number of people. labels Apr 26, 2024
@escopecz escopecz added this to the 5.1.0 milestone Apr 26, 2024
@escopecz escopecz merged commit ba7529c into mautic:5.x Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs code-review-passed PRs which have passed code review dynamic-content feature A new feature for inclusion in minor or major releases segments Anything related to segments unforking Used for PRs in the Acquia's unforking initiative
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants