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

Update telemetry endpoint to match data contract #190

Merged
merged 1 commit into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "node",
"request": "attach",
"port": 9229,
"preLaunchTask": "func: host start"
"preLaunchTask": "func: host start --cors *"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need now --cors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just is just a debugging task, I found that I was always adding this to debug, so added it here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what does --cors * do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So by default, it's set to block CORS calls, so if I am testing API locally from webhint.io (from a different localhost port), then the calls will get rejected. This will allow that so I can test locally or from webhint.io or postman

}
]
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"type": "func",
"command": "host start",
"command": "host start --cors *",
"problemMatcher": "$func-watch",
"isBackground": true,
"dependsOn": "npm build"
Expand Down
126 changes: 126 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/common/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export const trackEvent = async (name: string, properties: any) => {
* @param name - Event name.
* @param properties - Properties to track.
*/
export const addToAppInsights = (name: string, properties: any = {}) => {
export const addToAppInsights = (name: string, properties: any = {}, measurements: any = {}, time: Date) => {
appInsightsClient.trackEvent({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has the signature been updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@molant Where?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the app insights package. I don't see a bump in package.json in this PR so I wonder what/when that changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the Azure AI package, and it already accepts a measurement param.

measurements,
name,
properties
properties,
time
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/telemetry-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const run: AzureFunction = async (context: Context, req: HttpRequest): Pr

try {
for (const telemetry of req.body.data) {
addToAppInsights(telemetry.name, telemetry.properties);
addToAppInsights(telemetry.data.name, telemetry.data.properties, telemetry.data.measurements, telemetry.time);
}

await sendPendingData();
Expand Down