@ordergroove/offers 2.27.15 → 2.27.16

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/examples/index.js CHANGED
@@ -68,11 +68,13 @@ const exampleTemplates = [
68
68
  'Offers example',
69
69
  {
70
70
  name: 'empty',
71
- selector: 'og-offer:not([location])'
71
+ selector: 'og-offer:not([location])',
72
+ id: '1'
72
73
  },
73
74
  {
74
75
  name: 'built-in',
75
76
  selector: 'og-offer[location="initial"]',
77
+ id: '2',
76
78
  config: {
77
79
  settings: {
78
80
  ...settings,
@@ -84,6 +86,7 @@ const exampleTemplates = [
84
86
  {
85
87
  name: 'checkbox',
86
88
  selector: 'og-offer[location="initial-checkbox"]',
89
+ id: '3',
87
90
  config: {
88
91
  settings: {
89
92
  ...settings,
@@ -97,6 +100,7 @@ const exampleTemplates = [
97
100
  {
98
101
  name: 'select',
99
102
  selector: 'og-offer[location="initial-select"]',
103
+ id: '4',
100
104
  config: {
101
105
  settings: {
102
106
  ...settings,
@@ -108,6 +112,7 @@ const exampleTemplates = [
108
112
  {
109
113
  name: 'cart',
110
114
  selector: 'og-offer[location="cart"]',
115
+ id: '5',
111
116
  defaultPreviewMode: 'subscribed',
112
117
  config: {
113
118
  settings: {
@@ -120,6 +125,7 @@ const exampleTemplates = [
120
125
  {
121
126
  name: 'side-by-side',
122
127
  selector: 'og-offer[location="side-by-side"]',
128
+ id: '6',
123
129
  config: {
124
130
  settings: {
125
131
  ...settings,
@@ -135,6 +141,7 @@ const exampleTemplates = [
135
141
  {
136
142
  name: 'read-only',
137
143
  selector: 'og-offer[location="read-only"]',
144
+ id: '7',
138
145
  defaultPreviewMode: 'subscribed',
139
146
  config: {
140
147
  settings: {
@@ -151,6 +158,7 @@ const exampleTemplates = [
151
158
  {
152
159
  name: 'buttons',
153
160
  selector: 'og-offer[location="buttons"]',
161
+ id: '8',
154
162
  config: {
155
163
  settings: {
156
164
  ...settings,
@@ -167,6 +175,7 @@ const exampleTemplates = [
167
175
  {
168
176
  name: 'first-test',
169
177
  selector: 'og-offer[location="first-test"]',
178
+ id: '9',
170
179
  config: {
171
180
  settings: {
172
181
  ...settings,
@@ -181,6 +190,7 @@ const exampleTemplates = [
181
190
  {
182
191
  name: 'second-test no tooltip',
183
192
  selector: 'og-offer[location="second-test"]',
193
+ id: '10',
184
194
  config: {
185
195
  settings: {
186
196
  ...settings,
@@ -196,6 +206,7 @@ const exampleTemplates = [
196
206
  {
197
207
  name: 'Select mode',
198
208
  selector: 'og-offer[location="select1"]',
209
+ id: '11',
199
210
  markup: `
200
211
  <og-optin-select>
201
212
  <option value="optedOut">Buy one time</option>
@@ -206,6 +217,7 @@ const exampleTemplates = [
206
217
  {
207
218
  name: 'Custom markup',
208
219
  selector: 'og-offer[location="custom1"]',
220
+ id: '12',
209
221
  markup: `
210
222
  <og-when test="regularEligible">
211
223
  <p>
@@ -259,6 +271,7 @@ Add item to order on
259
271
  name: 'Upsell modal - radio',
260
272
  defaultPreviewMode: 'upsell',
261
273
  selector: 'og-offer[location="upsell-radio"]',
274
+ id: '13',
262
275
  markup: `
263
276
  <og-when test="upsellEligible">
264
277
  <og-upsell-button target="#upsell-radio">
@@ -283,6 +296,7 @@ Add item to order on
283
296
  name: 'Upsell modal - select',
284
297
  defaultPreviewMode: 'upsell',
285
298
  selector: 'og-offer[location="upsell-select"]',
299
+ id: '14',
286
300
  markup: `
287
301
  <og-when test="upsellEligible">
288
302
  <og-upsell-button target="#upsell-select">
@@ -297,6 +311,7 @@ Add item to order on
297
311
  name: 'Upsell modal - toggle',
298
312
  defaultPreviewMode: 'upsell',
299
313
  selector: 'og-offer[location="upsell-toggle"]',
314
+ id: '15',
300
315
  markup: `
301
316
  <og-when test="upsellEligible">
302
317
  <og-upsell-button target="#upsell-toggle">
@@ -315,6 +330,7 @@ Add item to order on
315
330
  {
316
331
  name: 'Product-specific default frequencies',
317
332
  selector: 'og-offer[location="psdf"]',
333
+ id: '16',
318
334
  markup: `
319
335
  <og-when test="regularEligible">
320
336
  <og-select-frequency default-text=" Most common!">
@@ -331,6 +347,7 @@ Add item to order on
331
347
  {
332
348
  name: 'og-optin-button',
333
349
  selector: 'og-offer[location=og-optin-button]',
350
+ id: '17',
334
351
  markup: `
335
352
  <og-optin-button>
336
353
  I want to subscribe to this product
@@ -340,6 +357,7 @@ Add item to order on
340
357
  {
341
358
  name: 'Frequency Status',
342
359
  selector: 'og-offer[location="frequency"]',
360
+ id: '18',
343
361
  markup: `
344
362
  <og-frequency-status>
345
363
  <span slot="not-subscribed">you are not subscribed </span>
@@ -348,6 +366,7 @@ Add item to order on
348
366
  {
349
367
  name: 'Tooltip',
350
368
  selector: 'og-offer[location="tooltip-placement"]',
369
+ id: '19',
351
370
  markup: [
352
371
  ['top-left', 'top', 'top-right'],
353
372
  ['left', '', 'right'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordergroove/offers",
3
- "version": "2.27.15",
3
+ "version": "2.27.16",
4
4
  "description": "offer state component",
5
5
  "author": "Eugenio Lattanzio <eugenio63@gmail.com>",
6
6
  "homepage": "https://github.com/ordergroove/plush-toys#readme",
@@ -45,5 +45,5 @@
45
45
  "devDependencies": {
46
46
  "@ordergroove/offers-templates": "^0.4.15"
47
47
  },
48
- "gitHead": "9ec6370c33f9ac82e46d35f1085e759c8b686a67"
48
+ "gitHead": "9d55bfe3c5bac0e80acbe1d6bfdddc8ecf222842"
49
49
  }
@@ -54,7 +54,8 @@ export class Offer extends TemplateElement {
54
54
  frequency: { type: String, reflect: true },
55
55
  productFrequency: { type: String },
56
56
  isCart: { type: Boolean, attribute: 'cart' },
57
- optedin: { type: Object }
57
+ optedin: { type: Object },
58
+ variationId: { type: String }
58
59
  };
59
60
  }
60
61
 
@@ -236,7 +237,8 @@ export class Offer extends TemplateElement {
236
237
 
237
238
  applyTemplate(template) {
238
239
  super.applyTemplate(template);
239
- const { locale } = template;
240
+ const { id: variationId, locale } = template;
241
+ this.variationId = variationId;
240
242
  this.locale = locale;
241
243
  const event = new CustomEvent('template-changed');
242
244
  this.dispatchEvent(event);
@@ -227,13 +227,27 @@ export async function synchronizeCartOptin(action: any, store: any) {
227
227
  /**
228
228
  * Returns a tracking event adhering to the below format:
229
229
  *
230
- * og__<ts in seconds>: "<product_id>,<action>,<location>,<selling_plan optional>"
230
+ * og__<ts in seconds>: "<product_id>,<action>,<location>,<selling_plan optional>,<variation_id optional>"
231
231
  *
232
232
  * Examples:
233
- * og__165653130: "offer_show,pdp,123456789"
234
- * og__165653137: "optin,pdp,123,456"
235
- * og__165653138: "optout,pdp,123,"
236
- * og__165653139: "optin,cart,123,456",
233
+ *
234
+ * - optin_product with selling plan ID 123 and variation ID 456:
235
+ * og__165653130: "optin_product,pdp,123,456"
236
+ *
237
+ * - optin_product with no selling plan and variation ID 456:
238
+ * og__165653137: "optin_product,pdp,,456"
239
+ *
240
+ * - optin_product with selling plan ID 123 and no variation ID:
241
+ * og__165653139: "optin_product,pdp,123,"
242
+ *
243
+ * - optin_product with no selling plan and no variation ID:
244
+ * og__165653141: "optin_product,pdp,,"
245
+ *
246
+ * - optout_product with variation id 456:
247
+ * og__165653135: "optout_product,pdp,,456"
248
+ *
249
+ * - product_change_frequency with selling plan ID 123 and variation ID 456:
250
+ * og__165653131: "product_change_frequency,pdp,123,456"
237
251
  *
238
252
  * @param action a Redux action
239
253
  * @return {Array} an array with positional values key, value
@@ -243,16 +257,19 @@ export function getTrackingEvent(action): Array<string> {
243
257
  if (!product_id) return [];
244
258
  const key = `og__${Math.ceil(new Date().getTime() / 1000)}`;
245
259
  const location = action.payload.offer?.location || '';
260
+ const variation = action.payload.offer?.variationId || '';
246
261
  const value = [product_id, action.type.toLowerCase(), location];
247
262
 
248
263
  switch (action.type) {
249
264
  case REQUEST_OFFER:
250
265
  case OPTOUT_PRODUCT:
251
- value.push('');
266
+ value.push(''); // No selling plan should be associated with these actions
267
+ value.push(variation);
252
268
  break;
253
269
  case OPTIN_PRODUCT:
254
270
  case PRODUCT_CHANGE_FREQUENCY:
255
271
  value.push(action.payload.frequency);
272
+ value.push(variation);
256
273
  break;
257
274
  default:
258
275
  return []; // we dont track anything else