Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(property-defs): skip definitions for per-device push subscription properties (#108388)

Daniel Marchuk67cb9cc455e4
diff --git a/rust/property-defs-rs/src/types.rs b/rust/property-defs-rs/src/types.rs
index 07cafbb71504..e6f2cbfb7660 100644
--- a/rust/property-defs-rs/src/types.rs
+++ b/rust/property-defs-rs/src/types.rs
@@ -79,6 +79,12 @@ pub const SKIP_PROPERTIES: [&str; 9] = [
// rare cases it arrives as a top-level event property, and carries little cardinality weight.
pub const SKIP_EVENT_PROPERTY_PREFIXES: [&str; 2] = ["$feature/", "$feature_enrollment/"];
+// Person property prefixes that should NOT generate PropertyDefinition rows. A push
+// subscription is stored under one person property per device, and the key embeds a hash of
+// the device token, so every registered device would otherwise add a definition that only
+// names one device and clutters the property picker.
+pub const SKIP_PERSON_PROPERTY_DEFINITION_PREFIXES: [&str; 1] = ["$device_push_subscription_"];
+
// "timestamp" is deliberately absent: any key that contains it already contains "time".
const DATETIME_PROPERTY_NAME_KEYWORDS: [&str; 6] =
["time", "date", "_at", "-at", "createdat", "updatedat"];
@@ -355,6 +361,19 @@ impl Event {
continue;
}
+ if parent_type == PropertyParentType::Person
+ && SKIP_PERSON_PROPERTY_DEFINITION_PREFIXES
+ .iter()
+ .any(|prefix| key.starts_with(prefix))
+ {
+ metrics::counter!(
+ UPDATES_SKIPPED,
+ &[("reason", "push_subscription_person_property")]
+ )
+ .increment(1);
+ continue;
+ }
+
if !will_fit_in_postgres_column(key) {
let skipped = if parent_type == PropertyParentType::Event {
2 // EventProperty + PropertyDefinition
diff --git a/rust/property-defs-rs/tests/types.rs b/rust/property-defs-rs/tests/types.rs
index 5ee36e97ed50..bbfe20f56fed 100644
--- a/rust/property-defs-rs/tests/types.rs
+++ b/rust/property-defs-rs/tests/types.rs
@@ -947,3 +947,35 @@ fn test_feature_flag_properties_skip_event_property_but_keep_property_definition
"expected PropertyDefinition for '{flagged_key}': {prop_def_names:?}"
);
}
+
+#[rstest]
+#[case("$set")]
+#[case("$set_once")]
+fn test_push_subscription_person_properties_skip_property_definition(#[case] operation: &str) {
+ let props = json!({
+ operation: {
+ "$device_push_subscription_my-app": "encrypted-token",
+ "$device_push_subscription_my-app:0123456789abcdef": "encrypted-token",
+ "email": "[email protected]"
+ }
+ });
+ let event = Event {
+ team_id: 1,
+ project_id: 1,
+ event: "$set".to_string(),
+ properties: Some(props.to_string()),
+ };
+
+ let updates = event.into_updates(1000);
+
+ let person_definitions: Vec<&str> = updates
+ .iter()
+ .filter_map(|u| match u {
+ Update::Property(pd) if pd.event_type == PropertyParentType::Person => {
+ Some(pd.name.as_str())
+ }
+ _ => None,
+ })
+ .collect();
+ assert_eq!(person_definitions, vec!["email"]);
+}