@atlaskit/smart-card 23.11.3 → 23.12.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/CHANGELOG.md +10 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +216 -146
- package/dist/cjs/utils/analytics/analytics.js +134 -74
- package/dist/cjs/utils/analytics/index.js +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +27 -1
- package/dist/cjs/view/EmbedCard/components/Frame.js +110 -5
- package/dist/cjs/view/EmbedCard/components/IframeDwellTracker.js +75 -0
- package/dist/cjs/view/EmbedCard/index.js +6 -2
- package/dist/cjs/view/EmbedCard/views/ResolvedView.js +6 -2
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +69 -1
- package/dist/es2019/utils/analytics/analytics.js +52 -0
- package/dist/es2019/utils/analytics/index.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +27 -1
- package/dist/es2019/view/EmbedCard/components/Frame.js +91 -6
- package/dist/es2019/view/EmbedCard/components/IframeDwellTracker.js +57 -0
- package/dist/es2019/view/EmbedCard/index.js +6 -2
- package/dist/es2019/view/EmbedCard/views/ResolvedView.js +6 -2
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +217 -147
- package/dist/esm/utils/analytics/analytics.js +127 -73
- package/dist/esm/utils/analytics/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +27 -1
- package/dist/esm/view/EmbedCard/components/Frame.js +110 -6
- package/dist/esm/view/EmbedCard/components/IframeDwellTracker.js +62 -0
- package/dist/esm/view/EmbedCard/index.js +6 -2
- package/dist/esm/view/EmbedCard/views/ResolvedView.js +6 -2
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +27 -1
- package/dist/types/state/flexible-ui-context/index.d.ts +4 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +2 -0
- package/dist/types/utils/analytics/analytics.d.ts +3 -1
- package/dist/types/utils/analytics/index.d.ts +1 -1
- package/dist/types/utils/analytics/types.d.ts +12 -0
- package/dist/types/utils/mocks.d.ts +2 -0
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/view/EmbedCard/components/Frame.d.ts +2 -0
- package/dist/types/view/EmbedCard/components/IframeDwellTracker.d.ts +8 -0
- package/dist/types/view/EmbedCard/types.d.ts +2 -0
- package/dist/types/view/EmbedCard/views/ResolvedView.d.ts +4 -0
- package/package.json +2 -2
- package/report.api.md +42 -1
- package/tmp/api-report-tmp.d.ts +20 -2
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.unresolvedEvent = exports.uiRenderSuccessEvent = exports.uiRenderFailedEvent = exports.uiLearnMoreLinkClickedEvent = exports.uiHoverCardViewedEvent = exports.uiHoverCardOpenLinkClickedEvent = exports.uiHoverCardDismissedEvent = exports.uiClosedAuthEvent = exports.uiCardClickedEvent = exports.uiAuthEvent = exports.uiAuthAlternateAccountEvent = exports.uiActionClickedEvent = exports.trackLinkUpdated = exports.trackAppAccountConnected = exports.trackAppAccountAuthStarted = exports.screenAuthPopupEvent = exports.resolvedEvent = exports.invokeSucceededEvent = exports.invokeFailedEvent = exports.fireSmartLinkEvent = exports.context = exports.connectSucceededEvent = exports.connectFailedEvent = exports.chunkloadFailedEvent = exports.SmartLinkEvents = exports.ANALYTICS_CHANNEL = void 0;
|
|
8
|
+
exports.unresolvedEvent = exports.uiRenderSuccessEvent = exports.uiRenderFailedEvent = exports.uiLearnMoreLinkClickedEvent = exports.uiIframeFocusedEvent = exports.uiIframeDwelledEvent = exports.uiHoverCardViewedEvent = exports.uiHoverCardOpenLinkClickedEvent = exports.uiHoverCardDismissedEvent = exports.uiClosedAuthEvent = exports.uiCardClickedEvent = exports.uiAuthEvent = exports.uiAuthAlternateAccountEvent = exports.uiActionClickedEvent = exports.trackLinkUpdated = exports.trackAppAccountConnected = exports.trackAppAccountAuthStarted = exports.screenAuthPopupEvent = exports.resolvedEvent = exports.invokeSucceededEvent = exports.invokeFailedEvent = exports.fireSmartLinkEvent = exports.context = exports.connectSucceededEvent = exports.connectFailedEvent = exports.chunkloadFailedEvent = exports.SmartLinkEvents = exports.ANALYTICS_CHANNEL = void 0;
|
|
9
9
|
|
|
10
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
11
|
|
|
@@ -373,15 +373,75 @@ var uiCardClickedEvent = function uiCardClickedEvent(_ref11) {
|
|
|
373
373
|
|
|
374
374
|
exports.uiCardClickedEvent = uiCardClickedEvent;
|
|
375
375
|
|
|
376
|
-
var
|
|
376
|
+
var uiIframeDwelledEvent = function uiIframeDwelledEvent(_ref12) {
|
|
377
377
|
var id = _ref12.id,
|
|
378
|
-
actionType = _ref12.actionType,
|
|
379
|
-
extensionKey = _ref12.extensionKey,
|
|
380
378
|
display = _ref12.display,
|
|
379
|
+
status = _ref12.status,
|
|
381
380
|
definitionId = _ref12.definitionId,
|
|
381
|
+
extensionKey = _ref12.extensionKey,
|
|
382
|
+
location = _ref12.location,
|
|
382
383
|
destinationProduct = _ref12.destinationProduct,
|
|
383
384
|
destinationSubproduct = _ref12.destinationSubproduct,
|
|
384
|
-
|
|
385
|
+
dwellTime = _ref12.dwellTime,
|
|
386
|
+
dwellPercentVisible = _ref12.dwellPercentVisible;
|
|
387
|
+
return {
|
|
388
|
+
action: 'dwelled',
|
|
389
|
+
actionSubject: 'smartLinkIframe',
|
|
390
|
+
eventType: 'ui',
|
|
391
|
+
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
392
|
+
id: id,
|
|
393
|
+
status: status,
|
|
394
|
+
definitionId: definitionId,
|
|
395
|
+
extensionKey: extensionKey,
|
|
396
|
+
display: display,
|
|
397
|
+
location: location,
|
|
398
|
+
destinationProduct: destinationProduct,
|
|
399
|
+
destinationSubproduct: destinationSubproduct,
|
|
400
|
+
dwellTime: dwellTime,
|
|
401
|
+
dwellPercentVisible: dwellPercentVisible
|
|
402
|
+
})
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
exports.uiIframeDwelledEvent = uiIframeDwelledEvent;
|
|
407
|
+
|
|
408
|
+
var uiIframeFocusedEvent = function uiIframeFocusedEvent(_ref13) {
|
|
409
|
+
var id = _ref13.id,
|
|
410
|
+
display = _ref13.display,
|
|
411
|
+
status = _ref13.status,
|
|
412
|
+
definitionId = _ref13.definitionId,
|
|
413
|
+
extensionKey = _ref13.extensionKey,
|
|
414
|
+
location = _ref13.location,
|
|
415
|
+
destinationProduct = _ref13.destinationProduct,
|
|
416
|
+
destinationSubproduct = _ref13.destinationSubproduct;
|
|
417
|
+
return {
|
|
418
|
+
action: 'focused',
|
|
419
|
+
actionSubject: 'smartLinkIframe',
|
|
420
|
+
eventType: 'ui',
|
|
421
|
+
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
422
|
+
id: id,
|
|
423
|
+
status: status,
|
|
424
|
+
definitionId: definitionId,
|
|
425
|
+
extensionKey: extensionKey,
|
|
426
|
+
display: display,
|
|
427
|
+
location: location,
|
|
428
|
+
destinationProduct: destinationProduct,
|
|
429
|
+
destinationSubproduct: destinationSubproduct
|
|
430
|
+
})
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
exports.uiIframeFocusedEvent = uiIframeFocusedEvent;
|
|
435
|
+
|
|
436
|
+
var uiActionClickedEvent = function uiActionClickedEvent(_ref14) {
|
|
437
|
+
var id = _ref14.id,
|
|
438
|
+
actionType = _ref14.actionType,
|
|
439
|
+
extensionKey = _ref14.extensionKey,
|
|
440
|
+
display = _ref14.display,
|
|
441
|
+
definitionId = _ref14.definitionId,
|
|
442
|
+
destinationProduct = _ref14.destinationProduct,
|
|
443
|
+
destinationSubproduct = _ref14.destinationSubproduct,
|
|
444
|
+
location = _ref14.location;
|
|
385
445
|
return {
|
|
386
446
|
action: 'clicked',
|
|
387
447
|
actionSubject: 'button',
|
|
@@ -402,13 +462,13 @@ var uiActionClickedEvent = function uiActionClickedEvent(_ref12) {
|
|
|
402
462
|
|
|
403
463
|
exports.uiActionClickedEvent = uiActionClickedEvent;
|
|
404
464
|
|
|
405
|
-
var uiClosedAuthEvent = function uiClosedAuthEvent(
|
|
406
|
-
var display =
|
|
407
|
-
extensionKey =
|
|
408
|
-
definitionId =
|
|
409
|
-
destinationProduct =
|
|
410
|
-
destinationSubproduct =
|
|
411
|
-
location =
|
|
465
|
+
var uiClosedAuthEvent = function uiClosedAuthEvent(_ref15) {
|
|
466
|
+
var display = _ref15.display,
|
|
467
|
+
extensionKey = _ref15.extensionKey,
|
|
468
|
+
definitionId = _ref15.definitionId,
|
|
469
|
+
destinationProduct = _ref15.destinationProduct,
|
|
470
|
+
destinationSubproduct = _ref15.destinationSubproduct,
|
|
471
|
+
location = _ref15.location;
|
|
412
472
|
return {
|
|
413
473
|
action: 'closed',
|
|
414
474
|
actionSubject: 'consentModal',
|
|
@@ -426,12 +486,12 @@ var uiClosedAuthEvent = function uiClosedAuthEvent(_ref13) {
|
|
|
426
486
|
|
|
427
487
|
exports.uiClosedAuthEvent = uiClosedAuthEvent;
|
|
428
488
|
|
|
429
|
-
var screenAuthPopupEvent = function screenAuthPopupEvent(
|
|
430
|
-
var extensionKey =
|
|
431
|
-
definitionId =
|
|
432
|
-
destinationProduct =
|
|
433
|
-
destinationSubproduct =
|
|
434
|
-
location =
|
|
489
|
+
var screenAuthPopupEvent = function screenAuthPopupEvent(_ref16) {
|
|
490
|
+
var extensionKey = _ref16.extensionKey,
|
|
491
|
+
definitionId = _ref16.definitionId,
|
|
492
|
+
destinationProduct = _ref16.destinationProduct,
|
|
493
|
+
destinationSubproduct = _ref16.destinationSubproduct,
|
|
494
|
+
location = _ref16.location;
|
|
435
495
|
return {
|
|
436
496
|
actionSubject: 'consentModal',
|
|
437
497
|
eventType: 'screen',
|
|
@@ -447,14 +507,14 @@ var screenAuthPopupEvent = function screenAuthPopupEvent(_ref14) {
|
|
|
447
507
|
|
|
448
508
|
exports.screenAuthPopupEvent = screenAuthPopupEvent;
|
|
449
509
|
|
|
450
|
-
var uiRenderSuccessEvent = function uiRenderSuccessEvent(
|
|
451
|
-
var display =
|
|
452
|
-
status =
|
|
453
|
-
extensionKey =
|
|
454
|
-
definitionId =
|
|
455
|
-
destinationProduct =
|
|
456
|
-
destinationSubproduct =
|
|
457
|
-
location =
|
|
510
|
+
var uiRenderSuccessEvent = function uiRenderSuccessEvent(_ref17) {
|
|
511
|
+
var display = _ref17.display,
|
|
512
|
+
status = _ref17.status,
|
|
513
|
+
extensionKey = _ref17.extensionKey,
|
|
514
|
+
definitionId = _ref17.definitionId,
|
|
515
|
+
destinationProduct = _ref17.destinationProduct,
|
|
516
|
+
destinationSubproduct = _ref17.destinationSubproduct,
|
|
517
|
+
location = _ref17.location;
|
|
458
518
|
return {
|
|
459
519
|
action: 'renderSuccess',
|
|
460
520
|
actionSubject: 'smartLink',
|
|
@@ -473,15 +533,15 @@ var uiRenderSuccessEvent = function uiRenderSuccessEvent(_ref15) {
|
|
|
473
533
|
|
|
474
534
|
exports.uiRenderSuccessEvent = uiRenderSuccessEvent;
|
|
475
535
|
|
|
476
|
-
var uiRenderFailedEvent = function uiRenderFailedEvent(
|
|
477
|
-
var display =
|
|
478
|
-
error =
|
|
479
|
-
errorInfo =
|
|
480
|
-
extensionKey =
|
|
481
|
-
definitionId =
|
|
482
|
-
destinationProduct =
|
|
483
|
-
destinationSubproduct =
|
|
484
|
-
location =
|
|
536
|
+
var uiRenderFailedEvent = function uiRenderFailedEvent(_ref18) {
|
|
537
|
+
var display = _ref18.display,
|
|
538
|
+
error = _ref18.error,
|
|
539
|
+
errorInfo = _ref18.errorInfo,
|
|
540
|
+
extensionKey = _ref18.extensionKey,
|
|
541
|
+
definitionId = _ref18.definitionId,
|
|
542
|
+
destinationProduct = _ref18.destinationProduct,
|
|
543
|
+
destinationSubproduct = _ref18.destinationSubproduct,
|
|
544
|
+
location = _ref18.location;
|
|
485
545
|
return {
|
|
486
546
|
actionSubject: 'smartLink',
|
|
487
547
|
action: 'renderFailed',
|
|
@@ -501,16 +561,16 @@ var uiRenderFailedEvent = function uiRenderFailedEvent(_ref16) {
|
|
|
501
561
|
|
|
502
562
|
exports.uiRenderFailedEvent = uiRenderFailedEvent;
|
|
503
563
|
|
|
504
|
-
var uiHoverCardViewedEvent = function uiHoverCardViewedEvent(
|
|
505
|
-
var id =
|
|
506
|
-
previewDisplay =
|
|
507
|
-
extensionKey =
|
|
508
|
-
definitionId =
|
|
509
|
-
destinationProduct =
|
|
510
|
-
destinationSubproduct =
|
|
511
|
-
location =
|
|
512
|
-
previewInvokeMethod =
|
|
513
|
-
status =
|
|
564
|
+
var uiHoverCardViewedEvent = function uiHoverCardViewedEvent(_ref19) {
|
|
565
|
+
var id = _ref19.id,
|
|
566
|
+
previewDisplay = _ref19.previewDisplay,
|
|
567
|
+
extensionKey = _ref19.extensionKey,
|
|
568
|
+
definitionId = _ref19.definitionId,
|
|
569
|
+
destinationProduct = _ref19.destinationProduct,
|
|
570
|
+
destinationSubproduct = _ref19.destinationSubproduct,
|
|
571
|
+
location = _ref19.location,
|
|
572
|
+
previewInvokeMethod = _ref19.previewInvokeMethod,
|
|
573
|
+
status = _ref19.status;
|
|
514
574
|
return {
|
|
515
575
|
action: 'viewed',
|
|
516
576
|
actionSubject: 'hoverCard',
|
|
@@ -531,17 +591,17 @@ var uiHoverCardViewedEvent = function uiHoverCardViewedEvent(_ref17) {
|
|
|
531
591
|
|
|
532
592
|
exports.uiHoverCardViewedEvent = uiHoverCardViewedEvent;
|
|
533
593
|
|
|
534
|
-
var uiHoverCardDismissedEvent = function uiHoverCardDismissedEvent(
|
|
535
|
-
var id =
|
|
536
|
-
previewDisplay =
|
|
537
|
-
hoverTime =
|
|
538
|
-
extensionKey =
|
|
539
|
-
definitionId =
|
|
540
|
-
destinationProduct =
|
|
541
|
-
destinationSubproduct =
|
|
542
|
-
location =
|
|
543
|
-
previewInvokeMethod =
|
|
544
|
-
status =
|
|
594
|
+
var uiHoverCardDismissedEvent = function uiHoverCardDismissedEvent(_ref20) {
|
|
595
|
+
var id = _ref20.id,
|
|
596
|
+
previewDisplay = _ref20.previewDisplay,
|
|
597
|
+
hoverTime = _ref20.hoverTime,
|
|
598
|
+
extensionKey = _ref20.extensionKey,
|
|
599
|
+
definitionId = _ref20.definitionId,
|
|
600
|
+
destinationProduct = _ref20.destinationProduct,
|
|
601
|
+
destinationSubproduct = _ref20.destinationSubproduct,
|
|
602
|
+
location = _ref20.location,
|
|
603
|
+
previewInvokeMethod = _ref20.previewInvokeMethod,
|
|
604
|
+
status = _ref20.status;
|
|
545
605
|
return {
|
|
546
606
|
action: 'dismissed',
|
|
547
607
|
actionSubject: 'hoverCard',
|
|
@@ -563,15 +623,15 @@ var uiHoverCardDismissedEvent = function uiHoverCardDismissedEvent(_ref18) {
|
|
|
563
623
|
|
|
564
624
|
exports.uiHoverCardDismissedEvent = uiHoverCardDismissedEvent;
|
|
565
625
|
|
|
566
|
-
var uiHoverCardOpenLinkClickedEvent = function uiHoverCardOpenLinkClickedEvent(
|
|
567
|
-
var id =
|
|
568
|
-
previewDisplay =
|
|
569
|
-
extensionKey =
|
|
570
|
-
definitionId =
|
|
571
|
-
destinationProduct =
|
|
572
|
-
destinationSubproduct =
|
|
573
|
-
location =
|
|
574
|
-
previewInvokeMethod =
|
|
626
|
+
var uiHoverCardOpenLinkClickedEvent = function uiHoverCardOpenLinkClickedEvent(_ref21) {
|
|
627
|
+
var id = _ref21.id,
|
|
628
|
+
previewDisplay = _ref21.previewDisplay,
|
|
629
|
+
extensionKey = _ref21.extensionKey,
|
|
630
|
+
definitionId = _ref21.definitionId,
|
|
631
|
+
destinationProduct = _ref21.destinationProduct,
|
|
632
|
+
destinationSubproduct = _ref21.destinationSubproduct,
|
|
633
|
+
location = _ref21.location,
|
|
634
|
+
previewInvokeMethod = _ref21.previewInvokeMethod;
|
|
575
635
|
return {
|
|
576
636
|
action: 'clicked',
|
|
577
637
|
actionSubject: 'button',
|
|
@@ -604,15 +664,15 @@ var uiLearnMoreLinkClickedEvent = function uiLearnMoreLinkClickedEvent() {
|
|
|
604
664
|
|
|
605
665
|
exports.uiLearnMoreLinkClickedEvent = uiLearnMoreLinkClickedEvent;
|
|
606
666
|
|
|
607
|
-
var chunkloadFailedEvent = function chunkloadFailedEvent(
|
|
608
|
-
var display =
|
|
609
|
-
error =
|
|
610
|
-
errorInfo =
|
|
611
|
-
extensionKey =
|
|
612
|
-
definitionId =
|
|
613
|
-
destinationProduct =
|
|
614
|
-
destinationSubproduct =
|
|
615
|
-
location =
|
|
667
|
+
var chunkloadFailedEvent = function chunkloadFailedEvent(_ref22) {
|
|
668
|
+
var display = _ref22.display,
|
|
669
|
+
error = _ref22.error,
|
|
670
|
+
errorInfo = _ref22.errorInfo,
|
|
671
|
+
extensionKey = _ref22.extensionKey,
|
|
672
|
+
definitionId = _ref22.definitionId,
|
|
673
|
+
destinationProduct = _ref22.destinationProduct,
|
|
674
|
+
destinationSubproduct = _ref22.destinationSubproduct,
|
|
675
|
+
location = _ref22.location;
|
|
616
676
|
return {
|
|
617
677
|
action: 'chunkLoadFailed',
|
|
618
678
|
actionSubject: 'smartLink',
|
|
@@ -126,6 +126,12 @@ Object.defineProperty(exports, "uiHoverCardViewedEvent", {
|
|
|
126
126
|
return _analytics.uiHoverCardViewedEvent;
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
|
+
Object.defineProperty(exports, "uiIframeDwelledEvent", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function get() {
|
|
132
|
+
return _analytics.uiIframeDwelledEvent;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
129
135
|
Object.defineProperty(exports, "uiLearnMoreLinkClickedEvent", {
|
|
130
136
|
enumerable: true,
|
|
131
137
|
get: function get() {
|
package/dist/cjs/version.json
CHANGED
|
@@ -147,6 +147,30 @@ function CardWithUrlContent(_ref) {
|
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
}, [appearance, state.status, url, definitionId, extensionKey, analytics.ui, id]);
|
|
150
|
+
var onIframeDwell = (0, _react.useCallback)(function (dwellTime, dwellPercentVisible) {
|
|
151
|
+
analytics.ui.iframeDwelledEvent({
|
|
152
|
+
id: id,
|
|
153
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
154
|
+
status: state.status,
|
|
155
|
+
definitionId: definitionId,
|
|
156
|
+
extensionKey: extensionKey,
|
|
157
|
+
destinationProduct: product,
|
|
158
|
+
destinationSubproduct: subproduct,
|
|
159
|
+
dwellTime: dwellTime,
|
|
160
|
+
dwellPercentVisible: dwellPercentVisible
|
|
161
|
+
});
|
|
162
|
+
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, isFlexibleUi, product, subproduct]);
|
|
163
|
+
var onIframeFocus = (0, _react.useCallback)(function () {
|
|
164
|
+
analytics.ui.iframeFocusedEvent({
|
|
165
|
+
id: id,
|
|
166
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
167
|
+
status: state.status,
|
|
168
|
+
definitionId: definitionId,
|
|
169
|
+
extensionKey: extensionKey,
|
|
170
|
+
destinationProduct: product,
|
|
171
|
+
destinationSubproduct: subproduct
|
|
172
|
+
});
|
|
173
|
+
}, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, isFlexibleUi, product, subproduct]);
|
|
150
174
|
|
|
151
175
|
if (isFlexibleUi) {
|
|
152
176
|
var cardState = state;
|
|
@@ -238,7 +262,9 @@ function CardWithUrlContent(_ref) {
|
|
|
238
262
|
testId: testId,
|
|
239
263
|
inheritDimensions: inheritDimensions,
|
|
240
264
|
showActions: showActions,
|
|
241
|
-
ref: embedIframeRef
|
|
265
|
+
ref: embedIframeRef,
|
|
266
|
+
onIframeDwell: onIframeDwell,
|
|
267
|
+
onIframeFocus: onIframeFocus
|
|
242
268
|
});
|
|
243
269
|
}
|
|
244
270
|
}
|
|
@@ -17,28 +17,127 @@ var _react2 = _interopRequireWildcard(require("react"));
|
|
|
17
17
|
|
|
18
18
|
var _utils = require("../../../utils");
|
|
19
19
|
|
|
20
|
+
var _IframeDwellTracker = require("./IframeDwellTracker");
|
|
21
|
+
|
|
22
|
+
var _linkProvider = require("@atlaskit/link-provider");
|
|
23
|
+
|
|
20
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
25
|
|
|
22
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
27
|
|
|
24
28
|
/** @jsx jsx */
|
|
29
|
+
function mergeRefs(refs) {
|
|
30
|
+
return function (value) {
|
|
31
|
+
refs.forEach(function (ref) {
|
|
32
|
+
if (typeof ref === 'function') {
|
|
33
|
+
ref(value);
|
|
34
|
+
} else if (ref !== null) {
|
|
35
|
+
ref.current = value;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
25
41
|
var Frame = /*#__PURE__*/_react2.default.forwardRef(function (_ref, iframeRef) {
|
|
26
42
|
var url = _ref.url,
|
|
27
43
|
_ref$isTrusted = _ref.isTrusted,
|
|
28
44
|
isTrusted = _ref$isTrusted === void 0 ? false : _ref$isTrusted,
|
|
29
|
-
testId = _ref.testId
|
|
45
|
+
testId = _ref.testId,
|
|
46
|
+
onIframeDwell = _ref.onIframeDwell,
|
|
47
|
+
onIframeFocus = _ref.onIframeFocus;
|
|
30
48
|
|
|
31
49
|
var _useState = (0, _react2.useState)(false),
|
|
32
50
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
33
51
|
isIframeLoaded = _useState2[0],
|
|
34
52
|
setIframeLoaded = _useState2[1];
|
|
35
53
|
|
|
54
|
+
var _useState3 = (0, _react2.useState)(false),
|
|
55
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
56
|
+
isMouseOver = _useState4[0],
|
|
57
|
+
setMouseOver = _useState4[1];
|
|
58
|
+
|
|
59
|
+
var _useState5 = (0, _react2.useState)(true),
|
|
60
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
61
|
+
isWindowFocused = _useState6[0],
|
|
62
|
+
setWindowFocused = _useState6[1];
|
|
63
|
+
|
|
64
|
+
var ref = (0, _react2.useRef)();
|
|
65
|
+
var mergedRef = mergeRefs([iframeRef, ref]);
|
|
66
|
+
var trackIframeDwellEvents = (0, _linkProvider.useFeatureFlag)('trackIframeDwellEvents');
|
|
67
|
+
|
|
68
|
+
var _useState7 = (0, _react2.useState)(0),
|
|
69
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
70
|
+
percentVisible = _useState8[0],
|
|
71
|
+
setPercentVisible = _useState8[1];
|
|
72
|
+
/**
|
|
73
|
+
* These are the 'percent visible' thresholds at which the intersectionObserver will
|
|
74
|
+
* trigger a state change. Eg. when the user scrolls and moves from 74% to 76%, or
|
|
75
|
+
* vice versa. It's in a state object so that its static for the useEffect
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
var _useState9 = (0, _react2.useState)([0.75, 0.8, 0.85, 0.9, 0.95, 1]),
|
|
80
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 1),
|
|
81
|
+
threshold = _useState10[0];
|
|
82
|
+
|
|
83
|
+
(0, _react2.useEffect)(function () {
|
|
84
|
+
if (!trackIframeDwellEvents) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!ref || !ref.current) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var observer = new IntersectionObserver(function (entries) {
|
|
93
|
+
entries.forEach(function (entry) {
|
|
94
|
+
setPercentVisible(entry === null || entry === void 0 ? void 0 : entry.intersectionRatio);
|
|
95
|
+
});
|
|
96
|
+
}, {
|
|
97
|
+
threshold: threshold
|
|
98
|
+
});
|
|
99
|
+
observer.observe(ref.current);
|
|
100
|
+
return function () {
|
|
101
|
+
observer.disconnect();
|
|
102
|
+
};
|
|
103
|
+
}, [trackIframeDwellEvents, threshold, mergedRef]);
|
|
104
|
+
(0, _react2.useEffect)(function () {
|
|
105
|
+
if (!trackIframeDwellEvents) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var onBlur = function onBlur() {
|
|
110
|
+
setWindowFocused(false);
|
|
111
|
+
|
|
112
|
+
if (document.activeElement === ref.current) {
|
|
113
|
+
onIframeFocus && onIframeFocus();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var onFocus = function onFocus() {
|
|
118
|
+
setWindowFocused(true);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
window.addEventListener('blur', onBlur);
|
|
122
|
+
window.addEventListener('focus', onFocus);
|
|
123
|
+
return function () {
|
|
124
|
+
window.removeEventListener('blur', onBlur);
|
|
125
|
+
window.removeEventListener('focus', onFocus);
|
|
126
|
+
};
|
|
127
|
+
}, [trackIframeDwellEvents, ref, onIframeFocus]);
|
|
128
|
+
|
|
36
129
|
if (!url) {
|
|
37
130
|
return null;
|
|
38
131
|
}
|
|
39
132
|
|
|
40
|
-
return (0, _react.jsx)(
|
|
41
|
-
|
|
133
|
+
return (0, _react.jsx)(_react2.default.Fragment, null, trackIframeDwellEvents ? (0, _react.jsx)(_IframeDwellTracker.IframeDwellTracker, {
|
|
134
|
+
isIframeLoaded: isIframeLoaded,
|
|
135
|
+
isMouseOver: isMouseOver,
|
|
136
|
+
isWindowFocused: isWindowFocused,
|
|
137
|
+
iframePercentVisible: percentVisible,
|
|
138
|
+
onIframeDwell: onIframeDwell
|
|
139
|
+
}) : null, (0, _react.jsx)("iframe", {
|
|
140
|
+
ref: mergedRef,
|
|
42
141
|
src: url,
|
|
43
142
|
"data-testid": "".concat(testId, "-frame"),
|
|
44
143
|
"data-iframe-loaded": isIframeLoaded,
|
|
@@ -52,14 +151,20 @@ var Frame = /*#__PURE__*/_react2.default.forwardRef(function (_ref, iframeRef) {
|
|
|
52
151
|
overflow: 'hidden',
|
|
53
152
|
borderRadius: '3px'
|
|
54
153
|
},
|
|
154
|
+
onMouseEnter: trackIframeDwellEvents ? function () {
|
|
155
|
+
return setMouseOver(true);
|
|
156
|
+
} : undefined,
|
|
157
|
+
onMouseLeave: trackIframeDwellEvents ? function () {
|
|
158
|
+
return setMouseOver(false);
|
|
159
|
+
} : undefined,
|
|
55
160
|
allowFullScreen: true,
|
|
56
161
|
scrolling: "yes",
|
|
57
162
|
allow: "autoplay; encrypted-media; clipboard-write",
|
|
58
163
|
onLoad: function onLoad() {
|
|
59
|
-
|
|
164
|
+
setIframeLoaded(true);
|
|
60
165
|
},
|
|
61
166
|
sandbox: (0, _utils.getIframeSandboxAttribute)(isTrusted)
|
|
62
|
-
});
|
|
167
|
+
}));
|
|
63
168
|
});
|
|
64
169
|
|
|
65
170
|
exports.Frame = Frame;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.IframeDwellTracker = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
14
|
+
/** @jsx jsx */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A kind of cheap logarithmic backoff. Fire analytics after the user has
|
|
18
|
+
* dwelled for 5 seconds, then 10 seconds, and so on.
|
|
19
|
+
*/
|
|
20
|
+
var INTERVALS_TO_LOG = [5, 10, 15, 20, 25, 30, 45, 60, 90, 120, 180];
|
|
21
|
+
|
|
22
|
+
var IframeDwellTracker = function IframeDwellTracker(_ref) {
|
|
23
|
+
var isIframeLoaded = _ref.isIframeLoaded,
|
|
24
|
+
isMouseOver = _ref.isMouseOver,
|
|
25
|
+
isWindowFocused = _ref.isWindowFocused,
|
|
26
|
+
iframePercentVisible = _ref.iframePercentVisible,
|
|
27
|
+
onIframeDwell = _ref.onIframeDwell;
|
|
28
|
+
|
|
29
|
+
var _useState = (0, _react.useState)({
|
|
30
|
+
time: 0,
|
|
31
|
+
percentVisible: 0
|
|
32
|
+
}),
|
|
33
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
34
|
+
dwell = _useState2[0],
|
|
35
|
+
setDwell = _useState2[1];
|
|
36
|
+
|
|
37
|
+
var dwellTimeoutId = (0, _react.useRef)(); // fire analytics when the dwell timer reaches 5 seconds
|
|
38
|
+
|
|
39
|
+
(0, _react.useEffect)(function () {
|
|
40
|
+
if (dwell.time > 0 && INTERVALS_TO_LOG.includes(dwell.time)) {
|
|
41
|
+
onIframeDwell && onIframeDwell(dwell.time, dwell.percentVisible);
|
|
42
|
+
}
|
|
43
|
+
}, [dwell, onIframeDwell]); // start and stop tracking dwell time
|
|
44
|
+
|
|
45
|
+
(0, _react.useEffect)(function () {
|
|
46
|
+
var incrementDwellTime = function incrementDwellTime() {
|
|
47
|
+
// callback is called on dwell state changes, so change percentVisible and time together
|
|
48
|
+
setDwell(function (_ref2) {
|
|
49
|
+
var time = _ref2.time;
|
|
50
|
+
return {
|
|
51
|
+
time: time + 1,
|
|
52
|
+
// snapshot of percent visible, rounded down to nearest 5%
|
|
53
|
+
percentVisible: Math.floor((iframePercentVisible || 0) * 20) * 5
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
if (isIframeLoaded && isMouseOver && isWindowFocused && iframePercentVisible > 0.75) {
|
|
59
|
+
if (dwellTimeoutId.current) {
|
|
60
|
+
clearInterval(dwellTimeoutId.current);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
dwellTimeoutId.current = setInterval(incrementDwellTime, 1000);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return function () {
|
|
67
|
+
if (dwellTimeoutId.current) {
|
|
68
|
+
clearInterval(dwellTimeoutId.current);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [setDwell, isMouseOver, isWindowFocused, isIframeLoaded, iframePercentVisible]);
|
|
72
|
+
return null;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.IframeDwellTracker = IframeDwellTracker;
|
|
@@ -56,7 +56,9 @@ var EmbedCard = /*#__PURE__*/_react.default.forwardRef(function (_ref, iframeRef
|
|
|
56
56
|
onResolve = _ref.onResolve,
|
|
57
57
|
onError = _ref.onError,
|
|
58
58
|
testId = _ref.testId,
|
|
59
|
-
inheritDimensions = _ref.inheritDimensions
|
|
59
|
+
inheritDimensions = _ref.inheritDimensions,
|
|
60
|
+
onIframeDwell = _ref.onIframeDwell,
|
|
61
|
+
onIframeFocus = _ref.onIframeFocus;
|
|
60
62
|
var data = details && details.data || (0, _jsonld.getEmptyJsonLd)();
|
|
61
63
|
var meta = details && details.meta;
|
|
62
64
|
var extensionKey = (0, _helpers.getExtensionKey)(details);
|
|
@@ -89,7 +91,9 @@ var EmbedCard = /*#__PURE__*/_react.default.forwardRef(function (_ref, iframeRef
|
|
|
89
91
|
isFrameVisible: isFrameVisible,
|
|
90
92
|
inheritDimensions: inheritDimensions,
|
|
91
93
|
onClick: handleFrameClick,
|
|
92
|
-
ref: iframeRef
|
|
94
|
+
ref: iframeRef,
|
|
95
|
+
onIframeDwell: onIframeDwell,
|
|
96
|
+
onIframeFocus: onIframeFocus
|
|
93
97
|
}));
|
|
94
98
|
} else {
|
|
95
99
|
if (platform === 'mobile') {
|
|
@@ -31,7 +31,9 @@ var EmbedCardResolvedView = /*#__PURE__*/_react2.default.forwardRef(function (_r
|
|
|
31
31
|
isTrusted = _ref.isTrusted,
|
|
32
32
|
_ref$testId = _ref.testId,
|
|
33
33
|
testId = _ref$testId === void 0 ? 'embed-card-resolved-view' : _ref$testId,
|
|
34
|
-
inheritDimensions = _ref.inheritDimensions
|
|
34
|
+
inheritDimensions = _ref.inheritDimensions,
|
|
35
|
+
onIframeDwell = _ref.onIframeDwell,
|
|
36
|
+
onIframeFocus = _ref.onIframeFocus;
|
|
35
37
|
var iconFromContext = context === null || context === void 0 ? void 0 : context.icon;
|
|
36
38
|
var src = typeof iconFromContext === 'string' ? iconFromContext : undefined;
|
|
37
39
|
var text = title || (context === null || context === void 0 ? void 0 : context.text);
|
|
@@ -68,7 +70,9 @@ var EmbedCardResolvedView = /*#__PURE__*/_react2.default.forwardRef(function (_r
|
|
|
68
70
|
url: preview === null || preview === void 0 ? void 0 : preview.src,
|
|
69
71
|
isTrusted: isTrusted,
|
|
70
72
|
testId: testId,
|
|
71
|
-
ref: embedIframeRef
|
|
73
|
+
ref: embedIframeRef,
|
|
74
|
+
onIframeDwell: onIframeDwell,
|
|
75
|
+
onIframeFocus: onIframeFocus
|
|
72
76
|
}));
|
|
73
77
|
});
|
|
74
78
|
|