@suprsend/web-sdk 0.1.19 → 0.1.20

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/web-sdk",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "This is sdk used to integrate suprsend functionality in javascript applications",
5
5
  "main": "dist/cjs_bundle.js",
6
6
  "scripts": {
@@ -0,0 +1 @@
1
+ var suprsend_config={api_url:"https://collector-staging.suprsend.workers.dev",imgkit_root:"https://ik.imagekit.io/l0quatz6utm/",api_events_route:"event/"},valid_notification_params=["title","body","icon","image","badge","vibrate","sound","dir","tag","data","requireInteraction","renotify","silent","timestamp","actions"];const url_fields=["image","icon","badge"];function safe_get(i,t){let n;try{n=i()}catch(i){n=t}return n}function validate_notification(i){let 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 track_data(i,t="post"){return fetch(`${suprsend_config.api_url}/${suprsend_config.api_events_route}`,{method:t,body:JSON.stringify(i),headers:{"Content-Type":"application/json"}})}self.addEventListener("push",(function(i){const t=validate_notification(i.data.json());console.log("Received notification",t),track_data({event:"$notification_delivered",properties:{id:safe_get((()=>t.data.notification_id))}}),i.waitUntil(self.registration.showNotification(t.title||"",t))})),self.addEventListener("notificationclose",(function(i){var t=i.notification;console.log("Closed notification",t),track_data({event:"$notification_dismiss",properties:{id:safe_get((()=>t.data.notification_id))}})})),self.addEventListener("notificationclick",(function(i){i.notification.close();var t=i.notification;console.log("Clicked notification",t),track_data({event:"$notification_clicked",properties:{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)}));
package/. npmignore DELETED
@@ -1,3 +0,0 @@
1
- /node_modules
2
- /src
3
- /serviceworker/serviceworker.js
@@ -1,3 +0,0 @@
1
- {
2
- "editor.formatOnSave": true
3
- }