Add try catch every time we need to use a SharedObject to avoid error when not allowed

After using the current version we've seen a lot of errors relating to the flush method of SharedObject. Adding some more try.. catch avoid using SharedObject object to store permanent data. Also, this method avoid crashing Mixpanel object construction and null object error trying to use it in client code.