Skip to content

Commit

Permalink
fix: processEvent for site apps (#27020)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Dec 19, 2024
1 parent 43defa9 commit 1b9b3e0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 6 additions & 2 deletions posthog/cdp/site_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,13 @@ def get_transpiled_function(hog_function: HogFunction) -> str:
callback(true);
}
return {
processEvent: (globals) => processEvent(globals, posthog)
const response = {}
if (processEvent) {
response.processEvent = (globals) => processEvent(globals, posthog)
}
return response
}
return { init: init };"""
Expand Down
8 changes: 6 additions & 2 deletions posthog/cdp/test/test_site_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ def test_get_transpiled_function_basic(self):
callback(true);
}
return {
processEvent: (globals) => processEvent(globals, posthog)
const response = {}
if (processEvent) {
response.processEvent = (globals) => processEvent(globals, posthog)
}
return response
}
return { init: init };
Expand Down
16 changes: 12 additions & 4 deletions posthog/models/test/test_remote_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,13 @@ def test_renders_js_including_site_functions(self):
callback(true);
}
return {
processEvent: (globals) => processEvent(globals, posthog)
const response = {}
if (processEvent) {
response.processEvent = (globals) => processEvent(globals, posthog)
}
return response
}
return { init: init };
Expand Down Expand Up @@ -793,9 +797,13 @@ def test_renders_js_including_site_functions(self):
callback(true);
}
return {
processEvent: (globals) => processEvent(globals, posthog)
const response = {}
if (processEvent) {
response.processEvent = (globals) => processEvent(globals, posthog)
}
return response
}
return { init: init };
Expand Down

0 comments on commit 1b9b3e0

Please sign in to comment.