This is an automated email from the ASF dual-hosted git repository.

unclegedd pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/flagon-useralejs.git

commit ad2d9ae7ade9a03f441174d71c63cf24e47028bd
Author: Jason Young <[email protected]>
AuthorDate: Tue Apr 25 14:24:02 2023 -0700

    Added journey test and updated README
---
 README.md                  |  6 ++++--
 journey/userale.journey.js | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 8aa2729..d4d543f 100644
--- a/README.md
+++ b/README.md
@@ -184,8 +184,10 @@ A complete list of available functions are as follows:
 | Function | Description | Notes |
 |---|---|---|
 | userale.options | modify userale's configuration option | see top level 
README for complete list of options |
-| userale.filter | filters out logs from logging queue by keys or values | 
filters are callbacks with global scope |
-| userale.map | modify/add log keys or values | mappings are callbacks with 
global scope |
+| [DEPRECATED] userale.filter | filters out logs from logging queue by keys or 
values | filters are callbacks with global scope |
+| [DEPRECATED] userale.map | modify/add log keys or values | mappings are 
callbacks with global scope |
+| userale.addCallbacks | add one or more callbacks to be executed during log 
packaging | callbacks have global scope |
+| userale.removeCallbacks | remove one or more callbacks by name | Removes 
callbacks added from userale.addCallbacks |
 | userale.log | appends a custom log to the log queue | the custom log object 
is an object key:value pairs |
 | userale.packageLog | transforms the provided event into a log and appends it 
to the log queue | designed for HTML events |
 | userale.packageCustomLog | packages the provided customLog to include 
standard meta data and appends it to the log queue | designed for non HTML 
events| 
diff --git a/journey/userale.journey.js b/journey/userale.journey.js
index 4e90ffd..1a73d39 100644
--- a/journey/userale.journey.js
+++ b/journey/userale.journey.js
@@ -44,4 +44,22 @@ describe('Userale logging', () => {
             expect(actualPath).to.deep.equal(expectedPath)
         })
     });
+
+    it('executes added callbacks', () => {
+        cy.visit('http://localhost:8000')
+        cy.wait('@backend')
+        cy.contains(/click me/i).click()
+        cy.wait('@backend').then(xhr => {
+            const body = xhr.request.body
+            const buttonClickLog = body.find(
+                log => log.target === 'button#test_button'
+                && log.logType === 'custom')
+                
+            expect(buttonClickLog).to.have.property('customLabel');
+
+            const actualValue = buttonClickLog.customLabel
+            const expectedValue = 'map & packageLog Example'
+            expect(actualValue).to.equal(expectedValue)
+        })
+    });
 });

Reply via email to