コード例 #1
0
    def create_with_data(self, user: Any = None, default_dashboards: bool = True, **kwargs) -> "Team":
        kwargs["test_account_filters"] = self.set_test_account_filters(kwargs.get("organization"))
        team = Team.objects.create(**kwargs)

        # Create default dashboards (skipped for demo projects)
        # TODO: Support multiple dashboard flavors based on #2822 personalization
        if default_dashboards:
            dashboard = Dashboard.objects.create(name="My App Dashboard", pinned=True, team=team)
            create_dashboard_from_template("DEFAULT_APP", dashboard)
        return team
コード例 #2
0
ファイル: team.py プロジェクト: zhang1998/posthog
    def create_with_data(self, user=None, **kwargs) -> "Team":
        team = Team.objects.create(**kwargs)

        if not user or not posthoganalytics.feature_enabled("actions-ux-201012", user.distinct_id):
            # Don't create default `Pageviews` action on actions-ux-201012 feature flag
            action = Action.objects.create(team=team, name="Pageviews")
            ActionStep.objects.create(action=action, event="$pageview")

        # Create default dashboard
        if user and posthoganalytics.feature_enabled("1694-dashboards", user.distinct_id):
            # Create app template dashboard if feature flag is active
            dashboard = Dashboard.objects.create(name="My App Dashboard", pinned=True, team=team,)
            create_dashboard_from_template("DEFAULT_APP", dashboard)
        else:
            # DEPRECATED: Will be retired in favor of dashboard_templates.py
            dashboard = Dashboard.objects.create(
                name="Default", pinned=True, team=team, share_token=generate_random_token()
            )

            DashboardItem.objects.create(
                team=team,
                dashboard=dashboard,
                name="Pageviews this week",
                type=TRENDS_LINEAR,
                filters={TREND_FILTER_TYPE_EVENTS: [{"id": "$pageview", "type": TREND_FILTER_TYPE_EVENTS}]},
                last_refresh=timezone.now(),
            )
            DashboardItem.objects.create(
                team=team,
                dashboard=dashboard,
                name="Most popular browsers this week",
                type="ActionsTable",
                filters={
                    TREND_FILTER_TYPE_EVENTS: [{"id": "$pageview", "type": TREND_FILTER_TYPE_EVENTS}],
                    "display": "ActionsTable",
                    "breakdown": "$browser",
                },
                last_refresh=timezone.now(),
            )
            DashboardItem.objects.create(
                team=team,
                dashboard=dashboard,
                name="Daily Active Users",
                type=TRENDS_LINEAR,
                filters={
                    TREND_FILTER_TYPE_EVENTS: [{"id": "$pageview", "math": "dau", "type": TREND_FILTER_TYPE_EVENTS}]
                },
                last_refresh=timezone.now(),
            )

        return team
コード例 #3
0
ファイル: team.py プロジェクト: PostHog/posthog
    def create_with_data(self,
                         user: Any = None,
                         default_dashboards: bool = True,
                         **kwargs) -> "Team":
        kwargs["test_account_filters"] = self.set_test_account_filters(
            kwargs.get("organization"))
        team = Team.objects.create(**kwargs)

        # Create default dashboards (skipped for demo projects)
        if default_dashboards:
            dashboard = Dashboard.objects.create(name="My App Dashboard",
                                                 pinned=True,
                                                 team=team)
            create_dashboard_from_template("DEFAULT_APP", dashboard)
            team.primary_dashboard = dashboard
            team.save()
        return team