You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flagon.apache.org by GitBox <gi...@apache.org> on 2021/03/18 19:54:03 UTC

[GitHub] [incubator-flagon-useralejs] UncleGedd commented on a change in pull request #64: Custom labels docs

UncleGedd commented on a change in pull request #64:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/64#discussion_r597198545



##########
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:
       Agreed Rob, I also prefer the idea of just using the `userale.map` function as opposed to adding more event listeners. I think we need a bit more context on what exactly the users are trying to accomplish and what they want to [decorate](https://github.com/apache/incubator-flagon-useralejs/issues/63).
   
   The examples that Rob linked and are located at [example/index.js](https://github.com/apache/incubator-flagon-useralejs/blob/master/example/index.js). Do you have any idea why in that code the extra event listeners are added?
   
    




-- 
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:
users@infra.apache.org