Skip to content

Instantly share code, notes, and snippets.

@brainysmurf
Last active May 29, 2021 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainysmurf/9829a9f2a7553ef80245fcbf113496cd to your computer and use it in GitHub Desktop.
Save brainysmurf/9829a9f2a7553ef80245fcbf113496cd to your computer and use it in GitHub Desktop.
/**
* This is my version of what I embed into libraries I want to track, as cluster.
* This way it ensures that consistent name, version used throughout, and easy to define namespace
* Note use of "name" "space" parameters
*/
function TrackMyself ({name='dottie', space=null, version='v1.5', ...kwargs}={}) {
if (Object.keys(kwargs).length>0) throw new TypeError("Unexpected param received");
const track = cttLibTracker.TrackMyself;
const options = {
name: space != null ? `${name}_${space}`: name,
version
};
track.stamp(options)
return track;
}
/**
* Usage
*/
function report () {
const track = TrackMyself({sspace: 'init'}); // throws TypeError
const track = TrackMyself({space: 'init'});
const output = track.currentUserUsage();
Logger.log(output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment