{"id":14988034,"url":"https://github.com/apache/flagon-useralejs","last_synced_at":"2025-12-17T02:30:17.966Z","repository":{"id":36965225,"uuid":"66700904","full_name":"apache/flagon-useralejs","owner":"apache","description":"Apache Flagon UserALE is a comprehensive, thin-client behavioral logging tool","archived":false,"fork":false,"pushed_at":"2024-10-26T04:57:26.000Z","size":6873,"stargazers_count":27,"open_issues_count":33,"forks_count":27,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-02-12T15:13:29.756Z","etag":null,"topics":["apache","behavioral-analytics","behavioral-sciences","business-analytics","flagon","javascript","js","node","node-js","npm-package","npmjs","usability","usage","user-monitoring"],"latest_commit_sha":null,"homepage":"https://flagon.apache.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-27T07:00:07.000Z","updated_at":"2025-02-06T15:52:13.000Z","dependencies_parsed_at":"2023-12-03T05:23:04.987Z","dependency_job_id":"56ef2b76-1fce-49f1-96a5-05b5dc96acfa","html_url":"https://github.com/apache/flagon-useralejs","commit_stats":{"total_commits":462,"total_committers":28,"mean_commits":16.5,"dds":0.5216450216450217,"last_synced_commit":"4eec2ffd87880bc96858f2802b054058eeebb003"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fflagon-useralejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fflagon-useralejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fflagon-useralejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fflagon-useralejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/flagon-useralejs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239690073,"owners_count":19681034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","behavioral-analytics","behavioral-sciences","business-analytics","flagon","javascript","js","node","node-js","npm-package","npmjs","usability","usage","user-monitoring"],"created_at":"2024-09-24T14:15:59.250Z","updated_at":"2025-12-17T02:30:13.891Z","avatar_url":"https://github.com/apache.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n    Licensed to the Apache Software Foundation (ASF) under one\n    or more contributor license agreements.  See the NOTICE file\n    distributed with this work for additional information\n    regarding copyright ownership.  The ASF licenses this file\n    to you under the Apache License, Version 2.0 (the\n    \"License\"); you may not use this file except in compliance\n    with the License.  You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing,\n    software distributed under the License is distributed on an\n    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n    KIND, either express or implied.  See the License for the\n    specific language governing permissions and limitations\n    under the License.\n--\u003e\n\n# Apache Flagon UserALE\n\n# 🚨 This repository has been archived and it's contents have moved to https://github.com/apache/flagon\n\n![Node.js CI](https://github.com/apache/flagon-useralejs/workflows/Node.js%20CI/badge.svg)\n[![Known Vulnerabilities](https://snyk.io/test/npm/flagon-userale/badge.svg)](https://snyk.io/test/npm/flagon-userale)\n![Maintenance](https://img.shields.io/maintenance/yes/2024)\n![npm](https://img.shields.io/npm/v/flagon-userale)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n![Node.js](https://img.shields.io/badge/Node.js%20Support-16.x%2C%2018.x-orange)\n\nApache UserALE is part of the [Apache Flagon Project](http://flagon.incubator.apache.org/). It is a client side instrumentation library written in JavaScript designed for easy deployment and lightweight configuration in gathering logs from your web applications for user behavioral analytics.\n\nOnce included in your project, Apache UserALE provides a comprehensive behavioral logging capability, capturing every event on every element rendered in your DOM.\n\nAdditional documentation and a demonstration can be found at the [Apache Flagon website](http://flagon.incubator.apache.org/userale/).\n\n### Quickstart Guide\n\n1. Include UserALE in your project as either a [module or script tag](https://github.com/apache/flagon-useralejs#installation)\n1. Set up a logging end-point. Try our [example server utility](https://github.com/apache/flagon-useralejs/tree/master/example#capturing-logs-using-the-logging-server) or try out our [Elasticsearch (ELK) stack example](https://github.com/apache/flagon/tree/master/docker).\n1. Configure [UserALE settings](https://github.com/apache/flagon-useralejs#configure) using our API, including where to POST logs to (port:8000 for UserALE example or port:8100 of ELK/Logstash)\n1. Further explore the [UserALE API](https://github.com/apache/flagon-useralejs#usage) to customize your log feed, add filters, custom logs, and modify logs themselves. Explore a few [examples](https://github.com/apache/flagon-useralejs#examples) here and a wider set in our [example utility](https://github.com/apache/flagon-useralejs/blob/master/example/webpackUserAleExample/index.js).\n1. Visualize and analyze your logs. See our sample [kibana dahsboards](https://github.com/apache/flagon/tree/master/docker#single-node-example-container) for behavioral analytics.\n\n## Table of Contents\n[What's New](https://github.com/apache/flagon-useralejs#whats-new-in-version-210)\n[Installation](https://github.com/apache/flagon-useralejs#installation)\n[Configure](https://github.com/apache/flagon-useralejs#configure)\n[Usage](https://github.com/apache/flagon-useralejs#usage)\n[Examples](https://github.com/apache/flagon-useralejs#examples)\n[Indexing, Storing, and Visualizing Logs](https://github.com/apache/flagon-useralejs#indexing-storing-and-visualizing-logs)\n[Modifying Source](https://github.com/apache/flagon-useralejs#modifying-source)\n[Contributing](https://github.com/apache/flagon-useralejs#contributing)\n[License](https://github.com/apache/flagon-useralejs#license)\n\n## What's New in Version 2.4.0?\n\n- Refactors Map and Filter APIs as generalized callbacks for functionality\n- Adds additional UserALE API examples utilizing generalized callbacks\n- Minor updates to update deprecated downstream dev dependencies\n- Minor changes to documentation, updated examples\n\nSee our [CHANGELOG](https://github.com/apache/flagon-useralejs/blob/master/CHANGELOG.md) for a complete list of changes.\n\n## Installation\n\nEither through cloning our [source repo](https://github.com/apache/flagon-useralejs) or by using npm:\n\n```html\nnpm install flagon-userale\n\nor\n\nnpm install flagon-userale --engine-strict (enforces supported Node.js versions)\n\n```\n\nTo include UserALE as an object in your project, include as a `module`:\n\n```html\nimport * as userale from 'flagon-userale';\n\nor\n\nconst userale = require('flagon-userale');\n```\nOur [webpack example](https://github.com/apache/flagon-useralejs/tree/master/example/webpackUserAleExample) illustrates this use-case.\n\nYou can also include UserALE as a `script-tag`. A pre-built version of the userale script is included in our package and\nrepositories:\n\n```html\n\u003cscript src=\"./node_modules/flagon-userale/build/userale-2.4.0.min.js\"\u003e\u003c/script\u003e\n```\nOur [script tag example](https://github.com/apache/flagon-useralejs/tree/master/example) illustrates this use-case\n\nIf you include UserALE as a `script-tag`, consider installing via npm as a development dependency:\n\n```html\nnpm install --save-dev flagon-userale\n```\n\nOr if you want to use a CDN, then you can use something like\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/flagon-userale@2.1.1/build/userale-2.4.0.min.js\"\u003e\u003c/script\u003e\n```\n\nWe also support a [WebExtension](https://github.com/apache/flagon-useralejs/tree/master/src/UserALEWebExtension) that can be added to your browser in developer mode. Follow the link for instructions.\n\nOnce UserALE is installed in your project, your application will start generating logs automatically.\n\n## Configure\n\nSome configuration is necessary. At minimum you will need to provide UserALE an end-point to ship logs to; default behavior is to ship logs to `localhost:8000`.\n\n**NOTE**: In order to facilitate testing configuration and usage of UserALE, we have included an [example logging server](https://github.com/apache/flagon-useralejs/tree/master/example#capturing-logs-using-the-logging-server) in our\n[example directory](https://github.com/apache/flagon-useralejs/tree/master/example). This is a very helpful utility\nthat works with both included [module examples](https://github.com/apache/flagon-useralejs/tree/master/example/webpackUserAleExample)\nand [script-tag examples](https://github.com/apache/flagon-useralejs/tree/master/example). We strongly recommend experimenting with it.\n\nConfiguration details follow:\n\nIf you have included UserALE in your project as a `module`, you will need to use our `userale.options()` function, which exposes library configuration options through our API.\n\nFor example, if you do *not* want UserALE to start logging automatically, you can modify this behavior through the `userale.options()` API (`autostart` config).\n\nThen, you can use the `userale.start()` API export to begin logging at the appropriate time during page load or triggered from an event:\n\n```html\nconst changeMe = \"me\";\nuserale.options({\n    \"userId\": changeMe,\n    \"autostart\": false,\n    \"url\": \"http://localhost:8000/\",\n    \"version\": \"next\",\n    \"logDetails\": false,\n    \"sessionId\": \"this one\"\n});\n\nuserale.start();\n\n```\n\nAdditional examples of `userale.options()` can be found in our [example directory](https://github.com/apache/flagon-useralejs/tree/master/example).\n\nThe complete list of configurable parameters that can be configured via `userale.options()` is:\n\n| Param | Description | Default |\n|---|---|---|\n| url | Logging URL | http://localhost:8000 |\n| autostart | Should UserALE start on page load | true |\n| transmitInterval | Delay between transmit checks | 5000 (ms) |\n| logCountThreshold | Minimum number of logs to send | 5 |\n| userId | User identifier | null |\n| sessionId | Session identifier | null |\n| version | Application version identifier | null |\n| logDetails | Toggle detailed logs (keys pressed and input/change values) | false |\n| resolution | Delay between instances of high frequency logs (mouseover, scroll, etc.) | 500 (ms) |\n| userFromParams | Query param in the page URL to fetch userId from | null |\n| toolName | Name of tool being logged | null |\n| authHeader | Authorization header to be passed to logging endpoint | null |\n\nIf you have included UserALE as a `script-tag` in your project, you can use HTML data parameters to pass configuration options to the library through the script tag. For example:\n\n```html\n  \u003cscript\n          src=\"./node_modules/flagon-userale/build/userale-2.4.0.min.js\"\n          data-url=\"http://localhost:8000/\"\n          data-user=\"example-user\"\n          data-version=\"2.4.0\"\n          data-tool=\"Apache UserALE Example\"\n  \u003e\u003c/script\u003e\n```\n\nYou have access to the same parameters listed above, however, naming conventions vary slightly for use in HTML:\n\n| Param | Description | Default |\n|---|---|---|\n| data-url | Logging URL | http://localhost:8000 |\n| data-autostart | Should UserALE start on page load | true |\n| data-interval | Delay between transmit checks | 5000 (ms) |\n| data-threshold | Minimum number of logs to send | 5 |\n| data-user | User identifier | null |\n| data-version | Application version identifier | null |\n| data-log-details | Toggle detailed logs (keys pressed and input/change values) | false |\n| data-resolution | Delay between instances of high frequency logs (mouseover, scroll, etc.) | 500 (ms) |\n| data-user-from-params | Query param in the page URL to fetch userId from | null |\n| data-tool | Name of tool being logged | null |\n| data-auth | Authorization header to be passed to logging endpoint | null |\n\nIf you are using our [WebExtension](https://github.com/apache/flagon-useralejs/tree/master/src/UserALEWebExtension),\nyou can modify some of these parameters via the extensions' `options` page.\n\n## Usage\n\nIncluding UserALE in your project as a `module` attaches the UserALE script as an object to the page.\n\nWe have exposed a number of functions that assist you in modifying, filtering, and customizing logs\n\nA complete list of available functions are as follows:\n\n| Function | Description | Notes |\n|---|---|---|\n| userale.options | modify userale's configuration option | see top level README for complete list of options |\n| [DEPRECATED] userale.filter | filters out logs from logging queue by keys or values | filters are callbacks with global scope |\n| [DEPRECATED] userale.map | modify/add log keys or values | mappings are callbacks with global scope |\n| userale.addCallbacks | add one or more callbacks to be executed during log packaging | callbacks have global scope |\n| userale.removeCallbacks | remove one or more callbacks by name | Removes callbacks added from userale.addCallbacks |\n| userale.log | appends a custom log to the log queue | the custom log object is an object key:value pairs |\n| userale.packageLog | transforms the provided event into a log and appends it to the log queue | designed for HTML events |\n| userale.packageCustomLog | packages the provided customLog to include standard meta data and appends it to the log queue | designed for non HTML events|\n| userale.details | defines the way information is extracted from various events | supports packageLog/packageCustomLog 'details' |\n| userale.getSelector | builds a string CSS selector from the provided HTML element id | populates 'target' field in packaged logs |\n| userale.buildPath| builds an array of elements from the provided event target, to the root element (DOM path) | populates the 'path' field in packaged logs |\n| userale.start | used to start the logging process if | unecessary if 'autostart' is set to true in initial setting (default) |\n| userale.stop | halts the logging process. Logs will no longer be sent | will need to invoke userale.start to restart logging |\n\nIncluding UserALE as a `script-tag` provides you access to the same functions listed above. However, UserALE essentially\nbecomes a property of the DOM. As such, you'll need to call functions as a window property:\n\n```html\nuserale.options = window.userale.options\n```\n\n## Examples\n\nWe provide a number of examples to illustrate how the [functions above](https://github.com/apache/flagon-useralejs#usage)\ncan be used with sample webpages and logging servers. These are tailored for [module examples](https://github.com/apache/flagon-useralejs/tree/master/example/webpackUserAleExample)\nand [script-tag examples](https://github.com/apache/flagon-useralejs/tree/master/example).\nSelect examples are below:\n\nFilter your logs with `userale.filter`:\n\n```html\nuserale.filter(function (log) {\n    var type_array = ['mouseup', 'mouseover', 'mousedown', 'keydown', 'dblclick', 'blur', 'focus', 'input', 'wheel'];\n    var logType_array = ['interval'];\n    return !type_array.includes(log.type) \u0026\u0026 !logType_array.includes(log.logType);\n});\n```\n\nModify (add/remove) log fields with surgical precision using `userale.map`:\n\n```html\nuserale.map(function (log) {\n        var targetsForLabels = [\"button#test_button\"];\n        if (targetsForLabels.includes(log.target)) {\n            return Object.assign({}, log, { CustomLabel: \"Click me!\" });\n        } else {\n            return log;\n        }\n      });\n```\n\n(Additional examples illustrate [precision custom labeling](https://github.com/apache/flagon-useralejs/tree/master/example/log-label-example), using a variety of functions.)\n\nGenerate custom logs with `userale.log`:\n\n```html\ndocument.addEventListener('change', function(e) {\n    if (e.target.value === 'log') {\n        userale.log({\n            target: userale.getSelector(e.target),\n            path: userale.buildPath(e),\n            type: e.type,\n            logType: 'custom',\n            userAction: false,\n            details: 'I can make this log look like anything I want',\n            customField1: 'foo',\n            customField2: 'bar',\n            userId: userale.options().userId,\n            toolVersion: userale.options().version,\n            toolName: userale.options().toolName,\n            useraleVersion: userale.options().useraleVersion,\n            sessionId: userale.options().sessionId,\n            customLabel: \"(custom) Log Example\"\n        });\n    }\n});\n```\n\nUser our own log packaging pipeline to streamline custom HTML event logging with `userale.packageLog`:\n\n```html\ndocument.addEventListener('change', function(e){\n    if (e.target.value === 'packageLog') {\n        /**You can then use the 'Mapping' API function to modify custom logs created with the packageLog function*/\n        userale.map(function (log) {\n            var targetsForLabels = ['change'];\n            if (targetsForLabels.includes(log.type)) {\n                return Object.assign({}, log, { logType: 'custom', customLabel: 'packageLog Example' });\n            } else {\n                return log;\n            }\n        });\n        /**You can also use the details function to package additional log meta data, or add custom details*/\n        userale.packageLog(e, userale.details(userale.options(),'change'));\n    } else {\n        return false\n    }\n});\n```\n\nAgain, see [Usage](https://github.com/apache/flagon-useralejs#usage) for differences in invoking these functions with `module` and `script-tag` includes.\n\nYou can find additional examples on our [website](http://flagon.incubator.apache.org/docs/useralejs/API/).\n\n## Indexing, Storing and Visualizing Logs\n\nWe recommend Elastic products, specifically an [ELK cluster](https://www.elastic.co/what-is/elk-stack), for indexing and storing logs in productions.\n\nYou can find a 'sand-box' ELK build, configuration files, and visualization/dashboards tailored for UserALE in the [Apache Flagon parent repository](https://github.com/apache/flagon/tree/master/docker).\n\nWe also provide some documentation about stack-considerations on our [project website](http://flagon.incubator.apache.org/docs/stack/).\n\n## Modifying Source\n\nYou may wish to modify UserALE to suite your needs. After making modification to [UserALE src](https://github.com/apache/flagon-useralejs/tree/master/src),\nyou will need to rebuild the UserALE script (and run tests).\n\nTo (re)build UserALE:\n\n```\nnpm run build\n```\n\nTo run UserALE unit tests:\n```\nnpm run test\n```\n\nWe use gulp-mocha for unit tests. The results will print to your terminal:\n```\n...\n    attachHandlers\n    ✓ attaches all the event handlers without duplicates\n    ✓ debounces bufferedEvents (505ms)\n    defineDetails\n      - configures high detail events correctly\n...\n\n  45 passing (954ms)\n  1 pending\n```\nAny failing tests will also be logged in the terminal. If there are failing tests, please consider [submitting an issue report](https://github.com/apache/flagon-useralejs/issues).\n\nFor more guidance on modifying Flagon UserALE src code, check out [the guide on our website](http://flagon.incubator.apache.org/docs/useralejs/modifying/).\n\n## Contributing\n\nContributions are welcome!  Simply [submit an issue](https://github.com/apache/flagon-useralejs/issues). Pull requests are welcome.  The core team will review it and work with you to incorporate it into UserALE. If you want to become a contributor to the project, see our [contribution guide](http://flagon.incubator.apache.org/docs/contributing/).\n\nJoin the conversation: tell us your needs, wishes, and interests by joining our [mailing list](dev-subscribe@flagon.incubator.apache.org)!\n\n## License\n\nApache Flagon UserALE is provided under Apache License version 2.0. See [LICENSE](https://github.com/apache/flagon-useralejs/blob/master/LICENSE) and [NOTICE](https://github.com/apache/flagon-useralejs/blob/master/NOTICE) files at MASTER for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fflagon-useralejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fflagon-useralejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fflagon-useralejs/lists"}