Post request of tracker is also sending the previous sent data in concatination with new generated

hi, i was trying javascript tracker, and defined my tracker initializer in app.component.ts file like this

loadSnowPlowScript() {
        (
            function(p, l, o, w, i, n, g) {
                if (!p[i]) {
                    p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
                    p.GlobalSnowplowNamespace.push(i);
                    p[i] = function() {
                            (p[i].q = p[i].q || []).push(arguments);
                        };
                    p[i].q = p[i].q || [];
                    n = l.createElement(o);
                    g = l.getElementsByTagName(o)[0];
                    n.async = 1;
                    n.src = w; g.parentNode.insertBefore(n, g);
                }
            }
            (window, document, 'script', 'http://d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js', 'snowplow_hello_angular')

        );
    const snowplow_hello_angular = window.snowplow_hello_angular;
    snowplow_hello_angular('newTracker', 'cf', '123.123.123.3:8080', {
        appId: 'javascript-Test',
        encodeBase64: false,
        platform: 'web',
        sessionCookieTimeout: 10,
    });
    snowplow_hello_angular('trackPageView');
    }

then i wrote a separate file for defining the different event and called this there , something like this

track_category(id, name) {
window.snowplow_hello_angular('trackUnstructEvent', {
            schema: 'iglu:in.test/myschema/jsonschema/1-0-0',
            data: {
                imgId: `${id}`,
                imgSrc: name,
                imgEvent: 'smallImg'
            }
        });  
}

Its working fine the only problem is whenever it fire a event it also send the data of previous click in concatenation with new one

ex of sent data

[
{
“evt”:{
“e”:“pv”,
“url”:“http://localhost:4200/menu”,
“page”:“test-title”,
“tv”:“js-2.10.0”,
“tna”:“cf”,
“aid”:“Test”,
“p”:“web”,
“tz”:“Asia/Kolkata”,
“lang”:“en-US”,
“cs”:“UTF-8”,
“res”:“1440x900”,
“cd”:“24”,
“cookie”:“1”,
“eid”:“7cde8745-e3e1-49b9-8964-d3a0e74fbef4”,
“dtm”:“1570436157157”,
“vp”:“1440x508”,
“ds”:“1455x15828”,
“vid”:“1”,
“sid”:“1c4cd101-c1a6-4db5-b656-8e12273d0b00”,
“duid”:“54461876-d406-4b6a-aa82-676a6ce93ef3”,
“fp”:“3350299139”,
“stm”:“1570436255275”
},
“bytes”:498
},
{
“evt”:{
“e”:“ue”,
“ue_pr”:“{"schema":"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0","data":{"schema":"iglu:in.test/myschema/jsonschema/1-0-0","data":{"imgId":"5","imgSrc":"All-in-1-Meals","imgEvent":"smallImg"}}}”,
“tv”:“js-2.10.0”,
“tna”:“cf”,
“aid”:“Test”,
“p”:“web”,
“tz”:“Asia/Kolkata”,
“lang”:“en-US”,
“cs”:“UTF-8”,
“res”:“1440x900”,
“cd”:“24”,
“cookie”:“1”,
“eid”:“4d6a553f-f86d-4ea9-92f7-2e5f88ed3995”,
“dtm”:“1570436255272”,
“vp”:“1440x508”,
“ds”:“1455x2409”,
“vid”:“1”,
“sid”:“1c4cd101-c1a6-4db5-b656-8e12273d0b00”,
“duid”:“54461876-d406-4b6a-aa82-676a6ce93ef3”,
“fp”:“3350299139”,
“refr”:“http://localhost:4200/menu”,
“url”:“http://localhost:4200/category”,
“stm”:“1570436255275”
},
“bytes”:691
},
{
“evt”:{
“e”:“ue”,
“ue_pr”:“{"schema":"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0","data":{"schema":"iglu:in.test/myschema/jsonschema/1-0-0","data":{"imgId":"9","imgSrc":"Biryani","imgEvent":"smallImg"}}}”,
“tv”:“js-2.10.0”,
“tna”:“cf”,
“aid”:“-Test”,
“p”:“web”,
“tz”:“Asia/Kolkata”,
“lang”:“en-US”,
“cs”:“UTF-8”,
“res”:“1440x900”,
“cd”:“24”,
“cookie”:“1”,
“eid”:“c1d1b4b5-2ec9-4b5b-919a-9e3bc5f68ae3”,
“dtm”:“1570436279393”,
“vp”:“1440x508”,
“ds”:“1455x2409”,
“vid”:“1”,
“sid”:“1c4cd101-c1a6-4db5-b656-8e12273d0b00”,
“duid”:“54461876-d406-4b6a-aa82-676a6ce93ef3”,
“fp”:“3350299139”,
“refr”:“http://localhost:4200/menu”,
“url”:“http://localhost:4200/category
},
“bytes”:684
},
{
“evt”:{
“e”:“pv”,
“url”:“http://localhost:4200/menu”,
“page”:“test”,
“tv”:“js-2.10.0”,
“tna”:“cf”,
“aid”:“Test”,
“p”:“web”,
“tz”:“Asia/Kolkata”,
“lang”:“en-US”,
“cs”:“UTF-8”,
“res”:“1440x900”,
“cd”:“24”,
“cookie”:“1”,
“eid”:“7854f447-3ba0-4828-ab4a-fe24b49a4aeb”,
“dtm”:“1570436317043”,
“vp”:“1440x508”,
“ds”:“1455x15828”,
“vid”:“1”,
“sid”:“1c4cd101-c1a6-4db5-b656-8e12273d0b00”,
“duid”:“54461876-d406-4b6a-aa82-676a6ce93ef3”,
“fp”:“3350299139”
},
“bytes”:498
}
]

can anyone tell how to prevent from sending the duplicate data (Already sent to collecter ) from resending ?

@tarway, I’m not sure I understand this line

const snowplow_hello_angular = window.snowplow_hello_angular;

What happens when you remove it completely?