Skip to content

Commit

Permalink
feat: Add better npm import, and script entrypoint for customizations (
Browse files Browse the repository at this point in the history
…#1550)

* Add better npm import, and script entrypoint for customizations

* Revert move to /lib rather than /lib/src
  • Loading branch information
robbie-c authored Nov 26, 2024
1 parent f71a829 commit 45016d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion playground/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useActiveFeatureFlags, usePostHog } from 'posthog-js/react'
import { useEffect, useState } from 'react'
import { cookieConsentGiven, PERSON_PROCESSING_MODE } from '@/src/posthog'
import { setAllPersonProfilePropertiesAsPersonPropertiesForFlags } from 'posthog-js/lib/src/customizations/setAllPersonProfilePropertiesAsPersonPropertiesForFlags'
import { setAllPersonProfilePropertiesAsPersonPropertiesForFlags } from 'posthog-js/lib/src/customizations'
import { STORED_PERSON_PROPERTIES_KEY } from '../../../src/constants'

export default function Home() {
Expand Down
2 changes: 2 additions & 0 deletions src/customizations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './setAllPersonProfilePropertiesAsPersonPropertiesForFlags'
export * from './before-send'
7 changes: 7 additions & 0 deletions src/entrypoints/customizations.full.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// this file is called customizations.full.ts because it includes all customizations
// this naming scheme allows us to create a lighter version in the future with only the most popular customizations
// without breaking backwards compatibility

import * as customizations from '../customizations'
import { assignableWindow } from '../utils/globals'
assignableWindow.posthogCustomizations = customizations
2 changes: 1 addition & 1 deletion src/posthog-persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class PostHogPersistence {
const campaignParams = Info.campaignParams(this.config.custom_campaign_params)
// only save campaign params if there were any
if (!isEmptyObject(stripEmptyProperties(campaignParams))) {
this.register(Info.campaignParams(this.config.custom_campaign_params))
this.register(campaignParams)
}
this.campaign_params_saved = true
}
Expand Down

0 comments on commit 45016d5

Please sign in to comment.