Unable to pass Snowplow input data into API Request enrichment


#1

I have placed code snippets for Tracker and API Request Enrich Json. Can you please suggest why it is not hitting the REST API with input data?

Below is the code tracker snippet to post the data into Scala Collector

Map<String, Object> eventData = new HashMap<String, Object>();
Map<String,String> test = new HashMap<String, String>();       
test.put("email","sandeep@gmail.com");
eventData.put("data", test);        
eventData.put("schema", "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0");
        
SelfDescribingJson json = new SelfDescribingJson("iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0", eventData);

List<SelfDescribingJson> contexts = new ArrayList<SelfDescribingJson>();
contexts.add(json);

System.out.println("json: "+json);
tracker.track(Structured.builder()
                .category("Repo")
                .action("pageBrowse")
                .subject(sub)
                .customContext(contexts)
                .build());

Below is the API Request Enrich Json:

{
  "schema": "iglu:com.snowplowanalytics.snowplow.enrichments/api_request_enrichment_config/jsonschema/1-0-0",

  "data": {
    "name": "api_request_enrichment_config",
    "vendor": "com.snowplowanalytics.snowplow.enrichments",
    "enabled": true,
    "parameters": {
      "inputs": [
        
        {
          "key": "email",
          "json": {
            "field": "unstruct_event",
            "schemaCriterion": "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
            "jsonPath": "$.email"
          }
        }
      ],
      "api": {
        "http": {
          "method": "GET",
          "uri": "http://localhost:8080/enrichapi?email={{\"{{email}}\"}}",		  
          "timeout": 5000,
          "authentication": {
            "httpBasic": {
              "username": "xxx",
              "password": "yyy"
            }
          }
        }
      },
      "outputs": [ {
        "schema": "iglu:com.acme/user/jsonschema/1-0-0",
        "json": {
          "jsonPath": "$.record"
        }
      } ],
      "cache": {
        "size": 3000,
        "ttl": 60
      }
    }
  }
}

#2

@sandeep.mreddy,

There seem to be quite a few problems with both tracker and API enrichment configuration file.

Java tracker

The SelfDescribingJson is expected to use the Iglu URI for the actual JSON schema for the self-describing event, not generic com.snowplowanalytics.snowplow/unstruct_event/...

Enrichment configuration

Same goes for an input with the field unstruct_event. You are supposed to use the URI for the JSON schema describing your actual event. You might need to familiarize yourself with self-describing events.

I doubt the API URI has to be escaped. I think you could get by with "http://localhost:8080/enrichapi?email={{email}}".

Do you actually use the JSON schema on your Iglu server as com.acme/user/jsonschema/1-0-0? Do you even run your own Iglu server? I’m asking this because the public Iglu Central has no such a schema.

You might be missing the fundamental principals how Snowplow pipeline operates.