Open Miraeld opened 4 weeks ago
Outdated
2 approaches.
If https://github.com/wp-media/wp-rocket/issues/7058 hasn't been merged yet, we can add a checkbox to the form file_optimization
with the following code:
Otherwise, reuse the code from the mentioned PR.
About tracking in mixpanel.
in src/js/global/main.js
create a function trackDJESafeMode
that will be used to detect if the checkbox enabling safe mode DJE is checked.
/***
* Track DJE Safe Mode Checkbox
***/
function trackDJESafeMode() {
var isChecked = $('#delay_js_execution_safe_mode').is(':checked');
if (isChecked) {
var exclusions = $('#delay_js_exclusions').val();
if (typeof mixpanel !== 'undefined') {
mixpanel.track('DJE Safe Mode Clicked', {
'exclusions': exclusions
});
}
}
}
and add a callback on the button used to save settings OR the form submit.
Example of callback on the button click
$('#wpr-options-submit').on('click', function() {
trackDJESafeMode();
});
Finally add the following after this https://github.com/wp-media/wp-rocket/blob/612980f97db6ea6bdadd2c6793892fa0cd59635c/inc/admin/ui/enqueue.php#L70
mixpanel.track( 'DJE Safe Mode Clicked', localStorage.getItem('dje-safe-mode-clicked') );
Do you need additional code for mixpanel? All the options using checkboxes are tracked automatically already I believe (it's been a long time I checked that)
We may be tracking all checkboxes already, @wp-media/product could you confirm ?, I've to admit when I was looking at it, I wasn't sure to understand at 100% the mixpanel code and what we are tracking already.
However, from the notion here we need to track the content of the textarea, and for this I guess we'll need to set it up.
Yes. The feature state and its exclusions entries are sent to mixpanel. But each as a single entry which makes it hard to filter and analyze:
[delay_js_exclusions] => Array
(
[0] => \/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |'|"|>)
[1] => js-(before|after)
[2] => (?:/wp-content/|/wp-includes/)(.*)
)
What is needed is tracking when the above exact consecutive lines are present to know the extent of usage and help decide the next step.
The same should be done for previous iterations of the jquery exclusion pattern (first line). I believe it was changed 2 times or maybe more.
Ummm, first of all, this grooming is to forget then, as I thought we didn't track everything already.
Then, If I understand well @DahmaniAdame , You want to send something to mixpanel each time someone has
Array
(
[0] => \/jquery(-migrate)?-?([0-9.]+)?(.min|.slim|.slim.min)?.js(\?(.*))?( |'|"|>)
[1] => js-(before|after)
[2] => (?:/wp-content/|/wp-includes/)(.*)
)
In their exclusions.
If this is correct, then I don't really understand why would we track this as it won't stay in the textarea
as we are sanitizing
the content of the textarea
and deleting the default exclusion that could be added by the safemode.
As in the future, if these three lines are within the textarea while saving, it should turn on automatically the safe mode (that's something we discussed during the 3.18 presentation, not sure if that's still a plan).
@DahmaniAdame Wouldn't it make sense to collect everything what's there? We might use this data in the future while looking for the opportunities for enhancements.
Metrics Collection: Implement Mixpanel tracking to collect data on the usage of the DJE safe mode checkbox.