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] implement Osplugin, extracting windows 11 info and put into telemetry #2294

Merged
merged 36 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5e7fc84
move Osplugin into application-insights
siyuniu-ms Mar 7, 2024
ebe6278
store in session storage and differ between ai and 1ds
siyuniu-ms Mar 11, 2024
0f371a4
reformat
siyuniu-ms Mar 12, 2024
7814a6a
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Mar 12, 2024
ff9277c
add maxretry
siyuniu-ms Mar 12, 2024
3a5367d
Update npm-shrinkwrap.json
siyuniu-ms Mar 12, 2024
ec74bc8
package
siyuniu-ms Mar 12, 2024
b3666d8
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Mar 12, 2024
5dcac9c
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Mar 13, 2024
aecaacf
ver
siyuniu-ms Mar 13, 2024
fd4c37a
update based on comments
siyuniu-ms Mar 13, 2024
aa10a29
Update OsPlugin.ts
siyuniu-ms Mar 19, 2024
fc4c2ff
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Mar 19, 2024
3f457ea
Update npm-shrinkwrap.json
siyuniu-ms Mar 20, 2024
9426c72
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Mar 20, 2024
7c63f4b
update package
siyuniu-ms Mar 20, 2024
8d6da55
Update OsPluginTest.ts
siyuniu-ms Mar 20, 2024
8807e16
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Mar 21, 2024
a8d46be
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Mar 25, 2024
31e107b
312
siyuniu-ms Mar 25, 2024
58828cd
ver
siyuniu-ms Mar 25, 2024
d5abba8
change based on comments
siyuniu-ms Mar 27, 2024
8eb5e10
name change
siyuniu-ms Mar 27, 2024
b70100f
change call method
siyuniu-ms Mar 28, 2024
ef600f7
react app works
siyuniu-ms Mar 28, 2024
eb801e6
Update OsPlugin.ts
siyuniu-ms Mar 28, 2024
3357535
Update ThrottleMgr.tests.ts
siyuniu-ms Mar 29, 2024
4b93888
UPDATE
siyuniu-ms Apr 2, 2024
1e52aa7
REMOVE
siyuniu-ms Apr 2, 2024
7f7c12d
change typedoc
siyuniu-ms Apr 2, 2024
46f5790
update test and comment and restore removed lines
siyuniu-ms Apr 2, 2024
43889b6
Update OsPluginTest.ts
siyuniu-ms Apr 2, 2024
fceff51
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Apr 2, 2024
a9a5c0e
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Apr 2, 2024
45fc021
size change
siyuniu-ms Apr 3, 2024
cfc7b36
Merge branch 'main' into siyu/OSPlugin
siyuniu-ms Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .aiAutoMinify.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
"eStorageProviders",
"ValueQueryType"
]
},
"@microsoft/applicationinsights-osplugin-js": {
"constEnums": []
}
}
}
26 changes: 18 additions & 8 deletions AISKU/Tests/Manual/testVersionConflict.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
<!DOCTYPE html>
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self' https://dc.services.visualstudio.com; script-src 'nonce-EDNnf03nceIOfn39fn3e9h3sdfa' https://js.monitor.azure.com ; img-src https://*; child-src 'none';" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<html lang="en">
<head>
<meta charset="utf-8">
<title>AISKU Sample</title>
<link rel="stylesheet" href="style/style.css"/>
<script type="text/javascript">
var connectionString = "YOUR_CONNECTION_STRING";
</script>


<!-- <script src="./ai3.test.js"></script> -->
<!-- <script src="./ai2.test.js"></script> -->
<script src="./ai3.test.js"></script>


