New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

appinsights-logger

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appinsights-logger - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

3

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const appInsights = require("applicationinsights");
appInsights.setup(process.env.APPINSIGHTS_INSTRUMENTATIONKEY).start();
const clientKey = (process.env.APPINSIGHTS_INSTRUMENTATIONKEY || "fake");
appInsights.setup(clientKey).start();
exports.aiClient = appInsights.defaultClient;

@@ -6,0 +7,0 @@ exports.ai = appInsights; // in case you need to override setup()

{
"name": "appinsights-logger",
"version": "0.0.4",
"version": "0.0.5",
"description": "thin, yet opinionated wrapper for applcation insights",

@@ -5,0 +5,0 @@ "repository": "gopuff/appinsights-logger",

@@ -22,3 +22,50 @@ ## AppInsights logger

## Advanced usage
### HTTP request tracking:
```ts
import { markDependency, measureDependency } from 'appinsights-logger'
const marker = markDependency('HTTP', 'GET /products')
try {
const url = 'https://domain.com/api/products'
const locations = await requestPromise(url)
measureDependency(marker, url)
} catch(ex) {
measureDependency(marker, url, false)
// could also trackException(ex) here
}
```
### Cosmos query tracking:
> dependency tracking is useful for measuring latency of remote calls (SQL, HTTP) and also failures
```ts
import { markDependency, measureDependency } from 'appinsights-logger'
const marker = markDependency('cosmos', 'query collection')
try {
const sql = 'select top 100 from c'
const locations = await cosmosDb.items.query(sql) // pseudo-code cosmos query
measureDependency(marker, sql)
} catch(ex) {
measureDependency(marker, sql, false)
// could also trackException(ex) here
}
```
### Debug Event tracking
> customEvents are powerful because you can query the logs by the `customDimensions` object
```ts
import { trackDebugEvent } from from 'appinsights-logger'
// This 'debug' event will only log if the DEBUG_INSIGHTS="true" env var is set
trackDebugEvent({ name: 'new order', properties: { order }, measurements: { productCount: order.products.length } })
```
#### Run E2E Test

@@ -32,4 +79,5 @@

```sh
npm run build
npm test
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc