notifly-sdk 1.0.0 → 1.0.1
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 +14 -12
- package/package.json +5 -2
package/index.js
CHANGED
|
@@ -31,14 +31,14 @@ exports.sessionStart = async function () {
|
|
|
31
31
|
"api_level": deviceInfo[2],
|
|
32
32
|
},
|
|
33
33
|
}
|
|
34
|
-
await logEvent("session_start", openAppEventParams, true)
|
|
34
|
+
await logEvent("session_start", openAppEventParams, null, true)
|
|
35
35
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
exports.initialize = async function (prjId, userName, password) {
|
|
39
39
|
try {
|
|
40
40
|
messaging().onNotificationOpenedApp(async (remoteMessage) => {
|
|
41
|
-
await logEvent("push_click", { "campaign_id": remoteMessage.data.campaign_id, "status": "background" }, true);
|
|
41
|
+
await logEvent("push_click", { "campaign_id": remoteMessage.data.campaign_id, "status": "background" }, null, true);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
messaging().getToken()
|
|
@@ -51,14 +51,14 @@ exports.initialize = async function (prjId, userName, password) {
|
|
|
51
51
|
if (link) {
|
|
52
52
|
Linking.openURL(remoteMessage.notification?.android?.link);
|
|
53
53
|
}
|
|
54
|
-
await logEvent("push_click", { "campaign_id": remoteMessage.data.campaign_id, "status": "quit" }, true);
|
|
55
|
-
await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "quit" }, true);
|
|
54
|
+
await logEvent("push_click", { "campaign_id": remoteMessage.data.campaign_id, "status": "quit" }, null, true);
|
|
55
|
+
await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "quit" }, null, true);
|
|
56
56
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
|
|
61
|
-
await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "background" }, true);
|
|
61
|
+
await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "background" }, null, true);
|
|
62
62
|
return
|
|
63
63
|
})
|
|
64
64
|
|
|
@@ -85,7 +85,7 @@ exports.initialize = async function (prjId, userName, password) {
|
|
|
85
85
|
switch (type) {
|
|
86
86
|
case 3:
|
|
87
87
|
try {
|
|
88
|
-
await logEvent("push_delivered", { "campaign_id": campaign_id, "status": "background-notifee" }, true);
|
|
88
|
+
await logEvent("push_delivered", { "campaign_id": campaign_id, "status": "background-notifee" }, null, true);
|
|
89
89
|
} catch (err) {
|
|
90
90
|
console.error('[Notifly]: ', err);
|
|
91
91
|
}
|
|
@@ -107,7 +107,7 @@ exports.foregroundSetting = function () {
|
|
|
107
107
|
channelId: "foreground",
|
|
108
108
|
},
|
|
109
109
|
});
|
|
110
|
-
await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "foreground" }, true);
|
|
110
|
+
await logEvent("push_delivered", { "campaign_id": remoteMessage.data.campaign_id, "status": "foreground" }, null, true);
|
|
111
111
|
});
|
|
112
112
|
notifee.onForegroundEvent(async ({ type, detail }) => {
|
|
113
113
|
const { notification } = detail;
|
|
@@ -119,9 +119,9 @@ exports.foregroundSetting = function () {
|
|
|
119
119
|
try {
|
|
120
120
|
if (notification.data.link) {
|
|
121
121
|
Linking.openURL(notification.data.link)
|
|
122
|
-
await logEvent("push_click", { "campaign_id": campaign_id, "status": "foreground" }, true);
|
|
122
|
+
await logEvent("push_click", { "campaign_id": campaign_id, "status": "foreground" }, null, true);
|
|
123
123
|
} else {
|
|
124
|
-
await logEvent("push_click", { "campaign_id": campaign_id, "status": "foreground" }, true);
|
|
124
|
+
await logEvent("push_click", { "campaign_id": campaign_id, "status": "foreground" }, null, true);
|
|
125
125
|
}
|
|
126
126
|
} catch (err) {
|
|
127
127
|
console.error('[Notifly]: ', err);
|
|
@@ -172,15 +172,16 @@ async function _getNotiflyUserId() {
|
|
|
172
172
|
|
|
173
173
|
async function _setUserProperties(params) {
|
|
174
174
|
if (params.external_user_id) {
|
|
175
|
+
params['previous_notifly_user_id'] = await _getNotiflyUserId();
|
|
175
176
|
await Promise.all([
|
|
176
177
|
AsyncStorage.setItem('notiflyExternalUserId', params.external_user_id),
|
|
177
178
|
AsyncStorage.removeItem('notiflyUserId'),
|
|
178
179
|
]);
|
|
179
180
|
}
|
|
180
|
-
return await logEvent("set_user_properties", params, true);
|
|
181
|
+
return (await logEvent("set_user_properties", params, null, true));
|
|
181
182
|
}
|
|
182
183
|
|
|
183
|
-
async function logEvent(eventName, eventParams, isInternalEvent = false) {
|
|
184
|
+
async function logEvent(eventName, eventParams, segmentation_event_param_keys = null, isInternalEvent = false) {
|
|
184
185
|
try {
|
|
185
186
|
let token;
|
|
186
187
|
const [savedCognitoToken, notiflyUserId, externalUserId, prjId, externalDeviceId, osVersion, appVersion] = await Promise.all([
|
|
@@ -225,6 +226,7 @@ async function logEvent(eventName, eventParams, isInternalEvent = false) {
|
|
|
225
226
|
"external_device_id": externalDeviceId,
|
|
226
227
|
"device_token": deviceToken,
|
|
227
228
|
"is_internal_event": isInternalEvent,
|
|
229
|
+
"segmentation_event_param_keys": segmentation_event_param_keys,
|
|
228
230
|
"project_id": prjId,
|
|
229
231
|
"platform": Platform.OS,
|
|
230
232
|
"os_version": osVersion,
|
|
@@ -261,7 +263,7 @@ async function logEvent(eventName, eventParams, isInternalEvent = false) {
|
|
|
261
263
|
const [userName, password] = await Promise.all([AsyncStorage.getItem('notiflyUserName'), AsyncStorage.getItem('notiflyUserPassword')])
|
|
262
264
|
const newToken = await getCognitoIdToken(userName, password);
|
|
263
265
|
await AsyncStorage.setItem("notiflyCognitoIdToken", newToken);
|
|
264
|
-
await logEvent(eventName, eventParams)
|
|
266
|
+
await logEvent(eventName, eventParams, segmentation_event_param_keys, isInternalEvent)
|
|
265
267
|
}
|
|
266
268
|
|
|
267
269
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notifly-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,5 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"author": "daeseongKim",
|
|
18
18
|
"license": "ISC",
|
|
19
|
-
"type": "module"
|
|
19
|
+
"type": "module",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"notifly-sdk": "^1.0.0"
|
|
22
|
+
}
|
|
20
23
|
}
|