How we saved over $240K per year by replacing Mixpanel with Google BigQuery, Pub/Sub, Dataflow & Kubernetes (code snippet #4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jellybtn; | |
import com.google.api.services.bigquery.model.TableRow; | |
import com.google.cloud.dataflow.sdk.values.TupleTag; | |
import org.json.JSONObject; | |
public class MapPeople extends BaseMap { | |
MapPeople(TupleTag < TableRow > errorsTag) { | |
super(errorsTag); | |
} | |
@Override | |
String getType() { | |
return "people"; | |
} | |
@Override | |
void map(JSONObject json, TableRow tableRow) { | |
if (json.has("$distinct_id")) { | |
tableRow.set("distinct_id", json.get("$distinct_id")); | |
} | |
if (json.has("$token")) { | |
tableRow.set("token", json.get("$token")); | |
} | |
if (json.has("$set")) { | |
tableRow.set("action", "set"); | |
tableRow.set("properties", json.get("$set").toString()); | |
} else if (json.has("$set_once")) { | |
tableRow.set("action", "set_once"); | |
tableRow.set("properties", json.get("$set_once").toString()); | |
} else if (json.has("$union")) { | |
tableRow.set("action", "union"); | |
tableRow.set("properties", json.get("$union").toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok