@bigbeakads/smartads-sdk-js 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -51,7 +51,7 @@ Creates a SmartAds SDK instance.
51
51
  | --------------------- | -------- | -------- | ----------------------------- |
52
52
  | `options.accessToken` | `string` | **Yes** | Your application access token |
53
53
 
54
- ### `smartAds.report(options)`
54
+ ### `smartAds.report(options, callback?)`
55
55
 
56
56
  Reports an event to the SmartAds server. Returns a `Promise<Response>`. Supports both Promise and callback patterns.
57
57
 
@@ -59,11 +59,18 @@ Reports an event to the SmartAds server. Returns a `Promise<Response>`. Supports
59
59
 
60
60
  #### Parameters
61
61
 
62
- | Parameter | Type | Required | Default | Description |
63
- | ----------- | -------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
- | `smartId` | `string` | **Yes** | — | Smart ID, obtained from URL parameters |
65
- | `eventName` | `EventName` | **Yes** | — | The event name to report. Supported values: `EVENT_ADD_TO_CART`, `EVENT_PURCHASE`, `EVENT_CONTENT_VIEW`, `EVENT_COMPLETE_REGISTRATION`, `EVENT_FIRST_DEPOSIT`, `EVENT_INITIATE_CHECKOUT` |
66
- | `callback` | `(response) => void` | No | — | Response callback |
62
+ | Parameter | Type | Required | Default | Description |
63
+ | ----------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
+ | `smartId` | `string` | **Yes** | — | Smart ID, obtained from URL parameters |
65
+ | `eventName` | `EventName`| **Yes** | — | The event name to report. Supported values: `EVENT_ADD_TO_CART`, `EVENT_PURCHASE`, `EVENT_CONTENT_VIEW`, `EVENT_COMPLETE_REGISTRATION`, `EVENT_FIRST_DEPOSIT`, `EVENT_INITIATE_CHECKOUT` |
66
+ | `currency` | `string` | No | — | Currency code, e.g. `USD` |
67
+ | `value` | `number` | No | — | Value amount, e.g. `2.99` |
68
+
69
+ #### Callback (Second Parameter)
70
+
71
+ | Parameter | Type | Required | Description |
72
+ | ---------- | -------------------- | -------- | ---------------- |
73
+ | `callback` | `(response) => void` | No | Response callback |
67
74
 
68
75
  #### Promise Usage
69
76
 
@@ -80,11 +87,13 @@ console.log('Response:', response);
80
87
 
81
88
  ```js
82
89
  const smartId = new URL(window.location.href).searchParams.get('smartId');
83
- smartAds.report({
84
- smartId: smartId,
85
- eventName: 'EVENT_PURCHASE',
86
- callback: (response) => {
90
+ smartAds.report(
91
+ {
92
+ smartId: smartId,
93
+ eventName: 'EVENT_PURCHASE',
94
+ },
95
+ (response) => {
87
96
  console.log('Response:', response);
88
97
  },
89
- });
98
+ );
90
99
  ```
