@connectid-tools/idp-selector-react 6.10.0-alpha.4 → 6.10.0-alpha.6

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/CidButton.d.ts CHANGED
@@ -23,6 +23,7 @@ type CidButtonProps = {
23
23
  onError?: (error: string) => void;
24
24
  showCompatibilityWarnings?: boolean;
25
25
  supportIncognito?: boolean;
26
+ disableAnalytics?: boolean;
26
27
  forceMobile?: boolean;
27
28
  forceIos?: boolean;
28
29
  forceAndroid?: boolean;
package/CidButton.js CHANGED
@@ -22,7 +22,7 @@ import { Overlay } from './Overlay';
22
22
  import { Popup } from './Popup';
23
23
  import { Process } from './Process';
24
24
  import { ThemeContext } from './ThemeContext';
25
- import { useAnalytics } from './analytics';
25
+ import { initialiseAnalytics } from './analytics';
26
26
  import './global.css';
27
27
  import { getCurrentUrlOrigin } from './navigator';
28
28
  import { isIntroTextTypeValid, isRequiredClaimsValid } from './validator';
@@ -30,7 +30,7 @@ import detectIncognito from './incognito';
30
30
  import { getBrowserName, getDeviceType, isAndroid, isIos } from './userAgent';
31
31
  import { hasCertification } from './certification';
32
32
  import { getCompatibility } from './compatibility';
33
- export const CidButton = ({ onProceed, claims, requiredClaims, rpLogoUrl, requiredCertifications, label = 'Verify', size = 'regular', type, introTextType, fullProcessCollapsible = false, participantsUri = 'https://data.directory.connectid.com.au/participants', certificationStatus = 'Active', rpDataSharingDescription = 'Your details will be shared with the current website.', enableManualVerification = false, showAllParticipants = false, theme = 'dark', logoLockupStyle = 'light', showInfoContent = false, onError = () => { }, showCompatibilityWarnings = false, supportIncognito = false, forceMobile = false, // only for testing purposes
33
+ export const CidButton = ({ onProceed, claims, requiredClaims, rpLogoUrl, requiredCertifications, label = 'Verify', size = 'regular', type, introTextType, fullProcessCollapsible = false, participantsUri = 'https://data.directory.connectid.com.au/participants', certificationStatus = 'Active', rpDataSharingDescription = 'Your details will be shared with the current website.', enableManualVerification = false, showAllParticipants = false, theme = 'dark', logoLockupStyle = 'light', showInfoContent = false, onError = () => { }, showCompatibilityWarnings = false, supportIncognito = false, disableAnalytics = false, forceMobile = false, // only for testing purposes
34
34
  forceIos = false, // only for testing purposes
35
35
  forceAndroid = false, // only for testing purposes
36
36
  forceIncognito = false, // only for testing purposes
@@ -42,7 +42,6 @@ forceBrowser = undefined, // only for testing purposes
42
42
  throw new Error(response.statusText);
43
43
  return response.json();
44
44
  }));
45
- useAnalytics();
46
45
  const [showPopup, setShowPopup] = useState(false);
47
46
  const [isIncognito, setIsIncognito] = useState();
48
47
  const analyticsData = {
@@ -116,8 +115,14 @@ forceBrowser = undefined, // only for testing purposes
116
115
  setIsIncognito(undefined);
117
116
  incognito = undefined;
118
117
  }
119
- analytics === null || analytics === void 0 ? void 0 : analytics.track('ConnectID Button Displayed', Object.assign(Object.assign({}, analyticsData), { incognito }));
118
+ initialiseAnalytics((analytics) => {
119
+ if (typeof analytics !== 'undefined') {
120
+ analytics.track('ConnectID Button Displayed', Object.assign(Object.assign({}, analyticsData), { incognito }));
121
+ }
122
+ });
120
123
  });
124
+ if (disableAnalytics)
125
+ return;
121
126
  track();
