Skip to content

Commit 8bfa95c

Browse files
committed
[web-console] Add Scarf Pixel to track OSS usage
Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
1 parent d3e2788 commit 8bfa95c

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

.github/workflows/build-rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77
CARGO_FLAGS: "--release --locked --all-targets"
88
CARGO_FEATURES_BASE: "fips,pubsub-emulator-test,iceberg-tests-fs,iceberg-tests-glue"
99
FELDERA_PLATFORM_VERSION_SUFFIX: ${{ github.sha }}
10+
FELDERA_BUILD_ORIGIN: ci
1011
RUSTC_WRAPPER: sccache
1112
SCCACHE_CACHE_SIZE: ${{ vars.SCCACHE_CACHE_SIZE }}
1213
SCCACHE_BUCKET: ${{ vars.SCCACHE_BUCKET }}

crates/pipeline-manager/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
100100
println!("cargo:rerun-if-env-changed=FELDERA_PLATFORM_VERSION_SUFFIX");
101101
println!("cargo:rustc-env=FELDERA_PLATFORM_VERSION_SUFFIX={platform_version_suffix}");
102102

103+
// Capture build source (ci vs source)
104+
let build_source = env::var("FELDERA_BUILD_ORIGIN").unwrap_or("source".to_string());
105+
println!("cargo:rerun-if-env-changed=FELDERA_BUILD_ORIGIN");
106+
println!("cargo:rustc-env=FELDERA_BUILD_ORIGIN={build_source}");
107+
103108
let build = BuildBuilder::default().build_timestamp(true).build()?;
104109
let cargo = CargoBuilder::all_cargo()?;
105110
let gitcl = GitclBuilder::default().sha(false).dirty(false).build()?;

crates/pipeline-manager/src/api/endpoints/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ pub(crate) struct Configuration {
8989
pub update_info: Option<UpdateInformation>,
9090
/// Information about the build environment
9191
pub build_info: BuildInformation,
92+
/// Build source: "ci" for GitHub Actions builds, "source" for local builds
93+
pub build_source: String,
9294
}
9395

9496
impl Configuration {
@@ -124,6 +126,7 @@ impl Configuration {
124126
license_validity: license_check.map(|v| v.check_outcome),
125127
update_info: None,
126128
build_info: BuildInformation::from_env(),
129+
build_source: env!("FELDERA_BUILD_ORIGIN").to_string(),
127130
}
128131
}
129132
}

js-packages/web-console/src/lib/services/manager/types.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ export type Condition = {
409409

410410
export type Configuration = {
411411
build_info: BuildInformation
412+
/**
413+
* Build source: "ci" for GitHub Actions builds, "source" for local builds
414+
*/
415+
build_source: string
412416
/**
413417
* URL that navigates to the changelog of the current version
414418
*/

js-packages/web-console/src/routes/+layout.svelte

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@
2626
afterNavigate(() => posthog.capture('$pageview'))
2727
}
2828
29+
// Scarf.sh tracking for OSS deployments
30+
// Only track Open source edition (excludes Enterprise builds)
31+
const shouldTrack = $derived(
32+
browser && page.data.feldera?.config?.edition === 'Open source'
33+
)
34+
const scarfPixelId = 'c5e8a21a-5f5a-424d-81c4-5ded97174900'
35+
const scarfTrackingUrl = $derived(
36+
shouldTrack
37+
? `https://static.scarf.sh/a.png?x-pxid=${scarfPixelId}&version=${encodeURIComponent(page.data.feldera!.config!.version)}&build_source=${encodeURIComponent(page.data.feldera!.config!.build_source)}`
38+
: ''
39+
)
40+
2941
const { upsert } = useSystemMessages()
3042
useInterval(() => {
3143
if (!page.data.feldera) {
@@ -44,6 +56,10 @@
4456
<Toaster position={'bottom-right'} toastOptions={{}}></Toaster>
4557
{@render children?.()}
4658

59+
{#if shouldTrack}
60+
<img src={scarfTrackingUrl} alt="" aria-hidden="true" style="display: none;" />
61+
{/if}
62+
4763
<style lang="scss" global>
4864
.toast-error {
4965
@apply top-auto bottom-8 bg-error-50-950;

openapi.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6892,12 +6892,17 @@
68926892
"revision",
68936893
"runtime_revision",
68946894
"changelog_url",
6895-
"build_info"
6895+
"build_info",
6896+
"build_source"
68966897
],
68976898
"properties": {
68986899
"build_info": {
68996900
"$ref": "#/components/schemas/BuildInformation"
69006901
},
6902+
"build_source": {
6903+
"type": "string",
6904+
"description": "Build source: \"ci\" for GitHub Actions builds, \"source\" for local builds"
6905+
},
69016906
"changelog_url": {
69026907
"type": "string",
69036908
"description": "URL that navigates to the changelog of the current version"

0 commit comments

Comments
 (0)