Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send the event schemas to the API #10

Open
aleks-tpom6oh opened this issue Jan 16, 2022 · 0 comments
Open

Send the event schemas to the API #10

aleks-tpom6oh opened this issue Jan 16, 2022 · 0 comments

Comments

@aleks-tpom6oh
Copy link
Contributor

aleks-tpom6oh commented Jan 16, 2022

The last piece is to send the data we prepared to the API.

TODO

API doc

Endpoint: api.avo.app/inspector/v1/track
Method: POST

Every time the trackSchemaFromEvent method is called we need to send the following to the API:

{
  [
    {
      "appName": ...,
      "appVersion": ...,
      "libVersion": ...,
      "libPlatform": "go",
      "apiKey": ...,
      "sessionId": "11332f62-ba2d-11eb-8529-0242ac130003", // UUID
      "messageId": "4cffbdca-ba2e-11eb-8529-0242ac130003", // UUID
      "createdAt": "2021-05-21T09:05:40.735Z",
      "type": "sessionStarted",
    },
    {
      "appName": "...",
      "appVersion": "...",
      "libVersion": "...",
      "libPlatform": "go"
	"sessionId": "11332f62-ba2d-11eb-8529-0242ac130003", //UUID same as in the sessionStarted event
      "messageId": "54cafd77-c6cd-46b0-8459-69b59d44f012", // new UUID
      "createdAt": "2021-05-21T09:05:40.740Z",
      "type": "event",
      // Data we prepared before
      "eventName": "Onboarding Started",
      "eventProperties": [
        {
          "propertyName": "user",
          "propertyType": "object",
          "children": [
            {
              "propertyName": "id",
              "propertyType": "string"
            }
          ]
        },
        {
          "propertyName": "friendNames",
          "propertyType": "list",
           "children": ["string", "null"]
        },
        {
          "propertyName": "isAdmin",
          "propertyType": "bool",
        },
      ]
    },
  ]
}
### HTTP Responses

- Server returns a `200` response for successful API requests.
- Server returns a `400` response for invalid requests.
Invalid requests include:
    - `Content-type header missing`
    - `Invalid API key

Write tests for the trackSchemaFromEvent method and the payload generated for the API calls.

Reference

https://github.com/avohq/node-avo-inspector/blob/main/src/AvoNetworkCallsHandler.ts
https://github.com/avohq/node-avo-inspector/blob/main/src/__tests__/TestNetworkCallsHandler.ts
https://github.com/avohq/node-avo-inspector/blob/main/src/__tests__/TestNetworkCallsHandlerPublic.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant