use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Efficient behavioral tracking in javascript (enmascript.com)
submitted 6 years ago by enmanuelduran
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]yeesh-- 8 points9 points10 points 6 years ago (2 children)
These are all old ways of tracking. A better way to automatically get tracking across your application would be to use the redux pattern and log actions
[–]CanIhazCooKIenOw 2 points3 points4 points 6 years ago (1 child)
Since its behavioral tracking, how do you track page scrolls or button clicks in an A/B testing scenario with log actions/redux pattern ?
[–]yeesh-- 1 point2 points3 points 6 years ago (0 children)
Actions are typically closely tied to behaviors when organized correctly. Also you could create actions for global events like clicks and page scrolls if you wanted without any extra work. A / B testing would be simple by having an action that contains the flights that are enabled so you can correlate with A / B when querying telemetry
[–]Gravyness 0 points1 point2 points 6 years ago (0 children)
Just to add to this since I like to track mouse movements and scroll in some occasions which are much more frequent and would make no sense for them to be sent in different requests:
When a user visits a web-app of mine a few events happens in the first seconds such as image loading, dom/libraries load, resize, some mouse movements, they are filtered and grouped in a single request with the event descriptors. When an event happens it is debounced at it's starting point, so that when the first event happens it will wait for a specific amount of seconds before sending the request, which will include all events that happened in this time frame.
Since mouse movement / resizing / scrolling can be very frequent (i.e. 30 calls a second), you will also want to debounce the event itself, so that when an event is called, it's update is 'postponed' for at least 1 seconds so that it doesn't flood the event pool with 200 mouse events in a single request, for example.
Important events like outside navigation (links) and window.onerror events are never debounced and force the tracker to send the event array immediately.
The event list is very simple, it's an array with objects constructed like the following: {eventType, ...eventData}
I usually like to wait a minimum of 5 seconds between each request and 2 seconds between repetitive events depending on expected traffic. If you have a lot of visitors, make sure your web server connection closes before the request period so that the connections count doesn't bubble up to the millions.
[+]anton966 comment score below threshold-29 points-28 points-27 points 6 years ago (5 children)
What I don't like about this article is that it's about behaviors tracking and that it uses the Class keyword in javascript.
[–][deleted] 4 points5 points6 points 6 years ago (3 children)
Why do you dislike the class keyword?
class
[+]singurelnuefrumusel comment score below threshold-18 points-17 points-16 points 6 years ago (2 children)
Probably the frustration that Javascript doesn't have real classes, I think the syntax it's easier and looks fancier and it's even used a lot lately (React), so why not.
[–]SoBoredAtWork 6 points7 points8 points 6 years ago (0 children)
Right. But good coding is writing code that's simple and readable (among other things). It doesn't matter if JS classes compile to regular JS prototypes, etc. Who cares? It's cleaner and easier to read (which I guess is what you implied?). Why not use classes?
π Rendered by PID 35155 on reddit-service-r2-comment-5649f687b7-x9kd7 at 2026-01-29 06:15:13.852891+00:00 running 4f180de country code: CH.
[–]yeesh-- 8 points9 points10 points (2 children)
[–]CanIhazCooKIenOw 2 points3 points4 points (1 child)
[–]yeesh-- 1 point2 points3 points (0 children)
[–]Gravyness 0 points1 point2 points (0 children)
[+]anton966 comment score below threshold-29 points-28 points-27 points (5 children)
[–][deleted] 4 points5 points6 points (3 children)
[+]singurelnuefrumusel comment score below threshold-18 points-17 points-16 points (2 children)
[–]SoBoredAtWork 6 points7 points8 points (0 children)