0.0.1 • Published 4 years ago

furiosa-pugsky v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

TypeScript library for Pugsky

Usage:

First to configure the client, compile the avro sources:

PugskyEventTypeCompiler.generateFromAvro()

First configure

var c1 = Configurer
	.newConfigurer()
	.withHost("pugsky.ada.com")
	.withRequestMethod("https")

Next initialize a new Pugsky event

var e1 = c1.build()

Setting values for the event:

e1.getData()
	.setEvent("SignUp")
	.setCategory("Onboarding")
	.setPropertyVal("type", "email")
	.setPropertyVal("accountId", "aa8ab8abjev")
	.setUserPropertyVal("sex", "MALE")
	.setUserPropertyVal("yearOfBirth", "1990")
	.setUserPropertyVal("platform", "ios")

Sending the event:

e1.send()

Note: The request is sent async. To send another event simultaneously, a new Pugsky event needs to be initialized first with var e2 = c1.build(), Then send with e2.send().

The representation of the event:

{
  "header": {
    "uuid": "13b2e1fe-7081-47e6-bb06-62ab48fad2ef",
    "topic": "events-furiosa",
    "type": "com.ada.pugsky.avro",
    "timestamp": "Thu, 31 Oct 2019 17:38:41 GMT",
    "application": "Pugsky",
    "version": "0.0.1"
  },
  "data": {
    "event": "SignUp",
    "category": "Onboarding",
    "properties": [
      {
        "key": "type",
        "value": "email"
      },
      {
        "key": "accountId",
        "value": "aa8ab8abjev"
      }
    ],
    "user_properties": [
      {
        "key": "sex",
        "value": "MALE"
      },
      {
        "key": "yearOfBirth",
        "value": "1990"
      },
      {
        "key": "platform",
        "value": "ios"
      }
    ]
  }
}

Run unit tests:

Set up jest:

# If using Apple OSX
export CPPFLAGS="-I/usr/local/opt/openssl/include" # For compiling librdkafka
export LDFLAGS="-L/usr/local/opt/openssl/lib" # For compiling librdkafka
npm install jest

To run tests:

jest