@microsoft/1ds-core-js

Microsoft Application Insights JavaScript SDK - 1ds-core-js extensions

Usage no npm install needed!

<script type="module">
  import microsoft1dsCoreJs from 'https://cdn.skypack.dev/@microsoft/1ds-core-js';
</script>

README


ArtifactType: npm package, javascript from CDN. Documentation: https://1dsdocs.azurewebsites.net/getting-started/javascript-getting_started.html Language: typescript Platform: various Stackoverflow: N/A Tags: 1DSJSSDK ms.reviewedAt: 02/21/2019 ms.reviewedBy: ramthi

Microsoft 1DS Web SDK Core

Description

1DS Web SDK Core is the telemetry orchestrator, responsible for initializing all attached plugins and calling process() on each of them.

npm

Package available here.

Basic Usage

Setup

import { AppInsightsCore, IExtendedConfiguration } from '@microsoft/1ds-core-js';
var appInsightsCore: AppInsightsCore = new AppInsightsCore();
var coreConfig: IExtendedConfiguration = {
      instrumentationKey: "YOUR_TENANT_KEY"
};
//Initialize SDK
appInsightsCore.initialize(coreConfig, []);

Configuration

IExtendedConfiguration

Config Description Type
instrumentationKey Instrumentation key of resource. string
diagnosticLogInterval Polling interval (in ms) for internal logging queue. number
maxMessageLimit Maximum number of iKey transmitted logging telemetry per page view. number
loggingLevelConsole Console logging level. All logs with a severity level higher than the configured level will be printed to console. Otherwise they are suppressed. number
loggingLevelTelemetry Telemtry logging level to instrumentation key. All logs with a severity level higher than the configured level will sent as telemetry data to the configured instrumentation key. number
enableDebugExceptions If enabled, uncaught exceptions will be thrown to help with debugging. boolean
endpointUrl Endpoint where telemetry data is sent. string
extensionConfig Extension configs loaded in SDK. [key: string]: any;
extensions Additional plugins that should be loaded by core at runtime. Array< ITelemetryPlugin>
channels Channel queues that is setup by caller in desired order. Array< IChannelControls[]>
propertyStorageOverride The property storage override that should be used to store internal SDK properties, otherwise stored as cookies. It is needed where cookies are not available. IPropertyStorageOverride
cookieCfg Defaults to cookie usage enabled see ICookieCfgConfig settings for full defaults. ICookieCfgConfig
[Optional]
(Since 3.1.0)
disableCookiesUsage A boolean that indicated whether to disable the use of cookies by the Aria SDK. The cookies added by the SDK are MicrosoftApplicationsTelemetryDeviceId and MicrosoftApplicationsTelemetryFirstLaunchTime. If cookies are disabled, then session events are not sent unless propertyStorageOverride is provided to store the values elsewhere. boolean
cookieDomain Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
(Since v3.1.0) If cookieCfg.domain is defined it will take precedence over this value.
alias for cookieCfg.domain
[Optional]
(Since 3.1.0)
cookiePath Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application gateway.
If cookieCfg.path is defined it will take precedence over this value.
alias for cookieCfg.path
[Optional]
(Since 3.1.0)
anonCookieName Name of the Anon cookie. The value will be set in the qsp header to collector requests. Collector will use this value to look for specific cookie to use for anid property. string
enablePerfMgr [Optional] When enabled (true) this will create local perfEvents for code that has been instrumented to emit perfEvents (via the doPerf() helper). This can be used to identify performance issues within the SDK based on your usage or optionally within your own instrumented code. More details are available by the basic documentation. Since v2.4.0 boolean
Defaults to false
perfEvtsSendAll [Optional] When enablePerfMgr is enabled and the IPerfManager fires a INotificationManager.perfEvent() this flag determines whether an event is fired (and sent to all listeners) for all events (true) or only for 'parent' events (false <default>).
A parent IPerfEvent is an event where no other IPerfEvent is still running at the point of this event being created and it's parent property is not null or undefined. Since v2.4.0
boolean
Defaults to false
idLength [Optional] Identifies the default length used to generate new random session and user id's. Defaults to 22, previous default value was 5 (v2.4.2 or less), if you need to keep the previous maximum length you should set this value to 5. number
Default: 22
disableEventTimings [Optional] Disables additional internal event timings that are added during processing of events, the timings are not sent as part telemetry items to the server. boolean
Default: false
enableCompoundKey [Optional] Enables support for objects with compound keys which indirectly represent an object where the "key" of the object contains a "." as part of it's name.
Example: event: { "somedata.embeddedvalue": 123 }
boolean
Default: false
disablePageUnloadEvents [Optional] An array of the page unload events that you would like to be ignored, special note there must be at least one valid unload event hooked, if you list all or the runtime environment only supports a listed "disabled" event it will still be hooked, if required by the SDK.
Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
string[]
Default: not specified
disablePageShowEvents [Optional] An array of page show events that you would like to be ignored, special note there must be at lease one valid show event hooked, if you list all or the runtime environment only supports a listed (disabled) event it will STILL be hooked, if required by the SDK.
Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
string[]
Default: not specified

IPropertyStorageOverride

Config Description Type
setProperty A function for passing key value pairs to be stored. function
getProperty A function that gets a value for a given key. function

ICookieMgrConfig

Cookie Configuration for instance based cookie management added in version 3.1.0.

Name Description
Type
enabled A boolean that indicates whether the use of cookies by the SDK is enabled by the current instance. If false, the instance of the SDK initialized by this configuration will not store or read any data from cookies boolean
domain Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. If not provided uses the value from root cookieDomain value. string
Defaults: null
path Specifies the path to use for the cookie, if not provided it will use any value from the root cookiePath value. string
Defaults: /
getCookie Function to fetch the named cookie value, if not provided it will use the internal cookie parsing / caching. (name: string) => string
Defaults: null
setCookie Function to set the named cookie with the specified value, only called when adding or updating a cookie. (name: string, value: string) => void
Defaults: null
delCookie Function to delete the named cookie with the specified value, separated from setCookie to avoid the need to parse the value to determine whether the cookie is being added or removed.if not provided it will use the internal cookie parsing / caching. (name: string, value: string) => void
Defaults: null

Cookie Handling

From version 3.1.0, cookie management is now available directly from the instance and can be disabled and re-enabled after initialization.

If cookie usage is disabled during initialization via the disableCookiesUsage configurations, you can now re-enable via the ICookieMgr setEnabled function.

The instance based cookie management also replaces the previous CoreUtils and global functions of disableCookies(), setCookie(...), getCookie(...) and deleteCookie(...). And to benefit from the tree-shaking enhancements also introduced as part of version 3.1.0 you should no longer uses the global functions.

Simplified Usage of new instance Cookie Manager

API documentation

https://1dsdocs.azurewebsites.net/api/webSDK/utl/core/3.0/f/index.html

Sample App

React sample App.

React Native sample App.

Learn More

You can learn more in 1DS First party getting started.

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

To turn off sending telemetry to Microsoft, ensure that the POST channel is not configured in the extensions. See below configuration for example:

var coreConfig: IExtendedConfiguration = {
      instrumentationKey: "YOUR_TENANT_KEY",
      extensions: [
        postChannel  // << REMOVE THIS EXTENSION TO STOP SENDING TELEMETRY TO MICROSOFT
      ],
      extensionConfig: []
};

License

MIT