Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.2.3] 12th Sept 2025
- Removed Campaigns details from LC

## [2.2.2] 9th Sept 2025
- Fixed handling of safari web push notifications in iPhone.

Expand Down
49 changes: 3 additions & 46 deletions clevertap.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
const POPUP_LOADING = 'WZRK_POPUP_LOADING';
const CUSTOM_HTML_PREVIEW = 'ctCustomHtmlPreview';
const WEB_POPUP_PREVIEW = 'ctWebPopupPreview';
const QUALIFIED_CAMPAIGNS = 'WZRK_QC';
const CUSTOM_CT_ID_PREFIX = '_w_';
const BLOCK_REQUEST_COOKIE = 'WZRK_BLOCK'; // Flag key for optional sub-domain profile isolation

Expand Down Expand Up @@ -9350,31 +9349,6 @@
targetEl.appendChild(newScript);
script.remove();
}
function addCampaignToLocalStorage(campaign) {
var _campaign$display3;

let region = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'eu1';
let accountId = arguments.length > 2 ? arguments[2] : undefined;

/* No Need to store campaigns in local storage in preview mode */
if ((campaign === null || campaign === void 0 ? void 0 : (_campaign$display3 = campaign.display) === null || _campaign$display3 === void 0 ? void 0 : _campaign$display3.preview) === true) {
return;
}

const campaignId = campaign.wzrk_id.split('_')[0];
const dashboardUrl = "https://".concat(region, ".dashboard.clevertap.com/").concat(accountId, "/campaigns/campaign/").concat(campaignId, "/report/stats");
const enrichedCampaign = { ...campaign,
url: dashboardUrl
};
const storedData = StorageManager.readFromLSorCookie(QUALIFIED_CAMPAIGNS);
const existingCampaigns = storedData ? JSON.parse(decodeURIComponent(storedData)) : [];
const isDuplicate = existingCampaigns.some(c => c.wzrk_id === campaign.wzrk_id);

if (!isDuplicate) {
const updatedCampaigns = [...existingCampaigns, enrichedCampaign];
StorageManager.saveToLSorCookie(QUALIFIED_CAMPAIGNS, encodeURIComponent(JSON.stringify(updatedCampaigns)));
}
}

