@g2crowd/buyer-intent-provider-sdk 0.2.0 → 0.4.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/README.md +237 -190
- package/package.json +19 -12
- package/src/browser/components/index.js +29 -0
- package/src/browser/components/tracker.js +105 -0
- package/src/browser/dom.js +184 -0
- package/src/browser/elements/base.js +124 -0
- package/src/browser/elements/index.js +6 -0
- package/src/browser/identity.js +67 -0
- package/src/browser/index.js +8 -0
- package/src/browser/sdk.js +336 -0
- package/src/browser/transport.js +25 -0
- package/src/index.d.ts +126 -0
- package/src/index.js +8 -0
- package/src/react/index.d.ts +77 -0
- package/{browser → src/react}/index.js +20 -10
- package/browser/sdk.js +0 -468
- package/browser/tag_component.js +0 -46
- package/browser/trackers.js +0 -42
- package/index.d.ts +0 -183
- package/index.js +0 -15
- /package/{browser → src/browser}/core.js +0 -0
- /package/{server → src/server}/handlers.js +0 -0
- /package/{server → src/server}/index.js +0 -0
- /package/{server.js → src/server.js} +0 -0
package/browser/sdk.js
DELETED
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
import { createBuyerIntentCore } from './core.js';
|
|
2
|
-
|
|
3
|
-
const DEFAULT_ACTIVITY_ENDPOINT = '/activity/events';
|
|
4
|
-
const DEFAULT_VIEW_NAME = '$view';
|
|
5
|
-
const DEFAULT_CLICK_NAME = '$click';
|
|
6
|
-
const DISTINCT_ID_STORAGE_KEY = 'buyer_intent_distinct_id';
|
|
7
|
-
|
|
8
|
-
const firedViewElements = new WeakSet();
|
|
9
|
-
const boundClickElements = new WeakSet();
|
|
10
|
-
|
|
11
|
-
function generateId() {
|
|
12
|
-
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
13
|
-
return crypto.randomUUID();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return `bi-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function readStoredDistinctId() {
|
|
20
|
-
if (typeof window === 'undefined') {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
return window.localStorage.getItem(DISTINCT_ID_STORAGE_KEY);
|
|
26
|
-
} catch (_error) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function storeDistinctId(value) {
|
|
32
|
-
if (typeof window === 'undefined') {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
window.localStorage.setItem(DISTINCT_ID_STORAGE_KEY, value);
|
|
38
|
-
} catch (_error) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function sendWithBeacon(url, payload) {
|
|
44
|
-
if (
|
|
45
|
-
typeof navigator !== 'undefined' &&
|
|
46
|
-
typeof navigator.sendBeacon === 'function'
|
|
47
|
-
) {
|
|
48
|
-
const blob = new Blob([JSON.stringify(payload)], {
|
|
49
|
-
type: 'application/json',
|
|
50
|
-
});
|
|
51
|
-
const sent = navigator.sendBeacon(url, blob);
|
|
52
|
-
if (sent) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (typeof fetch !== 'undefined') {
|
|
58
|
-
fetch(url, {
|
|
59
|
-
method: 'POST',
|
|
60
|
-
headers: { 'Content-Type': 'application/json' },
|
|
61
|
-
body: JSON.stringify(payload),
|
|
62
|
-
keepalive: true,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function parseJson(value) {
|
|
70
|
-
if (!value) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
return JSON.parse(value);
|
|
76
|
-
} catch (_error) {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function parseArray(value) {
|
|
82
|
-
if (!value) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const parsed = parseJson(value);
|
|
87
|
-
if (Array.isArray(parsed)) {
|
|
88
|
-
return parsed;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (typeof value === 'string') {
|
|
92
|
-
return value
|
|
93
|
-
.split(',')
|
|
94
|
-
.map((entry) => entry.trim())
|
|
95
|
-
.filter(Boolean);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function createBuyerIntentSDK() {
|
|
102
|
-
const core = createBuyerIntentCore();
|
|
103
|
-
let activityEndpoint = DEFAULT_ACTIVITY_ENDPOINT;
|
|
104
|
-
let origin = null;
|
|
105
|
-
let viewName = DEFAULT_VIEW_NAME;
|
|
106
|
-
let distinctId = null;
|
|
107
|
-
let userType = 'standard';
|
|
108
|
-
let lastPageKey = null;
|
|
109
|
-
let initialLandingPage = null;
|
|
110
|
-
let initialReferrer = null;
|
|
111
|
-
let initialUtmParams = null;
|
|
112
|
-
let observerStarted = false;
|
|
113
|
-
|
|
114
|
-
function ensureDistinctId() {
|
|
115
|
-
if (distinctId) {
|
|
116
|
-
return distinctId;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const stored = readStoredDistinctId();
|
|
120
|
-
if (stored) {
|
|
121
|
-
distinctId = stored;
|
|
122
|
-
return stored;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const generated = generateId();
|
|
126
|
-
distinctId = generated;
|
|
127
|
-
storeDistinctId(generated);
|
|
128
|
-
return generated;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function readUtmParams(urlValue) {
|
|
132
|
-
if (!urlValue) {
|
|
133
|
-
return {};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const url = new URL(urlValue, window.location.origin);
|
|
137
|
-
const params = url.searchParams;
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
utm_source: params.get('utm_source') || undefined,
|
|
141
|
-
utm_medium: params.get('utm_medium') || undefined,
|
|
142
|
-
utm_campaign: params.get('utm_campaign') || undefined,
|
|
143
|
-
utm_term: params.get('utm_term') || undefined,
|
|
144
|
-
utm_content: params.get('utm_content') || undefined,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function buildVisitContext() {
|
|
149
|
-
if (typeof window === 'undefined') {
|
|
150
|
-
return {};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const landingPage = initialLandingPage || window.location.href;
|
|
154
|
-
return {
|
|
155
|
-
landingPage,
|
|
156
|
-
referrer: initialReferrer || document.referrer || undefined,
|
|
157
|
-
userAgent:
|
|
158
|
-
typeof navigator !== 'undefined' ? navigator.userAgent : undefined,
|
|
159
|
-
utmParams: initialUtmParams || readUtmParams(landingPage),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function readDomTagElement(element) {
|
|
164
|
-
if (!element) {
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (element.tagName === 'SCRIPT') {
|
|
169
|
-
const parsed =
|
|
170
|
-
parseJson(element.textContent || '') ||
|
|
171
|
-
parseJson(element.getAttribute('data-buyer-intent'));
|
|
172
|
-
if (parsed && typeof parsed === 'object') {
|
|
173
|
-
return parsed;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const dataJson = parseJson(element.getAttribute('data-buyer-intent'));
|
|
178
|
-
if (dataJson && typeof dataJson === 'object') {
|
|
179
|
-
return dataJson;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const dataset = element.dataset || {};
|
|
183
|
-
return {
|
|
184
|
-
productIds: parseArray(dataset.productIds),
|
|
185
|
-
categoryIds: parseArray(dataset.categoryIds),
|
|
186
|
-
tag: dataset.tag,
|
|
187
|
-
sourceLocation: dataset.sourceLocation,
|
|
188
|
-
context: parseJson(dataset.context),
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function readDomTags(elements) {
|
|
193
|
-
if (typeof document === 'undefined') {
|
|
194
|
-
return [];
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const found = elements || new Set();
|
|
198
|
-
const legacy = document.getElementById('buyer-intent-tags');
|
|
199
|
-
if (legacy) {
|
|
200
|
-
found.add(legacy);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
document.querySelectorAll('[data-buyer-intent]').forEach((element) => {
|
|
204
|
-
found.add(element);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
return Array.from(found)
|
|
208
|
-
.map((element) => ({ element, tag: readDomTagElement(element) }))
|
|
209
|
-
.filter((entry) => entry.tag && typeof entry.tag === 'object');
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function applyElementConfig(element) {
|
|
213
|
-
if (!element || !element.dataset) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const {
|
|
218
|
-
origin: originValue,
|
|
219
|
-
userType: userTypeValue,
|
|
220
|
-
distinctId: distinctIdValue,
|
|
221
|
-
activityEndpoint: endpointValue,
|
|
222
|
-
} = element.dataset;
|
|
223
|
-
|
|
224
|
-
if (endpointValue) {
|
|
225
|
-
setActivityEndpoint(endpointValue);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (originValue || userTypeValue || distinctIdValue) {
|
|
229
|
-
setBaseProperties({
|
|
230
|
-
origin: originValue,
|
|
231
|
-
userType: userTypeValue,
|
|
232
|
-
distinctId: distinctIdValue,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function applyDomTags(element) {
|
|
238
|
-
const elements = element ? new Set([element]) : undefined;
|
|
239
|
-
const entries = readDomTags(elements);
|
|
240
|
-
entries.forEach(({ element: tagElement, tag }) => {
|
|
241
|
-
applyElementConfig(tagElement);
|
|
242
|
-
core.tagPage(tag);
|
|
243
|
-
});
|
|
244
|
-
return entries.length > 0;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function resolveEventName(element, fallback) {
|
|
248
|
-
if (element && element.dataset && element.dataset.eventName) {
|
|
249
|
-
return element.dataset.eventName;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return fallback;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function trackPageview(element) {
|
|
256
|
-
if (typeof window === 'undefined') {
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const pageKey = `${window.location.pathname}${window.location.search}`;
|
|
261
|
-
if (pageKey === lastPageKey) {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
lastPageKey = pageKey;
|
|
266
|
-
const hasTags = applyDomTags(element);
|
|
267
|
-
if (!hasTags) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const eventName = resolveEventName(element, viewName);
|
|
272
|
-
const payload = core.buildPayload({
|
|
273
|
-
name: eventName,
|
|
274
|
-
url: window.location.href,
|
|
275
|
-
origin: origin || window.location.hostname,
|
|
276
|
-
distinctId: ensureDistinctId(),
|
|
277
|
-
userType,
|
|
278
|
-
visit: buildVisitContext(),
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
const sent = sendWithBeacon(activityEndpoint, payload);
|
|
282
|
-
core.resetPageState();
|
|
283
|
-
return sent;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function trackClick(element) {
|
|
287
|
-
if (typeof window === 'undefined' || !element) {
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
applyDomTags(element);
|
|
292
|
-
const eventName = resolveEventName(element, DEFAULT_CLICK_NAME);
|
|
293
|
-
const payload = core.buildPayload({
|
|
294
|
-
name: eventName,
|
|
295
|
-
url: window.location.href,
|
|
296
|
-
origin: origin || window.location.hostname,
|
|
297
|
-
distinctId: ensureDistinctId(),
|
|
298
|
-
userType,
|
|
299
|
-
visit: buildVisitContext(),
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
const sent = sendWithBeacon(activityEndpoint, payload);
|
|
303
|
-
core.resetPageState();
|
|
304
|
-
return sent;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function init(options = {}) {
|
|
308
|
-
activityEndpoint = options.activityEndpoint || activityEndpoint;
|
|
309
|
-
origin = options.origin || origin;
|
|
310
|
-
viewName = options.viewName || options.pageviewName || viewName;
|
|
311
|
-
distinctId = options.distinctId || distinctId;
|
|
312
|
-
userType = options.userType || userType;
|
|
313
|
-
|
|
314
|
-
if (typeof window !== 'undefined' && !initialLandingPage) {
|
|
315
|
-
initialLandingPage = window.location.href;
|
|
316
|
-
initialReferrer = document.referrer || undefined;
|
|
317
|
-
initialUtmParams = readUtmParams(initialLandingPage);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
core.setBaseProperties({
|
|
321
|
-
origin: origin || undefined,
|
|
322
|
-
distinctId: distinctId || undefined,
|
|
323
|
-
userType,
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function setActivityEndpoint(value) {
|
|
328
|
-
activityEndpoint = value || activityEndpoint;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
function setBaseProperties(options = {}) {
|
|
332
|
-
if (options.origin) {
|
|
333
|
-
origin = options.origin;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (options.distinctId) {
|
|
337
|
-
distinctId = options.distinctId;
|
|
338
|
-
storeDistinctId(options.distinctId);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
if (options.userType) {
|
|
342
|
-
userType = options.userType;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
core.setBaseProperties({
|
|
346
|
-
origin: origin || undefined,
|
|
347
|
-
distinctId: distinctId || undefined,
|
|
348
|
-
userType,
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function tagPage(options = {}) {
|
|
353
|
-
core.tagPage(options);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function setVisitProperties(options = {}) {
|
|
357
|
-
core.setVisitProperties(options);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function trackNextRouter(nextRouter) {
|
|
361
|
-
if (!nextRouter || !nextRouter.events) {
|
|
362
|
-
return () => {};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
const handler = () => trackPageview();
|
|
366
|
-
nextRouter.events.on('routeChangeComplete', handler);
|
|
367
|
-
return () => nextRouter.events.off('routeChangeComplete', handler);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
function isClickTrigger(element) {
|
|
371
|
-
return element && element.dataset && element.dataset.trigger === 'click';
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function bindClickElement(element) {
|
|
375
|
-
if (!element || typeof element !== 'object') {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (boundClickElements.has(element)) {
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
boundClickElements.add(element);
|
|
384
|
-
applyElementConfig(element);
|
|
385
|
-
element.addEventListener('click', () => trackClick(element));
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function trackTaggedPageview(element) {
|
|
389
|
-
if (!element || typeof element !== 'object') {
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (isClickTrigger(element)) {
|
|
394
|
-
bindClickElement(element);
|
|
395
|
-
return false;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (firedViewElements.has(element)) {
|
|
399
|
-
return false;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
firedViewElements.add(element);
|
|
403
|
-
return trackPageview(element);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function observeTagElements() {
|
|
407
|
-
if (
|
|
408
|
-
observerStarted ||
|
|
409
|
-
typeof document === 'undefined' ||
|
|
410
|
-
typeof MutationObserver === 'undefined'
|
|
411
|
-
) {
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
observerStarted = true;
|
|
416
|
-
|
|
417
|
-
const handleElement = (element) => {
|
|
418
|
-
if (
|
|
419
|
-
element &&
|
|
420
|
-
element.matches &&
|
|
421
|
-
element.matches('buyer-intent-tag,[data-buyer-intent]')
|
|
422
|
-
) {
|
|
423
|
-
trackTaggedPageview(element);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (element && element.querySelectorAll) {
|
|
427
|
-
element
|
|
428
|
-
.querySelectorAll('buyer-intent-tag,[data-buyer-intent]')
|
|
429
|
-
.forEach((nested) => trackTaggedPageview(nested));
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
const observer = new MutationObserver((mutations) => {
|
|
434
|
-
mutations.forEach((mutation) => {
|
|
435
|
-
mutation.addedNodes.forEach((node) => {
|
|
436
|
-
if (node.nodeType === 1) {
|
|
437
|
-
handleElement(node);
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
observer.observe(document.documentElement || document.body, {
|
|
444
|
-
childList: true,
|
|
445
|
-
subtree: true,
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
document
|
|
449
|
-
.querySelectorAll('buyer-intent-tag,[data-buyer-intent]')
|
|
450
|
-
.forEach((element) => trackTaggedPageview(element));
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
observeTagElements();
|
|
454
|
-
|
|
455
|
-
return {
|
|
456
|
-
init,
|
|
457
|
-
trackPageview,
|
|
458
|
-
trackClick,
|
|
459
|
-
trackTaggedPageview,
|
|
460
|
-
tagPage,
|
|
461
|
-
setBaseProperties,
|
|
462
|
-
setVisitProperties,
|
|
463
|
-
setActivityEndpoint,
|
|
464
|
-
trackNextRouter,
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
export const buyerIntent = createBuyerIntentSDK();
|
package/browser/tag_component.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
function trackerElement({
|
|
4
|
-
productIds,
|
|
5
|
-
categoryIds,
|
|
6
|
-
tag,
|
|
7
|
-
sourceLocation,
|
|
8
|
-
context,
|
|
9
|
-
origin,
|
|
10
|
-
activityEndpoint,
|
|
11
|
-
userType,
|
|
12
|
-
distinctId,
|
|
13
|
-
eventName,
|
|
14
|
-
trigger,
|
|
15
|
-
children,
|
|
16
|
-
}) {
|
|
17
|
-
const payload = {
|
|
18
|
-
productIds,
|
|
19
|
-
categoryIds,
|
|
20
|
-
tag,
|
|
21
|
-
sourceLocation,
|
|
22
|
-
context,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return React.createElement(
|
|
26
|
-
'buyer-intent-tag',
|
|
27
|
-
{
|
|
28
|
-
'data-buyer-intent': JSON.stringify(payload),
|
|
29
|
-
'data-origin': origin,
|
|
30
|
-
'data-activity-endpoint': activityEndpoint,
|
|
31
|
-
'data-user-type': userType,
|
|
32
|
-
'data-distinct-id': distinctId,
|
|
33
|
-
'data-event-name': eventName,
|
|
34
|
-
'data-trigger': trigger,
|
|
35
|
-
},
|
|
36
|
-
children
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function ViewTracker(props) {
|
|
41
|
-
return trackerElement({ ...props, trigger: 'view' });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function ClickTracker(props) {
|
|
45
|
-
return trackerElement({ ...props, trigger: 'click' });
|
|
46
|
-
}
|
package/browser/trackers.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ViewTracker, ClickTracker } from './tag_component.js';
|
|
3
|
-
|
|
4
|
-
function view(tag, props) {
|
|
5
|
-
return React.createElement(ViewTracker, { ...props, tag });
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function click(eventName, props) {
|
|
9
|
-
return React.createElement(ClickTracker, { ...props, eventName });
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function CompareView({ productIds, ...rest }) {
|
|
13
|
-
return view('comparisons.show', { ...rest, productIds });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function CompetitorsView({ productId, ...rest }) {
|
|
17
|
-
return view('products.competitors', { ...rest, productIds: [productId] });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function ProfileView({ productId, ...rest }) {
|
|
21
|
-
return view('products.show', { ...rest, productIds: [productId] });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function PricingView({ productId, ...rest }) {
|
|
25
|
-
return view('products.pricing', { ...rest, productIds: [productId] });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function CategoryView({ categoryId, ...rest }) {
|
|
29
|
-
return view('categories.show', { ...rest, categoryIds: [categoryId] });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function WriteReviewView({ productId, ...rest }) {
|
|
33
|
-
return view('reviewers.take_survey', { ...rest, productIds: [productId] });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function AdClick({ productId, ...rest }) {
|
|
37
|
-
return click('/ad/clicked', { ...rest, productIds: [productId] });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function LeadCreateClick({ productId, ...rest }) {
|
|
41
|
-
return click('/leads/create', { ...rest, productIds: [productId] });
|
|
42
|
-
}
|