Skip to content

Commit

Permalink
New: Add measurements to events
Browse files Browse the repository at this point in the history
Also add new debugging options
  • Loading branch information
utsavized authored Jun 22, 2020
1 parent 613f9ee commit 3bc074d
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 5 deletions.
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 *"
}
]
}
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({
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

0 comments on commit 3bc074d

Please sign in to comment.