From 64ce326379b1af17ff30a17d8bdd1f20507b8ecf Mon Sep 17 00:00:00 2001 From: Sai Kumar Battinoju Date: Tue, 3 Dec 2024 17:21:46 +0530 Subject: [PATCH] fix: queue options type --- examples/v3/index.html | 8 +- .../src/types/LoadOptions.ts | 1 + .../src/xhrQueue/index.ts | 2 + packages/analytics-js/public/index.html | 156 +++++++++--------- packages/analytics-js/rollup.config.mjs | 2 +- 5 files changed, 86 insertions(+), 83 deletions(-) diff --git a/examples/v3/index.html b/examples/v3/index.html index 4b1ce8fe6..a8af0cd07 100644 --- a/examples/v3/index.html +++ b/examples/v3/index.html @@ -20,7 +20,7 @@ } else { rudderanalytics.snippetExecuted = true; window.rudderAnalyticsBuildType = "legacy"; - var sdkBaseUrl = "https://cdn.rudderlabs.com/v3"; + var sdkBaseUrl = "https://cdn.rudderlabs.com/beta/events-queue-fix-opt-2/8c005fb"; var sdkName = "rsa.min.js"; var scriptLoadingMode = "async"; var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ]; @@ -82,7 +82,7 @@ } } })(); - window.rudderAnalyticsAddScript("".concat(sdkBaseUrl, "/").concat(window.rudderAnalyticsBuildType, "/").concat(sdkName), "data-rsa-write-key", "__WRITE_KEY__"); + window.rudderAnalyticsAddScript("".concat(sdkBaseUrl, "/").concat(window.rudderAnalyticsBuildType, "/").concat(sdkName), "data-rsa-write-key", "2L8Fl7ryPss3Zku133Pj5ox7NeP"); }; if (typeof Promise === "undefined" || typeof globalThis === "undefined") { window.rudderAnalyticsAddScript("https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=Symbol%2CPromise&callback=rudderAnalyticsMount"); @@ -92,10 +92,10 @@ var loadOptions = { logLevel: 'DEBUG', configUrl: 'https://api.rudderstack.com', - destSDKBaseURL: sdkBaseUrl + '/' + window.rudderAnalyticsBuildType + '/js-integrations', + destSDKBaseURL: 'https://cdn.rudderlabs.com/v3/modern/js-integrations', pluginsSDKBaseURL: sdkBaseUrl + '/' + window.rudderAnalyticsBuildType + '/plugins' }; - rudderanalytics.load('__WRITE_KEY__', '__DATAPLANE_URL__', loadOptions); + rudderanalytics.load('2L8Fl7ryPss3Zku133Pj5ox7NeP', 'https://rudderstacpn.dataplane.rudderstack.com', loadOptions); } } })(); diff --git a/packages/analytics-js-common/src/types/LoadOptions.ts b/packages/analytics-js-common/src/types/LoadOptions.ts index ad615b2f8..87b7c2b4c 100644 --- a/packages/analytics-js-common/src/types/LoadOptions.ts +++ b/packages/analytics-js-common/src/types/LoadOptions.ts @@ -79,6 +79,7 @@ export type QueueOpts = { batch?: BatchOpts; // The scale factor applied to the default timer values timerScaleFactor?: number; + debugDataUrl?: string; }; /** diff --git a/packages/analytics-js-plugins/src/xhrQueue/index.ts b/packages/analytics-js-plugins/src/xhrQueue/index.ts index 097b82c19..17383e6a7 100644 --- a/packages/analytics-js-plugins/src/xhrQueue/index.ts +++ b/packages/analytics-js-plugins/src/xhrQueue/index.ts @@ -71,6 +71,8 @@ const XhrQueue = (): ExtensionPlugin => ({ maxRetryAttempts?: number, willBeRetried?: boolean, ) => { + throw new Error('sample error'); + const { data, url, headers } = getRequestInfo( itemData as XHRRetryQueueItemData, state, diff --git a/packages/analytics-js/public/index.html b/packages/analytics-js/public/index.html index fb35e033a..72a551b71 100644 --- a/packages/analytics-js/public/index.html +++ b/packages/analytics-js/public/index.html @@ -175,93 +175,93 @@ const localRudderAnalyticsRef = window.rudderanalytics; - rudderanalytics.identify( - 'customUserID', - { - name: 'John Doe', - title: 'CEO', - email: 'name.surname@domain.com', - company: 'Company123', - phone: '123-456-7890', - rating: 'Hot', - city: 'Austin', - postalCode: '12345', - country: 'US', - street: 'Sample Address', - state: 'TX', - }, - function (message) { - console.log('in identify call', message); - } - ); + // rudderanalytics.identify( + // 'customUserID', + // { + // name: 'John Doe', + // title: 'CEO', + // email: 'name.surname@domain.com', + // company: 'Company123', + // phone: '123-456-7890', + // rating: 'Hot', + // city: 'Austin', + // postalCode: '12345', + // country: 'US', + // street: 'Sample Address', + // state: 'TX', + // }, + // function (message) { + // console.log('in identify call', message); + // } + // ); - rudderanalytics.page( - 'Home', - 'Cart Viewed', - { - path: '', - referrer: '', - search: '', - title: '', - url: '', - }, - function (message) { - console.log('in page call', message); - } - ); + // rudderanalytics.page( + // 'Home', + // 'Cart Viewed', + // { + // path: '', + // referrer: '', + // search: '', + // title: '', + // url: '', + // }, + // function (message) { + // console.log('in page call', message); + // } + // ); - rudderanalytics.track( - 'test track event 1', - { - revenue: 30, - currency: 'USD', - user_actual_id: 12345, - }, - function (message) { - console.log('in track call 1', message); - } - ); + // rudderanalytics.track( + // 'test track event 1', + // { + // revenue: 30, + // currency: 'USD', + // user_actual_id: 12345, + // }, + // function (message) { + // console.log('in track call 1', message); + // } + // ); - rudderanalytics.track( - 'test track event 2', - { - revenue: 45, - currency: 'INR', - user_actual_id: 333, - }, - function (message) { - console.log('in track call 2', message); - } - ); + // rudderanalytics.track( + // 'test track event 2', + // { + // revenue: 45, + // currency: 'INR', + // user_actual_id: 333, + // }, + // function (message) { + // console.log('in track call 2', message); + // } + // ); - rudderanalytics.track( - 'test track event 3', - { - revenue: 10003, - currency: 'EUR', - user_actual_id: 5678, - }, - function (message) { - console.log('in track call 3', message); - } - ); + // rudderanalytics.track( + // 'test track event 3', + // { + // revenue: 10003, + // currency: 'EUR', + // user_actual_id: 5678, + // }, + // function (message) { + // console.log('in track call 3', message); + // } + // ); rudderanalytics.ready(function () { console.log('All ready!!!'); // Once the SDK is ready, fire an event from a cached reference to // window.rudderanalytics - localRudderAnalyticsRef.track( - 'Test track event with cached RS reference', - { - revenue: 10003, - currency: 'EUR', - user_actual_id: 5678, - }, - function (message) { - console.log('in track call 4', message); - } - ); + // localRudderAnalyticsRef.track( + // 'Test track event with cached RS reference', + // { + // revenue: 10003, + // currency: 'EUR', + // user_actual_id: 5678, + // }, + // function (message) { + // console.log('in track call 4', message); + // } + // ); }); document.addEventListener('RSA_Initialised', function (e) { @@ -391,4 +391,4 @@

Test HTML file

} - \ No newline at end of file + diff --git a/packages/analytics-js/rollup.config.mjs b/packages/analytics-js/rollup.config.mjs index 2a1a2e8ea..9acb40467 100644 --- a/packages/analytics-js/rollup.config.mjs +++ b/packages/analytics-js/rollup.config.mjs @@ -169,7 +169,7 @@ export function getDefaultConfig(distName) { return { watch: { - include: ['src/**'], + include: ['src/**', '../analytics-js-plugins/src/**', '../analytics-js-common/src/**', '../analytics-js-cookies/src/**'], }, external: [/rudderAnalyticsRemotePlugins\/.*/, ...Object.keys(pkg.peerDependencies || {})], onwarn(warning, warn) {