Shopgo_Totango - Version 1.0.0

Version Notes

First release

Download this release

Release Info

Developer Moe Ghashim
Extension Shopgo_Totango
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Shopgo/Totango/Helper/Data.php ADDED
@@ -0,0 +1,626 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_Totango
14
+ * @copyright Copyright (c) 2015 ShopGo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Data helper
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_Totango
24
+ * @author Ammar <ammar@shopgo.me>
25
+ * Emad <emad@shopgo.me>
26
+ * Ahmad <ahmadalkaid@shopgo.me>
27
+ * Aya <aya@shopgo.me>
28
+ * ShopGo <support@shopgo.me>
29
+ */
30
+ class Shopgo_Totango_Helper_Data extends Shopgo_Core_Helper_Abstract
31
+ {
32
+ /**
33
+ * Totango service URL
34
+ */
35
+ const SERVICE_URL = 'https://sdr.totango.com/pixel.gif/';
36
+
37
+ /**
38
+ * General config paths
39
+ */
40
+ const XML_PATH_GENERAL_ENABLED = 'totango/general/enabled';
41
+ const XML_PATH_GENERAL_SERVICE_ID = 'totango/general/service_id';
42
+ const XML_PATH_GENERAL_ACCOUNT_ID = 'totango/general/account_id';
43
+ const XML_PATH_GENERAL_ACCOUNT_NAME = 'totango/general/account_name';
44
+ const XML_PATH_GENERAL_USER_ID = 'totango/general/user_id';
45
+
46
+ /**
47
+ * Trackers config path
48
+ */
49
+ const XML_PATH_TRACKERS = 'totango/trackers/';
50
+
51
+ /**
52
+ * Trackers config active field
53
+ */
54
+ const XML_PATH_TRACKERS_ACTIVE = 'active';
55
+
56
+ /**
57
+ * Trackers config active field values
58
+ */
59
+ const TRACKERS_ACTIVE_NONE = 0;
60
+ const TRACKERS_ACTIVE_ALL = 1;
61
+ const TRACKERS_ACTIVE_CUSTOM = 2;
62
+
63
+ /**
64
+ * Trackers advanced excluded admin users config path
65
+ */
66
+ const XML_PATH_TRACKERS_ADV_EXC_ADMIN = 'totango/trackers_advanced/excluded_admin_users';
67
+
68
+ /**
69
+ * Module var directory
70
+ */
71
+ const VAR_DIR = 'shopgo/totango/';
72
+
73
+ /**
74
+ * Persist config files
75
+ */
76
+ const PERSIST_FILE = 'persist.xml';
77
+ const PERSIST_LOCAL_FILE = 'persist.local.xml';
78
+
79
+ /**
80
+ * Persist config mode status path
81
+ */
82
+ const XML_PATH_PERSIST_CONFIG_MODE_STATUS = 'persist';
83
+
84
+
85
+ /**
86
+ * Log file name
87
+ *
88
+ * @var string
89
+ */
90
+ protected $_logFile = 'totango.log';
91
+
92
+ /**
93
+ * Trackers names
94
+ *
95
+ * @var array
96
+ */
97
+ private static $_trackers = array(
98
+ 'complete_orders', 'canceled_orders',
99
+ 'product', 'category',
100
+ 'attribute', 'carrier',
101
+ 'payment', 'admin_login'
102
+ );
103
+
104
+
105
+ /**
106
+ * Get a list of predefined trackers
107
+ *
108
+ * @return array
109
+ */
110
+ public static function getTrackers()
111
+ {
112
+ return self::$_trackers;
113
+ }
114
+
115
+ /**
116
+ * Check whether the extension is enabled or not
117
+ *
118
+ * @return bool
119
+ */
120
+ public function isEnabled()
121
+ {
122
+ $result = $this->getConfig(self::XML_PATH_GENERAL_ENABLED);
123
+
124
+ if (!$result) {
125
+ $this->log(array(
126
+ 'message' => 'The module is disabled',
127
+ 'level' => 5
128
+ ));
129
+ }
130
+
131
+ return $result;
132
+ }
133
+
134
+ /**
135
+ * Check whether a specific tracker is enabled or not
136
+ *
137
+ * @param string $tracker
138
+ * @return bool
139
+ */
140
+ public function isTrackerEnabled($tracker)
141
+ {
142
+ $result = false;
143
+
144
+ $trackersActive = $this->getConfig(
145
+ self::XML_PATH_TRACKERS . self::XML_PATH_TRACKERS_ACTIVE
146
+ );
147
+
148
+ switch ($trackersActive) {
149
+ case self::TRACKERS_ACTIVE_NONE:
150
+ $result = false;
151
+
152
+ $this->log(array(
153
+ 'message' => 'All trackers are inactive/disabled',
154
+ 'level' => 5
155
+ ));
156
+
157
+ break;
158
+
159
+ case self::TRACKERS_ACTIVE_ALL:
160
+ $result = true;
161
+
162
+ $this->log(array(
163
+ 'message' => 'All trackers are active/enabled',
164
+ 'level' => 5
165
+ ));
166
+
167
+ break;
168
+
169
+ default:
170
+ $trackers = self::getTrackers();
171
+
172
+ if (isset($trackers[$tracker])) {
173
+ $result = $this->getConfig(
174
+ self::XML_PATH_TRACKERS . $tracker
175
+ );
176
+
177
+ if (!$result) {
178
+ $this->log(array(
179
+ 'message' => sprintf(
180
+ 'Tracker "%s" is disabled',
181
+ $tracker
182
+ ),
183
+ 'level' => 5
184
+ ));
185
+ }
186
+ } else {
187
+ $this->log(array(
188
+ 'message' => sprintf(
189
+ 'Tracker "%s" is invalid',
190
+ $tracker
191
+ ),
192
+ 'level' => 3
193
+ ));
194
+ }
195
+ }
196
+
197
+ return $result;
198
+ }
199
+
200
+ /**
201
+ * Get module var directory path
202
+ *
203
+ * @return string
204
+ */
205
+ public function getVarDir()
206
+ {
207
+ return Mage::getBaseDir('var')
208
+ . DS . str_replace('/', DS, self::VAR_DIR);
209
+ }
210
+
211
+ /**
212
+ * Customized get Mage store config
213
+ *
214
+ * @param string $path
215
+ * @param mixed $store
216
+ * @return mixed
217
+ */
218
+ public function getConfig($path, $store = null)
219
+ {
220
+ $config = $this->_getPersistConfig($path);
221
+
222
+ if ($config === null || trim($config) == '') {
223
+ $config = Mage::getStoreConfig($path, $store);
224
+ }
225
+
226
+ return $config;
227
+ }
228
+
229
+ /**
230
+ * Get persist config value
231
+ *
232
+ * @param string $path
233
+ * @return mixed
234
+ */
235
+ private function _getPersistConfig($path)
236
+ {
237
+ $config = null;
238
+ $varDir = $this->getVarDir();
239
+
240
+ $persistConfig = array(
241
+ 'base' => $varDir . self::PERSIST_FILE,
242
+ 'local' => $varDir . self::PERSIST_LOCAL_FILE
243
+ );
244
+
245
+ try {
246
+ $persistBase = $this->_loadXmlFile($persistConfig['base']);
247
+
248
+ if ($persistBase->hasFile) {
249
+ $persistStatus = $persistBase->getNode(
250
+ self::XML_PATH_PERSIST_CONFIG_MODE_STATUS
251
+ );
252
+
253
+ if (!$persistStatus) {
254
+ $this->log(array(
255
+ 'message' => 'Persist config status path is invalid',
256
+ 'level' => 3
257
+ ));
258
+
259
+ return $config;
260
+ }
261
+
262
+ if ($persistStatus->asArray() == 1) {
263
+ $this->log(array(
264
+ 'message' => 'Persist config mode is enabled ' .
265
+ '(Magento system configuration value is ignored!)',
266
+ 'level' => 5
267
+ ));
268
+
269
+ $persistLocal = $this->_loadXmlFile($persistConfig['local']);
270
+
271
+ return $this->_getPersistConfigFromSource(
272
+ $path, $persistBase, $persistLocal
273
+ );
274
+ } else {
275
+ $this->log(array(
276
+ 'message' => 'Persist config mode is disabled',
277
+ 'level' => 5
278
+ ));
279
+ }
280
+ } else {
281
+ $this->log(array(
282
+ 'message' => 'Could not read persist config file',
283
+ 'level' => 5
284
+ ));
285
+ }
286
+ } catch (Exception $e) {
287
+ $this->log(array(
288
+ 'message' => sprintf(
289
+ '[Persist Config Mode Exception]: %s',
290
+ $e->getMessage()
291
+ ),
292
+ 'level' => 3
293
+ ));
294
+
295
+ $this->log($e, 'exception');
296
+ }
297
+
298
+ return $config;
299
+ }
300
+
301
+ /**
302
+ * Get persist config from base or local sources
303
+ *
304
+ * @param string $path
305
+ * @param Varien_Simplexml_Config $persistBase
306
+ * @param Varien_Simplexml_Config $persistLocal
307
+ * @return mixed
308
+ */
309
+ private function _getPersistConfigFromSource($path, $persistBase, $persistLocal)
310
+ {
311
+ $config = null;
312
+
313
+ switch ($persistLocal->hasFile) {
314
+ case true:
315
+ $config = $persistLocal->getNode($path);
316
+
317
+ if (!empty($config)) {
318
+ $config = $config->asArray();
319
+
320
+ $this->log(array(
321
+ 'message' => 'Persist config "local" is used',
322
+ 'level' => 5
323
+ ));
324
+
325
+ if (trim($config) != '') {
326
+ break;
327
+ }
328
+ } else {
329
+ $this->log(array(
330
+ 'message' => sprintf(
331
+ 'Persist config "local" path (%s) ' .
332
+ 'is invalid or does not exist',
333
+ $path
334
+ ),
335
+ 'level' => 5
336
+ ));
337
+ }
338
+
339
+ // Break is omitted on purpose
340
+
341
+ case false:
342
+ // It looks a bit odd, but this is a necessary check
343
+ if (!$persistLocal->hasFile) {
344
+ $this->log(array(
345
+ 'message' => 'Could not read persist config local file',
346
+ 'level' => 5
347
+ ));
348
+ }
349
+
350
+ $config = $persistBase->getNode($path);
351
+
352
+ if (!empty($config)) {
353
+ $config = $config->asArray();
354
+ } else {
355
+ $this->log(array(
356
+ 'message' => sprintf(
357
+ 'Persist config "local" path (%s) ' .
358
+ 'is invalid or does not exist',
359
+ $path
360
+ ),
361
+ 'level' => 5
362
+ ));
363
+ }
364
+
365
+ break;
366
+ }
367
+
368
+ return $config;
369
+ }
370
+
371
+ /**
372
+ * Load XML file
373
+ *
374
+ * @param string $file
375
+ * @return Varien_Simplexml_Config
376
+ */
377
+ private function _loadXmlFile($file)
378
+ {
379
+ $xmlConfig = new Varien_Simplexml_Config();
380
+ $xmlConfig->hasFile = $xmlConfig->loadFile($file);
381
+
382
+ return $xmlConfig;
383
+ }
384
+
385
+ /**
386
+ * Get a list of of admin users to be excluded from tracking
387
+ *
388
+ * @return array
389
+ */
390
+ public function getExcludedAdminUsers()
391
+ {
392
+ $excludedAdminUsers = $this->getConfig(
393
+ self::XML_PATH_TRACKERS_ADV_EXC_ADMIN
394
+ );
395
+
396
+ return trim($excludedAdminUsers) != ''
397
+ ? array_map('trim', explode(',', $excludedAdminUsers))
398
+ : array();
399
+ }
400
+
401
+ /**
402
+ * Log data user-activity event or attribute-updates
403
+ *
404
+ * @param array $data
405
+ * @return bool
406
+ */
407
+ public function track($data)
408
+ {
409
+ $canSend = false;
410
+ $events = implode(', ', array_keys($data));
411
+
412
+ $this->log(sprintf(
413
+ 'Track Totango %s event(s)',
414
+ $events
415
+ ));
416
+
417
+ if (empty($data)) {
418
+ $this->log(array(
419
+ 'message' => 'There is no tracking data to process',
420
+ 'level' => 3
421
+ ));
422
+
423
+ return $canSend;
424
+ }
425
+
426
+ $params = array(
427
+ 'sdr_s' => $this->getConfig(
428
+ self::XML_PATH_GENERAL_SERVICE_ID
429
+ ),
430
+ 'sdr_o' => $this->getConfig(
431
+ self::XML_PATH_GENERAL_ACCOUNT_ID
432
+ )
433
+ );
434
+
435
+ if (empty($params['sdr_s']) || empty($params['sdr_o'])) {
436
+ $this->log(array(
437
+ 'message' => 'Insufficient tracking data ' .
438
+ '(Service ID and Account ID are mandatory)',
439
+ 'level' => 3
440
+ ));
441
+
442
+ return $canSend;
443
+ }
444
+
445
+ $accountName = $this->getConfig(
446
+ self::XML_PATH_GENERAL_ACCOUNT_NAME
447
+ );
448
+
449
+ if ($accountName) {
450
+ $params['sdr_odn'] = $accountName;
451
+ }
452
+
453
+ $canSend = true;
454
+
455
+ foreach ($data as $event => $_data) {
456
+ $eventData = $this->_getEventData($event, $_data);
457
+ $canSend = $canSend && $eventData['can_send'];
458
+ $params = array_merge($params, $eventData['params']);
459
+ }
460
+
461
+ if ($canSend) {
462
+ return $this->_sendRequest($params);
463
+ } else {
464
+ $this->log(array(
465
+ 'message' => 'Could not send a request to Totango',
466
+ 'level' => 3
467
+ ));
468
+ }
469
+ }
470
+
471
+ /**
472
+ * Get Totango event data
473
+ *
474
+ * @param string $event
475
+ * @param array $data
476
+ * @return array
477
+ */
478
+ private function _getEventData($event, $data)
479
+ {
480
+ $canSend = false;
481
+ $params = array();
482
+
483
+ switch ($event) {
484
+ case 'user-activity':
485
+ if (isset($data['action']) && isset($data['module'])) {
486
+ $params['sdr_u'] = $this->getConfig(
487
+ self::XML_PATH_GENERAL_USER_ID
488
+ );
489
+
490
+ $params['sdr_a'] = $data['action'];
491
+ $params['sdr_m'] = $data['module'];
492
+
493
+ $canSend = true;
494
+ } else {
495
+ $this->log(array(
496
+ 'message' => sprintf(
497
+ 'Insufficient tracking data for %s event',
498
+ $event
499
+ ),
500
+ 'level' => 3
501
+ ));
502
+ }
503
+
504
+ break;
505
+
506
+ case 'account-attribute':
507
+ if (is_array($data) && !empty($data)) {
508
+ foreach ($data as $name => $value) {
509
+ $params["sdr_o.{$name}"] = $value;
510
+ }
511
+
512
+ $canSend = true;
513
+ } else {
514
+ $this->log(array(
515
+ 'message' => sprintf(
516
+ 'Insufficient tracking data for %s event',
517
+ $event
518
+ ),
519
+ 'level' => 3
520
+ ));
521
+ }
522
+
523
+ break;
524
+
525
+ case 'user-attribute':
526
+ if (is_array($data) && !empty($data)) {
527
+ $params['sdr_u'] = $this->getConfig(
528
+ self::XML_PATH_GENERAL_USER_ID
529
+ );
530
+
531
+ foreach ($data as $name => $value) {
532
+ $params["sdr_u.{$name}"] = $value;
533
+ }
534
+
535
+ $canSend = true;
536
+ } else {
537
+ $this->log(array(
538
+ 'message' => sprintf(
539
+ 'Insufficient tracking data for %s event',
540
+ $event
541
+ ),
542
+ 'level' => 3
543
+ ));
544
+ }
545
+
546
+ break;
547
+
548
+ default:
549
+ $this->log(array(
550
+ 'message' => sprintf(
551
+ 'The requested event %s is invalid',
552
+ $event
553
+ ),
554
+ 'level' => 3
555
+ ));
556
+ }
557
+
558
+ return array(
559
+ 'can_send' => $canSend,
560
+ 'params' => $params
561
+ );
562
+ }
563
+
564
+ /**
565
+ * Send request to Totango
566
+ *
567
+ * @param array $params
568
+ * @return bool
569
+ */
570
+ private function _sendRequest($params)
571
+ {
572
+ $result = false;
573
+ $url = self::SERVICE_URL;
574
+
575
+ $this->log(array(
576
+ array('message' => 'Totango service call, Start...'),
577
+ array('message' => sprintf('Totango service URL: %s', $url)),
578
+ array('message' => array('request_params' => $params))
579
+ ));
580
+
581
+ if (empty($params)) {
582
+ $this->log(array(
583
+ 'message' => 'Could not send a request with empty parameters',
584
+ 'level' => 3
585
+ ));
586
+
587
+ return $result;
588
+ }
589
+
590
+ try {
591
+ $httpClient = new Varien_Http_Client();
592
+
593
+ $response = $httpClient
594
+ ->setUri($url)
595
+ ->setHeaders('Content-Type: image/gif')
596
+ ->setParameterPost($params)
597
+ ->request(Varien_Http_Client::POST);
598
+
599
+ if ($response->isSuccessful()) {
600
+ $result = true;
601
+ $this->log(
602
+ 'Totango request was sent successfully ' .
603
+ '(A successful response does not mean that ' .
604
+ 'it was received correctly by Totango. So, be careful!)'
605
+ );
606
+ } else {
607
+ $this->log(array(
608
+ 'message' => 'Totango sent request response was unsuccessful',
609
+ 'level' => 3
610
+ ));
611
+ }
612
+ } catch (Exception $e) {
613
+ $this->log(array(
614
+ 'message' => sprintf(
615
+ '[Totango Request Send Exception]: %s',
616
+ $e->getMessage()
617
+ ),
618
+ 'level' => 3
619
+ ));
620
+
621
+ $this->log($e, 'exception');
622
+ }
623
+
624
+ return $result;
625
+ }
626
+ }
app/code/community/Shopgo/Totango/Model/Observer.php ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_Totango
14
+ * @copyright Copyright (c) 2015 ShopGo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Observer model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_Totango
24
+ * @author Ammar <ammar@shopgo.me>
25
+ * Emad <emad@shopgo.me>
26
+ * Ahmad <ahmadalkaid@shopgo.me>
27
+ * Aya <aya@shopgo.me>
28
+ * ShopGo <support@shopgo.me>
29
+ */
30
+ class Shopgo_Totango_Model_Observer
31
+ {
32
+ /**
33
+ * Track orders based on their statuses
34
+ *
35
+ * @param Varien_Event_Observer $observer
36
+ * @return null
37
+ */
38
+ public function trackOrderStatus(Varien_Event_Observer $observer)
39
+ {
40
+ $helper = Mage::helper('totango');
41
+
42
+ // Current order state
43
+ $orderState = $observer->getOrder()->getState();
44
+ // List of order states and their data
45
+ $orderStates = array(
46
+ Mage_Sales_Model_Order::STATE_COMPLETE => array(
47
+ 'tracker-name' => 'complete_orders',
48
+ 'attribute-name' => 'Complete Orders'
49
+ ),
50
+ Mage_Sales_Model_Order::STATE_CANCELED => array(
51
+ 'tracker-name' => 'canceled_orders',
52
+ 'attribute-name' => 'Canceled Orders'
53
+ )
54
+ );
55
+
56
+ $helper->log(sprintf('Track %s order', $orderState));
57
+
58
+ if (!$helper->isEnabled()) {
59
+ return;
60
+ }
61
+
62
+ $orderStatesNames = array_keys($orderStates);
63
+
64
+ if (!isset($orderStatesNames[$orderState])) {
65
+ $helper->log(array(
66
+ 'message' => sprintf(
67
+ '%s orders are not trackable',
68
+ ucfirst($orderState)
69
+ ),
70
+ 'level' => 5
71
+ ));
72
+
73
+ return;
74
+ }
75
+
76
+ foreach ($orderStates as $state => $data) {
77
+ if ($helper->isTrackerEnabled($data['tracker-name'])) {
78
+ $orders = Mage::getModel('sales/order')
79
+ ->getCollection()
80
+ ->addAttributeToFilter('status', array(
81
+ 'eq' => $state
82
+ ))->getSize();
83
+
84
+ $helper->track(array(
85
+ 'account-attribute' => array(
86
+ $data['attribute-name'] => $orders
87
+ )
88
+ ));
89
+ }
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Track newly added catalog products
95
+ *
96
+ * @param Varien_Event_Observer $observer
97
+ * @return null
98
+ */
99
+ public function trackNewProduct(Varien_Event_Observer $observer)
100
+ {
101
+ $helper = Mage::helper('totango');
102
+
103
+ $helper->log('Track new catalog product, Start...');
104
+
105
+ if (!$helper->isEnabled()) {
106
+ return;
107
+ }
108
+
109
+ if ($helper->isTrackerEnabled('product')) {
110
+ $product = $observer->getProduct();
111
+ $isProduct = Mage::getModel('catalog/product')
112
+ ->getCollection()
113
+ ->addFieldToFilter('entity_id', $product->getId())
114
+ ->setPageSize(1)
115
+ ->getItems();
116
+
117
+ if (!$isProduct) {
118
+ $productsCount = Mage::getModel('catalog/product')
119
+ ->getCollection()->getSize();
120
+
121
+ $helper->track(array(
122
+ 'user-activity' => array(
123
+ 'action' => 'NewProduct',
124
+ 'module' => 'Catalog'
125
+ ),
126
+ 'account-attribute' => array(
127
+ // New product is not counted in this event.
128
+ // Thus, increment by 1.
129
+ 'Number of Catalog Products' => $productsCount + 1
130
+ )
131
+ ));
132
+ } else {
133
+ $helper->log(array(
134
+ 'message' => 'Not a new catalog product!',
135
+ 'level' => 5
136
+ ));
137
+ }
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Track newly added catalog categories
143
+ *
144
+ * @param Varien_Event_Observer $observer
145
+ * @return null
146
+ */
147
+ public function trackNewCategory(Varien_Event_Observer $observer)
148
+ {
149
+ $helper = Mage::helper('totango');
150
+
151
+ $helper->log('Track new catalog category, Start...');
152
+
153
+ if (!$helper->isEnabled()) {
154
+ return;
155
+ }
156
+
157
+ if ($helper->isTrackerEnabled('category')) {
158
+ $categoryId = $observer->getEvent()->getCategory()->getId();
159
+ $categories = Mage::getModel('catalog/category')
160
+ ->getCollection()
161
+ ->getAllIds();
162
+
163
+ if (!isset($categories[$categoryId])) {
164
+ $categoriesCount = Mage::getModel('catalog/category')
165
+ ->getCollection()->getSize();
166
+
167
+ $helper->track(array(
168
+ 'user-activity' => array(
169
+ 'action' => 'NewCategory',
170
+ 'module' => 'Catalog'
171
+ ),
172
+ 'account-attribute' => array(
173
+ // Exclude root category in this event.
174
+ // Thus, decrement by 1.
175
+ 'Number of Catalog Categories' => $categoriesCount - 1
176
+ )
177
+ ));
178
+ } else {
179
+ $helper->log(array(
180
+ 'message' => 'Not a new catalog category!',
181
+ 'level' => 5
182
+ ));
183
+ }
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Track newly added catalog attributes
189
+ *
190
+ * @param Varien_Event_Observer $observer
191
+ * @return null
192
+ */
193
+ public function trackNewAttribute(Varien_Event_Observer $observer)
194
+ {
195
+ $helper = Mage::helper('totango');
196
+
197
+ $helper->log('Track new catalog attribute, Start...');
198
+
199
+ if (!$helper->isEnabled()) {
200
+ return;
201
+ }
202
+
203
+ if ($helper->isTrackerEnabled('attribute')) {
204
+ $attributeId = $observer->getEvent()->getAttribute()->getId();
205
+ $isAttribute = Mage::getModel('eav/entity_attribute')
206
+ ->load($attributeId)
207
+ ->getAttributeCode();
208
+
209
+ if (!$isAttribute) {
210
+ $attributesCount = Mage::getResourceModel(
211
+ 'catalog/product_attribute_collection'
212
+ )->addVisibleFilter()->getSize();
213
+
214
+ $helper->track(array(
215
+ 'user-activity' => array(
216
+ 'action' => 'NewAttribute',
217
+ 'module' => 'Catalog'
218
+ ),
219
+ 'account-attribute' => array(
220
+ // New attribute is not counted in this event.
221
+ // Thus, increment by 1.
222
+ 'Number of Catalog Attributes' => $attributesCount + 1
223
+ )
224
+ ));
225
+ } else {
226
+ $helper->log(array(
227
+ 'message' => 'Not a new catalog attribute!',
228
+ 'level' => 5
229
+ ));
230
+ }
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Track active carriers
236
+ *
237
+ * @return null
238
+ */
239
+ public function trackActiveCarriers()
240
+ {
241
+ $helper = Mage::helper('totango');
242
+
243
+ $helper->log('Track active carriers, Start...');
244
+
245
+ if (!$helper->isEnabled()) {
246
+ return;
247
+ }
248
+
249
+ if ($helper->isTrackerEnabled('carrier')) {
250
+ $methods = Mage::getSingleton('shipping/config')
251
+ ->getActiveCarriers();
252
+
253
+ $methodsNames = implode(', ', array_map(
254
+ function($method) {
255
+ $title = Mage::getStoreConfig("carriers/{$method}/title");
256
+ return "{$title} [{$method}]";
257
+ },
258
+ array_keys($methods)
259
+ ));
260
+
261
+ $helper->track(array(
262
+ 'user-activity' => array(
263
+ 'action' => 'CarriersSave',
264
+ 'module' => 'Shipping'
265
+ ),
266
+ 'account-attribute' => array(
267
+ 'Number of Active Carriers' => count($methods),
268
+ 'Names of Active Carriers' => $methodsNames
269
+ )
270
+ ));
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Track active payment methods
276
+ *
277
+ * @return null
278
+ */
279
+ public function trackActivePaymentMethods()
280
+ {
281
+ $helper = Mage::helper('totango');
282
+
283
+ $helper->log('Track active payment methods, Start...');
284
+
285
+ if (!$helper->isEnabled()) {
286
+ return;
287
+ }
288
+
289
+ if ($helper->isTrackerEnabled('payment')) {
290
+ $methods = Mage::getSingleton('payment/config')
291
+ ->getActiveMethods();
292
+
293
+ $methodsNames = implode(', ', array_map(
294
+ function($method) {
295
+ return "{$method->getTitle()} [{$method->getCode()}]";
296
+ },
297
+ array_values($methods)
298
+ ));
299
+
300
+ $helper->track(array(
301
+ 'user-activity' => array(
302
+ 'action' => 'PaymentMethodsSave',
303
+ 'module' => 'Payment'
304
+ ),
305
+ 'account-attribute' => array(
306
+ 'Number of Active Payment Methods' => count($methods),
307
+ 'Names of Active Payment Methods' => $methodsNames
308
+ )
309
+ ));
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Track admin user successful logins
315
+ *
316
+ * @param Varien_Event_Observer $observer
317
+ * @return null
318
+ */
319
+ public function trackAdminSuccessfulLogin(Varien_Event_Observer $observer)
320
+ {
321
+ $helper = Mage::helper('totango');
322
+
323
+ $helper->log('Track successful admin user login');
324
+
325
+ if (!$helper->isEnabled()) {
326
+ return;
327
+ }
328
+
329
+ if ($helper->isTrackerEnabled('admin_login')) {
330
+ $adminUser = $observer->getUser();
331
+ $adminUsername = $adminUser->getUsername();
332
+
333
+ $excludedAdminUsers = $helper->getExcludedAdminUsers();
334
+
335
+ if (!isset($excludedAdminUsers[$adminUsername])) {
336
+ // New login is not counted in this event.
337
+ // So, this is a workaround for $adminUser->getLogDate()
338
+ $logDate = Mage::getModel('core/date')->date('Y-m-d H:i:s');
339
+
340
+ $helper->track(array(
341
+ 'user-activity' => array(
342
+ 'action' => 'AdminLogin',
343
+ 'module' => 'Admin'
344
+ ),
345
+ 'account-attribute' => array(
346
+ 'Admin User Name' => $adminUser->getUsername(),
347
+ 'Admin Last Login Time' => $logDate,
348
+ // New login is not counted in this event.
349
+ // Thus, increment by 1.
350
+ 'Admin Login Number' => $adminUser->getLognum() + 1
351
+ )
352
+ ));
353
+ } else {
354
+ $helper->log(array(
355
+ 'message' => sprintf(
356
+ 'Admin user "%s" is excluded from tracking',
357
+ $adminUsername
358
+ ),
359
+ 'level' => 5
360
+ ));
361
+ }
362
+ }
363
+ }
364
+ }
app/code/community/Shopgo/Totango/Model/System/Config/Source/Trackersactive.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_Totango
14
+ * @copyright Copyright (c) 2015 ShopGo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_Totango
24
+ * @author Ammar <ammar@shopgo.me>
25
+ * Emad <emad@shopgo.me>
26
+ * Ahmad <ahmadalkaid@shopgo.me>
27
+ * Aya <aya@shopgo.me>
28
+ * ShopGo <support@shopgo.me>
29
+ */
30
+ class Shopgo_Totango_Model_System_Config_Source_Trackersactive
31
+ {
32
+ /**
33
+ * Get trackers active options
34
+ *
35
+ * @return array
36
+ */
37
+ public function toOptionArray()
38
+ {
39
+ $helper = Mage::helper('adminhtml');
40
+
41
+ $options = array(
42
+ array(
43
+ 'label' => $helper->__('None'),
44
+ 'value' => Shopgo_Totango_Helper_Data::TRACKERS_ACTIVE_NONE
45
+ ),
46
+ array(
47
+ 'label' => $helper->__('All'),
48
+ 'value' => Shopgo_Totango_Helper_Data::TRACKERS_ACTIVE_ALL
49
+ ),
50
+ array(
51
+ 'label' => $helper->__('Custom'),
52
+ 'value' => Shopgo_Totango_Helper_Data::TRACKERS_ACTIVE_CUSTOM
53
+ )
54
+ );
55
+
56
+ return $options;
57
+ }
58
+ }
app/code/community/Shopgo/Totango/etc/adminhtml.xml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ShopGo
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ *
13
+ * @category Shopgo
14
+ * @package Shopgo_Totango
15
+ * @author Ammar <ammar@shopgo.me>
16
+ * Emad <emad@shopgo.me>
17
+ * Ahmad <ahmadalkaid@shopgo.me>
18
+ * Aya <aya@shopgo.me>
19
+ * ShopGo <support@shopgo.me>
20
+ * @copyright Copyright (c) 2015 ShopGo. (http://www.shopgo.me)
21
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <acl>
26
+ <resources>
27
+ <all>
28
+ <title>Allow Everything</title>
29
+ </all>
30
+ <admin>
31
+ <children>
32
+ <system>
33
+ <children>
34
+ <config>
35
+ <children>
36
+ <totango translate="title" module="totango">
37
+ <title>Totango</title>
38
+ </totango>
39
+ </children>
40
+ </config>
41
+ </children>
42
+ </system>
43
+ </children>
44
+ </admin>
45
+ </resources>
46
+ </acl>
47
+ </config>
app/code/community/Shopgo/Totango/etc/config.xml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ShopGo
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ *
13
+ * @category Shopgo
14
+ * @package Shopgo_Totango
15
+ * @author Ammar <ammar@shopgo.me>
16
+ * Emad <emad@shopgo.me>
17
+ * Ahmad <ahmadalkaid@shopgo.me>
18
+ * Aya <aya@shopgo.me>
19
+ * ShopGo <support@shopgo.me>
20
+ * @copyright Copyright (c) 2015 ShopGo. (http://www.shopgo.me)
21
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <modules>
26
+ <Shopgo_Totango>
27
+ <version>1.0.0</version>
28
+ </Shopgo_Totango>
29
+ </modules>
30
+ <global>
31
+ <helpers>
32
+ <totango>
33
+ <class>Shopgo_Totango_Helper</class>
34
+ </totango>
35
+ </helpers>
36
+ <models>
37
+ <totango>
38
+ <class>Shopgo_Totango_Model</class>
39
+ </totango>
40
+ </models>
41
+ <events>
42
+ <sales_order_save_after>
43
+ <observers>
44
+ <sales_order_save_after_observer>
45
+ <type>singleton</type>
46
+ <class>totango/observer</class>
47
+ <method>trackOrderStatus</method>
48
+ </sales_order_save_after_observer>
49
+ </observers>
50
+ </sales_order_save_after>
51
+ <catalog_product_save_before>
52
+ <observers>
53
+ <catalog_product_save_before_observer>
54
+ <type>singleton</type>
55
+ <class>totango/observer</class>
56
+ <method>trackNewProduct</method>
57
+ </catalog_product_save_before_observer>
58
+ </observers>
59
+ </catalog_product_save_before>
60
+ <catalog_category_prepare_save>
61
+ <observers>
62
+ <catalog_category_prepare_save_observer>
63
+ <type>singleton</type>
64
+ <class>totango/observer</class>
65
+ <method>trackNewCategory</method>
66
+ </catalog_category_prepare_save_observer>
67
+ </observers>
68
+ </catalog_category_prepare_save>
69
+ <catalog_entity_attribute_save_before>
70
+ <observers>
71
+ <catalog_entity_attribute_save_before_observer>
72
+ <type>singleton</type>
73
+ <class>totango/observer</class>
74
+ <method>trackNewAttribute</method>
75
+ </catalog_entity_attribute_save_before_observer>
76
+ </observers>
77
+ </catalog_entity_attribute_save_before>
78
+ <admin_system_config_changed_section_carriers>
79
+ <observers>
80
+ <admin_system_config_changed_section_carriers_observer>
81
+ <type>singleton</type>
82
+ <class>totango/observer</class>
83
+ <method>trackActiveCarriers</method>
84
+ </admin_system_config_changed_section_carriers_observer>
85
+ </observers>
86
+ </admin_system_config_changed_section_carriers>
87
+ <admin_system_config_changed_section_payment>
88
+ <observers>
89
+ <admin_system_config_changed_section_payment_observer>
90
+ <type>singleton</type>
91
+ <class>totango/observer</class>
92
+ <method>trackActivePaymentMethods</method>
93
+ </admin_system_config_changed_section_payment_observer>
94
+ </observers>
95
+ </admin_system_config_changed_section_payment>
96
+ <admin_session_user_login_success>
97
+ <observers>
98
+ <admin_session_user_login_success_observer>
99
+ <type>singleton</type>
100
+ <class>totango/observer</class>
101
+ <method>trackAdminSuccessfulLogin</method>
102
+ </admin_session_user_login_success_observer>
103
+ </observers>
104
+ </admin_session_user_login_success>
105
+ </events>
106
+ </global>
107
+ <default>
108
+ <totango>
109
+ <trackers>
110
+ <active>1</active>
111
+ <complete_orders>1</complete_orders>
112
+ <canceled_orders>1</canceled_orders>
113
+ <product>1</product>
114
+ <category>1</category>
115
+ <attribute>1</attribute>
116
+ <carrier>1</carrier>
117
+ <payment>1</payment>
118
+ <admin_login>1</admin_login>
119
+ </trackers>
120
+ </totango>
121
+ </default>
122
+ </config>
app/code/community/Shopgo/Totango/etc/system.xml ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ShopGo
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ *
13
+ * @category Shopgo
14
+ * @package Shopgo_Totango
15
+ * @author Ammar <ammar@shopgo.me>
16
+ * Emad <emad@shopgo.me>
17
+ * Ahmad <ahmadalkaid@shopgo.me>
18
+ * Aya <aya@shopgo.me>
19
+ * ShopGo <support@shopgo.me>
20
+ * @copyright Copyright (c) 2015 ShopGo. (http://www.shopgo.me)
21
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <tabs>
26
+ <shopgo translate="label" module="totango">
27
+ <label>ShopGo</label>
28
+ <sort_order>100</sort_order>
29
+ </shopgo>
30
+ </tabs>
31
+ <sections>
32
+ <totango translate="label" module="totango">
33
+ <label>Totango</label>
34
+ <tab>shopgo</tab>
35
+ <sort_order>100</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>0</show_in_website>
38
+ <show_in_store>0</show_in_store>
39
+ <groups>
40
+ <general translate="label" module="totango">
41
+ <label>General</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>10</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>0</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ <fields>
48
+ <enabled translate="label">
49
+ <label>Enabled</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>adminhtml/system_config_source_yesno</source_model>
52
+ <sort_order>10</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>0</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ </enabled>
57
+ <service_id translate="label">
58
+ <label>Service ID</label>
59
+ <frontend_type>text</frontend_type>
60
+ <sort_order>20</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>0</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ </service_id>
65
+ <account_id translate="label">
66
+ <label>Account ID</label>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>30</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>0</show_in_website>
71
+ <show_in_store>0</show_in_store>
72
+ </account_id>
73
+ <account_name translate="label">
74
+ <label>Account Name</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>40</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>0</show_in_website>
79
+ <show_in_store>0</show_in_store>
80
+ </account_name>
81
+ <user_id translate="label">
82
+ <label>User ID</label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>50</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>0</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ </user_id>
89
+ </fields>
90
+ </general>
91
+ <trackers translate="label" module="totango">
92
+ <label>Trackers</label>
93
+ <frontend_type>text</frontend_type>
94
+ <sort_order>20</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>0</show_in_website>
97
+ <show_in_store>0</show_in_store>
98
+ <fields>
99
+ <active translate="label">
100
+ <label>Active</label>
101
+ <frontend_type>select</frontend_type>
102
+ <source_model>totango/system_config_source_trackersactive</source_model>
103
+ <sort_order>10</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>0</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </active>
108
+ <complete_orders translate="label">
109
+ <label>Complete Orders</label>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
112
+ <sort_order>20</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>0</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ <depends><active>2</active></depends>
117
+ </complete_orders>
118
+ <canceled_orders translate="label">
119
+ <label>Canceled Orders</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
122
+ <sort_order>30</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>0</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ <depends><active>2</active></depends>
127
+ </canceled_orders>
128
+ <product translate="label">
129
+ <label>Products</label>
130
+ <frontend_type>select</frontend_type>
131
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
132
+ <sort_order>40</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>0</show_in_website>
135
+ <show_in_store>0</show_in_store>
136
+ <depends><active>2</active></depends>
137
+ </product>
138
+ <category translate="label">
139
+ <label>Categories</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
142
+ <sort_order>50</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>0</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ <depends><active>2</active></depends>
147
+ </category>
148
+ <attribute translate="label">
149
+ <label>Attributes</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
152
+ <sort_order>60</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>0</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ <depends><active>2</active></depends>
157
+ </attribute>
158
+ <carrier translate="label">
159
+ <label>Shipping Methods</label>
160
+ <frontend_type>select</frontend_type>
161
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
162
+ <sort_order>70</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>0</show_in_website>
165
+ <show_in_store>0</show_in_store>
166
+ <depends><active>2</active></depends>
167
+ </carrier>
168
+ <payment translate="label">
169
+ <label>Payment Methods</label>
170
+ <frontend_type>select</frontend_type>
171
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
172
+ <sort_order>80</sort_order>
173
+ <show_in_default>1</show_in_default>
174
+ <show_in_website>0</show_in_website>
175
+ <show_in_store>0</show_in_store>
176
+ <depends><active>2</active></depends>
177
+ </payment>
178
+ <admin_login translate="label">
179
+ <label>Admin Login</label>
180
+ <frontend_type>select</frontend_type>
181
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
182
+ <sort_order>90</sort_order>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>0</show_in_website>
185
+ <show_in_store>0</show_in_store>
186
+ <depends><active>2</active></depends>
187
+ </admin_login>
188
+ </fields>
189
+ </trackers>
190
+ <trackers_advanced translate="label" module="totango">
191
+ <label>Trackers (Advanced)</label>
192
+ <frontend_type>text</frontend_type>
193
+ <sort_order>30</sort_order>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>0</show_in_website>
196
+ <show_in_store>0</show_in_store>
197
+ <fields>
198
+ <excluded_admin_users translate="label comment">
199
+ <label>Excluded Admin Users</label>
200
+ <comment>Admin User Names (comma separated)</comment>
201
+ <frontend_type>text</frontend_type>
202
+ <sort_order>10</sort_order>
203
+ <show_in_default>1</show_in_default>
204
+ <show_in_website>0</show_in_website>
205
+ <show_in_store>0</show_in_store>
206
+ </excluded_admin_users>
207
+ </fields>
208
+ </trackers_advanced>
209
+ </groups>
210
+ </totango>
211
+ </sections>
212
+ </config>
app/etc/modules/Shopgo_Totango.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ShopGo
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ *
13
+ * @category Shopgo
14
+ * @package Shopgo_Totango
15
+ * @author Ammar <ammar@shopgo.me>
16
+ * Emad <emad@shopgo.me>
17
+ * Ahmad <ahmadalkaid@shopgo.me>
18
+ * Aya <aya@shopgo.me>
19
+ * ShopGo <support@shopgo.me>
20
+ * @copyright Copyright (c) 2015 ShopGo. (http://www.shopgo.me)
21
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <modules>
26
+ <Shopgo_Totango>
27
+ <active>true</active>
28
+ <codePool>community</codePool>
29
+ <depends>
30
+ <Shopgo_Core/>
31
+ </depends>
32
+ </Shopgo_Totango>
33
+ </modules>
34
+ </config>
package.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Shopgo_Totango</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Totango is a module that integrates Magento with Totango tracking service.</summary>
10
+ <description>&lt;p&gt;Totango module integrates Magento with Totango tracking service.&lt;/p&gt;&#xD;
11
+ &lt;h3&gt;What is Totango?&lt;/h3&gt;&#xD;
12
+ &lt;p&gt;Totango is the leading Customer Engagement platform that helps SaaS companies create an active and engaged user base.&lt;/p&gt;&#xD;
13
+ &lt;p&gt;Totango is built on the idea that customer success is all about understanding, measuring, and delivering business value to customers. To do this, Totango&#x2019;s platform is focused on identifying and monitoring &#x201C;leading indicators&#x201D; that help SaaS companies predict at-risk customers and proactively drive positive customer experiences.&lt;/p&gt;&#xD;
14
+ &lt;p&gt;Totango pulls in data from multiple systems to assemble a rich profile of every customer, including a predictive health rating and an &#x201C;engagement score,&#x201D; which is computed based on data science and machine learning.&lt;/p&gt;&#xD;
15
+ &lt;h3&gt;How does it work?&lt;/h3&gt;&#xD;
16
+ &lt;p&gt;Totango module tracks the following activities on Magento and sends tracking data to Totango:&lt;/p&gt;&#xD;
17
+ &lt;ul&gt;&#xD;
18
+ &lt;li&gt;Track completed and canceled orders.&lt;/li&gt;&#xD;
19
+ &lt;li&gt;Track new products.&lt;/li&gt;&#xD;
20
+ &lt;li&gt;Track new categories.&lt;/li&gt;&#xD;
21
+ &lt;li&gt;Track new attributes.&lt;/li&gt;&#xD;
22
+ &lt;li&gt;Track enabled couriers.&lt;/li&gt;&#xD;
23
+ &lt;li&gt;Track enabled payment methods.&lt;/li&gt;&#xD;
24
+ &lt;li&gt;Track successful admin logins.&lt;/li&gt;&#xD;
25
+ &lt;/ul&gt;&#xD;
26
+ &lt;h3&gt;Dependencies&lt;/h3&gt;&#xD;
27
+ &lt;ul&gt;&#xD;
28
+ &lt;li&gt;ShopGo Core&lt;/li&gt;&#xD;
29
+ &lt;/ul&gt;&#xD;
30
+ &lt;h3&gt;Notes&lt;/h3&gt;&#xD;
31
+ &lt;ul&gt;&#xD;
32
+ &lt;li&gt;Make sure that all dependencies mentioned above are installed before installing this module. Otherwise, it won't work.&lt;/li&gt;&#xD;
33
+ &lt;li&gt;More trackers will be added in the future.&lt;/li&gt;&#xD;
34
+ &lt;li&gt;You could customize this module and add your own trackers.&lt;/li&gt;&#xD;
35
+ &lt;li&gt;You could use/call this module's helper functions to send tracking calls to Totango.&lt;/li&gt;&#xD;
36
+ &lt;/ul&gt;&#xD;
37
+ &lt;p&gt;&lt;strong&gt;You could also get the latest version of this module from:&lt;/strong&gt;&lt;br /&gt;&#xD;
38
+ &lt;a href="https://github.com/shopgo-me/magento-totango-integration"&gt;https://github.com/shopgo-me/magento-totango-integration&lt;/a&gt;&lt;/p&gt;&#xD;
39
+ &lt;p&gt;&lt;strong&gt;For more info about Totango, visit this website:&lt;/strong&gt;&lt;br /&gt;&#xD;
40
+ &lt;a href="http://www.totango.com/"&gt;http://www.totango.com/&lt;/a&gt;&lt;/p&gt;</description>
41
+ <notes>First release</notes>
42
+ <authors><author><name>ShopGo</name><user>ShopGo</user><email>support@shopgo.me</email></author></authors>
43
+ <date>2015-09-17</date>
44
+ <time>11:53:14</time>
45
+ <contents><target name="magecommunity"><dir name="Shopgo"><dir name="Totango"><dir name="Helper"><file name="Data.php" hash="a107cbb74469eca6615569909a451987"/></dir><dir name="Model"><file name="Observer.php" hash="ce92c2fe886651c13ec4f2bb6e9d42d3"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Trackersactive.php" hash="7e053d45fd62a4492938dfb006c28c5b"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="067f7c3c9b06c50d95c72e392f6b7325"/><file name="config.xml" hash="3a00c0f23dfdca5ec9af05cb4f94f2bb"/><file name="system.xml" hash="d83a1e7718af2a8ccfda6dd0f4fd1f1c"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shopgo_Totango.xml" hash="057d7edbb264eebeaabb61ba002338a9"/></dir></target></contents>
46
+ <compatible/>
47
+ <dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php><package><name>Shopgo_Core</name><channel>community</channel><min>1.0.7</min><max/></package></required></dependencies>
48
+ </package>