Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] disable sdk load error send #1672 #2207

Merged
merged 9 commits into from
Dec 13, 2023
Merged
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ The current version of the snippet is version 7, the version is identified by th
// name: "appInsights", // Global SDK Instance name defaults to "appInsights" when not supplied
// ld: 0, // Defines the load delay (in ms) before attempting to load the sdk. -1 = block page load and add to head. (default) = 0ms load after timeout,
// useXhr: 1, // Use XHR instead of fetch to report failures (if available),
// disableSdkLoadError: true, // Prevent the SDK from reporting load failure,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this smaller, as the snippet needs to be able to be as small as possible.

something like dle, dlf, dler etc -- as long as the documentation has a good description this should be as small as possible (but not just d for example) as most consumers wont' use this as we don't want to have losts of additional code thats rarely used.

crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
// onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called)
cfg: { // Application Insights Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// name: "appInsights", // Global SDK Instance name defaults to "appInsights" when not supplied
// ld: 0, // Defines the load delay (in ms) before attempting to load the sdk. -1 = block page load and add to head. (default) = 0ms load after timeout,
// useXhr: 1, // Use XHR instead of fetch to report failures (if available),
// disableSdkLoadError: true, // Prevent the SDK from reporting load failure,
crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
// onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called)
cfg: { // Application Insights Configuration
Expand Down
3 changes: 3 additions & 0 deletions tools/applicationinsights-web-snippet/src/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ declare var cfg:ISnippetConfig;
}

function _reportFailure(targetSrc:string) {
if(cfg.disableSdkLoadError === true) {
return;
}
let conString = _parseConnectionString();
let iKey = conString[strConStringIKey] || aiConfig[strInstrumentationKey] || strEmpty;
let ingest = conString[strIngestionendpoint];
Expand Down
1 change: 1 addition & 0 deletions tools/applicationinsights-web-snippet/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ISnippetConfig {
onInit?: any;
cfg: IConfiguration;
cr?: boolean; // cdn retry would be proceed if ture
disableSdkLoadError?: boolean; // Custom optional value to disable sdk load error to be sent
}

export interface Fields {
Expand Down
Loading