@ninetailed/experience.js-gatsby 1.7.1 → 1.7.2

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
@@ -58,7 +58,7 @@ Add the plugin to the plugins array in your gatsby-config.js and your API Key.
58
58
  plugins: [
59
59
  ...your other gatsby plugins
60
60
  {
61
- resolve: `gatsby-plugin-ninetailed`,
61
+ resolve: `@ninetailed/experience.js-gatsby`,
62
62
  options: {
63
63
  clientId: 'your api key'
64
64
  }
@@ -72,6 +72,32 @@ By using the gatsby plugin there's no need to configure the `NinetailedProvuder`
72
72
 
73
73
  The plugin automatically tracks Pageviews on route change, please do not track it on your own as you would duplicate events.
74
74
 
75
+ ### Ninetailed Plugins
76
+
77
+ To use Ninetailed Plugins like `@ninetailed/experience.js-plugin-preview` you have to pass them to the plugins array of the `@ninetailed/experience.js-gatsby` SDK.
78
+
79
+ ```js
80
+ plugins: [
81
+ ...your other gatsby plugins
82
+ {
83
+ resolve: `@ninetailed/experience.js-gatsby`,
84
+ options: {
85
+ clientId: 'your api key',
86
+ ninetailedPlugins: [
87
+ {
88
+ resolve: `@ninetailed/experience.js-plugin-preview`,
89
+ // These options are the args of the plugin itself
90
+ options: {
91
+ clientId: "a readlony api token id",
92
+ secret: "a readlony token secret"
93
+ }
94
+ }
95
+ ]
96
+ }
97
+ }
98
+ ]
99
+ ```
100
+
75
101
  ## Personalizing Components
76
102
 
77
103
  ### Personalize Component
@@ -80,7 +106,7 @@ To make personalizing your components as seamless as possible Ninetailed provide
80
106
 
81
107
  ```TypeScript
82
108
  import React from 'react';
83
- import { Personalize } from '@ninetailed/experience.js-gatsby';
109
+ import { Personalize } from '@ninetailed/experience.js-react';
84
110
 
85
111
  type HeadlineProps = {
86
112
  text: string;
@@ -114,7 +140,7 @@ Using the visitor's and the useProfile hook makes it very easy to use inline per
114
140
 
115
141
  ```TypeScript
116
142
  import React, { useState, useEffect } from 'react';
117
- import { useProfile } from '@ninetailed/experience.js-gatsby';
143
+ import { useProfile } from '@ninetailed/experience.js-react';
118
144
 
119
145
  const Greeting = () => {
120
146
  const [loading, profile, error] = useProfile();
@@ -138,12 +164,13 @@ import {
138
164
  RenderRichTextData,
139
165
  ContentfulRichTextGatsbyReference,
140
166
  } from 'gatsby-source-contentful/rich-text';
141
- import { MergeTag } from '@ninetailed/experience.js-gatsby';
167
+ import { MergeTag } from '@ninetailed/experience.js-react';
142
168
 
143
169
  const options = {
144
170
  renderNode: {
145
171
  [INLINES.EMBEDDED_ENTRY]: (node) => {
146
172
  const id = node.data.target.id;
173
+ // The __typename changes depending on your Contentful setup.
147
174
  if (node.data.target.__typename === "ContentfulNtMergeTag" && id) {
148
175
  return <MergeTag id={mergeTag.id} />;
149
176
  }
package/gatsby-browser.js CHANGED
@@ -5,9 +5,12 @@ const tslib_1 = require("tslib");
5
5
  const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
6
  const experience_js_react_1 = require("@ninetailed/experience.js-react");
7
7
  const Tracker_1 = require("./src/lib/Tracker");
8
+ //@ts-ignore
9
+ const ninetailed_plugins_1 = require("./loaders/ninetailed-plugins");
8
10
  const WrapRootElement = (_a) => {
9
11
  var { children } = _a, options = (0, tslib_1.__rest)(_a, ["children"]);
10
- return (react_1.default.createElement(experience_js_react_1.NinetailedProvider, Object.assign({}, options),
12
+ const resolvedPlugins = ninetailed_plugins_1.plugins.map(({ plugin, options }) => plugin(options));
13
+ return (react_1.default.createElement(experience_js_react_1.NinetailedProvider, Object.assign({}, options, { plugins: resolvedPlugins }),
11
14
  react_1.default.createElement(Tracker_1.Tracker, null),
12
15
  children));
13
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"gatsby-browser.js","sourceRoot":"","sources":["../../../packages/gatsby/gatsby-browser.tsx"],"names":[],"mappings":";;;;AAAA,+DAA0B;AAE1B,yEAAqE;AAErE,+CAA4C;AAG5C,MAAM,eAAe,GAA4B,CAAC,EAGjD,EAAE,EAAE;QAH6C,EAChD,QAAQ,OAET,EADI,OAAO,2BAFsC,YAGjD,CADW;IAEV,OAAO,CACL,8BAAC,wCAAkB,oBAAK,OAAO;QAC7B,8BAAC,iBAAO,OAAG;QACV,QAAQ,CACU,CACtB,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,eAAe,GAAG,CAC7B,IAAgC,EAChC,OAAsB,EACtB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,OAAO,8BAAC,eAAe,oBAAK,OAAO,GAAG,OAAO,CAAmB,CAAC;AACnE,CAAC,CAAC;AAPW,QAAA,eAAe,mBAO1B"}
1
+ {"version":3,"file":"gatsby-browser.js","sourceRoot":"","sources":["../../../packages/gatsby/gatsby-browser.tsx"],"names":[],"mappings":";;;;AAAA,+DAA0B;AAE1B,yEAAqE;AAErE,+CAA4C;AAG5C,YAAY;AACZ,qEAA4E;AAE5E,MAAM,eAAe,GAA4B,CAAC,EAAwB,EAAE,EAAE;QAA5B,EAAE,QAAQ,OAAc,EAAT,OAAO,2BAAtB,YAAwB,CAAF;IACtE,MAAM,eAAe,GAAG,4BAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAExF,OAAO,CACL,8BAAC,wCAAkB,oBACb,OAAO,IACX,OAAO,EAAE,eAAe;QAExB,8BAAC,iBAAO,OAAG;QACV,QAAQ,CACU,CACtB,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,eAAe,GAAG,CAC7B,IAAgC,EAChC,OAAsB,EACtB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,OAAO,8BAAC,eAAe,oBAAK,OAAO,GAAG,OAAO,CAAmB,CAAC;AACnE,CAAC,CAAC;AAPW,QAAA,eAAe,mBAO1B"}
package/gatsby-node.js CHANGED
@@ -1,15 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pluginOptionsSchema = void 0;
3
+ exports.onCreateWebpackConfig = exports.pluginOptionsSchema = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
4
6
  const pluginOptionsSchema = ({ Joi, }) => {
5
7
  return Joi.object({
6
8
  clientId: Joi.string()
7
9
  .required()
8
- .description('Your organizations\' client id.')
10
+ .description("Your organizations' client id.")
9
11
  .messages({
10
12
  'any.required': '"clientId" needs to be specified. Get your clientId from the dashboard.',
11
- })
13
+ }),
14
+ ninetailedPlugins: Joi.array(),
12
15
  });
13
16
  };
14
17
  exports.pluginOptionsSchema = pluginOptionsSchema;
18
+ /**
19
+ * Add the webpack config for loading MDX files
20
+ */
21
+ const onCreateWebpackConfig = ({ loaders, actions }, pluginOptions) => {
22
+ actions.setWebpackConfig({
23
+ resolve: {
24
+ fallback: {
25
+ path: false,
26
+ crypto: false,
27
+ },
28
+ },
29
+ module: {
30
+ rules: [
31
+ {
32
+ test: /ninetailed-plugins\.js$/,
33
+ include: __dirname,
34
+ use: [
35
+ loaders.js(),
36
+ {
37
+ loader: path_1.default.join(__dirname, `loaders`, `ninetailed-plugins`),
38
+ options: {
39
+ plugins: pluginOptions.ninetailedPlugins,
40
+ },
41
+ },
42
+ ],
43
+ },
44
+ ],
45
+ },
46
+ });
47
+ };
48
+ exports.onCreateWebpackConfig = onCreateWebpackConfig;
15
49
  //# sourceMappingURL=gatsby-node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gatsby-node.js","sourceRoot":"","sources":["../../../packages/gatsby/gatsby-node.tsx"],"names":[],"mappings":";;;AAGO,MAAM,mBAAmB,GAAG,CAAC,EAClC,GAAG,GACqB,EAAqB,EAAE;IAC/C,OAAO,GAAG,CAAC,MAAM,CAAC;QAChB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;aACnB,QAAQ,EAAE;aACV,WAAW,CAAC,iCAAiC,CAAC;aAC9C,QAAQ,CAAC;YACR,cAAc,EACZ,yEAAyE;SAC5E,CAAC;KACL,CAAC,CAAC;AACL,CAAC,CAAC;AAZW,QAAA,mBAAmB,uBAY9B"}
1
+ {"version":3,"file":"gatsby-node.js","sourceRoot":"","sources":["../../../packages/gatsby/gatsby-node.tsx"],"names":[],"mappings":";;;;AAEA,6DAAwB;AAEjB,MAAM,mBAAmB,GAAG,CAAC,EAClC,GAAG,GACqB,EAAqB,EAAE;IAC/C,OAAO,GAAG,CAAC,MAAM,CAAC;QAChB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;aACnB,QAAQ,EAAE;aACV,WAAW,CAAC,gCAAgC,CAAC;aAC7C,QAAQ,CAAC;YACR,cAAc,EACZ,yEAAyE;SAC5E,CAAC;QACJ,iBAAiB,EAAE,GAAG,CAAC,KAAK,EAAE;KAC/B,CAAC,CAAC;AACL,CAAC,CAAC;AAbW,QAAA,mBAAmB,uBAa9B;AAIF;;GAEG;AACI,MAAM,qBAAqB,GAAG,CACnC,EAAE,OAAO,EAAE,OAAO,EAA2B,EAC7C,aAA4B,EAC5B,EAAE;IACF,OAAO,CAAC,gBAAgB,CAAC;QACvB,OAAO,EAAE;YACP,QAAQ,EAAE;gBACR,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE,KAAK;aACd;SACF;QACD,MAAM,EAAE;YACN,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,yBAAyB;oBAC/B,OAAO,EAAE,SAAS;oBAClB,GAAG,EAAE;wBACH,OAAO,CAAC,EAAE,EAAE;wBACZ;4BACE,MAAM,EAAE,cAAI,CAAC,IAAI,CACf,SAAS,EACT,SAAS,EACT,oBAAoB,CACrB;4BACD,OAAO,EAAE;gCACP,OAAO,EAAE,aAAa,CAAC,iBAAiB;6BACzC;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAjCW,QAAA,qBAAqB,yBAiChC"}
package/gatsby-ssr.js CHANGED
@@ -4,9 +4,12 @@ exports.wrapRootElement = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = (0, tslib_1.__importDefault)(require("react"));
6
6
  const experience_js_react_1 = require("@ninetailed/experience.js-react");
7
+ //@ts-ignore
8
+ const ninetailed_plugins_1 = require("./loaders/ninetailed-plugins");
7
9
  const wrapRootElement = (args, options) => {
10
+ const resolvedPlugins = ninetailed_plugins_1.plugins.map(({ plugin, options }) => plugin(options));
8
11
  const { element } = args;
9
- return react_1.default.createElement(experience_js_react_1.NinetailedProvider, Object.assign({}, options), element);
12
+ return react_1.default.createElement(experience_js_react_1.NinetailedProvider, Object.assign({}, options, { plugins: resolvedPlugins }), element);
10
13
  };
11
14
  exports.wrapRootElement = wrapRootElement;
12
15
  //# sourceMappingURL=gatsby-ssr.js.map
package/gatsby-ssr.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"gatsby-ssr.js","sourceRoot":"","sources":["../../../packages/gatsby/gatsby-ssr.tsx"],"names":[],"mappings":";;;;AAAA,+DAA0B;AAE1B,yEAAqE;AAI9D,MAAM,eAAe,GAAG,CAC7B,IAA6B,EAC7B,OAAsB,EACtB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,OAAO,8BAAC,wCAAkB,oBAAK,OAAO,GAAG,OAAO,CAAsB,CAAC;AACzE,CAAC,CAAC;AAPW,QAAA,eAAe,mBAO1B"}
1
+ {"version":3,"file":"gatsby-ssr.js","sourceRoot":"","sources":["../../../packages/gatsby/gatsby-ssr.tsx"],"names":[],"mappings":";;;;AAAA,+DAA0B;AAE1B,yEAAqE;AAIrE,YAAY;AACZ,qEAA4E;AAErE,MAAM,eAAe,GAAG,CAC7B,IAA6B,EAC7B,OAAsB,EACtB,EAAE;IACF,MAAM,eAAe,GAAG,4BAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,OAAO,8BAAC,wCAAkB,oBAAK,OAAO,IAAE,OAAO,EAAE,eAAe,KAAG,OAAO,CAAsB,CAAC;AACnG,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B"}
package/index.js CHANGED
@@ -1,2 +1,5 @@
1
- // This needs to exist, so the gatsby plugin build process works.
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./src/index"), exports);
2
5
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/gatsby/index.js"],"names":[],"mappings":"AAAA,iEAAiE"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/gatsby/index.ts"],"names":[],"mappings":";;;AAAA,2DAA2B"}
@@ -0,0 +1,26 @@
1
+ const loaderUtils = require(`loader-utils`);
2
+ /**
3
+ * loads a generated file that allows us to require all of the mdxPlugins.
4
+ * this is useful because otherwise requiring all the plugins in
5
+ * gatsby-ssr/browser results in a webpack require context warning
6
+ *
7
+ * results in a file that looks like:
8
+ *
9
+ * ```js
10
+ * module.exports = {
11
+ * plugins: [require('some-plugin'), require('some-other-plugin')]
12
+ * }
13
+ * ```
14
+ */
15
+ module.exports = function () {
16
+ const options = loaderUtils.getOptions(this);
17
+ const pluginRequires = !options.plugins
18
+ ? `[]`
19
+ : `[` +
20
+ options.plugins
21
+ .map((plugin) => `{plugin: require("${plugin.resolve ? plugin.resolve : plugin}").default, options: ${JSON.stringify(plugin.options)}}`)
22
+ .join(`,`) +
23
+ `]`;
24
+ return `module.exports = {plugins: ${pluginRequires}}`;
25
+ };
26
+ //# sourceMappingURL=ninetailed-plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ninetailed-plugins.js","sourceRoot":"","sources":["../../../../packages/gatsby/loaders/ninetailed-plugins.js"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,OAAO;QACrC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,GAAG;YACH,OAAO,CAAC,OAAO;iBACZ,GAAG,CACF,CAAC,MAAM,EAAE,EAAE,CACT,qBACE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MACpC,wBAAwB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAC5D;iBACA,IAAI,CAAC,GAAG,CAAC;YACZ,GAAG,CAAC;IACR,OAAO,8BAA8B,cAAc,GAAG,CAAC;AACzD,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-gatsby",
3
- "version": "1.7.1",
4
- "main": "index.js",
3
+ "version": "1.7.2",
5
4
  "keywords": [
6
5
  "gatsby",
7
6
  "gatsby-plugin",
@@ -15,14 +14,15 @@
15
14
  "react": ">=16.8.0",
16
15
  "gatsby": ">=2.27.4"
17
16
  },
18
- "typings": "./src/index.d.ts",
17
+ "main": "./index.js",
18
+ "typings": "./index.d.ts",
19
19
  "dependencies": {
20
- "@ninetailed/experience.js-react": "1.7.1",
20
+ "@ninetailed/experience.js-react": "1.7.2",
21
21
  "@analytics/google-analytics": "^0.5.3",
22
22
  "lodash": "^4.17.21",
23
- "@ninetailed/experience.js": "1.7.1",
23
+ "@ninetailed/experience.js": "1.7.2",
24
24
  "analytics": "^0.8.0",
25
- "@ninetailed/experience.js-shared": "1.7.1",
25
+ "@ninetailed/experience.js-shared": "1.7.2",
26
26
  "uuid": "^8.3.2",
27
27
  "ts-toolbelt": "^9.6.0",
28
28
  "locale-enum": "^1.1.1",