Skip to content

Commit

Permalink
Use a unique 'contact' ID for every event upload
Browse files Browse the repository at this point in the history
  • Loading branch information
abrauninger committed Oct 10, 2018
1 parent 84df4fb commit 633aa09
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/store/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,18 @@ export class TelemetrySession {

public recordLandingPage() {
this.uploadData({
sessionId: this.sessionId,
event: "LandingPage",
});
}

public recordStartSurvey() {
this.uploadData({
sessionId: this.sessionId,
event: "StartSurvey",
});
}

public recordAnswer(questionId: QuestionId, answerId: AnswerId) {
this.uploadData({
sessionId: this.sessionId,
event: "Answer",
question: questionId,
answer: answerId,
Expand All @@ -49,20 +46,22 @@ export class TelemetrySession {

public recordPlanPage(answers: IQuestionAndAnswer[]) {
this.uploadData({
sessionId: this.sessionId,
event: "ViewPlan",
answers: answers.map(qa => ({ question: qa.questionId, answer: qa.answerId })),
});
}

public recordStartOver() {
this.uploadData({
sessionId: this.sessionId,
event: "StartOver",
});
}

private uploadData(data: any) {
// 'contact' is needs to be unique for every event.
data.contact = uuidv4();
data.sessionId = this.sessionId;

fetch(TelemetryEndpoint, {
method: "POST",
headers: { 'Content-Type': 'application/json' },
Expand Down

0 comments on commit 633aa09

Please sign in to comment.