Closed (fixed)
Project:
Disqus
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Mar 2012 at 18:45 UTC
Updated:
1 Sep 2015 at 16:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
telegraph commentedComment #2
awolfey commentedI think the question here is also how to use drupal_add_js() to add the callback.
something like that should work, right?
Comment #3
girishmuraly commentedI have the same request and I think the best approach would be to implement the callback in a #post_render to the 'disqus' element. I've attached a patch that does this in a module called disqus_ga which I'm hoping can be a submodule to Disqus.
Other modules that want to do something different on the callback can either override the js callback using hook_js_alter() or follow the logic of the module to add their own callback.
Comment #4
slashrsm commentedYour patch looks like a whole new module. Did you want to include it in Disqus integration or create a standalone plugin?
Comment #5
girishmuraly commentedI thought it would benefit everybody if it was a submodule of Disqus. What do you think?
Comment #6
slashrsm commentedThat would work, but we need a patch against module for that also.
Comment #7
girishmuraly commentedI thought this patch would work. Works for me. Is there something I need to follow? Could you point me in the right direction please? Thank you.
Comment #8
hugronaphor commentedHere is the patch which is going to integrate the GA Tracking without creating a sub-mudule as in my opinion having a separate module for that is superfluous.
Things to mention:
- This patch will support the both, the old GA api and the new analytics.js and Universal Analytics (see: https://developers.google.com/analytics/devguides/collection/upgrade/ref... ).
Inspired from http://cgit.drupalcode.org/google_analytics_et/tree/js/google_analytics_... ;
- As we have already 3 .js files it's worth to move theme in a separate directory "js";
Please review.
Comment #9
slashrsm commentedThank you for your work. Looks very good. I'd suggest just few simple cosmetic improvements:
Let's add this new configuration variable to the hook_uninstall().
Missing newline.
It would be great to get this into 8.x-1.x first.
Comment #10
hugronaphor commentedThanks for the improvements suggestion.
Attaching the improved patch for 7.x-1.x (I also changed the callback name to make it more descriptive).
In the main time I'll work on 8.x-1.x branch.
Comment #11
hugronaphor commentedI saw that variable deletion is sorted alphabetically - pushing new variable in the corespondent place :)
Comment #12
hugronaphor commentedHere is the patch for 8.x-1.x
Comment #13
hugronaphor commentedComment #14
slashrsm commentedJS file seems to be missing in D8 patch.
Comment #15
slashrsm commented@hugronaphor: Check https://www.drupal.org/documentation/git/interdiff. Interdiffs are great way to clearly show changes between individual patches and make it much easier for people to review your work.
Comment #16
hugronaphor commentedHere is the fixed patch with js file included and interdiff.
Thanks for pointing me into the right direction.
Comment #17
slashrsm commentedThanks! This looks great. I missed another critical and another cosmetic thing during my last review. I apologize for ping-pong....
Library name is actually "disqus/disqus". However, since GA integraton can be disabled it would be nicer to separate it's JS into a separate library (which could be called "disqus/ga" eventually).
See https://www.drupal.org/node/2201089 for more info about libraries and their definition.
Would be nice to have this function namespaced in "Drupal.disqus". This applies to D7 too.
Comment #18
hugronaphor commentedBefore uploading the patch, would this be the correct way? :
disqus.libraries.yml
And I'm not sure I understand the meaning of "Drupal.disqus" namespace.
Do you mean as Drupal behavior maybe:
?
Comment #19
slashrsm commentedComment #20
hugronaphor commentedThis Issue can't be solved until the https://www.drupal.org/node/2476065 is not merged into 8.x-1.x
Comment #21
slashrsm commented#2476065 was merged.
Comment #22
hugronaphor commentedThanks @slashrsm
Here is the latest patch against 8.x-1.x
Comment #24
slashrsm commentedCommitted. Thank you!
Now we can include this in D7 version too.
Comment #25
hugronaphor commentedHere is the last path against the 7.x-1.x
Even if you suggested to namespace the function
disqusTrackNewCommentin "Drupal.disqus" namespace - I found it a bit difficult to manage the order of added JS files as we did in D8 branch (by using the libraries "dependenctcies" property) and this may create problems in future.Comment #26
slashrsm commentedThere are no other JS functions using this namespace at the moment so this would not be a problem, right?
Comment #27
hugronaphor commentedCorrect, there are no other JS functions using this namespace.
I'm concerned about where to declare the
Drupal.disqus = {};to make sure this will be available in any other part of APP. But you never can be sure without checking if the object exist already (this what I'm trying to avoid).Comment #28
slashrsm commentedFor now we could declare it in this file and try to fix this problem when we face it.
Comment #29
hugronaphor commentedI see what you mean. Here it is.
Comment #30
slashrsm commentedCommitted. Thanks!