@constructor-io/constructorio-node 4.15.1 → 4.16.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Constructor.io
3
+ Copyright (c) 2019 Constructor.io Corporation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-node",
3
- "version": "4.15.1",
3
+ "version": "4.16.0",
4
4
  "description": "Constructor.io Node.js client",
5
5
  "main": "src/constructorio.js",
6
6
  "types": "src/types/constructorio.d.ts",
@@ -22,7 +22,7 @@
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/Constructor-io/constructorio-node.git"
24
24
  },
25
- "author": "constructor.io",
25
+ "author": "Constructor.io Corporation",
26
26
  "license": "MIT",
27
27
  "bugs": {
28
28
  "url": "https://github.com/Constructor-io/constructorio-node/issues"
@@ -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
  }