0.0.1-security • Published 2 years ago
whjr-analytics v0.0.1-security
Whitehat Jr analytics library!
Easy to send segment events from website. The library supported both CDN and ESM types.
CDN
Add below code inside the head tag:
<script>
(function(w, d){
w.WHJR_ANALYTICS = w.WHJR_ANALYTICS || {};
// function will auto call when whjr-analytics library loaded.
w.onWhjrAnalyticsLoad = function() {
WHJR_ANALYTICS.load(`${config.SEGMENT_KEY}`);
window.WHJR_ANALYTICS.init({});
}
var e = d.createElement('script');
e.async=true;
e.src="https://sandeep-askulet.s3.amazonaws.com/whjr-analytics-latest.min.js";
d.head.appendChild(e);
})(window, document);
</script>
ESM
Install the module using npm/yarn:
npm install whjr-analytics@latest
OR
yarn add whjr-analytics@latest
After installation import the module in your file:
import { load, init } from 'whjr-analytics';
load(`${config.SEGMENT_KEY}`).then(() => {
init();
}).catch (e) {
console.error('library loading failed');
}
Supported Functions:
Function Name | Description | Arguments | Supported Version |
---|---|---|---|
load | To load segment library. | 1.0.0 | |
init | Enable to send events. | 1.0.0 | |
trackEvent | Send segment event. | 1.0.0 | |
trackError | Send error type events. | 1.0.0 | |
trackAPI | Send API type event. | 1.0.0 | |
trackPageView | Send page view event. | 1.0.0 | |
trackUser | Send user specific event. | 1.0.0 | |
getAmplitudeSessionId | Get amplitude session ID. | 1.0.0 | |
getSegmentAnonymousId | Get segment anonymous ID. | 1.0.0 | |
setEventProps | Set common properties, which will send in every event. | 1.0.0 | |
unSetEventProps | Unset common properties. | 1.0.0 | |
setUserProps | Set user specific properties, which will send in every event. | 1.0.0 | |
unSetUserProps | Unset user specific properties. | 1.0.0 |
Contributors
Whitehat Jr
License
ISC Whitehat Jr