HappyPorch / uSplit

A/B Testing plugin for Umbraco
The Unlicense
11 stars 7 forks source link

backoffice resources fix for IE11 #28

Closed markmc27 closed 5 years ago

markmc27 commented 5 years ago

When using uSplit in IE11, there are a bunch of console errors due to unsupported syntax in one of the resource files.

chrome_2019-06-04_10-52-00

The error is caused by use of ES2015 shorthand object initializer code (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer) which is unsupported in IE11.

This PR fixes the issue for the uSplitManageResource file; this was the file that highlighted the issue since the getExperiment request is called when uSplit is active on a site. There may be other cases of this in other files in the code that have so far gone unnoticed.

andresbiso commented 5 years ago

@markmc27 Thanks for the help. I was having the same issue. I added some changes to the fix since it was not working well on IE11 and Umbraco version 7.12.2 , I leave them here:

angular.module("umbraco.resources").factory("uSplitManageResource", function ($http) { var controllerPath = "backoffice/uSplit/Manage/"; return { getExperiment: function (id, profileId) { return $http.get(controllerPath + "GetExperimentAsync/" + id, { params: { profileId: profileId } } ); }, createExperiment: function (name, nodeId, profileId) { var params = { name: name, profileId: profileId }; if (nodeId) { params.nodeId = nodeId; } return $http.post(controllerPath + "CreateExperimentAsync", {}, { params: params } ); }, addVariation: function (name, experimentId, nodeId, profileId) { var data = { name: name, experimentId: experimentId }; if (nodeId) { data.nodeId = nodeId; } return $http.post(controllerPath + "AddVariationAsync", data, { params: { profileId: profileId } } ); }, deleteExperiment: function (id, profileId) { return $http.delete(controllerPath + "DeleteExperimentAsync/" + id, { params: { profileId: profileId } } ); }, deleteVariation: function (experimentId, variationName, profileId) { return $http.post(controllerPath + "DeleteVariationAsync", { experimentId: experimentId, variationName: variationName }, { params: { profileId: profileId } } ); }, setSegment: function (experimentId, providerKey, value, profileId) { return $http.post(controllerPath + "SetSegmentAsync", { experimentId: experimentId, providerKey: providerKey, value: value }, { params: { profileId: profileId } } ); }, start: function (experimentId, profileId) { return $http.post(controllerPath + "StartExperimentAsync/" + experimentId, {}, { params: { profileId: profileId } } ); }, stop: function (experimentId, profileId) { return $http.post(controllerPath + "StopExperimentAsync/" + experimentId, {}, { params: { profileId: profileId } } ); } } } );

markmc27 commented 5 years ago

Thanks @andresbiso! Updated with the full changes now 🙌

ondrejpialek commented 5 years ago

Thanks @markmc27 and @andresbiso. Will release a new version once we replace Google Analytics Experiments with Google Optimize