MCPcopy Create free account
hub / github.com/dailydotdev/apps / sendEvent

Function sendEvent

packages/webapp/context/PixelsContext.tsx:56–94  ·  view source on GitHub ↗
(
  eventName,
  params,
  options,
)

Source from the content-addressed store, hash-verified

54}
55
56const 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
96function WebPixelsProvider({
97 children,

Callers 1

trackEventFunction · 0.85

Calls 2

whenPixelLoadsFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected