Pubsub Enricher failed to add enriched values into the events (Javascript enrichment)

we deploy Pubsub Enricher in GCP APP Engine it will deployed successfully works fine but it will not added enriched value into event when its come to Enriched Topic and not throw error during enrichment

Enriched topic:

@mike can you help me on above error

Hi @Jitender_Attri ,

Which enrichment did you configure that does not add a context ? Can you share its configuration please ?

1 Like

Hi @BenB
Use javascript Enrichment

{

"schema": "iglu:com.snowplowanalytics.snowplow/javascript_script_config/jsonschema/1-0-0",

"data": {

    "vendor": "custom.co.jp",

    "name": "javascript_enrichment",

    "enabled": true,

    "parameters": {

        "script": "ZnVuY3Rpb24gcHJvY2VzcyhldmVudCkgewogICAgdmFyIGV2ZW50bmFtZSA9IGV2ZW50LmdldEV2ZW50X25hbWUoKTsKICAgIHZhciBkYXRlID0gZXZlbnQuZ2V0Q29sbGVjdG9yX3RzdGFtcCgpOwogICAgdmFyIG15QXJyID0gZGF0ZS5zcGxpdCgiICIpOwogICAgdmFyIGRhdGVudW09bXlBcnJbMF0ucmVwbGFjZSgvLS9nLCAiIik7CiAgICB2YXIga2V5ID0gZGF0ZW51bS5jb25jYXQoIl8iLGV2ZW50bmFtZSk7CiAgICAKICAgIAogICAgcmV0dXJuIFsgeyBzY2hlbWE6ICJpZ2x1OmNvbS5tY2RfamFwYW4vdXNlcl9kZXRhaWxzL2pzb25zY2hlbWEvNS0wLTAiLAogICAgICAgICAgICAgICBkYXRhOiAgeyAidXNlcl9pZCI6ICJzaXYiLCJhZ2UiOjM1LCJnZW5kZXIiOiJtYWxlIiB9IH0gXTsKfQ=="

    }

}

}

Hi @Jitender_Attri ,

Sorry for the delay. The vendor and the name should be

		"vendor": "com.snowplowanalytics.snowplow",
		"name": "javascript_script_config",

otherwise, the enrichment configuration is not recognized and is just discarded.

We created this issue to handle that.

@BenB This will give me error
{“schemaKey”:“iglu:com.snowplowanalytics.snowplow/javascript_script_config/jsonschema/1-0-0”,“identifier”:“Javascript enrichment”},“message”:{“error”:“Error compiling JavaScript function: [Cannot invoke “javax.script.Compilable.compile(String)” because the return value of “com.snowplowanalytics.snowplow.enrich.common.enrichments.registry.JavascriptScriptEnrichment.engine()” is null]”}}]},

Hi @Jitender_Attri ,

I tried with your configuration locally and it is working fine.

What is the version of your JDK ?

Javascript enrichment is based on Nashorn engine, which was not available before Java 8.

1 Like