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
package/dist/cjs/index.js
CHANGED
|
@@ -25352,6 +25352,7 @@ var SchedulerRoute = /** @class */ (function () {
|
|
|
25352
25352
|
getSchedulePosts: { url: '/schedulers/{scheduler_id}/posts', method: HTTP_METHODS.GET },
|
|
25353
25353
|
// Title Update Routes
|
|
25354
25354
|
listUpdates: { url: '/schedulers/{scheduler_id}/updates', method: HTTP_METHODS.GET },
|
|
25355
|
+
searchUpdates: { url: '/schedulers/{scheduler_id}/updates/search', method: HTTP_METHODS.GET },
|
|
25355
25356
|
createUpdate: { url: '/schedulers/{scheduler_id}/updates', method: HTTP_METHODS.POST },
|
|
25356
25357
|
getUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.GET },
|
|
25357
25358
|
updateUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.PUT },
|
|
@@ -25537,6 +25538,18 @@ var Scheduler = /** @class */ (function () {
|
|
|
25537
25538
|
Scheduler.listUpdates = function (scheduler_id, params) {
|
|
25538
25539
|
return Requests.processRoute(SchedulerRoute.routes.listUpdates, {}, { scheduler_id: scheduler_id }, params);
|
|
25539
25540
|
};
|
|
25541
|
+
/**
|
|
25542
|
+
* Search the updates related to a promotion schedule.
|
|
25543
|
+
*
|
|
25544
|
+
* @see https://api.glitch.fun/api/documentation#/Scheduler/searchTitleUpdates
|
|
25545
|
+
*
|
|
25546
|
+
* @param scheduler_id The ID of the promotion schedule.
|
|
25547
|
+
*
|
|
25548
|
+
* @returns promise
|
|
25549
|
+
*/
|
|
25550
|
+
Scheduler.searchUpdates = function (scheduler_id, params) {
|
|
25551
|
+
return Requests.processRoute(SchedulerRoute.routes.listUpdates, {}, { scheduler_id: scheduler_id }, params);
|
|
25552
|
+
};
|
|
25540
25553
|
/**
|
|
25541
25554
|
* Create a new title update for a promotion schedule.
|
|
25542
25555
|
*
|
|
@@ -26157,6 +26170,292 @@ var Hashtags = /** @class */ (function () {
|
|
|
26157
26170
|
return Hashtags;
|
|
26158
26171
|
}());
|
|
26159
26172
|
|
|
26173
|
+
var WebsiteAnalyticsRoute = /** @class */ (function () {
|
|
26174
|
+
function WebsiteAnalyticsRoute() {
|
|
26175
|
+
}
|
|
26176
|
+
WebsiteAnalyticsRoute.routes = {
|
|
26177
|
+
listSessions: {
|
|
26178
|
+
url: '/analytics/sessions',
|
|
26179
|
+
method: HTTP_METHODS.GET
|
|
26180
|
+
},
|
|
26181
|
+
listPageviews: {
|
|
26182
|
+
url: '/analytics/pageviews',
|
|
26183
|
+
method: HTTP_METHODS.GET
|
|
26184
|
+
},
|
|
26185
|
+
listEvents: {
|
|
26186
|
+
url: '/analytics/events',
|
|
26187
|
+
method: HTTP_METHODS.GET
|
|
26188
|
+
},
|
|
26189
|
+
overview: {
|
|
26190
|
+
url: '/analytics/overview',
|
|
26191
|
+
method: HTTP_METHODS.GET
|
|
26192
|
+
},
|
|
26193
|
+
collect: {
|
|
26194
|
+
url: '/analytics/collect',
|
|
26195
|
+
method: HTTP_METHODS.POST
|
|
26196
|
+
},
|
|
26197
|
+
sessionsAverage: {
|
|
26198
|
+
url: '/analytics/sessions/average',
|
|
26199
|
+
method: HTTP_METHODS.GET
|
|
26200
|
+
},
|
|
26201
|
+
sessionsHistogram: {
|
|
26202
|
+
url: '/analytics/sessions/histogram',
|
|
26203
|
+
method: HTTP_METHODS.GET
|
|
26204
|
+
},
|
|
26205
|
+
pageviewsOverTime: {
|
|
26206
|
+
url: '/analytics/pageviews/over-time',
|
|
26207
|
+
method: HTTP_METHODS.GET
|
|
26208
|
+
},
|
|
26209
|
+
topPages: {
|
|
26210
|
+
url: '/analytics/pageviews/top-pages',
|
|
26211
|
+
method: HTTP_METHODS.GET
|
|
26212
|
+
},
|
|
26213
|
+
eventsSummary: {
|
|
26214
|
+
url: '/analytics/events/summary',
|
|
26215
|
+
method: HTTP_METHODS.GET
|
|
26216
|
+
},
|
|
26217
|
+
popularEvents: {
|
|
26218
|
+
url: '/analytics/events/popular',
|
|
26219
|
+
method: HTTP_METHODS.GET
|
|
26220
|
+
},
|
|
26221
|
+
geoDistribution: {
|
|
26222
|
+
url: '/analytics/geo-distribution',
|
|
26223
|
+
method: HTTP_METHODS.GET
|
|
26224
|
+
},
|
|
26225
|
+
deviceBreakdown: {
|
|
26226
|
+
url: '/analytics/device-breakdown',
|
|
26227
|
+
method: HTTP_METHODS.GET
|
|
26228
|
+
},
|
|
26229
|
+
referrers: {
|
|
26230
|
+
url: '/analytics/referrers',
|
|
26231
|
+
method: HTTP_METHODS.GET
|
|
26232
|
+
},
|
|
26233
|
+
utmPerformance: {
|
|
26234
|
+
url: '/analytics/utm-performance',
|
|
26235
|
+
method: HTTP_METHODS.GET
|
|
26236
|
+
}
|
|
26237
|
+
};
|
|
26238
|
+
return WebsiteAnalyticsRoute;
|
|
26239
|
+
}());
|
|
26240
|
+
|
|
26241
|
+
var WebsiteAnalytics = /** @class */ (function () {
|
|
26242
|
+
function WebsiteAnalytics() {
|
|
26243
|
+
}
|
|
26244
|
+
/**
|
|
26245
|
+
* List website analytics sessions with comprehensive filtering
|
|
26246
|
+
*
|
|
26247
|
+
* @param params Filtering options:
|
|
26248
|
+
* - title_id?: string - Filter by title ID
|
|
26249
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26250
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26251
|
+
* - device_type?: 'desktop'|'mobile'|'tablet'|'bot'|'other'
|
|
26252
|
+
* - country_code?: string - 2-letter country code
|
|
26253
|
+
* - is_bot?: boolean - Filter by bot status
|
|
26254
|
+
* - sort?: 'started_at'|'total_duration'|'pageview_count' - Sort field
|
|
26255
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
26256
|
+
* - per_page?: number - Items per page (max 100)
|
|
26257
|
+
* @returns Promise with paginated sessions data
|
|
26258
|
+
*/
|
|
26259
|
+
WebsiteAnalytics.listSessions = function (params) {
|
|
26260
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.listSessions, {}, undefined, params);
|
|
26261
|
+
};
|
|
26262
|
+
/**
|
|
26263
|
+
* Get a paginated list of pageviews with filtering options
|
|
26264
|
+
*
|
|
26265
|
+
* @param params Filtering options:
|
|
26266
|
+
* - title_id?: string - Filter by title ID
|
|
26267
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
26268
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26269
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26270
|
+
* - is_exit?: boolean - Filter by exit pageviews
|
|
26271
|
+
* - sort?: 'occurred_at'|'load_time_ms'|'dom_complete_ms' - Sort field
|
|
26272
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
26273
|
+
* - per_page?: number - Items per page (max 100)
|
|
26274
|
+
* @returns Promise with paginated pageviews data
|
|
26275
|
+
*/
|
|
26276
|
+
WebsiteAnalytics.listPageviews = function (params) {
|
|
26277
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.listPageviews, {}, undefined, params);
|
|
26278
|
+
};
|
|
26279
|
+
/**
|
|
26280
|
+
* Get a paginated list of events with filtering options
|
|
26281
|
+
*
|
|
26282
|
+
* @param params Filtering options:
|
|
26283
|
+
* - title_id?: string - Filter by title ID
|
|
26284
|
+
* - analytics_session_id?: string - Filter by session ID
|
|
26285
|
+
* - event_name?: string - Filter by event name
|
|
26286
|
+
* - event_category?: string - Filter by event category
|
|
26287
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26288
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26289
|
+
* - sort?: 'occurred_at'|'event_name' - Sort field
|
|
26290
|
+
* - order?: 'asc'|'desc' - Sort order
|
|
26291
|
+
* - per_page?: number - Items per page (max 100)
|
|
26292
|
+
* @returns Promise with paginated events data
|
|
26293
|
+
*/
|
|
26294
|
+
WebsiteAnalytics.listEvents = function (params) {
|
|
26295
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.listEvents, {}, undefined, params);
|
|
26296
|
+
};
|
|
26297
|
+
/**
|
|
26298
|
+
* Get an analytics overview with summarized metrics
|
|
26299
|
+
*
|
|
26300
|
+
* @param params Overview options:
|
|
26301
|
+
* - title_id: string - Required title ID
|
|
26302
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26303
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26304
|
+
* - group_by?: 'day'|'week'|'month'|'year' - Grouping period
|
|
26305
|
+
* - include_breakdowns?: boolean - Include detailed breakdowns
|
|
26306
|
+
* @returns Promise with overview data
|
|
26307
|
+
*/
|
|
26308
|
+
WebsiteAnalytics.overview = function (params) {
|
|
26309
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.overview, {}, undefined, params);
|
|
26310
|
+
};
|
|
26311
|
+
/**
|
|
26312
|
+
* Single ingestion endpoint for sessions, pageviews and events
|
|
26313
|
+
*
|
|
26314
|
+
* @param data Analytics data payload with type property:
|
|
26315
|
+
* - type: 'session'|'pageview'|'event' - Type of analytics data
|
|
26316
|
+
* - title_id: string - Title ID
|
|
26317
|
+
* - tracking_token: string - HMAC token for verification
|
|
26318
|
+
* - plus type-specific fields
|
|
26319
|
+
* @returns Promise with acceptance response
|
|
26320
|
+
*/
|
|
26321
|
+
WebsiteAnalytics.collect = function (data) {
|
|
26322
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.collect, data);
|
|
26323
|
+
};
|
|
26324
|
+
/**
|
|
26325
|
+
* Get average session length data with optional grouping
|
|
26326
|
+
*
|
|
26327
|
+
* @param params Filtering options:
|
|
26328
|
+
* - title_id?: string - Filter by title ID
|
|
26329
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26330
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26331
|
+
* - group_by?: 'day'|'week'|'month' - Grouping period
|
|
26332
|
+
* - device_type?: string - Filter by device type
|
|
26333
|
+
* - country_code?: string - Filter by country
|
|
26334
|
+
* @returns Promise with average session data
|
|
26335
|
+
*/
|
|
26336
|
+
WebsiteAnalytics.sessionsAverage = function (params) {
|
|
26337
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.sessionsAverage, {}, undefined, params);
|
|
26338
|
+
};
|
|
26339
|
+
/**
|
|
26340
|
+
* Get session duration histogram data
|
|
26341
|
+
*
|
|
26342
|
+
* @param params Filtering options:
|
|
26343
|
+
* - title_id?: string - Filter by title ID
|
|
26344
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26345
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26346
|
+
* - bucket_size?: number - Duration bucket size in seconds
|
|
26347
|
+
* @returns Promise with histogram data
|
|
26348
|
+
*/
|
|
26349
|
+
WebsiteAnalytics.sessionsHistogram = function (params) {
|
|
26350
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.sessionsHistogram, {}, undefined, params);
|
|
26351
|
+
};
|
|
26352
|
+
/**
|
|
26353
|
+
* Get pageviews over time with optional grouping
|
|
26354
|
+
*
|
|
26355
|
+
* @param params Filtering options:
|
|
26356
|
+
* - title_id?: string - Filter by title ID
|
|
26357
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26358
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26359
|
+
* - group_by?: 'hour'|'day'|'week'|'month' - Grouping period
|
|
26360
|
+
* - path?: string - Filter by specific path
|
|
26361
|
+
* @returns Promise with pageviews over time data
|
|
26362
|
+
*/
|
|
26363
|
+
WebsiteAnalytics.pageviewsOverTime = function (params) {
|
|
26364
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.pageviewsOverTime, {}, undefined, params);
|
|
26365
|
+
};
|
|
26366
|
+
/**
|
|
26367
|
+
* Get top pages by views
|
|
26368
|
+
*
|
|
26369
|
+
* @param params Filtering options:
|
|
26370
|
+
* - title_id?: string - Filter by title ID
|
|
26371
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26372
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26373
|
+
* - limit?: number - Number of top pages to return
|
|
26374
|
+
* @returns Promise with top pages data
|
|
26375
|
+
*/
|
|
26376
|
+
WebsiteAnalytics.topPages = function (params) {
|
|
26377
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.topPages, {}, undefined, params);
|
|
26378
|
+
};
|
|
26379
|
+
/**
|
|
26380
|
+
* Get summary of events
|
|
26381
|
+
*
|
|
26382
|
+
* @param params Filtering options:
|
|
26383
|
+
* - title_id?: string - Filter by title ID
|
|
26384
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26385
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26386
|
+
* - event_category?: string - Filter by event category
|
|
26387
|
+
* @returns Promise with events summary data
|
|
26388
|
+
*/
|
|
26389
|
+
WebsiteAnalytics.eventsSummary = function (params) {
|
|
26390
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.eventsSummary, {}, undefined, params);
|
|
26391
|
+
};
|
|
26392
|
+
/**
|
|
26393
|
+
* Get most popular events
|
|
26394
|
+
*
|
|
26395
|
+
* @param params Filtering options:
|
|
26396
|
+
* - title_id?: string - Filter by title ID
|
|
26397
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26398
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26399
|
+
* - limit?: number - Number of events to return
|
|
26400
|
+
* @returns Promise with popular events data
|
|
26401
|
+
*/
|
|
26402
|
+
WebsiteAnalytics.popularEvents = function (params) {
|
|
26403
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.popularEvents, {}, undefined, params);
|
|
26404
|
+
};
|
|
26405
|
+
/**
|
|
26406
|
+
* Get geographic distribution of visitors
|
|
26407
|
+
*
|
|
26408
|
+
* @param params Filtering options:
|
|
26409
|
+
* - title_id?: string - Filter by title ID
|
|
26410
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26411
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26412
|
+
* - limit?: number - Number of countries to return
|
|
26413
|
+
* @returns Promise with geo distribution data
|
|
26414
|
+
*/
|
|
26415
|
+
WebsiteAnalytics.geoDistribution = function (params) {
|
|
26416
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.geoDistribution, {}, undefined, params);
|
|
26417
|
+
};
|
|
26418
|
+
/**
|
|
26419
|
+
* Get device type breakdown
|
|
26420
|
+
*
|
|
26421
|
+
* @param params Filtering options:
|
|
26422
|
+
* - title_id?: string - Filter by title ID
|
|
26423
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26424
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26425
|
+
* @returns Promise with device breakdown data
|
|
26426
|
+
*/
|
|
26427
|
+
WebsiteAnalytics.deviceBreakdown = function (params) {
|
|
26428
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.deviceBreakdown, {}, undefined, params);
|
|
26429
|
+
};
|
|
26430
|
+
/**
|
|
26431
|
+
* Get top referrers
|
|
26432
|
+
*
|
|
26433
|
+
* @param params Filtering options:
|
|
26434
|
+
* - title_id?: string - Filter by title ID
|
|
26435
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26436
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26437
|
+
* - limit?: number - Number of referrers to return
|
|
26438
|
+
* @returns Promise with referrers data
|
|
26439
|
+
*/
|
|
26440
|
+
WebsiteAnalytics.referrers = function (params) {
|
|
26441
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.referrers, {}, undefined, params);
|
|
26442
|
+
};
|
|
26443
|
+
/**
|
|
26444
|
+
* Get UTM campaign performance
|
|
26445
|
+
*
|
|
26446
|
+
* @param params Filtering options:
|
|
26447
|
+
* - title_id?: string - Filter by title ID
|
|
26448
|
+
* - start_date?: string - Start date (YYYY-MM-DD)
|
|
26449
|
+
* - end_date?: string - End date (YYYY-MM-DD)
|
|
26450
|
+
* - group_by?: 'source'|'medium'|'campaign' - Grouping field
|
|
26451
|
+
* @returns Promise with UTM performance data
|
|
26452
|
+
*/
|
|
26453
|
+
WebsiteAnalytics.utmPerformance = function (params) {
|
|
26454
|
+
return Requests.processRoute(WebsiteAnalyticsRoute.routes.utmPerformance, {}, undefined, params);
|
|
26455
|
+
};
|
|
26456
|
+
return WebsiteAnalytics;
|
|
26457
|
+
}());
|
|
26458
|
+
|
|
26160
26459
|
var Parser = /** @class */ (function () {
|
|
26161
26460
|
function Parser() {
|
|
26162
26461
|
}
|
|
@@ -26180,6 +26479,75 @@ var Parser = /** @class */ (function () {
|
|
|
26180
26479
|
return Parser;
|
|
26181
26480
|
}());
|
|
26182
26481
|
|
|
26482
|
+
// Browser implementation using crypto-js
|
|
26483
|
+
var BrowserCrypto = /** @class */ (function () {
|
|
26484
|
+
function BrowserCrypto() {
|
|
26485
|
+
this.CryptoJS = require('crypto-js');
|
|
26486
|
+
}
|
|
26487
|
+
BrowserCrypto.prototype.createHmac = function (algorithm, secret) {
|
|
26488
|
+
var _this = this;
|
|
26489
|
+
var data = '';
|
|
26490
|
+
var hmac = {
|
|
26491
|
+
update: function (updateData) {
|
|
26492
|
+
data = updateData;
|
|
26493
|
+
return hmac;
|
|
26494
|
+
},
|
|
26495
|
+
digest: function (encoding) {
|
|
26496
|
+
if (encoding !== 'hex') {
|
|
26497
|
+
throw new Error('Only hex encoding is supported in browser implementation');
|
|
26498
|
+
}
|
|
26499
|
+
return _this.CryptoJS.HmacSHA256(data, secret).toString(_this.CryptoJS.enc.Hex);
|
|
26500
|
+
}
|
|
26501
|
+
};
|
|
26502
|
+
return hmac;
|
|
26503
|
+
};
|
|
26504
|
+
return BrowserCrypto;
|
|
26505
|
+
}());
|
|
26506
|
+
// Node.js implementation that maintains sync interface
|
|
26507
|
+
var NodeCrypto = /** @class */ (function () {
|
|
26508
|
+
function NodeCrypto() {
|
|
26509
|
+
// Use dynamic import but handle it synchronously for interface compliance
|
|
26510
|
+
try {
|
|
26511
|
+
// This will throw in browser environments
|
|
26512
|
+
this.crypto = require('crypto');
|
|
26513
|
+
}
|
|
26514
|
+
catch (e) {
|
|
26515
|
+
this.crypto = undefined;
|
|
26516
|
+
}
|
|
26517
|
+
}
|
|
26518
|
+
NodeCrypto.prototype.createHmac = function (algorithm, secret) {
|
|
26519
|
+
if (!this.crypto) {
|
|
26520
|
+
throw new Error('Node.js crypto module not available');
|
|
26521
|
+
}
|
|
26522
|
+
return this.crypto.createHmac(algorithm, secret);
|
|
26523
|
+
};
|
|
26524
|
+
return NodeCrypto;
|
|
26525
|
+
}());
|
|
26526
|
+
// Determine which crypto implementation to use
|
|
26527
|
+
var getCrypto = function () {
|
|
26528
|
+
var _a;
|
|
26529
|
+
try {
|
|
26530
|
+
// Check if we're in Node.js environment and crypto is available
|
|
26531
|
+
if (typeof process !== 'undefined' && ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
|
|
26532
|
+
var nodeCrypto = new NodeCrypto();
|
|
26533
|
+
// Verify crypto was actually loaded
|
|
26534
|
+
try {
|
|
26535
|
+
nodeCrypto.createHmac('sha256', 'test');
|
|
26536
|
+
return nodeCrypto;
|
|
26537
|
+
}
|
|
26538
|
+
catch (e) {
|
|
26539
|
+
console.warn('Node.js crypto not available, falling back to browser implementation');
|
|
26540
|
+
}
|
|
26541
|
+
}
|
|
26542
|
+
}
|
|
26543
|
+
catch (e) {
|
|
26544
|
+
console.warn('Node.js environment detection failed, falling back to browser implementation');
|
|
26545
|
+
}
|
|
26546
|
+
// Fall back to browser implementation
|
|
26547
|
+
return new BrowserCrypto();
|
|
26548
|
+
};
|
|
26549
|
+
// Singleton crypto instance
|
|
26550
|
+
var cryptoInstance = getCrypto();
|
|
26183
26551
|
var Session = /** @class */ (function () {
|
|
26184
26552
|
function Session() {
|
|
26185
26553
|
}
|
|
@@ -26204,10 +26572,7 @@ var Session = /** @class */ (function () {
|
|
|
26204
26572
|
};
|
|
26205
26573
|
Session.hasJoinedCommunity = function () {
|
|
26206
26574
|
var community = Storage.get('community');
|
|
26207
|
-
|
|
26208
|
-
return false;
|
|
26209
|
-
}
|
|
26210
|
-
return (community === null || community === void 0 ? void 0 : community.me) ? true : false;
|
|
26575
|
+
return !!(community === null || community === void 0 ? void 0 : community.me);
|
|
26211
26576
|
};
|
|
26212
26577
|
Session.end = function () {
|
|
26213
26578
|
Storage.setAuthToken(null);
|
|
@@ -26226,6 +26591,31 @@ var Session = /** @class */ (function () {
|
|
|
26226
26591
|
Storage.set(Session._email_key, data.email);
|
|
26227
26592
|
Config.setAuthToken(data.token.access_token);
|
|
26228
26593
|
};
|
|
26594
|
+
/**
|
|
26595
|
+
* Generate a tracking token for analytics collection
|
|
26596
|
+
* @param titleId The title ID to generate token for
|
|
26597
|
+
* @param secret The secret key (should match server config)
|
|
26598
|
+
* @returns HMAC-SHA256 token
|
|
26599
|
+
* @throws Error if crypto operations fail
|
|
26600
|
+
*/
|
|
26601
|
+
Session.generateTrackingToken = function (titleId, secret) {
|
|
26602
|
+
try {
|
|
26603
|
+
if (!titleId) {
|
|
26604
|
+
throw new Error('titleId is required');
|
|
26605
|
+
}
|
|
26606
|
+
if (!secret) {
|
|
26607
|
+
throw new Error('secret is required');
|
|
26608
|
+
}
|
|
26609
|
+
return cryptoInstance
|
|
26610
|
+
.createHmac('sha256', secret)
|
|
26611
|
+
.update(titleId)
|
|
26612
|
+
.digest('hex');
|
|
26613
|
+
}
|
|
26614
|
+
catch (error) {
|
|
26615
|
+
console.error('Failed to generate tracking token:', error);
|
|
26616
|
+
throw new Error('Failed to generate tracking token');
|
|
26617
|
+
}
|
|
26618
|
+
};
|
|
26229
26619
|
Session._id_key = 'user_id';
|
|
26230
26620
|
Session._first_name_key = 'user_first_name';
|
|
26231
26621
|
Session._last_name_key = 'user_last_name';
|
|
@@ -26586,7 +26976,8 @@ var Glitch = /** @class */ (function () {
|
|
|
26586
26976
|
Media: Media,
|
|
26587
26977
|
Scheduler: Scheduler,
|
|
26588
26978
|
Funnel: Funnel,
|
|
26589
|
-
SocialStats: SocialStats
|
|
26979
|
+
SocialStats: SocialStats,
|
|
26980
|
+
WebsiteAnalytics: WebsiteAnalytics
|
|
26590
26981
|
};
|
|
26591
26982
|
Glitch.util = {
|
|
26592
26983
|
Requests: Requests,
|