Hi All!
Currently trigger tracks all visits of a user, so there could be a statistic of visits as it's shown below:
admin
1 sec ago
admin
13 sec ago
admin
54 min 30 sec ago
admin
56 min 27 sec ago
admin
58 min 24 sec ago
admin
58 min 36 sec ago
admin
1 hour 1 min ago
admin
1 hour 16 min ago
admin
1 hour 16 min ago
So, user may reload page, for example, 5 times (e.g. because it's loading too long) and all these reloads will be tracked as visits -- this work as a spam for users, who are interesting in such statistic.
It could be great to have an option which sets a time delay between points when system tracks visits of a user.
PS: I created a custom module for tracking of visits, but then found that Activity can do this too. Now I don't want to use my own modle, because I really like how the Activity works :)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | expand_activity_record-1255090.patch | 4.78 KB | ss81 |
Comments
Comment #1
sirkitree commentedIn the DEVELOPER.txt there are some hooks defined that you can utilize for this. One allows you to do something before activity is recorded. I would suggest utilizing that hook, do you checking, and only record based on your time sensitivity.
Comment #2
ss81 commentedHello Jerad Bitner,
Thank you for suggetion! I will try to use these hooks. Could we leave this post, so I will be able to add an example of code here?
--
Best regards,
Sergei
Comment #3
ss81 commentedThere is a mistake in DEVELOPER.txt, as well as on http://drupal.org/node/626914:
The name of function should be example_activity_record_alter() instead of example_activity_recordS_alter()
Comment #4
ss81 commentedUnfortunately, record is always recorded to DB. There is the code:
Even if I unset the $record in my hook, the empty record would be recorded by drupal_write_record().
It could be great to add a condition and verify the $record after the call of drupal_alter():
Comment #5
ss81 commentedI've tried to use the hook_activity_message_recorded(). Unfortunately I can't avoid tracking from this hook because the table {activity_access} is filled after it:
So, in hook_activity_message_recorded() I can verify a tracked activity (by $record->aid) and remove it, but I can't remove records from {activity_access}.
I added the condition which checks if $record is empty after the call of hook_activity_record_alter(). Now it works well.
The patch is attached. It could be great if you can check and test it.
PS: Eclipse cleared whitespaces, so patch is a bit long :( The changes, which I made, are located in lines 78-81.
Comment #6
ss81 commentedComment #7
_shyD6 reached its EOL back in February 2016, and there is no active release for D6 for this module anymore.
Development or support is not planned for D6. All D6-related issues are marked as outdated in a bunch.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.
Thanks!