refactor to json metric builder
refactor of api and cookie implementation
update to cookie logic