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

[BUG] Snippet initialization with IE8 fails with minified code (works with un-minified code) #1852

Closed
MSNev opened this issue Jun 9, 2022 · 2 comments
Labels
es3 ES3 Issues (IE8) investigating Investigating the issue p2 production released - NPM snippet Snippet update required or suggested
Milestone

Comments

@MSNev
Copy link
Collaborator

MSNev commented Jun 9, 2022

There is an issue with the snippet version check ApplicationInsightsContainer when using === and !== matching the version with "2.0".

This check works with unminified version of SDK works without any issues in IE8/9 mode, but causes the SDK to fail to initialize properly when the minified version is used.

This is because of a difference in the way the minified code performs the 2 numeric comparisons for the snippet version for (version !== 2.0 and version === 2.0) which causes this to fail for IE8/9 and all other browsers.

This is because the snippet initializes the version as 2 (not 2.0 -- subtle issue) and IE8/9 treat this differently (integer vs float) for the way these are checked in the minified code, which results in this check failing only for the minified code -- it works for the un-minified code.

The correct fix for this (because we can't update all of the deployed snippet versions) is to change these 2 comparisons to use != and == instead of !== and ===.

As a workaround for anyone hitting this issue and assuming you CAN update the snippet used is to set the snippet version to 2.0 instead of 2.
So changing this minified code ,sv:"5",version:2,config:d to ,sv:"5",version:2.0,config:d

@MSNev MSNev added p2 production es3 ES3 Issues (IE8) snippet Snippet update required or suggested labels Jun 9, 2022
@MSNev MSNev added this to the 2.8.5 milestone Jun 9, 2022
@MSNev
Copy link
Collaborator Author

MSNev commented Jun 13, 2022

This is quite a bit more complicated than originally determined.
For the current version on the CDN, the only really work-around it to use the 2.5 version from the CDN as it's not the version number from the snippet as originally diagnosed.

The underlying root cause is a combination of items, simplistically, it is not a bug in any 1 component but the way all 3 are interacting.

This issue only affects the pre-minified bundle which is included in the NPM packages and deployed to the CDN, the main un-minified code works with IE8 and depending on the minifier you use and the level of minification performed will determine whether the issue reproduces.

What is the issue?

  • As part of minification for Application Insights we use @microsoft/dynamicProto to remove the un-minifier Class.prototype.xxxx in the generated code.
  • This works fine for un-minified code
  • For minification we use Uglify-JS v3 and as part of the "minification" process when a "class" doesn't have any static or class level functions (which is what happens when we use "dynamicProto") the "class" effectively becomes an object that is "linked" to the class function during creation.
  • All of the above works perfectly on all browsers (minified or un-minified) "except" for IE8, where the minification step of creating an object class does not "keep" the link with the "constructor" (class) function, so when dynamicProto successfully creates the prototype functions the object is not linked with the prototype, so the class functions don't exist..

If however, the class has a non-dynamic prototype or static function the minification process doesn't cause this issue....

Investigating possible solutions.

@MSNev MSNev added the investigating Investigating the issue label Jun 13, 2022
MSNev added a commit that referenced this issue Jun 14, 2022
MSNev added a commit that referenced this issue Jun 14, 2022
MSNev added a commit that referenced this issue Jun 14, 2022
@MSNev MSNev changed the title [BUG] Snippet initialization with IE8/9 fails with minified code (works with un-minified code) [BUG] Snippet initialization with IE8 fails with minified code (works with un-minified code) Jun 14, 2022
MSNev added a commit that referenced this issue Jun 14, 2022
MSNev added a commit that referenced this issue Jun 15, 2022
@MSNev MSNev added the fixed - waiting release PR Committed and waiting deployment label Jun 17, 2022
@MSNev MSNev closed this as completed Jul 12, 2022
MSNev added a commit that referenced this issue Jul 28, 2022
* [BUG] Snippet initialization with IE8/9 fails with minified code (works with un-minified code) #1852 (#1854)

* [BUG] CDN Packaging is not exposing the internal tools (CoreUtils / Telemetry / etc) #1857 (#1858)

* fix stopTrackEvents (#1859)

Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>

* Refactor code to provide better tree shaking and minification of generated code #1076 (#1811)

- Add Automatic Name replacing / Crunching

* Address Component Governance issues (#1860)

- Update npm to 8.13.2
- Update rush to 5.75.0

* [Release] Increase version to 2.8.5 (#1861)

- Updates React Plugin to v3.3.5 (with v2.8.5 as dependency) -- using React 17
- Updates React Native Plugin to 2.5.5 (with v2.8.5 as dependency)
- Updates Chrome Debug Extension to 0.3.5

* Update and add legal compliance notices and license terms (#1865)

* Remove React-JS and React-Native code from this repo (#1866)

* Merge master to beta @ 200e0f1
- Update shrinkwrap and npm version for rush.json

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
MSNev added a commit to MSNev/ApplicationInsights-JS that referenced this issue Oct 3, 2022
* [BUG] Snippet initialization with IE8/9 fails with minified code (works with un-minified code) microsoft#1852 (microsoft#1854)

* [BUG] CDN Packaging is not exposing the internal tools (CoreUtils / Telemetry / etc) microsoft#1857 (microsoft#1858)

* fix stopTrackEvents (microsoft#1859)

Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>

* Refactor code to provide better tree shaking and minification of generated code microsoft#1076 (microsoft#1811)

- Add Automatic Name replacing / Crunching

* Address Component Governance issues (microsoft#1860)

- Update npm to 8.13.2
- Update rush to 5.75.0

* [Release] Increase version to 2.8.5 (microsoft#1861)

- Updates React Plugin to v3.3.5 (with v2.8.5 as dependency) -- using React 17
- Updates React Native Plugin to 2.5.5 (with v2.8.5 as dependency)
- Updates Chrome Debug Extension to 0.3.5

* Update and add legal compliance notices and license terms (microsoft#1865)

* Remove React-JS and React-Native code from this repo (microsoft#1866)

* [BUG] Remote Dependency requests don't "always" have the correct ai.operation.id tag (page view race condition) microsoft#1862 (microsoft#1869)

* [BUG] Performance improvements when calling newGuid multiple times (like 10,000) microsoft#1870 (microsoft#1871)

* [Release] Increase version to 2.8.6 (microsoft#1872)

* add click plugin url config back (microsoft#1874)

* fix(AISKULight): call getSKUDefaults after it's defined, change this.config references to _self (microsoft#1876)

Closes: microsoft#1875

* Merge master to beta @ 6ba2c0d

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Co-authored-by: Lindsay Evans <linz@linz.id.au>
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
es3 ES3 Issues (IE8) investigating Investigating the issue p2 production released - NPM snippet Snippet update required or suggested
Projects
None yet
Development

No branches or pull requests

1 participant