{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-JS/issues/606","repository_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-JS","labels_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-JS/issues/606/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-JS/issues/606/comments","events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-JS/issues/606/events","html_url":"https://github.com/Microsoft/ApplicationInsights-JS/issues/606","id":325396434,"node_id":"MDU6SXNzdWUzMjUzOTY0MzQ=","number":606,"title":"ReferenceError: s is not defined","user":{"login":"ahhalder","id":18713982,"node_id":"MDQ6VXNlcjE4NzEzOTgy","avatar_url":"https://avatars1.githubusercontent.com/u/18713982?v=4","gravatar_id":"","url":"https://api.github.com/users/ahhalder","html_url":"https://github.com/ahhalder","followers_url":"https://api.github.com/users/ahhalder/followers","following_url":"https://api.github.com/users/ahhalder/following{/other_user}","gists_url":"https://api.github.com/users/ahhalder/gists{/gist_id}","starred_url":"https://api.github.com/users/ahhalder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahhalder/subscriptions","organizations_url":"https://api.github.com/users/ahhalder/orgs","repos_url":"https://api.github.com/users/ahhalder/repos","events_url":"https://api.github.com/users/ahhalder/events{/privacy}","received_events_url":"https://api.github.com/users/ahhalder/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-22T17:40:05Z","updated_at":"2018-09-27T08:36:23Z","closed_at":"2018-06-29T19:59:13Z","author_association":"NONE","body":"Hi All,\r\n\r\nI am implementing AppInsight in client side(javascript) for my web application.\r\n\r\nI added below method in main.master.cs\r\n\r\n public string AddAppInsightScript()\r\n    {\r\n        string AnalyticsScript = string.Empty;\r\n        bool enableAppInsight = false;\r\n        enableAppInsight = (ConfigurationManager.AppSettings[\"EnableAppInsight\"] ?? \"false\").ToLower() == \"true\";\r\n        var instrumentationKey = ConfigurationManager.AppSettings[\"InstrumentationKey\"];\r\n        TelemetryConfiguration.Active.DisableTelemetry = !enableAppInsight;\r\n        if (enableAppInsight && !string.IsNullOrEmpty(instrumentationKey))\r\n        {\r\n            StringBuilder sb = new StringBuilder();\r\n            sb.Append(\"<script type=\\\"text/javascript\\\">\");\r\n            sb.Append(\" var appInsights=window.appInsights||function(a){\");\r\n            sb.Append(\r\n                \"function b(a){c[a]=function(){var b=arguments;c.queue.push(function(){c[a].apply(c,b)})}}var c={config:a},d=document,e=window;setTimeout(function(){\");\r\n            sb.Append(\"var b=d.createElement(\\\"script\\\");b.src=a.url||\\\"https://az416426.vo.msecnd.net/scripts/a/ai.0.js\\\",d.getElementsByTagName(\\\"script\\\")[0].parentNode.appendChild(b)});try{c.cookie=d.cookie}catch(a){}c.queue=[];for(var \");\r\n            sb.Append(\"f=[\\\"Event\\\",\\\"Exception\\\",\\\"Metric\\\",\\\"PageView\\\",\\\"Trace\\\",\\\"Dependency\\\"];f.length;)b(\\\"track\\\"+f.pop());if(b(\\\"setAuthenticatedUserContext\\\"),b(\\\"clearAuthenticatedUserContext\\\")\");\r\n            sb.Append(\" ,b(\\\"startTrackEvent\\\"),b(\\\"stopTrackEvent\\\"),b(\\\"startTrackPage\\\"),b(\\\"stopTrackPage\\\"),b(\\\"flush\\\"),!a.disableExceptionTracking){f=\\\"onerror\\\",b(\\\"_\\\"+f);var \");\r\n            sb.Append(\"g=e[f];e[f]=function(a,b,d,e,h){var i=g&&g(a,b,d,e,h);return!0!==i&&c[\\\"_\\\"+f](a,b,d,e,h),i}}return c\");\r\n            sb.Append(\" }({\");\r\n            sb.Append(\"instrumentationKey:\\\"\");\r\n            sb.Append(instrumentationKey);\r\n            sb.Append(\"\\\" });\");\r\n            sb.Append(\"window.appInsights=appInsights,appInsights.queue&&0===appInsights.queue.length&&appInsights.trackPageView();\");\r\n            sb.Append(\"</script>\");\r\n            AnalyticsScript = sb.ToString();\r\n        }\r\n        return AnalyticsScript;\r\n    }\r\n\r\nThen calling this method in main.mater templete\r\n\r\n<head id=\"PageHeader\" runat=\"server\">\r\n    <%#AddAppInsightScript()%>\r\n</head>\r\n\r\nNow I am sending custom event from one of the myAnalytics.js file like below.\r\n\r\nlogEvent: function (origin,source,label) {\r\n            var appInsights = window.appInsights;\r\n            if (appInsights != null) {\r\n                var appName = _$AppWindowRef.Session.AppName ? _$AppWindowRef.Session.AppName : \"NA\";\r\n                var role = _$AppWindowRef.Session.role ? _$AppWindowRef.Session.role : \"NA\";\r\n                appInsights.trackEvent(origin);\r\n                appInsights.flush();\r\n            }         \r\n        },\r\n\r\nBut I get the exception as below in the method appInsight.trackEvent();\r\n\"ReferenceError: s is not defined\r\n    at eval (eval at n.trackEvent (https://az416426.vo.msecnd.net/scripts/a/ai.0.js:1:84032), <anonymous>:1:1)\r\n    at Object.n.trackEvent (https://az416426.vo.msecnd.net/scripts/a/ai.0.js:1:84032)\r\n    at Object.logEvent (http://localhost/SaaS/scripts/logging/heat.analytics.js?t=20180522120516:129:29)\r\n    at SaaS.WebUI.ObjectLayoutPanel.<anonymous> (http://localhost/SaaS/scripts/saas.webui/objectlayout/objectlayoutpanel.js?t=20180321090747:533:28)\r\n    at EXTUTIL.Event.fire (http://localhost/SaaS/lib/ext-js-31/pkgs/ext-foundation-debug.js?t=20180321090641:2339:34)\r\n    at Ext.Frs.ObjectViewToolbar.fireEvent (http://localhost/SaaS/lib/ext-js-31/pkgs/ext-foundation-debug.js?t=20180321090641:1983:31)\r\n    at Ext.Frs.ObjectViewToolbar.<anonymous> (http://localhost/SaaS/scripts/ext.frs/objectviewtoolbar.js?t=20180321090742:464:53)\r\n    at sb.onClick (http://localhost/SaaS/lib/ext-js-31/pkgs/pkg-buttons-debug.js?t=20180321090641:625:30)\r\n    at HTMLTableElement.h (http://localhost/SaaS/lib/ext-js-31/pkgs/ext-foundation-debug.js?t=20180321090641:2768:16)\"\r\n\r\nAppreciate your help in this."},"comment":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-JS/issues/comments/425006890","html_url":"https://github.com/Microsoft/ApplicationInsights-JS/issues/606#issuecomment-425006890","issue_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-JS/issues/606","id":425006890,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTAwNjg5MA==","user":{"login":"jonicabrown","id":36988370,"node_id":"MDQ6VXNlcjM2OTg4Mzcw","avatar_url":"https://avatars1.githubusercontent.com/u/36988370?v=4","gravatar_id":"","url":"https://api.github.com/users/jonicabrown","html_url":"https://github.com/jonicabrown","followers_url":"https://api.github.com/users/jonicabrown/followers","following_url":"https://api.github.com/users/jonicabrown/following{/other_user}","gists_url":"https://api.github.com/users/jonicabrown/gists{/gist_id}","starred_url":"https://api.github.com/users/jonicabrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonicabrown/subscriptions","organizations_url":"https://api.github.com/users/jonicabrown/orgs","repos_url":"https://api.github.com/users/jonicabrown/repos","events_url":"https://api.github.com/users/jonicabrown/events{/privacy}","received_events_url":"https://api.github.com/users/jonicabrown/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T08:36:23Z","updated_at":"2018-09-27T08:36:23Z","author_association":"NONE","body":"I'm getting the same error; exception being caught and logged \"internally\" (according to the code, not sure what that means?); not showing up in the console.\r\n\r\nappInsights is definitely defined with valid instrumentation key; standard telemetry showing up in Azure Portal.\r\n\r\nI pared down my request to bare minimum and still getting it:\r\nappInsights.trackEvent(\"sendXitiPage\");\r\n\r\nStack trace:\r\n-------------\r\nmessage: \"s is not defined\"\r\nstack: \"ReferenceError: s is not defined↵    at eval (eval at n.trackEvent (https://az416426.vo.msecnd.net/scripts/a/ai.0.js:1:84831), <anonymous>:1:1)↵    at Object.n.trackEvent (https://az416426.vo.msecnd.net/scripts/a/ai.0.js:1:84831)↵    at Object.module.sendXitiPage (http://vue.racecentre.fep.local/Components/CommonServices/utils/general.js:305:21)↵    at b.$scope.fetchMessage (http://vue.racecentre.fep.local/Components/Curtain/Directive/curtain.js:23:37)↵    at controller (http://vue.racecentre.fep.local/Components/Curtain/Directive/curtain.js:92:20)↵    at Object.invoke (http://vue.racecentre.fep.local/ThirdParty/angular/angular.min.js:41:376)↵    at R.instance (http://vue.racecentre.fep.local/ThirdParty/angular/angular.min.js:89:399)↵    at m (http://vue.racecentre.fep.local/ThirdParty/angular/angular.min.js:65:65)↵    at http://vue.racecentre.fep.local/ThirdParty/angular/angular.min.js:76:459↵    at http://vue.racecentre.fep.local/ThirdParty/angular/angular.min.js:130:409\"\r\n__proto__: Error\r\n\r\n![image](https://user-images.githubusercontent.com/36988370/46133366-93e8c080-c240-11e8-89e6-60b5a96d52a1.png)\r\n"}}
{"actor":{"display_login":"jonicabrown"}}