@suprsend/web-sdk 0.1.23 → 0.1.24
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/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suprsend/web-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "This is sdk used to integrate suprsend functionality in javascript applications",
|
|
5
5
|
"main": "dist/cjs_bundle.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"build": "rm -rf dist && webpack --env module_type=commonjs --env filename=cjs_bundle.js && webpack --env module_type=window --env filename=cdn_bundle.js",
|
|
9
|
-
"minify-sw": "touch ./serviceworker/serviceworker.min.js && rm ./serviceworker/serviceworker.min.js && minify ./serviceworker/serviceworker.js > ./serviceworker/serviceworker.min.js",
|
|
10
9
|
"publish-sdk": "npm run build && npm publish"
|
|
11
10
|
},
|
|
12
11
|
"keywords": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function uuid(){var i=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"==t?n:3&n|8).toString(16)}))}function epoch_milliseconds(){return Math.round(Date.now())}function safe_get(i,t){var n;try{n=i()}catch(i){n=t}return n}var suprsend_config={api_url:"https://hub.suprsend.com",imgkit_root:"https://ik.imagekit.io/l0quatz6utm/",api_events_route:"event/",workspace_key:""},valid_notification_params=["title","body","icon","image","badge","vibrate","sound","dir","tag","data","requireInteraction","renotify","silent","timestamp","actions"],url_fields=["image","icon","badge"];function init_workspace(i,t){suprsend_config.workspace_key=i,t&&(suprsend_config.api_url=t)}function validate_notification(i){var t={};for(var n in i)valid_notification_params.includes(n)&&(url_fields.includes(n)?t[n]=`${suprsend_config.imgkit_root}${i[n]}`:t[n]=i[n]);return t.actions instanceof Array||delete t.actions,t}function call_ss_api(i,t="post"){var n=(new Date).toGMTString(),e=suprsend_config.workspace_key+":";return fetch(`${suprsend_config.api_url}/${suprsend_config.api_events_route}`,{method:t,body:JSON.stringify(i),headers:{"Content-Type":"application/json",Authorization:e,"x-amz-date":n}})}function send_notification_event(i,t){call_ss_api({event:i,env:suprsend_config.workspace_key,$insert_id:uuid(),$time:epoch_milliseconds(),properties:t})}self.addEventListener("push",(function(i){var t=validate_notification(i.data.json());send_notification_event("$notification_delivered",{id:safe_get((()=>t.data.notification_id))}),i.waitUntil(self.registration.showNotification(t.title||"",t))})),self.addEventListener("notificationclose",(function(i){var t=i.notification;send_notification_event("$notification_dismiss",{id:safe_get((()=>t.data.notification_id))})})),self.addEventListener("notificationclick",(function(i){i.notification.close();var t=i.notification;send_notification_event("$notification_clicked",{id:safe_get((()=>t.data.notification_id)),label_id:i.action});var n=safe_get((()=>t.data.launch_urls)),e="/";n?i.action&&n[i.action]?e=n[i.action]:n.default&&(e=n.default):e="/",clients.openWindow(e)}));
|