@constructor-io/constructorio-client-javascript 2.29.9 → 2.29.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,6 +8,9 @@ A JavaScript client for [Constructor.io](http://constructor.io/). [Constructor.i
8
8
 
9
9
  > This client is intended for use in a browser environment but can also be used in React Native based mobile applications. Additional information about utilization in a React Native context can be found on the [Wiki](https://github.com/Constructor-io/constructorio-client-javascript/wiki/Utilization-in-a-DOM-less-environment). If you want a JavaScript client for server side integrations please use [@constructor-io/constructorio-node](https://github.com/Constructor-io/constructorio-node)
10
10
 
11
+ ## Documentation
12
+ Full API documentation is available on [Github Pages](https://constructor-io.github.io/constructorio-client-javascript/index.html)
13
+
11
14
  ## 1. Install
12
15
 
13
16
  This package can be installed via npm: `npm i @constructor-io/constructorio-client-javascript`. Once installed, simply import or require the package into your repository.
@@ -45,8 +48,6 @@ window.addEventListener('cio.client.search.getSearchResults.completed', (event)
45
48
  }, false);
46
49
  ```
47
50
 
48
- Full API documentation is available on [Github Pages](https://constructor-io.github.io/constructorio-client-javascript/index.html)
49
-
50
51
  ## Development / npm commands
51
52
 
52
53
  ```bash
@@ -1,9 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
6
-
7
3
  /* eslint-disable no-param-reassign */
8
4
  var CRC32 = require('crc-32');
9
5
 
@@ -100,13 +96,13 @@ var utils = {
100
96
  },
101
97
  hasOrderIdRecord: function hasOrderIdRecord(orderId) {
102
98
  var orderIdHash = CRC32.str(orderId.toString());
103
- var purchaseEventStorage = store.session.get(purchaseEventStorageKey);
99
+ var purchaseEventStorage = store.local.get(purchaseEventStorageKey);
104
100
 
105
101
  if (typeof purchaseEventStorage === 'string') {
106
102
  purchaseEventStorage = JSON.parse(purchaseEventStorage);
107
103
  }
108
104
 
109
- if (purchaseEventStorage && purchaseEventStorage[orderIdHash]) {
105
+ if (purchaseEventStorage && purchaseEventStorage.includes(orderIdHash)) {
110
106
  return true;
111
107
  }
112
108
 
@@ -114,7 +110,7 @@ var utils = {
114
110
  },
115
111
  addOrderIdRecord: function addOrderIdRecord(orderId) {
116
112
  var orderIdHash = CRC32.str(orderId.toString());
117
- var purchaseEventStorage = store.session.get(purchaseEventStorageKey);
113
+ var purchaseEventStorage = store.local.get(purchaseEventStorageKey);
118
114
 
119
115
  if (typeof purchaseEventStorage === 'string') {
120
116
  purchaseEventStorage = JSON.parse(purchaseEventStorage);
@@ -122,18 +118,22 @@ var utils = {
122
118
 
123
119
  if (purchaseEventStorage) {
124
120
  // If the order already exists, do nothing
125
- if (purchaseEventStorage[orderIdHash]) {
121
+ if (purchaseEventStorage.includes(orderIdHash)) {
126
122
  return;
127
123
  }
128
124
 
129
- purchaseEventStorage[orderIdHash] = true;
125
+ if (purchaseEventStorage.length >= 10) {
126
+ purchaseEventStorage = purchaseEventStorage.slice(-9);
127
+ }
128
+
129
+ purchaseEventStorage.push(orderIdHash);
130
130
  } else {
131
131
  // Create a new object map for the order ids
132
- purchaseEventStorage = (0, _defineProperty2["default"])({}, orderIdHash, true);
133
- } // Push the order id map into session storage
132
+ purchaseEventStorage = [orderIdHash];
133
+ } // Push the order id map into local storage
134
134
 
135
135
 
136
- store.session.set(purchaseEventStorageKey, JSON.stringify(purchaseEventStorage));
136
+ store.local.set(purchaseEventStorageKey, JSON.stringify(purchaseEventStorage));
137
137
  },
138
138
  // Abort network request based on supplied timeout interval (in milliseconds)
139
139
  // - method call parameter takes precedence over global options parameter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.29.9",
3
+ "version": "2.29.10",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "scripts": {