Amplitude-JavaScript icon indicating copy to clipboard operation
Amplitude-JavaScript copied to clipboard

400 error: Invalid fields [event_id]

Open nikhiltech opened this issue 5 years ago • 3 comments

We are getting 400 errors in our dev environments, each api call after amplitude init is failing and throwing 400 with response: invalid_event_field. Invalid fields [event_id]. It works fine after deleting the localstorage unsent event data. But needed to understand why it is happening and how we can put fallback for production user. I am pasting snippet of amplitude SDK here that we are using.

(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script") ;r.type="text/javascript" ;r.integrity="sha384-cukXwabQy+j/QA1+RqiXSzxhgQg5Rrn3zVszlwH3pWj/bXJxlA8Ge7NhcD6vP2Ik" ;r.crossOrigin="anonymous";r.defer=true ;r.src="https://cdn.amplitude.com/libs/amplitude-7.1.0-min.gz.js" ;r.onload=function(){if(!e.amplitude.runQueuedFunctions){ console.log("[Amplitude] Error: could not load SDK")}} ;var i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i) ;function s(e,t){e.prototype[t]=function(){ this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}} var o=function(){this._q=[];return this} ;var a=["add","append","clearAll","prepend","set","setOnce","unset"] ;for(var c=0;c<a.length;c++){s(o,a[c])}n.Identify=o;var u=function(){this._q=[] ;return this} ;var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"] ;for(var p=0;p<l.length;p++){s(u,l[p])}n.Revenue=u ;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","enableTracking","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","groupIdentify","onInit","logEventWithTimestamp","logEventWithGroups","setSessionId","resetSessionId"] ;function v(e){function t(t){e[t]=function(){ e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}} for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){ e=(!e||e.length===0?"$default_instance":e).toLowerCase() ;if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]} ;e.amplitude=n})(window,document); amplitude.getInstance().init('AMPLITUDE_API_KEY');

nikhiltech avatar Jan 18 '21 14:01 nikhiltech

Thanks for reporting @nikhiltech. Could you upload a screenshot of the unset local storage value or a failed network request example from your browser's dev tools?

jooohhn avatar Jan 20 '21 20:01 jooohhn

image image image Attached network failed request and localstorage screenshot

nikhiltech avatar Jan 21 '21 06:01 nikhiltech

@jooohhn Any update on this?

nikhiltech avatar Feb 23 '21 21:02 nikhiltech