<!-- <script src="./ai3.test.js"></script> -->
<script type="text/javascript" nonce = "EDNnf03nceIOfn39fn3e9h3sdfa">
!(function (cfg){function e(){cfg.onInit&&cfg.onInit(i)}var S,u,D,t,n,i,C=window,x=document,w=C.location,I="script",b="ingestionendpoint",E="disableExceptionTracking",A="ai.device.";"instrumentationKey"[S="toLowerCase"](),u="crossOrigin",D="POST",t="appInsightsSDK",n=cfg.name||"appInsights",(cfg.name||C[t])&&(C[t]=n),i=C[n]||function(l){var d=!1,g=!1,f={initialize:!0,queue:[],sv:"7",version:2,config:l};function m(e,t){var n={},i="Browser";function a(e){e=""+e;return 1===e.length?"0"+e:e}return n[A+"id"]=i[S](),n[A+"type"]=i,n["ai.operation.name"]=w&&w.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(f.sv||f.version),{time:(i=new Date).getUTCFullYear()+"-"+a(1+i.getUTCMonth())+"-"+a(i.getUTCDate())+"T"+a(i.getUTCHours())+":"+a(i.getUTCMinutes())+":"+a(i.getUTCSeconds())+"."+(i.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z",iKey:e,name:"Microsoft.ApplicationInsights."+e.replace(/-/g,"")+"."+t,sampleRate:100,tags:n,data:{baseData:{ver:2}},ver:4,seq:"1",aiDataContract:undefined}}var h=-1,v=0,y=["js.monitor.azure.com","js.cdn.applicationinsights.io","js.cdn.monitor.azure.com","js0.cdn.applicationinsights.io","js0.cdn.monitor.azure.com","js2.cdn.applicationinsights.io","js2.cdn.monitor.azure.com","az416426.vo.msecnd.net"],k=l.url||cfg.src;if(k){if((n=navigator)&&(~(n=(n.userAgent||"").toLowerCase()).indexOf("msie")||~n.indexOf("trident/"))&&~k.indexOf("ai.3")&&(k=k.replace(/(\/)(ai\.3\.)([^\d]*)$/,function(e,t,n){return t+"ai.2"+n})),!1!==cfg.cr)for(var e=0;e<y.length;e++)if(0<k.indexOf(y[e])){h=e;break}var i=function(e){var a,t,n,i,o,r,s,c,p,u;f.queue=[],g||(0<=h&&v+1<y.length?(a=(h+v+1)%y.length,T(k.replace(/^(.*\/\/)([\w\.]*)(\/.*)$/,function(e,t,n,i){return t+y[a]+i})),v+=1):(d=g=!0,o=k,c=(p=function(){var e,t={},n=l.connectionString;if(n)for(var i=n.split(";"),a=0;a<i.length;a++){var o=i[a].split("=");2===o.length&&(t[o[0][S]()]=o[1])}return t[b]||(e=(n=t.endpointsuffix)?t.location:null,t[b]="https://"+(e?e+".":"")+"dc."+(n||"services.visualstudio.com")),t}()).instrumentationkey||l.instrumentationKey||"",p=(p=p[b])?p+"/v2/track":l.endpointUrl,(u=[]).push((t="SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)",n=o,r=p,(s=(i=m(c,"Exception")).data).baseType="ExceptionData",s.baseData.exceptions=[{typeName:"SDKLoadFailed",message:t.replace(/\./g,"-"),hasFullStack:!1,stack:t+"\nSnippet failed to load ["+n+"] -- Telemetry is disabled\nHelp Link: https://go.microsoft.com/fwlink/?linkid=2128109\nHost: "+(w&&w.pathname||"_unknown_")+"\nEndpoint: "+r,parsedStack:[]}],i)),u.push((s=o,t=p,(r=(n=m(c,"Message")).data).baseType="MessageData",(i=r.baseData).message='AI (Internal): 99 message:"'+("SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details) ("+s+")").replace(/\"/g,"")+'"',i.properties={endpoint:t},n)),o=u,c=p,JSON&&((r=C.fetch)&&!cfg.useXhr?r(c,{method:D,body:JSON.stringify(o),mode:"cors"}):XMLHttpRequest&&((s=new XMLHttpRequest).open(D,c),s.setRequestHeader("Content-type","application/json"),s.send(JSON.stringify(o))))))},a=function(e,t){g||setTimeout(function(){!t&&f.core||i()},500),d=!1},T=function(e){var n=x.createElement(I),e=(n.src=e,cfg[u]);return!e&&""!==e||"undefined"==n[u]||(n[u]=e),n.onload=a,n.onerror=i,n.onreadystatechange=function(e,t){"loaded"!==n.readyState&&"complete"!==n.readyState||a(0,t)},cfg.ld&&cfg.ld<0?x.getElementsByTagName("head")[0].appendChild(n):setTimeout(function(){x.getElementsByTagName(I)[0].parentNode.appendChild(n)},cfg.ld||0),n};T(k)}try{f.cookie=x.cookie}catch(p){}function t(e){for(;e.length;)!function(t){f[t]=function(){var e=arguments;d||f.queue.push(function(){f[t].apply(f,e)})}}(e.pop())}var r,s,n="track",o="TrackPage",c="TrackEvent",n=(t([n+"Event",n+"PageView",n+"Exception",n+"Trace",n+"DependencyData",n+"Metric",n+"PageViewPerformance","start"+o,"stop"+o,"start"+c,"stop"+c,"addTelemetryInitializer","setAuthenticatedUserContext","clearAuthenticatedUserContext","flush"]),f.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4},(l.extensionConfig||{}).ApplicationInsightsAnalytics||{});return!0!==l[E]&&!0!==n[E]&&(t(["_"+(r="onerror")]),s=C[r],C[r]=function(e,t,n,i,a){var o=s&&s(e,t,n,i,a);return!0!==o&&f["_"+r]({message:e,url:t,lineNumber:n,columnNumber:i,error:a,evt:C.event}),o},l.autoExceptionInstrumented=!0),f}(cfg.cfg),(C[n]=i).queue&&0===i.queue.length?(i.queue.push(e),i.trackPageView({})):e();})({
src: "https://js.monitor.azure.com/scripts/b/ai.3.gbl.min.js",
// 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),
// dle: true, // Prevent the SDK from reporting load failure log
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
connectionString: "InstrumentationKey=88888888"
}
});
</script>
</head>
<body>
<h1>Microsoft Application Insights JavaScript SDK - AISKU</h1>
Expand Down
2 changes: 1 addition & 1 deletion AISKU/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"sidebarLinks": {
"Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md",
"Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md",
"Readme": "https://github.com/Microsoft/ApplicationInsights-JS"
"Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/AISKU/README.md"
},
"navigationLinks": {
"GitHub": "https://github.com/Microsoft/ApplicationInsights-JS",
Expand Down
2 changes: 1 addition & 1 deletion AISKULight/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"sidebarLinks": {
"Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md",
"Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md",
"Readme": "https://github.com/Microsoft/ApplicationInsights-JS"
"Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/AISKULight/README.md"
},
"navigationLinks": {
"GitHub": "https://github.com/Microsoft/ApplicationInsights-JS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2533,8 +2533,10 @@ export class SenderTests extends AITestClass {
device: {
deviceClass: "Browser",
localId: "browser"
},
os: {
osVer: "Windows11"
MSNev marked this conversation as resolved.
Show resolved Hide resolved
}

},
tags: [{"ai.internal.sdkVersion": "javascript:2.5.1"}],
data: {
Expand Down Expand Up @@ -2580,6 +2582,9 @@ export class SenderTests extends AITestClass {
QUnit.assert.ok(appInsightsEnvelope.tags);
QUnit.assert.equal("d041d2e5fa834b4f9eee41ac163bf402", appInsightsEnvelope.tags["ai.session.id"]);
QUnit.assert.equal("browser", appInsightsEnvelope.tags["ai.device.id"]);
QUnit.assert.equal("browser", appInsightsEnvelope.tags["ai.device.id"]);
QUnit.assert.equal("Windows11", appInsightsEnvelope.tags["ai.device.osVersion"]);

QUnit.assert.equal("Browser", appInsightsEnvelope.tags["ai.device.type"]);
QUnit.assert.equal("javascript:2.5.1", appInsightsEnvelope.tags["ai.internal.sdkVersion"]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function _extractPartAExtensions(logger: IDiagnosticLogger, item: ITelemetryItem
let extOs = itmExt.os;
if (extOs) {
_setValueIf(envTags, CtxTagKeys.deviceOS, extOs.name);
_setValueIf(envTags, CtxTagKeys.deviceOSVersion, extOs.osVer);
}

// No support for mapping Trace.traceState to 2.0 as it is currently empty
Expand Down
2 changes: 1 addition & 1 deletion channels/applicationinsights-channel-js/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"sidebarLinks": {
"Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md",
"Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md",
"Readme": "https://github.com/Microsoft/ApplicationInsights-JS"
"Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/channels/applicationinsights-channel-js"
},
"navigationLinks": {
"GitHub": "https://github.com/Microsoft/ApplicationInsights-JS",
Expand Down
2 changes: 1 addition & 1 deletion channels/offline-channel-js/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"sidebarLinks": {
"Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md",
"Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/channels/offline-channel-js",
"Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/channels/offline-channel-js",
},
"navigationLinks": {
"GitHub": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/channels/offline-channel-js",
Expand Down
2 changes: 1 addition & 1 deletion channels/tee-channel-js/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"sidebarLinks": {
"Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md",
"Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md",
"Readme": "https://github.com/Microsoft/ApplicationInsights-JS"
"Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/channels/tee-channel-js"
},
"navigationLinks": {
"GitHub": "https://github.com/Microsoft/ApplicationInsights-JS",
Expand Down
Loading
Loading