|
1 | | -import React, { useState } from 'react'; |
| 1 | +import React, { useEffect, useState } from 'react'; |
| 2 | +import { useLocation } from 'react-router-dom'; |
2 | 3 | import { useSelector } from 'react-redux'; |
3 | 4 | import { sendTrackEvent } from '@edx/frontend-platform/analytics'; |
4 | 5 | import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; |
| 6 | +import { history } from '@edx/frontend-platform'; |
5 | 7 | import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; |
6 | | - |
7 | 8 | import { Button } from '@edx/paragon'; |
8 | 9 | import { AlertList } from '../../generic/user-messages'; |
9 | 10 |
|
@@ -109,6 +110,23 @@ function OutlineTab({ intl }) { |
109 | 110 | /** show post enrolment survey to only B2C learners */ |
110 | 111 | const learnerType = isEnterpriseUser() ? 'enterprise_learner' : 'b2c_learner'; |
111 | 112 |
|
| 113 | + const location = useLocation(); |
| 114 | + |
| 115 | + useEffect(() => { |
| 116 | + const currentParams = new URLSearchParams(location.search); |
| 117 | + const startCourse = currentParams.get('start_course'); |
| 118 | + if (startCourse === '1') { |
| 119 | + sendTrackEvent('welcome.email.clicked.startcourse', {}); |
| 120 | + |
| 121 | + // Deleting the course_start query param as it only needs to be set once |
| 122 | + // whenever passed in query params. |
| 123 | + currentParams.delete('start_course'); |
| 124 | + history.replace({ |
| 125 | + search: currentParams.toString(), |
| 126 | + }); |
| 127 | + } |
| 128 | + }, [location.search]); |
| 129 | + |
112 | 130 | return ( |
113 | 131 | <> |
114 | 132 | <div data-learner-type={learnerType} className="row w-100 mx-0 my-3 justify-content-between"> |
|
0 commit comments