TP-70213 | Bundle Version Addition in Clickstream Events (#11439)

This commit is contained in:
Mayank Singh
2024-06-18 17:24:08 +05:30
committed by GitHub
parent a416dd6ac7
commit c6736d8a67
4 changed files with 17 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ export const EVENT_NAMES = {
export const EVENT_PROPERTY_KEYS = {
STATUS: "status",
BUNDLE_VERSION: "bundleVersion",
};
export const EVENT_PROPERTY_VALUES = {

View File

@@ -1,3 +1,5 @@
import { getBundleVersion } from "../../../network/NetworkUtils";
import { EVENT_PROPERTY_KEYS } from "../constants";
import { AnalyticsEvent } from "../interface";
import { NativeAnalyticsModule } from "../native-module/NativeModules";
@@ -10,10 +12,14 @@ export const useAnalyticsEvent = () => {
};
export const sendAsAnalyticsEvent = (analyticsEvent: AnalyticsEvent) => {
const eventName = analyticsEvent.name;
const propertiesWithBundleVersion = {
...analyticsEvent.properties,
[EVENT_PROPERTY_KEYS.BUNDLE_VERSION]: getBundleVersion().toString(),
};
NativeAnalyticsModule.sendAsAnalyticsEvent(
eventName,
analyticsEvent.properties,
analyticsEvent.name,
propertiesWithBundleVersion,
);
};

View File

@@ -15,9 +15,13 @@ const getDeviceId = async () => {
return await getStringPreference("DEVICE_ID", "string");
};
export const getBundleVersion = () => {
return packageJson.versionCode;
};
const addBundleVersionToHeader = (axiosInstance: AxiosInstance) => {
axiosInstance.interceptors.request.use(requestConfig => {
requestConfig.headers[BUNDLE_VERSION] = (packageJson as any).versionCode;
requestConfig.headers[BUNDLE_VERSION] = getBundleVersion();
return requestConfig;
});
};

View File

@@ -1,7 +1,7 @@
{
"name": "NaviApp",
"version": "0.2.1",
"versionCode": 6,
"version": "0.2.2",
"versionCode": 7,
"private": true,
"scripts": {
"start": "yarn react-native start",