Code Monkey home page Code Monkey logo

mautic-extended-field's Introduction

Mautic Extended Field Latest Stable Version License Build Status

Features:

  • Allows for hundreds of custom fields.
  • Prevents outages due to field additions/deletions at large scale (when used exclusively).
  • Allows for separation of data for those with HIPAA/PCI concerns.

Out of the box Mautic has a few challenges for companies that need hundreds of fields, or to store millions of leads. A full problem definition can be found at mautic/mautic#4139. This plugin is a compromise between a strict EAV approach and current custom field support, and allows an admin to disable the core "Contact" fields in favor of Extended fields if needed.

Plugin Overview

New Schema Structure

When creating a custom field, rather than adding a column to either the Lead (leads) or Company (companies) tables, This plugin implements new tables based on field type (boolean, text, choice, etc), and similar tables for secure data fields. A total of 14 new tables are created following the table name syntax:

 `leads_fields_leads . [DATA TYPE] . xref`   OR
 `leads_fields_lead . [DATA TYPE] . _secure_xref`

Each table contains the columns:

 `lead_id` - the id of the lead from the `leads` table the row applies to
 `lead_field_id` - the id of the corresponding Custom Field from the `lead_fields` table
 `value` - the value for the Custom Field. 

Overriding Mautic Lead Bundle

This plugin takes two approaches to overriding current methods for managing custom fields.

To allow for new Object types for Custom Fields, three form types are overridden using Symfony's Form Inheritance. By declaring a Form Inheritance tag in the plugin's config the build method of the original Form Type can be overridden to allow this plugin to redefine the form, injecting two new validated Object Types - Extended Field and Secure Extended Field. This Plugin overrides the FieldType, LeadType and ListType form definitions.

The other method of overriding the Mautic Lead Bundle is Symfony's Compiler Pass method. This allows the plugin to redirect the Classes used for service definitions from the Mautic Lead Bundle to use Classes defined by this plugin. The following services were redefined using this method:

`mautic.lead.model.field`
`mautic.form.type.leadfield`
`mautic.lead.model.lead`
`mautic.lead.repository.lead`
`mautic.lead.model.list`

Installation & Usage

Choose a release that matches your version of Mautic.

Mautic version Installation
2.12.x composer require thedmsgroup/mautic-extended-field-bundle "^2.12"
2.14.x composer require thedmsgroup/mautic-extended-field-bundle "^2.14"
2.15.x composer require thedmsgroup/mautic-extended-field-bundle "^2.15"
  1. Install by running the command above or by downloading the appropriate version and unpacking the contents into a folder named /plugins/MauticExtendedFieldBundle
  2. Go to /s/plugins/reload. The Extended Fields plugin should show up. Installation is complete.
  3. When creating new custom fields /s/contacts/fields/new select Object "Extended" or "Extended Secure".
  4. Optionally disable "core" lead fields in ExtendedField Settings /s/config/edit.

TODO

  • Permissions for Secure fields -- Need to implement Permission pass methods for any ExtendedFieldSecure data type display, edit or retrieval.
  • Support retrieving leads by unique IDs that are also extended fields. -- Override LeadRepository::getLeadIdsByUniqueFields to join and pivot on columns.
  • Support segmentation by an "empty" extended field (outer join).

Changes for Report Compatibility

** NOTE ** The ReportSubscriber event listener dynamically checks for an edit or
view request of reports and dynanically sets priority of the REPORT_ON_BUILD.
The REPORT_ON_BUILD and REPORT_ON_GENERATE subscribers exist specifically to add
UTM Tags into the Segment Membership Data Source. This is tangental functionality to the core "Extended Fields" purpose
and will hopefully go away pending approval of a Core modification that adds UTM Tags into the contacts column list.

Icon by lakshishasri from the Noun project.

mautic-extended-field's People

Contributors

cykonetic avatar heathdutton avatar indorock avatar scottshipman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mautic-extended-field's Issues

Incompatible with 2.15.0-beta

[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]
  Circular reference detected for service "mautic.lead.model.field", path: "mautic.lead.model.field -> mautic.lead.model.list -> mautic.lead.model.lead_segment_service -> mautic.lead.model.lead_segment_filter_factory -> mautic.lead.model.lead_segment_schema_cache -> mautic.lead.model.field".

The table prefixes duplication during installation of Extended Fields plugin

Mautic: 2.16.0
Extended Fields: 2.15
PHP: 7.1.33

The table prefixes duplication during installation of Extended Fields plugin.

image

