Skip to content

Instantly share code, notes, and snippets.

@brainysmurf
Last active May 29, 2021
Embed
What would you like to do?
/**
* 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