Skip to content
This repository was archived by the owner on Mar 26, 2023. It is now read-only.

Commit a127b6b

Browse files
committed
Marketing enhancements
1 parent 89d8bd1 commit a127b6b

5 files changed

Lines changed: 41 additions & 43 deletions

File tree

.env.development

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ VUE_APP_API_PRINTER=https://printer.api.test.profcomff.com
55
VUE_APP_API_REPORT=https://report.api.test.profcomff.com
66
VUE_APP_API_TIMETABLE=https://timetable.api.test.profcomff.com
77
VUE_APP_API_NAVBAR=https://navbar.api.test.profcomff.com
8-
VUE_APP_API_MARKETING=https://marketing.api.test.profcomff.com
9-
VUE_APP_FEEDBACK_FORM=https://forms.yandex.ru/u/635d013b068ff0587320bfc9/
8+
VUE_APP_API_MARKETING=https://marketing.api.test.profcomff.com/v1
9+
VUE_APP_FEEDBACK_FORM=https://forms.yandex.ru/u/635d013b068ff0587320bfc9/

.env.production

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ VUE_APP_API_PRINTER=https://printer.api.profcomff.com
55
VUE_APP_API_REPORT=https://report.api.profcomff.com
66
VUE_APP_API_TIMETABLE=https://timetable.api.profcomff.com
77
VUE_APP_API_NAVBAR=https://navbar.api.profcomff.com
8-
VUE_APP_API_MARKETING=https://marketing.api.profcomff.com
9-
FEEDBACK_FORM=https://forms.yandex.ru/u/635d013b068ff0587320bfc9/
8+
VUE_APP_API_MARKETING=https://marketing.api.profcomff.com/v1
9+
FEEDBACK_FORM=https://forms.yandex.ru/u/635d013b068ff0587320bfc9/

src/router/index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,28 @@ const router = createRouter({
3434
routes,
3535
});
3636

37-
router.beforeEach((to, from, next) => {
38-
console.log(to);
37+
router.beforeEach((to, from) => {
38+
// Log to marketing API
39+
fetch(`${process.env.VUE_APP_API_MARKETING}/action`, {
40+
method: 'POST',
41+
cache: 'no-cache',
42+
redirect: 'follow',
43+
headers: { 'Content-Type': 'application/json' },
44+
body: JSON.stringify({
45+
user_id: localStorage.getItem('marketing-id'),
46+
action: 'route to',
47+
path_from: from.fullPath || null,
48+
path_to: to.fullPath || null,
49+
}),
50+
}).catch();
51+
3952
if (
4053
to.meta.requiresGroupSelection &&
4154
(localStorage.getItem('timetable-group-id') === null ||
4255
localStorage.getItem('timetable-group-id') === undefined ||
4356
localStorage.getItem('timetable-group-id') === '-1')
4457
)
45-
next({ name: 'init' });
46-
else next();
58+
return { name: 'init' };
4759
});
4860

4961
export default router;

src/views/EventView.vue

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import GroupRow from '@/components/GroupRow.vue';
7878
import LecturerRow from '@/components/LecturerRow.vue';
7979
import RoomRow from '@/components/RoomRow.vue';
80+
8081
export default {
8182
components: { LecturerRow, RoomRow, GroupRow },
8283
data() {
@@ -104,7 +105,6 @@ export default {
104105
document.dispatchEvent(changeHeaderLayoutEvent);
105106
},
106107
},
107-
108108
beforeMount() {
109109
this.loadEventInfo();
110110
console.log(this.eventInfo);
@@ -155,41 +155,9 @@ export default {
155155
},
156156
clickRoom(roomId) {
157157
this.$router.push(`/timetable/room/${roomId}`);
158-
try {
159-
fetch(`${process.env.VUE_APP_API_MARKETING}/action`, {
160-
method: 'POST',
161-
cache: 'no-cache',
162-
redirect: 'follow',
163-
headers: { 'Content-Type': 'application/json' },
164-
body: JSON.stringify({
165-
user_id: localStorage.getItem('marketing-id'),
166-
action: 'route to',
167-
path_from: '/timetable',
168-
path_to: '/timetable/room',
169-
}),
170-
});
171-
} catch {
172-
//Failed, skips
173-
}
174158
},
175159
clickLecturer(lecturerId) {
176160
this.$router.push(`/timetable/lecturer/${lecturerId}`);
177-
try {
178-
fetch(`${process.env.VUE_APP_API_MARKETING}/action`, {
179-
method: 'POST',
180-
cache: 'no-cache',
181-
redirect: 'follow',
182-
headers: { 'Content-Type': 'application/json' },
183-
body: JSON.stringify({
184-
user_id: localStorage.getItem('marketing-id'),
185-
action: 'route to',
186-
path_from: '/timetable',
187-
path_to: '/timetable/lecturer',
188-
}),
189-
});
190-
} catch {
191-
//Failed, skips
192-
}
193161
},
194162
getCurComments() {
195163
let cur = this.comments[this.eventId];

src/views/TimetableView.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import EventRow from '@/components/EventRow.vue';
4949
import retry from '@/utils/Retrying.js';
5050
import { fetchTimetable } from '@/utils/FetchTimetable.js';
51-
import { getMonday, isToday } from '@/utils/Dates.js';
51+
import { getMonday, isToday, getIsoDate } from '@/utils/Dates.js';
5252
5353
export default {
5454
components: {
@@ -100,10 +100,28 @@ export default {
100100
},
101101
},
102102
watch: {
103-
date(newDate) {
103+
date(newDate, oldDate) {
104104
this.loaded = false;
105105
// 5 раз с интервалом в 1 секунду попробуй скачать расписание
106106
this.loadTimetableOnDate(newDate);
107+
108+
fetch(`${process.env.VUE_APP_API_MARKETING}/action`, {
109+
method: 'POST',
110+
cache: 'no-cache',
111+
redirect: 'follow',
112+
headers: { 'Content-Type': 'application/json' },
113+
body: JSON.stringify({
114+
user_id: localStorage.getItem('marketing-id'),
115+
action: 'timetable change date',
116+
path_from: '/timetable',
117+
path_to: '/timetable',
118+
additional_data: JSON.stringify({
119+
date: getIsoDate(newDate),
120+
prev_date: getIsoDate(oldDate),
121+
group: this.groupInfo || { id: this.groupId } || null,
122+
}),
123+
}),
124+
});
107125
},
108126
},
109127
beforeMount() {

0 commit comments

Comments
 (0)