create-instantsearch-app 7.2.1 → 7.3.1
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
|
@@ -50,6 +50,10 @@ cd my-app
|
|
|
50
50
|
yarn start
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
> **Important**
|
|
54
|
+
> Selecting 'Y' when being prompted to ‘Enable user events’ activates the [`insights`](https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-insights) option for compatible templates, allowing Algolia to process your user Events. Events can unlock powerful features, enhancing your application's effectiveness and we encourage you to consider enabling this valuable functionality. Please review our [API reference](https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-insights) for more details about Events collection and settings.
|
|
55
|
+
|
|
56
|
+
|
|
53
57
|
## Usage
|
|
54
58
|
|
|
55
59
|
This package comes with the module `createInstantSearchApp(path, options?)` and the command-line tool `create-instantsearch-app`.
|
|
@@ -110,7 +114,8 @@ The `config` flag is handy to automate app generations.
|
|
|
110
114
|
"indexName": "MY_INDEX_NAME",
|
|
111
115
|
"searchPlaceholder": "Search",
|
|
112
116
|
"attributesToDisplay": ["name", "description"],
|
|
113
|
-
"attributesForFaceting": ["brand", "location"]
|
|
117
|
+
"attributesForFaceting": ["brand", "location"],
|
|
118
|
+
"enableInsights": true
|
|
114
119
|
}
|
|
115
120
|
```
|
|
116
121
|
|
|
@@ -132,6 +137,7 @@ const app = createInstantSearchApp('~/lab/my-app', {
|
|
|
132
137
|
libraryVersion: '2.0.0',
|
|
133
138
|
attributesToDisplay: ['name', 'description'],
|
|
134
139
|
attributesForFaceting: ['keywords'],
|
|
140
|
+
enableInsights: true,
|
|
135
141
|
});
|
|
136
142
|
|
|
137
143
|
app.create().then(() => console.log('App generated!'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-instantsearch-app",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "⚡️ Build InstantSearch apps at the speed of thought",
|
|
6
6
|
"keywords": [
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"validate-npm-package-name": "3.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@instantsearch/testutils": "1.
|
|
52
|
+
"@instantsearch/testutils": "1.19.0",
|
|
53
53
|
"jest-image-snapshot": "2.12.0",
|
|
54
54
|
"walk-sync": "2.0.2"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "0035f4bc5b91cdb4095ec36f5514c6718ea00c29"
|
|
57
57
|
}
|
|
@@ -131,7 +131,7 @@ describe('flags', () => {
|
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
describe('insights', () => {
|
|
134
|
-
test('with a valid version', async () => {
|
|
134
|
+
test('with a valid version and user consent', async () => {
|
|
135
135
|
utils.fetchLibraryVersions.mockImplementationOnce(() =>
|
|
136
136
|
Promise.resolve(['1.2.0'])
|
|
137
137
|
);
|
|
@@ -139,7 +139,7 @@ describe('flags', () => {
|
|
|
139
139
|
expect(
|
|
140
140
|
(
|
|
141
141
|
await postProcessAnswers({
|
|
142
|
-
configuration: {},
|
|
142
|
+
configuration: { enableInsights: true },
|
|
143
143
|
templateConfig: {
|
|
144
144
|
libraryName: 'instantsearch.js',
|
|
145
145
|
flags: {
|
|
@@ -152,6 +152,27 @@ describe('flags', () => {
|
|
|
152
152
|
).toEqual(expect.objectContaining({ insights: true }));
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
+
test('with a valid version and no user consent', async () => {
|
|
156
|
+
utils.fetchLibraryVersions.mockImplementationOnce(() =>
|
|
157
|
+
Promise.resolve(['1.2.0'])
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
expect(
|
|
161
|
+
(
|
|
162
|
+
await postProcessAnswers({
|
|
163
|
+
configuration: { enableInsights: false },
|
|
164
|
+
templateConfig: {
|
|
165
|
+
libraryName: 'instantsearch.js',
|
|
166
|
+
flags: {
|
|
167
|
+
insights: '>= 1',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
optionsFromArguments: {},
|
|
171
|
+
})
|
|
172
|
+
).flags
|
|
173
|
+
).toEqual(expect.objectContaining({ insights: false }));
|
|
174
|
+
});
|
|
175
|
+
|
|
155
176
|
test('with an invalid version', async () => {
|
|
156
177
|
utils.fetchLibraryVersions.mockImplementationOnce(() =>
|
|
157
178
|
Promise.resolve(['1.2.0'])
|
package/src/cli/index.js
CHANGED
|
@@ -286,6 +286,35 @@ const getQuestions = ({ appName }) => ({
|
|
|
286
286
|
},
|
|
287
287
|
when: ({ searchInputType }) => searchInputType === 'autocomplete',
|
|
288
288
|
},
|
|
289
|
+
{
|
|
290
|
+
type: 'confirm',
|
|
291
|
+
name: 'enableInsights',
|
|
292
|
+
message: 'Enable user events',
|
|
293
|
+
default: true,
|
|
294
|
+
suffix: `${chalk.gray(`
|
|
295
|
+
Selecting 'Y' enables the \`insights\` option.
|
|
296
|
+
By doing this, you instruct Algolia to process your user Events.
|
|
297
|
+
Please review our API reference at ${chalk.bold(
|
|
298
|
+
chalk.underline('https://alg.li/instantsearch-insights')
|
|
299
|
+
)}
|
|
300
|
+
for more details about Events collection and settings.`)}`,
|
|
301
|
+
when: ({ libraryVersion, template }) => {
|
|
302
|
+
const templatePath = getTemplatePath(template);
|
|
303
|
+
const templateConfig = getAppTemplateConfig(templatePath);
|
|
304
|
+
|
|
305
|
+
const selectedLibraryVersion = libraryVersion;
|
|
306
|
+
const requiredLibraryVersion =
|
|
307
|
+
templateConfig.flags && templateConfig.flags.insights;
|
|
308
|
+
const supportsInsights =
|
|
309
|
+
selectedLibraryVersion &&
|
|
310
|
+
requiredLibraryVersion &&
|
|
311
|
+
semver.satisfies(selectedLibraryVersion, requiredLibraryVersion, {
|
|
312
|
+
includePrerelease: true,
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
return supportsInsights;
|
|
316
|
+
},
|
|
317
|
+
},
|
|
289
318
|
],
|
|
290
319
|
widget: [
|
|
291
320
|
{
|
|
@@ -76,7 +76,7 @@ async function postProcessAnswers({
|
|
|
76
76
|
combinedAnswers.attributesForFaceting.includes('ais.dynamicWidgets'),
|
|
77
77
|
insights:
|
|
78
78
|
Boolean(templateConfig.flags && templateConfig.flags.insights) &&
|
|
79
|
-
|
|
79
|
+
combinedAnswers.enableInsights === true,
|
|
80
80
|
autocomplete:
|
|
81
81
|
Boolean(templateConfig.flags && templateConfig.flags.autocomplete) &&
|
|
82
82
|
combinedAnswers.searchInputType === 'autocomplete',
|