Skip to content

Commit

Permalink
Adds logId and setter for instance identity.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrdo authored and psylwester committed Feb 9, 2021
1 parent 23c800b commit 1938398
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###### This is pre-release software, but please **[log issues](https://github.com/ptrdo/postette/issues)** found.
# Postette `v0.4.0`
# Postette `v0.4.1`
A gadget for establishing a dialogue between a web client application and the human interacting with it.

*Donnez-moi la postette!*
Expand Down Expand Up @@ -166,6 +166,7 @@ See the [Notify Options](#notify-options) or the [code documentation](postette.j
| `addModalSelector` | string | Runtime addition to querySelector elements incompatible with integrated appearance. |
| `print` | quit | Renders collection of messages (since session start) to a dropdown list in the interface. Successive calls will toggle the list, or passing `true` will remove it for certain. |
| `log` | | Prints collection of messages (since session start) to the browser's console. |
| `setLogId` | string/null | Optional instance identifier for logging (e.g. a username). |
| `clearQueue` | | Clears the queue of impending messages (history is unaffected). |
| `clearHistory` | | Clears the history of previous messages (queue is unaffected). |

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postette",
"version": "v0.4.0",
"version": "v0.4.1",
"description": "A zero-dependency gadget for the management and execution of notifications to a person interacting with a web client application.",
"homepage": "https://github.com/ptrdo/postette#readme",
"main": "",
Expand Down
17 changes: 13 additions & 4 deletions postette.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* @property {String} version // the semantic versioning of this code.
* @property {String} identity // the namespace prefixed to unique properties and attributes.
* @property {String} markupId // the element ID of the HTML to be injected.
* @property {String} logId // an optional instance identifier for logging.
* @property {Array} queue // a collection of the messages in queue for toast.
* @property {Object} currentNotification // properties of current message in process of notification.
* @property {Object} previousNotification // properties of most recent message in process of notification.
Expand All @@ -75,9 +76,10 @@
* @property {Element} clickerElement // the currently rendered BUTTON (to dismiss).
*/

var version = "0.4.0",
var version = "0.4.1",
identity = "postette",
markupId = identity + Date.now(),
logId = null,
queue = [],
currentNotification = {},
previousNotification = {},
Expand Down Expand Up @@ -286,10 +288,9 @@
var queryUser = function () {
var result = "unknown-user";
try {
/* When authentication routines are present, here would be where they are called. */
result = markupId;
result = logId || markupId;
} catch (err) {
console.warn(identity, "queryUser:", "A user was expected but not found.", err);
console.warn(identity, "queryUser:", "An instance identifier was expected but not found.", err);
}
return result;
};
Expand Down Expand Up @@ -1665,6 +1666,14 @@

getTransition: function() {
return CONFIG.transition();
},

/**
* setLogId stipulates a value for logging, such as a UserName.
* @param {String} id (optional) the value to log. Null clears and defaults to markupId (the instance identifier).
*/
setLogId: function (id) {
logId = typeof id === "undefined" || /^null$/i.test(id) ? null : id.toString();
}
};
}
Expand Down

0 comments on commit 1938398

Please sign in to comment.