122
127
  }, []);
123
128
  const getCompatibilityConfirmText = (compatibilityWarnings) => {
@@ -127,7 +132,9 @@ forceBrowser = undefined, // only for testing purposes
127
132
  return 'It looks like you are in incognito mode. This generally will not work - we suggest switching out of incognito mode and trying again.\nClick on "Cancel" to abort or "OK" to proceed.';
128
133
  };
129
134
  const handleOnProceed = (authorisationServerId, authorisationServerName, authorisationServerCertifications) => {
130
- analytics === null || analytics === void 0 ? void 0 : analytics.track('IDP Selected', Object.assign(Object.assign({}, analyticsData), { authorisationServerId, idp_name: authorisationServerName, incognito: isIncognito }));
135
+ if (typeof analytics !== 'undefined') {
136
+ analytics.track('IDP Selected', Object.assign(Object.assign({}, analyticsData), { authorisationServerId, idp_name: authorisationServerName, incognito: isIncognito }));
137
+ }
131
138
  setShowPopup(false);
132
139
  const isMobile = forceMobile || getDeviceType() === 'mobile';
133
140
  const idpHasAppCertification = hasCertification(authorisationServerCertifications, 'Channel', 'app');
@@ -154,11 +161,15 @@ forceBrowser = undefined, // only for testing purposes
154
161
  };
155
162
  const handleButtonClick = () => {
156
163
  setShowPopup(true);
157
- analytics === null || analytics === void 0 ? void 0 : analytics.track('ConnectID Button Clicked', Object.assign(Object.assign({}, analyticsData), { incognito: isIncognito }));
164
+ if (typeof analytics !== 'undefined') {
165
+ analytics.track('ConnectID Button Clicked', Object.assign(Object.assign({}, analyticsData), { incognito: isIncognito }));
166
+ }
158
167
  };
159
168
  const handleClosePopup = () => {
160
169
  setShowPopup(false);
161
- analytics === null || analytics === void 0 ? void 0 : analytics.track('IDP Selector Popup Close Button Clicked', Object.assign(Object.assign({}, analyticsData), { incognito: isIncognito }));
170
+ if (typeof analytics !== 'undefined') {
171
+ analytics.track('IDP Selector Popup Close Button Clicked', Object.assign(Object.assign({}, analyticsData), { incognito: isIncognito }));
172
+ }
162
173
  };
163
174
  if (!isRequiredClaimsValid(claims, requiredClaims)) {
164
175
  const errorMessage = `requiredClaims needs to be a subset of claims. claims: ${claims.join(', ')}; requiredClaims: ${requiredClaims === null || requiredClaims === void 0 ? void 0 : requiredClaims.join(', ')}.`;
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useAnalytics } from './analytics';
3
2
  import { getCurrentUrlOrigin } from './navigator';
4
3
  import './CidButtonHowItWorks.css';
5
4
  import { ThemeContext } from './ThemeContext';
6
5
  import { useContext } from 'react';
7
6
  export const CidButtonHowItWorks = () => {
8
- useAnalytics();
9
7
  const theme = useContext(ThemeContext);
10
8
  const handleClick = () => {
11
- if (!analytics)
12
- return;
13
- analytics.track('Link to External Page Clicked', {
14
- source: 'how_does_it_work',
15
- link_url: 'https://connectid.com.au/#use-cases',
16
- rp_sub_brand: getCurrentUrlOrigin(),
17
- });
9
+ if (typeof analytics !== 'undefined') {
10
+ analytics.track('Link to External Page Clicked', {
11
+ source: 'how_does_it_work',
12
+ link_url: 'https://connectid.com.au/#use-cases',
13
+ rp_sub_brand: getCurrentUrlOrigin(),
14
+ });
15
+ }
18
16
  };
19
17
  return (_jsx("a", { href: "https://connectid.com.au/#use-cases", onClick: handleClick, target: "_blank", tabIndex: 0, className: `cid-idp-selector-how-it-works ${theme === 'light' ? 'cid-idp-selector-how-it-works--light' : ''}`, "data-testid": "how-it-works", children: "How does it work?" }));
20
18
  };
