Skip to content

Commit

Permalink
Merge pull request #2421 from codecrafters-io/track-second-stage-events
Browse files Browse the repository at this point in the history
Add analytics tracking for completed steps in second stage tutorial card.
  • Loading branch information
rohitpaulk authored Nov 22, 2024
2 parents e018483 + 41f4e9a commit b0b1707
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AnalyticsEventTrackerService from 'codecrafters-frontend/services/analytics-event-tracker';
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import CoursePageStateService from 'codecrafters-frontend/services/course-page-state';
Expand Down Expand Up @@ -56,6 +57,7 @@ class RunTestsStep extends BaseStep implements Step {
}

export default class SecondStageTutorialCardComponent extends Component<Signature> {
@service declare analyticsEventTracker: AnalyticsEventTrackerService;
@service declare coursePageState: CoursePageStateService;
@service declare store: Store;

Expand Down Expand Up @@ -100,11 +102,23 @@ export default class SecondStageTutorialCardComponent extends Component<Signatur
handleStepCompletedManually(step: Step) {
if (step.id === 'read-instructions') {
this.coursePageState.recordManuallyCompletedStepInSecondStageInstructions('read-instructions');

this.analyticsEventTracker.track('completed_second_stage_tutorial_step', {
step_number: 1,
step_id: 'read-instructions',
repository_id: this.args.repository.id,
});
}

if (step.id === 'implement-solution') {
this.coursePageState.recordManuallyCompletedStepInSecondStageInstructions('read-instructions');
this.coursePageState.recordManuallyCompletedStepInSecondStageInstructions('implement-solution');

this.analyticsEventTracker.track('completed_second_stage_tutorial_step', {
step_number: 2,
step_id: 'implement-solution',
repository_id: this.args.repository.id,
});
}
}

Expand Down

0 comments on commit b0b1707

Please sign in to comment.