PluginProbe ʕ •ᴥ•ʔ
Custom Twitter Feeds – A Tweets Widget or X Feed Widget / 2.8.0
Custom Twitter Feeds – A Tweets Widget or X Feed Widget v2.8.0
2.8.0 2.7.0 2.6.1 2.6.0 1.0 1.0.1 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.2 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.4 1.4.1 1.5 1.5.1 1.6 1.6.1 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1 2.1.1 2.1.2 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.5.4 2.5.5 trunk
custom-twitter-feeds / admin / assets / js / smash-usage-session.js
custom-twitter-feeds / admin / assets / js Last commit date
about.js 4 weeks ago admin-notifications.js 4 weeks ago settings.js 4 weeks ago smash-usage-session.js 4 weeks ago support.js 4 weeks ago
smash-usage-session.js
55 lines
1 /**
2 * Smash Usage Tracking: session duration and record-event from JS.
3 *
4 * @package TwitterFeed
5 */
6 (function ($) {
7 'use strict';
8
9 if (typeof window.ctfSmashUsageSession === 'undefined') {
10 return;
11 }
12
13 var config = window.ctfSmashUsageSession;
14 var sessionStart = Date.now();
15 var sessionSent = false;
16
17 function sendSessionDuration() {
18 if (sessionSent) {
19 return;
20 }
21 sessionSent = true;
22 var durationSeconds = Math.round((Date.now() - sessionStart) / 1000);
23 if (durationSeconds < 3) {
24 return;
25 }
26 if (navigator.sendBeacon) {
27 var data = new FormData();
28 data.append('action', 'ctf_smash_usage_record_session');
29 data.append('nonce', config.nonce);
30 data.append('duration_seconds', durationSeconds);
31 navigator.sendBeacon(config.ajax_url, data);
32 } else {
33 $.post(config.ajax_url, {
34 action: 'ctf_smash_usage_record_session',
35 nonce: config.nonce,
36 duration_seconds: durationSeconds
37 });
38 }
39 }
40
41 function recordEvent(eventName) {
42 $.post(config.ajax_url, {
43 action: 'ctf_smash_usage_record_event',
44 nonce: config.event_nonce,
45 event_name: eventName
46 });
47 }
48
49 $(window).on('beforeunload pagehide', function () {
50 sendSessionDuration();
51 });
52
53 window.ctfSmashUsageRecordEvent = recordEvent;
54 })(jQuery);
55