master
Raw Download raw file
 1// ________                                                _________
 2// \________\--------___       ___         ____----------/_________/
 3//     \_______\----\\\\\\   //_ _ \\    //////-------/________/
 4//         \______\----\\|| (( ~|~ )))  ||//------/________/
 5//             \_____\---\\ ((\ = / ))) //----/_____/
 6//                  \____\--\_)))  \ _)))---/____/
 7//                        \__/  (((     (((_/
 8// ヾღ彡                   |  -)))  -  ))
 9// =================================================================
10// _usage_tracker.js
11// -----------------------------------------------------------------
12// author:  @soron, @archangel
13// SEC LVL: ?
14// Chars:   315
15// Descr:   ???
16// Syntax:  _usage_tracker
17// =================================================================
18
19
20// this script hooks into a player-provided utility to track the number of calls
21function(context, args) {
22
23    // we'll wrap the analytics in a try-catch, so that a failure during recording doesn't break the rest of the script
24    try {
25        // Basic usage. see dtr.man{page:"soron.arch_data"} for additional usage. Also, there's ada.haxfax floating around, which has a semi-compatible API.
26		#s.soron.arch_data({log:{c:context}});
27    } catch (e) {
28        // oh well, we can live with this. Congrats, user-who-is-not-tracked!
29    }
30
31
32    // I guess we should do something other than just record our usage, right? Ah, I know! Let's display our usage, and the usage of whatever script called us (if any).
33    return {
34        // the query:"foo.bar" version is also shown, formatted, on dtr.man pages.
35        my_usage: #s.soron.arch_data({query: context.this_script}),
36        calling_usage: #s.soron.arch_data({query: context.calling_script}),
37        // these next two are formatted better when called on the command line. Try them there! soron.arch_data{rankings:"cli"}, for example
38        //global_cli_usage: #s.soron.arch_data({rankings:"cli"}),
39        //global_lib_usage: #s.soron.arch_data({rankings:"lib"}),
40    }
41}