Skip to content

Commit 17d0f06

Browse files
author
Brian Vaughn
committed
Access interaction-tracking API through React.unstable_interactions
1. For CJS bundles, this will just re-export the interaction-tracking package but for UMD builds, it will inline the functionality to avoid breaking backwards compatibility. 2. All new interaction-tracking APIs are tagged as unstabled (e.g. React.unstable_interactions.wrap, import { unstable_track } from 'interaction-tracking')
1 parent 3021a81 commit 17d0f06

File tree

18 files changed

+416
-333
lines changed

18 files changed

+416
-333
lines changed

fixtures/unstable-async/suspense/src/components/App.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import {track, wrap} from 'interaction-tracking';
2-
import React, {Placeholder, PureComponent} from 'react';
1+
import React, {Placeholder, PureComponent, unstable_interactions} from 'react';
32
import {createResource} from 'simple-cache-provider';
43
import {cache} from '../cache';
54
import Spinner from './Spinner';
65
import ContributorListPage from './ContributorListPage';
76

7+
const {track, wrap} = unstable_interactions;
8+
89
const UserPageResource = createResource(() => import('./UserPage'));
910

1011
function UserPageLoader(props) {

fixtures/unstable-async/suspense/src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {track} from 'interaction-tracking';
2-
import React, {Fragment, PureComponent} from 'react';
1+
import React, {Fragment, PureComponent, unstable_interactions} from 'react';
32
import {unstable_createRoot, render} from 'react-dom';
43
import {cache} from './cache';
54
import {
@@ -12,6 +11,8 @@ import App from './components/App';
1211
import Draggable from 'react-draggable';
1312
import './index.css';
1413

14+
const {track} = unstable_interactions;
15+
1516
let handleReset;
1617

1718
class Shell extends PureComponent {

fixtures/unstable-async/suspense/yarn.lock

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3483,7 +3483,11 @@ [email protected], inquirer@^3.0.6:
34833483
through "^2.3.6"
34843484

34853485
interaction-tracking@../../../build/node_modules/interaction-tracking:
3486+
version "16.4.3-alpha.0"
3487+
3488+
34863489
version "0.0.1"
3490+
resolved "https://registry.yarnpkg.com/interaction-tracking/-/interaction-tracking-0.0.1.tgz#08877accb2ec479f2af83d7de7a9ae60b80e8dc5"
34873491

34883492
34893493
version "1.2.0"
@@ -4102,6 +4106,10 @@ js-tokens@^3.0.0, js-tokens@^3.0.2:
41024106
version "3.0.2"
41034107
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
41044108

4109+
"js-tokens@^3.0.0 || ^4.0.0":
4110+
version "4.0.0"
4111+
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
4112+
41054113
js-yaml@^3.4.3, js-yaml@^3.7.0, js-yaml@^3.9.1:
41064114
version "3.10.0"
41074115
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc"
@@ -4389,12 +4397,18 @@ longest@^1.0.1:
43894397
version "1.0.1"
43904398
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
43914399

4392-
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
4400+
loose-envify@^1.0.0, loose-envify@^1.3.1:
43934401
version "1.3.1"
43944402
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
43954403
dependencies:
43964404
js-tokens "^3.0.0"
43974405

4406+
loose-envify@^1.1.0:
4407+
version "1.4.0"
4408+
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
4409+
dependencies:
4410+
js-tokens "^3.0.0 || ^4.0.0"
4411+
43984412
loud-rejection@^1.0.0:
43994413
version "1.6.0"
44004414
resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
@@ -5720,7 +5734,7 @@ react-dev-utils@^5.0.1:
57205734
text-table "0.2.0"
57215735

57225736
react-dom@../../../build/node_modules/react-dom:
5723-
version "16.4.1"
5737+
version "16.4.3-alpha.0"
57245738
dependencies:
57255739
loose-envify "^1.1.0"
57265740
object-assign "^4.1.1"
@@ -5783,8 +5797,9 @@ react-scripts@^1.1.4:
57835797
fsevents "^1.1.3"
57845798

57855799
react@../../../build/node_modules/react:
5786-
version "16.4.1"
5800+
version "16.4.3-alpha.0"
57875801
dependencies:
5802+
interaction-tracking "16.4.3-alpha.0"
57885803
loose-envify "^1.1.0"
57895804
object-assign "^4.1.1"
57905805
prop-types "^15.6.2"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/interaction-tracking-subscriptions.production.min.js');
5+
} else {
6+
module.exports = require('./cjs/interaction-tracking-subscriptions.development.js');
7+
}

packages/interaction-tracking/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "interaction-tracking",
33
"description": "utility for tracking interaction events",
4-
"version": "0.0.1",
4+
"version": "16.4.3-alpha.0",
55
"license": "MIT",
66
"files": [
77
"LICENSE",

packages/interaction-tracking/src/InteractionTracking.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ if (enableInteractionTracking) {
8383
// They should not typically be accessed directly.
8484
export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef};
8585

86-
export function clear(callback: Function): any {
86+
export function unstable_clear(callback: Function): any {
8787
if (!enableInteractionTracking) {
8888
return callback();
8989
}
@@ -98,19 +98,19 @@ export function clear(callback: Function): any {
9898
}
9999
}
100100

101-
export function getCurrent(): Set<Interaction> | null {
101+
export function unstable_getCurrent(): Set<Interaction> | null {
102102
if (!enableInteractionTracking) {
103103
return null;
104104
} else {
105105
return interactionsRef.current;
106106
}
107107
}
108108

109-
export function getThreadID(): number {
109+
export function unstable_getThreadID(): number {
110110
return ++threadIDCounter;
111111
}
112112

113-
export function track(
113+
export function unstable_track(
114114
name: string,
115115
timestamp: number,
116116
callback: Function,
@@ -174,7 +174,7 @@ export function track(
174174
return returnValue;
175175
}
176176

177-
export function wrap(
177+
export function unstable_wrap(
178178
callback: Function,
179179
threadID: number = DEFAULT_THREAD_ID,
180180
): Function {

packages/interaction-tracking/src/InteractionTrackingSubscriptions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ if (enableInteractionTracking) {
1717
subscribers = new Set();
1818
}
1919

20-
export function subscribe(subscriber: Subscriber): void {
20+
export function unstable_subscribe(subscriber: Subscriber): void {
2121
if (enableInteractionTracking) {
2222
subscribers.add(subscriber);
2323
}
2424
}
2525

26-
export function unsubscribe(subscriber: Subscriber): void {
26+
export function unstable_unsubscribe(subscriber: Subscriber): void {
2727
if (enableInteractionTracking) {
2828
subscribers.delete(subscriber);
2929
}

0 commit comments

Comments
 (0)