confusingstraw commented on a change in pull request #64:
URL:
https://github.com/apache/incubator-flagon-useralejs/pull/64#discussion_r597162520
##########
File path: example/log-label-example/README.md
##########
@@ -0,0 +1,97 @@
+# Custom Log Label Examples
+
+Examples illustrating how to add custom labels to logs generated by `userale`.
+
+## Adding Custom Labels to Logs
+
+### Method 1
+
+Consider the following HTML:
+
+```html
+
+<div>
+ <button>New Feature</button>
+</div>
+```
+
+The following code snippet will add a custom field and send a log whenever the
new feature button is clicked:
+
+```js
+document.addEventListener('click', function (e) {
+ if (e.target.innerHTML === 'New Feature') {
+ window.userale.map(log => ({...log, logType: 'custom', customLabel:
'New Feature'}));
+ window.userale.packageLog(e,
window.userale.details(window.userale.options(), e.type));
+ window.userale.map();
+ } else {
+ return false
+ }
+});
Review comment:
the key takeaway is that `userale.map` and `userale.filter` are intended
to function in a similar way to [Array.map
](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
)and
[Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter).
that is, they operate on all the logs moving through the `userale` pipeline.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]