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 query string bug #888

Merged
merged 6 commits into from
Jul 20, 2023
Merged

Fix query string bug #888

merged 6 commits into from
Jul 20, 2023

Conversation

danieljackins
Copy link
Contributor

@danieljackins danieljackins commented Jul 13, 2023

  • Since we started looking at the ctx object for the query string, if a user passed in an object for the 'search' key an error would be thrown from trying to parse a string. This was causing these events to be dropped.

  • Only override context.page with event properties on page calls

[] I've included a changeset (psst. run yarn changeset. Read about changesets here).

@changeset-bot
Copy link

changeset-bot bot commented Jul 13, 2023

🦋 Changeset detected

Latest commit: d456302

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@silesky
Copy link
Contributor

silesky commented Jul 13, 2023

@danieljackins page.search should always be a string https://segment.com/docs/connections/spec/page/#properties?
While this stops errors from being thrown, I don't think this exactly solves the underlying issue around track event.properties overriding page (which is actually the issue, I think)

@danieljackins
Copy link
Contributor Author

@danieljackins this should always be a string https://segment.com/docs/connections/spec/page/#properties? I am not sure this is exactly what we want

Right, but this bug report was from a customer who was passing in an object to it in analytics-classic (and older versions of analytics-next) successfully.

@danieljackins danieljackins marked this pull request as draft July 13, 2023 18:46
@@ -131,7 +131,8 @@ export function normalize(
const ctx = json.context

// This guard against missing ctx.page should not be neccessary, since context.page is always defined
const query: string = ctx.page?.search || ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure where we set search for ourselves, but if it's internal maybe we should try putting our stuff in a particular nested object internal? or use _search ?

@danieljackins danieljackins marked this pull request as ready for review July 18, 2023 17:07
@@ -131,7 +131,8 @@ export function normalize(
const ctx = json.context

// This guard against missing ctx.page should not be neccessary, since context.page is always defined
const query: string = ctx.page?.search || ''
const query: string =
typeof ctx.page?.search === 'string' ? ctx.page?.search : ''
Copy link
Contributor

@silesky silesky Jul 19, 2023

Choose a reason for hiding this comment

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

This behavior needs a test, correct? 'Page calls should be able to accept search as an object.'

@danieljackins danieljackins merged commit f3183f2 into master Jul 20, 2023
@danieljackins danieljackins deleted the query-bug branch July 20, 2023 16:33
@github-actions github-actions bot mentioned this pull request Jul 20, 2023
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.

3 participants