0.2.10 • Published 2 years ago

applicationinsights-cloudflareworkers v0.2.10

Weekly downloads
6
License
ISC
Repository
github
Last release
2 years ago

Application Insights Cloudflareworkers

Note: Still a work in progress. This package might still have breaking changes

Provides application insights functionality in cloudflare workers

Install

npm i --save applicationinsights-cloudflareworkers

Webpack

If you are using webpack you might need change config to load package properly.

Alternative 1 (Recommended)

Use webpack-modules plugin

npm i --save-dev webpack-modules
// Add this to your webpack config file
const WebpackModules = require('webpack-modules');
 
module.exports = {
  // ...
  plugins: [
    new WebpackModules()
  ]
}

Alternative 2

Change mainFields setting (with my cause issues with other dependencies)

module.exports = {
  //...
  resolve: {
    mainFields: ['module', 'main']
  }
};

Examples

Sample code:

import { ApplicationInsights, RequestData } from 'applicationinsights-cloudflareworkers'

const requestTest = new RequestData({
    name: 'Test',
    success: true,
    url: 'https://example.com',
    id: '15fadc35-65b2-41da-b86f-998dcb7489e3',
    properties: {
        anyName: 'anyValue',
    },
    duration: '00.00:00:10.000000',
    responseCode: '200',
})

const ai = new ApplicationInsights({
    context: {
        'ai.operation.id': 'testid',
    },
    instrumentationKey: 'a08f3f2d-9884-4437-b6ec-c835d3d58d82', // Replace with your own instrumentationKey
})

// Pass in AvailabilityData, EventData, ExceptionData, MessageData, MetricData, PageViewPerfData, RemoteDependencyData or RequestData
ai.trackData(requestTest, 'RequestData') // type (second) argument might be required if you minify your code(unminified it can be inferred)

const res = await ai.flush() // Flush is not automatic. You need to call .flush()

// After flush it takes ~5 mins before you will see in application insights

console.log(`Status: ${res.status}`) // See response for errors if code is not 200

For more examples see the test folder

In application insights you will see: Request Application Insights Request Application Insights More Info

Contributing

I am open to pull requests. Please summarize the changes you make. If you have large changes please open an issue, so we can discuss before you start working on the changes.

0.2.10

2 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago