Skip to content

Commit

Permalink
Add better npm import, and script entrypoint for customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Nov 25, 2024
1 parent 92bb3e6 commit 066bdde
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 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/customizations'
import { STORED_PERSON_PROPERTIES_KEY } from '../../../src/constants'

export default function Home() {
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const entrypointTargets = entrypoints.map((file) => {
const typeTargets = entrypoints
.filter((file) => file.endsWith('.es.ts'))
.map((file) => {
const source = `./lib/src/entrypoints/${file.replace('.ts', '.d.ts')}`
const source = `./lib/entrypoints/${file.replace('.ts', '.d.ts')}`
/** @type {import('rollup').RollupOptions} */
return {
input: source,
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
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib",
"target": "ES5",
"lib": ["dom", "dom.iterable", "esnext"],
Expand Down

0 comments on commit 066bdde

Please sign in to comment.