@uniformdev/canvas-next-rsc-shared 19.94.0 → 19.95.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ContextInstance, ContextState, ContextOptions } from '@uniformdev/context';
1
+ import { ContextInstance, ContextState, ContextOptions, PersonalizationEvent, TestEvent } from '@uniformdev/context';
2
2
  import * as _uniformdev_canvas from '@uniformdev/canvas';
3
3
  import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
4
4
  import { PropsWithChildren } from 'react';
@@ -161,6 +161,7 @@ declare const runPersonalization: ({ component, trackingEventName, count, contex
161
161
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
162
162
  }) => {
163
163
  indexes: number[];
164
+ event: PersonalizationEvent;
164
165
  };
165
166
 
166
167
  type TestProps = {
@@ -177,6 +178,7 @@ declare const runTest: ({ test, component, contextInstance, }: TestProps & {
177
178
  contextInstance: Pick<ContextInstance, 'test'> | undefined;
178
179
  }) => {
179
180
  index: number | null;
181
+ event: TestEvent;
180
182
  };
181
183
 
182
184
  type ResolvePathResult = {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ContextInstance, ContextState, ContextOptions } from '@uniformdev/context';
1
+ import { ContextInstance, ContextState, ContextOptions, PersonalizationEvent, TestEvent } from '@uniformdev/context';
2
2
  import * as _uniformdev_canvas from '@uniformdev/canvas';
3
3
  import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
4
4
  import { PropsWithChildren } from 'react';
@@ -161,6 +161,7 @@ declare const runPersonalization: ({ component, trackingEventName, count, contex
161
161
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
162
162
  }) => {
163
163
  indexes: number[];
164
+ event: PersonalizationEvent;
164
165
  };
165
166
 
166
167
  type TestProps = {
@@ -177,6 +178,7 @@ declare const runTest: ({ test, component, contextInstance, }: TestProps & {
177
178
  contextInstance: Pick<ContextInstance, 'test'> | undefined;
178
179
  }) => {
179
180
  index: number | null;
181
+ event: TestEvent;
180
182
  };
181
183
 
182
184
  type ResolvePathResult = {
package/dist/index.esm.js CHANGED
@@ -100,6 +100,7 @@ var createUniformContext = ({
100
100
  setTestVariantId: (...props) => context.setTestVariantId(...props),
101
101
  scores: context.scores,
102
102
  test: (...props) => context.test(...props),
103
+ manifest: context.manifest,
103
104
  update: (update) => {
104
105
  const { params, searchParams } = update;
105
106
  const DEFAULT_URL = `${getBaseUrl()}/`;
@@ -128,7 +129,9 @@ var createUniformContext = ({
128
129
  ...update,
129
130
  url
130
131
  });
131
- }
132
+ },
133
+ internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
134
+ internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
132
135
  };
133
136
  return appDirectoryContext;
134
137
  };
@@ -154,6 +157,7 @@ var runPersonalization = ({
154
157
  };
155
158
  });
156
159
  const indexes = [];
160
+ const variantIds = [];
157
161
  let parsedCount;
158
162
  if (typeof count === "string") {
159
163
  parsedCount = parseInt(count, 10);
@@ -171,6 +175,7 @@ var runPersonalization = ({
171
175
  if (variations) {
172
176
  for (let i = 0; i < variations.length; i++) {
173
177
  indexes.push(variations[i].index);
178
+ variantIds.push(variations[i].id);
174
179
  }
175
180
  }
176
181
  } else {
@@ -185,9 +190,17 @@ var runPersonalization = ({
185
190
  }
186
191
  }
187
192
  indexes.push(...defaults);
193
+ variantIds.push(...defaults.map((i) => componentVariations[i].id));
188
194
  }
195
+ const event = {
196
+ name: trackingEventName,
197
+ variantIds,
198
+ changed: true,
199
+ control: false
200
+ };
189
201
  return {
190
- indexes
202
+ indexes,
203
+ event
191
204
  };
192
205
  };
193
206
 
@@ -211,6 +224,7 @@ var runTest = ({
211
224
  };
212
225
  });
213
226
  let index = null;
227
+ let variantId = null;
214
228
  if (contextInstance) {
215
229
  const { result } = contextInstance.test({
216
230
  name: test,
@@ -218,15 +232,24 @@ var runTest = ({
218
232
  });
219
233
  if (result) {
220
234
  index = result.index;
235
+ variantId = result.id;
221
236
  }
222
- } else {
237
+ }
238
+ if (!variantId) {
223
239
  const [first] = componentVariations;
224
240
  if (first) {
225
241
  index = first.index;
242
+ variantId = first.id;
226
243
  }
227
244
  }
245
+ const event = {
246
+ name: test,
247
+ variantAssigned: true,
248
+ variantId: variantId != null ? variantId : "NO_VARIANTS"
249
+ };
228
250
  return {
229
- index
251
+ index,
252
+ event
230
253
  };
231
254
  };
232
255
  export {
package/dist/index.js CHANGED
@@ -123,6 +123,7 @@ var createUniformContext = ({
123
123
  setTestVariantId: (...props) => context.setTestVariantId(...props),
124
124
  scores: context.scores,
125
125
  test: (...props) => context.test(...props),
126
+ manifest: context.manifest,
126
127
  update: (update) => {
127
128
  const { params, searchParams } = update;
128
129
  const DEFAULT_URL = `${getBaseUrl()}/`;
@@ -151,7 +152,9 @@ var createUniformContext = ({
151
152
  ...update,
152
153
  url
153
154
  });
154
- }
155
+ },
156
+ internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
157
+ internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
155
158
  };
156
159
  return appDirectoryContext;
157
160
  };
@@ -177,6 +180,7 @@ var runPersonalization = ({
177
180
  };
178
181
  });
179
182
  const indexes = [];
183
+ const variantIds = [];
180
184
  let parsedCount;
181
185
  if (typeof count === "string") {
182
186
  parsedCount = parseInt(count, 10);
@@ -194,6 +198,7 @@ var runPersonalization = ({
194
198
  if (variations) {
195
199
  for (let i = 0; i < variations.length; i++) {
196
200
  indexes.push(variations[i].index);
201
+ variantIds.push(variations[i].id);
197
202
  }
198
203
  }
199
204
  } else {
@@ -208,9 +213,17 @@ var runPersonalization = ({
208
213
  }
209
214
  }
210
215
  indexes.push(...defaults);
216
+ variantIds.push(...defaults.map((i) => componentVariations[i].id));
211
217
  }
218
+ const event = {
219
+ name: trackingEventName,
220
+ variantIds,
221
+ changed: true,
222
+ control: false
223
+ };
212
224
  return {
213
- indexes
225
+ indexes,
226
+ event
214
227
  };
215
228
  };
216
229
 
@@ -234,6 +247,7 @@ var runTest = ({
234
247
  };
235
248
  });
236
249
  let index = null;
250
+ let variantId = null;
237
251
  if (contextInstance) {
238
252
  const { result } = contextInstance.test({
239
253
  name: test,
@@ -241,15 +255,24 @@ var runTest = ({
241
255
  });
242
256
  if (result) {
243
257
  index = result.index;
258
+ variantId = result.id;
244
259
  }
245
- } else {
260
+ }
261
+ if (!variantId) {
246
262
  const [first] = componentVariations;
247
263
  if (first) {
248
264
  index = first.index;
265
+ variantId = first.id;
249
266
  }
250
267
  }
268
+ const event = {
269
+ name: test,
270
+ variantAssigned: true,
271
+ variantId: variantId != null ? variantId : "NO_VARIANTS"
272
+ };
251
273
  return {
252
- index
274
+ index,
275
+ event
253
276
  };
254
277
  };
255
278
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -100,6 +100,7 @@ var createUniformContext = ({
100
100
  setTestVariantId: (...props) => context.setTestVariantId(...props),
101
101
  scores: context.scores,
102
102
  test: (...props) => context.test(...props),
103
+ manifest: context.manifest,
103
104
  update: (update) => {
104
105
  const { params, searchParams } = update;
105
106
  const DEFAULT_URL = `${getBaseUrl()}/`;
@@ -128,7 +129,9 @@ var createUniformContext = ({
128
129
  ...update,
129
130
  url
130
131
  });
131
- }
132
+ },
133
+ internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
134
+ internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
132
135
  };
133
136
  return appDirectoryContext;
134
137
  };
@@ -154,6 +157,7 @@ var runPersonalization = ({
154
157
  };
155
158
  });
