Skip to content

Commit 335dfc1

Browse files
author
Curtis
committed
Check for null when loading saved global user properties
1 parent 24c3126 commit 335dfc1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

amplitude-1.0-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/amplitude.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,9 @@
542542
}
543543
var savedUnsentEventsString = localStorage.getItem(options.unsentKey);
544544
var savedGlobalUserPropertiesString = localStorage.getItem(options.gupKey);
545-
options.globalUserProperties = JSON.parse(LZW.decompress(Base64.decode(savedGlobalUserPropertiesString)));
545+
if (savedGlobalUserPropertiesString) {
546+
options.globalUserProperties = JSON.parse(LZW.decompress(Base64.decode(savedGlobalUserPropertiesString)));
547+
}
546548
unsentEvents = (savedUnsentEventsString && JSON.parse(LZW.decompress(Base64.decode(savedUnsentEventsString)))) || [];
547549
if (unsentEvents.length > 0) {
548550
this.sendEvents();
@@ -632,6 +634,7 @@
632634
var instance = new Amplitude();
633635

634636
window.amplitude = instance;
637+
window.Base64 = Base64;
635638

636639
// Apply the queued commands
637640
for (var i = 0; i < q.length; i++) {

0 commit comments

Comments
 (0)