package/LearnMore.js CHANGED
@@ -2,19 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from 'react';
3
3
  import './LearnMore.css';
4
4
  import { ThemeContext } from './ThemeContext';
5
- import { useAnalytics } from './analytics';
6
5
  import { getCurrentUrlOrigin } from './navigator';
7
6
  export const LearnMore = () => {
8
- useAnalytics();
9
7
  const theme = useContext(ThemeContext);
10
8
  const handleClick = () => {
11
- if (!analytics)
12
- return;
13
- analytics.track('Link to External Page Clicked', {
14
- source: 'learn_more',
15
- link_url: 'https://www.connectid.com.au',
16
- rp_sub_brand: getCurrentUrlOrigin(),
17
- });
9
+ if (typeof analytics !== 'undefined') {
10
+ analytics.track('Link to External Page Clicked', {
11
+ source: 'learn_more',
12
+ link_url: 'https://www.connectid.com.au',
13
+ rp_sub_brand: getCurrentUrlOrigin(),
14
+ });
15
+ }
18
16
  };
19
17
  return (_jsxs("div", { className: `cid-idp-selector-learn-more ${theme === 'light' ? 'cid-idp-selector-learn-more--light' : ''}`, children: ["Visit", ' ', _jsx("a", { href: "https://www.connectid.com.au", onClick: handleClick, target: "_blank", tabIndex: 0, "data-testid": "learn-more", children: "connectid.com.au" }), ' ', "to learn more."] }));
20
18
  };
package/Popup.js CHANGED
@@ -11,7 +11,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
11
11
  import { useEffect, useRef, useState } from 'react';
12
12
  import ReactDOM from 'react-dom';
13
13
  import { useMediaQuery } from 'react-responsive';
14
- import { useAnalytics } from './analytics';
15
14
  import { filterAuthorisationServers, getManualAuthorisationServer } from './certification';
16
15
  import './global.css';
17
16
  import { InfoBox } from './InfoBox';