156
159
  const indexes = [];
160
+ const variantIds = [];
157
161
  let parsedCount;
158
162
  if (typeof count === "string") {
159
163
  parsedCount = parseInt(count, 10);
@@ -171,6 +175,7 @@ var runPersonalization = ({
171
175
  if (variations) {
172
176
  for (let i = 0; i < variations.length; i++) {
173
177
  indexes.push(variations[i].index);
178
+ variantIds.push(variations[i].id);
174
179
  }
175
180
  }
176
181
  } else {
@@ -185,9 +190,17 @@ var runPersonalization = ({
185
190
  }
186
191
  }
187
192
  indexes.push(...defaults);
193
+ variantIds.push(...defaults.map((i) => componentVariations[i].id));
188
194
  }
195
+ const event = {
196
+ name: trackingEventName,
197
+ variantIds,
198
+ changed: true,
199
+ control: false
200
+ };
189
201
  return {
190
- indexes
202
+ indexes,
203
+ event
191
204
  };
192
205
  };
193
206
 
@@ -211,6 +224,7 @@ var runTest = ({
211
224
  };
212
225
  });
213
226
  let index = null;
227
+ let variantId = null;
214
228
  if (contextInstance) {
215
229
  const { result } = contextInstance.test({
216
230
  name: test,
@@ -218,15 +232,24 @@ var runTest = ({
218
232
  });
219
233
  if (result) {
220
234
  index = result.index;
235
+ variantId = result.id;
221
236
  }
222
- } else {
237
+ }
238
+ if (!variantId) {
223
239
  const [first] = componentVariations;
224
240
  if (first) {
225
241
  index = first.index;
242
+ variantId = first.id;
226
243
  }
227
244
  }
245
+ const event = {
246
+ name: test,
247
+ variantAssigned: true,
248
+ variantId: variantId != null ? variantId : "NO_VARIANTS"
249
+ };
228
250
  return {
229
- index
251
+ index,
252
+ event
230
253
  };
231
254
  };
232
255
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc-shared",
3
- "version": "19.94.0",
3
+ "version": "19.95.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -32,8 +32,8 @@
32
32
  "react-dom": "18.2.0"
33
33
  },
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "19.94.0",
36
- "@uniformdev/context": "19.94.0"
35
+ "@uniformdev/canvas": "19.95.0",
36
+ "@uniformdev/context": "19.95.0"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=16.14.0"
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "83b33647cd09dafcd4ea23012c4e87a45b71c0af"
49
+ "gitHead": "3e3fb19655bb28c5452cb98418d8c87bef0f853a"
50
50
  }