File size: 6,269 Bytes
303c85f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnalyticsController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const analytics_service_1 = require("./analytics.service");
const better_auth_guard_1 = require("../auth/better-auth.guard");
const subscription_guard_1 = require("../billing/subscription.guard");
const subscription_features_1 = require("../billing/subscription-features");
let AnalyticsController = class AnalyticsController {
    analyticsService;
    constructor(analyticsService) {
        this.analyticsService = analyticsService;
    }
    async getDashboardMetrics(podcastId, req) {
        return this.analyticsService.getDashboardMetrics(podcastId, req.userId);
    }
    async getPipeline(podcastId, req) {
        return this.analyticsService.getGuestPipeline(podcastId, req.userId);
    }
    async getOutreachMetrics(podcastId, req) {
        return this.analyticsService.getOutreachMetrics(podcastId, req.userId);
    }
    async getSchedulingMetrics(podcastId, daysBack, req) {
        return this.analyticsService.getSchedulingMetrics(podcastId, req.userId, daysBack ? parseInt(daysBack, 10) : 90);
    }
    async getActivity(podcastId, limit, req) {
        return this.analyticsService.getRecentActivity(podcastId, req.userId, limit ? parseInt(limit, 10) : 20);
    }
};
exports.AnalyticsController = AnalyticsController;
__decorate([
    (0, common_1.Get)("dashboard"),
    (0, swagger_1.ApiOperation)({
        summary: "Dashboard metrics",
        description: "Get key metrics for the podcast dashboard",
    }),
    (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }),
    (0, swagger_1.ApiResponse)({ status: 200, description: "Dashboard metrics retrieved" }),
    __param(0, (0, common_1.Param)("podcastId")),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], AnalyticsController.prototype, "getDashboardMetrics", null);
__decorate([
    (0, common_1.Get)("pipeline"),
    (0, swagger_1.ApiOperation)({
        summary: "Guest pipeline",
        description: "Get guest counts by status with priority scores",
    }),
    (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }),
    __param(0, (0, common_1.Param)("podcastId")),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], AnalyticsController.prototype, "getPipeline", null);
__decorate([
    (0, common_1.Get)("outreach"),
    (0, swagger_1.ApiOperation)({
        summary: "Outreach metrics",
        description: "Get email sequence performance metrics (Studio plan)",
    }),
    (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }),
    (0, subscription_guard_1.RequireFeature)(subscription_features_1.SubscriptionFeature.ADVANCED_ANALYTICS),
    __param(0, (0, common_1.Param)("podcastId")),
    __param(1, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], AnalyticsController.prototype, "getOutreachMetrics", null);
__decorate([
    (0, common_1.Get)("scheduling"),
    (0, swagger_1.ApiOperation)({
        summary: "Scheduling metrics",
        description: "Get episode scheduling and conversion metrics (Studio plan)",
    }),
    (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }),
    (0, swagger_1.ApiQuery)({ name: "daysBack", type: Number, required: false, description: "Days to look back" }),
    (0, subscription_guard_1.RequireFeature)(subscription_features_1.SubscriptionFeature.ADVANCED_ANALYTICS),
    __param(0, (0, common_1.Param)("podcastId")),
    __param(1, (0, common_1.Query)("daysBack")),
    __param(2, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object]),
    __metadata("design:returntype", Promise)
], AnalyticsController.prototype, "getSchedulingMetrics", null);
__decorate([
    (0, common_1.Get)("activity"),
    (0, swagger_1.ApiOperation)({
        summary: "Activity timeline",
        description: "Get recent activity for the podcast",
    }),
    (0, swagger_1.ApiParam)({ name: "podcastId", description: "Podcast ID" }),
    (0, swagger_1.ApiQuery)({ name: "limit", type: Number, required: false }),
    __param(0, (0, common_1.Param)("podcastId")),
    __param(1, (0, common_1.Query)("limit")),
    __param(2, (0, common_1.Req)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object]),
    __metadata("design:returntype", Promise)
], AnalyticsController.prototype, "getActivity", null);
exports.AnalyticsController = AnalyticsController = __decorate([
    (0, swagger_1.ApiTags)("Analytics"),
    (0, swagger_1.ApiBearerAuth)("jwt"),
    (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard, subscription_guard_1.SubscriptionGuard),
    (0, common_1.Controller)("podcasts/:podcastId/analytics"),
    __metadata("design:paramtypes", [analytics_service_1.AnalyticsService])
], AnalyticsController);
//# sourceMappingURL=analytics.controller.js.map