@@ -25,7 +24,6 @@ export const Popup = ({ onProceed, onCancel, onError, claims, requiredClaims, sh
25
24
  const [isIncognito, setIsIncognito] = useState();
26
25
  const [showClaims, setShowClaims] = useState(false); // mobile only
27
26
  const popupRef = useRef(null);
28
- useAnalytics();
29
27
  const isMobile = useMediaQuery({ query: '(max-width: 482px)' });
30
28
  const infoboxLinkRef = useRef(null);
31
29
  const closeButtonRef = useRef(null);
@@ -101,12 +99,14 @@ export const Popup = ({ onProceed, onCancel, onError, claims, requiredClaims, sh
101
99
  }
102
100
  };
103
101
  const handleConnectIdLinkClicked = () => __awaiter(void 0, void 0, void 0, function* () {
104
- analytics === null || analytics === void 0 ? void 0 : analytics.track('Link to External Page Clicked', {
105
- source: 'what_is_connectid',
106
- link_url: 'https://www.connectid.com.au',
107
- rp_sub_brand: getCurrentUrlOrigin(),
108
- incognito: isIncognito,
109
- });
102
+ if (typeof analytics !== 'undefined') {
103
+ analytics.track('Link to External Page Clicked', {
104
+ source: 'what_is_connectid',
105
+ link_url: 'https://www.connectid.com.au',
106
+ rp_sub_brand: getCurrentUrlOrigin(),
107
+ incognito: isIncognito,
108
+ });
109
+ }
110
110
  });
111
111
  const renderClaimList = () => {
112
112
  return (_jsx("ul", { id: "cid-idp-selector-popup-claims", className: `cid-idp-selector-popup-claims ${showClaims ? 'cid-idp-selector-popup-claims--visible' : ''}`, "data-testid": "claims", children: sortClaims(claims).map((claim) => (_jsxs("li", { className: "cid-idp-selector-popup-claim", "data-testid": `claim-${claim}`, children: [_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M8 16C12.4183 16 16 12.4183 16 8C16 3.58172 12.4183 0 8 0C3.58172 0 0 3.58172 0 8C0 12.4183 3.58172 16 8 16Z", fill: "#BEEDD2" }), _jsx("path", { d: "M4.81445 8.14121L6.95437 10.2811L11.472 5.76465", stroke: "#262626", strokeWidth: "1.7", strokeLinecap: "round" })] }), claimsDescription[claim]] }, claim))) }));
package/README.md CHANGED
@@ -259,6 +259,12 @@ The SVG image below the ConnectID button has either option dark or light mode. B
259
259
 
260
260
  ## 🚀 Release Notes
261
261
 
262
+ ### 6.10.0-alpha.6 (Jun 26, 2025)
263
+ - Add `disableAnalytics` option.
264
+
265
+ ### 6.10.0-alpha.5 (Jun 25, 2025)
266
+ - Fix analytics double loading.
267
+
262
268
  ### 6.10.0-alpha.4 (Jun 20, 2025)
263
269
  - Add test support for Samsung and Chrome browsers.
264
270
 
package/analytics.d.ts CHANGED
@@ -1 +1,2 @@
1
- export declare const useAnalytics: () => void;
1
+ import { Analytics } from "./types";
2
+ export declare const initialiseAnalytics: (onLoad: (analytics: Analytics) => void) => void;
package/analytics.js CHANGED
@@ -1,8 +1,11 @@
1
1
  const PROD_WRITE_KEY = 'LrD9CEGUEy1O3s73nGbaGcyTqELujozJ';
2
2
  const DEV_WRITE_KEY = 'PWlESErGso9uTimwmGB7SsnxCpKF8pRl';
3
3
  const WRITE_KEY = 'production' === 'production' ? PROD_WRITE_KEY : DEV_WRITE_KEY;
4
- export const useAnalytics = () => {
5
- // copied from https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/
4
+ export const initialiseAnalytics = (onLoad) => {
5
+ // adapted from https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/
6
+ // to handle RSC
7
+ if (typeof window === 'undefined')
8
+ return;
6
9
  // @ts-ignore
7
10
  // Create a queue, but don't obliterate an existing one!
8
11
  var analytics = (window.analytics = window.analytics || []);
@@ -74,6 +77,9 @@ export const useAnalytics = () => {
74
77
  // @ts-ignore
75
78
  first.parentNode.insertBefore(script, first);
76
79
  analytics._loadOptions = options;
80
+ script.onload = function () {
81
+ onLoad(analytics);
82
+ };
77
83
  };
78
84
  analytics._writeKey = WRITE_KEY;
79
85
  // Add a version to keep track of what's in the wild.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectid-tools/idp-selector-react",
3
- "version": "6.10.0-alpha.4",
3
+ "version": "6.10.0-alpha.6",
4
4
  "description": "React component for IDP Selector.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,12 +26,12 @@
26
26
  "homepage": "https://github.com/connectid-tools/idp-selector-react",
27
27
  "devDependencies": {
28
28
  "@babel/preset-typescript": "^7.27.1",
29
- "@types/node": "^22.15.32",
29
+ "@types/node": "^22.15.33",
30
30
  "@types/react": "^18.3.23",
31
31
  "@types/react-dom": "^18.3.7",
32
32
  "cypress": "^14.5.0",
33
33
  "jest-environment-jsdom": "^29.7.0",
34
- "prettier": "^3.5.3",
34
+ "prettier": "^3.6.1",
35
35
  "react": "^18.3.1",
36
36
  "react-dom": "^18.3.1",
37
37
  "replace-in-file": "^8.3.0",