@@ -8,12 +8,13 @@ interface ReportCallback {
8
8
  interface ReportOptions {
9
9
  smartId: string;
10
10
  eventName: EventName;
11
- callback?: ReportCallback;
11
+ currency?: string;
12
+ value?: number;
12
13
  }
13
14
  declare class SmartAds {
14
15
  private accessToken;
15
16
  constructor(options: SmartAdsOptions);
16
- report(options: ReportOptions): Promise<Response>;
17
+ report(options: ReportOptions, callback?: ReportCallback): Promise<Response>;
17
18
  }
18
19
  export { SmartAds, type EventName };
19
20
  export default SmartAds;
package/dist/esm/index.js CHANGED
@@ -21,12 +21,12 @@ var SmartAds = /*#__PURE__*/function () {
21
21
  _createClass(SmartAds, [{
22
22
  key: "report",
23
23
  value: function () {
24
- var _report = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
25
- var smartId, eventName, callback, payload, response, json;
24
+ var _report = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, callback) {
25
+ var smartId, eventName, currency, value, payload, _response, json, err;
26
26
  return _regeneratorRuntime().wrap(function _callee$(_context) {
27
27
  while (1) switch (_context.prev = _context.next) {
28
28
  case 0:
29
- smartId = options.smartId, eventName = options.eventName, callback = options.callback;
29
+ smartId = options.smartId, eventName = options.eventName, currency = options.currency, value = options.value;
30
30
  if (smartId) {
31
31
  _context.next = 3;
32
32
  break;
@@ -42,9 +42,12 @@ var SmartAds = /*#__PURE__*/function () {
42
42
  payload = {
43
43
  access_token: this.accessToken,
44
44
  smartId: smartId,
45
- event_name: eventName
45
+ event_name: eventName,
46
+ currency: currency,
47
+ value: value
46
48
  };
47
- _context.next = 8;
49
+ _context.prev = 6;
50
+ _context.next = 9;
48
51
  return fetch(POSTBACK_URL, {
49
52
  method: 'POST',
50
53
  headers: {
@@ -52,21 +55,27 @@ var SmartAds = /*#__PURE__*/function () {
52
55
  },
53
56
  body: JSON.stringify(payload)
54
57
  });
55
- case 8:
56
- response = _context.sent;
57
- _context.next = 11;
58
- return response.json();
59
- case 11:
58
+ case 9:
59
+ _response = _context.sent;
60
+ _context.next = 12;
61
+ return _response.json();
62
+ case 12:
60
63
  json = _context.sent;
61
64
  callback === null || callback === void 0 || callback(json);
62
65
  return _context.abrupt("return", json);
63
- case 14:
66
+ case 17:
67
+ _context.prev = 17;
68
+ _context.t0 = _context["catch"](6);
69
+ err = _context.t0 instanceof Error ? _context.t0 : new Error(String(_context.t0));
70
+ callback === null || callback === void 0 || callback(null, err);
71
+ throw err;
72
+ case 22:
64
73
  case "end":
65
74
  return _context.stop();
66
75
  }
67
- }, _callee, this);
76
+ }, _callee, this, [[6, 17]]);
68
77
  }));
69
- function report(_x) {
78
+ function report(_x, _x2) {
70
79
  return _report.apply(this, arguments);
71
80
  }
72
81
  return report;
@@ -1 +1 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(function(){return function(){var t={935:function(t){function e(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports},76:function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},81:function(t,e,r){var n=r(355);function o(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,n(o.key),o)}}t.exports=function(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},951:function(t,e,r){var n=r(355);t.exports=function(t,e,r){return(e=n(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.__esModule=!0,t.exports.default=t.exports},958:function(t,e,r){var n=r(705).default;function o(){"use strict";t.exports=o=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},i=Object.prototype,a=i.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},s=c.iterator||"@@iterator",f=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(e){p=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,i=Object.create(o.prototype),a=new N(n||[]);return u(i,"_invoke",{value:S(t,r,a)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var y="suspendedStart",v="executing",m="completed",x={};function g(){}function b(){}function w(){}var _={};p(_,s,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(G([])));L&&L!==i&&a.call(L,s)&&(_=L);var j=w.prototype=g.prototype=Object.create(_);function O(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,i,u,c){var s=d(t[o],t,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==n(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,u,c)}),(function(t){r("throw",t,u,c)})):e.resolve(l).then((function(t){f.value=t,u(f)}),(function(t){return r("throw",t,u,c)}))}c(s.arg)}var o;u(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function S(t,r,n){var o=y;return function(i,a){if(o===v)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=P(u,n);if(c){if(c===x)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=d(t,r,n);if("normal"===s.type){if(o=n.done?m:"suspendedYield",s.arg===x)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function P(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),x;var i=d(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,x;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,x):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,x)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function G(t){if(t||""===t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(a.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(n(t)+" is not iterable")}return b.prototype=w,u(j,"constructor",{value:w,configurable:!0}),u(w,"constructor",{value:b,configurable:!0}),b.displayName=p(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,p(t,l,"GeneratorFunction")),t.prototype=Object.create(j),t},r.awrap=function(t){return{__await:t}},O(k.prototype),p(k.prototype,f,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),p(j,l,"Generator"),p(j,s,(function(){return this})),p(j,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=G,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!t)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return u.type="throw",u.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),s=a.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,x):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),x},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),x}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;M(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:G(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),x}},r}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},388:function(t,e,r){var n=r(705).default;t.exports=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},355:function(t,e,r){var n=r(705).default,o=r(388);t.exports=function(t){var e=o(t,"string");return"symbol"==n(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},705:function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return function(){"use strict";r.r(n),r.d(n,{SmartAds:function(){return p}});var t=r(958),e=r.n(t),o=r(935),i=r.n(o),a=r(76),u=r.n(a),c=r(81),s=r.n(c),f=r(951),l=r.n(f),p=function(){function t(e){if(u()(this,t),l()(this,"accessToken",void 0),!e.accessToken)throw new Error("accessToken is required");this.accessToken=e.accessToken}var r;return s()(t,[{key:"report",value:(r=i()(e()().mark((function t(r){var n,o,i,a,u,c;return e()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.smartId,o=r.eventName,i=r.callback,n){t.next=3;break}throw new Error("smartId is required");case 3:if(o){t.next=5;break}throw new Error("eventName is required");case 5:return a={access_token:this.accessToken,smartId:n,event_name:o},t.next=8,fetch("https://agent.ads-server-k.com/smartads/api/v1/postback/smart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});case 8:return u=t.sent,t.next=11,u.json();case 11:return c=t.sent,null==i||i(c),t.abrupt("return",c);case 14:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})}]),t}();n.default=p}(),n}()}));
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(function(){return function(){var t={935:function(t){function e(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports},76:function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},81:function(t,e,r){var n=r(355);function o(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,n(o.key),o)}}t.exports=function(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},951:function(t,e,r){var n=r(355);t.exports=function(t,e,r){return(e=n(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.__esModule=!0,t.exports.default=t.exports},958:function(t,e,r){var n=r(705).default;function o(){"use strict";t.exports=o=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},i=Object.prototype,a=i.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},s=c.iterator||"@@iterator",f=c.asyncIterator||"@@asyncIterator",l=c.toStringTag||"@@toStringTag";function p(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{p({},"")}catch(e){p=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,i=Object.create(o.prototype),a=new N(n||[]);return u(i,"_invoke",{value:k(t,r,a)}),i}function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var d="suspendedStart",v="executing",m="completed",x={};function g(){}function b(){}function w(){}var _={};p(_,s,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(G([])));L&&L!==i&&a.call(L,s)&&(_=L);var j=w.prototype=g.prototype=Object.create(_);function O(t){["next","throw","return"].forEach((function(e){p(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(o,i,u,c){var s=y(t[o],t,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==n(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,u,c)}),(function(t){r("throw",t,u,c)})):e.resolve(l).then((function(t){f.value=t,u(f)}),(function(t){return r("throw",t,u,c)}))}c(s.arg)}var o;u(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function k(t,r,n){var o=d;return function(i,a){if(o===v)throw new Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=P(u,n);if(c){if(c===x)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=y(t,r,n);if("normal"===s.type){if(o=n.done?m:"suspendedYield",s.arg===x)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function P(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),x;var i=y(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,x;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,x):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,x)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function G(t){if(t||""===t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(a.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(n(t)+" is not iterable")}return b.prototype=w,u(j,"constructor",{value:w,configurable:!0}),u(w,"constructor",{value:b,configurable:!0}),b.displayName=p(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,p(t,l,"GeneratorFunction")),t.prototype=Object.create(j),t},r.awrap=function(t){return{__await:t}},O(S.prototype),p(S.prototype,f,(function(){return this})),r.AsyncIterator=S,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new S(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),p(j,l,"Generator"),p(j,s,(function(){return this})),p(j,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=G,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!t)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return u.type="throw",u.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=a.call(i,"catchLoc"),s=a.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,x):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),x},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),x}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;M(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:G(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),x}},r}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},388:function(t,e,r){var n=r(705).default;t.exports=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},355:function(t,e,r){var n=r(705).default,o=r(388);t.exports=function(t){var e=o(t,"string");return"symbol"==n(e)?e:String(e)},t.exports.__esModule=!0,t.exports.default=t.exports},705:function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return function(){"use strict";r.r(n),r.d(n,{SmartAds:function(){return p}});var t=r(958),e=r.n(t),o=r(935),i=r.n(o),a=r(76),u=r.n(a),c=r(81),s=r.n(c),f=r(951),l=r.n(f),p=function(){function t(e){if(u()(this,t),l()(this,"accessToken",void 0),!e.accessToken)throw new Error("accessToken is required");this.accessToken=e.accessToken}var r;return s()(t,[{key:"report",value:(r=i()(e()().mark((function t(r,n){var o,i,a,u,c,s,f,l;return e()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=r.smartId,i=r.eventName,a=r.currency,u=r.value,o){t.next=3;break}throw new Error("smartId is required");case 3:if(i){t.next=5;break}throw new Error("eventName is required");case 5:return c={access_token:this.accessToken,smartId:o,event_name:i,currency:a,value:u},t.prev=6,t.next=9,fetch("https://agent.ads-server-k.com/smartads/api/v1/postback/smart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});case 9:return s=t.sent,t.next=12,s.json();case 12:return f=t.sent,null==n||n(f),t.abrupt("return",f);case 17:throw t.prev=17,t.t0=t.catch(6),l=t.t0 instanceof Error?t.t0:new Error(String(t.t0)),null==n||n(null,l),l;case 22:case"end":return t.stop()}}),t,this,[[6,17]])}))),function(t,e){return r.apply(this,arguments)})}]),t}();n.default=p}(),n}()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbeakads/smartads-sdk-js",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "BigBeak Smart Ads SDK for JavaScript",
5
5
  "module": "dist/esm/index.js",
6
6
  "main": "dist/umd/smartads-sdk-js.min.js",