Sending self describing events with the nodejs tracker

I’m trying to update a project of ours that uses the nodejs tracker to add schemas to the unstructured events. It started on 0.2.0 but the error I’m seeing comes through on both 0.2.0 and 0.3.0. At the moment I’ve using a test setup with a snowplow-mini collector on port 8080. The events are coming through but going to bad rows. The error message I’m seeing are always

{"level":"error","message":"Payload with vendor :8080 and version i not supported by this version of Scala Common Enrich"}

The line looks like base64 but it isn’t decoding well, perhaps it’s thrift? What I can see though make it look like the event is constructed correctly, well the ue_pr bit at least.

CwBkAAAACzEzLjExNC41LjIwCgDIAAABXXUFeu0LANIAAAAFVVRGLTgLANwAAAAQc3NjLTAuNi4wLXN0ZG91dAsBQAAAAAgvOjgwODAvaQsBSgAAAYxlPXVlJnVlX3ByPSU3QiUyMnNjaGVtYSUyMiUzQSUyMmlnbHUlM0Fjb20uc25vd3Bsb3dhbmFseXRpY3Muc25vd3Bsb3clMkZ1bnN0cnVjdF9ldmVudCUyRmpzb25zY2hlbWElMkYxLTAtMCUyMiUyQyUyMmRhdGElMjIlM0ElN0IlMjJzY2hlbWElMjIlM0ElMjJpZ2x1JTNBY29tLm1ldGFpbCUyRmtvcnRvdV9zdGFyX2ZlZWRiYWNrJTJGanNvbnNjaGVtYSUyRjEtMC0wJTIyJTJDJTIyZGF0YSUyMiUzQSU3QiUyMnJhdGluZyUyMiUzQTMlN0QlN0QlN0QmcD1zcnYmdHY9bm9kZS0wLjMuMCZ0bmE9cHJvZCZhaWQ9a29ydG91LWZiLWNoYXRib3QmdWlkPTkyNTQxMjkyMDkxODAwOSZsYW5nPWVuX0dCJmVpZD05Zjg0MzRjMC02YWY0LTRmZmQtODNkMC1lMDYwODdhZDFiOGUmZHRtPTE1MDA5MDY4NzY5NTIPAV4LAAAAAgAAABFDb25uZWN0aW9uOiBjbG9zZQAAABhIb3N0OiA1Mi4xNy4yMDYuMTA0OjgwODALAZAAAAANNTIuMTcuMjA2LjEwNAsBmgAAACQ1OTk3ODI5Mi1lM2FiLTQ3YTYtYmRkZi0xOWYzYTJjYjFhZTELemkAAABBaWdsdTpjb20uc25vd3Bsb3dhbmFseXRpY3Muc25vd3Bsb3cvQ29sbGVjdG9yUGF5bG9hZC90aHJpZnQvMS0wLTAA

The code to set up the tracker is

function TrackerFactory(deps, host, namespace, appId) {
  const snowplow = deps.snowplow;
  this.commonEmitter = snowplow.emitter(
    host,
    'http',
    8080,
    'GET',
    0,
    (err, response, body) => {
      if (err || response.statusCode !== 200) {
        console.error(`Snowplow request failed - err: ${err}, response: ${response}`);
      }
    }
  );
  this.tracker = snowplow.tracker;
  this.namespace = namespace;
  this.appId = appId;
}

I barely know any JavaScript but I did change the port from 80 to 8080 and I’m passing in the correct host. It’s working well enough to send the event.

This whole thing is running in a lambda function but I have managed to send a test event from a nodejs repl so any hints on how to see what the Snowplow tracker is sending would be great.

Hello @gareth,

Please make sure your host variable has form of my-collector.com, i.e. does not have http:// prefix, :8080 port or /sompath URL in it.

Thanks, I managed to revert the change I made to the collector URL before deploying my latest version. I had initially naively tried the JS tracker approach of putting the port in the collector URL.

var snowplow = require(’@snowplow/node-tracker’);
async function track (category,element) {

var gotEmitter = snowplow.gotEmitter;
var tracker = snowplow.tracker;
const e = gotEmitter(
    host, // Collector endpoint
    'http', // Optionally specify a method - http is the default
    null, // Optionally specify a port 443
    'POST', // Method - defaults to GET
    1 // Only send events once n are buffered. Defaults to 1 for GET requests and 10 for POST requests.
);

const t = tracker([e], 'SnowplowTracker', 'Gen', false);
var res = t.track(snowplow.buildSelfDescribingEvent({
    event: {
        schema: schema-url,
        data: {
                event_name: "test1",
                category: category,
                member: element,
                codebase: "xyz"
            }
    }
}));
return res;}

console output is ::

{
“statusCode”: 200,
“body”: {
“e”: “ue”,
“eid”: “7c41b623-52c9-46d9-9a4f-f1615d93b955”,
“p”: “srv”,
“tv”: “node-3.1.6”,
“tna”: “SnowplowTracker”,
“aid”: “LeadGen”,
“dtm”: “1654521339584”,
“ue_pr”: “schema-with-data”,
“stm”: “1654521339585”
}
}

but the data never seen in visulaization tool

@Pankaj_More - as this isn’t related to the original thread are you able to create a new thread instead with your question?

@mike i thought it’s similar to earlier thread , so i posted here, created new one Thanks!!