def demo(request: Request): user = request.user organization = user.organization try: team = organization.teams.get(is_demo=True) except Team.DoesNotExist: team = create_demo_team(organization, user, request) user.current_team = team user.save() if "$pageview" not in team.event_names: team.event_names.append("$pageview") team.event_names_with_usage.append({ "event": "$pageview", "usage_count": None, "volume": None }) team.save() if is_ee_enabled(): # :TRICKY: Lazily backfill missing event data. from ee.clickhouse.models.event import get_events_by_team result = get_events_by_team(team_id=team.pk) if not result: create_demo_data(team, dashboards=False) return render_template("demo.html", request=request, context={"api_token": team.api_token})
def demo(request: Request): user = cast(User, request.user) organization = user.organization if not organization: raise AttributeError("This user has no organization.") try: team = organization.teams.get(is_demo=True) except Team.DoesNotExist: team = create_demo_team(organization, user, request) user.current_team = team user.save() EventDefinition.objects.get_or_create(team=team, name="$pageview") if is_clickhouse_enabled(): # :TRICKY: Lazily backfill missing event data. from ee.clickhouse.models.event import get_events_by_team result = get_events_by_team(team_id=team.pk) if not result: create_demo_data(team, dashboards=False) return render_template("demo.html", request=request, context={"api_token": team.api_token})
def demo(request): user = request.user organization = user.organization try: team = organization.teams.get(name=TEAM_NAME) except Team.DoesNotExist: team = Team.objects.create_with_data(organization=organization, name=TEAM_NAME, ingested_event=True, completed_snippet_onboarding=True) _create_anonymous_users(team=team, base_url=request.build_absolute_uri("/demo")) _create_funnel(team=team, base_url=request.build_absolute_uri("/demo")) _recalculate(team=team) user.current_team = team user.save() if "$pageview" not in team.event_names: team.event_names.append("$pageview") team.save() if is_ee_enabled(): from ee.clickhouse.demo import create_anonymous_users_ch from ee.clickhouse.models.event import get_events_by_team result = get_events_by_team(team_id=team.pk) if not result: create_anonymous_users_ch( team=team, base_url=request.build_absolute_uri("/demo")) return render_template("demo.html", request=request, context={"api_token": team.api_token})
def demo(request): team = request.user.team if not Event.objects.filter(team=team).exists(): _create_anonymous_users(team=team, base_url=request.build_absolute_uri("/demo")) _create_funnel(team=team, base_url=request.build_absolute_uri("/demo")) _recalculate(team=team) if "$pageview" not in team.event_names: team.event_names.append("$pageview") team.save() if check_ee_enabled(): from ee.clickhouse.demo import create_anonymous_users_ch from ee.clickhouse.models.event import get_events_by_team result = get_events_by_team(team_id=team.pk) if not result: create_anonymous_users_ch( team=team, base_url=request.build_absolute_uri("/demo")) return render_template("demo.html", request=request, context={"api_token": team.api_token})