Uncaught TypeError: localStorage.set is not a function
gingerlime opened this issue · 4 comments
Tested with a local web server (python -m http.server 9000
) with this html file inside the root folder of the git repo
<html>
<head>
<script src="dist/alephbet.min.js"></script>
<script type="text/javascript">
payment = new AlephBet.Goal('payment completed');
track_url = "http://example.com";
namespace = "alephbet";
AlephBet.options.debug = true;
experiment = new AlephBet.Experiment({
name: "my a/b test",
tracking_adapter: new AlephBet.GimelAdapter(track_url, namespace),
// trigger: function() { ... }, // optional trigger
variants: {
red: {
activate: function() {
// add your code here
}
},
blue: {
activate: function() {
// add your code here
}
}
}
});
experiment.add_goals([payment]);
payment.complete()
</script>
</head>
</html>
Going to http://localhost:9000/file.html produces the error
Unfortunately it's hard to debug the minified code. If I try to use dist/alephbet.js
instead, then it fails with a different error completely (Uncaught ReferenceError: exports is not defined
)...
@joker-777 @zwacky I should have done those manual tests earlier I guess, but better late than never?
Overall I'm getting a feeling that the latest refactoring broke functionality, at least for the simple use-cases that don't use import
or require
, plus there might be some bugs also with the localStorage implementation. See also #42
Should we revert back to an earlier version and start from scratch? I hope fixing those errors would be simpler though.
Looks to me like the files in the dist folder are outdated. running npm run buid
beforehand makes the uncaught TypeError go away. Do you see the same, @gingerlime?
Thank you @zwacky.
- We should definitely commit the updated dist files. I will maybe try to add a github action to check that this is done. EDIT: see #44
- When I use master and build the dist files, then I see the error I reported here. This might be specific to the Alephbet tracking adapters by the looks of things (but probably related to how we use the storage adapter, which was refactored)
This seems to work correctly now with 0.23.1 👍