glitch-javascript-sdk 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +374 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Scheduler.d.ts +10 -0
- package/dist/esm/api/WebsiteAnalytics.d.ts +187 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +374 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/WebsiteAnalyticsRoute.d.ts +7 -0
- package/dist/esm/util/Session.d.ts +8 -0
- package/dist/index.d.ts +204 -0
- package/package.json +2 -1
- package/src/api/Scheduler.ts +13 -0
- package/src/api/WebsiteAnalytics.ts +308 -0
- package/src/api/index.ts +3 -1
- package/src/index.ts +3 -1
- package/src/routes/SchedulerRoute.ts +1 -0
- package/src/routes/WebsiteAnalyticsRoute.ts +69 -0
- package/src/util/Session.ts +92 -4
|
@@ -81,6 +81,16 @@ declare class Scheduler {
|
|
|
81
81
|
* @returns promise
|
|
82
82
|
*/
|
|
83
83
|
static listUpdates<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
84
|
+
/**
|
|
85
|
+
* Search the updates related to a promotion schedule.
|
|
86
|
+
*
|
|
87
|
+
* @see https://api.glitch.fun/api/documentation#/Scheduler/searchTitleUpdates
|
|
88
|
+
*
|
|
89
|
+
* @param scheduler_id The ID of the promotion schedule.
|
|
90
|
+
*
|
|
91
|
+
* @returns promise
|
|
92
|
+
*/
|
|
93
|
+
static searchUpdates<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
84
94
|
/**
|
|
85
95
|
* Create a new title update for a promotion schedule.
|
|
86
96
|
*
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import Response from "../util/Response";
|
|
2
|
+
import { AxiosPromise } from "axios";
|
|
3
|
+
declare class WebsiteAnalytics {
|
|
4
|
+
/**
|
|
5
|
+
* List website analytics sessions with comprehensive filtering
|
|
6
|
+
*
|
|
7
|
+
* @param params Filtering options:
|
|
8
|
+
* - title_id?: string - Filter by title ID
|
|
9
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
10
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
11
|
+
* - device_type?: 'desktop'|'mobile'|'tablet'|'bot'|'other'
|
|
12
|
+
* - country_code?: string - 2-letter country code
|
|
13
|
+
* - is_bot?: boolean - Filter by bot status
|
|
14
|
+
* - sort?: 'started_at'|'total_duration'|'pageview_count' - Sort field
|
|
15
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
16
|
+
* - per_page?: number - Items per page (max 100)
|
|
17
|
+
* @returns Promise with paginated sessions data
|
|
18
|
+
*/
|
|
19
|
+
static listSessions<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
20
|
+
/**
|
|
21
|
+
* Get a paginated list of pageviews with filtering options
|
|
22
|
+
*
|
|
23
|
+
* @param params Filtering options:
|
|
24
|
+
* - title_id?: string - Filter by title ID
|
|
25
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
26
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
27
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
28
|
+
* - is_exit?: boolean - Filter by exit pageviews
|
|
29
|
+
* - sort?: 'occurred_at'|'load_time_ms'|'dom_complete_ms' - Sort field
|
|
30
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
31
|
+
* - per_page?: number - Items per page (max 100)
|
|
32
|
+
* @returns Promise with paginated pageviews data
|
|
33
|
+
*/
|
|
34
|
+
static listPageviews<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
35
|
+
/**
|
|
36
|
+
* Get a paginated list of events with filtering options
|
|
37
|
+
*
|
|
38
|
+
* @param params Filtering options:
|
|
39
|
+
* - title_id?: string - Filter by title ID
|
|
40
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
41
|
+
* - event_name?: string - Filter by event name
|
|
42
|
+
* - event_category?: string - Filter by event category
|
|
43
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
44
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
45
|
+
* - sort?: 'occurred_at'|'event_name' - Sort field
|
|
46
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
47
|
+
* - per_page?: number - Items per page (max 100)
|
|
48
|
+
* @returns Promise with paginated events data
|
|
49
|
+
*/
|
|
50
|
+
static listEvents<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
51
|
+
/**
|
|
52
|
+
* Get an analytics overview with summarized metrics
|
|
53
|
+
*
|
|
54
|
+
* @param params Overview options:
|
|
55
|
+
* - title_id: string - Required title ID
|
|
56
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
57
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
58
|
+
* - group_by?: 'day'|'week'|'month'|'year' - Grouping period
|
|
59
|
+
* - include_breakdowns?: boolean - Include detailed breakdowns
|
|
60
|
+
* @returns Promise with overview data
|
|
61
|
+
*/
|
|
62
|
+
static overview<T>(params: Record<string, any>): AxiosPromise<Response<T>>;
|
|
63
|
+
/**
|
|
64
|
+
* Single ingestion endpoint for sessions, pageviews and events
|
|
65
|
+
*
|
|
66
|
+
* @param data Analytics data payload with type property:
|
|
67
|
+
* - type: 'session'|'pageview'|'event' - Type of analytics data
|
|
68
|
+
* - title_id: string - Title ID
|
|
69
|
+
* - tracking_token: string - HMAC token for verification
|
|
70
|
+
* - plus type-specific fields
|
|
71
|
+
* @returns Promise with acceptance response
|
|
72
|
+
*/
|
|
73
|
+
static collect<T>(data: object): AxiosPromise<Response<T>>;
|
|
74
|
+
/**
|
|
75
|
+
* Get average session length data with optional grouping
|
|
76
|
+
*
|
|
77
|
+
* @param params Filtering options:
|
|
78
|
+
* - title_id?: string - Filter by title ID
|
|
79
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
80
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
81
|
+
* - group_by?: 'day'|'week'|'month' - Grouping period
|
|
82
|
+
* - device_type?: string - Filter by device type
|
|
83
|
+
* - country_code?: string - Filter by country
|
|
84
|
+
* @returns Promise with average session data
|
|
85
|
+
*/
|
|
86
|
+
static sessionsAverage<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
87
|
+
/**
|
|
88
|
+
* Get session duration histogram data
|
|
89
|
+
*
|
|
90
|
+
* @param params Filtering options:
|
|
91
|
+
* - title_id?: string - Filter by title ID
|
|
92
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
93
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
94
|
+
* - bucket_size?: number - Duration bucket size in seconds
|
|
95
|
+
* @returns Promise with histogram data
|
|
96
|
+
*/
|
|
97
|
+
static sessionsHistogram<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
98
|
+
/**
|
|
99
|
+
* Get pageviews over time with optional grouping
|
|
100
|
+
*
|
|
101
|
+
* @param params Filtering options:
|
|
102
|
+
* - title_id?: string - Filter by title ID
|
|
103
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
104
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
105
|
+
* - group_by?: 'hour'|'day'|'week'|'month' - Grouping period
|
|
106
|
+
* - path?: string - Filter by specific path
|
|
107
|
+
* @returns Promise with pageviews over time data
|
|
108
|
+
*/
|
|
109
|
+
static pageviewsOverTime<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
110
|
+
/**
|
|
111
|
+
* Get top pages by views
|
|
112
|
+
*
|
|
113
|
+
* @param params Filtering options:
|
|
114
|
+
* - title_id?: string - Filter by title ID
|
|
115
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
116
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
117
|
+
* - limit?: number - Number of top pages to return
|
|
118
|
+
* @returns Promise with top pages data
|
|
119
|
+
*/
|
|
120
|
+
static topPages<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
121
|
+
/**
|
|
122
|
+
* Get summary of events
|
|
123
|
+
*
|
|
124
|
+
* @param params Filtering options:
|
|
125
|
+
* - title_id?: string - Filter by title ID
|
|
126
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
127
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
128
|
+
* - event_category?: string - Filter by event category
|
|
129
|
+
* @returns Promise with events summary data
|
|
130
|
+
*/
|
|
131
|
+
static eventsSummary<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
132
|
+
/**
|
|
133
|
+
* Get most popular events
|
|
134
|
+
*
|
|
135
|
+
* @param params Filtering options:
|
|
136
|
+
* - title_id?: string - Filter by title ID
|
|
137
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
138
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
139
|
+
* - limit?: number - Number of events to return
|
|
140
|
+
* @returns Promise with popular events data
|
|
141
|
+
*/
|
|
142
|
+
static popularEvents<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
143
|
+
/**
|
|
144
|
+
* Get geographic distribution of visitors
|
|
145
|
+
*
|
|
146
|
+
* @param params Filtering options:
|
|
147
|
+
* - title_id?: string - Filter by title ID
|
|
148
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
149
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
150
|
+
* - limit?: number - Number of countries to return
|
|
151
|
+
* @returns Promise with geo distribution data
|
|
152
|
+
*/
|
|
153
|
+
static geoDistribution<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
154
|
+
/**
|
|
155
|
+
* Get device type breakdown
|
|
156
|
+
*
|
|
157
|
+
* @param params Filtering options:
|
|
158
|
+
* - title_id?: string - Filter by title ID
|
|
159
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
160
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
161
|
+
* @returns Promise with device breakdown data
|
|
162
|
+
*/
|
|
163
|
+
static deviceBreakdown<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
164
|
+
/**
|
|
165
|
+
* Get top referrers
|
|
166
|
+
*
|
|
167
|
+
* @param params Filtering options:
|
|
168
|
+
* - title_id?: string - Filter by title ID
|
|
169
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
170
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
171
|
+
* - limit?: number - Number of referrers to return
|
|
172
|
+
* @returns Promise with referrers data
|
|
173
|
+
*/
|
|
174
|
+
static referrers<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
175
|
+
/**
|
|
176
|
+
* Get UTM campaign performance
|
|
177
|
+
*
|
|
178
|
+
* @param params Filtering options:
|
|
179
|
+
* - title_id?: string - Filter by title ID
|
|
180
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
181
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
182
|
+
* - group_by?: 'source'|'medium'|'campaign' - Grouping field
|
|
183
|
+
* @returns Promise with UTM performance data
|
|
184
|
+
*/
|
|
185
|
+
static utmPerformance<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
186
|
+
}
|
|
187
|
+
export default WebsiteAnalytics;
|
package/dist/esm/api/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ import Scheduler from "./Scheduler";
|
|
|
31
31
|
import Funnel from "./Funnel";
|
|
32
32
|
import SocialStats from "./SocialStats";
|
|
33
33
|
import Hashtags from "./Hashtags";
|
|
34
|
+
import WebsiteAnalytics from "./WebsiteAnalytics";
|
|
34
35
|
export { Ads };
|
|
35
36
|
export { Auth };
|
|
36
37
|
export { Competitions };
|
|
@@ -64,3 +65,4 @@ export { Scheduler };
|
|
|
64
65
|
export { Funnel };
|
|
65
66
|
export { SocialStats };
|
|
66
67
|
export { Hashtags };
|
|
68
|
+
export { WebsiteAnalytics };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ import { Scheduler } from "./api";
|
|
|
31
31
|
import { Funnel } from "./api";
|
|
32
32
|
import { SocialStats } from "./api";
|
|
33
33
|
import { Hashtags } from "./api";
|
|
34
|
+
import { WebsiteAnalytics } from "./api";
|
|
34
35
|
import Requests from "./util/Requests";
|
|
35
36
|
import Parser from "./util/Parser";
|
|
36
37
|
import Session from "./util/Session";
|
|
@@ -83,6 +84,7 @@ declare class Glitch {
|
|
|
83
84
|
Scheduler: typeof Scheduler;
|
|
84
85
|
Funnel: typeof Funnel;
|
|
85
86
|
SocialStats: typeof SocialStats;
|
|
87
|
+
WebsiteAnalytics: typeof WebsiteAnalytics;
|
|
86
88
|
};
|
|
87
89
|
static util: {
|
|
88
90
|
Requests: typeof Requests;
|
package/dist/esm/index.js
CHANGED
|
@@ -12168,6 +12168,7 @@ var SchedulerRoute = /** @class */ (function () {
|
|
|
12168
12168
|
getSchedulePosts: { url: '/schedulers/{scheduler_id}/posts', method: HTTP_METHODS.GET },
|
|
12169
12169
|
// Title Update Routes
|
|
12170
12170
|
listUpdates: { url: '/schedulers/{scheduler_id}/updates', method: HTTP_METHODS.GET },
|
|
12171
|
+
searchUpdates: { url: '/schedulers/{scheduler_id}/updates/search', method: HTTP_METHODS.GET },
|
|
12171
12172
|
createUpdate: { url: '/schedulers/{scheduler_id}/updates', method: HTTP_METHODS.POST },
|
|
12172
12173
|
getUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.GET },
|
|
12173
12174
|
updateUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.PUT },
|
|
@@ -12353,6 +12354,18 @@ var Scheduler = /** @class */ (function () {
|
|
|
12353
12354
|
Scheduler.listUpdates = function (scheduler_id, params) {
|
|
12354
12355
|
return Requests.processRoute(SchedulerRoute.routes.listUpdates, {}, { scheduler_id: scheduler_id }, params);
|
|
12355
12356
|
};
|
|
12357
|
+
/**
|
|
12358
|
+
* Search the updates related to a promotion schedule.
|
|
12359
|
+
*
|
|
12360
|
+
* @see https://api.glitch.fun/api/documentation#/Scheduler/searchTitleUpdates
|
|
12361
|
+
*
|
|
12362
|
+
* @param scheduler_id The ID of the promotion schedule.
|
|
12363
|
+
*
|
|
12364
|
+
* @returns promise
|
|
12365
|
+
*/
|
|
12366
|
+
Scheduler.searchUpdates = function (scheduler_id, params) {
|
|
12367
|
+
return Requests.processRoute(SchedulerRoute.routes.listUpdates, {}, { scheduler_id: scheduler_id }, params);
|
|
12368
|
+
};
|
|
12356
12369
|
/**
|
|
12357
12370
|
* Create a new title update for a promotion schedule.
|
|
12358
12371
|
*
|
|
@@ -12973,6 +12986,292 @@ var Hashtags = /** @class */ (function () {
|
|
|
12973
12986
|
return Hashtags;
|
|
12974
12987
|
}());
|
|
12975
12988
|
|
|
12989
|
+
var WebsiteAnalyticsRoute = /** @class */ (function () {
|
|
12990
|
+
function WebsiteAnalyticsRoute() {
|
|
12991
|
+
}
|
|
12992
|
+
WebsiteAnalyticsRoute.routes = {
|
|
12993
|
+
listSessions: {
|
|
12994
|
+
url: '/analytics/sessions',
|
|
12995
|
+
method: HTTP_METHODS.GET
|
|
12996
|
+
},
|
|
12997
|
+
listPageviews: {
|
|
12998
|
+
url: '/analytics/pageviews',
|
|
12999
|
+
method: HTTP_METHODS.GET
|
|
13000
|
+
},
|
|
13001
|
+
listEvents: {
|
|
13002
|
+
url: '/analytics/events',
|
|
13003
|
+
method: HTTP_METHODS.GET
|
|
13004
|
+
},
|
|
13005
|
+
overview: {
|
|
13006
|
+
url: '/analytics/overview',
|
|
13007
|
+
method: HTTP_METHODS.GET
|
|
13008
|
+
},
|
|
13009
|
+
collect: {
|
|
13010
|
+
url: '/analytics/collect',
|
|
13011
|
+
method: HTTP_METHODS.POST
|
|
13012
|
+
},
|
|
13013
|
+
sessionsAverage: {
|
|
13014
|
+
url: '/analytics/sessions/average',
|
|
13015
|
+
method: HTTP_METHODS.GET
|
|
13016
|
+
},
|
|
13017
|
+
sessionsHistogram: {
|
|
13018
|
+
url: '/analytics/sessions/histogram',
|
|
13019
|
+
method: HTTP_METHODS.GET
|
|
13020
|
+
},
|
|
13021
|
+
pageviewsOverTime: {
|
|
13022
|
+
url: '/analytics/pageviews/over-time',
|
|
13023
|
+
method: HTTP_METHODS.GET
|
|
13024
|
+
},
|
|
13025
|
+
topPages: {
|
|
13026
|
+
url: '/analytics/pageviews/top-pages',
|
|
13027
|
+
method: HTTP_METHODS.GET
|
|
13028
|
+
},
|
|
13029
|
+
eventsSummary: {
|
|
13030
|
+
url: '/analytics/events/summary',
|
|
13031
|
+
method: HTTP_METHODS.GET
|
|
13032
|
+
},
|
|
13033
|
+
popularEvents: {
|
|
13034
|
+
url: '/analytics/events/popular',
|
|
13035
|
+
method: HTTP_METHODS.GET
|
|
13036
|
+
},
|
|
13037
|
+
geoDistribution: {
|
|
13038
|
+
url: '/analytics/geo-distribution',
|
|
13039
|
+
method: HTTP_METHODS.GET
|
|
13040
|
+
},
|
|
13041
|
+
deviceBreakdown: {
|
|
13042
|
+
url: '/analytics/device-breakdown',
|
|
13043
|
+
method: HTTP_METHODS.GET
|
|
13044
|
+
},
|
|
13045
|
+
referrers: {
|
|
13046
|
+
url: '/analytics/referrers',
|
|
13047
|
+
method: HTTP_METHODS.GET
|
|
13048
|
+
},
|
|
13049
|
+
utmPerformance: {
|
|
13050
|
+
url: '/analytics/utm-performance',
|
|
13051
|
+
method: HTTP_METHODS.GET
|
|
13052
|
+
}
|
|
13053
|
+
};
|
|
13054
|
+
return WebsiteAnalyticsRoute;
|
|
13055
|
+
}());
|
|
13056
|
+
|
|
13057
|
+
var WebsiteAnalytics = /** @class */ (function () {
|
|
13058
|
+
function WebsiteAnalytics() {
|
|
13059
|
+
}
|
|
13060
|
+
/**
|
|
13061
|
+
* List website analytics sessions with comprehensive filtering
|
|
13062
|
+
*
|
|
13063
|
+
* @param params Filtering options:
|
|
13064
|
+
* - title_id?: string - Filter by title ID
|
|
13065
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13066
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13067
|
+
* - device_type?: 'desktop'|'mobile'|'tablet'|'bot'|'other'
|
|
13068
|
+
* - country_code?: string - 2-letter country code
|
|
13069
|
+
* - is_bot?: boolean - Filter by bot status
|
|
13070
|
+
* - sort?: 'started_at'|'total_duration'|'pageview_count' - Sort field
|
|
13071
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
13072
|
+
* - per_page?: number - Items per page (max 100)
|
|
13073
|
+
* @returns Promise with paginated sessions data
|
|
13074
|
+
*/
|
|
13075
|
+
WebsiteAnalytics.listSessions = function (params) {
|
|
13076
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.listSessions, {}, undefined, params);
|
|
13077
|
+
};
|
|
13078
|
+
/**
|
|
13079
|
+
* Get a paginated list of pageviews with filtering options
|
|
13080
|
+
*
|
|
13081
|
+
* @param params Filtering options:
|
|
13082
|
+
* - title_id?: string - Filter by title ID
|
|
13083
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
13084
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13085
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13086
|
+
* - is_exit?: boolean - Filter by exit pageviews
|
|
13087
|
+
* - sort?: 'occurred_at'|'load_time_ms'|'dom_complete_ms' - Sort field
|
|
13088
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
13089
|
+
* - per_page?: number - Items per page (max 100)
|
|
13090
|
+
* @returns Promise with paginated pageviews data
|
|
13091
|
+
*/
|
|
13092
|
+
WebsiteAnalytics.listPageviews = function (params) {
|
|
13093
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.listPageviews, {}, undefined, params);
|
|
13094
|
+
};
|
|
13095
|
+
/**
|
|
13096
|
+
* Get a paginated list of events with filtering options
|
|
13097
|
+
*
|
|
13098
|
+
* @param params Filtering options:
|
|
13099
|
+
* - title_id?: string - Filter by title ID
|
|
13100
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
13101
|
+
* - event_name?: string - Filter by event name
|
|
13102
|
+
* - event_category?: string - Filter by event category
|
|
13103
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13104
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13105
|
+
* - sort?: 'occurred_at'|'event_name' - Sort field
|
|
13106
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
13107
|
+
* - per_page?: number - Items per page (max 100)
|
|
13108
|
+
* @returns Promise with paginated events data
|
|
13109
|
+
*/
|
|
13110
|
+
WebsiteAnalytics.listEvents = function (params) {
|
|
13111
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.listEvents, {}, undefined, params);
|
|
13112
|
+
};
|
|
13113
|
+
/**
|
|
13114
|
+
* Get an analytics overview with summarized metrics
|
|
13115
|
+
*
|
|
13116
|
+
* @param params Overview options:
|
|
13117
|
+
* - title_id: string - Required title ID
|
|
13118
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13119
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13120
|
+
* - group_by?: 'day'|'week'|'month'|'year' - Grouping period
|
|
13121
|
+
* - include_breakdowns?: boolean - Include detailed breakdowns
|
|
13122
|
+
* @returns Promise with overview data
|
|
13123
|
+
*/
|
|
13124
|
+
WebsiteAnalytics.overview = function (params) {
|
|
13125
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.overview, {}, undefined, params);
|
|
13126
|
+
};
|
|
13127
|
+
/**
|
|
13128
|
+
* Single ingestion endpoint for sessions, pageviews and events
|
|
13129
|
+
*
|
|
13130
|
+
* @param data Analytics data payload with type property:
|
|
13131
|
+
* - type: 'session'|'pageview'|'event' - Type of analytics data
|
|
13132
|
+
* - title_id: string - Title ID
|
|
13133
|
+
* - tracking_token: string - HMAC token for verification
|
|
13134
|
+
* - plus type-specific fields
|
|
13135
|
+
* @returns Promise with acceptance response
|
|
13136
|
+
*/
|
|
13137
|
+
WebsiteAnalytics.collect = function (data) {
|
|
13138
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.collect, data);
|
|
13139
|
+
};
|
|
13140
|
+
/**
|
|
13141
|
+
* Get average session length data with optional grouping
|
|
13142
|
+
*
|
|
13143
|
+
* @param params Filtering options:
|
|
13144
|
+
* - title_id?: string - Filter by title ID
|
|
13145
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13146
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13147
|
+
* - group_by?: 'day'|'week'|'month' - Grouping period
|
|
13148
|
+
* - device_type?: string - Filter by device type
|
|
13149
|
+
* - country_code?: string - Filter by country
|
|
13150
|
+
* @returns Promise with average session data
|
|
13151
|
+
*/
|
|
13152
|
+
WebsiteAnalytics.sessionsAverage = function (params) {
|
|
13153
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.sessionsAverage, {}, undefined, params);
|
|
13154
|
+
};
|
|
13155
|
+
/**
|
|
13156
|
+
* Get session duration histogram data
|
|
13157
|
+
*
|
|
13158
|
+
* @param params Filtering options:
|
|
13159
|
+
* - title_id?: string - Filter by title ID
|
|
13160
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13161
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13162
|
+
* - bucket_size?: number - Duration bucket size in seconds
|
|
13163
|
+
* @returns Promise with histogram data
|
|
13164
|
+
*/
|
|
13165
|
+
WebsiteAnalytics.sessionsHistogram = function (params) {
|
|
13166
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.sessionsHistogram, {}, undefined, params);
|
|
13167
|
+
};
|
|
13168
|
+
/**
|
|
13169
|
+
* Get pageviews over time with optional grouping
|
|
13170
|
+
*
|
|
13171
|
+
* @param params Filtering options:
|
|
13172
|
+
* - title_id?: string - Filter by title ID
|
|
13173
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13174
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13175
|
+
* - group_by?: 'hour'|'day'|'week'|'month' - Grouping period
|
|
13176
|
+
* - path?: string - Filter by specific path
|
|
13177
|
+
* @returns Promise with pageviews over time data
|
|
13178
|
+
*/
|
|
13179
|
+
WebsiteAnalytics.pageviewsOverTime = function (params) {
|
|
13180
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.pageviewsOverTime, {}, undefined, params);
|
|
13181
|
+
};
|
|
13182
|
+
/**
|
|
13183
|
+
* Get top pages by views
|
|
13184
|
+
*
|
|
13185
|
+
* @param params Filtering options:
|
|
13186
|
+
* - title_id?: string - Filter by title ID
|
|
13187
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13188
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13189
|
+
* - limit?: number - Number of top pages to return
|
|
13190
|
+
* @returns Promise with top pages data
|
|
13191
|
+
*/
|
|
13192
|
+
WebsiteAnalytics.topPages = function (params) {
|
|
13193
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.topPages, {}, undefined, params);
|
|
13194
|
+
};
|
|
13195
|
+
/**
|
|
13196
|
+
* Get summary of events
|
|
13197
|
+
*
|
|
13198
|
+
* @param params Filtering options:
|
|
13199
|
+
* - title_id?: string - Filter by title ID
|
|
13200
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13201
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13202
|
+
* - event_category?: string - Filter by event category
|
|
13203
|
+
* @returns Promise with events summary data
|
|
13204
|
+
*/
|
|
13205
|
+
WebsiteAnalytics.eventsSummary = function (params) {
|
|
13206
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.eventsSummary, {}, undefined, params);
|
|
13207
|
+
};
|
|
13208
|
+
/**
|
|
13209
|
+
* Get most popular events
|
|
13210
|
+
*
|
|
13211
|
+
* @param params Filtering options:
|
|
13212
|
+
* - title_id?: string - Filter by title ID
|
|
13213
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13214
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13215
|
+
* - limit?: number - Number of events to return
|
|
13216
|
+
* @returns Promise with popular events data
|
|
13217
|
+
*/
|
|
13218
|
+
WebsiteAnalytics.popularEvents = function (params) {
|
|
13219
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.popularEvents, {}, undefined, params);
|
|
13220
|
+
};
|
|
13221
|
+
/**
|
|
13222
|
+
* Get geographic distribution of visitors
|
|
13223
|
+
*
|
|
13224
|
+
* @param params Filtering options:
|
|
13225
|
+
* - title_id?: string - Filter by title ID
|
|
13226
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13227
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13228
|
+
* - limit?: number - Number of countries to return
|
|
13229
|
+
* @returns Promise with geo distribution data
|
|
13230
|
+
*/
|
|
13231
|
+
WebsiteAnalytics.geoDistribution = function (params) {
|
|
13232
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.geoDistribution, {}, undefined, params);
|
|
13233
|
+
};
|
|
13234
|
+
/**
|
|
13235
|
+
* Get device type breakdown
|
|
13236
|
+
*
|
|
13237
|
+
* @param params Filtering options:
|
|
13238
|
+
* - title_id?: string - Filter by title ID
|
|
13239
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13240
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13241
|
+
* @returns Promise with device breakdown data
|
|
13242
|
+
*/
|
|
13243
|
+
WebsiteAnalytics.deviceBreakdown = function (params) {
|
|
13244
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.deviceBreakdown, {}, undefined, params);
|
|
13245
|
+
};
|
|
13246
|
+
/**
|
|
13247
|
+
* Get top referrers
|
|
13248
|
+
*
|
|
13249
|
+
* @param params Filtering options:
|
|
13250
|
+
* - title_id?: string - Filter by title ID
|
|
13251
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13252
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13253
|
+
* - limit?: number - Number of referrers to return
|
|
13254
|
+
* @returns Promise with referrers data
|
|
13255
|
+
*/
|
|
13256
|
+
WebsiteAnalytics.referrers = function (params) {
|
|
13257
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.referrers, {}, undefined, params);
|
|
13258
|
+
};
|
|
13259
|
+
/**
|
|
13260
|
+
* Get UTM campaign performance
|
|
13261
|
+
*
|
|
13262
|
+
* @param params Filtering options:
|
|
13263
|
+
* - title_id?: string - Filter by title ID
|
|
13264
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13265
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
13266
|
+
* - group_by?: 'source'|'medium'|'campaign' - Grouping field
|
|
13267
|
+
* @returns Promise with UTM performance data
|
|
13268
|
+
*/
|
|
13269
|
+
WebsiteAnalytics.utmPerformance = function (params) {
|
|
13270
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.utmPerformance, {}, undefined, params);
|
|
13271
|
+
};
|
|
13272
|
+
return WebsiteAnalytics;
|
|
13273
|
+
}());
|
|
13274
|
+
|
|
12976
13275
|
var Parser = /** @class */ (function () {
|
|
12977
13276
|
function Parser() {
|
|
12978
13277
|
}
|
|
@@ -12996,6 +13295,54 @@ var Parser = /** @class */ (function () {
|
|
|
12996
13295
|
return Parser;
|
|
12997
13296
|
}());
|
|
12998
13297
|
|
|
13298
|
+
// Browser implementation using crypto-js
|
|
13299
|
+
var BrowserCrypto = /** @class */ (function () {
|
|
13300
|
+
function BrowserCrypto() {
|
|
13301
|
+
}
|
|
13302
|
+
BrowserCrypto.prototype.createHmac = function (algorithm, secret) {
|
|
13303
|
+
var CryptoJS = require('crypto-js');
|
|
13304
|
+
var data = '';
|
|
13305
|
+
var hmac = {
|
|
13306
|
+
update: function (updateData) {
|
|
13307
|
+
data = updateData;
|
|
13308
|
+
return hmac;
|
|
13309
|
+
},
|
|
13310
|
+
digest: function (encoding) {
|
|
13311
|
+
if (encoding !== 'hex') {
|
|
13312
|
+
throw new Error('Only hex encoding is supported in browser implementation');
|
|
13313
|
+
}
|
|
13314
|
+
return CryptoJS.HmacSHA256(data, secret).toString(CryptoJS.enc.Hex);
|
|
13315
|
+
}
|
|
13316
|
+
};
|
|
13317
|
+
return hmac;
|
|
13318
|
+
};
|
|
13319
|
+
return BrowserCrypto;
|
|
13320
|
+
}());
|
|
13321
|
+
// Node.js implementation using native crypto
|
|
13322
|
+
var NodeCrypto = /** @class */ (function () {
|
|
13323
|
+
function NodeCrypto() {
|
|
13324
|
+
this.crypto = require('crypto');
|
|
13325
|
+
}
|
|
13326
|
+
NodeCrypto.prototype.createHmac = function (algorithm, secret) {
|
|
13327
|
+
return this.crypto.createHmac(algorithm, secret);
|
|
13328
|
+
};
|
|
13329
|
+
return NodeCrypto;
|
|
13330
|
+
}());
|
|
13331
|
+
// Determine which crypto implementation to use
|
|
13332
|
+
var getCrypto = function () {
|
|
13333
|
+
try {
|
|
13334
|
+
// Check if we're in Node.js environment
|
|
13335
|
+
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
|
|
13336
|
+
return new NodeCrypto();
|
|
13337
|
+
}
|
|
13338
|
+
// Fall back to browser implementation
|
|
13339
|
+
return new BrowserCrypto();
|
|
13340
|
+
}
|
|
13341
|
+
catch (e) {
|
|
13342
|
+
return new BrowserCrypto();
|
|
13343
|
+
}
|
|
13344
|
+
};
|
|
13345
|
+
var crypto = getCrypto();
|
|
12999
13346
|
var Session = /** @class */ (function () {
|
|
13000
13347
|
function Session() {
|
|
13001
13348
|
}
|
|
@@ -13042,6 +13389,31 @@ var Session = /** @class */ (function () {
|
|
|
13042
13389
|
Storage.set(Session._email_key, data.email);
|
|
13043
13390
|
Config.setAuthToken(data.token.access_token);
|
|
13044
13391
|
};
|
|
13392
|
+
/**
|
|
13393
|
+
* Generate a tracking token for analytics collection
|
|
13394
|
+
* @param titleId The title ID to generate token for
|
|
13395
|
+
* @param secret The secret key (should match server config)
|
|
13396
|
+
* @returns HMAC-SHA256 token
|
|
13397
|
+
* @throws Error if crypto operations fail
|
|
13398
|
+
*/
|
|
13399
|
+
Session.generateTrackingToken = function (titleId, secret) {
|
|
13400
|
+
try {
|
|
13401
|
+
if (!titleId) {
|
|
13402
|
+
throw new Error('titleId is required');
|
|
13403
|
+
}
|
|
13404
|
+
if (!secret) {
|
|
13405
|
+
throw new Error('secret is required');
|
|
13406
|
+
}
|
|
13407
|
+
return crypto
|
|
13408
|
+
.createHmac('sha256', secret)
|
|
13409
|
+
.update(titleId)
|
|
13410
|
+
.digest('hex');
|
|
13411
|
+
}
|
|
13412
|
+
catch (error) {
|
|
13413
|
+
console.error('Failed to generate tracking token:', error);
|
|
13414
|
+
throw new Error('Failed to generate tracking token');
|
|
13415
|
+
}
|
|
13416
|
+
};
|
|
13045
13417
|
Session._id_key = 'user_id';
|
|
13046
13418
|
Session._first_name_key = 'user_first_name';
|
|
13047
13419
|
Session._last_name_key = 'user_last_name';
|
|
@@ -13402,7 +13774,8 @@ var Glitch = /** @class */ (function () {
|
|
|
13402
13774
|
Media: Media,
|
|
13403
13775
|
Scheduler: Scheduler,
|
|
13404
13776
|
Funnel: Funnel,
|
|
13405
|
-
SocialStats: SocialStats
|
|
13777
|
+
SocialStats: SocialStats,
|
|
13778
|
+
WebsiteAnalytics: WebsiteAnalytics
|
|
13406
13779
|
};
|
|
13407
13780
|
Glitch.util = {
|
|
13408
13781
|
Requests: Requests,
|