@explorins/pers-sdk 2.2.0-alpha.3 → 2.3.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/README.md +104 -0
- package/dist/analytics.js +1 -1
- package/dist/booking/api/booking-api.d.ts +16 -6
- package/dist/booking/api/booking-api.d.ts.map +1 -1
- package/dist/booking/index.d.ts +51 -0
- package/dist/booking/index.d.ts.map +1 -1
- package/dist/campaign/api/campaign-api.d.ts +26 -0
- package/dist/campaign/api/campaign-api.d.ts.map +1 -1
- package/dist/campaign/index.d.ts +2 -3
- package/dist/campaign/index.d.ts.map +1 -1
- package/dist/campaign/models/index.d.ts +7 -32
- package/dist/campaign/models/index.d.ts.map +1 -1
- package/dist/campaign/services/campaign-service.d.ts +8 -8
- package/dist/campaign/services/campaign-service.d.ts.map +1 -1
- package/dist/campaign.cjs +41 -0
- package/dist/campaign.cjs.map +1 -1
- package/dist/campaign.js +41 -0
- package/dist/campaign.js.map +1 -1
- package/dist/chunks/{pers-sdk-B_MgqxL0.js → pers-sdk-4HCl1VLk.js} +451 -67
- package/dist/chunks/pers-sdk-4HCl1VLk.js.map +1 -0
- package/dist/chunks/pers-sdk-BMisq9AJ.cjs +12261 -0
- package/dist/chunks/pers-sdk-BMisq9AJ.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-DEfiDbIs.cjs → pers-sdk-CVsokrmI.cjs} +451 -66
- package/dist/chunks/pers-sdk-CVsokrmI.cjs.map +1 -0
- package/dist/chunks/pers-sdk-Qckavv08.js +12207 -0
- package/dist/chunks/pers-sdk-Qckavv08.js.map +1 -0
- package/dist/chunks/{redemption-service-w0GMdF0m.js → redemption-service-CQ73aUTe.js} +42 -1
- package/dist/chunks/{redemption-service-w0GMdF0m.js.map → redemption-service-CQ73aUTe.js.map} +1 -1
- package/dist/chunks/{redemption-service-KamEndzB.cjs → redemption-service-PnHyM2qu.cjs} +42 -1
- package/dist/chunks/{redemption-service-KamEndzB.cjs.map → redemption-service-PnHyM2qu.cjs.map} +1 -1
- package/dist/chunks/token-service-BcuDj292.js.map +1 -1
- package/dist/chunks/token-service-CnnrCOsg.cjs.map +1 -1
- package/dist/chunks/{transaction-request.builder-BZ6Uq6Qe.js → transaction-request.builder-D6VLhaMi.js} +28 -6
- package/dist/chunks/transaction-request.builder-D6VLhaMi.js.map +1 -0
- package/dist/chunks/{transaction-request.builder-D8pIzjYD.cjs → transaction-request.builder-IU_rZIIM.cjs} +28 -6
- package/dist/chunks/transaction-request.builder-IU_rZIIM.cjs.map +1 -0
- package/dist/core/data-source/index.d.ts +33 -0
- package/dist/core/data-source/index.d.ts.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts +17 -0
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core/pers-config.d.ts +24 -0
- package/dist/core/pers-config.d.ts.map +1 -1
- package/dist/core/tracking/index.d.ts +7 -0
- package/dist/core/tracking/index.d.ts.map +1 -0
- package/dist/core/tracking/tracking-manager.d.ts +86 -0
- package/dist/core/tracking/tracking-manager.d.ts.map +1 -0
- package/dist/core.cjs +174 -9
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +148 -5
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +33 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/managers/campaign-manager.d.ts +54 -0
- package/dist/managers/campaign-manager.d.ts.map +1 -1
- package/dist/managers/redemption-manager.d.ts +57 -3
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/transaction-manager.d.ts +26 -40
- package/dist/managers/transaction-manager.d.ts.map +1 -1
- package/dist/managers/user-manager.d.ts +31 -0
- package/dist/managers/user-manager.d.ts.map +1 -1
- package/dist/managers/webhook-manager.d.ts +1 -1
- package/dist/node.cjs +3 -3
- package/dist/node.js +3 -3
- package/dist/package.json +2 -2
- package/dist/pers-sdk.d.ts +65 -1
- package/dist/pers-sdk.d.ts.map +1 -1
- package/dist/redemption/api/redemption-api.d.ts +26 -0
- package/dist/redemption/api/redemption-api.d.ts.map +1 -1
- package/dist/redemption/index.d.ts +2 -3
- package/dist/redemption/index.d.ts.map +1 -1
- package/dist/redemption/models/index.d.ts +6 -33
- package/dist/redemption/models/index.d.ts.map +1 -1
- package/dist/redemption/services/redemption-service.d.ts +8 -9
- package/dist/redemption/services/redemption-service.d.ts.map +1 -1
- package/dist/redemption.cjs +1 -1
- package/dist/redemption.js +1 -1
- package/dist/token/api/token-api.d.ts +6 -18
- package/dist/token/api/token-api.d.ts.map +1 -1
- package/dist/token/index.d.ts +1 -1
- package/dist/token/index.d.ts.map +1 -1
- package/dist/token/services/token-service.d.ts +2 -1
- package/dist/token/services/token-service.d.ts.map +1 -1
- package/dist/transaction/api/transaction-api.d.ts +15 -4
- package/dist/transaction/api/transaction-api.d.ts.map +1 -1
- package/dist/transaction/index.d.ts +1 -1
- package/dist/transaction/index.d.ts.map +1 -1
- package/dist/transaction/models/index.d.ts +4 -19
- package/dist/transaction/models/index.d.ts.map +1 -1
- package/dist/transaction/services/transaction-service.d.ts +6 -3
- package/dist/transaction/services/transaction-service.d.ts.map +1 -1
- package/dist/transaction.cjs +1 -1
- package/dist/transaction.js +1 -1
- package/dist/user/api/user-api.d.ts +29 -5
- package/dist/user/api/user-api.d.ts.map +1 -1
- package/dist/user/index.d.ts +1 -1
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user.cjs +34 -0
- package/dist/user.cjs.map +1 -1
- package/dist/user.js +34 -0
- package/dist/user.js.map +1 -1
- package/dist/webhook/models/index.d.ts +2 -2
- package/package.json +2 -2
- package/dist/chunks/environment-C_hPDl8L.cjs +0 -46
- package/dist/chunks/environment-C_hPDl8L.cjs.map +0 -1
- package/dist/chunks/environment-DEI_L882.js +0 -42
- package/dist/chunks/environment-DEI_L882.js.map +0 -1
- package/dist/chunks/pers-sdk-B_MgqxL0.js.map +0 -1
- package/dist/chunks/pers-sdk-DEfiDbIs.cjs.map +0 -1
- package/dist/chunks/transaction-request.builder-BZ6Uq6Qe.js.map +0 -1
- package/dist/chunks/transaction-request.builder-D8pIzjYD.cjs.map +0 -1
|
@@ -5,8 +5,8 @@ import { createUserStatusSDK } from '../user-status.js';
|
|
|
5
5
|
import { a as TokenService, T as TokenApi } from './token-service-BcuDj292.js';
|
|
6
6
|
import { B as BusinessApi, b as BusinessService, a as BusinessMembershipApi, c as BusinessMembershipService } from './business-membership-service-NLoqoFpG.js';
|
|
7
7
|
import { CampaignService, CampaignApi } from '../campaign.js';
|
|
8
|
-
import { a as RedemptionService, R as RedemptionApi } from './redemption-service-
|
|
9
|
-
import { a as TransactionService, T as TransactionApi } from './transaction-request.builder-
|
|
8
|
+
import { a as RedemptionService, R as RedemptionApi } from './redemption-service-CQ73aUTe.js';
|
|
9
|
+
import { a as TransactionService, T as TransactionApi } from './transaction-request.builder-D6VLhaMi.js';
|
|
10
10
|
import { a as PaymentService, P as PurchaseApi } from './payment-service-IvM6rryM.js';
|
|
11
11
|
import { T as TenantManager } from './tenant-manager-xmYKBFGu.js';
|
|
12
12
|
import { b as buildPaginationParams, n as normalizeToPaginated } from './pagination-utils-9vQ-Npkr.js';
|
|
@@ -1589,6 +1589,135 @@ const SDK_VERSION = "2.2.0-alpha.3";
|
|
|
1589
1589
|
/** Full SDK identifier for headers */
|
|
1590
1590
|
const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
|
|
1591
1591
|
|
|
1592
|
+
/**
|
|
1593
|
+
* Tracking Manager - Handles data source and platform tracking
|
|
1594
|
+
*
|
|
1595
|
+
* Manages attribution data for analytics across all user actions.
|
|
1596
|
+
*
|
|
1597
|
+
* @module @explorins/pers-sdk/core/tracking
|
|
1598
|
+
*/
|
|
1599
|
+
/**
|
|
1600
|
+
* Manages data source and platform tracking state
|
|
1601
|
+
*/
|
|
1602
|
+
class TrackingManager {
|
|
1603
|
+
constructor(options) {
|
|
1604
|
+
this.configDataSource = options?.dataSource;
|
|
1605
|
+
this.configPlatform = options?.platform;
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Set data source tracking info (replaces existing)
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* ```typescript
|
|
1612
|
+
* tracking.setDataSource({
|
|
1613
|
+
* channel: 'mobile',
|
|
1614
|
+
* medium: 'push',
|
|
1615
|
+
* campaign: 'summer_2026',
|
|
1616
|
+
* });
|
|
1617
|
+
* ```
|
|
1618
|
+
*/
|
|
1619
|
+
setDataSource(dataSource) {
|
|
1620
|
+
this._dataSource = dataSource;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Update data source tracking info (merges with existing)
|
|
1624
|
+
*
|
|
1625
|
+
* @example
|
|
1626
|
+
* ```typescript
|
|
1627
|
+
* tracking.updateDataSource({
|
|
1628
|
+
* campaign: 'new_campaign',
|
|
1629
|
+
* });
|
|
1630
|
+
* ```
|
|
1631
|
+
*/
|
|
1632
|
+
updateDataSource(dataSource) {
|
|
1633
|
+
const existing = this._dataSource ?? this.configDataSource;
|
|
1634
|
+
this._dataSource = { ...existing, ...dataSource };
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Set platform info for analytics
|
|
1638
|
+
*
|
|
1639
|
+
* @example
|
|
1640
|
+
* ```typescript
|
|
1641
|
+
* tracking.setPlatform({
|
|
1642
|
+
* os: 'iOS',
|
|
1643
|
+
* osVersion: '17.4',
|
|
1644
|
+
* app: 'MyApp',
|
|
1645
|
+
* appVersion: '2.3.1',
|
|
1646
|
+
* deviceType: 'phone',
|
|
1647
|
+
* });
|
|
1648
|
+
* ```
|
|
1649
|
+
*/
|
|
1650
|
+
setPlatform(platform) {
|
|
1651
|
+
this._platform = platform;
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Get current data source config
|
|
1655
|
+
*/
|
|
1656
|
+
getDataSource() {
|
|
1657
|
+
return this._dataSource ?? this.configDataSource;
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Get current platform info
|
|
1661
|
+
*/
|
|
1662
|
+
getPlatform() {
|
|
1663
|
+
return this._platform ?? this.configPlatform;
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* Check if tracking is properly configured
|
|
1667
|
+
*
|
|
1668
|
+
* Returns warnings for missing recommended tracking data.
|
|
1669
|
+
* Useful for development/debugging to ensure proper attribution.
|
|
1670
|
+
*/
|
|
1671
|
+
validate() {
|
|
1672
|
+
const warnings = [];
|
|
1673
|
+
const dataSource = this.getDataSource();
|
|
1674
|
+
const platform = this.getPlatform();
|
|
1675
|
+
// Check channel for non-web contexts
|
|
1676
|
+
if (!dataSource?.channel) {
|
|
1677
|
+
warnings.push('No channel set. Native apps should set channel: "mobile"');
|
|
1678
|
+
}
|
|
1679
|
+
// Check platform info
|
|
1680
|
+
if (!platform || Object.keys(platform).length === 0) {
|
|
1681
|
+
warnings.push('No platform info set. Consider calling setPlatform() for better analytics');
|
|
1682
|
+
}
|
|
1683
|
+
return {
|
|
1684
|
+
isValid: warnings.length === 0,
|
|
1685
|
+
warnings,
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Build HTTP headers for data source tracking
|
|
1690
|
+
*
|
|
1691
|
+
* @internal - Used by PersApiClient
|
|
1692
|
+
*/
|
|
1693
|
+
buildHeaders() {
|
|
1694
|
+
const headers = {};
|
|
1695
|
+
const dataSource = this.getDataSource();
|
|
1696
|
+
const platform = this.getPlatform();
|
|
1697
|
+
if (dataSource) {
|
|
1698
|
+
if (dataSource.channel) {
|
|
1699
|
+
headers['x-source-channel'] = dataSource.channel;
|
|
1700
|
+
}
|
|
1701
|
+
if (dataSource.medium) {
|
|
1702
|
+
headers['x-source-medium'] = dataSource.medium;
|
|
1703
|
+
}
|
|
1704
|
+
if (dataSource.campaign) {
|
|
1705
|
+
headers['x-source-campaign'] = dataSource.campaign;
|
|
1706
|
+
}
|
|
1707
|
+
if (dataSource.source) {
|
|
1708
|
+
headers['x-source'] = dataSource.source;
|
|
1709
|
+
}
|
|
1710
|
+
if (dataSource.referrer) {
|
|
1711
|
+
headers['Referer'] = dataSource.referrer;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
if (platform && Object.keys(platform).length > 0) {
|
|
1715
|
+
headers['x-platform'] = JSON.stringify(platform);
|
|
1716
|
+
}
|
|
1717
|
+
return headers;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1592
1721
|
// packages/pers-sdk/src/core/pers-api-client.ts
|
|
1593
1722
|
/**
|
|
1594
1723
|
* PERS API Client - Platform-agnostic HTTP client with authentication
|
|
@@ -1637,6 +1766,11 @@ class PersApiClient {
|
|
|
1637
1766
|
}
|
|
1638
1767
|
this.authService = new AuthService(this.authApi, this.mergedConfig.authProvider);
|
|
1639
1768
|
this.refreshManager = new TokenRefreshManager(this.authService, this.mergedConfig.authProvider);
|
|
1769
|
+
// Initialize tracking manager
|
|
1770
|
+
this.tracking = new TrackingManager({
|
|
1771
|
+
dataSource: this.mergedConfig.dataSource,
|
|
1772
|
+
platform: this.mergedConfig.platform,
|
|
1773
|
+
});
|
|
1640
1774
|
if (this.mergedConfig.authProvider) {
|
|
1641
1775
|
this.initializationPromise = this.initialize();
|
|
1642
1776
|
}
|
|
@@ -1921,24 +2055,8 @@ class PersApiClient {
|
|
|
1921
2055
|
else if (this.mergedConfig.apiProjectKey) {
|
|
1922
2056
|
headers['x-project-key'] = this.mergedConfig.apiProjectKey;
|
|
1923
2057
|
}
|
|
1924
|
-
// Add data source
|
|
1925
|
-
|
|
1926
|
-
if (dataSource) {
|
|
1927
|
-
headers['x-source-channel'] = dataSource.channel;
|
|
1928
|
-
if (dataSource.medium) {
|
|
1929
|
-
headers['x-source-medium'] = dataSource.medium;
|
|
1930
|
-
}
|
|
1931
|
-
if (dataSource.campaign) {
|
|
1932
|
-
headers['x-source-campaign'] = dataSource.campaign;
|
|
1933
|
-
}
|
|
1934
|
-
if (dataSource.source) {
|
|
1935
|
-
headers['x-source'] = dataSource.source;
|
|
1936
|
-
}
|
|
1937
|
-
// Note: referrer is typically set by browser, but can be overridden
|
|
1938
|
-
if (dataSource.referrer) {
|
|
1939
|
-
headers['Referer'] = dataSource.referrer;
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
2058
|
+
// Add tracking headers (data source + platform)
|
|
2059
|
+
Object.assign(headers, this.tracking.buildHeaders());
|
|
1942
2060
|
return headers;
|
|
1943
2061
|
}
|
|
1944
2062
|
// ==========================================
|
|
@@ -1962,6 +2080,33 @@ class PersApiClient {
|
|
|
1962
2080
|
getOriginalConfig() {
|
|
1963
2081
|
return this.config;
|
|
1964
2082
|
}
|
|
2083
|
+
// ==========================================
|
|
2084
|
+
// DATA SOURCE TRACKING
|
|
2085
|
+
// ==========================================
|
|
2086
|
+
/** Set data source tracking info (replaces existing) */
|
|
2087
|
+
setDataSource(dataSource) {
|
|
2088
|
+
this.tracking.setDataSource(dataSource);
|
|
2089
|
+
}
|
|
2090
|
+
/** Update data source tracking info (merges with existing) */
|
|
2091
|
+
updateDataSource(dataSource) {
|
|
2092
|
+
this.tracking.updateDataSource(dataSource);
|
|
2093
|
+
}
|
|
2094
|
+
/** Set platform info for analytics */
|
|
2095
|
+
setPlatform(platform) {
|
|
2096
|
+
this.tracking.setPlatform(platform);
|
|
2097
|
+
}
|
|
2098
|
+
/** Get current data source config */
|
|
2099
|
+
getDataSource() {
|
|
2100
|
+
return this.tracking.getDataSource();
|
|
2101
|
+
}
|
|
2102
|
+
/** Get current platform info */
|
|
2103
|
+
getPlatform() {
|
|
2104
|
+
return this.tracking.getPlatform();
|
|
2105
|
+
}
|
|
2106
|
+
/** Validate tracking configuration (for debugging) */
|
|
2107
|
+
validateTracking() {
|
|
2108
|
+
return this.tracking.validate();
|
|
2109
|
+
}
|
|
1965
2110
|
}
|
|
1966
2111
|
|
|
1967
2112
|
/**
|
|
@@ -3180,6 +3325,37 @@ class UserManager {
|
|
|
3180
3325
|
});
|
|
3181
3326
|
return result;
|
|
3182
3327
|
}
|
|
3328
|
+
/**
|
|
3329
|
+
* Admin: Export users as CSV
|
|
3330
|
+
*
|
|
3331
|
+
* Generates a comprehensive CSV export of all tenant users for
|
|
3332
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
3333
|
+
* requires administrator privileges and creates a downloadable file.
|
|
3334
|
+
*
|
|
3335
|
+
* @param options - Optional date range filters
|
|
3336
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
3337
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
3338
|
+
* @returns Promise resolving to CSV blob for download
|
|
3339
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
3340
|
+
*
|
|
3341
|
+
* @example Export All Users
|
|
3342
|
+
* ```typescript
|
|
3343
|
+
* const csvBlob = await sdk.users.exportCSV();
|
|
3344
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
3345
|
+
* ```
|
|
3346
|
+
*
|
|
3347
|
+
* @example Export Users Within Date Range
|
|
3348
|
+
* ```typescript
|
|
3349
|
+
* const csvBlob = await sdk.users.exportCSV({
|
|
3350
|
+
* dateFrom: '2024-01-01',
|
|
3351
|
+
* dateTo: '2024-12-31'
|
|
3352
|
+
* });
|
|
3353
|
+
* ```
|
|
3354
|
+
*/
|
|
3355
|
+
async exportCSV(options) {
|
|
3356
|
+
const userApi = new UserApi(this.apiClient);
|
|
3357
|
+
return userApi.exportCSV(options);
|
|
3358
|
+
}
|
|
3183
3359
|
/**
|
|
3184
3360
|
* Get the user service for advanced operations
|
|
3185
3361
|
*
|
|
@@ -4642,7 +4818,13 @@ class CampaignManager {
|
|
|
4642
4818
|
* ```
|
|
4643
4819
|
*/
|
|
4644
4820
|
async getCampaigns(options) {
|
|
4645
|
-
|
|
4821
|
+
// Convert Date objects to ISO strings for API compatibility
|
|
4822
|
+
const normalizedOptions = options ? {
|
|
4823
|
+
...options,
|
|
4824
|
+
startDate: options.startDate instanceof Date ? options.startDate.toISOString() : options.startDate,
|
|
4825
|
+
endDate: options.endDate instanceof Date ? options.endDate.toISOString() : options.endDate,
|
|
4826
|
+
} : undefined;
|
|
4827
|
+
return this.campaignService.getCampaigns(normalizedOptions);
|
|
4646
4828
|
}
|
|
4647
4829
|
/**
|
|
4648
4830
|
* Admin: Create new campaign
|
|
@@ -5291,6 +5473,60 @@ class CampaignManager {
|
|
|
5291
5473
|
async removeTriggerSource(campaignId, triggerSourceId) {
|
|
5292
5474
|
return this.campaignService.removeTriggerSourceFromCampaign(campaignId, triggerSourceId);
|
|
5293
5475
|
}
|
|
5476
|
+
/**
|
|
5477
|
+
* Admin: Export campaigns as CSV
|
|
5478
|
+
*
|
|
5479
|
+
* Generates a comprehensive CSV export of all tenant campaigns for
|
|
5480
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
5481
|
+
* requires administrator privileges and creates a downloadable file.
|
|
5482
|
+
*
|
|
5483
|
+
* @param options - Optional date range filters
|
|
5484
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
5485
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
5486
|
+
* @returns Promise resolving to CSV blob for download
|
|
5487
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
5488
|
+
*
|
|
5489
|
+
* @example Export All Campaigns
|
|
5490
|
+
* ```typescript
|
|
5491
|
+
* const csvBlob = await sdk.campaigns.exportCSV();
|
|
5492
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
5493
|
+
* ```
|
|
5494
|
+
*
|
|
5495
|
+
* @example Export Campaigns Within Date Range
|
|
5496
|
+
* ```typescript
|
|
5497
|
+
* const csvBlob = await sdk.campaigns.exportCSV({
|
|
5498
|
+
* dateFrom: '2024-01-01',
|
|
5499
|
+
* dateTo: '2024-12-31'
|
|
5500
|
+
* });
|
|
5501
|
+
* ```
|
|
5502
|
+
*/
|
|
5503
|
+
async exportCSV(options) {
|
|
5504
|
+
const campaignApi = new CampaignApi(this.apiClient);
|
|
5505
|
+
return campaignApi.exportCSV(options);
|
|
5506
|
+
}
|
|
5507
|
+
/**
|
|
5508
|
+
* Admin: Export campaign claims as CSV
|
|
5509
|
+
*
|
|
5510
|
+
* Generates a comprehensive CSV export of all campaign claim records for
|
|
5511
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
5512
|
+
* requires administrator privileges and creates a downloadable file.
|
|
5513
|
+
*
|
|
5514
|
+
* @param options - Optional date range filters
|
|
5515
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
5516
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
5517
|
+
* @returns Promise resolving to CSV blob for download
|
|
5518
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
5519
|
+
*
|
|
5520
|
+
* @example Export All Claims
|
|
5521
|
+
* ```typescript
|
|
5522
|
+
* const csvBlob = await sdk.campaigns.exportClaimsCSV();
|
|
5523
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
5524
|
+
* ```
|
|
5525
|
+
*/
|
|
5526
|
+
async exportClaimsCSV(options) {
|
|
5527
|
+
const campaignApi = new CampaignApi(this.apiClient);
|
|
5528
|
+
return campaignApi.exportClaimsCSV(options);
|
|
5529
|
+
}
|
|
5294
5530
|
/**
|
|
5295
5531
|
* Get the full campaign service for advanced operations
|
|
5296
5532
|
*
|
|
@@ -6097,6 +6333,60 @@ class RedemptionManager {
|
|
|
6097
6333
|
async deleteRedemption(id) {
|
|
6098
6334
|
return this.redemptionService.deleteRedemption(id);
|
|
6099
6335
|
}
|
|
6336
|
+
/**
|
|
6337
|
+
* Admin: Export redemptions as CSV
|
|
6338
|
+
*
|
|
6339
|
+
* Generates a comprehensive CSV export of all tenant redemptions for
|
|
6340
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
6341
|
+
* requires administrator privileges and creates a downloadable file.
|
|
6342
|
+
*
|
|
6343
|
+
* @param options - Optional date range filters
|
|
6344
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
6345
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
6346
|
+
* @returns Promise resolving to CSV blob for download
|
|
6347
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
6348
|
+
*
|
|
6349
|
+
* @example Export All Redemptions
|
|
6350
|
+
* ```typescript
|
|
6351
|
+
* const csvBlob = await sdk.redemptions.exportCSV();
|
|
6352
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6353
|
+
* ```
|
|
6354
|
+
*
|
|
6355
|
+
* @example Export Redemptions Within Date Range
|
|
6356
|
+
* ```typescript
|
|
6357
|
+
* const csvBlob = await sdk.redemptions.exportCSV({
|
|
6358
|
+
* dateFrom: '2024-01-01',
|
|
6359
|
+
* dateTo: '2024-12-31'
|
|
6360
|
+
* });
|
|
6361
|
+
* ```
|
|
6362
|
+
*/
|
|
6363
|
+
async exportCSV(options) {
|
|
6364
|
+
const redemptionApi = new RedemptionApi(this.apiClient);
|
|
6365
|
+
return redemptionApi.exportCSV(options);
|
|
6366
|
+
}
|
|
6367
|
+
/**
|
|
6368
|
+
* Admin: Export redemption redeems as CSV
|
|
6369
|
+
*
|
|
6370
|
+
* Generates a comprehensive CSV export of all redemption redeem records for
|
|
6371
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
6372
|
+
* requires administrator privileges and creates a downloadable file.
|
|
6373
|
+
*
|
|
6374
|
+
* @param options - Optional date range filters
|
|
6375
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
6376
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
6377
|
+
* @returns Promise resolving to CSV blob for download
|
|
6378
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
6379
|
+
*
|
|
6380
|
+
* @example Export All Redeems
|
|
6381
|
+
* ```typescript
|
|
6382
|
+
* const csvBlob = await sdk.redemptions.exportRedeemsCSV();
|
|
6383
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6384
|
+
* ```
|
|
6385
|
+
*/
|
|
6386
|
+
async exportRedeemsCSV(options) {
|
|
6387
|
+
const redemptionApi = new RedemptionApi(this.apiClient);
|
|
6388
|
+
return redemptionApi.exportRedeemsCSV(options);
|
|
6389
|
+
}
|
|
6100
6390
|
/**
|
|
6101
6391
|
* Get the full redemption service for advanced operations
|
|
6102
6392
|
*
|
|
@@ -6490,54 +6780,36 @@ class TransactionManager {
|
|
|
6490
6780
|
* external analysis, reporting, or compliance purposes. This operation
|
|
6491
6781
|
* requires administrator privileges and creates a downloadable file.
|
|
6492
6782
|
*
|
|
6783
|
+
* @param options - Optional date range filters
|
|
6784
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
6785
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
6493
6786
|
* @returns Promise resolving to CSV blob for download
|
|
6494
6787
|
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
6495
6788
|
*
|
|
6496
|
-
* @example
|
|
6789
|
+
* @example Export All Transactions
|
|
6497
6790
|
* ```typescript
|
|
6498
|
-
*
|
|
6499
|
-
*
|
|
6500
|
-
* const csvBlob = await sdk.transactions.exportTransactionsCSV();
|
|
6501
|
-
*
|
|
6502
|
-
* // Create download link
|
|
6503
|
-
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6504
|
-
* const link = document.createElement('a');
|
|
6505
|
-
* link.href = downloadUrl;
|
|
6506
|
-
* link.download = `transactions-${new Date().toISOString().split('T')[0]}.csv`;
|
|
6507
|
-
*
|
|
6508
|
-
* // Trigger download
|
|
6509
|
-
* document.body.appendChild(link);
|
|
6510
|
-
* link.click();
|
|
6511
|
-
* document.body.removeChild(link);
|
|
6512
|
-
*
|
|
6513
|
-
* // Clean up object URL
|
|
6514
|
-
* URL.revokeObjectURL(downloadUrl);
|
|
6515
|
-
*
|
|
6516
|
-
* console.log('Transaction export downloaded successfully');
|
|
6517
|
-
*
|
|
6518
|
-
* } catch (error) {
|
|
6519
|
-
* console.log('Export failed:', error.message);
|
|
6520
|
-
* }
|
|
6791
|
+
* const csvBlob = await sdk.transactions.exportCSV();
|
|
6792
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6521
6793
|
* ```
|
|
6522
6794
|
*
|
|
6523
|
-
* @example
|
|
6795
|
+
* @example Export Transactions Within Date Range
|
|
6524
6796
|
* ```typescript
|
|
6525
|
-
*
|
|
6526
|
-
*
|
|
6527
|
-
*
|
|
6528
|
-
*
|
|
6529
|
-
* const buffer = Buffer.from(await csvBlob.arrayBuffer());
|
|
6530
|
-
*
|
|
6531
|
-
* // Save to file system
|
|
6532
|
-
* const fs = require('fs');
|
|
6533
|
-
* const filename = `transactions-export-${Date.now()}.csv`;
|
|
6534
|
-
* fs.writeFileSync(filename, buffer);
|
|
6535
|
-
*
|
|
6536
|
-
* console.log(`Transaction data exported to ${filename}`);
|
|
6797
|
+
* const csvBlob = await sdk.transactions.exportCSV({
|
|
6798
|
+
* dateFrom: '2024-01-01',
|
|
6799
|
+
* dateTo: '2024-12-31'
|
|
6800
|
+
* });
|
|
6537
6801
|
* ```
|
|
6538
6802
|
*/
|
|
6539
|
-
async
|
|
6540
|
-
return this.transactionService.exportTransactionsCSV();
|
|
6803
|
+
async exportCSV(options) {
|
|
6804
|
+
return this.transactionService.exportTransactionsCSV(options);
|
|
6805
|
+
}
|
|
6806
|
+
/**
|
|
6807
|
+
* Admin: Export transactions as CSV
|
|
6808
|
+
*
|
|
6809
|
+
* @deprecated Use `exportCSV()` instead for consistent naming across all managers
|
|
6810
|
+
*/
|
|
6811
|
+
async exportTransactionsCSV(options) {
|
|
6812
|
+
return this.exportCSV(options);
|
|
6541
6813
|
}
|
|
6542
6814
|
/**
|
|
6543
6815
|
* Prepare existing transaction for client-side signing
|
|
@@ -8743,10 +9015,10 @@ class WebhookApi {
|
|
|
8743
9015
|
params.append('hookId', options.webhookId);
|
|
8744
9016
|
if (options?.status)
|
|
8745
9017
|
params.append('status', options.status);
|
|
8746
|
-
if (options?.
|
|
8747
|
-
params.append('dateFrom', options.
|
|
8748
|
-
if (options?.
|
|
8749
|
-
params.append('dateTo', options.
|
|
9018
|
+
if (options?.dateFrom)
|
|
9019
|
+
params.append('dateFrom', options.dateFrom);
|
|
9020
|
+
if (options?.dateTo)
|
|
9021
|
+
params.append('dateTo', options.dateTo);
|
|
8750
9022
|
if (options?.page)
|
|
8751
9023
|
params.append('page', String(options.page));
|
|
8752
9024
|
if (options?.limit)
|
|
@@ -9235,7 +9507,7 @@ class WebhookManager {
|
|
|
9235
9507
|
* // Get executions for specific webhook
|
|
9236
9508
|
* const executions = await sdk.webhooks.getExecutions({
|
|
9237
9509
|
* webhookId: 'webhook-123',
|
|
9238
|
-
*
|
|
9510
|
+
* dateFrom: '2024-01-01'
|
|
9239
9511
|
* });
|
|
9240
9512
|
* ```
|
|
9241
9513
|
*/
|
|
@@ -10618,6 +10890,28 @@ class BookingApi {
|
|
|
10618
10890
|
async delete(id) {
|
|
10619
10891
|
return this.apiClient.delete(`${this.basePath}/${id}`);
|
|
10620
10892
|
}
|
|
10893
|
+
// ==========================================
|
|
10894
|
+
// CSV EXPORT
|
|
10895
|
+
// ==========================================
|
|
10896
|
+
/**
|
|
10897
|
+
* ADMIN: Export bookings to CSV
|
|
10898
|
+
*
|
|
10899
|
+
* Returns a CSV file with booking data for the tenant.
|
|
10900
|
+
* Supports date range filtering.
|
|
10901
|
+
*
|
|
10902
|
+
* @param options - Export options (dateFrom, dateTo in ISO format)
|
|
10903
|
+
* @returns CSV blob
|
|
10904
|
+
*/
|
|
10905
|
+
async exportCSV(options) {
|
|
10906
|
+
const params = new URLSearchParams();
|
|
10907
|
+
if (options?.dateFrom)
|
|
10908
|
+
params.append('dateFrom', options.dateFrom);
|
|
10909
|
+
if (options?.dateTo)
|
|
10910
|
+
params.append('dateTo', options.dateTo);
|
|
10911
|
+
const queryString = params.toString();
|
|
10912
|
+
const url = `${this.basePath}/export/csv${queryString ? `?${queryString}` : ''}`;
|
|
10913
|
+
return this.apiClient.get(url, 'blob');
|
|
10914
|
+
}
|
|
10621
10915
|
}
|
|
10622
10916
|
|
|
10623
10917
|
/**
|
|
@@ -11070,6 +11364,28 @@ class PersSDK {
|
|
|
11070
11364
|
this.setupWalletEventsAutoConnect();
|
|
11071
11365
|
// Auto-restore session from stored tokens (if enabled, default: true)
|
|
11072
11366
|
this.setupAutoRestoreSession();
|
|
11367
|
+
// Dev-mode tracking validation (helps developers ensure proper attribution)
|
|
11368
|
+
this.validateTrackingInDev();
|
|
11369
|
+
}
|
|
11370
|
+
/**
|
|
11371
|
+
* Validate tracking configuration in development mode
|
|
11372
|
+
* @internal
|
|
11373
|
+
*/
|
|
11374
|
+
validateTrackingInDev() {
|
|
11375
|
+
// Only run in development (check common env vars)
|
|
11376
|
+
const isDev = (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development') ||
|
|
11377
|
+
(typeof window !== 'undefined' && window.__DEV__);
|
|
11378
|
+
if (!isDev)
|
|
11379
|
+
return;
|
|
11380
|
+
// Delay check to allow time for setDataSource/setPlatform calls
|
|
11381
|
+
setTimeout(() => {
|
|
11382
|
+
const result = this.apiClient.validateTracking();
|
|
11383
|
+
if (!result.isValid) {
|
|
11384
|
+
console.warn('[PERS SDK] Tracking configuration warnings:');
|
|
11385
|
+
result.warnings.forEach(w => console.warn(` ⚠️ ${w}`));
|
|
11386
|
+
console.warn('[PERS SDK] Call sdk.setDataSource() and sdk.setPlatform() for better analytics.');
|
|
11387
|
+
}
|
|
11388
|
+
}, 2000);
|
|
11073
11389
|
}
|
|
11074
11390
|
/**
|
|
11075
11391
|
* Setup automatic session restoration from stored tokens
|
|
@@ -11770,6 +12086,74 @@ class PersSDK {
|
|
|
11770
12086
|
// Reset manager so it picks up new config
|
|
11771
12087
|
this._walletEvents = undefined;
|
|
11772
12088
|
}
|
|
12089
|
+
// ==========================================
|
|
12090
|
+
// DATA SOURCE TRACKING
|
|
12091
|
+
// ==========================================
|
|
12092
|
+
/**
|
|
12093
|
+
* Set data source tracking for analytics attribution
|
|
12094
|
+
*
|
|
12095
|
+
* Use this to track where users and actions originate from.
|
|
12096
|
+
* Web apps typically only need medium/campaign/source (channel is auto-detected).
|
|
12097
|
+
* Native apps must set channel: 'mobile'.
|
|
12098
|
+
*
|
|
12099
|
+
* @param dataSource - Data source configuration
|
|
12100
|
+
*
|
|
12101
|
+
* @example Web app with UTM params
|
|
12102
|
+
* ```typescript
|
|
12103
|
+
* sdk.setDataSource({
|
|
12104
|
+
* medium: 'email',
|
|
12105
|
+
* campaign: 'summer_2026',
|
|
12106
|
+
* source: 'mailchimp',
|
|
12107
|
+
* });
|
|
12108
|
+
* ```
|
|
12109
|
+
*
|
|
12110
|
+
* @example Native app
|
|
12111
|
+
* ```typescript
|
|
12112
|
+
* sdk.setDataSource({
|
|
12113
|
+
* channel: 'mobile',
|
|
12114
|
+
* medium: 'push',
|
|
12115
|
+
* campaign: 'retention_30d',
|
|
12116
|
+
* });
|
|
12117
|
+
* ```
|
|
12118
|
+
*/
|
|
12119
|
+
setDataSource(dataSource) {
|
|
12120
|
+
this.apiClient.setDataSource(dataSource);
|
|
12121
|
+
}
|
|
12122
|
+
/**
|
|
12123
|
+
* Update data source (merges with existing values)
|
|
12124
|
+
*
|
|
12125
|
+
* @param dataSource - Partial data source to merge
|
|
12126
|
+
*
|
|
12127
|
+
* @example Update campaign after deep link
|
|
12128
|
+
* ```typescript
|
|
12129
|
+
* sdk.updateDataSource({ campaign: 'new_campaign' });
|
|
12130
|
+
* ```
|
|
12131
|
+
*/
|
|
12132
|
+
updateDataSource(dataSource) {
|
|
12133
|
+
this.apiClient.updateDataSource(dataSource);
|
|
12134
|
+
}
|
|
12135
|
+
/**
|
|
12136
|
+
* Set platform info for device analytics
|
|
12137
|
+
*
|
|
12138
|
+
* Native apps should call this on initialization with device info.
|
|
12139
|
+
* Web apps can optionally send browser/OS info.
|
|
12140
|
+
*
|
|
12141
|
+
* @param platform - Platform information
|
|
12142
|
+
*
|
|
12143
|
+
* @example Native app
|
|
12144
|
+
* ```typescript
|
|
12145
|
+
* sdk.setPlatform({
|
|
12146
|
+
* os: 'iOS',
|
|
12147
|
+
* osVersion: '17.4',
|
|
12148
|
+
* app: 'MyApp',
|
|
12149
|
+
* appVersion: '2.3.1',
|
|
12150
|
+
* deviceType: 'phone',
|
|
12151
|
+
* });
|
|
12152
|
+
* ```
|
|
12153
|
+
*/
|
|
12154
|
+
setPlatform(platform) {
|
|
12155
|
+
this.apiClient.setPlatform(platform);
|
|
12156
|
+
}
|
|
11773
12157
|
/**
|
|
11774
12158
|
* Gets the API client for direct PERS API requests
|
|
11775
12159
|
*
|
|
@@ -11819,5 +12203,5 @@ function createPersSDK(httpClient, config) {
|
|
|
11819
12203
|
return new PersSDK(httpClient, config);
|
|
11820
12204
|
}
|
|
11821
12205
|
|
|
11822
|
-
export {
|
|
11823
|
-
//# sourceMappingURL=pers-sdk-
|
|
12206
|
+
export { createPersEventsClient as $, AuthStatus as A, BusinessManager as B, CampaignManager as C, DefaultAuthProvider as D, TriggerSourceManager as E, FATAL_AUTH_CODES as F, WebhookManager as G, WalletEventsManager as H, IndexedDBTokenStorage as I, CustomFieldDefinitionManager as J, BookingManager as K, LocalStorageTokenStorage as L, MemoryTokenStorage as M, FileApi as N, FileService as O, PersSDK as P, ApiKeyApi as Q, RedemptionManager as R, SDK_NAME as S, TrackingManager as T, UserManager as U, WebhookApi as V, WebDPoPCryptoProvider as W, WebhookService as X, BookingApi as Y, BookingService as Z, PersEventsClient as _, AuthTokenManager as a, AUTH_STORAGE_KEYS as b, createPersSDK as c, DPOP_STORAGE_KEYS as d, SDK_VERSION as e, SDK_USER_AGENT as f, PersApiClient as g, DEFAULT_PERS_CONFIG as h, buildApiRoot as i, buildWalletEventsWsUrl as j, StaticJwtAuthProvider as k, AuthApi as l, mergeWithDefaults as m, isFatalAuthErrorInMessage as n, AuthService as o, DPoPManager as p, PersEventEmitter as q, AuthManager as r, UserStatusManager as s, TokenManager as t, TransactionManager as u, PurchaseManager as v, FileManager as w, ApiKeyManager as x, AnalyticsManager as y, DonationManager as z };
|
|
12207
|
+
//# sourceMappingURL=pers-sdk-4HCl1VLk.js.map
|