notifly-sdk 2.1.0 → 2.1.2

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/index.js CHANGED
@@ -4,7 +4,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
4
4
  import messaging from '@react-native-firebase/messaging';
5
5
  import logEvent from './src/log_event';
6
6
  import { setUserProperties, removeUserId } from './src/user';
7
- import { clickHandler, getSDKVersion, sessionStart } from './src/utils';
7
+ import { clickHandler, sessionStart } from './src/utils';
8
8
  import { showInAppMessage } from './src/in_app_message';
9
9
 
10
10
  exports.trackEvent = logEvent;
@@ -51,7 +51,7 @@ exports.setUserId = async function (userID) {
51
51
  */
52
52
  exports.initialize = async function (prjId, userName, password, useCustomClickHandler = false) {
53
53
  try {
54
- const [, sdkVersion] = await Promise.all([messaging().requestPermission(), getSDKVersion()]);
54
+ await messaging().requestPermission();
55
55
 
56
56
  // in-app-message
57
57
  const openedInAppWebViewCount = { count: 0 };
@@ -77,7 +77,6 @@ exports.initialize = async function (prjId, userName, password, useCustomClickHa
77
77
  AsyncStorage.setItem('notiflyProjectId', prjId),
78
78
  AsyncStorage.setItem('notiflyUserName', userName),
79
79
  AsyncStorage.setItem('notiflyUserPassword', password),
80
- AsyncStorage.setItem('notiflySDKVersion', sdkVersion),
81
80
  ]);
82
81
  await sessionStart();
83
82
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notifly-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/constant.js CHANGED
@@ -1,3 +1,5 @@
1
+ export const SDK_VERSION = '2.1.1';
2
+
1
3
  export const NAMESPACE = {
2
4
  'EVENTID': '830b5f7b-e392-43db-a17b-d835f0bcab2b',
3
5
  'REGISTERED_USERID': 'ce7c62f9-e8ae-4009-8fd6-468e9581fa21',
@@ -101,7 +101,7 @@ export async function showInAppMessage(data, openedInAppWebViewCount) {
101
101
  openedInAppWebViewCount.count = openedInAppWebViewCount.count + 1;
102
102
  logEvent(
103
103
  'in_app_message_show',
104
- { type: 'message_event', channel: 'in-app-message', campaign: data.campaign_id },
104
+ { type: 'message_event', channel: 'in-app-message', campaign_id: data.campaign_id },
105
105
  null,
106
106
  true
107
107
  ); // logging in app messaging delivered
package/src/log_event.js CHANGED
@@ -3,7 +3,7 @@ import rnDeviceInfo from 'react-native-device-info';
3
3
  import AsyncStorage from '@react-native-async-storage/async-storage';
4
4
  import messaging from '@react-native-firebase/messaging';
5
5
  import { v5 as uuidv5 } from 'uuid';
6
- import { NAMESPACE } from './constant';
6
+ import { NAMESPACE, SDK_VERSION } from './constant';
7
7
  import { getNotiflyUserId } from './utils';
8
8
  import { getCognitoIdToken } from './auth';
9
9
 
@@ -43,7 +43,6 @@ export default async function logEvent(
43
43
  osVersion,
44
44
  appVersion,
45
45
  deviceToken,
46
- sdkVersion,
47
46
  ] = await Promise.all([
48
47
  AsyncStorage.getItem('notiflyCognitoIdToken'),
49
48
  getNotiflyUserId(),
@@ -53,7 +52,6 @@ export default async function logEvent(
53
52
  rnDeviceInfo.getSystemVersion(),
54
53
  rnDeviceInfo.getVersion(),
55
54
  messaging().getToken(),
56
- AsyncStorage.getItem('notiflySdkVersion'),
57
55
  ]);
58
56
 
59
57
  const eventId = uuidv5(`${notiflyUserId}${eventName}${new Date().valueOf()}`, NAMESPACE.EVENTID).replace(
@@ -98,7 +96,6 @@ export default async function logEvent(
98
96
  prjId,
99
97
  osVersion,
100
98
  appVersion,
101
- sdkVersion,
102
99
  externalUserId,
103
100
  eventParams
104
101
  );
@@ -153,7 +150,6 @@ function _getBodyForLogEvent(
153
150
  prjId,
154
151
  osVersion,
155
152
  appVersion,
156
- sdkVersion,
157
153
  externalUserId,
158
154
  eventParams
159
155
  ) {
@@ -172,7 +168,7 @@ function _getBodyForLogEvent(
172
168
  platform: Platform.OS,
173
169
  os_version: osVersion,
174
170
  app_version: appVersion,
175
- sdk_version: sdkVersion,
171
+ sdk_version: SDK_VERSION,
176
172
  external_user_id: externalUserId || undefined,
177
173
  });
178
174
 
package/src/utils.js CHANGED
@@ -112,19 +112,3 @@ export async function clickHandler(remoteMessage) {
112
112
  console.warn('[Notifly] custom click handler registration failed.');
113
113
  }
114
114
  }
115
-
116
- /**
117
- * Asynchronously retrieves the SDK version from the package.json file.
118
- * @async
119
- * @function getSDKVersion
120
- * @returns {Promise<string|null>} A promise that resolves to the SDK version (string) if successful, or null in case of error.
121
- */
122
- export async function getSDKVersion() {
123
- try {
124
- const packageJson = await import('../package.json', { assert: { type: 'json' } });
125
- return packageJson?.default?.version;
126
- } catch (error) {
127
- console.error('Error loading package.json:', error);
128
- return null;
129
- }
130
- }