umbraco-community / umbraco-analytics

Google Analytics for the Umbraco CMS
41 stars 31 forks source link

TypeError: moment.defineLocale is not a function Umbraco 7.10 #56

Open bindles1 opened 6 years ago

bindles1 commented 6 years ago

TypeError: moment.defineLocale is not a function Line 12: /umbraco/lib/moment/en-gb.js

var en_gb = moment.defineLocale('en-gb', {

This error stops any sort of calendar functionality from working. i.e. can't set future publish dates on pages.

MrCosmo commented 6 years ago

I'm having the same issue

MartijnRasenberg commented 6 years ago

See https://github.com/moment/momentjs.com/issues/171 The version of moment.js this plugin pushes is 2.4.0 (try console.log(moment.version)), support for moment.locale() is added @ 2.8.0. Umbraco now uses 2.10.x, but the plugin version is loaded after the umbraco version and thus overrides it. If you empty (clear all content) from \App_Plugins\Analytics\lib\momentjs\moment.js the version included in this package is not loaded, and the error is not shown. But...the package is not working afterwards.

Emetico commented 6 years ago

I got the same issue in Umbraco 7.10.4.

I removed '~/App_Plugins/Analytics/lib/momentjs/moment.js' , from App_Plugins/Analytics/package.manifest. And the plugin still seems to work as expected.

Still i think this issue should be fixed. Maybe load it via assetsService.loadJs() instead of putting it in the package manifest?

~/App_Plugins/Analytics/backOffice/directives/DateRangePicker.Directive.js

assetsService.loadJs('~/App_Plugins/Analytics/lib/momentjs/moment.js').then(function () {
    element.daterangepicker(..
});