We don't need to attach the table prefix in the table declaration of the loadMetadataCommon method, because this is handle by the loadClassMetadata event in the DoctrineEventsSubscriber class.

->setTable(MAUTIC_TABLE_PREFIX.'lead_fields_leads_'.$dataType.($secure ? '_secure' : '').'_xref');

Installation prefix not implemented

Hi guys,

There is an option to create table prefix during Mautic installation . It seems your plugin does not support this and sql queries do not work properly (tables are missing) . I'm putting the error message we got:

[2018-05-17 17:10:23] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\TableNotFoundException:
"An exception occurred while executing '
SELECT COUNT(l.id) as count FROM mtc_leads l LEFT JOIN mtc_users u ON u.id = l.owner_id LEFT JOIN lead_fields_leads_string_xref string129
ON (l.id = string129.lead_id) AND (string129.lead_field_id = 129)'
: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.lead_fields_leads_string_xref' doesn't exist"
at /home/webhosts/XLCD.com/html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 53
{"exception":"[object] (Doctrine\DBAL\Exception\TableNotFoundException(code: 0): An exception occurred while executing 'SELECT COUNT(l.id) as count
FROM mtc_leads l LEFT JOIN mtc_users u ON u.id = l.owner_id LEFT JOIN lead_fields_leads_string_xref string129 ON (l.id = string129.lead_id) AND
(string129.lead_field_id = 129)':\n\nSQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.lead_fields_leads_string_xref' doesn't exist at
/home/webhosts/XLCD.com/html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:53,
Doctrine\DBAL\Driver\PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.lead_fields_leads_string_xref'
doesn't exist at /home/webhosts/XLCD.com/html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:106,
PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.lead_fields_leads_string_xref' doesn't exist at
/home/webhosts/XLCD.com/html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:104)"} []

Br - PS

An error when an anonymous trying to submit a form with an email field and to merge with an existing contact.

Mautic: 2.16.0
Extended Fields: 2.15
PHP: 7.1.33

An error when an anonymous trying to submit a form with an email field and to merge with a contact.

It occurs inside the createLeadFromSubmit method of the Mautic\FormBundle\Model\SubmissionModel class because to access the repository of the lead uses the getRepository method directly from Doctrine\ORM\EntityManager class.

Steps to reproduce

  1. Create an extended custom field, for example: my_extended_field;
  2. Create a form with the email and the points fields and bind them to the custom fields of a contact, for example:
    Email: email
    Points: points
  3. Create a contact with filled an email only.
  4. Put your form to a website.
  5. Go to your website page with your form like an anonymous and try to submit the form.

image

  1. After form submission you will get en error.

The error log:

500 Internal Server Error - PHP Notice - Undefined index: my_extended_field

