
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
track-user-activity-js
Advanced tools
The Activity Tracker SDK is a JavaScript library that enables developers to track user activities on a website. It provides functionalities to record custom events, user login/logout, track page visits, and visualize user interactions through a heatmap. This SDK is designed to assist developers in gaining insights into user behavior for better user experience and optimization.
npm install activity-tracker-sdk
import {ActivityTracker} from "activity-tracker-sdk"
const config = {
developer_id: 'YOUR_DEVELOPER_ID',
app_id: 'YOUR_APP_ID',
};
const activityTracker = new ActivityTracker(config);
This method tracks the user event like button click, mouse movement, hovers etc
@Param( eventName: string eventType: string eventData?: Record<string, any> pageUrl?: string )
activityTracker.trackCustomEvent('EventName', 'EventType', { eventData: 'additional data' });
This method is use to track a user currently logged in to the application, in other to associate the logged in user with the ipAddress
To login a user ensure that you call the activityTracker.login() method to track when a logged in user perform an action. and also the activityTracker.logout() to track when the user logs out
@Param( email: string userId: string )
activityTracker.login('user@example.com', 'user_id');
activityTracker.logout();
This method is use to track page clicks of a user in an application it accepts three parameter
@Param( scrollx: number, scrolly: number, pageUrl: string )
activityTracker.trackPageClick(scrollx, scrolly, pageUrl)
activityTracker.trackPageVisit(pageUrl)
The SDK requires the following configuration parameters:
developer_id: Your developer ID.
app_id: Your application ID.
Check the examples directory for usage examples and integration scenarios.
import ActivityTracker from "track-user-activity-js";
export const useActivityTracker = () => {
const tracker = new ActivityTracker({
developer_id: "Your developer ID."
app_id: "Your application ID."
});
const trackPageVisit = (page) => {
tracker.trackPageVisit(page);
};
const trackPageClick = (pageUrl) => {
const scrollX = window.scrollX || window.pageXOffset;
const scrollY = window.scrollY || window.pageYOffset;
tracker.trackPageClick(scrollY, scrollX, pageUrl);
};
const trackInboundReferral = (pageUrl) => {
tracker.trackInBoundReferral(pageUrl)
}
const trackOutBoundReferral = (pageUrl) => {
tracker.trackOutboundUrl("/localhost:5000/about")
}
const trackCustomEvent = (eventName, eventType, eventData, pageUrl) => {
tracker.trackCustomEvent(eventName, eventType, eventData, pageUrl);
};
const login = async (email, userId) => {
try {
await tracker.login(email, userId);
} catch (error) {
console.error("Error updating user address:", error);
}
};
const logout = () => {
tracker.logout()
}
return {
trackPageVisit,
trackHeatMap,
trackCustomEvent,
login,
logout
};
};
const { trackPageVisit, trackHeatMap, trackCustomEvent, login, logout } = useActivityTracker()
const router = useLocation()
const currentBaseUrl = window.location.origin;
useEffect(() => {
trackPageClick(currentBaseUrl + router.pathname)
console.log("Working")
}, [currentBaseUrl, router.pathname, trackPageVisit])
useEffect(() => {
trackHeatMap("container")
}, [trackHeatMap])
function login() {
login("email address","userId")
}
function logout(){
logout()
}
<button onClick={() => trackCustomEvent("Click Button", "click")}>Click me</button>
FAQs
## Overview
The npm package track-user-activity-js receives a total of 0 weekly downloads. As such, track-user-activity-js popularity was classified as not popular.
We found that track-user-activity-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.