Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@sitecore-cloudsdk/events
Advanced tools
This package provides browser- and server-side functions to capture events in your app and send them to Sitecore. Events are for collecting behavioral data about your users as they interact with your app.
This package provides browser- and server-side functions to capture events in your app and send them to Sitecore. Events are for collecting behavioral data about your users as they interact with your app.
To use the Sitecore Cloud SDK, you need an XM Cloud project. This project has to be created from the XM Cloud foundation template and deployed on XM Cloud.
The foundation template contains an XM Cloud JSS Next.js app. You use the Sitecore Cloud SDK in this app. To be able to use the Sitecore Cloud SDK, you need JSS version 21.6.0 or newer.
npm install @sitecore-cloudsdk/events
init()
function.pageView()
- send a VIEW event.identity()
- send an IDENTITY event.form()
- send a FORM event (browser-side only).event()
- send a custom event.NOTE
These code examples illustrate how the Sitecore Cloud SDK works in a standalone Next.js app. In production, you implement Sitecore Cloud SDK functionality differently, in a JSS Next.js app. See code examples for that environment in the official documentation.
Capture and send a VIEW event from the browser side:
'use client';
import { useEffect } from 'react';
import { init, pageView } from '@sitecore-cloudsdk/events/browser';
export default function Home() {
useEffect(() => {
initEvents();
}, []);
const initEvents = async () => {
await init({
sitecoreEdgeContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID || '',
siteName: process.env.NEXT_PUBLIC_SITENAME || '',
enableBrowserCookie: true,
});
console.log(`Initialized "@sitecore-cloudsdk/events/browser".`);
};
const sendPageViewEvent = async () => {
await pageView();
console.log('Sent VIEW event.');
};
return (
<div>
<button onClick={sendPageViewEvent}>send VIEW event</button>
</div>
);
}
Capture and send a VIEW event from the server side:
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { init, pageView } from '@sitecore-cloudsdk/events/server';
export async function middleware(req: NextRequest) {
const res = NextResponse.next();
await init(req, res, {
sitecoreEdgeContextId: process.env.NEXT_PUBLIC_SITECORE_EDGE_CONTEXT_ID || '',
siteName: process.env.NEXT_PUBLIC_SITENAME || '',
enableServerCookie: true,
});
console.log(`Initialized "@sitecore-cloudsdk/events/server".`);
const pageViewRes = await pageView(req);
console.log('Sent VIEW event.');
return res;
}
FAQs
This package provides browser- and server-side functions to capture events in your app and send them to Sitecore. Events are for collecting behavioral data about your users as they interact with your app.
We found that @sitecore-cloudsdk/events demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.