
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@elastic/behavioral-analytics-browser-tracker
Advanced tools
This package provides a tracker for the browser. Instructions for integrating the browser tracker into your site can be found in the Behavioural Analytics Collection view, under the integrate tab.
This package provides a tracker for the browser. Instructions for integrating the browser tracker into your site can be found in the Behavioural Analytics Collection view, under the integrate tab.
Once you have integrated the tracker into your site, you can access the instance of tracker under the window.elasticAnalytics
object.
You must call the createTracker
method before you can use the tracker.
window.elasticAnalytics.createTracker({
endpoint: "https://my-analytics-dsn.elastic.co",
collectionName: "website",
apiKey: "<api-key>",
});
When createTracker
is called, the tracker will store two fingerprints in the browser cookie:
EA_UID
cookie. Default Time length is 24 hours from the first time the user visits the site.EA_SID
cookie. Time length is 30 minutes from the last time the user visits the site.These fingerprints are used to identify the user across sessions.
You can change the User Token and time length by passing in the token
and lifetime
parameters to the createTracker
method.
window.elasticAnalytics.createTracker({
user: {
token: () => "my-user-token",
lifetime: 24 * 60 * 60 * 1000, // 24 hours
},
session: {
lifetime: 30 * 60 * 1000, // 30 minutes
},
});
You don't always want all sessions to be sent to your Elastic cluster. You can introduce session-based sampling by adding sampling
parameter to the createTracker
method.
If sampling is set to 1 (default), all sessions will send events. If sampling is set to 0, no sessions will send events.
window.elasticAnalytics.createTracker({
// ... tracker settings
sampling: 0.3, // 30% of sessions will send events to the server
});
createTracker
Creates a tracker instance. This method must be called before you can use the tracker.
createTracker(((options: TrackerOptions) = {}));
window.elasticAnalytics.createTracker({
endpoint: "https://my-analytics-dsn.elastic.co",
collectionName: "website",
apiKey: "<api-key>",
user: {
token: () => "my-user-token",
lifetime: 24 * 60 * 60 * 1000, // 24 hours
},
session: {
lifetime: 30 * 60 * 1000, // 30 minutes
},
});
Name | Type | Description |
---|---|---|
options | TrackerOptions | The options for the tracker. |
These events are used to track the user's search behavior. You can dispatch these events by calling the trackSearch
method.
Below is an example of how you can dispatch a search event when a user searches for a query, for a hypothetical search API.
import { trackSearch } from "@elastic/behavioral-analytics-javascript-tracker";
const getSearchResults = async (query: string) => {
const results = await api.getSearchResults(query);
trackSearch({
search: {
query: query,
results: {
// optional
items: [],
total_results: results.totalResults,
},
},
});
};
A full list of properties that can be passed to the trackSearch
method below:
window.elasticAnalytics.trackSearch({
search: {
query: "laptop",
filters: [
// optional
{ field: "brand", value: ["apple"] },
],
page: {
//optional
current: 1,
size: 10,
},
results: {
// optional
items: [
{
document: {
id: "123",
index: "products",
},
page: {
url: "http://my-website.com/products/123",
},
},
],
total_results: 100,
},
sort: {
name: "relevance",
},
search_application: "website",
},
});
These events are used to track the user's search click behavior. Think of these events to track what the user is clicking on after they have performed a search. You can dispatch these events by calling the trackSearchClick
method.
Below is an example of how you can dispatch a search click event when a user clicks on a search result, for a hypothetical search API.
window.elasticAnalytics.trackSearchClick({
// document that they clicked on
document: { id: "123", index: "products" },
// the query and results that they used to find this document
search: {
query: "laptop",
filters: [
{ field: "brand", value: ["apple"] },
{ field: "price", value: ["1000-2000"] },
],
page: {
current: 1,
size: 10,
},
results: {
items: [
{
document: {
id: "123",
index: "products",
},
page: {
url: "http://my-website.com/products/123",
},
},
],
total_results: 100,
},
sort: {
name: "relevance",
},
search_application: "website",
},
});
Enum value for the type of event to track. Can be one of "search", "click", "pageview" values.
Options for the tracker.
Name | Type | Description |
---|---|---|
userToken | () => string | string | A string or a function that returns the user token. |
userTokenExpirationDate | number | The expiration date of the user token. |
FAQs
This package provides a tracker for the browser. Instructions for integrating the browser tracker into your site can be found in the Behavioural Analytics Collection view, under the integrate tab.
We found that @elastic/behavioral-analytics-browser-tracker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 53 open source maintainers 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.