Skip to content

Fix: guard against undefined conversionValue#15

Open
ZLeventer wants to merge 1 commit intolinkedin-developers:mainfrom
ZLeventer:fix/undefined-conversion-value
Open

Fix: guard against undefined conversionValue#15
ZLeventer wants to merge 1 commit intolinkedin-developers:mainfrom
ZLeventer:fix/undefined-conversion-value

Conversation

@ZLeventer
Copy link
Copy Markdown

Summary

  • Fixes CAPI tag throws error if conversionValue is undefined #14JSON.parse(data.conversionValue) crashes when conversionValue is undefined
  • Changed from JSON.parse(data.conversionValue) || { ... } to a ternary check: data.conversionValue ? JSON.parse(data.conversionValue) : { ... }
  • The fallback object with currencyCode and amount is now used correctly when no conversion value is provided

Test plan

  • Deploy tag to a GTM container without setting conversionValue
  • Verify the tag fires without errors and uses the fallback currency/amount values
  • Verify existing behavior is unchanged when conversionValue is provided

…pers#14)

Guard against undefined conversionValue before calling JSON.parse to
prevent the tag from throwing when no conversion value is provided.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

CAPI tag throws error if conversionValue is undefined

1 participant