workarea-listrak 5.0.1

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.
Files changed (163) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc.json +36 -0
  3. data/.esvmrc +5 -0
  4. data/.gitignore +32 -0
  5. data/CHANGELOG.md +322 -0
  6. data/Gemfile +14 -0
  7. data/README.md +130 -0
  8. data/Rakefile +53 -0
  9. data/app/assets/javascripts/workarea/admin/modules/listrak/list_events_select.js +83 -0
  10. data/app/assets/javascripts/workarea/storefront/listrak/adapters/listrak_adapter.js +110 -0
  11. data/app/assets/javascripts/workarea/storefront/listrak/listrak_config.js.erb +13 -0
  12. data/app/assets/javascripts/workarea/storefront/listrak/modules/listrak.js +64 -0
  13. data/app/controllers/workarea/admin/listrak/configurations_controller.rb +30 -0
  14. data/app/controllers/workarea/admin/listrak/events_controller.rb +17 -0
  15. data/app/helpers/workarea/listrak/analytics/helper.rb +44 -0
  16. data/app/models/workarea/listrak/configuration.rb +19 -0
  17. data/app/queries/workarea/categorization.decorator +7 -0
  18. data/app/services/workarea/listrak/data_api/customers.rb +26 -0
  19. data/app/services/workarea/listrak/data_api/orders.rb +26 -0
  20. data/app/services/workarea/listrak/data_api/products.rb +26 -0
  21. data/app/services/workarea/listrak/data_api.rb +63 -0
  22. data/app/services/workarea/listrak/email_api/contacts.rb +73 -0
  23. data/app/services/workarea/listrak/email_api/events.rb +44 -0
  24. data/app/services/workarea/listrak/email_api/lists.rb +21 -0
  25. data/app/services/workarea/listrak/email_api/messages.rb +50 -0
  26. data/app/services/workarea/listrak/email_api/transactional_messages.rb +32 -0
  27. data/app/services/workarea/listrak/email_api.rb +71 -0
  28. data/app/services/workarea/listrak/models/address.rb +83 -0
  29. data/app/services/workarea/listrak/models/contact.rb +67 -0
  30. data/app/services/workarea/listrak/models/contact_form.rb +24 -0
  31. data/app/services/workarea/listrak/models/customer_form.rb +209 -0
  32. data/app/services/workarea/listrak/models/event.rb +45 -0
  33. data/app/services/workarea/listrak/models/event_form.rb +25 -0
  34. data/app/services/workarea/listrak/models/list.rb +204 -0
  35. data/app/services/workarea/listrak/models/message_form.rb +147 -0
  36. data/app/services/workarea/listrak/models/order_form.rb +352 -0
  37. data/app/services/workarea/listrak/models/order_item.rb +197 -0
  38. data/app/services/workarea/listrak/models/product_form.rb +369 -0
  39. data/app/services/workarea/listrak/models/transactional_message_form.rb +21 -0
  40. data/app/services/workarea/listrak/oauth.rb +45 -0
  41. data/app/services/workarea/listrak/transactional_message.rb +83 -0
  42. data/app/view_models/workarea/admin/listrak_configuration_view_model.rb +17 -0
  43. data/app/views/workarea/admin/listrak/configurations/edit.html.haml +28 -0
  44. data/app/views/workarea/admin/listrak/events/index.json.jbuilder +4 -0
  45. data/app/views/workarea/admin/shared/_listrak_configuration_link.html.haml +1 -0
  46. data/app/views/workarea/storefront/checkouts/_listrak.html.haml +2 -0
  47. data/app/workers/workarea/listrak/customer_exporter.rb +22 -0
  48. data/app/workers/workarea/listrak/order_exporter.rb +22 -0
  49. data/app/workers/workarea/listrak/product_exporter.rb +50 -0
  50. data/app/workers/workarea/listrak/subscribe_email_signup.rb +34 -0
  51. data/app/workers/workarea/listrak/unsubscribe_email_signup.rb +27 -0
  52. data/bin/rails +18 -0
  53. data/bin/rake +16 -0
  54. data/bin/rspec +16 -0
  55. data/bin/rubocop +16 -0
  56. data/config/initializers/append_points.rb +28 -0
  57. data/config/initializers/configuration.rb +8 -0
  58. data/config/locales/en.yml +17 -0
  59. data/config/routes.rb +10 -0
  60. data/docs/Listrak Technical Integration Guide.docx +0 -0
  61. data/lib/generators/workarea/listrak/message/USAGE +9 -0
  62. data/lib/generators/workarea/listrak/message/message_generator.rb +15 -0
  63. data/lib/generators/workarea/listrak/message/templates/message.rb.erb +24 -0
  64. data/lib/workarea/listrak/analytics.rb +17 -0
  65. data/lib/workarea/listrak/bogus_data_api/customers.rb +9 -0
  66. data/lib/workarea/listrak/bogus_data_api/orders.rb +9 -0
  67. data/lib/workarea/listrak/bogus_data_api/products.rb +9 -0
  68. data/lib/workarea/listrak/bogus_data_api/proxy_client.rb +29 -0
  69. data/lib/workarea/listrak/bogus_data_api.rb +46 -0
  70. data/lib/workarea/listrak/bogus_email_api/contacts.rb +8 -0
  71. data/lib/workarea/listrak/bogus_email_api/events.rb +23 -0
  72. data/lib/workarea/listrak/bogus_email_api/lists.rb +63 -0
  73. data/lib/workarea/listrak/bogus_email_api/proxy_client.rb +29 -0
  74. data/lib/workarea/listrak/bogus_email_api/transactional_messages.rb +9 -0
  75. data/lib/workarea/listrak/bogus_email_api.rb +51 -0
  76. data/lib/workarea/listrak/engine.rb +12 -0
  77. data/lib/workarea/listrak/error.rb +39 -0
  78. data/lib/workarea/listrak/version.rb +5 -0
  79. data/lib/workarea/listrak.rb +57 -0
  80. data/readme/listrak-admin.png +0 -0
  81. data/script/admin_ci +9 -0
  82. data/script/ci +11 -0
  83. data/script/core_ci +9 -0
  84. data/script/plugins_ci +9 -0
  85. data/script/storefront_ci +9 -0
  86. data/test/dummy/Rakefile +6 -0
  87. data/test/dummy/bin/bundle +3 -0
  88. data/test/dummy/bin/rails +4 -0
  89. data/test/dummy/bin/rake +4 -0
  90. data/test/dummy/bin/setup +34 -0
  91. data/test/dummy/bin/update +29 -0
  92. data/test/dummy/config/application.rb +18 -0
  93. data/test/dummy/config/boot.rb +5 -0
  94. data/test/dummy/config/cable.yml +9 -0
  95. data/test/dummy/config/environment.rb +5 -0
  96. data/test/dummy/config/environments/development.rb +54 -0
  97. data/test/dummy/config/environments/production.rb +86 -0
  98. data/test/dummy/config/environments/test.rb +43 -0
  99. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  100. data/test/dummy/config/initializers/assets.rb +11 -0
  101. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  102. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  103. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  104. data/test/dummy/config/initializers/inflections.rb +16 -0
  105. data/test/dummy/config/initializers/mime_types.rb +4 -0
  106. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  107. data/test/dummy/config/initializers/session_store.rb +3 -0
  108. data/test/dummy/config/initializers/workarea.rb +5 -0
  109. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  110. data/test/dummy/config/locales/en.yml +23 -0
  111. data/test/dummy/config/puma.rb +47 -0
  112. data/test/dummy/config/routes.rb +5 -0
  113. data/test/dummy/config/secrets.yml +38 -0
  114. data/test/dummy/config/spring.rb +6 -0
  115. data/test/dummy/config.ru +5 -0
  116. data/test/dummy/db/seeds.rb +2 -0
  117. data/test/dummy/public/404.html +67 -0
  118. data/test/dummy/public/422.html +67 -0
  119. data/test/dummy/public/500.html +66 -0
  120. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  121. data/test/dummy/public/apple-touch-icon.png +0 -0
  122. data/test/dummy/public/favicon.ico +0 -0
  123. data/test/factories/workarea/factories/listrak.rb +15 -0
  124. data/test/helpers/workarea/listrak/analytics/helper_test.rb +38 -0
  125. data/test/integration/workarea/admin/listrak/configuration_integration_test.rb +26 -0
  126. data/test/integration/workarea/admin/listrak/events_integration_test.rb +21 -0
  127. data/test/lib/generators/workarea/listrak/message_generator_test.rb +26 -0
  128. data/test/queries/workarea/categorization_test.decorator +15 -0
  129. data/test/services/workarea/listrak/data_api/customers_test.rb +35 -0
  130. data/test/services/workarea/listrak/data_api/orders_test.rb +24 -0
  131. data/test/services/workarea/listrak/data_api/products_test.rb +27 -0
  132. data/test/services/workarea/listrak/email_api/contacts_test.rb +55 -0
  133. data/test/services/workarea/listrak/email_api/events_test.rb +51 -0
  134. data/test/services/workarea/listrak/email_api/lists_test.rb +45 -0
  135. data/test/services/workarea/listrak/email_api/messages_test.rb +28 -0
  136. data/test/services/workarea/listrak/email_api/transactional_messages_test.rb +50 -0
  137. data/test/services/workarea/listrak/oauth_test.rb +27 -0
  138. data/test/services/workarea/listrak/transactional_message_test.rb +48 -0
  139. data/test/support/workarea/listrak/test_order_confirmation_email.rb +116 -0
  140. data/test/support/workarea/listrak/vcr_config.rb +31 -0
  141. data/test/system/workarea/listrak_system_test.rb +75 -0
  142. data/test/test_helper.rb +16 -0
  143. data/test/vcr_cassettes/listrak/data_api/customers_import-successful.yml +88 -0
  144. data/test/vcr_cassettes/listrak/data_api/orders_import-successful.yml +90 -0
  145. data/test/vcr_cassettes/listrak/data_api/products_import-successful.yml +88 -0
  146. data/test/vcr_cassettes/listrak/email_api/contacts_get-successful.yml +87 -0
  147. data/test/vcr_cassettes/listrak/email_api/contacts_upsert-already_unsubscribed.yml +90 -0
  148. data/test/vcr_cassettes/listrak/email_api/contacts_upsert-successful.yml +87 -0
  149. data/test/vcr_cassettes/listrak/email_api/events_create-invalid_parameter.yml +90 -0
  150. data/test/vcr_cassettes/listrak/email_api/events_create-successful.yml +87 -0
  151. data/test/vcr_cassettes/listrak/email_api/events_get-successful.yml +88 -0
  152. data/test/vcr_cassettes/listrak/email_api/lists_all-successful.yml +88 -0
  153. data/test/vcr_cassettes/listrak/email_api/messages_create-successful.yml +88 -0
  154. data/test/vcr_cassettes/listrak/email_api/transactional_messages_create-successful.yml +89 -0
  155. data/test/vcr_cassettes/listrak/oauth-successful.yml +44 -0
  156. data/test/vcr_cassettes/listrak/oauth-unsuccessful.yml +46 -0
  157. data/test/vcr_cassettes/listrak/system_tests/footer_email_signup-successful.yml +171 -0
  158. data/test/vcr_cassettes/listrak/system_tests/footer_email_signup_overrides_unsubscribe.yml +255 -0
  159. data/test/vcr_cassettes/listrak/system_tests/unsubscribing.yml +593 -0
  160. data/test/workers/workarea/listrak/order_exporter_test.rb +31 -0
  161. data/test/workers/workarea/listrak/product_exporter_test.rb +62 -0
  162. data/workarea-listrak.gemspec +16 -0
  163. metadata +223 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2100d5e0ce9d7e3640ef0987da83414d700c9c3bcd166d59f5d7517d53d46f61