// CleverTap specific utilities
const getCampaignObject = () => {
Expand Down Expand Up @@ -13849,7 +13823,7 @@
case WVE_QUERY_PARAMS.SDK_CHECK:
if (parentWindow) {
logger.debug('SDK version check');
const sdkVersion = '2.2.2';
const sdkVersion = '2.2.3';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid hard-coded SDK version; derive from a single source of truth

The string literal '2.2.3' here will drift from other places. Introduce a single SDK_VERSION constant and reuse it for the dashboard postMessage, data.af.lib, and getSDKVersion().

Apply something like:

+// At top-level (near other constants)
+const SDK_VERSION = '2.2.3';

 // inside SDK check
-const sdkVersion = '2.2.3';
+const sdkVersion = SDK_VERSION;

And below (see other comments) derive "web-sdk-v..." from SDK_VERSION instead of embedding more literals.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const sdkVersion = '2.2.3';
const SDK_VERSION = '2.2.3';
const sdkVersion = SDK_VERSION;
🤖 Prompt for AI Agents
In clevertap.js around line 13826, replace the hard-coded string '2.2.3' with a
single SDK_VERSION constant defined near the top of the module and reuse that
constant wherever the SDK version is needed (dashboard postMessage payload,
data.af.lib assignment, and the getSDKVersion() return); also compute the
derived identifier "web-sdk-v..." by prefixing the SDK_VERSION constant instead
of embedding literals so all version uses come from the single source of truth.

parentWindow.postMessage({
message: 'SDKVersion',
accountId,
Expand Down Expand Up @@ -15786,10 +15760,6 @@
const msgArr = [];

for (let index = 0; index < msg.inbox_notifs.length; index++) {
var _CampaignContext$msg, _CampaignContext$msg$;

addCampaignToLocalStorage(msg.inbox_notifs[index], CampaignContext.region, (_CampaignContext$msg = CampaignContext.msg) === null || _CampaignContext$msg === void 0 ? void 0 : (_CampaignContext$msg$ = _CampaignContext$msg.arp) === null || _CampaignContext$msg$ === void 0 ? void 0 : _CampaignContext$msg$.id);

if (this.doCampHouseKeeping(msg.inbox_notifs[index], Logger.getInstance()) !== false) {
msgArr.push(msg.inbox_notifs[index]);
}
Expand All @@ -15808,9 +15778,6 @@
};

for (let index = 0; index < sortedCampaigns.length; index++) {
var _CampaignContext$msg2, _CampaignContext$msg3;

addCampaignToLocalStorage(sortedCampaigns[index], CampaignContext.region, (_CampaignContext$msg2 = CampaignContext.msg) === null || _CampaignContext$msg2 === void 0 ? void 0 : (_CampaignContext$msg3 = _CampaignContext$msg2.arp) === null || _CampaignContext$msg3 === void 0 ? void 0 : _CampaignContext$msg3.id);
const targetNotif = sortedCampaigns[index];

if (targetNotif.display.wtarget_type === CAMPAIGN_TYPES.FOOTER_NOTIFICATION || targetNotif.display.wtarget_type === CAMPAIGN_TYPES.FOOTER_NOTIFICATION_2) {
Expand Down Expand Up @@ -16328,7 +16295,7 @@
let proto = document.location.protocol;
proto = proto.replace(':', '');
dataObject.af = { ...dataObject.af,
lib: 'web-sdk-v2.2.2',
lib: 'web-sdk-v2.2.3',
protocol: proto,
...$ct.flutterVersion
}; // app fields
Comment on lines +16298 to 16301
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

DRY the SDK version in telemetry payload

data.af.lib repeats a versioned string. Build it from a single SDK_VERSION constant to prevent mismatches with other locations (handleActionMode and getSDKVersion).

-        lib: 'web-sdk-v2.2.3',
+        lib: `web-sdk-v${SDK_VERSION}`,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
lib: 'web-sdk-v2.2.3',
protocol: proto,
...$ct.flutterVersion
}; // app fields
lib: `web-sdk-v${SDK_VERSION}`,
protocol: proto,
...$ct.flutterVersion
}; // app fields
🤖 Prompt for AI Agents
In clevertap.js around lines 16298 to 16301, the telemetry payload sets
data.af.lib to a hardcoded 'web-sdk-v2.2.3', which duplicates the SDK version
string used elsewhere (handleActionMode and getSDKVersion); define a single
SDK_VERSION constant (e.g., const SDK_VERSION = 'web-sdk-v2.2.3') at module
scope and replace all hardcoded occurrences (including data.af.lib,
handleActionMode, and getSDKVersion) to reference that constant so the version
is maintained in one place.

Expand Down Expand Up @@ -18250,7 +18217,7 @@
}

getSDKVersion() {
return 'web-sdk-v2.2.2';
return 'web-sdk-v2.2.3';
}
Comment on lines +18220 to 18221
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Expose getSDKVersion from the same constant

Return the same version used elsewhere; avoid another hard-coded literal.

-      return 'web-sdk-v2.2.3';
+      return `web-sdk-v${SDK_VERSION}`;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return 'web-sdk-v2.2.3';
}
return `web-sdk-v${SDK_VERSION}`;
}
🤖 Prompt for AI Agents
In clevertap.js around lines 18220-18221, the function currently returns a
hard-coded 'web-sdk-v2.2.3'; instead return the existing shared SDK version
constant used elsewhere (e.g., SDK_VERSION or exported getSDKVersion constant)
to avoid duplicating literals — import or reference that constant and return it
here so the same version value is used across the codebase.


defineVariable(name, defaultValue) {
Expand Down Expand Up @@ -18299,16 +18266,6 @@
addOneTimeVariablesChangedCallback(callback) {
_classPrivateFieldLooseBase(this, _variableStore)[_variableStore].addOneTimeVariablesChangedCallback(callback);
}
/*
This function is used for debugging and getting the details of all the campaigns
that were qualified and rendered for the current user
*/


getAllQualifiedCampaignDetails() {
const existingCampaign = StorageManager.readFromLSorCookie(QUALIFIED_CAMPAIGNS) && JSON.parse(decodeURIComponent(StorageManager.readFromLSorCookie(QUALIFIED_CAMPAIGNS)));
return existingCampaign;
}

}

Expand Down
2 changes: 1 addition & 1 deletion clevertap.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions clevertap.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clevertap-web-sdk",
"version": "2.2.2",
"version": "2.2.3",
"description": "",
"main": "clevertap.js",
"scripts": {
Expand Down
10 changes: 0 additions & 10 deletions src/clevertap.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
APPLICATION_SERVER_KEY_RECEIVED,
VARIABLES,
GCOOKIE_NAME,
QUALIFIED_CAMPAIGNS,
BLOCK_REQUEST_COOKIE,
ISOLATE_COOKIE
} from './util/constants'
Expand Down Expand Up @@ -1071,13 +1070,4 @@ export default class CleverTap {
addOneTimeVariablesChangedCallback (callback) {
this.#variableStore.addOneTimeVariablesChangedCallback(callback)
}

/*
This function is used for debugging and getting the details of all the campaigns
that were qualified and rendered for the current user
*/
getAllQualifiedCampaignDetails () {
const existingCampaign = StorageManager.readFromLSorCookie(QUALIFIED_CAMPAIGNS) && JSON.parse(decodeURIComponent(StorageManager.readFromLSorCookie(QUALIFIED_CAMPAIGNS)))
return existingCampaign
}
}
5 changes: 1 addition & 4 deletions src/util/campaignHouseKeeping/commonCampaignUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ import {
mergeEventMap,
setupClickEvent,
staleDataUpdate,
webNativeDisplayCampaignUtils,
addCampaignToLocalStorage
webNativeDisplayCampaignUtils
} from '../campaignRender/utilities.js'
import { CampaignContext } from './campaignContext.js'
import _tr from '../tr.js'
Expand Down Expand Up @@ -1262,7 +1261,6 @@ export const commonCampaignUtils = {
if (msg.inbox_notifs) {
const msgArr = []
for (let index = 0; index < msg.inbox_notifs.length; index++) {
addCampaignToLocalStorage(msg.inbox_notifs[index], CampaignContext.region, CampaignContext.msg?.arp?.id)
if (this.doCampHouseKeeping(msg.inbox_notifs[index], Logger.getInstance()) !== false) {
msgArr.push(msg.inbox_notifs[index])
}
Expand All @@ -1283,7 +1281,6 @@ export const commonCampaignUtils = {
}

for (let index = 0; index < sortedCampaigns.length; index++) {
addCampaignToLocalStorage(sortedCampaigns[index], CampaignContext.region, CampaignContext.msg?.arp?.id)
const targetNotif = sortedCampaigns[index]

if (
Expand Down
31 changes: 1 addition & 30 deletions src/util/campaignRender/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
WZRK_ID,
NOTIFICATION_VIEWED,
WEB_NATIVE_TEMPLATES,
WEB_NATIVE_DISPLAY_VISUAL_EDITOR_TYPES,
QUALIFIED_CAMPAIGNS
WEB_NATIVE_DISPLAY_VISUAL_EDITOR_TYPES
} from '../constants'
import { StorageManager, $ct } from '../storage'
import RequestDispatcher from '../requestDispatcher'
Expand Down Expand Up @@ -697,31 +696,3 @@ export function addScriptTo (script, target = 'body') {
targetEl.appendChild(newScript)
script.remove()
}

export function addCampaignToLocalStorage (campaign, region = 'eu1', accountId) {
/* No Need to store campaigns in local storage in preview mode */
if (campaign?.display?.preview === true) {
return
}

const campaignId = campaign.wzrk_id.split('_')[0]
const dashboardUrl = `https://${region}.dashboard.clevertap.com/${accountId}/campaigns/campaign/${campaignId}/report/stats`

const enrichedCampaign = {
...campaign,
url: dashboardUrl
}

const storedData = StorageManager.readFromLSorCookie(QUALIFIED_CAMPAIGNS)
const existingCampaigns = storedData ? JSON.parse(decodeURIComponent(storedData)) : []

const isDuplicate = existingCampaigns.some(c => c.wzrk_id === campaign.wzrk_id)

if (!isDuplicate) {
const updatedCampaigns = [...existingCampaigns, enrichedCampaign]
StorageManager.saveToLSorCookie(
QUALIFIED_CAMPAIGNS,
encodeURIComponent(JSON.stringify(updatedCampaigns))
)
}
}
1 change: 0 additions & 1 deletion src/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const NEW_SOFT_PROMPT_SELCTOR_ID = 'pnWrapper'
export const POPUP_LOADING = 'WZRK_POPUP_LOADING'
export const CUSTOM_HTML_PREVIEW = 'ctCustomHtmlPreview'
export const WEB_POPUP_PREVIEW = 'ctWebPopupPreview'
export const QUALIFIED_CAMPAIGNS = 'WZRK_QC'
export const CUSTOM_CT_ID_PREFIX = '_w_'
export const BLOCK_REQUEST_COOKIE = 'WZRK_BLOCK'

Expand Down
Loading