Registry / devops / appinsights-rest

appinsights-rest

JSON →
library0.2.3jsnpmunverified

A lightweight, framework-independent Application Insights REST API client for Node.js, optimized for Nuxt 4 and modern frameworks. Version 0.2.3 is current (released intermittently on GitHub). It supports full telemetry (events, requests, dependencies, exceptions, traces, metrics) with automatic batching and retry, zero core dependencies, and TypeScript types. Unlike the official @microsoft/applicationinsights-web SDK, this focuses on server-side telemetry with a simple synchronous API queued for batch delivery.

npm install appinsights-rest
INSTALL
IMPORT
SIG · APPINSIGHTS-REST
A
appinsights-rest
devopsjavascriptv0.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AppInsightsLogger
import { AppInsightsLogger } from 'appinsights-rest'
const AppInsightsLogger = require('appinsights-rest')
CommonJS require will not work as package is ESM-only.
AppInsightsConfig
import type { AppInsightsConfig } from 'appinsights-rest'
import { AppInsightsConfig } from 'appinsights-rest'
Use 'import type' for TypeScript interfaces to avoid runtime import.
RequestTelemetry
import type { RequestTelemetry } from 'appinsights-rest'
Type-only import for request tracking options.

Shows how to initialize AppInsightsLogger with connection string, track events, requests, exceptions, and clean up with dispose.

import { AppInsightsLogger } from 'appinsights-rest' const logger = new AppInsightsLogger({ connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING ?? '', role: 'my-app', appVersion: '1.0.0' }) logger.trackEvent('user_login', { userId: '123', method: 'oauth' }) const requestId = logger.trackRequest({ name: 'GET /api/users', url: 'https://example.com/api/users', duration: 150, responseCode: 200, success: true }) try { throw new Error('test error') } catch (error) { logger.trackException(error, { context: 'user_registration' }) } await logger.dispose()
Debug
Known issues
breakingESM-only package: 'require' will throw Module is not defined.
fix
Use 'import' syntax or dynamic import. For CommonJS projects, set type: module or use .mjs extension.
affects: >=0.1.0
gotchaTracking methods are synchronous and queue telemetry; they do not send immediately.
fix
Call await logger.dispose() or logger.flush() (if exposed) to ensure all queued telemetry is sent before process exit.
affects: >=0.1.0
gotchaConnection string is required; missing it will cause runtime error on first flush.
fix
Always set APPLICATIONINSIGHTS_CONNECTION_STRING environment variable or pass connectionString to constructor.
affects: >=0.1.0
deprecatedThe 'correlationId' option in trackRequest is deprecated in v0.2.0; use 'operationId' instead.
fix
Replace correlationId with operationId in RequestTelemetry options.
affects: >=0.2.0
gotchaNuxt integration requires Nuxt 4.0.0 or higher; older Nuxt versions are not supported.
fix
Upgrade to Nuxt 4 or use the framework-independent core without Nuxt module.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: appinsights_rest_1.AppInsightsLogger is not a constructor
Using CommonJS require with an ESM-only package.
fix
Change require to import: import { AppInsightsLogger } from 'appinsights-rest'
Error: Missing connection string. Set APPLICATIONINSIGHTS_CONNECTION_STRING or pass connectionString option.
No connection string provided to constructor or environment variable.
fix
Set env variable or pass connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING ?? ''
ERR_MODULE_NOT_FOUND: Cannot find module 'appinsights-rest'
Package not installed or incorrect import path.
fix
Run npm install appinsights-rest and ensure import path is correct.
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
nuxtoptionalOptional Nuxt 4 module integration
Agent activity
53 hits · last 30 days
node
48
Amazon
1
OpenAI (training)
1
Resources
appinsights-rest — npm install appinsights-rest · libregistry