4
+ data.tar.gz: 628151e8705a7bd39a7c8365b5624701e38009aa70acf57c637b0db4d830e89a
5
+ SHA512:
6
+ metadata.gz: 14769fb83d044f5cccfe0dfaccdcdcb51f3e2ba68df6738b2c0507ca1aaa67fb8e7b4669efa828d247ea8209cdb4c2dbdbb1e495f8249d38838bc2e362fe0ffd
7
+ data.tar.gz: 4d0141ffd9abfaa4facdc9594768c70424f5b4d0c6e5b1874b2ea40ba424706f65a1fc281e9ffc6d1c4529a27eefd6afb575bc36c2f08df94b3a920c86ae325a
data/.eslintrc.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "semi": ["error", "always"],
5
+ "eqeqeq": ["error", "always"]
6
+ },
7
+ "globals": {
8
+ "window": true,
9
+ "document": true,
10
+ "WORKAREA": true,
11
+ "$": true,
12
+ "jQuery": true,
13
+ "_": true,
14
+ "feature": true,
15
+ "JST": true,
16
+ "Turbolinks": true,
17
+ "I18n": true,
18
+ "Chart": true,
19
+ "Dropzone": true,
20
+ "strftime": true,
21
+ "Waypoint": true,
22
+ "wysihtml": true,
23
+ "LocalTime": true,
24
+ "describe": true,
25
+ "after": true,
26
+ "afterEach": true,
27
+ "before": true,
28
+ "beforeEach": true,
29
+ "it": true,
30
+ "expect": true,
31
+ "sinon": true,
32
+ "fixture": true,
33
+ "chai": true,
34
+ "_ltk": true
35
+ }
36
+ }
data/.esvmrc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "default": {
3
+ "version": "5.2"
4
+ }
5
+ }
data/.gitignore ADDED
@@ -0,0 +1,32 @@
1
+ *.gem
2
+ *.rbc
3
+ **/*/.DS_Store
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /spec/examples.txt
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+ Gemfile.lock
14
+ test/dummy/tmp/export/*.csv
15
+ .DS_Store
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+ .byebug_history
28
+ .envrc
29
+ log
30
+ tmp
31
+ test/dummy/public/system/
32
+ coverage
data/CHANGELOG.md ADDED
@@ -0,0 +1,322 @@
1
+ Workarea Listrak 5.0.1 (2019-08-21)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Open Source!
5
+
6
+
7
+
8
+ Workarea Listrak 5.0.0 (2019-06-25)
9
+ --------------------------------------------------------------------------------
10
+
11
+ * Listrak REST APIs
12
+
13
+ Replace the SOAP implementation with Lisrak's REST APIs
14
+
15
+ LISTRAK-52
16
+ Eric Pigeon
17
+
18
+
19
+
20
+ Workarea Listrak 4.0.2 (2019-02-19)
21
+ --------------------------------------------------------------------------------
22
+
23
+ * Perform the `_ltk` check when events are fired, instead of when the adapter is registered.
24
+
25
+ LISTRAK-59
26
+ Brian Berg
27
+
28
+ * Add condition to check the listrak SDK is available before running adapter callbacks
29
+
30
+ LISTRAK-57
31
+ Jake Beresford
32
+
33
+
34
+
35
+ Workarea Listrak 4.0.1 (2018-01-11)
36
+ --------------------------------------------------------------------------------
37
+
38
+ * Refactor Listrak SCA reporting
39
+
40
+ Our original implementation was not passing along configured
41
+ `email_capture_ids` to javascript, this updates that config markup to
42
+ match patterns present in other workarea plugins.
43
+
44
+ Listrak adapter was using route syntax from v2 when storefront was
45
+ called `store_front`. Updating to the new v3 route resolves issues with
46
+ updating cart items analytics.
47
+
48
+ There was room for improvement with how our listrak module handled
49
+ adding SCA email address abandoner listener to every email field.
50
+ Before this plugin relied on host app to pass each field name in the
51
+ configuration, this update enchances that experience by also including a
52
+ search for _all_ email fields within a given `$scope`.
53
+
54
+ LISTRAK-47
55
+
56
+ Refactor JS
57
+
58
+ The mutation of the emailIds array made the updated JS hard to follow
59
+ and understand at what point what typeof `configIds`.
60
+
61
+ Names and var creation has been cleaned up to make the selector string
62
+ building more readable.
63
+
64
+ LISTRAK-47
65
+ Jordan Stewart
66
+
67
+
68
+ Workarea Listrak 4.0.0 (2017-07-31)
69
+ --------------------------------------------------------------------------------
70
+
71
+
72
+ Workarea Listrak 4.0.0 (2017-07-31)
73
+ --------------------------------------------------------------------------------
74
+
75
+
76
+ Workarea Listrak 4.0.0 (2017-07-31)
77
+ --------------------------------------------------------------------------------
78
+
79
+ * LISTRAK-45
80
+ Eric Pigeon
81
+
82
+ * Use different list ID in transactional email
83
+
84
+ Transactional emails always use a different List ID on Listrak than the
85
+ normal email subscribe list. This new configuration setting is available
86
+ in the `:listrak` secrets as `:transactional_list_id`.
87
+
88
+ LISTRAK-43
89
+ Tom Scott
90
+
91
+
92
+ WebLinc Listrak 3.1.4.pre (2017-03-14)
93
+ --------------------------------------------------------------------------------
94
+
95
+ * Fix regressions to older arity syntax
96
+
97
+ After the LISTRAK-42 fix was deployed as workarea-listrak v3.1.3, another
98
+ error popped up due to perform_api_call being called with the wrong
99
+ number of arguments.
100
+
101
+ Report: https://discourse.workarea.com/t/listrak-gem-contact-api-call-bug/680/3
102
+
103
+ LISTRAK-42
104
+ Tom Scott
105
+
106
+ * Write tagged log messages when making requests
107
+
108
+ When sending requests to Listrak's SOAP API, log all request/response
109
+ params so that we can easily debug the data in case of failure. This is
110
+ especially true for transactional messages. Also, make sure log messages
111
+ are tagged with "[LISTRAK]" so they can be easily found when grepping
112
+ through log history.
113
+
114
+ LISTRAK-41
115
+ Tom Scott
116
+
117
+ * Display price in fixed-point notation LISTRAK-40 SHADES-684
118
+ Tom Scott
119
+
120
+ * Use correct attribute for item price.
121
+
122
+ Price was not getting passed in AddItem() calls causing improper reports
123
+ on the Listrak admin side.
124
+
125
+ LISTRAK-40
126
+ SHADES-684
127
+ Tom Scott
128
+
129
+ * Merge branch 'bugfix/LISTRAK-39-dont-run-workers-except-in-production'
130
+
131
+ Added more docs.
132
+ Tom Scott
133
+
134
+ * Dont run workers except in production
135
+
136
+ all the environments were exporting to the same ftp with the same file
137
+ name, only enable the scheduled jobs when the environment is production.
138
+
139
+ LISTRAK-39
140
+ Eric Pigeon
141
+
142
+ * Fix typo in setting of Order.ItemTotal
143
+
144
+ The ItemTotal in this handler was being set to a blank value due to the
145
+ typo on the `payload.subtotal_price` key.
146
+
147
+ LISTRAK-37
148
+ Tom Scott
149
+
150
+ * Improve errors in Workarea::Listrak::Gateway
151
+
152
+ LISTRAK-34
153
+ Tom Scott
154
+
155
+ * Fix multiple email captures in Listrak
156
+
157
+ It seems that the CaptureEmail calls over each email_capture_id was
158
+ causing multiple requests to be sent to Listrak for each completed
159
+ field. This will prevent calls for nonexistent items by checking for
160
+ whether the field exists on the page prior to calling
161
+ `_ltk.SCA.CaptureEmail()` on it.
162
+
163
+ This fixes one of the tasks in SHADES-668 as well.
164
+
165
+ LISTRAK-36
166
+ Tom Scott
167
+
168
+ * Rename checkoutConfirmation to checkoutOrderPlaced
169
+
170
+ The JS code wasn't firing on confirmation because the analytics event
171
+ was misnamed, renamed it ot what's found in base so it will "Just Work".
172
+
173
+ This will also resolve SHADES-688 when it's deployed in **v3.0.1**.
174
+
175
+ LISTRAK-35
176
+ Tom Scott
177
+
178
+ * Add Jesse's changes for firing the ltk event.
179
+
180
+ LISTRAK-30
181
+ Tom Scott
182
+
183
+ * LISTRAK-30 Refactor Listrak JS code as an analytics adapter
184
+ Eric Pigeon
185
+
186
+ * Append sdk partial to storefront.javascript
187
+
188
+ This is apparently a more accurate place to be putting this code, in
189
+ addition, it places the code on the bottom of the page. Not really sure
190
+ how "breaking" of a change this is gonna be so hold off on merging
191
+ before we're sure.
192
+
193
+ LISTRAK-32
194
+ Tom Scott
195
+
196
+ * Hard-code WSDL URL
197
+
198
+ This URL never changes, there's no reason to supply it from secrets.
199
+
200
+ LISTRAK-31
201
+ Tom Scott
202
+
203
+ * Fix cart recreate tag
204
+
205
+ This is based on the implementation in Tahari, the cart recreate code
206
+ supplied by Listrak in their docs is apparently incorrect. Since the
207
+ `_ltk` object is already defined, we don't need to wait for any kind of
208
+ event. Instead, we should be calling Listrak SCA methods as soon as we
209
+ can.
210
+
211
+ LISTRAK-28
212
+ Tom Scott
213
+
214
+ * Use full url for product images
215
+
216
+ LISTRAK-25
217
+ Eric Pigeon
218
+
219
+ * Shedule product export nightly
220
+
221
+ LISTRAK-24
222
+ Eric Pigeon
223
+
224
+ * LISTRAK-123: Ensure product URL is fully-qualified
225
+
226
+ Had an issue with testing this one...had to hard-set the
227
+ `Workarea.config.domain`.
228
+ Tom Scott
229
+
230
+ * LISTRAK-20: Use absolute paths for CSVs
231
+
232
+ Can cause issues building files on the server, solved by always
233
+ prepending `Rails.root` in file_to_upload.
234
+ Tom Scott
235
+
236
+ * Fix ftp hash symbol access
237
+
238
+ fix trying to access hash from secrets as symbol keys
239
+ clean up decorator to follow convention
240
+ test decorated categorization method
241
+ fix dummy mongoid.yml to be mongoid 5 compliant
242
+ clean up gemspec authors
243
+
244
+ LISTRAK-19
245
+ Eric Pigeon
246
+
247
+ * Update item price method and ensure _ltk var exists
248
+
249
+ Running tests on this one uncovered an issue that would have caused the
250
+ cart summary view to error out. Updated the `item.unit_price` call to
251
+ `item.total_price` everywhere, since that field is defined on
252
+ Order::Item and OrderItemViewModel doesn't define a unit_price method.
253
+
254
+ LISTRAK-17
255
+ Tom Scott
256
+
257
+ * LISTRAK-17: Trigger cart updates when the cart summary view is rendered
258
+ bberg
259
+
260
+ * LISTRAK-16: Configuration refactor. Tom deflips table.
261
+ Mark Platt
262
+
263
+ * LISTRAK-16: Add secrets to an config in initializer. Update js to use config
264
+ Mark Platt
265
+
266
+ * Fix render_listrak_tracking_code overriding
267
+
268
+ This wasn't able to be overridden properly in the host app, and I had to
269
+ resort to a `nil?` check in order to allow it to be overridden. Not sure
270
+ of how the configuration hierarchy works in this case, but it's much
271
+ easier and clearer in the engine.rb to write it this way IMHO.
272
+
273
+ LISTRAK-13
274
+ Tom Scott
275
+
276
+ * v0.13.0: Render Listrak JS conditionally
277
+
278
+ Some clients wish to use Google Tag Manager in order to render
279
+ the Listrak JavaScript tracking code. While this was always
280
+ configurable, the setting has been renamed to
281
+ `listrak_render_tracking_code` in order to prevent naming conflicts and
282
+ be more descriptive of the domain in which it is active.
283
+
284
+ This is a major-version release in case anyone was already using the old,
285
+ badly-named config setting. Renamed it to be "namespaced" within
286
+ listrak, so it's easy to see where the setting is being used.
287
+
288
+ LISTRAK-11
289
+ Tom Scott
290
+
291
+ * Use configured merchant_id in Listrak JS tracker
292
+
293
+ Listrak needs to include a bit of JS on every page for tracking user
294
+ movements through the app. The merchant ID included in this tracking
295
+ code was hard-coded into the gem and the same for every user of the gem.
296
+ Refactored to use a secret from `config/secrets.yml` instead of the
297
+ hard-coded value. Users of the workarea-listrak gem will need to update
298
+ `config/secrets.yml` and insert a `:merchant_id:` into the `listrak:`
299
+ hash. This ID can be obtained from your client's Listrak account.
300
+
301
+ Releasing this as a minor version upgrade (v0.12.0) because it depends on
302
+ configuration in secrets.yml that wasn't there before, and will break
303
+ apps in production without a corresponding change to the encrypted data
304
+ bag for this app.
305
+
306
+ LISTRAK-10
307
+ Tom Scott
308
+
309
+ * Disable Listrak JS in testing.
310
+
311
+ When testing the application with Capybara, sometimes Listrak can fail
312
+ the build for random reasons. This definitely shouldn't block feature
313
+ testing an application, as this kind of integration can fail for a wide
314
+ variety of reasons, and we want our tests to depend on the network as
315
+ little as possible. This change surrounds the assignment of the JS
316
+ partial to the application layout with a conditional, that omits adding
317
+ the partial if we are currently in the test environment.
318
+
319
+ Example: https://bamboo.tools.workarea.com/browse/ESTUYO-DEV-172/log
320
+
321
+ LISTRAK-9
322
+ Tom Scott
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+ source "https://gems.weblinc.com"
3
+
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'yard', source: 'https://rubygems.org'
8
+ end
9
+
10
+ gem 'byebug'
11
+
12
+ group :test do
13
+ gem "simplecov", require: false
14
+ end
data/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # Listrak
2
+
3
+ Integrate the [Listrak][] ERP with the Workarea platform. This plugin
4
+ currently implements the following Listrak features:
5
+
6
+ - Page view tracking
7
+ - Cart abandonment
8
+ - Transactional email delivery
9
+ - Automatically subscribing users to a distribution list
10
+
11
+ ## Installation
12
+
13
+ Add the following to Gemfile:
14
+
15
+ ```ruby
16
+ gem 'workarea-listrak', '~> 5.0'
17
+ ```
18
+
19
+ ### Secrets
20
+
21
+ ```yaml
22
+ listrak:
23
+ data_api:
24
+ client_id:
25
+ client_secret:
26
+ email_api:
27
+ client_id:
28
+ client_secret:
29
+ ```
30
+
31
+ ### Configuration
32
+
33
+ Most listrak configuration is set via the admin; you will need to set the
34
+ `Default List` in the admin after installing the plugin.
35
+
36
+ ![lisrak admin](./readme/listrak-admin.png)
37
+
38
+ ```ruby
39
+ Workarea.config do |config|
40
+ config.listrak.analytics = {
41
+ merchant_id: 'LISTRAK MERCHANT ID',
42
+ email_capture_ids: 'ID's OF EMAIL FIELDS USED FOR JAVASCRIPT ABANDONMENT'
43
+ }
44
+ end
45
+ ```
46
+
47
+ ### Subscribing email addresses to a distribution list
48
+
49
+ When customers sign up for the newsletter within the popup dialog or
50
+ create a new user account, `Workarea::Listrak` will send the email and
51
+ any other user-specific information to Listrak. This occurs immediately
52
+ in a background job during creation of a `Email::Signup`.
53
+
54
+ ### Data Exporting
55
+
56
+ The following will be sent to Listrak via API whenever they are created or saved:
57
+
58
+ * Customers
59
+ * Orders (on order place)
60
+ * Products
61
+
62
+ ### Transactional Email Delivery
63
+
64
+ This library is capable of replacing the internal application mailers
65
+ with API calls to Listrak's email delivery service, passing it the data
66
+ that it needs. To generate a new transactional message class, run:
67
+
68
+ ```bash
69
+ $ bin/rails generate workarea:listrak:message OrderConfirmation
70
+ ```
71
+
72
+ This will generate a class `app/messages/workarea/order_confirmation_message.rb`
73
+
74
+ You will need to define the `message_id` and `messsage_attribute` as well as define the methods
75
+ for these values. For example:
76
+
77
+ ```ruby
78
+ module Workarea
79
+ module Listrak
80
+ class OrderConfirmationEmail
81
+ include Listrak::TransactionalMessage
82
+
83
+ attr_reader :order
84
+
85
+ message_id 11838256
86
+ message_attributes(
87
+ order_date: 2446175
88
+ )
89
+
90
+ def initialize(order)
91
+ @order = order
92
+ end
93
+
94
+ private
95
+
96
+ def email_address
97
+ order.email
98
+ end
99
+
100
+ def order_date
101
+ order.placed_at.to_s
102
+ end
103
+ end
104
+ end
105
+ ```
106
+
107
+ To send the message, call the `#deliver` method:
108
+
109
+ ```ruby
110
+ OrderConfirmationMessage.new(order).deliver
111
+ ```
112
+
113
+ ### JavaScript Analytics Integration
114
+
115
+ All of Listrak's JS code blocks respond to the `listrakAsyncListener`
116
+ event, which is triggered after Listrak's external "SDK" code is loaded
117
+ onto the page. Workarea's analytics adapter encapsulates this as a public
118
+ method called `addListrakListener`.
119
+
120
+ It's important that the init function from Storefront's **analytics.js**
121
+ is called prior to the **listrak.js** init, so events can be registered
122
+ before the SDK is loaded. This happens out-of-box, but is mentioned here
123
+ if an implementation team creates their own **application.js.erb**
124
+ manifest manually, or other modules that implement more Listrak features
125
+ (like recommendations) are added to your application in the future.
126
+
127
+ To reiterate, **listrak.js needs to be your last initialized JS
128
+ module**.
129
+
130
+ [Listrak]: http://listrak.com
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require "bundler/setup"
4
+ rescue LoadError
5
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
+ end
7
+
8
+ require 'rdoc/task'
9
+
10
+ RDoc::Task.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = 'Tasker'
13
+ rdoc.options << '--line-numbers'
14
+ rdoc.rdoc_files.include('README.md')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
+ load "rails/tasks/engine.rake"
20
+ load "rails/tasks/statistics.rake"
21
+ load "workarea/changelog.rake"
22
+
23
+ require "rake/testtask"
24
+
25
+ Rake::TestTask.new(:test) do |t|
26
+ t.libs << "lib"
27
+ t.libs << "test"
28
+ t.pattern = "test/**/*_test.rb"
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
33
+
34
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
35
+ require "workarea/listrak/version"
36
+
37
+ desc "Release version #{Workarea::Listrak::VERSION} of the gem"
38
+ task :release do
39
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
40
+
41
+ #Rake::Task['workarea:changelog'].execute
42
+ #system 'git add CHANGELOG.md'
43
+ #system 'git commit -m "Update CHANGELOG"'
44
+ #system 'git push origin HEAD'
45
+
46
+ system "git tag -a v#{Workarea::Listrak::VERSION} -m 'Tagging #{Workarea::Listrak::VERSION}'"
47
+ system "git push --tags"
48
+
49
+ system "gem build workarea-listrak.gemspec"
50
+ system "gem push workarea-listrak-#{Workarea::Listrak::VERSION}.gem"
51
+ system "gem push workarea-listrak-#{Workarea::Listrak::VERSION}.gem --host #{host}"
52
+ system "rm workarea-listrak-#{Workarea::Listrak::VERSION}.gem"
53
+ end
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @namespace WORKAREA.listrakListEventsSelect
3
+ */
4
+
5
+ WORKAREA.registerModule('listrakListEventsSelect', (function () {
6
+ 'use strict';
7
+
8
+ var injectHiddenInput = function (index, select) {
9
+ // allows select[multiple=true] elements to post empty values
10
+ if ( ! $(select).is('[multiple]')) { return; }
11
+
12
+ $(select).before(function () {
13
+ return JST['workarea/core/templates/hidden_input']({
14
+ name: select.name,
15
+ value: ''
16
+ });
17
+ });
18
+ },
19
+
20
+ getConfig = function () {
21
+ var settings = _.assign({}, WORKAREA.config.remoteSelects, {
22
+ placeholder: I18n.t('workarea.admin.listrak_configuration.edit.events_select_placeholder'),
23
+ allowClear: true,
24
+ multiple: true,
25
+ width: false,
26
+ ajax: {
27
+ url: function () {
28
+ return WORKAREA.routes.admin.listrakListEventsPath({ list_id: listId(), format: "json" });
29
+ },
30
+ dataType: 'json',
31
+ delay: 250,
32
+ processResults: function (data) {
33
+ return {
34
+ results: _.map(data.results, function (item) {
35
+ return {
36
+ id: item.value,
37
+ text: item.label
38
+ };
39
+ })
40
+ };
41
+ },
42
+ cache: true,
43
+ escapeMarkup: function (markup) {
44
+ return markup;
45
+ }
46
+ }
47
+ });
48
+
49
+ return settings;
50
+ },
51
+
52
+ listId = function () {
53
+ return $('#default_list_id').val();
54
+ },
55
+
56
+ initSelect2 = function (index, select) {
57
+ $(select)
58
+ .each(injectHiddenInput)
59
+ .select2(getConfig());
60
+ },
61
+
62
+ resetEventIds = function () {
63
+ $('[data-listrak-events-select]')
64
+ .val(null).trigger('change');
65
+ },
66
+
67
+ destroy = function (event) {
68
+ $('[data-listrak-events-select]', event.currentTarget)
69
+ .select2('destroy');
70
+ },
71
+
72
+ init = function ($scope) {
73
+ $('#default_list_id').on("change", resetEventIds);
74
+ $('[data-listrak-events-select]', $scope)
75
+ .each(initSelect2);
76
+ };
77
+
78
+ $(document).on('turbolinks:before-cache', destroy);
79
+
80
+ return {
81
+ init: init
82
+ };
83
+ }()));