Migration from Version 1 to Version 2¶
In this update, we have reworked our API interface so that you can expect not have to update your snippet regularly. To migrate from Version 1 to Version 2, please follow the steps below.
Please be advised that support for Version 1 will be ending several months after the release of Version 2. Unsupported versions will no longer be able to track or display messages. Please update to Version 2 as soon as possible.
Implement snippet¶
Please change the snippet as below
Before
<script>
!function(e,r,t){var o={c:null,d:null,e:[],f:[],g:[],h:[],i:[],setup:function(e,r){this.c=[e,r]},setUserID:function(e){this.d=e},track:function(e,r){this.e.push([e,r])},setStringUserProfile:function(e,r){this.f.push([e,r])},setIntUserProfile:function(e,r){this.g.push([e,r])},setDoubleUserProfile:function(e,r){this.h.push([e,r])},setDateUserProfile:function(e,r){this.i.push([e,r])}};window.reproio=window.reproio||o;var i=e.createElement(r),n=e.getElementsByTagName(r)[0];i.src="https://cdn.reproio.com/web/v1/repro-sdk.min.js",i.async=!0,i.onload=function(){if(o.d&&reproio.setUserID(o.d),o.c&&reproio.setup(o.c[0],o.c[1]),o.e.length>0)for(var e=0;e<o.e.length;e++)reproio.track(o.e[e][0],o.e[e][1]);if(o.f.length>0)for(e=0;e<o.f.length;e++)reproio.setStringUserProfile(o.f[e][0],o.f[e][1]);if(o.g.length>0)for(e=0;e<o.g.length;e++)reproio.setIntUserProfile(o.g[e][0],o.g[e][1]);if(o.h.length>0)for(e=0;e<o.h.length;e++)reproio.setDoubleUserProfile(o.h[e][0],o.h[e][1]);if(o.i.length>0)for(e=0;e<o.i.length;e++)reproio.setDateUserProfile(o.i[e][0],o.i[e][1])},n.parentNode.insertBefore(i,n)}(document,"script");
reproio.setup("YOUR_REPRO_SDK_TOKEN")
</script>
After
<script>
!function(o,e,n){var r=[];if(window.reproio)console.info("Repro Web SDK was loaded more than once");else{window.reproio=function(){r.push(arguments)};var i=o.createElement(e),t=o.getElementsByTagName(e)[0];i.src="https://cdn.reproio.com/web/v2/repro-sdk.min.js",i.async=!0,i.crossOrigin="",i.onload=function(){window.reproio("setSnippetVersion","2.1"),r.forEach(function(o){window.reproio.apply(window.reproio,o)})},t.parentNode.insertBefore(i,t)}}(document,"script");
reproio("setup", "YOUR_REPRO_SDK_TOKEN");
</script>
UserID¶
Please change the snippet as below
Before
reproio.setUserID("xxxxxxxxxxxx");
After
reproio("setUserID", "xxxxxxxxxxxx");
Event Tracking¶
Please change the snippet as below
Before
// Custom event
reproio.track("Finished tutorial");
// Custom event with properties
reproio.track("user review", { rating: 3 });
After
// Custom event
reproio("track", "Finished tutorial");
// Custom event with properties
reproio("track", "user review", { rating: 3 });
User Profile¶
Please change the snippet as below
In case of String type
Before
reproio.setStringUserProfile("Job", "Developer");
After
reproio("setStringUserProfile", "Job", "Developer");
Note
For other types (eg int type), please check to User Profile