( eventName, params, options, )
| 54 | } |
| 55 | |
| 56 | const sendEvent: PixelsContextData['trackEvent'] = ( |
| 57 | eventName, |
| 58 | params, |
| 59 | options, |
| 60 | ) => { |
| 61 | whenPixelLoads( |
| 62 | () => pixels.gtag, |
| 63 | (gtag) => gtag('event', eventName.replace(/ /g, '_').toLowerCase()), |
| 64 | ); |
| 65 | whenPixelLoads( |
| 66 | () => pixels.fbq, |
| 67 | (fbq) => |
| 68 | fbq( |
| 69 | 'track', |
| 70 | eventName, |
| 71 | params, |
| 72 | options?.eventId ? { eventID: options.eventId } : undefined, |
| 73 | ), |
| 74 | ); |
| 75 | if (options?.xEventId) { |
| 76 | const xParams: Record<string, unknown> = {}; |
| 77 | if (typeof params?.value === 'number') { |
| 78 | xParams.value = params.value; |
| 79 | } |
| 80 | if (params?.currency) { |
| 81 | xParams.currency = params.currency; |
| 82 | } |
| 83 | if (options.eventId) { |
| 84 | xParams.conversion_id = options.eventId; |
| 85 | } |
| 86 | if (options.email) { |
| 87 | xParams.email_address = options.email; |
| 88 | } |
| 89 | whenPixelLoads( |
| 90 | () => pixels.twq, |
| 91 | (twq) => twq('event', options.xEventId, xParams), |
| 92 | ); |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | function WebPixelsProvider({ |
| 97 | children, |
no test coverage detected