如何跟踪我的Greasemonkey脚本有多少次自动升级下载? [英] How to track how many automatic-upgrade downloads my Greasemonkey script has?

查看:185
本文介绍了如何跟踪我的Greasemonkey脚本有多少次自动升级下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中包含一系列Greasemonkey用户脚本的链接。用户脚本有 @updateURL 参数设置,这样当我上传一个新版本到页面时,安装脚本的人会自动更新其版本,或者询问是否他们想要升级。



这一切都很好。我在托管页面上安装了Google Analytics(分析),因此我可以看到页面有多少次点击,但我想知道的是有多少人正在获取更新。

正常分析不会因为他们都依赖点击某个链接的人,但Greasemonkey会下载更新的文件而不点击任何内容(或者据我所知,触发分析中的页面点击)。

我假设我需要一个服务器端解决方案,但我不知道它会是什么样子。也许上述所有关于GM的内容都不相关,简单的问题是:

如何跟踪从我的服务器下载文件的次数(不需要依靠点击下载链接)?

[编辑进一步信息]



@Brock Adams谢谢答案 - 它非常详细,正是我所期待的。我没有意识到单独的 meta.js 选项,但是稍微阅读一下,我发现这是个好主意,因为它意味着只有<$ c $在检查更新时,必须下载c> meta.js 文件(而不是整个 user.js 文件)。当我设置它时,自动更新是一种新的方式,并没有太多关于它们的文档。
我仍​​然找不到太多,所以我想知道你能否澄清。主 user.js 文件中的元数据保持不变,只需在 meta.js code> @updateURL 并且没有版本号,即:

  // == UserScript == 
// @namespace http://namespace.com/userscripts
// @description一些描述。
// @downloadURL https://namespace.com/userscripts/example.user.js
// @updateURL https://namespace.com/userscripts/example.meta.js
// @include https://example.com/*
// @grant none
// == / UserScript ==

,然后所有 example.meta.js 必须有

  // == UserScript == 
// @version 2.1
// == / UserScript ==

是否正确?再次感谢。

解决方案

执行此操作的唯一方法是处理您的HTTP服务器日志(由Apache,Nginx等保存)。 )。谷歌分析不能做到这一点,因为它依靠运行自己的JavaScript - 在脚本更新和直接下载时被绕过。



您可以从您的主机控制面板或通过FTP。



<$>在原始日志中,直接下载通常如下所示:

  107.178.216.165  -   -  [12 / Jun / 2014:17:22:35 -0500]GET /test/Alert.user.js HTTP / 1.1200 37 -  Mozilla / 5.0 {redacted} Firefox

请注意缺少引用( _列就在浏览器信息之前),而这些通常是该会话给定IP地址的唯一请求,而典型的页面请求 GET

不幸的是,大多数主机提供的标准日志分析程序是 Webalizer Awstats 的。这两者都不会帮助您按原样追踪下载内容。但是,您可以设置自定义AWStats配置文件并将其配置为查看 *。user.js 文件作为下载(请参阅此答案以获得可能的配方)。




重要提示:当Greasemonkey检查更新时,它会下载由 @updateURL (或 @downloadURL if @updateURL 未指定) - 仅用于比较版本号。

因此,要追踪真正的下载量,请务必 @updateURL 指令使用单独的 *。meta.js 文件。这将避免将例行检查算作下载。


I have a page with a series of links to Greasemonkey userscripts. The userscripts have @updateURL parameters set, so that when I upload a new version to the page people who have the script installed either have their version of it updated automatically or are asked if they want to upgrade.

This all works fine. I have Google analytics installed on the hosting page, so I can see how many hits the page gets, but what I would like to know is how many people are getting the updates.
The normal analytics won't work because they all rely on somebody clicking on a link, but Greasemonkey downloads the updated file without clicking on anything (or, as far as I can tell, triggering a page hit in analytics).

I'm assuming I need a server-side solution, but I have no idea what it would look like. Maybe all the above about GM is irrelevant, and the simple question is:
How can I track how many times a file is downloaded from my server (without relying on counting clicks on download links)?

[EDIT FOR FURTHER INFO]

@Brock Adams Thank you for the answer - it was very detailed and exactly what I was looking for. I wasn't aware of the separate meta.js option, but reading a little into it I see that it's a good idea anyway as it means that only the meta.js file has to be downloaded (as opposed to the entire user.js file) when checking for updates. When I set this up, auto-updates were kind of new and there wasn't much documentation around about them. I still can't find much, so I wonder if you could clarify. The metadata in the main user.js file stays the same, just with a pointer to meta.js in the @updateURL and without the version number, ie:

// ==UserScript==
// @namespace   http://namespace.com/userscripts
// @description some description. 
// @downloadURL https://namespace.com/userscripts/example.user.js
// @updateURL   https://namespace.com/userscripts/example.meta.js
// @include     https://example.com/*
// @grant       none
// ==/UserScript==

and then all example.meta.js has to have is

// ==UserScript==
// @version 2.1
// ==/UserScript==

is that correct? thanks again.

解决方案

The only way to do this is to process your HTTP server logs (kept by Apache, Nginx, etc.). Google analytics cannot do this because it relies on running its own javascript -- something that is bypassed on script updates and direct downloads.

You can access your raw HTTP logs from your host control panel or via FTP. See your host company for more information.

In a raw log, a direct download typically looks like this:

107.178.216.165 - - [12/Jun/2014:17:22:35 -0500] "GET /test/Alert.user.js HTTP/1.1" 200 37 "-" "Mozilla/5.0 {redacted} Firefox"

Note the lack of referrer (The "_" column just before the browser info), and these are often the only request from a given IP address for that session, whereas typical page requests GET several files per session.

Unfortunately, the standard log-analysis programs, provided by most hosts are Webalizer and Awstats. Neither one of these will help you track downloads as-is. But, you can set up a custom AWStats config file and configure it to view *.user.js files as downloads (See this answer for a possible recipe).


Important: When Greasemonkey checks for updates, it downloads the file specified by @updateURL (or by @downloadURL if @updateURL is not specified) -- just to compare the version numbers.

So, to track real downloads, always use a separate *.meta.js file for the @updateURL directive. This will avoid having routine checks counted as downloads.

这篇关于如何跟踪我的Greasemonkey脚本有多少次自动升级下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