* update readme

* change to previous config
This commit is contained in:
Karlie-777 2022-07-21 15:38:01 -07:00 коммит произвёл GitHub
Родитель cc89cc7532
Коммит 3617fc3863
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 12 добавлений и 9 удалений

Просмотреть файл

@ -222,6 +222,8 @@ Note that by default `setAutoCollectConsole` is configured to *exclude* calls to
(e.g. `winston`, `bunyan`) will be collected. You can change this behavior to *include* calls (e.g. `winston`, `bunyan`) will be collected. You can change this behavior to *include* calls
to `console` methods by using `setAutoCollectConsole(true, true)`. to `console` methods by using `setAutoCollectConsole(true, true)`.
Note that by default `enableAutoWebSnippetInjection` will use the connection string for SDK initialization. If you want to use a different one, you can set it as `enableAutoWebSnippetInjection(true, "your-connection-string")`.
The TelemetryClient object contains a `config` property with many optional settings. These can be set as follows: The TelemetryClient object contains a `config` property with many optional settings. These can be set as follows:
``` ```
client.config.PROPERTYNAME = VALUE; client.config.PROPERTYNAME = VALUE;
@ -268,7 +270,8 @@ separately from clients created with `new appInsights.TelemetryClient()`.
| httpAgent | An http.Agent to use for SDK HTTP traffic (Optional, Default undefined) | | httpAgent | An http.Agent to use for SDK HTTP traffic (Optional, Default undefined) |
| httpsAgent | An https.Agent to use for SDK HTTPS traffic (Optional, Default undefined) | httpsAgent | An https.Agent to use for SDK HTTPS traffic (Optional, Default undefined)
| aadTokenCredential| Azure Credential instance to be used to authenticate the App. [AAD Identity Credential Classes](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#credential-classes) | aadTokenCredential| Azure Credential instance to be used to authenticate the App. [AAD Identity Credential Classes](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#credential-classes)
| enableAutoWebSnippetInjection(Preview)| Sets the state of automatic web snippet injection (disabled by default). If true, web snippet will be injected into valid node server http response automatically. If a connection string is provided here, e.g. `enableAutoWebSnippetInjection(true, "your-connection-string")`, auto snippet injection will use it instead of the default one (connection string used for SDK initialization) | | | enableAutoWebSnippetInjection(Preview)| Sets the state of automatic web snippet injection (Optional, disabled by default). If true, web snippet will be injected into valid node server http response automatically with the connection string used for SDK initialization
| webSnippetConnectionString(Preview)| Sets connection string used for web snippet injection (Optional, Default undefined)| |
[Config.ts]: https://github.com/microsoft/ApplicationInsights-node.js/blob/develop/Library/Config.ts [Config.ts]: https://github.com/microsoft/ApplicationInsights-node.js/blob/develop/Library/Config.ts

Просмотреть файл

@ -21,7 +21,7 @@ describe("AutoCollection/WebSnippet", () => {
describe("#init and #dispose()", () => { describe("#init and #dispose()", () => {
it("init should enable and dispose should stop injection", () => { it("init should enable and dispose should stop injection", () => {
var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").setWebSnippetInjection(true); var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").enableAutoWebSnippetInjection(true);
var enableWebSnippetsSpy = sinon.spy(WebSnippet.INSTANCE, "enable"); var enableWebSnippetsSpy = sinon.spy(WebSnippet.INSTANCE, "enable");
appInsights.start(); appInsights.start();
@ -35,7 +35,7 @@ describe("AutoCollection/WebSnippet", () => {
describe("#validate response", () => { describe("#validate response", () => {
it("injection should be triggered only in HTML responses", () => { it("injection should be triggered only in HTML responses", () => {
var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").setWebSnippetInjection(true); var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").enableAutoWebSnippetInjection(true);
let webSnippet = WebSnippet.INSTANCE; let webSnippet = WebSnippet.INSTANCE;
let _headers: any = {}; let _headers: any = {};
@ -64,7 +64,7 @@ describe("AutoCollection/WebSnippet", () => {
}); });
describe("#web snippet injection to string", () => { describe("#web snippet injection to string", () => {
var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").setWebSnippetInjection(true); var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").enableAutoWebSnippetInjection(true);
let webSnippet = WebSnippet.INSTANCE; let webSnippet = WebSnippet.INSTANCE;
webSnippet.enable(true); webSnippet.enable(true);
it("injection add correct snippet code", () => { it("injection add correct snippet code", () => {
@ -105,7 +105,7 @@ describe("AutoCollection/WebSnippet", () => {
}); });
describe("#web snippet injection to buffer", () => { describe("#web snippet injection to buffer", () => {
var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").setWebSnippetInjection(true); var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").enableAutoWebSnippetInjection(true);
let webSnippet = WebSnippet.INSTANCE let webSnippet = WebSnippet.INSTANCE
webSnippet.enable(true); webSnippet.enable(true);
it("injection add correct snippet code", () => { it("injection add correct snippet code", () => {
@ -155,7 +155,7 @@ describe("AutoCollection/WebSnippet", () => {
describe("#web snippet replace correct connection string from config", () => { describe("#web snippet replace correct connection string from config", () => {
it("injection should use correct connection string from config", () => { it("injection should use correct connection string from config", () => {
var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").setWebSnippetInjection(true,"InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3330;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/"); var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").enableAutoWebSnippetInjection(true,"InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3330;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/");
let webSnippet = WebSnippet.INSTANCE; let webSnippet = WebSnippet.INSTANCE;
webSnippet.enable(true, "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3330;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/"); webSnippet.enable(true, "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3330;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/");
assert.equal(webSnippet["_isIkeyValid"], true,"ikey should be set to valid"); assert.equal(webSnippet["_isIkeyValid"], true,"ikey should be set to valid");
@ -181,7 +181,7 @@ describe("AutoCollection/WebSnippet", () => {
describe("#web snippet enable should throw errors when ikey from config is not valid", () => { describe("#web snippet enable should throw errors when ikey from config is not valid", () => {
it("injection should throw errors when ikey from config is not valid", () => { it("injection should throw errors when ikey from config is not valid", () => {
var infoStub = sandbox.stub(console, "info"); var infoStub = sandbox.stub(console, "info");
var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").setWebSnippetInjection(true,"InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeff;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/"); var appInsights = AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333").enableAutoWebSnippetInjection(true,"InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeff;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/");
let webSnippet = WebSnippet.INSTANCE; let webSnippet = WebSnippet.INSTANCE;
webSnippet.enable(true, "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeff;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/"); webSnippet.enable(true, "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeff;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/");
assert.equal(webSnippet["_isIkeyValid"], false,"ikey should be set to invalid"); assert.equal(webSnippet["_isIkeyValid"], false,"ikey should be set to invalid");

Просмотреть файл

@ -167,7 +167,7 @@ describe("ApplicationInsights", () => {
.setAutoCollectRequests(false) .setAutoCollectRequests(false)
.setAutoCollectDependencies(false) .setAutoCollectDependencies(false)
.setAutoDependencyCorrelation(false) .setAutoDependencyCorrelation(false)
.setWebSnippetInjection(false) .enableAutoWebSnippetInjection(false)
.start(); .start();
assert.ok(!Console.INSTANCE.isInitialized()); assert.ok(!Console.INSTANCE.isInitialized());

Просмотреть файл

@ -322,7 +322,7 @@ export class Configuration {
* @param WebSnippetConnectionString if provided, web snippet injection will use this ConnectionString. Default to use the connectionString in Node.js app initialization * @param WebSnippetConnectionString if provided, web snippet injection will use this ConnectionString. Default to use the connectionString in Node.js app initialization
* @returns {Configuration} this class * @returns {Configuration} this class
*/ */
public static setWebSnippetInjection(value: boolean, WebSnippetConnectionString?: string ) { public static enableAutoWebSnippetInjection(value: boolean, WebSnippetConnectionString?: string ) {
_isSnippetInjection = value; _isSnippetInjection = value;
_webSnippetConnectionString = WebSnippetConnectionString; _webSnippetConnectionString = WebSnippetConnectionString;
if (_isStarted) { if (_isStarted) {