Skip to content

Plain JavaScript / No Framework

You can use the SDK in any project without an engine or framework. The core features like Session Properties, Custom Events, Sensors, and Exit Polls will still work. However, features that depend on an engine adapter (automatic gaze tracking, performance profiling, scene export, dynamic objects) will not be available.

Installation

npm install @cognitive3d/analytics

Initialization and Usage

import C3D from '@cognitive3d/analytics';
import settings from './settings';

const c3d = new C3D(settings);
c3d.setScene('MyRawWebXRScene');

// --- Set required properties ---
c3d.setDeviceProperty("AppEngine", "None"); // REQUIRED: must be set if not using an engine adapter
c3d.setUserProperty("c3d.app.version", "1.0"); // REQUIRED: set your app's version

// --- Start the session ---
// You can optionally pass an XRSession if you have one
await c3d.startSession();

// --- Record data during the session ---
c3d.customEvent.send('tutorial_step_completed', [0, 1, 0], { step: 3 });
c3d.sensor.recordSensor('score', 1200);

// --- End the session ---
c3d.endSession();

Supported Features

When using the SDK without a framework adapter, the following features are available:

  • Session management (startSession, endSession)
  • Custom Events
  • Sensors
  • Exit Polls
  • Session, User, Device, and Participant Properties

The following features require an engine adapter and are not available:

  • Automatic WebXR Gaze Tracking
  • Automatic Performance Sensors (Profiler)
  • Scene Export
  • Object Export
  • Dynamic Objects

intercom If you have a question or any feedback about our documentation please use the Intercom button (purple circle) in the lower right corner of any web page or join our Discord.