import { jsConfigParams } from "./params"; import { CodeBlock } from "../CodeBlock/CodeBlock"; import { Callout } from "../Callout/Callout"; function getExampleJsonConfig() { return JSON.stringify( jsConfigParams.map(({ name }) => [name, "..."]).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}), null, 2 ); } export const NPMManual: React.FC<{ domain: string; writeKey?: string }> = ({ domain, writeKey }) => { return (

Tracking Events with NPM package

@jitsu/js is an NPM package that allows you to track events from your JavaScript code. The package is isomorphic and can be used in both browser and Node.js environments.

Installation

npm install @jitsu/js

Usage

{[ `export async function track() {`, ` const analytics = jitsuAnalytics({`, ` host: "${domain}",`, ` ${ writeKey ? "//For browser, use browser write key" : "//For browser, write key is not required, individual tracking host is enough" }`, ` //For nodejs, use a server write key from JS settings`, ` writeKey: "",`, ` });`, ` await analytics.identify("userId", {email: "test", anyOtherProperty: "value"});`, ` await analytics.track("test page", { pageProperty: "propValue" });`, ` await analytics.page("test", { a: 1 });`, `}`, ].join("\n")}

In browser, page properties such as title, location will be detected automatically. In Node.js, you need to provide them manually. See RuntimeFacade interface. Provide you own implementation of `RuntimeFacade` for nodejs

); };