Skip to content

Commit

Permalink
Merge pull request #46 from velocidi/kotlin-literals
Browse files Browse the repository at this point in the history
Update README and Sample project to use Map and Array literals.
  • Loading branch information
dimamo5 authored May 6, 2021
2 parents 38e38f9 + 4a10ea8 commit 7535d19
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ val eventJsonString =
Velocidi.getInstance().track(UserId("<Advertising ID>", "gaid"), eventJsonString)

// Using a JSONObject
val eventJsonObj = JSONObject()
eventJsonObj.put("clientId", "velocidi")
eventJsonObj.put("siteId", "velocidi.com")
eventJsonObj.put("type", "appView")
eventJsonObj.put("title", "Welcome Screen")

Velocidi.getInstance().track(UserId("<Advertising ID>", "gaid"), eventJsonObj)
val eventJsonObj = mapOf(
"clientId" to "velocidi",
"siteId" to "velocidi.com",
"type" to "appView",
"title" to "Welcome Screen",
"customFields" to mapOf(
"debug" to true,
"role" to "superuser"
)
)

Velocidi.getInstance().track(UserId("<Advertising ID>", "gaid"), JSONObject(eventJsonObj))
```

### Match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ protected void onCreate(Bundle savedInstanceState) {
Velocidi.init(config, this);

try {
JSONObject eventJsonObj = new JSONObject();
eventJsonObj.put("clientId", "velocidi");
eventJsonObj.put("siteId", "velocidi.com");
eventJsonObj.put("type", "appView");
JSONObject eventJsonObj = new JSONObject()
.put("clientId", "velocidi")
.put("siteId", "velocidi.com")
.put("type", "appView");

Velocidi.getInstance().track(
new UserId("user_email_hash", "email_sha256"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,20 @@ class MainActivity : AppCompatActivity() {
eventJsonString
)

// OR using a JSONObject
val customFields = JSONObject()
customFields.put("debug", true)
customFields.put("role", "superuser")

val eventJsonObj = JSONObject()
eventJsonObj.put("clientId", "velocidi")
eventJsonObj.put("siteId", "velocidi.com")
eventJsonObj.put("type", "appView")
eventJsonObj.put("customFields", customFields)
eventJsonObj.put("title", "Welcome Screen")
val eventJsonObj = mapOf(
"clientId" to "velocidi",
"siteId" to "velocidi.com",
"type" to "appView",
"title" to "Welcome Screen",
"customFields" to mapOf(
"debug" to true,
"role" to "superuser"
)
)

Velocidi.getInstance().track(
UserId("user_email_hash", "email_sha256"),
eventJsonObj
JSONObject(eventJsonObj)
)
}

Expand Down

0 comments on commit 7535d19

Please sign in to comment.