@suprsend/web-sdk 0.1.29 → 0.1.30

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.29",
3
+ "version": "0.1.30",
4
4
  "description": "This is sdk used to integrate suprsend functionality in javascript applications",
5
5
  "main": "dist/cjs_bundle.js",
6
6
  "scripts": {
@@ -63,7 +63,11 @@ function validate_notification(notification_obj) {
63
63
  var validated_notification_obj = {};
64
64
  for (var item in notification_obj) {
65
65
  if (valid_notification_params.includes(item)) {
66
- if (url_fields.includes(item)) {
66
+ if (
67
+ url_fields.includes(item) &&
68
+ notification_obj[item] &&
69
+ !notification_obj[item].startsWith("http")
70
+ ) {
67
71
  validated_notification_obj[
68
72
  item
69
73
  ] = `${suprsend_config.imgkit_root}${notification_obj[item]}`;
package/src/index.js CHANGED
@@ -122,7 +122,7 @@ class SuprSend {
122
122
  !utils.is_internal_event(event) &&
123
123
  utils.has_special_char(event)
124
124
  ) {
125
- console.log("Suprsend: key cannot start with $ or ss_");
125
+ console.log("SuprSend: key cannot start with $ or ss_");
126
126
  return;
127
127
  }
128
128
  const super_props = utils.get_parsed_local_store_data(
package/src/user.js CHANGED
@@ -64,7 +64,7 @@ class User {
64
64
  if (regex.email.test(email)) {
65
65
  this.append(key, email);
66
66
  } else {
67
- console.log("Suprsend: Provide valid Email ID");
67
+ console.log("SuprSend: Provide valid Email ID");
68
68
  }
69
69
  }
70
70
 
@@ -74,10 +74,10 @@ class User {
74
74
  if (mobile_number.isValid()) {
75
75
  this.append(key, mobile);
76
76
  } else {
77
- console.log("Suprsend: Provide valid Mobile number");
77
+ console.log("SuprSend: Provide valid Mobile number");
78
78
  }
79
79
  } catch (err) {
80
- console.log("Suprsend: Provide valid Mobile number");
80
+ console.log("SuprSend: Provide valid Mobile number");
81
81
  }
82
82
  }
83
83
 
@@ -129,7 +129,7 @@ class User {
129
129
  if (!utils.has_special_char(key)) {
130
130
  formatted_data = [key];
131
131
  } else {
132
- console.log("Suprsend: key cannot start with $ or ss_");
132
+ console.log("SuprSend: key cannot start with $ or ss_");
133
133
  }
134
134
  } else if (Array.isArray(key)) {
135
135
  formatted_data = [];
package/src/utils.js CHANGED
@@ -208,7 +208,7 @@ function format_props({ key, value, allow_special_tags = false }) {
208
208
  for (let item in key) {
209
209
  if (key[item] !== undefined) {
210
210
  if (!allow_special_tags && has_special_char(item)) {
211
- console.log("Suprsend: key cannot start with $ or ss_");
211
+ console.log("SuprSend: key cannot start with $ or ss_");
212
212
  continue;
213
213
  }
214
214
  formatted_data[String(item)] = key[item];
@@ -216,7 +216,7 @@ function format_props({ key, value, allow_special_tags = false }) {
216
216
  }
217
217
  } else if (value != undefined) {
218
218
  if (!allow_special_tags && has_special_char(String(key))) {
219
- console.log("Suprsend: key cannot start with $ or ss_");
219
+ console.log("SuprSend: key cannot start with $ or ss_");
220
220
  return;
221
221
  }
222
222
  formatted_data = { [String(key)]: value };
package/src/web_push.js CHANGED
@@ -21,11 +21,10 @@ class WebPush {
21
21
  return navigator.serviceWorker
22
22
  .register(`/${config.service_worker_file}`)
23
23
  .then((registration) => {
24
- console.log("Service worker successfully registered.");
25
24
  this._subscribe_push(registration);
26
25
  })
27
26
  .catch((err) => {
28
- console.error("Unable to register service worker.", err);
27
+ console.error("SuprSend: Unable to register service worker.", err);
29
28
  });
30
29
  };
31
30
 
@@ -66,7 +65,7 @@ class WebPush {
66
65
  const subscription = await this._get_subscription();
67
66
  if (!subscription) {
68
67
  if (!config.vapid_key) {
69
- console.log("Provide vapid key while calling init");
68
+ console.log("SuprSend: Provide vapid key while calling init");
70
69
  return;
71
70
  }
72
71
  const applicationServerKey = utils.urlB64ToUint8Array(config.vapid_key);
@@ -76,7 +75,7 @@ class WebPush {
76
75
  });
77
76
  this.user.add_webpush(subscription);
78
77
  } else {
79
- console.log("Push already subscribed");
78
+ // pass
80
79
  }
81
80
  }
82
81
  };
@@ -98,7 +97,7 @@ class WebPush {
98
97
  if (this._check_push_support()) {
99
98
  this._subscribe_with_delay();
100
99
  } else {
101
- console.log("OOPS, Web Push isn't supported");
100
+ console.log("SuprSend: Web Push isn't supported");
102
101
  }
103
102
  };
104
103