TypeScript Types for window.Meticulous

TypeScript definitions for the window.Meticulous object are available in the @alwaysmeticulous/sdk-bundles-api package.

Installation

Install the package as a dev dependency:

npm install --save-dev @alwaysmeticulous/sdk-bundles-api

Usage

Import the type and extend the Window interface:

import type { MeticulousPublicApi } from '@alwaysmeticulous/sdk-bundles-api';

declare global {
  interface Window {
    Meticulous?: MeticulousPublicApi;
  }
}

Now you have full type safety when using the window.Meticulous object:

// Detect if running as a test
if (window.Meticulous?.isRunningAsTest) {
  console.log('Running as a Meticulous test');
}

// Record session context with type safety
window.Meticulous?.context.recordUserId('user-123');
window.Meticulous?.context.recordUserEmail('user@example.com');
window.Meticulous?.context.recordFeatureFlag('myFlag', true);
window.Meticulous?.context.recordCustomContext('userRole', 'admin');

Full API Reference

For the complete type definition, see public-window-api.ts in the meticulous-sdk repository.