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

Function whenPixelLoads

packages/webapp/context/PixelsContext.tsx:33–50  ·  view source on GitHub ↗
(
  getTracker: () => Tracker | undefined,
  send: (tracker: Tracker) => void,
  triesLeft = PIXEL_WAIT_TRIES,
)

Source from the content-addressed store, hash-verified

31
32// Each pixel loads on its own, so each one waits for its own script
33const whenPixelLoads = (
34 getTracker: () => Tracker | undefined,
35 send: (tracker: Tracker) => void,
36 triesLeft = PIXEL_WAIT_TRIES,
37) => {
38 const tracker = getTracker();
39 if (typeof tracker === 'function') {
40 send(tracker);
41 return;
42 }
43
44 if (triesLeft > 0) {
45 setTimeout(
46 () => whenPixelLoads(getTracker, send, triesLeft - 1),
47 PIXEL_WAIT_MS,
48 );
49 }
50};
51
52interface PixelsContextProviderProps {
53 children: ReactElement;

Callers 1

sendEventFunction · 0.85

Calls 1

sendFunction · 0.85

Tested by

no test coverage detected