appscms-tools-theme 3.6.6 → 3.6.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/assets/js/usageTracking.js +82 -14
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65588e3032d192ae700cd9794d32054c936d730b8b7cee11383030f1a2c23e45
4
- data.tar.gz: 8f18ce4956a9e51b7e90f82396b834e328f6332fcc4cf9342a868046ca4a7f43
3
+ metadata.gz: 18a339812bdf8cbc4a8c2434eb9c19e296f5743ec0ebceafc573f490ba6abe10
4
+ data.tar.gz: 44733df1d1a19472cf747c9ae7923bc7bed26b1d9fbeba025602f523c1f3f52a
5
5
  SHA512:
6
- metadata.gz: b71a062aa7bf0cfee40c9ab9287fb0e7d713e1d452b1f9298dc83f5efc03cb2fbc6708be004c5df3ff4e7e38a5b6f3b9d334941c10a2ec65c4dec49fffb359a2
7
- data.tar.gz: bab231bd24c1567f57ac0d33c9fe1116c388ea915d3b9627b5b16f46b3325acb310aa0d0445b61477460437e106785e0579c62f53744a20ebcb212049e158f7d
6
+ metadata.gz: 840487e54f3b56e0b97525a0bdd44b9bdbbb7932ed5f24a0788a0542760ba7f1fd65e7bcf7740c4767375bfe5052b076925d1085a18255ff7882ecbbf772d48d
7
+ data.tar.gz: 97d381946e058c694ed9c7d92a729471636a2ab8fe15bb796e7d9397b05c6963c974121094d2de6136bbe90468047142d2cbce7c02770ac0cc0b1ff7c712d518
@@ -1,7 +1,46 @@
1
- ---
2
- ---
1
+ // Generate a unique ID for the user (if not already generated)
2
+ const generateUserID = () => {
3
+ // Check if the user ID is already stored in cookies or local storage
4
+ const storedUserID = getStoredUserID();
3
5
 
4
- let userTrackingCountLimit='{{site.userTrackingCount}}';
6
+ if (storedUserID) {
7
+ return storedUserID;
8
+ }
9
+
10
+ // Example: Generating a random string
11
+ const characters =
12
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
13
+ let id = "";
14
+ for (let i = 0; i < 10; i++) {
15
+ id += characters.charAt(Math.floor(Math.random() * characters.length));
16
+ }
17
+
18
+ // Store the generated user ID in cookies or local storage
19
+ storeUserID(id);
20
+
21
+ return id;
22
+ };
23
+
24
+ // Get the stored user ID from cookies or local storage
25
+ const getStoredUserID = () => {
26
+ return localStorage.getItem("userID");
27
+ };
28
+
29
+ // Store the user ID in cookies or local storage
30
+ const storeUserID = (userID) => {
31
+ localStorage.setItem("userID", userID);
32
+ };
33
+
34
+ // Get the current date in YYYY-MM-DD format
35
+ const getCurrentDate = () => {
36
+ const today = new Date();
37
+ const year = today.getFullYear();
38
+ const month = String(today.getMonth() + 1).padStart(2, "0");
39
+ const day = String(today.getDate()).padStart(2, "0");
40
+ return `${year}-${month}-${day}`;
41
+ };
42
+
43
+ let userTrackingCountLimit = "20";
5
44
  const checkUsage = () => {
6
45
  const today = new Date().toDateString();
7
46
  const usageCount = getCookie("featureUsageCount");
@@ -17,8 +56,29 @@ const checkUsage = () => {
17
56
  // First usage of the day
18
57
  setCookie("featureUsageCount", 1, getExpirationDate());
19
58
  }
20
- };
59
+ const userID = generateUserID();
60
+ try {
61
+ if ((usageCount + 1) % 5 === 0) {
62
+ gtag("event", `feature_used_${usageCount + 1}_times`, {
63
+ user_id: userID,
64
+ userID: userID,
65
+ feature: window.location.pathname + location.search,
66
+ });
67
+ }
68
+ } catch (error) {
69
+ console.log(error);
70
+ }
21
71
 
72
+ try {
73
+ gtag("event", "feature_used", {
74
+ user_id: userID,
75
+ userID: userID,
76
+ feature: window.location.pathname + location.search,
77
+ });
78
+ } catch (error) {
79
+ console.log(error);
80
+ }
81
+ };
22
82
  const incrementUsageCount = (count) => {
23
83
  const today = new Date().toDateString();
24
84
 
@@ -37,10 +97,19 @@ const showShareModal = () => {
37
97
  const handleShare = () => {
38
98
  const usageCount = getCookie("featureUsageCount");
39
99
  if (usageCount) {
40
- // Decrement the usage count by 1 if the user has already used the feature today
41
- setCookie("featureUsageCount", usageCount , getExpirationDate());
100
+ setCookie("featureUsageCount", 0, getExpirationDate());
42
101
  }
43
102
  document.getElementById("shareModal").style.display = "none";
103
+ try {
104
+ const userID = generateUserID();
105
+ gtag("event", "feature_shared", {
106
+ user_id: userID,
107
+ userID: userID,
108
+ feature: window.location.pathname + location.search,
109
+ });
110
+ } catch (error) {
111
+ console.log(error);
112
+ }
44
113
  };
45
114
 
46
115
  const getCookie = (name) => {
@@ -63,13 +132,12 @@ const getExpirationDate = () => {
63
132
  date.setTime(date.getTime() + 24 * 60 * 60 * 1000); // 24 hours in milliseconds
64
133
  return date.toUTCString();
65
134
  };
66
- const socialShare=document.querySelectorAll('.social-share')
135
+ const socialShare = document.querySelectorAll(".social-share");
67
136
 
68
137
  if (socialShare) {
69
- Array.from(socialShare).map(item=>{
70
- item.addEventListener('click',()=>{
71
- handleShare()
72
- })
73
- })
74
-
75
- }
138
+ Array.from(socialShare).map((item) => {
139
+ item.addEventListener("click", () => {
140
+ handleShare();
141
+ });
142
+ });
143
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appscms-tools-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.6
4
+ version: 3.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - vivek-appscms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-10 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll