Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Add organization ID to analytics payloads #9643

Merged
merged 7 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ def _init_factories(self) -> None:

def _init_analytics(self) -> None:
init_analytics(
user_id=None,
data_context_id=uuid.UUID(self._data_context_id),
organization_id=None,
oss_id=self._get_oss_id(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ def _check_if_latest_version(self) -> None:

@override
def _init_analytics(self) -> None:
organization_id = self.ge_cloud_config.organization_id
init_analytics(
user_id=self._get_cloud_user_id(),
data_context_id=uuid.UUID(self._data_context_id),
organization_id=uuid.UUID(organization_id) if organization_id else None,
oss_id=self._get_oss_id(),
cloud_mode=True,
)
Expand Down
7 changes: 5 additions & 2 deletions tests/analytics/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def test_ephemeral_context_init(monkeypatch):
) as mock_init, mock.patch("posthog.capture") as mock_submit:
_ = gx.get_context(mode="ephemeral")

mock_init.assert_called_once_with(data_context_id=mock.ANY, oss_id=mock.ANY)
mock_init.assert_called_once_with(
data_context_id=mock.ANY, organization_id=None, oss_id=mock.ANY, user_id=None
)
mock_submit.assert_called_once_with(
mock.ANY,
"data_context.initialized",
Expand All @@ -109,7 +111,8 @@ def test_cloud_context_init(cloud_api_fake, cloud_details, monkeypatch):

mock_init.assert_called_once_with(
user_id=UUID(FAKE_USER_ID), # Should be consistent with the fake Cloud API
data_context_id=mock.ANY,
data_context_id=UUID(cloud_details.org_id),
organization_id=cloud_details.org_id,
oss_id=mock.ANY,
cloud_mode=True,
)
Expand Down