@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
|
@@ -7,8 +7,8 @@ var userStatus = require('../user-status.cjs');
|
|
|
7
7
|
var tokenService = require('./token-service-CnnrCOsg.cjs');
|
|
8
8
|
var businessMembershipService = require('./business-membership-service-Dkb780NX.cjs');
|
|
9
9
|
var campaign = require('../campaign.cjs');
|
|
10
|
-
var redemptionService = require('./redemption-service-
|
|
11
|
-
var transactionRequest_builder = require('./transaction-request.builder-
|
|
10
|
+
var redemptionService = require('./redemption-service-PnHyM2qu.cjs');
|
|
11
|
+
var transactionRequest_builder = require('./transaction-request.builder-IU_rZIIM.cjs');
|
|
12
12
|
var paymentService = require('./payment-service-Bkw7ZXev.cjs');
|
|
13
13
|
var tenantManager = require('./tenant-manager-DR5eSEJw.cjs');
|
|
14
14
|
var paginationUtils = require('./pagination-utils-B2jRHMSO.cjs');
|
|
@@ -1591,6 +1591,135 @@ const SDK_VERSION = "2.2.0-alpha.3";
|
|
|
1591
1591
|
/** Full SDK identifier for headers */
|
|
1592
1592
|
const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
|
|
1593
1593
|
|
|
1594
|
+
/**
|
|
1595
|
+
* Tracking Manager - Handles data source and platform tracking
|
|
1596
|
+
*
|
|
1597
|
+
* Manages attribution data for analytics across all user actions.
|
|
1598
|
+
*
|
|
1599
|
+
* @module @explorins/pers-sdk/core/tracking
|
|
1600
|
+
*/
|
|
1601
|
+
/**
|
|
1602
|
+
* Manages data source and platform tracking state
|
|
1603
|
+
*/
|
|
1604
|
+
class TrackingManager {
|
|
1605
|
+
constructor(options) {
|
|
1606
|
+
this.configDataSource = options?.dataSource;
|
|
1607
|
+
this.configPlatform = options?.platform;
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Set data source tracking info (replaces existing)
|
|
1611
|
+
*
|
|
1612
|
+
* @example
|
|
1613
|
+
* ```typescript
|
|
1614
|
+
* tracking.setDataSource({
|
|
1615
|
+
* channel: 'mobile',
|
|
1616
|
+
* medium: 'push',
|
|
1617
|
+
* campaign: 'summer_2026',
|
|
1618
|
+
* });
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
setDataSource(dataSource) {
|
|
1622
|
+
this._dataSource = dataSource;
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Update data source tracking info (merges with existing)
|
|
1626
|
+
*
|
|
1627
|
+
* @example
|
|
1628
|
+
* ```typescript
|
|
1629
|
+
* tracking.updateDataSource({
|
|
1630
|
+
* campaign: 'new_campaign',
|
|
1631
|
+
* });
|
|
1632
|
+
* ```
|
|
1633
|
+
*/
|
|
1634
|
+
updateDataSource(dataSource) {
|
|
1635
|
+
const existing = this._dataSource ?? this.configDataSource;
|
|
1636
|
+
this._dataSource = { ...existing, ...dataSource };
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Set platform info for analytics
|
|
1640
|
+
*
|
|
1641
|
+
* @example
|
|
1642
|
+
* ```typescript
|
|
1643
|
+
* tracking.setPlatform({
|
|
1644
|
+
* os: 'iOS',
|
|
1645
|
+
* osVersion: '17.4',
|
|
1646
|
+
* app: 'MyApp',
|
|
1647
|
+
* appVersion: '2.3.1',
|
|
1648
|
+
* deviceType: 'phone',
|
|
1649
|
+
* });
|
|
1650
|
+
* ```
|
|
1651
|
+
*/
|
|
1652
|
+
setPlatform(platform) {
|
|
1653
|
+
this._platform = platform;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Get current data source config
|
|
1657
|
+
*/
|
|
1658
|
+
getDataSource() {
|
|
1659
|
+
return this._dataSource ?? this.configDataSource;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Get current platform info
|
|
1663
|
+
*/
|
|
1664
|
+
getPlatform() {
|
|
1665
|
+
return this._platform ?? this.configPlatform;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Check if tracking is properly configured
|
|
1669
|
+
*
|
|
1670
|
+
* Returns warnings for missing recommended tracking data.
|
|
1671
|
+
* Useful for development/debugging to ensure proper attribution.
|
|
1672
|
+
*/
|
|
1673
|
+
validate() {
|
|
1674
|
+
const warnings = [];
|
|
1675
|
+
const dataSource = this.getDataSource();
|
|
1676
|
+
const platform = this.getPlatform();
|
|
1677
|
+
// Check channel for non-web contexts
|
|
1678
|
+
if (!dataSource?.channel) {
|
|
1679
|
+
warnings.push('No channel set. Native apps should set channel: "mobile"');
|
|
1680
|
+
}
|
|
1681
|
+
// Check platform info
|
|
1682
|
+
if (!platform || Object.keys(platform).length === 0) {
|
|
1683
|
+
warnings.push('No platform info set. Consider calling setPlatform() for better analytics');
|
|
1684
|
+
}
|
|
1685
|
+
return {
|
|
1686
|
+
isValid: warnings.length === 0,
|
|
1687
|
+
warnings,
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* Build HTTP headers for data source tracking
|
|
1692
|
+
*
|
|
1693
|
+
* @internal - Used by PersApiClient
|
|
1694
|
+
*/
|
|
1695
|
+
buildHeaders() {
|
|
1696
|
+
const headers = {};
|
|
1697
|
+
const dataSource = this.getDataSource();
|
|
1698
|
+
const platform = this.getPlatform();
|
|
1699
|
+
if (dataSource) {
|
|
1700
|
+
if (dataSource.channel) {
|
|
1701
|
+
headers['x-source-channel'] = dataSource.channel;
|
|
1702
|
+
}
|
|
1703
|
+
if (dataSource.medium) {
|
|
1704
|
+
headers['x-source-medium'] = dataSource.medium;
|
|
1705
|
+
}
|
|
1706
|
+
if (dataSource.campaign) {
|
|
1707
|
+
headers['x-source-campaign'] = dataSource.campaign;
|
|
1708
|
+
}
|
|
1709
|
+
if (dataSource.source) {
|
|
1710
|
+
headers['x-source'] = dataSource.source;
|
|
1711
|
+
}
|
|
1712
|
+
if (dataSource.referrer) {
|
|
1713
|
+
headers['Referer'] = dataSource.referrer;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
if (platform && Object.keys(platform).length > 0) {
|
|
1717
|
+
headers['x-platform'] = JSON.stringify(platform);
|
|
1718
|
+
}
|
|
1719
|
+
return headers;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1594
1723
|
// packages/pers-sdk/src/core/pers-api-client.ts
|
|
1595
1724
|
/**
|
|
1596
1725
|
* PERS API Client - Platform-agnostic HTTP client with authentication
|
|
@@ -1639,6 +1768,11 @@ class PersApiClient {
|
|
|
1639
1768
|
}
|
|
1640
1769
|
this.authService = new AuthService(this.authApi, this.mergedConfig.authProvider);
|
|
1641
1770
|
this.refreshManager = new TokenRefreshManager(this.authService, this.mergedConfig.authProvider);
|
|
1771
|
+
// Initialize tracking manager
|
|
1772
|
+
this.tracking = new TrackingManager({
|
|
1773
|
+
dataSource: this.mergedConfig.dataSource,
|
|
1774
|
+
platform: this.mergedConfig.platform,
|
|
1775
|
+
});
|
|
1642
1776
|
if (this.mergedConfig.authProvider) {
|
|
1643
1777
|
this.initializationPromise = this.initialize();
|
|
1644
1778
|
}
|
|
@@ -1923,24 +2057,8 @@ class PersApiClient {
|
|
|
1923
2057
|
else if (this.mergedConfig.apiProjectKey) {
|
|
1924
2058
|
headers['x-project-key'] = this.mergedConfig.apiProjectKey;
|
|
1925
2059
|
}
|
|
1926
|
-
// Add data source
|
|
1927
|
-
|
|
1928
|
-
if (dataSource) {
|
|
1929
|
-
headers['x-source-channel'] = dataSource.channel;
|
|
1930
|
-
if (dataSource.medium) {
|
|
1931
|
-
headers['x-source-medium'] = dataSource.medium;
|
|
1932
|
-
}
|
|
1933
|
-
if (dataSource.campaign) {
|
|
1934
|
-
headers['x-source-campaign'] = dataSource.campaign;
|
|
1935
|
-
}
|
|
1936
|
-
if (dataSource.source) {
|
|
1937
|
-
headers['x-source'] = dataSource.source;
|
|
1938
|
-
}
|
|
1939
|
-
// Note: referrer is typically set by browser, but can be overridden
|
|
1940
|
-
if (dataSource.referrer) {
|
|
1941
|
-
headers['Referer'] = dataSource.referrer;
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
2060
|
+
// Add tracking headers (data source + platform)
|
|
2061
|
+
Object.assign(headers, this.tracking.buildHeaders());
|
|
1944
2062
|
return headers;
|
|
1945
2063
|
}
|
|
1946
2064
|
// ==========================================
|
|
@@ -1964,6 +2082,33 @@ class PersApiClient {
|
|
|
1964
2082
|
getOriginalConfig() {
|
|
1965
2083
|
return this.config;
|
|
1966
2084
|
}
|
|
2085
|
+
// ==========================================
|
|
2086
|
+
// DATA SOURCE TRACKING
|
|
2087
|
+
// ==========================================
|
|
2088
|
+
/** Set data source tracking info (replaces existing) */
|
|
2089
|
+
setDataSource(dataSource) {
|
|
2090
|
+
this.tracking.setDataSource(dataSource);
|
|
2091
|
+
}
|
|
2092
|
+
/** Update data source tracking info (merges with existing) */
|
|
2093
|
+
updateDataSource(dataSource) {
|
|
2094
|
+
this.tracking.updateDataSource(dataSource);
|
|
2095
|
+
}
|
|
2096
|
+
/** Set platform info for analytics */
|
|
2097
|
+
setPlatform(platform) {
|
|
2098
|
+
this.tracking.setPlatform(platform);
|
|
2099
|
+
}
|
|
2100
|
+
/** Get current data source config */
|
|
2101
|
+
getDataSource() {
|
|
2102
|
+
return this.tracking.getDataSource();
|
|
2103
|
+
}
|
|
2104
|
+
/** Get current platform info */
|
|
2105
|
+
getPlatform() {
|
|
2106
|
+
return this.tracking.getPlatform();
|
|
2107
|
+
}
|
|
2108
|
+
/** Validate tracking configuration (for debugging) */
|
|
2109
|
+
validateTracking() {
|
|
2110
|
+
return this.tracking.validate();
|
|
2111
|
+
}
|
|
1967
2112
|
}
|
|
1968
2113
|
|
|
1969
2114
|
/**
|
|
@@ -3182,6 +3327,37 @@ class UserManager {
|
|
|
3182
3327
|
});
|
|
3183
3328
|
return result;
|
|
3184
3329
|
}
|
|
3330
|
+
/**
|
|
3331
|
+
* Admin: Export users as CSV
|
|
3332
|
+
*
|
|
3333
|
+
* Generates a comprehensive CSV export of all tenant users for
|
|
3334
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
3335
|
+
* requires administrator privileges and creates a downloadable file.
|
|
3336
|
+
*
|
|
3337
|
+
* @param options - Optional date range filters
|
|
3338
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
3339
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
3340
|
+
* @returns Promise resolving to CSV blob for download
|
|
3341
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
3342
|
+
*
|
|
3343
|
+
* @example Export All Users
|
|
3344
|
+
* ```typescript
|
|
3345
|
+
* const csvBlob = await sdk.users.exportCSV();
|
|
3346
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
3347
|
+
* ```
|
|
3348
|
+
*
|
|
3349
|
+
* @example Export Users Within Date Range
|
|
3350
|
+
* ```typescript
|
|
3351
|
+
* const csvBlob = await sdk.users.exportCSV({
|
|
3352
|
+
* dateFrom: '2024-01-01',
|
|
3353
|
+
* dateTo: '2024-12-31'
|
|
3354
|
+
* });
|
|
3355
|
+
* ```
|
|
3356
|
+
*/
|
|
3357
|
+
async exportCSV(options) {
|
|
3358
|
+
const userApi = new user.UserApi(this.apiClient);
|
|
3359
|
+
return userApi.exportCSV(options);
|
|
3360
|
+
}
|
|
3185
3361
|
/**
|
|
3186
3362
|
* Get the user service for advanced operations
|
|
3187
3363
|
*
|
|
@@ -4644,7 +4820,13 @@ class CampaignManager {
|
|
|
4644
4820
|
* ```
|
|
4645
4821
|
*/
|
|
4646
4822
|
async getCampaigns(options) {
|
|
4647
|
-
|
|
4823
|
+
// Convert Date objects to ISO strings for API compatibility
|
|
4824
|
+
const normalizedOptions = options ? {
|
|
4825
|
+
...options,
|
|
4826
|
+
startDate: options.startDate instanceof Date ? options.startDate.toISOString() : options.startDate,
|
|
4827
|
+
endDate: options.endDate instanceof Date ? options.endDate.toISOString() : options.endDate,
|
|
4828
|
+
} : undefined;
|
|
4829
|
+
return this.campaignService.getCampaigns(normalizedOptions);
|
|
4648
4830
|
}
|
|
4649
4831
|
/**
|
|
4650
4832
|
* Admin: Create new campaign
|
|
@@ -5293,6 +5475,60 @@ class CampaignManager {
|
|
|
5293
5475
|
async removeTriggerSource(campaignId, triggerSourceId) {
|
|
5294
5476
|
return this.campaignService.removeTriggerSourceFromCampaign(campaignId, triggerSourceId);
|
|
5295
5477
|
}
|
|
5478
|
+
/**
|
|
5479
|
+
* Admin: Export campaigns as CSV
|
|
5480
|
+
*
|
|
5481
|
+
* Generates a comprehensive CSV export of all tenant campaigns for
|
|
5482
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
5483
|
+
* requires administrator privileges and creates a downloadable file.
|
|
5484
|
+
*
|
|
5485
|
+
* @param options - Optional date range filters
|
|
5486
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
5487
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
5488
|
+
* @returns Promise resolving to CSV blob for download
|
|
5489
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
5490
|
+
*
|
|
5491
|
+
* @example Export All Campaigns
|
|
5492
|
+
* ```typescript
|
|
5493
|
+
* const csvBlob = await sdk.campaigns.exportCSV();
|
|
5494
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
5495
|
+
* ```
|
|
5496
|
+
*
|
|
5497
|
+
* @example Export Campaigns Within Date Range
|
|
5498
|
+
* ```typescript
|
|
5499
|
+
* const csvBlob = await sdk.campaigns.exportCSV({
|
|
5500
|
+
* dateFrom: '2024-01-01',
|
|
5501
|
+
* dateTo: '2024-12-31'
|
|
5502
|
+
* });
|
|
5503
|
+
* ```
|
|
5504
|
+
*/
|
|
5505
|
+
async exportCSV(options) {
|
|
5506
|
+
const campaignApi = new campaign.CampaignApi(this.apiClient);
|
|
5507
|
+
return campaignApi.exportCSV(options);
|
|
5508
|
+
}
|
|
5509
|
+
/**
|
|
5510
|
+
* Admin: Export campaign claims as CSV
|
|
5511
|
+
*
|
|
5512
|
+
* Generates a comprehensive CSV export of all campaign claim records for
|
|
5513
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
5514
|
+
* requires administrator privileges and creates a downloadable file.
|
|
5515
|
+
*
|
|
5516
|
+
* @param options - Optional date range filters
|
|
5517
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
5518
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
5519
|
+
* @returns Promise resolving to CSV blob for download
|
|
5520
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
5521
|
+
*
|
|
5522
|
+
* @example Export All Claims
|
|
5523
|
+
* ```typescript
|
|
5524
|
+
* const csvBlob = await sdk.campaigns.exportClaimsCSV();
|
|
5525
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
5526
|
+
* ```
|
|
5527
|
+
*/
|
|
5528
|
+
async exportClaimsCSV(options) {
|
|
5529
|
+
const campaignApi = new campaign.CampaignApi(this.apiClient);
|
|
5530
|
+
return campaignApi.exportClaimsCSV(options);
|
|
5531
|
+
}
|
|
5296
5532
|
/**
|
|
5297
5533
|
* Get the full campaign service for advanced operations
|
|
5298
5534
|
*
|
|
@@ -6099,6 +6335,60 @@ class RedemptionManager {
|
|
|
6099
6335
|
async deleteRedemption(id) {
|
|
6100
6336
|
return this.redemptionService.deleteRedemption(id);
|
|
6101
6337
|
}
|
|
6338
|
+
/**
|
|
6339
|
+
* Admin: Export redemptions as CSV
|
|
6340
|
+
*
|
|
6341
|
+
* Generates a comprehensive CSV export of all tenant redemptions for
|
|
6342
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
6343
|
+
* requires administrator privileges and creates a downloadable file.
|
|
6344
|
+
*
|
|
6345
|
+
* @param options - Optional date range filters
|
|
6346
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
6347
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
6348
|
+
* @returns Promise resolving to CSV blob for download
|
|
6349
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
6350
|
+
*
|
|
6351
|
+
* @example Export All Redemptions
|
|
6352
|
+
* ```typescript
|
|
6353
|
+
* const csvBlob = await sdk.redemptions.exportCSV();
|
|
6354
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6355
|
+
* ```
|
|
6356
|
+
*
|
|
6357
|
+
* @example Export Redemptions Within Date Range
|
|
6358
|
+
* ```typescript
|
|
6359
|
+
* const csvBlob = await sdk.redemptions.exportCSV({
|
|
6360
|
+
* dateFrom: '2024-01-01',
|
|
6361
|
+
* dateTo: '2024-12-31'
|
|
6362
|
+
* });
|
|
6363
|
+
* ```
|
|
6364
|
+
*/
|
|
6365
|
+
async exportCSV(options) {
|
|
6366
|
+
const redemptionApi = new redemptionService.RedemptionApi(this.apiClient);
|
|
6367
|
+
return redemptionApi.exportCSV(options);
|
|
6368
|
+
}
|
|
6369
|
+
/**
|
|
6370
|
+
* Admin: Export redemption redeems as CSV
|
|
6371
|
+
*
|
|
6372
|
+
* Generates a comprehensive CSV export of all redemption redeem records for
|
|
6373
|
+
* external analysis, reporting, or compliance purposes. This operation
|
|
6374
|
+
* requires administrator privileges and creates a downloadable file.
|
|
6375
|
+
*
|
|
6376
|
+
* @param options - Optional date range filters
|
|
6377
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
6378
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
6379
|
+
* @returns Promise resolving to CSV blob for download
|
|
6380
|
+
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
6381
|
+
*
|
|
6382
|
+
* @example Export All Redeems
|
|
6383
|
+
* ```typescript
|
|
6384
|
+
* const csvBlob = await sdk.redemptions.exportRedeemsCSV();
|
|
6385
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6386
|
+
* ```
|
|
6387
|
+
*/
|
|
6388
|
+
async exportRedeemsCSV(options) {
|
|
6389
|
+
const redemptionApi = new redemptionService.RedemptionApi(this.apiClient);
|
|
6390
|
+
return redemptionApi.exportRedeemsCSV(options);
|
|
6391
|
+
}
|
|
6102
6392
|
/**
|
|
6103
6393
|
* Get the full redemption service for advanced operations
|
|
6104
6394
|
*
|
|
@@ -6492,54 +6782,36 @@ class TransactionManager {
|
|
|
6492
6782
|
* external analysis, reporting, or compliance purposes. This operation
|
|
6493
6783
|
* requires administrator privileges and creates a downloadable file.
|
|
6494
6784
|
*
|
|
6785
|
+
* @param options - Optional date range filters
|
|
6786
|
+
* @param options.dateFrom - Start date filter (ISO date string)
|
|
6787
|
+
* @param options.dateTo - End date filter (ISO date string)
|
|
6495
6788
|
* @returns Promise resolving to CSV blob for download
|
|
6496
6789
|
* @throws {PersApiError} When not authenticated as administrator or export fails
|
|
6497
6790
|
*
|
|
6498
|
-
* @example
|
|
6791
|
+
* @example Export All Transactions
|
|
6499
6792
|
* ```typescript
|
|
6500
|
-
*
|
|
6501
|
-
*
|
|
6502
|
-
* const csvBlob = await sdk.transactions.exportTransactionsCSV();
|
|
6503
|
-
*
|
|
6504
|
-
* // Create download link
|
|
6505
|
-
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6506
|
-
* const link = document.createElement('a');
|
|
6507
|
-
* link.href = downloadUrl;
|
|
6508
|
-
* link.download = `transactions-${new Date().toISOString().split('T')[0]}.csv`;
|
|
6509
|
-
*
|
|
6510
|
-
* // Trigger download
|
|
6511
|
-
* document.body.appendChild(link);
|
|
6512
|
-
* link.click();
|
|
6513
|
-
* document.body.removeChild(link);
|
|
6514
|
-
*
|
|
6515
|
-
* // Clean up object URL
|
|
6516
|
-
* URL.revokeObjectURL(downloadUrl);
|
|
6517
|
-
*
|
|
6518
|
-
* console.log('Transaction export downloaded successfully');
|
|
6519
|
-
*
|
|
6520
|
-
* } catch (error) {
|
|
6521
|
-
* console.log('Export failed:', error.message);
|
|
6522
|
-
* }
|
|
6793
|
+
* const csvBlob = await sdk.transactions.exportCSV();
|
|
6794
|
+
* const downloadUrl = URL.createObjectURL(csvBlob);
|
|
6523
6795
|
* ```
|
|
6524
6796
|
*
|
|
6525
|
-
* @example
|
|
6797
|
+
* @example Export Transactions Within Date Range
|
|
6526
6798
|
* ```typescript
|
|
6527
|
-
*
|
|
6528
|
-
*
|
|
6529
|
-
*
|
|
6530
|
-
*
|
|
6531
|
-
* const buffer = Buffer.from(await csvBlob.arrayBuffer());
|
|
6532
|
-
*
|
|
6533
|
-
* // Save to file system
|
|
6534
|
-
* const fs = require('fs');
|
|
6535
|
-
* const filename = `transactions-export-${Date.now()}.csv`;
|
|
6536
|
-
* fs.writeFileSync(filename, buffer);
|
|
6537
|
-
*
|
|
6538
|
-
* console.log(`Transaction data exported to ${filename}`);
|
|
6799
|
+
* const csvBlob = await sdk.transactions.exportCSV({
|
|
6800
|
+
* dateFrom: '2024-01-01',
|
|
6801
|
+
* dateTo: '2024-12-31'
|
|
6802
|
+
* });
|
|
6539
6803
|
* ```
|
|
6540
6804
|
*/
|
|
6541
|
-
async
|
|
6542
|
-
return this.transactionService.exportTransactionsCSV();
|
|
6805
|
+
async exportCSV(options) {
|
|
6806
|
+
return this.transactionService.exportTransactionsCSV(options);
|
|
6807
|
+
}
|
|
6808
|
+
/**
|
|
6809
|
+
* Admin: Export transactions as CSV
|
|
6810
|
+
*
|
|
6811
|
+
* @deprecated Use `exportCSV()` instead for consistent naming across all managers
|
|
6812
|
+
*/
|
|
6813
|
+
async exportTransactionsCSV(options) {
|
|
6814
|
+
return this.exportCSV(options);
|
|
6543
6815
|
}
|
|
6544
6816
|
/**
|
|
6545
6817
|
* Prepare existing transaction for client-side signing
|
|
@@ -8745,10 +9017,10 @@ class WebhookApi {
|
|
|
8745
9017
|
params.append('hookId', options.webhookId);
|
|
8746
9018
|
if (options?.status)
|
|
8747
9019
|
params.append('status', options.status);
|
|
8748
|
-
if (options?.
|
|
8749
|
-
params.append('dateFrom', options.
|
|
8750
|
-
if (options?.
|
|
8751
|
-
params.append('dateTo', options.
|
|
9020
|
+
if (options?.dateFrom)
|
|
9021
|
+
params.append('dateFrom', options.dateFrom);
|
|
9022
|
+
if (options?.dateTo)
|
|
9023
|
+
params.append('dateTo', options.dateTo);
|
|
8752
9024
|
if (options?.page)
|
|
8753
9025
|
params.append('page', String(options.page));
|
|
8754
9026
|
if (options?.limit)
|
|
@@ -9237,7 +9509,7 @@ class WebhookManager {
|
|
|
9237
9509
|
* // Get executions for specific webhook
|
|
9238
9510
|
* const executions = await sdk.webhooks.getExecutions({
|
|
9239
9511
|
* webhookId: 'webhook-123',
|
|
9240
|
-
*
|
|
9512
|
+
* dateFrom: '2024-01-01'
|
|
9241
9513
|
* });
|
|
9242
9514
|
* ```
|
|
9243
9515
|
*/
|
|
@@ -10620,6 +10892,28 @@ class BookingApi {
|
|
|
10620
10892
|
async delete(id) {
|
|
10621
10893
|
return this.apiClient.delete(`${this.basePath}/${id}`);
|
|
10622
10894
|
}
|
|
10895
|
+
// ==========================================
|
|
10896
|
+
// CSV EXPORT
|
|
10897
|
+
// ==========================================
|
|
10898
|
+
/**
|
|
10899
|
+
* ADMIN: Export bookings to CSV
|
|
10900
|
+
*
|
|
10901
|
+
* Returns a CSV file with booking data for the tenant.
|
|
10902
|
+
* Supports date range filtering.
|
|
10903
|
+
*
|
|
10904
|
+
* @param options - Export options (dateFrom, dateTo in ISO format)
|
|
10905
|
+
* @returns CSV blob
|
|
10906
|
+
*/
|
|
10907
|
+
async exportCSV(options) {
|
|
10908
|
+
const params = new URLSearchParams();
|
|
10909
|
+
if (options?.dateFrom)
|
|
10910
|
+
params.append('dateFrom', options.dateFrom);
|
|
10911
|
+
if (options?.dateTo)
|
|
10912
|
+
params.append('dateTo', options.dateTo);
|
|
10913
|
+
const queryString = params.toString();
|
|
10914
|
+
const url = `${this.basePath}/export/csv${queryString ? `?${queryString}` : ''}`;
|
|
10915
|
+
return this.apiClient.get(url, 'blob');
|
|
10916
|
+
}
|
|
10623
10917
|
}
|
|
10624
10918
|
|
|
10625
10919
|
/**
|
|
@@ -11072,6 +11366,28 @@ class PersSDK {
|
|
|
11072
11366
|
this.setupWalletEventsAutoConnect();
|
|
11073
11367
|
// Auto-restore session from stored tokens (if enabled, default: true)
|
|
11074
11368
|
this.setupAutoRestoreSession();
|
|
11369
|
+
// Dev-mode tracking validation (helps developers ensure proper attribution)
|
|
11370
|
+
this.validateTrackingInDev();
|
|
11371
|
+
}
|
|
11372
|
+
/**
|
|
11373
|
+
* Validate tracking configuration in development mode
|
|
11374
|
+
* @internal
|
|
11375
|
+
*/
|
|
11376
|
+
validateTrackingInDev() {
|
|
11377
|
+
// Only run in development (check common env vars)
|
|
11378
|
+
const isDev = (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development') ||
|
|
11379
|
+
(typeof window !== 'undefined' && window.__DEV__);
|
|
11380
|
+
if (!isDev)
|
|
11381
|
+
return;
|
|
11382
|
+
// Delay check to allow time for setDataSource/setPlatform calls
|
|
11383
|
+
setTimeout(() => {
|
|
11384
|
+
const result = this.apiClient.validateTracking();
|
|
11385
|
+
if (!result.isValid) {
|
|
11386
|
+
console.warn('[PERS SDK] Tracking configuration warnings:');
|
|
11387
|
+
result.warnings.forEach(w => console.warn(` ⚠️ ${w}`));
|
|
11388
|
+
console.warn('[PERS SDK] Call sdk.setDataSource() and sdk.setPlatform() for better analytics.');
|
|
11389
|
+
}
|
|
11390
|
+
}, 2000);
|
|
11075
11391
|
}
|
|
11076
11392
|
/**
|
|
11077
11393
|
* Setup automatic session restoration from stored tokens
|
|
@@ -11772,6 +12088,74 @@ class PersSDK {
|
|
|
11772
12088
|
// Reset manager so it picks up new config
|
|
11773
12089
|
this._walletEvents = undefined;
|
|
11774
12090
|
}
|
|
12091
|
+
// ==========================================
|
|
12092
|
+
// DATA SOURCE TRACKING
|
|
12093
|
+
// ==========================================
|
|
12094
|
+
/**
|
|
12095
|
+
* Set data source tracking for analytics attribution
|
|
12096
|
+
*
|
|
12097
|
+
* Use this to track where users and actions originate from.
|
|
12098
|
+
* Web apps typically only need medium/campaign/source (channel is auto-detected).
|
|
12099
|
+
* Native apps must set channel: 'mobile'.
|
|
12100
|
+
*
|
|
12101
|
+
* @param dataSource - Data source configuration
|
|
12102
|
+
*
|
|
12103
|
+
* @example Web app with UTM params
|
|
12104
|
+
* ```typescript
|
|
12105
|
+
* sdk.setDataSource({
|
|
12106
|
+
* medium: 'email',
|
|
12107
|
+
* campaign: 'summer_2026',
|
|
12108
|
+
* source: 'mailchimp',
|
|
12109
|
+
* });
|
|
12110
|
+
* ```
|
|
12111
|
+
*
|
|
12112
|
+
* @example Native app
|
|
12113
|
+
* ```typescript
|
|
12114
|
+
* sdk.setDataSource({
|
|
12115
|
+
* channel: 'mobile',
|
|
12116
|
+
* medium: 'push',
|
|
12117
|
+
* campaign: 'retention_30d',
|
|
12118
|
+
* });
|
|
12119
|
+
* ```
|
|
12120
|
+
*/
|
|
12121
|
+
setDataSource(dataSource) {
|
|
12122
|
+
this.apiClient.setDataSource(dataSource);
|
|
12123
|
+
}
|
|
12124
|
+
/**
|
|
12125
|
+
* Update data source (merges with existing values)
|
|
12126
|
+
*
|
|
12127
|
+
* @param dataSource - Partial data source to merge
|
|
12128
|
+
*
|
|
12129
|
+
* @example Update campaign after deep link
|
|
12130
|
+
* ```typescript
|
|
12131
|
+
* sdk.updateDataSource({ campaign: 'new_campaign' });
|
|
12132
|
+
* ```
|
|
12133
|
+
*/
|
|
12134
|
+
updateDataSource(dataSource) {
|
|
12135
|
+
this.apiClient.updateDataSource(dataSource);
|
|
12136
|
+
}
|
|
12137
|
+
/**
|
|
12138
|
+
* Set platform info for device analytics
|
|
12139
|
+
*
|
|
12140
|
+
* Native apps should call this on initialization with device info.
|
|
12141
|
+
* Web apps can optionally send browser/OS info.
|
|
12142
|
+
*
|
|
12143
|
+
* @param platform - Platform information
|
|
12144
|
+
*
|
|
12145
|
+
* @example Native app
|
|
12146
|
+
* ```typescript
|
|
12147
|
+
* sdk.setPlatform({
|
|
12148
|
+
* os: 'iOS',
|
|
12149
|
+
* osVersion: '17.4',
|
|
12150
|
+
* app: 'MyApp',
|
|
12151
|
+
* appVersion: '2.3.1',
|
|
12152
|
+
* deviceType: 'phone',
|
|
12153
|
+
* });
|
|
12154
|
+
* ```
|
|
12155
|
+
*/
|
|
12156
|
+
setPlatform(platform) {
|
|
12157
|
+
this.apiClient.setPlatform(platform);
|
|
12158
|
+
}
|
|
11775
12159
|
/**
|
|
11776
12160
|
* Gets the API client for direct PERS API requests
|
|
11777
12161
|
*
|
|
@@ -11858,6 +12242,7 @@ exports.SDK_USER_AGENT = SDK_USER_AGENT;
|
|
|
11858
12242
|
exports.SDK_VERSION = SDK_VERSION;
|
|
11859
12243
|
exports.StaticJwtAuthProvider = StaticJwtAuthProvider;
|
|
11860
12244
|
exports.TokenManager = TokenManager;
|
|
12245
|
+
exports.TrackingManager = TrackingManager;
|
|
11861
12246
|
exports.TransactionManager = TransactionManager;
|
|
11862
12247
|
exports.TriggerSourceManager = TriggerSourceManager;
|
|
11863
12248
|
exports.UserManager = UserManager;
|
|
@@ -11873,4 +12258,4 @@ exports.createPersEventsClient = createPersEventsClient;
|
|
|
11873
12258
|
exports.createPersSDK = createPersSDK;
|
|
11874
12259
|
exports.isFatalAuthErrorInMessage = isFatalAuthErrorInMessage;
|
|
11875
12260
|
exports.mergeWithDefaults = mergeWithDefaults;
|
|
11876
|
-
//# sourceMappingURL=pers-sdk-
|
|
12261
|
+
//# sourceMappingURL=pers-sdk-CVsokrmI.cjs.map
|