glitch-javascript-sdk 1.8.1 → 1.8.3
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 +396 -5
- 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 +396 -5
- 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 +121 -10
|
@@ -22,5 +22,13 @@ declare class Session {
|
|
|
22
22
|
email: string;
|
|
23
23
|
username: string;
|
|
24
24
|
}): void;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a tracking token for analytics collection
|
|
27
|
+
* @param titleId The title ID to generate token for
|
|
28
|
+
* @param secret The secret key (should match server config)
|
|
29
|
+
* @returns HMAC-SHA256 token
|
|
30
|
+
* @throws Error if crypto operations fail
|
|
31
|
+
*/
|
|
32
|
+
static generateTrackingToken(titleId: string, secret: string): string;
|
|
25
33
|
}
|
|
26
34
|
export default Session;
|
package/dist/index.d.ts
CHANGED
|
@@ -4523,6 +4523,16 @@ declare class Scheduler {
|
|
|
4523
4523
|
* @returns promise
|
|
4524
4524
|
*/
|
|
4525
4525
|
static listUpdates<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
4526
|
+
/**
|
|
4527
|
+
* Search the updates related to a promotion schedule.
|
|
4528
|
+
*
|
|
4529
|
+
* @see https://api.glitch.fun/api/documentation#/Scheduler/searchTitleUpdates
|
|
4530
|
+
*
|
|
4531
|
+
* @param scheduler_id The ID of the promotion schedule.
|
|
4532
|
+
*
|
|
4533
|
+
* @returns promise
|
|
4534
|
+
*/
|
|
4535
|
+
static searchUpdates<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
4526
4536
|
/**
|
|
4527
4537
|
* Create a new title update for a promotion schedule.
|
|
4528
4538
|
*
|
|
@@ -4964,6 +4974,191 @@ declare class Hashtags {
|
|
|
4964
4974
|
static top<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
4965
4975
|
}
|
|
4966
4976
|
|
|
4977
|
+
declare class WebsiteAnalytics {
|
|
4978
|
+
/**
|
|
4979
|
+
* List website analytics sessions with comprehensive filtering
|
|
4980
|
+
*
|
|
4981
|
+
* @param params Filtering options:
|
|
4982
|
+
* - title_id?: string - Filter by title ID
|
|
4983
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
4984
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
4985
|
+
* - device_type?: 'desktop'|'mobile'|'tablet'|'bot'|'other'
|
|
4986
|
+
* - country_code?: string - 2-letter country code
|
|
4987
|
+
* - is_bot?: boolean - Filter by bot status
|
|
4988
|
+
* - sort?: 'started_at'|'total_duration'|'pageview_count' - Sort field
|
|
4989
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
4990
|
+
* - per_page?: number - Items per page (max 100)
|
|
4991
|
+
* @returns Promise with paginated sessions data
|
|
4992
|
+
*/
|
|
4993
|
+
static listSessions<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
4994
|
+
/**
|
|
4995
|
+
* Get a paginated list of pageviews with filtering options
|
|
4996
|
+
*
|
|
4997
|
+
* @param params Filtering options:
|
|
4998
|
+
* - title_id?: string - Filter by title ID
|
|
4999
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
5000
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5001
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5002
|
+
* - is_exit?: boolean - Filter by exit pageviews
|
|
5003
|
+
* - sort?: 'occurred_at'|'load_time_ms'|'dom_complete_ms' - Sort field
|
|
5004
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
5005
|
+
* - per_page?: number - Items per page (max 100)
|
|
5006
|
+
* @returns Promise with paginated pageviews data
|
|
5007
|
+
*/
|
|
5008
|
+
static listPageviews<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5009
|
+
/**
|
|
5010
|
+
* Get a paginated list of events with filtering options
|
|
5011
|
+
*
|
|
5012
|
+
* @param params Filtering options:
|
|
5013
|
+
* - title_id?: string - Filter by title ID
|
|
5014
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
5015
|
+
* - event_name?: string - Filter by event name
|
|
5016
|
+
* - event_category?: string - Filter by event category
|
|
5017
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5018
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5019
|
+
* - sort?: 'occurred_at'|'event_name' - Sort field
|
|
5020
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
5021
|
+
* - per_page?: number - Items per page (max 100)
|
|
5022
|
+
* @returns Promise with paginated events data
|
|
5023
|
+
*/
|
|
5024
|
+
static listEvents<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5025
|
+
/**
|
|
5026
|
+
* Get an analytics overview with summarized metrics
|
|
5027
|
+
*
|
|
5028
|
+
* @param params Overview options:
|
|
5029
|
+
* - title_id: string - Required title ID
|
|
5030
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5031
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5032
|
+
* - group_by?: 'day'|'week'|'month'|'year' - Grouping period
|
|
5033
|
+
* - include_breakdowns?: boolean - Include detailed breakdowns
|
|
5034
|
+
* @returns Promise with overview data
|
|
5035
|
+
*/
|
|
5036
|
+
static overview<T>(params: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5037
|
+
/**
|
|
5038
|
+
* Single ingestion endpoint for sessions, pageviews and events
|
|
5039
|
+
*
|
|
5040
|
+
* @param data Analytics data payload with type property:
|
|
5041
|
+
* - type: 'session'|'pageview'|'event' - Type of analytics data
|
|
5042
|
+
* - title_id: string - Title ID
|
|
5043
|
+
* - tracking_token: string - HMAC token for verification
|
|
5044
|
+
* - plus type-specific fields
|
|
5045
|
+
* @returns Promise with acceptance response
|
|
5046
|
+
*/
|
|
5047
|
+
static collect<T>(data: object): AxiosPromise<Response<T>>;
|
|
5048
|
+
/**
|
|
5049
|
+
* Get average session length data with optional grouping
|
|
5050
|
+
*
|
|
5051
|
+
* @param params Filtering options:
|
|
5052
|
+
* - title_id?: string - Filter by title ID
|
|
5053
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5054
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5055
|
+
* - group_by?: 'day'|'week'|'month' - Grouping period
|
|
5056
|
+
* - device_type?: string - Filter by device type
|
|
5057
|
+
* - country_code?: string - Filter by country
|
|
5058
|
+
* @returns Promise with average session data
|
|
5059
|
+
*/
|
|
5060
|
+
static sessionsAverage<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5061
|
+
/**
|
|
5062
|
+
* Get session duration histogram data
|
|
5063
|
+
*
|
|
5064
|
+
* @param params Filtering options:
|
|
5065
|
+
* - title_id?: string - Filter by title ID
|
|
5066
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5067
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5068
|
+
* - bucket_size?: number - Duration bucket size in seconds
|
|
5069
|
+
* @returns Promise with histogram data
|
|
5070
|
+
*/
|
|
5071
|
+
static sessionsHistogram<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5072
|
+
/**
|
|
5073
|
+
* Get pageviews over time with optional grouping
|
|
5074
|
+
*
|
|
5075
|
+
* @param params Filtering options:
|
|
5076
|
+
* - title_id?: string - Filter by title ID
|
|
5077
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5078
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5079
|
+
* - group_by?: 'hour'|'day'|'week'|'month' - Grouping period
|
|
5080
|
+
* - path?: string - Filter by specific path
|
|
5081
|
+
* @returns Promise with pageviews over time data
|
|
5082
|
+
*/
|
|
5083
|
+
static pageviewsOverTime<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5084
|
+
/**
|
|
5085
|
+
* Get top pages by views
|
|
5086
|
+
*
|
|
5087
|
+
* @param params Filtering options:
|
|
5088
|
+
* - title_id?: string - Filter by title ID
|
|
5089
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5090
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5091
|
+
* - limit?: number - Number of top pages to return
|
|
5092
|
+
* @returns Promise with top pages data
|
|
5093
|
+
*/
|
|
5094
|
+
static topPages<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5095
|
+
/**
|
|
5096
|
+
* Get summary of events
|
|
5097
|
+
*
|
|
5098
|
+
* @param params Filtering options:
|
|
5099
|
+
* - title_id?: string - Filter by title ID
|
|
5100
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5101
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5102
|
+
* - event_category?: string - Filter by event category
|
|
5103
|
+
* @returns Promise with events summary data
|
|
5104
|
+
*/
|
|
5105
|
+
static eventsSummary<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5106
|
+
/**
|
|
5107
|
+
* Get most popular events
|
|
5108
|
+
*
|
|
5109
|
+
* @param params Filtering options:
|
|
5110
|
+
* - title_id?: string - Filter by title ID
|
|
5111
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5112
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5113
|
+
* - limit?: number - Number of events to return
|
|
5114
|
+
* @returns Promise with popular events data
|
|
5115
|
+
*/
|
|
5116
|
+
static popularEvents<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5117
|
+
/**
|
|
5118
|
+
* Get geographic distribution of visitors
|
|
5119
|
+
*
|
|
5120
|
+
* @param params Filtering options:
|
|
5121
|
+
* - title_id?: string - Filter by title ID
|
|
5122
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5123
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5124
|
+
* - limit?: number - Number of countries to return
|
|
5125
|
+
* @returns Promise with geo distribution data
|
|
5126
|
+
*/
|
|
5127
|
+
static geoDistribution<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5128
|
+
/**
|
|
5129
|
+
* Get device type breakdown
|
|
5130
|
+
*
|
|
5131
|
+
* @param params Filtering options:
|
|
5132
|
+
* - title_id?: string - Filter by title ID
|
|
5133
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5134
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5135
|
+
* @returns Promise with device breakdown data
|
|
5136
|
+
*/
|
|
5137
|
+
static deviceBreakdown<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5138
|
+
/**
|
|
5139
|
+
* Get top referrers
|
|
5140
|
+
*
|
|
5141
|
+
* @param params Filtering options:
|
|
5142
|
+
* - title_id?: string - Filter by title ID
|
|
5143
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5144
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5145
|
+
* - limit?: number - Number of referrers to return
|
|
5146
|
+
* @returns Promise with referrers data
|
|
5147
|
+
*/
|
|
5148
|
+
static referrers<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5149
|
+
/**
|
|
5150
|
+
* Get UTM campaign performance
|
|
5151
|
+
*
|
|
5152
|
+
* @param params Filtering options:
|
|
5153
|
+
* - title_id?: string - Filter by title ID
|
|
5154
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
5155
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
5156
|
+
* - group_by?: 'source'|'medium'|'campaign' - Grouping field
|
|
5157
|
+
* @returns Promise with UTM performance data
|
|
5158
|
+
*/
|
|
5159
|
+
static utmPerformance<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
5160
|
+
}
|
|
5161
|
+
|
|
4967
5162
|
interface Route {
|
|
4968
5163
|
url: string;
|
|
4969
5164
|
method: string;
|
|
@@ -5026,6 +5221,14 @@ declare class Session {
|
|
|
5026
5221
|
email: string;
|
|
5027
5222
|
username: string;
|
|
5028
5223
|
}): void;
|
|
5224
|
+
/**
|
|
5225
|
+
* Generate a tracking token for analytics collection
|
|
5226
|
+
* @param titleId The title ID to generate token for
|
|
5227
|
+
* @param secret The secret key (should match server config)
|
|
5228
|
+
* @returns HMAC-SHA256 token
|
|
5229
|
+
* @throws Error if crypto operations fail
|
|
5230
|
+
*/
|
|
5231
|
+
static generateTrackingToken(titleId: string, secret: string): string;
|
|
5029
5232
|
}
|
|
5030
5233
|
|
|
5031
5234
|
declare class Storage {
|
|
@@ -5296,6 +5499,7 @@ declare class Glitch {
|
|
|
5296
5499
|
Scheduler: typeof Scheduler;
|
|
5297
5500
|
Funnel: typeof Funnel;
|
|
5298
5501
|
SocialStats: typeof SocialStats;
|
|
5502
|
+
WebsiteAnalytics: typeof WebsiteAnalytics;
|
|
5299
5503
|
};
|
|
5300
5504
|
static util: {
|
|
5301
5505
|
Requests: typeof Requests;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glitch-javascript-sdk",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "Javascript SDK for Glitch",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"vite-plugin-node-polyfills": "^0.17.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@types/crypto-js": "^4.2.2",
|
|
38
39
|
"axios": "^1.6.2",
|
|
39
40
|
"buffer": "^6.0.3",
|
|
40
41
|
"crypto-js": "^4.2.0",
|
package/src/api/Scheduler.ts
CHANGED
|
@@ -108,6 +108,19 @@ class Scheduler {
|
|
|
108
108
|
return Requests.processRoute(SchedulerRoute.routes.listUpdates, {}, { scheduler_id }, params);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Search the updates related to a promotion schedule.
|
|
113
|
+
*
|
|
114
|
+
* @see https://api.glitch.fun/api/documentation#/Scheduler/searchTitleUpdates
|
|
115
|
+
*
|
|
116
|
+
* @param scheduler_id The ID of the promotion schedule.
|
|
117
|
+
*
|
|
118
|
+
* @returns promise
|
|
119
|
+
*/
|
|
120
|
+
public static searchUpdates<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
121
|
+
return Requests.processRoute(SchedulerRoute.routes.listUpdates, {}, { scheduler_id }, params);
|
|
122
|
+
}
|
|
123
|
+
|
|
111
124
|
/**
|
|
112
125
|
* Create a new title update for a promotion schedule.
|
|
113
126
|
*
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import WebsiteAnalyticsRoute from "../routes/WebsiteAnalyticsRoute";
|
|
2
|
+
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise } from "axios";
|
|
5
|
+
|
|
6
|
+
class WebsiteAnalytics {
|
|
7
|
+
/**
|
|
8
|
+
* List website analytics sessions with comprehensive filtering
|
|
9
|
+
*
|
|
10
|
+
* @param params Filtering options:
|
|
11
|
+
* - title_id?: string - Filter by title ID
|
|
12
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
13
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
14
|
+
* - device_type?: 'desktop'|'mobile'|'tablet'|'bot'|'other'
|
|
15
|
+
* - country_code?: string - 2-letter country code
|
|
16
|
+
* - is_bot?: boolean - Filter by bot status
|
|
17
|
+
* - sort?: 'started_at'|'total_duration'|'pageview_count' - Sort field
|
|
18
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
19
|
+
* - per_page?: number - Items per page (max 100)
|
|
20
|
+
* @returns Promise with paginated sessions data
|
|
21
|
+
*/
|
|
22
|
+
public static listSessions<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
23
|
+
return Requests.processRoute(
|
|
24
|
+
WebsiteAnalyticsRoute.routes.listSessions,
|
|
25
|
+
{},
|
|
26
|
+
undefined,
|
|
27
|
+
params
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get a paginated list of pageviews with filtering options
|
|
33
|
+
*
|
|
34
|
+
* @param params Filtering options:
|
|
35
|
+
* - title_id?: string - Filter by title ID
|
|
36
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
37
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
38
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
39
|
+
* - is_exit?: boolean - Filter by exit pageviews
|
|
40
|
+
* - sort?: 'occurred_at'|'load_time_ms'|'dom_complete_ms' - Sort field
|
|
41
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
42
|
+
* - per_page?: number - Items per page (max 100)
|
|
43
|
+
* @returns Promise with paginated pageviews data
|
|
44
|
+
*/
|
|
45
|
+
public static listPageviews<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
46
|
+
return Requests.processRoute(
|
|
47
|
+
WebsiteAnalyticsRoute.routes.listPageviews,
|
|
48
|
+
{},
|
|
49
|
+
undefined,
|
|
50
|
+
params
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get a paginated list of events with filtering options
|
|
56
|
+
*
|
|
57
|
+
* @param params Filtering options:
|
|
58
|
+
* - title_id?: string - Filter by title ID
|
|
59
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
60
|
+
* - event_name?: string - Filter by event name
|
|
61
|
+
* - event_category?: string - Filter by event category
|
|
62
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
63
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
64
|
+
* - sort?: 'occurred_at'|'event_name' - Sort field
|
|
65
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
66
|
+
* - per_page?: number - Items per page (max 100)
|
|
67
|
+
* @returns Promise with paginated events data
|
|
68
|
+
*/
|
|
69
|
+
public static listEvents<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
70
|
+
return Requests.processRoute(
|
|
71
|
+
WebsiteAnalyticsRoute.routes.listEvents,
|
|
72
|
+
{},
|
|
73
|
+
undefined,
|
|
74
|
+
params
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get an analytics overview with summarized metrics
|
|
80
|
+
*
|
|
81
|
+
* @param params Overview options:
|
|
82
|
+
* - title_id: string - Required title ID
|
|
83
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
84
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
85
|
+
* - group_by?: 'day'|'week'|'month'|'year' - Grouping period
|
|
86
|
+
* - include_breakdowns?: boolean - Include detailed breakdowns
|
|
87
|
+
* @returns Promise with overview data
|
|
88
|
+
*/
|
|
89
|
+
public static overview<T>(params: Record<string, any>): AxiosPromise<Response<T>> {
|
|
90
|
+
return Requests.processRoute(
|
|
91
|
+
WebsiteAnalyticsRoute.routes.overview,
|
|
92
|
+
{},
|
|
93
|
+
undefined,
|
|
94
|
+
params
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Single ingestion endpoint for sessions, pageviews and events
|
|
100
|
+
*
|
|
101
|
+
* @param data Analytics data payload with type property:
|
|
102
|
+
* - type: 'session'|'pageview'|'event' - Type of analytics data
|
|
103
|
+
* - title_id: string - Title ID
|
|
104
|
+
* - tracking_token: string - HMAC token for verification
|
|
105
|
+
* - plus type-specific fields
|
|
106
|
+
* @returns Promise with acceptance response
|
|
107
|
+
*/
|
|
108
|
+
public static collect<T>(data: object): AxiosPromise<Response<T>> {
|
|
109
|
+
return Requests.processRoute(
|
|
110
|
+
WebsiteAnalyticsRoute.routes.collect,
|
|
111
|
+
data
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get average session length data with optional grouping
|
|
117
|
+
*
|
|
118
|
+
* @param params Filtering options:
|
|
119
|
+
* - title_id?: string - Filter by title ID
|
|
120
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
121
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
122
|
+
* - group_by?: 'day'|'week'|'month' - Grouping period
|
|
123
|
+
* - device_type?: string - Filter by device type
|
|
124
|
+
* - country_code?: string - Filter by country
|
|
125
|
+
* @returns Promise with average session data
|
|
126
|
+
*/
|
|
127
|
+
public static sessionsAverage<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
128
|
+
return Requests.processRoute(
|
|
129
|
+
WebsiteAnalyticsRoute.routes.sessionsAverage,
|
|
130
|
+
{},
|
|
131
|
+
undefined,
|
|
132
|
+
params
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Get session duration histogram data
|
|
138
|
+
*
|
|
139
|
+
* @param params Filtering options:
|
|
140
|
+
* - title_id?: string - Filter by title ID
|
|
141
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
142
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
143
|
+
* - bucket_size?: number - Duration bucket size in seconds
|
|
144
|
+
* @returns Promise with histogram data
|
|
145
|
+
*/
|
|
146
|
+
public static sessionsHistogram<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
147
|
+
return Requests.processRoute(
|
|
148
|
+
WebsiteAnalyticsRoute.routes.sessionsHistogram,
|
|
149
|
+
{},
|
|
150
|
+
undefined,
|
|
151
|
+
params
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get pageviews over time with optional grouping
|
|
157
|
+
*
|
|
158
|
+
* @param params Filtering options:
|
|
159
|
+
* - title_id?: string - Filter by title ID
|
|
160
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
161
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
162
|
+
* - group_by?: 'hour'|'day'|'week'|'month' - Grouping period
|
|
163
|
+
* - path?: string - Filter by specific path
|
|
164
|
+
* @returns Promise with pageviews over time data
|
|
165
|
+
*/
|
|
166
|
+
public static pageviewsOverTime<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
167
|
+
return Requests.processRoute(
|
|
168
|
+
WebsiteAnalyticsRoute.routes.pageviewsOverTime,
|
|
169
|
+
{},
|
|
170
|
+
undefined,
|
|
171
|
+
params
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Get top pages by views
|
|
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
|
+
* - limit?: number - Number of top pages to return
|
|
183
|
+
* @returns Promise with top pages data
|
|
184
|
+
*/
|
|
185
|
+
public static topPages<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
186
|
+
return Requests.processRoute(
|
|
187
|
+
WebsiteAnalyticsRoute.routes.topPages,
|
|
188
|
+
{},
|
|
189
|
+
undefined,
|
|
190
|
+
params
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Get summary of events
|
|
196
|
+
*
|
|
197
|
+
* @param params Filtering options:
|
|
198
|
+
* - title_id?: string - Filter by title ID
|
|
199
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
200
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
201
|
+
* - event_category?: string - Filter by event category
|
|
202
|
+
* @returns Promise with events summary data
|
|
203
|
+
*/
|
|
204
|
+
public static eventsSummary<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
205
|
+
return Requests.processRoute(
|
|
206
|
+
WebsiteAnalyticsRoute.routes.eventsSummary,
|
|
207
|
+
{},
|
|
208
|
+
undefined,
|
|
209
|
+
params
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get most popular events
|
|
215
|
+
*
|
|
216
|
+
* @param params Filtering options:
|
|
217
|
+
* - title_id?: string - Filter by title ID
|
|
218
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
219
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
220
|
+
* - limit?: number - Number of events to return
|
|
221
|
+
* @returns Promise with popular events data
|
|
222
|
+
*/
|
|
223
|
+
public static popularEvents<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
224
|
+
return Requests.processRoute(
|
|
225
|
+
WebsiteAnalyticsRoute.routes.popularEvents,
|
|
226
|
+
{},
|
|
227
|
+
undefined,
|
|
228
|
+
params
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Get geographic distribution of visitors
|
|
234
|
+
*
|
|
235
|
+
* @param params Filtering options:
|
|
236
|
+
* - title_id?: string - Filter by title ID
|
|
237
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
238
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
239
|
+
* - limit?: number - Number of countries to return
|
|
240
|
+
* @returns Promise with geo distribution data
|
|
241
|
+
*/
|
|
242
|
+
public static geoDistribution<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
243
|
+
return Requests.processRoute(
|
|
244
|
+
WebsiteAnalyticsRoute.routes.geoDistribution,
|
|
245
|
+
{},
|
|
246
|
+
undefined,
|
|
247
|
+
params
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Get device type breakdown
|
|
253
|
+
*
|
|
254
|
+
* @param params Filtering options:
|
|
255
|
+
* - title_id?: string - Filter by title ID
|
|
256
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
257
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
258
|
+
* @returns Promise with device breakdown data
|
|
259
|
+
*/
|
|
260
|
+
public static deviceBreakdown<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
261
|
+
return Requests.processRoute(
|
|
262
|
+
WebsiteAnalyticsRoute.routes.deviceBreakdown,
|
|
263
|
+
{},
|
|
264
|
+
undefined,
|
|
265
|
+
params
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get top referrers
|
|
271
|
+
*
|
|
272
|
+
* @param params Filtering options:
|
|
273
|
+
* - title_id?: string - Filter by title ID
|
|
274
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
275
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
276
|
+
* - limit?: number - Number of referrers to return
|
|
277
|
+
* @returns Promise with referrers data
|
|
278
|
+
*/
|
|
279
|
+
public static referrers<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
280
|
+
return Requests.processRoute(
|
|
281
|
+
WebsiteAnalyticsRoute.routes.referrers,
|
|
282
|
+
{},
|
|
283
|
+
undefined,
|
|
284
|
+
params
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Get UTM campaign performance
|
|
290
|
+
*
|
|
291
|
+
* @param params Filtering options:
|
|
292
|
+
* - title_id?: string - Filter by title ID
|
|
293
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
294
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
295
|
+
* - group_by?: 'source'|'medium'|'campaign' - Grouping field
|
|
296
|
+
* @returns Promise with UTM performance data
|
|
297
|
+
*/
|
|
298
|
+
public static utmPerformance<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
299
|
+
return Requests.processRoute(
|
|
300
|
+
WebsiteAnalyticsRoute.routes.utmPerformance,
|
|
301
|
+
{},
|
|
302
|
+
undefined,
|
|
303
|
+
params
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export default WebsiteAnalytics;
|
package/src/api/index.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
|
|
|
35
36
|
export {Ads};
|
|
36
37
|
export {Auth};
|
|
@@ -64,4 +65,5 @@ export {Media};
|
|
|
64
65
|
export {Scheduler};
|
|
65
66
|
export {Funnel};
|
|
66
67
|
export {SocialStats};
|
|
67
|
-
export {Hashtags};
|
|
68
|
+
export {Hashtags};
|
|
69
|
+
export {WebsiteAnalytics};
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {Scheduler} from "./api";
|
|
|
35
35
|
import {Funnel} from "./api";
|
|
36
36
|
import {SocialStats} from "./api";
|
|
37
37
|
import {Hashtags} from "./api";
|
|
38
|
+
import {WebsiteAnalytics} from "./api";
|
|
38
39
|
|
|
39
40
|
import Requests from "./util/Requests";
|
|
40
41
|
import Parser from "./util/Parser";
|
|
@@ -98,7 +99,8 @@ class Glitch {
|
|
|
98
99
|
Media : Media,
|
|
99
100
|
Scheduler : Scheduler,
|
|
100
101
|
Funnel: Funnel,
|
|
101
|
-
SocialStats : SocialStats
|
|
102
|
+
SocialStats : SocialStats,
|
|
103
|
+
WebsiteAnalytics: WebsiteAnalytics
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
public static util = {
|
|
@@ -13,6 +13,7 @@ class SchedulerRoute {
|
|
|
13
13
|
|
|
14
14
|
// Title Update Routes
|
|
15
15
|
listUpdates: { url: '/schedulers/{scheduler_id}/updates', method: HTTP_METHODS.GET },
|
|
16
|
+
searchUpdates: { url: '/schedulers/{scheduler_id}/updates/search', method: HTTP_METHODS.GET },
|
|
16
17
|
createUpdate: { url: '/schedulers/{scheduler_id}/updates', method: HTTP_METHODS.POST },
|
|
17
18
|
getUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.GET },
|
|
18
19
|
updateUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.PUT },
|