Asset download not tracked

Your software
My Mautic version is: v2.16.2
My PHP version is: v7.3.14

Your problem
My problem is: I have a PDF asset that users can request by filling in
a form (Gravity Forms → Zapier → Mautic), which works. I send the
asset download link by mail to the user from within Mautic. The
following happens:

  • The asset downloads correctly
  • Mautic shows the contact has opened the mail, but not that they
    have downloaded the asset.
  • The asset_downloads table is empty
  • The asset page does show the correct number of downloads
  • The user doesn’t get added to a segment of users who have
    downloaded that asset

These errors are showing in the log: none - in fact, there’s no entry
at all in the logs. The Apache log shows the asset being downloaded.

Steps I have tried to fix the problem:

  • I’ve checked that the link in the email is encoded by Mautic (it
    is).
  • I’ve ensured that the user receiving the email is not logged into
    Mautic (they don’t have a Mautic account, but I logged out anyway)
  • I tried to follow the code page but got lost at index.php(!). If
    someone can point me to where in the codebase to look, I’ll try
    some debugging.

I’ve found an error in the Apache log. This error is repeated every time the asset is downloaded. Can anyone shed any light on this?

[Wed Jun 24 20:19:58.144496 2020] [proxy_fcgi:error] [pid 27810:tid 140140244576000] [client 2001:678:32c:57af::1005:59668] AH01071: Got error 'PHP message: Doctrine\\ORM\\ORMInvalidArgumentException: A new entity was found through the relationship 'Mautic\\AssetBundle\\Entity\\Download#lead' that was not configured to cascade persist operations for entity: Mautic\\LeadBundle\\Entity\\Lead with ID #. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). in /var/www/ems/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:92\nStack trace:\n#0 /var/www/ems/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(852): Doctrine\\ORM\\ORMInvalidArgumentException::newEntityFoundThroughRelationship(Array, Object(Mautic\\LeadBundle\\Entity\\Lead))\n#1 /var/www/ems/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(740): Doctrine\\ORM\\UnitOfWork->computeAssociationChanges(Array, Object(Mautic\\LeadBundle\\Entity\\Lead))\n#2 /var/www/ems/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(452): Doctrine\\ORM\\Unit...'

How can I move this forwards?

Either I misunderstand what Mautic should be able to do, or there’s a configuration problem or there’s a bug.

If someone would point to where in the code asset tracking is implemented, I’ll try to dig deeper.

Thanks.

I’ve now set up a virgin 2.16.2 installation to try this. The good news is that I don’t get any errors anywhere. The bad news is that it still doesn’t work.

Really looking for a way to move this forwards. What can I do to help?