Upgrade analytics code