Skip to content

Commit

Permalink
feat: Deprecate sanitize_properties (#1632)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeelaudibert authored Jan 6, 2025
1 parent baa8aa7 commit 1f5680d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ export class PostHog {

const sanitize_properties = this.config.sanitize_properties
if (sanitize_properties) {
logger.error('sanitize_properties is deprecated. Use before_send instead')
properties = sanitize_properties(properties, event_name)
}

Expand All @@ -1064,6 +1065,7 @@ export class PostHog {
let setOnceProperties = extend({}, this.persistence.get_initial_props(), dataSetOnce || {})
const sanitize_properties = this.config.sanitize_properties
if (sanitize_properties) {
logger.error('sanitize_properties is deprecated. Use before_send instead')
setOnceProperties = sanitize_properties(setOnceProperties, '$set_once')
}
if (isEmptyObject(setOnceProperties)) {
Expand Down
14 changes: 8 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ export interface PostHogConfig {
inapp_protocol: string
inapp_link_new_window: boolean
request_batching: boolean
sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null
properties_string_max_length: number
session_recording: SessionRecordingOptions
session_idle_timeout_seconds: number
Expand All @@ -291,6 +290,13 @@ export interface PostHogConfig {
feature_flag_request_timeout_ms: number
get_device_id: (uuid: string) => string
name: string

/**
* This function is called when collecting properties for an event.
* It allows you to edit data before it is sent
* @deprecated - use `before_send` instead
*/
sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null
/**
* this is a read-only function that can be used to react to event capture
* @deprecated - use `before_send` instead - NB before_send is not read only
Expand Down Expand Up @@ -527,11 +533,7 @@ export interface RemoteConfig {
}
elementsChainAsString?: boolean
// this is currently in development and may have breaking changes without a major version bump
autocaptureExceptions?:
| boolean
| {
endpoint?: string
}
autocaptureExceptions?: boolean | { endpoint?: string }
sessionRecording?: SessionRecordingCanvasOptions & {
endpoint?: string
consoleLogRecordingEnabled?: boolean
Expand Down

0 comments on commit 1f5680d

Please sign in to comment.