"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.createDotNetAgentInstructions = void 0; var _i18n = require("@kbn/i18n"); var _eui = require("@elastic/eui"); var _react = _interopRequireDefault(require("react")); var _agent_config_instructions = require("../agent_config_instructions"); var _instruction_variants = require("../instruction_variants"); var _api_key_callout = require("./api_key_callout"); var _agent_status_instructions = require("../agent_status_instructions"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ const createDotNetAgentInstructions = commonOptions => { const { baseUrl, apmServerUrl, apiKeyDetails, checkAgentStatus, agentStatus, agentStatusLoading } = commonOptions; const codeBlock = `public class Startup { public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseAllElasticApm(Configuration); //…rest of the method } //…rest of the class }`; return [{ title: _i18n.i18n.translate('xpack.apm.onboarding.dotNet.download.title', { defaultMessage: 'Download the APM agent' }), children: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_eui.EuiMarkdownFormat, null, _i18n.i18n.translate('xpack.apm.onboarding.dotNet.download.textPre', { defaultMessage: 'Add the the agent package(s) from [NuGet]({allNuGetPackagesLink}) to your .NET application. There are multiple \ NuGet packages available for different use cases. \n\nFor an ASP.NET Core application with Entity Framework \ Core download the [Elastic.Apm.NetCoreAll]({netCoreAllApmPackageLink}) package. This package will automatically add every \ agent component to your application. \n\n In case you would like to minimize the dependencies, you can use the \ [Elastic.Apm.AspNetCore]({aspNetCorePackageLink}) package for just \ ASP.NET Core monitoring or the [Elastic.Apm.EfCore]({efCorePackageLink}) package for just Entity Framework Core monitoring. \n\n In \ case you only want to use the public Agent API for manual instrumentation use the [Elastic.Apm]({elasticApmPackageLink}) package.', values: { allNuGetPackagesLink: 'https://www.nuget.org/packages?q=Elastic.apm', netCoreAllApmPackageLink: 'https://www.nuget.org/packages/Elastic.Apm.NetCoreAll', aspNetCorePackageLink: 'https://www.nuget.org/packages/Elastic.Apm.AspNetCore', efCorePackageLink: 'https://www.nuget.org/packages/Elastic.Apm.EntityFrameworkCore', elasticApmPackageLink: 'https://www.nuget.org/packages/Elastic.Apm' } }))) }, { title: _i18n.i18n.translate('xpack.apm.onboarding.dotNet.configureApplication.title', { defaultMessage: 'Add the agent to the application' }), children: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_eui.EuiMarkdownFormat, null, _i18n.i18n.translate('xpack.apm.onboarding.dotNet.configureApplication.textPre', { defaultMessage: 'In case of ASP.NET Core with the `Elastic.Apm.NetCoreAll` package, call the `UseAllElasticApm` \ method in the `Configure` method within the `Startup.cs` file.' })), /*#__PURE__*/_react.default.createElement(_eui.EuiSpacer, null), /*#__PURE__*/_react.default.createElement(_eui.EuiCodeBlock, { language: "bash", isCopyable: true }, codeBlock), /*#__PURE__*/_react.default.createElement(_eui.EuiSpacer, null), /*#__PURE__*/_react.default.createElement(_eui.EuiMarkdownFormat, null, _i18n.i18n.translate('xpack.apm.onboarding.dotNet.configureApplication.textPost', { defaultMessage: 'Passing an `IConfiguration` instance is optional and by doing so, the agent will read config settings through this \ `IConfiguration` instance (e.g. from the `appsettings.json` file).' }))) }, { title: _i18n.i18n.translate('xpack.apm.onboarding.dotNet.configureAgent.title', { defaultMessage: 'Sample appsettings.json file:' }), children: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ((apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.displayApiKeySuccessCallout) || (apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.displayApiKeyErrorCallout)) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_api_key_callout.ApiKeyCallout, { isError: apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.displayApiKeyErrorCallout, isSuccess: apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.displayApiKeySuccessCallout, errorMessage: apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.errorMessage }), /*#__PURE__*/_react.default.createElement(_eui.EuiSpacer, null)), /*#__PURE__*/_react.default.createElement(_agent_config_instructions.AgentConfigInstructions, { variantId: _instruction_variants.INSTRUCTION_VARIANT.DOTNET, apmServerUrl: apmServerUrl, apiKey: apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.apiKey, createApiKey: apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.createAgentKey, createApiKeyLoading: apiKeyDetails === null || apiKeyDetails === void 0 ? void 0 : apiKeyDetails.createApiKeyLoading }), /*#__PURE__*/_react.default.createElement(_eui.EuiSpacer, null), /*#__PURE__*/_react.default.createElement(_eui.EuiMarkdownFormat, null, _i18n.i18n.translate('xpack.apm.onboarding.dotNet.configureAgent.textPost', { defaultMessage: 'In case you don’t pass an `IConfiguration` instance to the agent (e.g. in case of non ASP.NET Core applications) \ you can also configure the agent through environment variables. \n \ See [the documentation]({documentationLink}) for advanced usage, including the [Profiler Auto instrumentation]({profilerLink}) quick start.', values: { documentationLink: `${baseUrl}guide/en/apm/agent/dotnet/current/configuration.html`, profilerLink: `${baseUrl}guide/en/apm/agent/dotnet/current/setup-auto-instrumentation.html#setup-auto-instrumentation` } }))) }, (0, _agent_status_instructions.agentStatusCheckInstruction)({ checkAgentStatus, agentStatus, agentStatusLoading })]; }; exports.createDotNetAgentInstructions = createDotNetAgentInstructions;