Skip to content

Commit 8040964

Browse files
committed
Add set and set_once to simulator.py
1 parent 45303b8 commit 8040964

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ Specifically, the [Python integration](https://posthog.com/docs/integrations/pyt
88

99
### [Join our Slack community.](https://join.slack.com/t/posthogusers/shared_invite/enQtOTY0MzU5NjAwMDY3LTc2MWQ0OTZlNjhkODk3ZDI3NDVjMDE1YjgxY2I4ZjI4MzJhZmVmNjJkN2NmMGJmMzc2N2U3Yjc3ZjI5NGFlZDQ)
1010

11-
# Running & Testing Locally
11+
# Local Development
12+
13+
## Testing Locally
1214

1315
1. Run `python3 -m venv env` (creates virtual environment called "env")
1416
2. Run `source env/bin/activate` (activates the virtual environment)
1517
3. Run `python3 -m pip install -e ".[test]"` (installs the package in develop mode, along with test dependencies)
1618
4. Run `make test`
19+
20+
## Running Locally
21+
22+
Assuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.

simulator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ def set_once():
7979
)
8080

8181

82+
def set():
83+
posthog.set(
84+
options.distinct_id,
85+
properties=json_hash(options.traits),
86+
context=json_hash(options.context),
87+
)
88+
8289
def unknown():
8390
print()
8491

@@ -92,7 +99,7 @@ def unknown():
9299
ch.setLevel(logging.DEBUG)
93100
log.addHandler(ch)
94101

95-
switcher = {"capture": capture, "page": page, "identify": identify}
102+
switcher = {"capture": capture, "page": page, "identify": identify, "set_once": set_once, "set": set}
96103

97104
func = switcher.get(options.type)
98105
if func:

0 commit comments

Comments
 (0)