这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,14 @@ public String licenseType() {
return "NORMAL";
}

@Bean(name = "disablePixel")
public boolean disablePixel() {
return Boolean.parseBoolean(env.getProperty("DISABLE_PIXEL", "false"));
@Bean(name = "scarfEnabled")
public boolean scarfEnabled() {
return applicationProperties.getSystem().isScarfEnabled();
}

@Bean(name = "posthogEnabled")
public boolean posthogEnabled() {
return applicationProperties.getSystem().isPosthogEnabled();
}

@Bean(name = "machineType")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ public static class System {
private String tessdataDir;
private Boolean enableAlphaFunctionality;
private Boolean enableAnalytics;
private Boolean enablePosthog;
private Boolean enableScarf;
private Datasource datasource;
private Boolean disableSanitize;
private int maxDPI;
Expand All @@ -333,6 +335,18 @@ public static class System {
public boolean isAnalyticsEnabled() {
return this.getEnableAnalytics() != null && this.getEnableAnalytics();
}

public boolean isPosthogEnabled() {
// Treat null as enabled when analytics is enabled
return this.isAnalyticsEnabled()
&& (this.getEnablePosthog() == null || this.getEnablePosthog());
}

public boolean isScarfEnabled() {
// Treat null as enabled when analytics is enabled
return this.isAnalyticsEnabled()
&& (this.getEnableScarf() == null || this.getEnableScarf());
}
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public PostHogService(
}

private void captureSystemInfo() {
if (!applicationProperties.getSystem().isAnalyticsEnabled()) {
if (!applicationProperties.getSystem().isPosthogEnabled()) {
return;
}
try {
Expand All @@ -67,7 +67,7 @@ private void captureSystemInfo() {
}

public void captureEvent(String eventName, Map<String, Object> properties) {
if (!applicationProperties.getSystem().isAnalyticsEnabled()) {
if (!applicationProperties.getSystem().isPosthogEnabled()) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions app/core/src/main/resources/messages_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,8 @@ cookieBanner.preferencesModal.necessary.title.2=Always Enabled
cookieBanner.preferencesModal.necessary.description=These cookies are essential for the website to function properly. They enable core features like setting your privacy preferences, logging in, and filling out forms—which is why they can’t be turned off.
cookieBanner.preferencesModal.analytics.title=Analytics
cookieBanner.preferencesModal.analytics.description=These cookies help us understand how our tools are being used, so we can focus on building the features our community values most. Rest assured—Stirling PDF cannot and will never track the content of the documents you work with.
cookieBanner.preferencesModal.analytics.posthog.label=PostHog Analytics
cookieBanner.preferencesModal.analytics.scarf.label=Scarf Pixel

#scannerEffect
scannerEffect.title=Scanner Effect
Expand Down
2 changes: 2 additions & 0 deletions app/core/src/main/resources/messages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,8 @@ cookieBanner.preferencesModal.necessary.title.2=Always Enabled
cookieBanner.preferencesModal.necessary.description=These cookies are essential for the website to function properly. They enable core features like setting your privacy preferences, logging in, and filling out forms—which is why they can’t be turned off.
cookieBanner.preferencesModal.analytics.title=Analytics
cookieBanner.preferencesModal.analytics.description=These cookies help us understand how our tools are being used, so we can focus on building the features our community values most. Rest assured—Stirling PDF cannot and will never track the content of the documents you work with.
cookieBanner.preferencesModal.analytics.posthog.label=PostHog Analytics
cookieBanner.preferencesModal.analytics.scarf.label=Scarf Pixel

#scannerEffect
scannerEffect.title=Scanner Effect
Expand Down
4 changes: 3 additions & 1 deletion app/core/src/main/resources/settings.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ system:
showUpdateOnlyAdmin: false # only admins can see when a new update is available, depending on showUpdate it must be set to 'true'
customHTMLFiles: false # enable to have files placed in /customFiles/templates override the existing template HTML files
tessdataDir: /usr/share/tessdata # path to the directory containing the Tessdata files. This setting is relevant for Windows systems. For Windows users, this path should be adjusted to point to the appropriate directory where the Tessdata files are stored.
enableAnalytics: null # set to 'true' to enable analytics, set to 'false' to disable analytics; for enterprise users, this is set to true
enableAnalytics: null # Master toggle for analytics: set to 'true' to enable all analytics, 'false' to disable all analytics, or leave as 'null' to prompt admin on first launch
enablePosthog: null # Enable PostHog analytics (open-source product analytics): set to 'true' to enable, 'false' to disable, or 'null' to enable by default when analytics is enabled
enableScarf: null # Enable Scarf pixel: set to 'true' to enable, 'false' to disable, or 'null' to enable by default when analytics is enabled
enableUrlToPDF: false # Set to 'true' to enable URL to PDF, INTERNAL ONLY, known security issues, should not be used externally
disableSanitize: false # set to true to disable Sanitize HTML; (can lead to injections in HTML)
maxDPI: 500 # Maximum allowed DPI for PDF to image conversion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ import './cookieconsent.umd.js';
// Enable dark mode
document.documentElement.classList.add('cc--darkmode');

// Build analytics services dynamically based on backend config
const analyticsServices = {};
if (typeof posthogEnabled !== 'undefined' && posthogEnabled) {
analyticsServices.posthog = {
label: cookieBannerPreferencesModalPosthogLabel
};
}
if (typeof scarfEnabled !== 'undefined' && scarfEnabled) {
analyticsServices.scarf = {
label: cookieBannerPreferencesModalScarfLabel
};
}

CookieConsent.run({
guiOptions: {
consentModal: {
Expand All @@ -22,7 +35,9 @@ CookieConsent.run({
necessary: {
readOnly: true
},
analytics: {}
analytics: {
services: analyticsServices
}
},
language: {
default: "en",
Expand Down
57 changes: 48 additions & 9 deletions app/core/src/main/resources/templates/fragments/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,51 @@
<!-- Bootstrap Icons -->
<link rel="stylesheet" th:href="@{'/css/bootstrap-icons.min.css'}">

<!-- Pixel, doesn't collect any PII-->
<img th:if="${!@disablePixel}" referrerpolicy="no-referrer-when-downgrade"
th:src="'https://pixel.stirlingpdf.com/a.png?x-pxid=4f5fa02f-a065-4efb-bb2c-24509a4b6b92'
+ '&machineType=' + ${@machineType}
+ '&appVersion=' + ${@appVersion}
+ '&licenseType=' + ${@license}
+ '&loginEnabled=' + ${@loginEnabled}"
style="position: absolute; visibility: hidden;" />
<!-- Scarf Pixel - loaded dynamically based on cookie consent -->
<script th:inline="javascript">
const posthogEnabled = /*[[${@posthogEnabled}]]*/ false;
const scarfEnabled = /*[[${@scarfEnabled}]]*/ false;
const scarfPixelUrl = /*[['https://pixel.stirlingpdf.com/a.png?x-pxid=4f5fa02f-a065-4efb-bb2c-24509a4b6b92'
+ '&machineType=' + ${@machineType}
+ '&appVersion=' + ${@appVersion}
+ '&licenseType=' + ${@license}
+ '&loginEnabled=' + ${@loginEnabled}]]*/ '';

function loadScarfPixel() {
if (!scarfEnabled || !window.CookieConsent) return;

// Check if scarf service is accepted
if (window.CookieConsent.acceptedService('scarf', 'analytics')) {
// Remove any existing scarf pixel
const existingPixel = document.getElementById('scarf-pixel');
if (existingPixel) existingPixel.remove();

// Create and inject the pixel
const img = document.createElement('img');
img.id = 'scarf-pixel';
img.src = scarfPixelUrl;
img.referrerPolicy = 'no-referrer-when-downgrade';
img.style.position = 'absolute';
img.style.visibility = 'hidden';
document.body.appendChild(img);
} else {
// Remove pixel if user rejected
const existingPixel = document.getElementById('scarf-pixel');
if (existingPixel) existingPixel.remove();
}
}

// Load pixel on consent events
window.addEventListener('cc:onConsent', loadScarfPixel);
window.addEventListener('cc:onChange', loadScarfPixel);

// Try to load on page load if consent already given
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadScarfPixel);
} else {
loadScarfPixel();
}
</script>

<!-- Custom -->
<link rel="stylesheet" th:href="@{'/css/general.css'}">
Expand Down Expand Up @@ -221,7 +258,7 @@
return;
}

window.CookieConsent.acceptedCategory('analytics')?
window.CookieConsent.acceptedService('posthog', 'analytics')?
posthog.opt_in_capturing() : posthog.opt_out_capturing();
}
const stirlingPDFLabel = /*[[${@StirlingPDFLabel}]]*/ '';
Expand All @@ -248,6 +285,8 @@
const cookieBannerPreferencesModalNecessaryDescription = /*[[#{cookieBanner.preferencesModal.necessary.description}]]*/ "";
const cookieBannerPreferencesModalAnalyticsTitle = /*[[#{cookieBanner.preferencesModal.analytics.title}]]*/ "";
const cookieBannerPreferencesModalAnalyticsDescription = /*[[#{cookieBanner.preferencesModal.analytics.description}]]*/ "";
const cookieBannerPreferencesModalPosthogLabel = /*[[#{cookieBanner.preferencesModal.analytics.posthog.label}]]*/ "";
const cookieBannerPreferencesModalScarfLabel = /*[[#{cookieBanner.preferencesModal.analytics.scarf.label}]]*/ "";

if (analyticsEnabled) {
!function (t, e) {
Expand Down
Loading