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

fix: capture customLabelProp if set #302

Merged
merged 5 commits into from
Nov 5, 2024
Merged

Conversation

marandaneto
Copy link
Member

@marandaneto marandaneto commented Nov 4, 2024

Problem

Closes #301

Screenshot 2024-11-04 at 12 25 38

Changes

Release info Sub-libraries affected

Bump level

  • Major
  • Minor
  • Patch

Libraries affected

  • All of them
  • posthog-web
  • posthog-node
  • posthog-react-native

Changelog notes

  • Added support for X

Copy link

github-actions bot commented Nov 4, 2024

Size Change: +84 B (+0.08%)

Total Size: 106 kB

Filename Size Change
posthog-react-native/lib/posthog-react-native/src/autocapture.js 1.78 kB +3 B (+0.17%)
posthog-react-native/lib/posthog-react-native/src/PostHogProvider.js 1.57 kB +81 B (+5.44%) 🔍
ℹ️ View Unchanged
Filename Size
posthog-node/lib/index.cjs.js 20 kB
posthog-node/lib/index.esm.js 20 kB
posthog-react-native/lib/posthog-core/src/eventemitter.js 1.08 kB
posthog-react-native/lib/posthog-core/src/index.js 9.72 kB
posthog-react-native/lib/posthog-core/src/lz-string.js 1.42 kB
posthog-react-native/lib/posthog-core/src/types.js 365 B
posthog-react-native/lib/posthog-core/src/utils.js 822 B
posthog-react-native/lib/posthog-core/src/vendor/uuidv7.js 2.04 kB
posthog-react-native/lib/posthog-react-native/index.js 485 B
posthog-react-native/lib/posthog-react-native/src/frameworks/wix-navigation.js 651 B
posthog-react-native/lib/posthog-react-native/src/hooks/useFeatureFlag.js 437 B
posthog-react-native/lib/posthog-react-native/src/hooks/useFeatureFlags.js 362 B
posthog-react-native/lib/posthog-react-native/src/hooks/useLifecycleTracker.js 416 B
posthog-react-native/lib/posthog-react-native/src/hooks/useNavigationTracker.js 628 B
posthog-react-native/lib/posthog-react-native/src/hooks/usePostHog.js 249 B
posthog-react-native/lib/posthog-react-native/src/legacy.js 810 B
posthog-react-native/lib/posthog-react-native/src/native-deps.js 1.17 kB
posthog-react-native/lib/posthog-react-native/src/optional/OptionalAsyncStorage.js 183 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoApplication.js 215 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoDevice.js 211 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoFileSystem.js 224 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalExpoLocalization.js 216 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalReactNativeDeviceInfo.js 220 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalReactNativeNavigation.js 218 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalReactNativeNavigationWix.js 222 B
posthog-react-native/lib/posthog-react-native/src/optional/OptionalSessionReplay.js 231 B
posthog-react-native/lib/posthog-react-native/src/posthog-rn.js 4.01 kB
posthog-react-native/lib/posthog-react-native/src/PostHogContext.js 210 B
posthog-react-native/lib/posthog-react-native/src/storage.js 1.09 kB
posthog-react-native/lib/posthog-react-native/src/types.js 90 B
posthog-react-native/lib/posthog-react-native/src/version.js 123 B
posthog-web/lib/index.cjs.js 17.1 kB
posthog-web/lib/index.esm.js 17.1 kB

compressed-size-action

@@ -91,7 +93,7 @@ export const PostHogProvider = ({

return (
<View
ph-label="PostHogProvider"
{...{ [phLabelProp]: 'PostHogProvider' }} // Dynamically setting customLabelProp (default: ph-label)
Copy link
Member Author

Choose a reason for hiding this comment

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

that is chatgpt code :D

@marandaneto marandaneto requested a review from a team November 4, 2024 10:58
@marandaneto marandaneto marked this pull request as ready for review November 4, 2024 10:59
const elAttrLabelKey = `attr__${customLabelProp}`
let lastLabel: string | undefined = undefined

for (let i = elements.length - 1; i >= 0; i--) {
const element = elements[i]
if (element[elAttrLabelKey]) {
// this element had a ph-label set, promote it to the lastLabel
// this element had a customLabelProp (default: ph-label) set, promote it to the lastLabel
Copy link

Choose a reason for hiding this comment

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

Can't we just iterate over normally here with early exit instead of reverse?

Copy link
Member Author

Choose a reason for hiding this comment

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

the reason why it is reversed is in the comment above.
I'd not change what's working already as well, the change is about using the wrong label name only.

Copy link

@ioannisj ioannisj left a comment

Choose a reason for hiding this comment

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

looks good :)

@marandaneto marandaneto merged commit ae60ef4 into main Nov 5, 2024
4 checks passed
@marandaneto marandaneto deleted the fix/customLabelProp branch November 5, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

posthog-react-native 3.3.9: customLabelProp doesn't change prop name
2 participants