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
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/neat-emus-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@segment/analytics-next': patch
---

Fix query string parsing bug that was causing events containing the 'search' property with a non string value to be dropped
3 changes: 2 additions & 1 deletion packages/browser/src/plugins/segmentio/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?

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.'


delete json.options
json.writeKey = settings?.apiKey
Expand Down