Skip to content

Commit 69bbb12

Browse files
FrooodleDarioGii
andauthored
Survey change to reduce prompts to users (#3913)
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Dario Ghunney Ware <[email protected]>
1 parent 2218f0b commit 69bbb12

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

stirling-pdf/src/main/resources/static/js/downloader.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
if (window.isDownloadScriptInitialized) return; // Prevent re-execution
33
window.isDownloadScriptInitialized = true;
44

5+
// Global PDF processing count tracking for survey system
6+
window.incrementPdfProcessingCount = function() {
7+
let pdfProcessingCount = parseInt(localStorage.getItem('pdfProcessingCount') || '0');
8+
pdfProcessingCount++;
9+
localStorage.setItem('pdfProcessingCount', pdfProcessingCount.toString());
10+
};
11+
512
const {
613
pdfPasswordPrompt,
714
multipleInputsForSingleRequest,
@@ -312,6 +319,11 @@
312319
pdf_pages: pageCount,
313320
});
314321
}
322+
323+
// Increment PDF processing count for survey tracking
324+
if (success && typeof window.incrementPdfProcessingCount === 'function') {
325+
window.incrementPdfProcessingCount();
326+
}
315327
}
316328
}
317329

stirling-pdf/src/main/resources/static/js/multitool/PdfContainer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ class PdfContainer {
271271
pdf_pages: pageCount,
272272
});
273273
}
274+
275+
// Increment PDF processing count for survey tracking
276+
if (success && typeof window.incrementPdfProcessingCount === 'function') {
277+
window.incrementPdfProcessingCount();
278+
}
274279
} catch { }
275280
}
276281

stirling-pdf/src/main/resources/static/js/pages/home.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,16 @@ document.addEventListener('DOMContentLoaded', function () {
6666
const dontShowAgain = document.getElementById('dontShowAgain');
6767
const takeSurveyButton = document.getElementById('takeSurvey');
6868

69-
const viewThresholds = [5, 10, 15, 22, 30, 50, 75, 100, 150, 200];
69+
const pdfProcessingThresholds = [8, 15, 22, 35, 50, 75, 100, 150];
7070

71-
// Check if survey version changed and reset page views if it did
71+
// Check if survey version changed and reset PDF processing count if it did
7272
const storedVersion = localStorage.getItem('surveyVersion');
7373
if (storedVersion && storedVersion !== surveyVersion) {
74-
localStorage.setItem('pageViews', '0');
74+
localStorage.setItem('pdfProcessingCount', '0');
7575
localStorage.setItem('surveyVersion', surveyVersion);
7676
}
7777

78-
let pageViews = parseInt(localStorage.getItem('pageViews') || '0');
79-
80-
pageViews++;
81-
localStorage.setItem('pageViews', pageViews.toString());
78+
let pdfProcessingCount = parseInt(localStorage.getItem('pdfProcessingCount') || '0');
8279

8380
function shouldShowSurvey() {
8481
if(!window.showSurvey) {
@@ -90,11 +87,11 @@ document.addEventListener('DOMContentLoaded', function () {
9087
}
9188

9289
// If survey version changed and we hit a threshold, show the survey
93-
if (localStorage.getItem('surveyVersion') !== surveyVersion && viewThresholds.includes(pageViews)) {
90+
if (localStorage.getItem('surveyVersion') !== surveyVersion && pdfProcessingThresholds.includes(pdfProcessingCount)) {
9491
return true;
9592
}
9693

97-
return viewThresholds.includes(pageViews);
94+
return pdfProcessingThresholds.includes(pdfProcessingCount);
9895
}
9996

10097
if (shouldShowSurvey()) {

0 commit comments

Comments
 (0)