Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add better npm import, and script entrypoint for customizations #1550

Merged
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry should have commented here


it's a big size bump for a convenience change...

i guess they're either not pure or rollup isn't detecting them as pure...

need some kind of /@NO_SIDE_EFFECTS/ marker somewhere so that these are only available in NPM not in the bundles?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the size bump tells me that this hasn't worked as expected.

I'll look into it

Apologies for the premature tagging for review

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I removed the tsconfig change, and this seems to have prevented the increase in bundle size. I'll figure this part out separately.

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by, saw this could be smaller

}
this.campaign_params_saved = true
}
Expand Down
Loading