Symfony\Component\Debug\Exception\ContextErrorException
/app/bundles/LeadBundle/Deduplicate/ContactMerger.php:201 at
/app/bundles/LeadBundle/Deduplicate/ContactMerger.php:201 at Mautic\CoreBundle\ErrorHandler\ErrorHandler -> handleError ( '8', 'PHP Notice - Undefined index: my_extended_field', '/var/www/html/app/bundles/LeadBundle/Deduplicate/ContactMerger.php', '201', array('winner' => object(Lead), 'loser' => object(Lead), 'loserDate' => object(DateTime), 'winnerDate' => object(DateTime), 'newest' => object(Lead), 'oldest' => object(Lead), 'newestFields' => array('id' => '1431', 'title' => null, 'firstname' => null, 'lastname' => null, 'company' => null, 'position' => null, 'email' => null, 'mobile' => null, 'phone' => null, 'points' => '0', 'address1' => null, 'address2' => null, 'city' => null, 'state' => null, 'zipcode' => null, 'country' => null, 'preferred_locale' => null, 'timezone' => 'Europe/Paris', 'last_active' => '2020-06-25 13:21:55', 'attribution_date' => null, 'attribution' => null, 'my_extended_field' => '20'), 'oldestFields' => array('id' => '1430', 'title' => null, 'firstname' => null, 'lastname' => null, 'company' => null, 'position' => null, 'email' => '[email protected]', 'mobile' => null, 'phone' => null, 'points' => '0', 'address1' => null, 'address2' => null, 'city' => null, 'state' => null, 'zipcode' => null, 'country' => null, 'preferred_locale' => null, 'timezone' => null, 'last_active' => null, 'attribution_date' => null, 'attribution' => null), 'field' => 'my_extended_field', 'newValue' => '2020-06-25 13:21:55', 'fromValue' => 'empty', 'exception' => object(ValueNotMergeableException)) )
/app/bundles/LeadBundle/Deduplicate/ContactMerger.php:98 at Mautic\LeadBundle\Deduplicate\ContactMerger -> mergeFieldData ( object(Lead), object(Lead) )
/app/bundles/LeadBundle/Model/LegacyLeadModel.php:65 at Mautic\LeadBundle\Deduplicate\ContactMerger -> merge ( object(Lead), object(Lead) )
/app/bundles/LeadBundle/Model/LeadModel.php:2759 at Mautic\LeadBundle\Model\LegacyLeadModel -> mergeLeads ( object(Lead), object(Lead), true )
/app/bundles/FormBundle/Model/SubmissionModel.php:990 at Mautic\LeadBundle\Model\LeadModel -> mergeLeads ( object(Lead), object(Lead) )
/app/bundles/FormBundle/Model/SubmissionModel.php:403 at Mautic\FormBundle\Model\SubmissionModel -> createLeadFromSubmit ( object(Form), array('email' => '[email protected]', 'points' => '3344'),

Extended field values do not populate into email on send

The values in the extended fields are not populating into emails,

Steps to replicate:

  1. Build emails
  2. Add the token for the field
  3. Send email

The email shows the token in the builder, but when st sends it does not show the value in the email sent to the user.

Any ideas?

Cannot build a segment based on "empty" extended field.

Creating segments based on extended fields fails to recognize never set extended fields Ex

With an extended field:
Segment Ageless: Filter afb_age is empty, 0 records

With a lead field:
Segment jobless: Filter position is empty: 130184 records

API not supported

Hi,

thanks for this great extension.
As we want to use it hundreds of fields that are synced over 10 installations, we approach extended fields with the API.
When trying to create a field using the REST api, it is always created as a lead object, not extendedfield

Follow REST API documentation to create a field:
https://developer.mautic.org/#create-field

'user', 'password' => 'pwd', ); $initAuth = new ApiAuth(); $auth = $initAuth->newAuth($settings); $apiUrl = "https://your-mautic.com"; $api = new MauticApi(); $fieldApi = $api->newApi("contactFields", $auth, $apiUrl); $data = array( 'label' => 'API test field', 'type' => 'text', 'object' => 'extendedField', ); $field = $fieldApi->create($data); ?>

In table lead_fields, any new field created by a API call gets the object "lead".

(BUG) Form field value is not mapped to (extended) custom field in existing contact profile

Description : The functionality to map a form value to an extended custom field is broken when the contact already exists in Mautic. It's a problem for migrating an existing system's custom contact field to extended contact fields.

Mautic : v2.12.2
PHP : PHP Version 7.0.27

  1. Set as follows

