@constructor-io/constructorio-node 4.14.4 → 4.14.5-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-node",
3
- "version": "4.14.4",
3
+ "version": "4.14.5-beta.0",
4
4
  "description": "Constructor.io Node.js client",
5
5
  "main": "src/constructorio.js",
6
6
  "types": "src/types/constructorio.d.ts",
@@ -1,18 +1,26 @@
1
+ /* eslint-disable global-require */
1
2
  /* eslint-disable camelcase, no-unneeded-ternary, max-len */
2
- const nodeFetch = require('./nodeFetch');
3
3
 
4
4
  // Modules
5
5
  const Search = require('./modules/search');
6
6
  const Browse = require('./modules/browse');
7
7
  const Autocomplete = require('./modules/autocomplete');
8
8
  const Recommendations = require('./modules/recommendations');
9
- const Tracker = require('./modules/tracker');
10
- const Catalog = require('./modules/catalog');
11
9
  const Tasks = require('./modules/tasks');
12
10
  const Quizzes = require('./modules/quizzes');
13
11
  const { version: packageVersion } = require('../package.json');
14
12
  const utils = require('./utils/helpers');
15
13
 
14
+ let nodeFetch;
15
+ let Catalog;
16
+ let Tracker;
17
+
18
+ if (typeof process !== 'undefined' && process.env && process.env.NEXT_RUNTIME !== 'edge') {
19
+ nodeFetch = require('./nodeFetch');
20
+ Catalog = require('./modules/catalog');
21
+ Tracker = require('./modules/tracker');
22
+ }
23
+
16
24
  /**
17
25
  * Class to instantiate the ConstructorIO client.
18
26
  */
@@ -59,17 +67,20 @@ class ConstructorIO {
59
67
  securityToken: securityToken || '',
60
68
  version: version || global.CLIENT_VERSION || `cio-node-${packageVersion}`,
61
69
  serviceUrl: utils.addHTTPSToString(normalizedServiceUrl) || 'https://ac.cnstrc.com',
62
- fetch: fetch || nodeFetch,
70
+ fetch: fetch || nodeFetch || global.fetch,
63
71
  networkParameters: networkParameters || {},
64
72
  };
65
73
 
74
+ if (typeof process !== 'undefined' && process.env && process.env.NEXT_RUNTIME !== 'edge') {
75
+ this.tracker = new Tracker(this.options);
76
+ this.catalog = new Catalog(this.options);
77
+ }
78
+
66
79
  // Expose global modules
67
80
  this.search = new Search(this.options);
68
81
  this.browse = new Browse(this.options);
69
82
  this.autocomplete = new Autocomplete(this.options);
70
83
  this.recommendations = new Recommendations(this.options);
71
- this.tracker = new Tracker(this.options);
72
- this.catalog = new Catalog(this.options);
73
84
  this.tasks = new Tasks(this.options);
74
85
  this.quizzes = new Quizzes(this.options);
75
86
  }