analytics.js-integrations
                                
                                 analytics.js-integrations copied to clipboard
                                
                                    analytics.js-integrations copied to clipboard
                            
                            
                            
                        Promise.prototype.finally not defined in MS Edge due to replacement in @segment/tracktor module
Something in the @segment/tracktor module has a dependency on an old version of core-js where Promise.prototype.finally is not defined. In Microsoft Edge, the native Promise object gets replaced by the core-js version which can cause things to break if code depends on using finally
This is a related issue where the core-js author references the fact that v2 or less does not implement Promise#finally in its polyfill (see: https://github.com/zloirock/core-js/blob/v2/modules/es6.promise.js)
To reproduce, in the @segment/tracktor project, in the build/index.html file, replace the line <script type="text/javascript" src="tracktor.js"></script> with:
<script>
  console.log('running native Promise#finally')
  Promise.resolve(true).finally(() =>
    console.log('Promise#finally executed')
  )
</script>
<script type="text/javascript" src="tracktor.js"></script>
<script>
  document
    .getElementById('dynamic-btn')
    .addEventListener('click', function () {
      console.log('button clicked')
      console.log('Promise#finally no longer here')
      console.log(Promise.prototype.finally)
      Promise.resolve(true).finally(() => console.log('this will not run'))
    })
</script>
and run on Edge.

What I'm guessing is happening is:
- @babel/[email protected]depends on- [email protected]
- core-js-compattells- @babel/preset-envto include things from- core-js
- @babel/preset-envfinds an included- core-jsinstalled a.- [email protected]depends on- [email protected]b.- [email protected]depends on- [email protected]
- @babel/preset-envinjects the- [email protected]polyfills it determines are needed based on the defined targets and built ins
@babel/preset-env emits a warning about this here: https://github.com/babel/babel/blob/c5ba345ac26d90fb5da8954f00f5c7285ee5ada8/packages/babel-preset-env/src/normalize-options.js#L220
I think this can be alleviated by explicitly defining a dependency on core-js@^3.6.5
Just as an extra note, this isn't an issue with the release of the Chromium backed version of MS Edge