-
Notifications
You must be signed in to change notification settings - Fork 312
[Facebook Pixel] - Private Beta bug fixes #3920
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
Open
joe-ayoub-segment
wants to merge
14
commits into
main
Choose a base branch
from
fix/fb-pixel-web-content-ids-default
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a716ab3
Remove broken content_ids default in Facebook Conversions API Web
joe-ayoub-segment 39a05e7
Coerce single content_ids/contents values to arrays in FB Pixel Web
joe-ayoub-segment e0560ab
Emit search_string in FB Pixel Web Search events
joe-ayoub-segment 5ddf090
Emit status in FB Pixel Web CompleteRegistration events
joe-ayoub-segment cb74cc5
Add Maryland and Rhode Island LDU options to FB Pixel Web
joe-ayoub-segment f0d34c4
Normalize field values in FB Pixel Web (trim, currency, minimums)
joe-ayoub-segment f6ad0f0
Split event_config into flat fields to fix app UI depends_on
joe-ayoub-segment bfae20d
updating to correct script file provided by FB
joe-ayoub-segment 8ff7e9d
Normalize word-form gender values in FB Pixel Web
joe-ayoub-segment aac4c07
updating types
joe-ayoub-segment d7dd166
minor bug fix
joe-ayoub-segment 6e7d3bf
Align FB Pixel field-event mappings with Meta docs
joe-ayoub-segment 05b7041
Trim string values inside contents items in FB Pixel Web
joe-ayoub-segment b11ee23
Harden validate(): whitespace content_ids + custom_event_name required
joe-ayoub-segment File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
670 changes: 320 additions & 350 deletions
670
packages/browser-destinations/destinations/facebook-conversions-api-web/metadata.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...inations/destinations/facebook-conversions-api-web/src/send/__tests__/content-ids.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { content_ids } from '../fields' | ||
| import { formatFBEvent } from '../functions' | ||
| import { Payload } from '../generated-types' | ||
|
|
||
| describe('content_ids field', () => { | ||
| describe('field definition', () => { | ||
| it('is a multiple string field', () => { | ||
| expect(content_ids.type).toBe('string') | ||
| expect(content_ids.multiple).toBe(true) | ||
| }) | ||
|
|
||
| // Regression guard: the field previously shipped a broken default that | ||
| // used the disabled Liquid `map` filter | ||
| // ({ '@liquid': "{{ properties.products | map: 'product_id' }}" }). | ||
| // That default threw / never resolved to an array, so content_ids was | ||
| // always dropped. We removed the default; customers configure it if | ||
| // needed. Do NOT reintroduce a default without verifying it resolves to | ||
| // an array of strings AND renders in the app mapping-editor UI. | ||
| it('has no default mapping', () => { | ||
| expect(content_ids.default).toBeUndefined() | ||
| }) | ||
|
|
||
| it('is gated behind the relevant event dependencies', () => { | ||
| expect(content_ids.depends_on).toBeDefined() | ||
| }) | ||
| }) | ||
|
|
||
| describe('formatFBEvent handling of content_ids', () => { | ||
| it('passes a provided array of ids through', () => { | ||
| const payload: Partial<Payload> = { | ||
| event_name: 'ViewContent', | ||
| show_fields: true, | ||
| content_ids: ['SKU-ABC-123', 'SKU-XYZ-789'] | ||
| } | ||
|
joe-ayoub-segment marked this conversation as resolved.
|
||
|
|
||
| const result = formatFBEvent(payload as Payload) | ||
|
|
||
| expect(result.content_ids).toEqual(['SKU-ABC-123', 'SKU-XYZ-789']) | ||
| }) | ||
|
|
||
| it('omits content_ids when it is an empty array', () => { | ||
| const payload: Partial<Payload> = { | ||
| event_name: 'AddToCart', | ||
| show_fields: true, | ||
| content_ids: [] | ||
| } | ||
|
|
||
| const result = formatFBEvent(payload as Payload) | ||
|
|
||
| expect(result).not.toHaveProperty('content_ids') | ||
| }) | ||
|
|
||
| it('omits content_ids when it is absent', () => { | ||
| const payload: Partial<Payload> = { | ||
| event_name: 'Purchase', | ||
| show_fields: true, | ||
| value: 45.97 | ||
| } | ||
|
|
||
| const result = formatFBEvent(payload as Payload) | ||
|
|
||
| expect(result).not.toHaveProperty('content_ids') | ||
| }) | ||
| }) | ||
| }) | ||
71 changes: 49 additions & 22 deletions
71
...tinations/destinations/facebook-conversions-api-web/src/send/__tests__/depends-on.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,55 @@ | ||
| import { getDependenciesFor } from '../depends-on' | ||
|
|
||
| describe('depends-on getDependenciesFor', () => { | ||
| test('returns correct depends_on rules', () => { | ||
| test('multi-event field includes show_fields plus one condition per event', () => { | ||
| const result = getDependenciesFor('delivery_category') | ||
| expect(true).toBe(true) | ||
| expect(result.match).toBe('any') | ||
| expect(result.conditions).toEqual( | ||
| [ | ||
| { | ||
| fieldKey: 'event_config.show_fields', | ||
| operator: 'is', | ||
| value: 'true' | ||
| }, | ||
| { | ||
| fieldKey: 'event_config.event_name', | ||
| operator: 'is', | ||
| value: 'Purchase' | ||
| }, | ||
| { | ||
| fieldKey: 'event_config.event_name', | ||
| operator: 'is', | ||
| value: 'InitiateCheckout' | ||
| } | ||
| ] | ||
| ) | ||
| }) | ||
| expect(result.conditions).toEqual([ | ||
| { | ||
| fieldKey: 'show_fields', | ||
| operator: 'is', | ||
| value: true | ||
| }, | ||
| { | ||
| fieldKey: 'event_name', | ||
| operator: 'is', | ||
| value: 'Purchase' | ||
| }, | ||
| { | ||
| fieldKey: 'event_name', | ||
| operator: 'is', | ||
| value: 'InitiateCheckout' | ||
| } | ||
| ]) | ||
| }) | ||
|
|
||
| test('single-event field still includes its event condition', () => { | ||
| // status is relevant to exactly one event (CompleteRegistration); it must | ||
| // still gate on that event, not only on show_fields. | ||
| const result = getDependenciesFor('status') | ||
| expect(result.match).toBe('any') | ||
| expect(result.conditions).toEqual([ | ||
| { fieldKey: 'show_fields', operator: 'is', value: true }, | ||
| { fieldKey: 'event_name', operator: 'is', value: 'CompleteRegistration' } | ||
| ]) | ||
| }) | ||
|
|
||
| test('custom_event_name gates on show_fields and the CustomEvent event', () => { | ||
| const result = getDependenciesFor('custom_event_name') | ||
| expect(result.conditions).toEqual([ | ||
| { fieldKey: 'show_fields', operator: 'is', value: true }, | ||
| { fieldKey: 'event_name', operator: 'is', value: 'CustomEvent' } | ||
| ]) | ||
| }) | ||
|
|
||
| test('show_fields condition uses a boolean value, not the string "true"', () => { | ||
| const result = getDependenciesFor('status') | ||
| const showFieldsCondition = result.conditions.find((c) => 'fieldKey' in c && c.fieldKey === 'show_fields') | ||
| expect(showFieldsCondition).toEqual({ fieldKey: 'show_fields', operator: 'is', value: true }) | ||
| }) | ||
|
|
||
| test('unknown field returns only the show_fields condition', () => { | ||
| const result = getDependenciesFor('not_a_real_field') | ||
| expect(result.conditions).toEqual([{ fieldKey: 'show_fields', operator: 'is', value: true }]) | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.