Page MenuHomePhabricator

Provide interface for gadget usage statistics
Closed, ResolvedPublic

Description

I'm opening this bug because I agree with what is requested at T34858: the JS and CSS pages should NOT be parsed as if they were normal "wiki pages" (at least NOT by default, i.e., only if the user opted in for such wiki-parsing). If someone fix that bug, though, the users who create user scripts will have no other hack to track the (crosswiki) usage of their code, and won't be able to notify users about possibly breaking changes in new versions of some JS code.

As you can check on commons:Special:WhatLinksHere/Template:GlobalJsUsage, some people also use fake [[File:UserName UserScript.js]] pages to be able to get a list from Special:GlobalUsage for the associated scripts (see also T3886: A cross-wiki "What links here" (aggregate local iwbacklinks from wikis))

MediaWiki needs a proper way to deal with tracking user scripts.


Version: unspecified
Severity: enhancement
See Also: T34858: Do not parse .js/.css pages and save their parsed content in database tables

Details

Reference
bz33355

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 12:07 AM
bzimport set Reference to bz33355.
bzimport added a subscriber: Unknown Object (MLST).
He7d3r created this task.Dec 23 2011, 8:22 PM
Reedy added a comment.Dec 24 2011, 4:36 PM

RL2/the gadgets rewrite should fix a lot of this...

(In reply to comment #1)

RL2/the gadgets rewrite should fix a lot of this...

Would that also work for JS/CSS files in userspace and the Project: namespace?

(In reply to comment #1)

RL2/the gadgets rewrite should fix a lot of this...

Well, it makes it redundant to have to update import-calls as the gadget will be centrally stored. But we don't yet provide a way to see how many people have certain gadgets enabled. This info is available in the database, but not in an efficient way (major wikis make weekly dumps of this from the Toolserver on a wiki page like https://commons.wikimedia.org/wiki/Commons:Database_reports/User_preferences#Gadgets )

(In reply to comment #2)

(In reply to comment #1)

RL2/the gadgets rewrite should fix a lot of this...

Would that also work for JS/CSS files in userspace and the Project: namespace?

No, and we don't have to in my opinion. Right now the habbit is for script to be copied and pasted or live-imported on load time from one user or wiki to another. That causes two needs:

  • Being able to track usage so that in case of changes, they can be updated
  • Statistics, how many people are using X

The goal is to remove that habbit, and instead have people write much more as gadgets, which allows re-use of code and asynchronous loading with other modules as well as much better internationalization and an easier for the users (no need to dive into code but just ticking checkboxes on Special:Preferences).

Both of these needs are still valid though.
the first one is redundant by using Gadgets since then code is stored and loaded from 1 central location, removing the need for updates.

The statistics is something we should still think about. For now the Wikimedia wiki's can do with database report bots, but ideally we'd have something like this in core or in an extension.

Renaming bug summary to aim for fixing the need for the way scripts are encourages to be written today and in the future, not the way they were being written up to last year.

Unless something has changed since my involvement decreased, at least on the English Wikipedia, there's a pretty big barrier (of inertia if nothing else) to getting new gadgets added - I really can't see gadgets becoming the preferred method of creating userscripts unless and until that is changed. Until that happens (and even after, for quite some time, given the extant body of non-gadget scripts), we still need some method of tracking script usage.

(In reply to comment #5)

Unless something has changed since my involvement decreased, at least on the
English Wikipedia, there's a pretty big barrier (of inertia if nothing else) to
getting new gadgets added - I really can't see gadgets becoming the preferred
method of creating userscripts unless and until that is changed. Until that
happens (and even after, for quite some time, given the extant body of
non-gadget scripts), we still need some method of tracking script usage.

Well, if we're talking about a new feature. Then I don't think there's a need
to support user scripts (if that's possible in a good way at all).

If you're referring to /* [[links]] */ and Special:WhatLinksHere.. well, I'd say keep
using that until gadgets are the common way for creating scripts.

He7d3r updated the task description. (Show Details)Dec 3 2014, 12:16 PM
He7d3r set Security to None.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 24 2015, 5:21 AM

(In reply to comment #5)
Well, if we're talking about a new feature. Then I don't think there's a need
to support user scripts (if that's possible in a good way at all).
If you're referring to /* [[links]] */ and Special:WhatLinksHere.. well, I'd say keep
using that until gadgets are the common way for creating scripts.

In the future we obviously want to use the modernised gadget infrastructure for tracking how people use gadgets. I think it would be a mistake to ignore user scripts, though.

As we move towards Gadgets 2.0 (and eventually 3.0), we are going to want to convert existing widely used user scripts into gadgets so that we can take advantage of the new features. Also, as more of deprecated JavaScript gets removed from MediaWiki, it would be desirable to fix widely used user scripts that use this deprecated code, so that communities aren't left without scripts that they rely on. However, there are so many scripts out there that it is very hard to see which scripts are worth updating and which aren't. It would be useful to be able to find out at least the number of people that use a given script, even if we don't list the pages that they are used on in the way Special:WhatLinksHere does.

We have already made significant progress on tracking gadgets with the implementation of Special:GadgetUsage (T115152). It would be great to have something similar for user scripts. It doesn't have to be real-time data - perhaps the data could be generated by a script running every week, or something like that.

Krinkle changed the task status from Duplicate to Resolved.EditedDec 8 2015, 5:55 PM
Krinkle claimed this task.

Closing this a duplicate of T21288 and T115152.

Tracking user scripts is in my opinion not feasible because they have no registry inside MediaWiki. Each user script is a free-form wiki page that happens to end in .js. The using of a user script by another user doesn't involve any MediaWiki systems, either (whereas Gadgets involve the user preferences system).

"Using" a user script usually constitutes including a statement in your personal javascript space that makes an HTTP request of sorts for a url that loads the raw contents of another wiki page. E.g. as importScript( 'User:Example/foo.js' ); There are many variations on this. And wikis also override this method on wikis (eg. importScriptMW or importMW or importScriptURI or mw.loader.load or jQuery.ajax or $j.ajax etc.).

I'd recommend using Special:WhatLinksHere to track non-gadget user scripts and instructing users to embed a tracking comment above the import script that follows a standard format.

For example:

// [[File:Krinkle Foo.js]]
mw.loader.load('//example.org/w/index.php?title=User:Krinkle/foo.js&action=raw&ctype=text/javascript');

This way even allows you to do it on a global level by leveraging GlobalUsage. Example: https://meta.wikimedia.org/wiki/Special:GlobalUsage/Krinkle_RTRC.js

He7d3r rescinded a token.Dec 9 2015, 12:28 AM
He7d3r awarded a token.