|
6 | 6 | # Add argument parsing |
7 | 7 | parser = argparse.ArgumentParser(description="PostHog Python library example") |
8 | 8 | parser.add_argument( |
9 | | - "--flag", default="person-on-events-enabled", help="Feature flag key to check (default: person-on-events-enabled)" |
| 9 | + "--flag", |
| 10 | + default="person-on-events-enabled", |
| 11 | + help="Feature flag key to check (default: person-on-events-enabled)", |
10 | 12 | ) |
11 | 13 | args = parser.parse_args() |
12 | 14 |
|
|
38 | 40 |
|
39 | 41 |
|
40 | 42 | # Capture an event |
41 | | -posthog.capture("distinct_id", "event", {"property1": "value", "property2": "value"}, send_feature_flags=True) |
| 43 | +posthog.capture( |
| 44 | + "distinct_id", |
| 45 | + "event", |
| 46 | + {"property1": "value", "property2": "value"}, |
| 47 | + send_feature_flags=True, |
| 48 | +) |
42 | 49 |
|
43 | 50 | print(posthog.feature_enabled("beta-feature", "distinct_id")) |
44 | | -print(posthog.feature_enabled("beta-feature-groups", "distinct_id", groups={"company": "id:5"})) |
| 51 | +print( |
| 52 | + posthog.feature_enabled( |
| 53 | + "beta-feature-groups", "distinct_id", groups={"company": "id:5"} |
| 54 | + ) |
| 55 | +) |
45 | 56 |
|
46 | 57 | print(posthog.feature_enabled("beta-feature", "distinct_id")) |
47 | 58 |
|
|
53 | 64 |
|
54 | 65 | posthog.alias("distinct_id", "new_distinct_id") |
55 | 66 |
|
56 | | -posthog.capture("new_distinct_id", "event2", {"property1": "value", "property2": "value"}) |
57 | 67 | posthog.capture( |
58 | | - "new_distinct_id", "event-with-groups", {"property1": "value", "property2": "value"}, groups={"company": "id:5"} |
| 68 | + "new_distinct_id", "event2", {"property1": "value", "property2": "value"} |
| 69 | +) |
| 70 | +posthog.capture( |
| 71 | + "new_distinct_id", |
| 72 | + "event-with-groups", |
| 73 | + {"property1": "value", "property2": "value"}, |
| 74 | + groups={"company": "id:5"}, |
59 | 75 | ) |
60 | 76 |
|
61 | 77 | # # Add properties to the person |
|
82 | 98 | # Local Evaluation |
83 | 99 |
|
84 | 100 | # If flag has City=Sydney, this call doesn't go to `/decide` |
85 | | -print(posthog.feature_enabled("test-flag", "distinct_id_random_22", person_properties={"$geoip_city_name": "Sydney"})) |
| 101 | +print( |
| 102 | + posthog.feature_enabled( |
| 103 | + "test-flag", |
| 104 | + "distinct_id_random_22", |
| 105 | + person_properties={"$geoip_city_name": "Sydney"}, |
| 106 | + ) |
| 107 | +) |
86 | 108 |
|
87 | 109 | print( |
88 | 110 | posthog.feature_enabled( |
|
98 | 120 | print(posthog.get_all_flags("distinct_id_random_22", only_evaluate_locally=True)) |
99 | 121 | print( |
100 | 122 | posthog.get_all_flags( |
101 | | - "distinct_id_random_22", person_properties={"$geoip_city_name": "Sydney"}, only_evaluate_locally=True |
| 123 | + "distinct_id_random_22", |
| 124 | + person_properties={"$geoip_city_name": "Sydney"}, |
| 125 | + only_evaluate_locally=True, |
102 | 126 | ) |
103 | 127 | ) |
104 | 128 | print(posthog.get_remote_config_payload("encrypted_payload_flag_key")) |
|
0 commit comments