image

  1. Create 2 custom fields : 1 normal / 1 extended (I haven't tried secure extended)

image

  1. Create a form with 2 text fields, and map the value of each to the previously created contact & extended custom fields

image

  1. Submit the form with a value in each field (and use the email of an existing contact whose profile already exists in Mautic)

image

  1. Observe the form results (it should be as expected)

image

  1. Check contact profile

image

LOG : It seems (without certainty) that the following log errors relates to this issue:

[2018-07-17 04:46:41] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: "An exception occurred while executing 'SELECT DISTINCT f.title AS title FROM lead_fields l WHERE (f.title <> '') AND (f.title IS NOT NULL) ORDER BY title ASC LIMIT 10 OFFSET 0': SQLSTATE[42S22]: Column not found: 1054 Unknown column 'f.title' in 'field list'" at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 71 {"exception":"[object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing 'SELECT DISTINCT f.title AS title FROM lead_fields l WHERE (f.title <> '') AND (f.title IS NOT NULL) ORDER BY title ASC LIMIT 10 OFFSET 0':\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column 'f.title' in 'field list' at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:71, Doctrine\DBAL\Driver\PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'f.title' in 'field list' at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:106, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'f.title' in 'field list' at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:104)"} []

Note : If you use in the form the email of a new contact (never added to Mautic before), then it will create this contact and the mapping will work well.

image

New extended field does not show up in form

Hi,

I have created a new extended text field
bildschirmfoto 2018-06-08 um 12 01 10

When trying to use it in a form it does not show.
bildschirmfoto 2018-06-08 um 12 02 50

I also tried to add a value to the DB hoping that this might be solving it (as per bug #29)

Unfortunately, it still does not work. Am I missing something?

Thanks for help

Tracking script inserts field id instead of value in extended fields if fingerprint tracking is enabled

What type of report is this:

Q A
Bug report? possible bug
Feature request?
Enhancement?

Description:

I‘ve upgraded to 2.15.1 and I am using extended fields. Inserting and updating values work perfect via api. But when using the mtc.js tracking script, every pageview inserts a number in each extend field (like 23, 24). This only happens with extended fields not with contact fields.

If a bug:

Q A
Mautic version 2.15.1
PHP version

Steps to reproduce:

  1. activate extended field plugin
  2. using tracking script on the website mtc.js
  3. Mautic inserts numbers in each extended field

Log errors:

Please check for related errors in the latest log file in [mautic root]/app/log/ and/or the web server's logs and post them here. Be sure to remove sensitive information if applicable.

Incompatible with Mautic 2.15.1

I Tried using the Plugin with Mautic 2.15.1 and get the following error:

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
You have requested a non-existent service "mautic.lead.model.lead".

Could not find out which change in Mautic 2.15.1 caused this issue ...

Not working in Mautic 4.x

The plugin is amazing and super helpful. But it gives an 500 error everytime i want to edit an existing custom field in Mautic 4.
Maybe someone knows what to update to get it working again in M4?

This is the error i get in the logs:
mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Attempted to call an undefined method named "getContainer" of class "Symfony\Component\EventDispatcher\EventDispatcher"." at /var/www/html/mautic/plugins/MauticExtendedFieldBundle/Form/ExtendedFieldExtension.php line 34 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Attempted to call an undefined method named "getContainer" of class "Symfony\Component\EventDispatcher\EventDispatcher". at /var/www/html/mautic/plugins/MauticExtendedFieldBundle/Form/ExtendedFieldExtension.php:34)"} []

(BUG) After migration, custom field type "extended contact field" can not be deleted

How to replicate ?

  1. Migrate from 2.12.2 to 2.14.1
  2. Go to custom fields
  3. Search for an extended custom field that already has non-empty values for some contact

Actual result : The extended contact field can not be deleted, and the error below is logged. Any contact that have non-empty value for this contact field also can not be deleted from contact page.

Expected result : It should delete this fields, in any circumstances

In order to delete the custom field, here's what I had to find all my contacts that had a non-empty value for this extended contact field, and replace manually non-empty value by empty value

This is the error message I got :

mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: "An exception occurred while executing 'DELETE FROM lead_fields WHERE id = ?' with params [44]: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`troy_mautic_staging`.`lead_fields_leads_string_xref`, CONSTRAINT `FK_552CFEC5EE6485B3` FOREIGN KEY (`lead_field_id`) REFERENCES `lead_fields` (`id`))" at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 60 {"exception":"[object] (Doctrine\\DBAL\\Exception\\ForeignKeyConstraintViolationException(code: 0): An exception occurred while executing 'DELETE FROM lead_fields WHERE id = ?' with params [44]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`troy_mautic_staging`.`lead_fields_leads_string_xref`, CONSTRAINT `FK_552CFEC5EE6485B3` FOREIGN KEY (`lead_field_id`) REFERENCES `lead_fields` (`id`)) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:60, Doctrine\\DBAL\\Driver\\PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`troy_mautic_staging`.`lead_fields_leads_string_xref`, CONSTRAINT `FK_552CFEC5EE6485B3` FOREIGN KEY (`lead_field_id`) REFERENCES `lead_fields` (`id`)) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`troy_mautic_staging`.`lead_fields_leads_string_xref`, CONSTRAINT `FK_552CFEC5EE6485B3` FOREIGN KEY (`lead_field_id`) REFERENCES `lead_fields` (`id`)) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)"} []

Editing contact's extended field does not save the value

Hi guys,

I created an extended text area field. When i tried to edit a contact manually, and add some text in the field, the text was not saved, and the following exception was thrown:

[2020-02-13 19:41:37] mautic.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMException: "Entity 'Mautic\LeadBundle\Entity\LeadField' has no field 'alias'. You can therefore not call 'findOneByAlias' on the entities' repository" at /opt/bitnami/apps/mautic/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php line 184 {"exception":"[object] (Doctrine\ORM\ORMException(code: 0): Entity 'Mautic\LeadBundle\Entity\LeadField' has no field 'alias'. You can therefore not call 'findOneByAlias' on the entities' repository at /opt/bitnami/apps/mautic/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:184)"} []

can you please help?

plugin status

Hi is this plugin still working with the latest Mautic version 3.3.3 ?

Installation not working on version 2.13

Hi all,

I'm really interested in this feature, but I can't make the installation. Already tried:

  • Downloading the files manually
  • Clearing the cache
    Still doesn't work.

Do you have any success tests using 2.13?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.