This module is created by Ingrow to send events automatically to Ingrow event streaming platform.
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/fingerpich/ingrow-web-event-grabber@latest/dist/bundle.min.js"></script>
<script>
const ingrowConfig = { apiKey: "API_KEY", projectID: "PROJECT_ID", userID: "" }
IngrowEventGrabber.startEventGrabber(ingrowConfig)
</script>
npm install https://github.com/fingerpich/ingrow-web-event-grabber
import { startEventGrabber } from "ingrow-event-grabber"
const ingrowConfig = { apiKey: "API_KEY", projectID: "PROJECT_ID", userID: "" }
startEventGrabber(ingrowConfig)
const sampleRates = {
mouse = 1,
page = 1,
error = 1,
domChange = 1,
}
startEventGrabber(ingrowConfig, sampleRates)
When you install ingrow-js-event-grabber
the ingrow-js-sdk
is imported in so you can use it as the following code
import { startEventGrabber, Ingrow } from "ingrow-js-event-grabber"
const ingrow = new Ingrow(apiKey: "API_KEY", projectID: "PROJECT_ID", user: "" )
startEventGrabber(ingrow)
// and on special events
ingrow.sendEvent("STREAM_NAME", {
description: "paginate",
event_type: "Click",
element_type: "Button",
time: new Date(),
})
You can use middlewares to have more control over data before they get sent as following
const middlewares = [
(item, next, eventConfig) => {
// prevent all domchange events to be sent
if (eventConfig.type === 'domChange') {
return
}
// smaples event data
if (Math.random() > .5) {
next()
}
},
(item, next) => {
// updates event data
item.date = Date.now()
next(item) // passes the updated data to the next middlewares
},
(item, next) => {
// logs the event data before it gets sent
console.log(item)
next()
},
]
startEventGrabber(ingrow, null, middlewares)
import { setUser, setIp } from "ingrow-js-event-grabber"
setUser("userID") // to trace events related to specific user by adding userID when user logged in
setIp("userIP") // we set it automatically but if you want you can change it