@solution-center/tracking 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.
@@ -0,0 +1,205 @@
1
+ /*!
2
+ * Name: @solution-center/tracking
3
+ * Version: 2.1.0
4
+ * Homepage: https://github.bus.zalan.do/norris/solution-center-tracking
5
+ * License: MIT
6
+ * @preserve
7
+ */
8
+ /******/ (function(modules) { // webpackBootstrap
9
+ /******/ // The module cache
10
+ /******/ var installedModules = {};
11
+ /******/
12
+ /******/ // The require function
13
+ /******/ function __webpack_require__(moduleId) {
14
+ /******/
15
+ /******/ // Check if module is in cache
16
+ /******/ if(installedModules[moduleId]) {
17
+ /******/ return installedModules[moduleId].exports;
18
+ /******/ }
19
+ /******/ // Create a new module (and put it into the cache)
20
+ /******/ var module = installedModules[moduleId] = {
21
+ /******/ i: moduleId,
22
+ /******/ l: false,
23
+ /******/ exports: {}
24
+ /******/ };
25
+ /******/
26
+ /******/ // Execute the module function
27
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
28
+ /******/
29
+ /******/ // Flag the module as loaded
30
+ /******/ module.l = true;
31
+ /******/
32
+ /******/ // Return the exports of the module
33
+ /******/ return module.exports;
34
+ /******/ }
35
+ /******/
36
+ /******/
37
+ /******/ // expose the modules object (__webpack_modules__)
38
+ /******/ __webpack_require__.m = modules;
39
+ /******/
40
+ /******/ // expose the module cache
41
+ /******/ __webpack_require__.c = installedModules;
42
+ /******/
43
+ /******/ // define getter function for harmony exports
44
+ /******/ __webpack_require__.d = function(exports, name, getter) {
45
+ /******/ if(!__webpack_require__.o(exports, name)) {
46
+ /******/ Object.defineProperty(exports, name, {
47
+ /******/ configurable: false,
48
+ /******/ enumerable: true,
49
+ /******/ get: getter
50
+ /******/ });
51
+ /******/ }
52
+ /******/ };
53
+ /******/
54
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
55
+ /******/ __webpack_require__.n = function(module) {
56
+ /******/ var getter = module && module.__esModule ?
57
+ /******/ function getDefault() { return module['default']; } :
58
+ /******/ function getModuleExports() { return module; };
59
+ /******/ __webpack_require__.d(getter, 'a', getter);
60
+ /******/ return getter;
61
+ /******/ };
62
+ /******/
63
+ /******/ // Object.prototype.hasOwnProperty.call
64
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
65
+ /******/
66
+ /******/ // __webpack_public_path__
67
+ /******/ __webpack_require__.p = "";
68
+ /******/
69
+ /******/ // Load entry module and return exports
70
+ /******/ return __webpack_require__(__webpack_require__.s = 0);
71
+ /******/ })
72
+ /************************************************************************/
73
+ /******/ ([
74
+ /* 0 */
75
+ /***/ (function(module, exports, __webpack_require__) {
76
+
77
+ "use strict";
78
+
79
+ Object.defineProperty(exports, "__esModule", { value: true });
80
+ var angular = __webpack_require__(1);
81
+ var tracking_service_1 = __webpack_require__(2);
82
+ var module = angular.module('solutioncenter.tracking', ['solutioncenter.communicator'])
83
+ .service('ScTrackingService', tracking_service_1.default);
84
+ exports.default = module;
85
+
86
+
87
+ /***/ }),
88
+ /* 1 */
89
+ /***/ (function(module, exports) {
90
+
91
+ module.exports = angular;
92
+
93
+ /***/ }),
94
+ /* 2 */
95
+ /***/ (function(module, exports, __webpack_require__) {
96
+
97
+ "use strict";
98
+
99
+ Object.defineProperty(exports, "__esModule", { value: true });
100
+ var event_model_1 = __webpack_require__(3);
101
+ var tracking_error_model_1 = __webpack_require__(4);
102
+ var tracking_constants_1 = __webpack_require__(5);
103
+ var ScTrackingService = (function () {
104
+ function ScTrackingService($http, $q, ScEnvironments) {
105
+ this.$http = $http;
106
+ this.$q = $q;
107
+ this.ScEnvironments = ScEnvironments;
108
+ this.eventUrl = ScEnvironments.getCurrentEnvironment().USER_SERVICE + ScTrackingService.eventEndpoint;
109
+ }
110
+ ScTrackingService.eventValid = function (event) {
111
+ return (!!event.source && !!event.user_id && !!event.user_type && !!event.metadata);
112
+ };
113
+ ScTrackingService.prototype.constructUrl = function (eventType) {
114
+ return "" + this.eventUrl + eventType;
115
+ };
116
+ ScTrackingService.prototype.track = function (eventType, e) {
117
+ if (!eventType) {
118
+ return this.$q.reject(new tracking_error_model_1.default(tracking_error_model_1.default.NO_EVENT_TYPE));
119
+ }
120
+ var event = new event_model_1.Event(e);
121
+ if (ScTrackingService.eventValid(event)) {
122
+ var prefixedEventType = tracking_constants_1.EVENT_TYPE_PREFIX + eventType;
123
+ return this.$http.post(this.constructUrl(prefixedEventType), event);
124
+ }
125
+ else {
126
+ return this.$q.reject(new tracking_error_model_1.default(tracking_error_model_1.default.INVALID_EVENT));
127
+ }
128
+ };
129
+ ScTrackingService.$inject = ['$http', '$q', 'ScEnvironments'];
130
+ ScTrackingService.eventEndpoint = '/events/business-events/';
131
+ return ScTrackingService;
132
+ }());
133
+ exports.default = ScTrackingService;
134
+
135
+
136
+ /***/ }),
137
+ /* 3 */
138
+ /***/ (function(module, exports, __webpack_require__) {
139
+
140
+ "use strict";
141
+
142
+ Object.defineProperty(exports, "__esModule", { value: true });
143
+ var Event = (function () {
144
+ function Event(data) {
145
+ this.source = '';
146
+ this.user_id = 0;
147
+ this.user_type = '';
148
+ Object.assign(this, data);
149
+ }
150
+ return Event;
151
+ }());
152
+ exports.Event = Event;
153
+
154
+
155
+ /***/ }),
156
+ /* 4 */
157
+ /***/ (function(module, exports, __webpack_require__) {
158
+
159
+ "use strict";
160
+
161
+ var __extends = (this && this.__extends) || (function () {
162
+ var extendStatics = Object.setPrototypeOf ||
163
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
164
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
165
+ return function (d, b) {
166
+ extendStatics(d, b);
167
+ function __() { this.constructor = d; }
168
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
169
+ };
170
+ })();
171
+ Object.defineProperty(exports, "__esModule", { value: true });
172
+ var TrackingError = (function (_super) {
173
+ __extends(TrackingError, _super);
174
+ function TrackingError(message) {
175
+ var _this = _super.call(this, message) || this;
176
+ _this.message = message;
177
+ _this.name = 'TrackingError';
178
+ return _this;
179
+ }
180
+ TrackingError.INVALID_EVENT = 'Invalid event. Missing one or more required parameter: source, user_id, user_type.';
181
+ TrackingError.NO_EVENT_TYPE = 'No event type was provided.';
182
+ return TrackingError;
183
+ }(Error));
184
+ exports.default = TrackingError;
185
+
186
+
187
+ /***/ }),
188
+ /* 5 */
189
+ /***/ (function(module, exports, __webpack_require__) {
190
+
191
+ "use strict";
192
+
193
+ Object.defineProperty(exports, "__esModule", { value: true });
194
+ exports.EVENT_TYPE_PREFIX = 'brand-solutions.solution-center.';
195
+
196
+
197
+ /***/ })
198
+ /******/ ]);
199
+
200
+
201
+ //////////////////
202
+ // WEBPACK FOOTER
203
+ // ./node_modules/@solution-center/tracking/dist/solutioncenter.tracking.js
204
+ // module id = 197
205
+ // module chunks = 1
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@solution-center/tracking",
3
+ "version": "0.0.6",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "description": "",
9
+ "license": "MIT",
10
+ "author": "hzlnd0",
11
+ "main": "dist/solutioncenter.tracking.js",
12
+ "scripts": {
13
+ "build": "npm run mkdir && node build.js",
14
+ "mkdir": "node build.js",
15
+ "prepublishOnly": "npm run build",
16
+ "test": "exit 0"
17
+ },
18
+ "dependencies": {
19
+ "angular": "^1.6.6"
20
+ }
21
+ }