Skip to content

Commit 4d1801b

Browse files
sakshamg1304rohitesh-wingify
authored andcommitted
fix: track and setAttrute issue
1 parent c112daf commit 4d1801b

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.21.1] - 2025-02-20
9+
10+
### Fixed
11+
12+
- Fixed trackEvent, setAttribute methods where usageStatsAccountId was used for network call.
13+
814
## [1.21.0] - 2025-02-18
915

1016
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vwo/vwo-fme-php-sdk",
33

4-
"version": "1.21.0",
4+
"version": "1.21.1",
55
"keywords": ["vwo", "fme", "sdk"],
66
"license": "Apache-2.0",
77
"authors": [{

src/Api/SetAttribute.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ private function createImpressionForAttributes(SettingsModel $settings, array $a
6565
$properties = $networkUtil->getEventsBaseProperties(
6666
EventEnum::VWO_SYNC_VISITOR_PROP,
6767
$context->getUserAgent(),
68-
$context->getIpAddress(),
69-
$context->getSessionId()
68+
$context->getIpAddress()
7069
);
7170

7271
// Construct payload data for multiple attributes

src/Api/TrackEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ private function createImpressionForTrack(SettingsModel $settings, string $event
9595
$networkUtil = new NetworkUtil($serviceContainer);
9696

9797
// Get base properties for the event
98-
$properties = $networkUtil->getEventsBaseProperties($eventName, $context->getUserAgent(), $context->getIpAddress(), $context->getSessionId());
98+
$properties = $networkUtil->getEventsBaseProperties($eventName, $context->getUserAgent(), $context->getIpAddress());
9999

100100
// Prepare the payload for the track goal
101101
$payload = $networkUtil->getTrackGoalPayloadData(
102102
$settings,
103103
$context,
104104
$eventName,
105-
$eventProperties,
105+
$eventProperties
106106
);
107107

108108
// Send the prepared payload via POST API request

src/Constants/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Constants {
4040
const DEFAULT_EVENTS_PER_REQUEST = 100;
4141
const SDK_NAME = 'vwo-fme-php-sdk';
4242

43-
const SDK_VERSION = '1.21.0';
43+
const SDK_VERSION = '1.21.1';
4444
const AP = 'server';
4545

4646
const SETTINGS = 'settings';

src/Utils/ImpressionUtil.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public static function SendImpressionForVariationShown(
6161
$properties = $networkUtil->getEventsBaseProperties(
6262
EventEnum::VWO_VARIATION_SHOWN,
6363
urlencode($context->getUserAgent()), // Encode user agent to ensure URL safety
64-
$context->getIpAddress(),
65-
$context->getIpAddress(),
66-
$context->getSessionId()
64+
$context->getIpAddress()
6765
);
6866

6967
$campaignKeyWithFeatureName = CampaignUtil::getCampaignKeyFromCampaignId($settings, $payload['d']['event']['props']['id']);

src/VWOClient.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,7 @@ public function setAttribute($attributesOrAttributeValue = null, $attributeValue
214214
try {
215215
$loggerService = $this->serviceContainer->getLoggerService();
216216
$loggerService->debug("API Called: $apiName");
217-
// Ensure context is valid
218-
if (!isset($context['id']) || empty($context['id'])) {
219-
$loggerService->error('INVALID_CONTEXT_PASSED', ['an' => ApiEnum::SET_ATTRIBUTE, 'apiName' => $apiName], false);
220-
throw new \Error('TypeError: Invalid context');
221-
}
222-
// set uuid in context
223-
$context['uuid'] = $this->getUUIDFromContext($context, $apiName);
224-
217+
225218
if (DataTypeUtil::isString($attributesOrAttributeValue)) {
226219
// Validate attributeKey is a string
227220
if (!DataTypeUtil::isString($attributesOrAttributeValue)) {
@@ -235,6 +228,11 @@ public function setAttribute($attributesOrAttributeValue = null, $attributeValue
235228
!DataTypeUtil::isBoolean($attributeValueOrContext)) {
236229
$loggerService->error("INVALID_PARAM", ['key' => $attributeValueOrContext, 'an'=> ApiEnum::SET_ATTRIBUTE, 'apiName' => $apiName, 'type' => gettype($attributeValueOrContext), 'correctType' => 'string'], false);
237230
throw new \TypeError('TypeError: attributeValue should be a valid string, number, or boolean');
231+
}
232+
// Ensure context is valid
233+
if (!isset($context['id']) || empty($context['id'])) {
234+
$loggerService->error('INVALID_CONTEXT_PASSED', ['an' => ApiEnum::SET_ATTRIBUTE, 'apiName' => $apiName], false);
235+
throw new \Error('TypeError: Invalid context');
238236
}
239237

240238
//Get userId using UserIdUtil if aliasing is enabled and gateway service is provided
@@ -247,6 +245,8 @@ public function setAttribute($attributesOrAttributeValue = null, $attributeValue
247245
}
248246
}
249247
$context['id'] = $userId;
248+
// set uuid in context
249+
$context['uuid'] = $this->getUUIDFromContext($context, $apiName);
250250

251251
$contextModel = new ContextModel();
252252
$contextModel->modelFromDictionary($context);
@@ -300,6 +300,8 @@ public function setAttribute($attributesOrAttributeValue = null, $attributeValue
300300
}
301301
}
302302
$context['id'] = $userId;
303+
// set uuid in context
304+
$context['uuid'] = $this->getUUIDFromContext($context, $apiName);
303305

304306
$contextModel = new ContextModel();
305307
$contextModel->modelFromDictionary($context);

0 commit comments

Comments
 (0)