cryptique-sdk 1.2.1 → 1.2.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/lib/cjs/index.js +26 -20
- package/lib/esm/index.js +26 -20
- package/lib/umd/index.js +26 -20
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -24,6 +24,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
24
24
|
window.Cryptique = window.Cryptique || {};
|
|
25
25
|
window.Cryptique.initialized = true;
|
|
26
26
|
|
|
27
|
+
// Capture native fetch before any third-party library (wagmi, viem, etc.)
|
|
28
|
+
// can patch window.fetch. All SDK outgoing requests use this reference
|
|
29
|
+
// directly so they are never affected by external fetch wrappers.
|
|
30
|
+
const _nativeFetch = window.fetch.bind(window);
|
|
31
|
+
|
|
27
32
|
// ============================================================================
|
|
28
33
|
// SECTION 1: CONFIGURATION
|
|
29
34
|
// ============================================================================
|
|
@@ -563,7 +568,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
563
568
|
// Construct migration endpoint URL from track endpoint
|
|
564
569
|
const migrationUrl = CONFIG.API.TRACK.replace('/track', '/migrate-user-id');
|
|
565
570
|
|
|
566
|
-
const response = await
|
|
571
|
+
const response = await _nativeFetch(migrationUrl, {
|
|
567
572
|
method: 'POST',
|
|
568
573
|
headers: {
|
|
569
574
|
'Content-Type': 'application/json'
|
|
@@ -4420,7 +4425,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4420
4425
|
fetchOptions.body = JSON.stringify(payload);
|
|
4421
4426
|
}
|
|
4422
4427
|
|
|
4423
|
-
const response = await
|
|
4428
|
+
const response = await _nativeFetch(endpoint, fetchOptions);
|
|
4424
4429
|
|
|
4425
4430
|
clearTimeout(timeoutId);
|
|
4426
4431
|
timeoutId = null;
|
|
@@ -4603,7 +4608,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4603
4608
|
};
|
|
4604
4609
|
|
|
4605
4610
|
// Send PATCH request to update wallet address
|
|
4606
|
-
const response = await
|
|
4611
|
+
const response = await _nativeFetch(CONFIG.API.UTM_EVENTS + '/update-wallet', {
|
|
4607
4612
|
method: 'PATCH',
|
|
4608
4613
|
headers: {
|
|
4609
4614
|
'Content-Type': 'application/json',
|
|
@@ -5319,7 +5324,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5319
5324
|
startNetworkTracking() {
|
|
5320
5325
|
try {
|
|
5321
5326
|
// Track fetch errors - only intercept calls to our own backend
|
|
5322
|
-
|
|
5327
|
+
// Use _nativeFetch as the base so the wrapper always delegates to the
|
|
5328
|
+
// true browser fetch, regardless of what other libraries have patched.
|
|
5323
5329
|
window.fetch = function(...args) {
|
|
5324
5330
|
const startTime = Date.now();
|
|
5325
5331
|
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
@@ -5327,10 +5333,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5327
5333
|
// Pass third-party requests through completely untouched — no interception,
|
|
5328
5334
|
// no involvement of our SDK in their call stack or error handling
|
|
5329
5335
|
if (!url.includes('backend.cryptique.io')) {
|
|
5330
|
-
return
|
|
5336
|
+
return _nativeFetch.apply(this, args);
|
|
5331
5337
|
}
|
|
5332
5338
|
|
|
5333
|
-
return
|
|
5339
|
+
return _nativeFetch.apply(this, args).then(response => {
|
|
5334
5340
|
// Only track error status codes (4xx, 5xx)
|
|
5335
5341
|
if (response.status >= 400) {
|
|
5336
5342
|
const networkErrorData = {
|
|
@@ -6225,7 +6231,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6225
6231
|
*/
|
|
6226
6232
|
async _sendEvent(eventData) {
|
|
6227
6233
|
try {
|
|
6228
|
-
const response = await
|
|
6234
|
+
const response = await _nativeFetch(CONFIG.API.EVENTS, {
|
|
6229
6235
|
method: 'POST',
|
|
6230
6236
|
headers: {
|
|
6231
6237
|
'Content-Type': 'application/json',
|
|
@@ -6375,7 +6381,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6375
6381
|
|
|
6376
6382
|
// Call API endpoint
|
|
6377
6383
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/identify');
|
|
6378
|
-
const response = await
|
|
6384
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6379
6385
|
method: 'POST',
|
|
6380
6386
|
headers: {
|
|
6381
6387
|
'Content-Type': 'application/json',
|
|
@@ -6486,7 +6492,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6486
6492
|
|
|
6487
6493
|
// Call backend endpoint to ensure new anonymous identity exists
|
|
6488
6494
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/reset');
|
|
6489
|
-
const response = await
|
|
6495
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6490
6496
|
method: 'POST',
|
|
6491
6497
|
headers: {
|
|
6492
6498
|
'Content-Type': 'application/json',
|
|
@@ -6601,7 +6607,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6601
6607
|
// Call API endpoint to update user_identity and session in database
|
|
6602
6608
|
// This handles merging and immediate session update if session exists
|
|
6603
6609
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/wallet-address');
|
|
6604
|
-
const response = await
|
|
6610
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6605
6611
|
method: 'POST',
|
|
6606
6612
|
headers: {
|
|
6607
6613
|
'Content-Type': 'application/json',
|
|
@@ -7335,7 +7341,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7335
7341
|
}
|
|
7336
7342
|
|
|
7337
7343
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/set');
|
|
7338
|
-
const response = await
|
|
7344
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7339
7345
|
method: 'POST',
|
|
7340
7346
|
headers: {
|
|
7341
7347
|
'Content-Type': 'application/json',
|
|
@@ -7384,7 +7390,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7384
7390
|
}
|
|
7385
7391
|
|
|
7386
7392
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/set_once');
|
|
7387
|
-
const response = await
|
|
7393
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7388
7394
|
method: 'POST',
|
|
7389
7395
|
headers: {
|
|
7390
7396
|
'Content-Type': 'application/json',
|
|
@@ -7433,7 +7439,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7433
7439
|
}
|
|
7434
7440
|
|
|
7435
7441
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/unset');
|
|
7436
|
-
const response = await
|
|
7442
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7437
7443
|
method: 'POST',
|
|
7438
7444
|
headers: {
|
|
7439
7445
|
'Content-Type': 'application/json',
|
|
@@ -7488,7 +7494,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7488
7494
|
}
|
|
7489
7495
|
|
|
7490
7496
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/increment');
|
|
7491
|
-
const response = await
|
|
7497
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7492
7498
|
method: 'POST',
|
|
7493
7499
|
headers: {
|
|
7494
7500
|
'Content-Type': 'application/json',
|
|
@@ -7544,7 +7550,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7544
7550
|
}
|
|
7545
7551
|
|
|
7546
7552
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/append');
|
|
7547
|
-
const response = await
|
|
7553
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7548
7554
|
method: 'POST',
|
|
7549
7555
|
headers: {
|
|
7550
7556
|
'Content-Type': 'application/json',
|
|
@@ -7600,7 +7606,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7600
7606
|
}
|
|
7601
7607
|
|
|
7602
7608
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/union');
|
|
7603
|
-
const response = await
|
|
7609
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7604
7610
|
method: 'POST',
|
|
7605
7611
|
headers: {
|
|
7606
7612
|
'Content-Type': 'application/json',
|
|
@@ -7656,7 +7662,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7656
7662
|
}
|
|
7657
7663
|
|
|
7658
7664
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/remove');
|
|
7659
|
-
const response = await
|
|
7665
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7660
7666
|
method: 'POST',
|
|
7661
7667
|
headers: {
|
|
7662
7668
|
'Content-Type': 'application/json',
|
|
@@ -7707,7 +7713,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7707
7713
|
}
|
|
7708
7714
|
|
|
7709
7715
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/track_charge');
|
|
7710
|
-
const response = await
|
|
7716
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7711
7717
|
method: 'POST',
|
|
7712
7718
|
headers: {
|
|
7713
7719
|
'Content-Type': 'application/json',
|
|
@@ -7751,7 +7757,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7751
7757
|
}
|
|
7752
7758
|
|
|
7753
7759
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/clear_charges');
|
|
7754
|
-
const response = await
|
|
7760
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7755
7761
|
method: 'POST',
|
|
7756
7762
|
headers: {
|
|
7757
7763
|
'Content-Type': 'application/json',
|
|
@@ -7793,7 +7799,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7793
7799
|
}
|
|
7794
7800
|
|
|
7795
7801
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/delete_user');
|
|
7796
|
-
const response = await
|
|
7802
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7797
7803
|
method: 'POST',
|
|
7798
7804
|
headers: {
|
|
7799
7805
|
'Content-Type': 'application/json',
|
package/lib/esm/index.js
CHANGED
|
@@ -22,6 +22,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
22
22
|
window.Cryptique = window.Cryptique || {};
|
|
23
23
|
window.Cryptique.initialized = true;
|
|
24
24
|
|
|
25
|
+
// Capture native fetch before any third-party library (wagmi, viem, etc.)
|
|
26
|
+
// can patch window.fetch. All SDK outgoing requests use this reference
|
|
27
|
+
// directly so they are never affected by external fetch wrappers.
|
|
28
|
+
const _nativeFetch = window.fetch.bind(window);
|
|
29
|
+
|
|
25
30
|
// ============================================================================
|
|
26
31
|
// SECTION 1: CONFIGURATION
|
|
27
32
|
// ============================================================================
|
|
@@ -561,7 +566,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
561
566
|
// Construct migration endpoint URL from track endpoint
|
|
562
567
|
const migrationUrl = CONFIG.API.TRACK.replace('/track', '/migrate-user-id');
|
|
563
568
|
|
|
564
|
-
const response = await
|
|
569
|
+
const response = await _nativeFetch(migrationUrl, {
|
|
565
570
|
method: 'POST',
|
|
566
571
|
headers: {
|
|
567
572
|
'Content-Type': 'application/json'
|
|
@@ -4418,7 +4423,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4418
4423
|
fetchOptions.body = JSON.stringify(payload);
|
|
4419
4424
|
}
|
|
4420
4425
|
|
|
4421
|
-
const response = await
|
|
4426
|
+
const response = await _nativeFetch(endpoint, fetchOptions);
|
|
4422
4427
|
|
|
4423
4428
|
clearTimeout(timeoutId);
|
|
4424
4429
|
timeoutId = null;
|
|
@@ -4601,7 +4606,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
4601
4606
|
};
|
|
4602
4607
|
|
|
4603
4608
|
// Send PATCH request to update wallet address
|
|
4604
|
-
const response = await
|
|
4609
|
+
const response = await _nativeFetch(CONFIG.API.UTM_EVENTS + '/update-wallet', {
|
|
4605
4610
|
method: 'PATCH',
|
|
4606
4611
|
headers: {
|
|
4607
4612
|
'Content-Type': 'application/json',
|
|
@@ -5317,7 +5322,8 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5317
5322
|
startNetworkTracking() {
|
|
5318
5323
|
try {
|
|
5319
5324
|
// Track fetch errors - only intercept calls to our own backend
|
|
5320
|
-
|
|
5325
|
+
// Use _nativeFetch as the base so the wrapper always delegates to the
|
|
5326
|
+
// true browser fetch, regardless of what other libraries have patched.
|
|
5321
5327
|
window.fetch = function(...args) {
|
|
5322
5328
|
const startTime = Date.now();
|
|
5323
5329
|
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
@@ -5325,10 +5331,10 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
5325
5331
|
// Pass third-party requests through completely untouched — no interception,
|
|
5326
5332
|
// no involvement of our SDK in their call stack or error handling
|
|
5327
5333
|
if (!url.includes('backend.cryptique.io')) {
|
|
5328
|
-
return
|
|
5334
|
+
return _nativeFetch.apply(this, args);
|
|
5329
5335
|
}
|
|
5330
5336
|
|
|
5331
|
-
return
|
|
5337
|
+
return _nativeFetch.apply(this, args).then(response => {
|
|
5332
5338
|
// Only track error status codes (4xx, 5xx)
|
|
5333
5339
|
if (response.status >= 400) {
|
|
5334
5340
|
const networkErrorData = {
|
|
@@ -6223,7 +6229,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6223
6229
|
*/
|
|
6224
6230
|
async _sendEvent(eventData) {
|
|
6225
6231
|
try {
|
|
6226
|
-
const response = await
|
|
6232
|
+
const response = await _nativeFetch(CONFIG.API.EVENTS, {
|
|
6227
6233
|
method: 'POST',
|
|
6228
6234
|
headers: {
|
|
6229
6235
|
'Content-Type': 'application/json',
|
|
@@ -6373,7 +6379,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6373
6379
|
|
|
6374
6380
|
// Call API endpoint
|
|
6375
6381
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/identify');
|
|
6376
|
-
const response = await
|
|
6382
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6377
6383
|
method: 'POST',
|
|
6378
6384
|
headers: {
|
|
6379
6385
|
'Content-Type': 'application/json',
|
|
@@ -6484,7 +6490,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6484
6490
|
|
|
6485
6491
|
// Call backend endpoint to ensure new anonymous identity exists
|
|
6486
6492
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/reset');
|
|
6487
|
-
const response = await
|
|
6493
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6488
6494
|
method: 'POST',
|
|
6489
6495
|
headers: {
|
|
6490
6496
|
'Content-Type': 'application/json',
|
|
@@ -6599,7 +6605,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
6599
6605
|
// Call API endpoint to update user_identity and session in database
|
|
6600
6606
|
// This handles merging and immediate session update if session exists
|
|
6601
6607
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/wallet-address');
|
|
6602
|
-
const response = await
|
|
6608
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6603
6609
|
method: 'POST',
|
|
6604
6610
|
headers: {
|
|
6605
6611
|
'Content-Type': 'application/json',
|
|
@@ -7333,7 +7339,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7333
7339
|
}
|
|
7334
7340
|
|
|
7335
7341
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/set');
|
|
7336
|
-
const response = await
|
|
7342
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7337
7343
|
method: 'POST',
|
|
7338
7344
|
headers: {
|
|
7339
7345
|
'Content-Type': 'application/json',
|
|
@@ -7382,7 +7388,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7382
7388
|
}
|
|
7383
7389
|
|
|
7384
7390
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/set_once');
|
|
7385
|
-
const response = await
|
|
7391
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7386
7392
|
method: 'POST',
|
|
7387
7393
|
headers: {
|
|
7388
7394
|
'Content-Type': 'application/json',
|
|
@@ -7431,7 +7437,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7431
7437
|
}
|
|
7432
7438
|
|
|
7433
7439
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/unset');
|
|
7434
|
-
const response = await
|
|
7440
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7435
7441
|
method: 'POST',
|
|
7436
7442
|
headers: {
|
|
7437
7443
|
'Content-Type': 'application/json',
|
|
@@ -7486,7 +7492,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7486
7492
|
}
|
|
7487
7493
|
|
|
7488
7494
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/increment');
|
|
7489
|
-
const response = await
|
|
7495
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7490
7496
|
method: 'POST',
|
|
7491
7497
|
headers: {
|
|
7492
7498
|
'Content-Type': 'application/json',
|
|
@@ -7542,7 +7548,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7542
7548
|
}
|
|
7543
7549
|
|
|
7544
7550
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/append');
|
|
7545
|
-
const response = await
|
|
7551
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7546
7552
|
method: 'POST',
|
|
7547
7553
|
headers: {
|
|
7548
7554
|
'Content-Type': 'application/json',
|
|
@@ -7598,7 +7604,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7598
7604
|
}
|
|
7599
7605
|
|
|
7600
7606
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/union');
|
|
7601
|
-
const response = await
|
|
7607
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7602
7608
|
method: 'POST',
|
|
7603
7609
|
headers: {
|
|
7604
7610
|
'Content-Type': 'application/json',
|
|
@@ -7654,7 +7660,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7654
7660
|
}
|
|
7655
7661
|
|
|
7656
7662
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/remove');
|
|
7657
|
-
const response = await
|
|
7663
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7658
7664
|
method: 'POST',
|
|
7659
7665
|
headers: {
|
|
7660
7666
|
'Content-Type': 'application/json',
|
|
@@ -7705,7 +7711,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7705
7711
|
}
|
|
7706
7712
|
|
|
7707
7713
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/track_charge');
|
|
7708
|
-
const response = await
|
|
7714
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7709
7715
|
method: 'POST',
|
|
7710
7716
|
headers: {
|
|
7711
7717
|
'Content-Type': 'application/json',
|
|
@@ -7749,7 +7755,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7749
7755
|
}
|
|
7750
7756
|
|
|
7751
7757
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/clear_charges');
|
|
7752
|
-
const response = await
|
|
7758
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7753
7759
|
method: 'POST',
|
|
7754
7760
|
headers: {
|
|
7755
7761
|
'Content-Type': 'application/json',
|
|
@@ -7791,7 +7797,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
|
|
|
7791
7797
|
}
|
|
7792
7798
|
|
|
7793
7799
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/delete_user');
|
|
7794
|
-
const response = await
|
|
7800
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7795
7801
|
method: 'POST',
|
|
7796
7802
|
headers: {
|
|
7797
7803
|
'Content-Type': 'application/json',
|
package/lib/umd/index.js
CHANGED
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
window.Cryptique = window.Cryptique || {};
|
|
29
29
|
window.Cryptique.initialized = true;
|
|
30
30
|
|
|
31
|
+
// Capture native fetch before any third-party library (wagmi, viem, etc.)
|
|
32
|
+
// can patch window.fetch. All SDK outgoing requests use this reference
|
|
33
|
+
// directly so they are never affected by external fetch wrappers.
|
|
34
|
+
const _nativeFetch = window.fetch.bind(window);
|
|
35
|
+
|
|
31
36
|
// ============================================================================
|
|
32
37
|
// SECTION 1: CONFIGURATION
|
|
33
38
|
// ============================================================================
|
|
@@ -567,7 +572,7 @@
|
|
|
567
572
|
// Construct migration endpoint URL from track endpoint
|
|
568
573
|
const migrationUrl = CONFIG.API.TRACK.replace('/track', '/migrate-user-id');
|
|
569
574
|
|
|
570
|
-
const response = await
|
|
575
|
+
const response = await _nativeFetch(migrationUrl, {
|
|
571
576
|
method: 'POST',
|
|
572
577
|
headers: {
|
|
573
578
|
'Content-Type': 'application/json'
|
|
@@ -4424,7 +4429,7 @@
|
|
|
4424
4429
|
fetchOptions.body = JSON.stringify(payload);
|
|
4425
4430
|
}
|
|
4426
4431
|
|
|
4427
|
-
const response = await
|
|
4432
|
+
const response = await _nativeFetch(endpoint, fetchOptions);
|
|
4428
4433
|
|
|
4429
4434
|
clearTimeout(timeoutId);
|
|
4430
4435
|
timeoutId = null;
|
|
@@ -4607,7 +4612,7 @@
|
|
|
4607
4612
|
};
|
|
4608
4613
|
|
|
4609
4614
|
// Send PATCH request to update wallet address
|
|
4610
|
-
const response = await
|
|
4615
|
+
const response = await _nativeFetch(CONFIG.API.UTM_EVENTS + '/update-wallet', {
|
|
4611
4616
|
method: 'PATCH',
|
|
4612
4617
|
headers: {
|
|
4613
4618
|
'Content-Type': 'application/json',
|
|
@@ -5323,7 +5328,8 @@
|
|
|
5323
5328
|
startNetworkTracking() {
|
|
5324
5329
|
try {
|
|
5325
5330
|
// Track fetch errors - only intercept calls to our own backend
|
|
5326
|
-
|
|
5331
|
+
// Use _nativeFetch as the base so the wrapper always delegates to the
|
|
5332
|
+
// true browser fetch, regardless of what other libraries have patched.
|
|
5327
5333
|
window.fetch = function(...args) {
|
|
5328
5334
|
const startTime = Date.now();
|
|
5329
5335
|
const url = typeof args[0] === 'string' ? args[0] : (args[0]?.url || '');
|
|
@@ -5331,10 +5337,10 @@
|
|
|
5331
5337
|
// Pass third-party requests through completely untouched — no interception,
|
|
5332
5338
|
// no involvement of our SDK in their call stack or error handling
|
|
5333
5339
|
if (!url.includes('backend.cryptique.io')) {
|
|
5334
|
-
return
|
|
5340
|
+
return _nativeFetch.apply(this, args);
|
|
5335
5341
|
}
|
|
5336
5342
|
|
|
5337
|
-
return
|
|
5343
|
+
return _nativeFetch.apply(this, args).then(response => {
|
|
5338
5344
|
// Only track error status codes (4xx, 5xx)
|
|
5339
5345
|
if (response.status >= 400) {
|
|
5340
5346
|
const networkErrorData = {
|
|
@@ -6229,7 +6235,7 @@
|
|
|
6229
6235
|
*/
|
|
6230
6236
|
async _sendEvent(eventData) {
|
|
6231
6237
|
try {
|
|
6232
|
-
const response = await
|
|
6238
|
+
const response = await _nativeFetch(CONFIG.API.EVENTS, {
|
|
6233
6239
|
method: 'POST',
|
|
6234
6240
|
headers: {
|
|
6235
6241
|
'Content-Type': 'application/json',
|
|
@@ -6379,7 +6385,7 @@
|
|
|
6379
6385
|
|
|
6380
6386
|
// Call API endpoint
|
|
6381
6387
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/identify');
|
|
6382
|
-
const response = await
|
|
6388
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6383
6389
|
method: 'POST',
|
|
6384
6390
|
headers: {
|
|
6385
6391
|
'Content-Type': 'application/json',
|
|
@@ -6490,7 +6496,7 @@
|
|
|
6490
6496
|
|
|
6491
6497
|
// Call backend endpoint to ensure new anonymous identity exists
|
|
6492
6498
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/reset');
|
|
6493
|
-
const response = await
|
|
6499
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6494
6500
|
method: 'POST',
|
|
6495
6501
|
headers: {
|
|
6496
6502
|
'Content-Type': 'application/json',
|
|
@@ -6605,7 +6611,7 @@
|
|
|
6605
6611
|
// Call API endpoint to update user_identity and session in database
|
|
6606
6612
|
// This handles merging and immediate session update if session exists
|
|
6607
6613
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/wallet-address');
|
|
6608
|
-
const response = await
|
|
6614
|
+
const response = await _nativeFetch(apiUrl, {
|
|
6609
6615
|
method: 'POST',
|
|
6610
6616
|
headers: {
|
|
6611
6617
|
'Content-Type': 'application/json',
|
|
@@ -7339,7 +7345,7 @@
|
|
|
7339
7345
|
}
|
|
7340
7346
|
|
|
7341
7347
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/set');
|
|
7342
|
-
const response = await
|
|
7348
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7343
7349
|
method: 'POST',
|
|
7344
7350
|
headers: {
|
|
7345
7351
|
'Content-Type': 'application/json',
|
|
@@ -7388,7 +7394,7 @@
|
|
|
7388
7394
|
}
|
|
7389
7395
|
|
|
7390
7396
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/set_once');
|
|
7391
|
-
const response = await
|
|
7397
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7392
7398
|
method: 'POST',
|
|
7393
7399
|
headers: {
|
|
7394
7400
|
'Content-Type': 'application/json',
|
|
@@ -7437,7 +7443,7 @@
|
|
|
7437
7443
|
}
|
|
7438
7444
|
|
|
7439
7445
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/unset');
|
|
7440
|
-
const response = await
|
|
7446
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7441
7447
|
method: 'POST',
|
|
7442
7448
|
headers: {
|
|
7443
7449
|
'Content-Type': 'application/json',
|
|
@@ -7492,7 +7498,7 @@
|
|
|
7492
7498
|
}
|
|
7493
7499
|
|
|
7494
7500
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/increment');
|
|
7495
|
-
const response = await
|
|
7501
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7496
7502
|
method: 'POST',
|
|
7497
7503
|
headers: {
|
|
7498
7504
|
'Content-Type': 'application/json',
|
|
@@ -7548,7 +7554,7 @@
|
|
|
7548
7554
|
}
|
|
7549
7555
|
|
|
7550
7556
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/append');
|
|
7551
|
-
const response = await
|
|
7557
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7552
7558
|
method: 'POST',
|
|
7553
7559
|
headers: {
|
|
7554
7560
|
'Content-Type': 'application/json',
|
|
@@ -7604,7 +7610,7 @@
|
|
|
7604
7610
|
}
|
|
7605
7611
|
|
|
7606
7612
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/union');
|
|
7607
|
-
const response = await
|
|
7613
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7608
7614
|
method: 'POST',
|
|
7609
7615
|
headers: {
|
|
7610
7616
|
'Content-Type': 'application/json',
|
|
@@ -7660,7 +7666,7 @@
|
|
|
7660
7666
|
}
|
|
7661
7667
|
|
|
7662
7668
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/remove');
|
|
7663
|
-
const response = await
|
|
7669
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7664
7670
|
method: 'POST',
|
|
7665
7671
|
headers: {
|
|
7666
7672
|
'Content-Type': 'application/json',
|
|
@@ -7711,7 +7717,7 @@
|
|
|
7711
7717
|
}
|
|
7712
7718
|
|
|
7713
7719
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/track_charge');
|
|
7714
|
-
const response = await
|
|
7720
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7715
7721
|
method: 'POST',
|
|
7716
7722
|
headers: {
|
|
7717
7723
|
'Content-Type': 'application/json',
|
|
@@ -7755,7 +7761,7 @@
|
|
|
7755
7761
|
}
|
|
7756
7762
|
|
|
7757
7763
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/clear_charges');
|
|
7758
|
-
const response = await
|
|
7764
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7759
7765
|
method: 'POST',
|
|
7760
7766
|
headers: {
|
|
7761
7767
|
'Content-Type': 'application/json',
|
|
@@ -7797,7 +7803,7 @@
|
|
|
7797
7803
|
}
|
|
7798
7804
|
|
|
7799
7805
|
const apiUrl = CONFIG.API.TRACK.replace('/track', '/people/delete_user');
|
|
7800
|
-
const response = await
|
|
7806
|
+
const response = await _nativeFetch(apiUrl, {
|
|
7801
7807
|
method: 'POST',
|
|
7802
7808
|
headers: {
|
|
7803
7809
|
'Content-Type': 'application/json',
|
package/package.json
CHANGED