feeds-fun 1.16.4 → 1.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feeds-fun",
3
- "version": "1.16.4",
3
+ "version": "1.16.6",
4
4
  "author": "Aliaksei Yaletski (Tiendil) <a.eletsky@gmail.com> (https://tiendil.org/)",
5
5
  "description": "Frontend for the Feeds Fun — web-based news reader",
6
6
  "keywords": [
Binary file
@@ -34,6 +34,7 @@
34
34
  import {useTagsStore} from "@/stores/tags";
35
35
  import * as tagsFilterState from "@/logic/tagsFilterState";
36
36
  import * as asserts from "@/logic/asserts";
37
+ import * as events from "@/logic/events";
37
38
 
38
39
  const tagsStore = useTagsStore();
39
40
 
@@ -47,6 +48,7 @@
47
48
  countMode?: string | null;
48
49
  secondaryMode?: string | null;
49
50
  showSwitch?: boolean | null;
51
+ changeSource: events.TagChangeSource;
50
52
  }>();
51
53
 
52
54
  const tagInfo = computed(() => {
@@ -81,14 +83,20 @@
81
83
  return result;
82
84
  });
83
85
 
84
- function onClick() {
86
+ async function onClick() {
85
87
  asserts.defined(tagsStates);
86
- tagsStates.value.onTagClicked({tag: properties.uid});
88
+
89
+ let changeInfo = tagsStates.value.onTagClicked({tag: properties.uid});
90
+
91
+ await events.tagStateChanged({tag: properties.uid, source: properties.changeSource, ...changeInfo});
87
92
  }
88
93
 
89
- function onRevers() {
94
+ async function onRevers() {
90
95
  asserts.defined(tagsStates);
91
- tagsStates.value.onTagReversed({tag: properties.uid});
96
+
97
+ let changeInfo = tagsStates.value.onTagReversed({tag: properties.uid});
98
+
99
+ await events.tagStateChanged({tag: properties.uid, source: properties.changeSource, ...changeInfo});
92
100
  }
93
101
 
94
102
  const tooltip = computed(() => {
@@ -11,8 +11,9 @@
11
11
  class="ml-1"
12
12
  :uid="tag"
13
13
  :count="tags[tag] ?? 0"
14
- :showSwitch="true"
15
- count-mode="no" />
14
+ :show-switch="true"
15
+ count-mode="no"
16
+ change-source="tag_filter" />
16
17
  </li>
17
18
  </ul>
18
19
 
@@ -34,7 +35,8 @@
34
35
  <ffun-tag
35
36
  :uid="tag"
36
37
  :count="tags[tag]"
37
- count-mode="prefix" />
38
+ count-mode="prefix"
39
+ changeSource="tag_filter" />
38
40
  </li>
39
41
  </ul>
40
42
 
@@ -7,7 +7,8 @@
7
7
  :uid="tag"
8
8
  :count="tagsCount[tag]"
9
9
  :secondary-mode="tagMode(tag)"
10
- count-mode="tooltip" />
10
+ count-mode="tooltip"
11
+ change-source="entry_record" />
11
12
 
12
13
  <a
13
14
  class=""
@@ -1,5 +1,8 @@
1
1
  import * as api from "@/logic/api";
2
2
  import type * as t from "@/logic/types";
3
+ import type {State as TagState} from "@/logic/tagsFilterState";
4
+
5
+ export type TagChangeSource = "tag_filter" | "entry_record";
3
6
 
4
7
  export async function newsLinkOpened({entryId}: {entryId: t.EntryId}) {
5
8
  await api.trackEvent({name: "news_link_opened", entry_id: entryId});
@@ -12,3 +15,23 @@ export async function newsBodyOpened({entryId}: {entryId: t.EntryId}) {
12
15
  export async function socialLinkClicked({linkType}: {linkType: string}) {
13
16
  await api.trackEvent({name: "social_link_clicked", link_type: linkType});
14
17
  }
18
+
19
+ export async function tagStateChanged({
20
+ tag,
21
+ fromState,
22
+ toState,
23
+ source
24
+ }: {
25
+ tag: string;
26
+ fromState: TagState;
27
+ toState: TagState;
28
+ source: TagChangeSource;
29
+ }) {
30
+ await api.trackEvent({
31
+ name: "tag_filter_state_changed",
32
+ tag: tag,
33
+ from_state: fromState,
34
+ to_state: toState,
35
+ source: source
36
+ });
37
+ }
@@ -26,25 +26,33 @@ export class Storage {
26
26
  });
27
27
  }
28
28
 
29
- onTagStateChanged({tag, state}: {tag: string; state: State}) {
29
+ onTagStateChanged({tag, state}: {tag: string; state: State}): {fromState: State; toState: State} {
30
30
  if (state === "required") {
31
31
  this.requiredTags[tag] = true;
32
32
  if (this.excludedTags[tag]) {
33
33
  delete this.excludedTags[tag];
34
+ return {fromState: "excluded", toState: "required"};
34
35
  }
36
+ return {fromState: "none", toState: "required"};
35
37
  } else if (state === "excluded") {
36
38
  this.excludedTags[tag] = true;
37
39
  if (this.requiredTags[tag]) {
38
40
  delete this.requiredTags[tag];
41
+ return {fromState: "required", toState: "excluded"};
39
42
  }
43
+ return {fromState: "none", toState: "excluded"};
40
44
  } else if (state === "none") {
41
45
  if (this.requiredTags[tag]) {
42
46
  delete this.requiredTags[tag];
47
+ return {fromState: "required", toState: "none"};
43
48
  }
44
49
 
45
50
  if (this.excludedTags[tag]) {
46
51
  delete this.excludedTags[tag];
52
+ return {fromState: "excluded", toState: "none"};
47
53
  }
54
+
55
+ return {fromState: "none", toState: "none"};
48
56
  } else {
49
57
  throw new Error(`Unknown tag state: ${state}`);
50
58
  }
@@ -52,11 +60,11 @@ export class Storage {
52
60
 
53
61
  onTagReversed({tag}: {tag: string}) {
54
62
  if (!(tag in this.selectedTags)) {
55
- this.onTagStateChanged({tag: tag, state: "required"});
63
+ return this.onTagStateChanged({tag: tag, state: "required"});
56
64
  } else if (this.requiredTags[tag]) {
57
- this.onTagStateChanged({tag: tag, state: "excluded"});
65
+ return this.onTagStateChanged({tag: tag, state: "excluded"});
58
66
  } else if (this.excludedTags[tag]) {
59
- this.onTagStateChanged({tag: tag, state: "required"});
67
+ return this.onTagStateChanged({tag: tag, state: "required"});
60
68
  } else {
61
69
  throw new Error(`Unknown tag state: ${tag}`);
62
70
  }
@@ -64,9 +72,9 @@ export class Storage {
64
72
 
65
73
  onTagClicked({tag}: {tag: string}) {
66
74
  if (tag in this.selectedTags) {
67
- this.onTagStateChanged({tag: tag, state: "none"});
75
+ return this.onTagStateChanged({tag: tag, state: "none"});
68
76
  } else {
69
- this.onTagStateChanged({tag: tag, state: "required"});
77
+ return this.onTagStateChanged({tag: tag, state: "required"});
70
78
  }
71
79
  }
72
80