glitch-javascript-sdk 1.8.0 → 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.
@@ -0,0 +1,7 @@
1
+ import Route from "./interface";
2
+ declare class WebsiteAnalyticsRoute {
3
+ static routes: {
4
+ [key: string]: Route;
5
+ };
6
+ }
7
+ export default WebsiteAnalyticsRoute;
@@ -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
@@ -862,6 +862,37 @@ declare class Ads {
862
862
  * @returns A response object with data (funding instruments)
863
863
  */
864
864
  static listCampaignFundingInstruments<T>(campaign_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
865
+ /**
866
+ * GET /ads/reddit/targeting/carriers
867
+ *
868
+ * Example usage:
869
+ * Ads.listRedditCarriers({ scheduler_id: 'uuid-of-scheduler', 'page.size': 50 })
870
+ */
871
+ static listRedditCarriers<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
872
+ /**
873
+ * GET /ads/reddit/targeting/communities?names=sub1,sub2
874
+ */
875
+ static listRedditCommunities<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
876
+ /**
877
+ * GET /ads/reddit/targeting/communities/search?query=xyz
878
+ */
879
+ static searchRedditCommunities<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
880
+ /**
881
+ * GET /ads/reddit/targeting/devices
882
+ */
883
+ static listRedditDevices<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
884
+ /**
885
+ * GET /ads/reddit/targeting/geolocations
886
+ */
887
+ static listRedditGeolocations<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
888
+ /**
889
+ * GET /ads/reddit/targeting/interests
890
+ */
891
+ static listRedditInterests<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
892
+ /**
893
+ * GET /ads/reddit/targeting/third_party_audiences
894
+ */
895
+ static listRedditThirdPartyAudiences<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
865
896
  }
866
897
 
867
898
  declare class Communities {
@@ -4492,6 +4523,16 @@ declare class Scheduler {
4492
4523
  * @returns promise
4493
4524
  */
4494
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>>;
4495
4536
  /**
4496
4537
  * Create a new title update for a promotion schedule.
4497
4538
  *
@@ -4605,6 +4646,13 @@ declare class Scheduler {
4605
4646
  * @returns promise
4606
4647
  */
4607
4648
  static clearRedditAuth<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
4649
+ /**
4650
+ * Clear Reddit Ads OAuth credentials from a promotion schedule.
4651
+ *
4652
+ * @param scheduler_id The ID of the promotion schedule.
4653
+ * @returns promise
4654
+ */
4655
+ static clearRedditAdsAuth<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
4608
4656
  /**
4609
4657
  * Clear YouTube OAuth credentials from a promotion schedule.
4610
4658
  *
@@ -4926,6 +4974,191 @@ declare class Hashtags {
4926
4974
  static top<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
4927
4975
  }
4928
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
+
4929
5162
  interface Route {
4930
5163
  url: string;
4931
5164
  method: string;
@@ -4988,6 +5221,14 @@ declare class Session {
4988
5221
  email: string;
4989
5222
  username: string;
4990
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;
4991
5232
  }
4992
5233
 
4993
5234
  declare class Storage {
@@ -5258,6 +5499,7 @@ declare class Glitch {
5258
5499
  Scheduler: typeof Scheduler;
5259
5500
  Funnel: typeof Funnel;
5260
5501
  SocialStats: typeof SocialStats;
5502
+ WebsiteAnalytics: typeof WebsiteAnalytics;
5261
5503
  };
5262
5504
  static util: {
5263
5505
  Requests: typeof Requests;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
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/Ads.ts CHANGED
@@ -474,6 +474,93 @@ class Ads {
474
474
  );
475
475
  }
476
476
 
477
+ /**
478
+ * GET /ads/reddit/targeting/carriers
479
+ *
480
+ * Example usage:
481
+ * Ads.listRedditCarriers({ scheduler_id: 'uuid-of-scheduler', 'page.size': 50 })
482
+ */
483
+ public static listRedditCarriers<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
484
+ return Requests.processRoute(
485
+ AdsRoute.routes.getRedditCarriers,
486
+ undefined,
487
+ undefined,
488
+ params
489
+ );
490
+ }
491
+
492
+ /**
493
+ * GET /ads/reddit/targeting/communities?names=sub1,sub2
494
+ */
495
+ public static listRedditCommunities<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
496
+ return Requests.processRoute(
497
+ AdsRoute.routes.getRedditCommunities,
498
+ undefined,
499
+ undefined,
500
+ params
501
+ );
502
+ }
503
+
504
+ /**
505
+ * GET /ads/reddit/targeting/communities/search?query=xyz
506
+ */
507
+ public static searchRedditCommunities<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
508
+ return Requests.processRoute(
509
+ AdsRoute.routes.searchRedditCommunities,
510
+ undefined,
511
+ undefined,
512
+ params
513
+ );
514
+ }
515
+
516
+ /**
517
+ * GET /ads/reddit/targeting/devices
518
+ */
519
+ public static listRedditDevices<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
520
+ return Requests.processRoute(
521
+ AdsRoute.routes.getRedditDevices,
522
+ undefined,
523
+ undefined,
524
+ params
525
+ );
526
+ }
527
+
528
+ /**
529
+ * GET /ads/reddit/targeting/geolocations
530
+ */
531
+ public static listRedditGeolocations<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
532
+ return Requests.processRoute(
533
+ AdsRoute.routes.getRedditGeolocations,
534
+ undefined,
535
+ undefined,
536
+ params
537
+ );
538
+ }
539
+
540
+ /**
541
+ * GET /ads/reddit/targeting/interests
542
+ */
543
+ public static listRedditInterests<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
544
+ return Requests.processRoute(
545
+ AdsRoute.routes.getRedditInterests,
546
+ undefined,
547
+ undefined,
548
+ params
549
+ );
550
+ }
551
+
552
+ /**
553
+ * GET /ads/reddit/targeting/third_party_audiences
554
+ */
555
+ public static listRedditThirdPartyAudiences<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
556
+ return Requests.processRoute(
557
+ AdsRoute.routes.getRedditThirdPartyAudiences,
558
+ undefined,
559
+ undefined,
560
+ params
561
+ );
562
+ }
563
+
477
564
  }
478
565
 
479
566
  export default Ads;
@@ -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
  *
@@ -260,6 +273,16 @@ class Scheduler {
260
273
  return Requests.processRoute(SchedulerRoute.routes.clearRedditAuth, {}, { scheduler_id }, params);
261
274
  }
262
275
 
276
+ /**
277
+ * Clear Reddit Ads OAuth credentials from a promotion schedule.
278
+ *
279
+ * @param scheduler_id The ID of the promotion schedule.
280
+ * @returns promise
281
+ */
282
+ public static clearRedditAdsAuth<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
283
+ return Requests.processRoute(SchedulerRoute.routes.clearRedditAdsAuth, {}, { scheduler_id }, params);
284
+ }
285
+
263
286
  /**
264
287
  * Clear YouTube OAuth credentials from a promotion schedule.
265
288
  *