@imtbl/checkout-widgets 2.24.7 → 2.24.9-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/browser/{AddTokensWidget-aAZMavtt.js → AddTokensWidget-CIR8BF_I.js} +24 -297
- package/dist/browser/{BridgeWidget-CWWCr015.js → BridgeWidget-C5Uljhhx.js} +13 -294
- package/dist/browser/{CommerceWidget-B36D9SAt.js → CommerceWidget-CeBBYCbK.js} +17 -47
- package/dist/browser/{FeesBreakdown-WeqZxAT6.js → FeesBreakdown-BU4haotD.js} +1 -1
- package/dist/browser/{OnRampWidget-DpxysET8.js → OnRampWidget-Ccvb3QkT.js} +5 -80
- package/dist/browser/{SaleWidget-CMkn5eAJ.js → SaleWidget-CPARFlzv.js} +61 -219
- package/dist/browser/{SpendingCapHero-BuWrv_Rb.js → SpendingCapHero-B-0YYZho.js} +1 -1
- package/dist/browser/{SwapWidget-CEnCMtGs.js → SwapWidget-ujE6uX-N.js} +12 -206
- package/dist/browser/{TokenImage-EqfdG328.js → TokenImage-BeUf_Ulv.js} +1 -1
- package/dist/browser/{TopUpView-D3BxE8R3.js → TopUpView-GMv3360Q.js} +3 -54
- package/dist/browser/{WalletApproveHero-C_8es7r9.js → WalletApproveHero-BJi7ufqM.js} +4 -12
- package/dist/browser/{WalletWidget-Czye7zS5.js → WalletWidget-BABrqsfd.js} +4 -96
- package/dist/browser/{index-WfurfROg.js → index-CcxHW36j.js} +1275 -9717
- package/dist/browser/{index-CcLq9am4.js → index-Cp1w6map.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{useInterval-CrmneADn.js → useInterval-DbCsm_gG.js} +1 -1
- package/dist/types/components/FormComponents/SelectForm/SelectForm.d.ts +1 -5
- package/dist/types/components/FormComponents/SelectInput/SelectInput.d.ts +1 -5
- package/dist/types/components/Transak/TransakIframe.d.ts +0 -1
- package/dist/types/components/Transak/useTransakEvents.d.ts +0 -4
- package/dist/types/components/WalletDrawer/ConnectWalletDrawer.d.ts +1 -2
- package/dist/types/lib/squid/hooks/useExecute.d.ts +1 -2
- package/dist/types/views/top-up/TopUpView.d.ts +1 -5
- package/dist/types/widgets/add-tokens/hooks/useError.d.ts +1 -1
- package/dist/types/widgets/purchase/components/PurchaseConnectWalletDrawer.d.ts +1 -3
- package/dist/types/widgets/sale/hooks/useSaleEvents.d.ts +5 -31
- package/dist/types/widgets/swap/components/Fees.d.ts +1 -1
- package/package.json +7 -9
- package/src/components/ConnectLoader/ConnectLoader.tsx +0 -16
- package/src/components/FormComponents/SelectForm/SelectForm.tsx +2 -18
- package/src/components/FormComponents/SelectInput/SelectInput.tsx +1 -12
- package/src/components/RouteOptionsDrawer/RouteOptionsDrawer.tsx +2 -26
- package/src/components/Transactions/ChangeWallet.tsx +1 -12
- package/src/components/Transactions/ClaimWithdrawalInProgress.tsx +0 -11
- package/src/components/Transactions/NoTransactions.tsx +0 -10
- package/src/components/Transactions/TransactionItemWithdrawPending.tsx +1 -13
- package/src/components/Transactions/Transactions.tsx +2 -28
- package/src/components/Transak/TransakIframe.tsx +0 -6
- package/src/components/Transak/useTransakEvents.ts +1 -70
- package/src/components/WalletDrawer/ConnectWalletDrawer.tsx +2 -35
- package/src/components/WalletDrawer/PayWithWalletDrawer.tsx +0 -1
- package/src/context/view-context/test-components/ViewContextTestComponent.tsx +14 -15
- package/src/lib/squid/hooks/useExecute.ts +5 -18
- package/src/views/top-up/TopUpView.tsx +5 -56
- package/src/widgets/add-tokens/AddTokensRoot.tsx +28 -29
- package/src/widgets/add-tokens/AddTokensWidget.tsx +2 -17
- package/src/widgets/add-tokens/components/TokenDrawerMenu.tsx +2 -18
- package/src/widgets/add-tokens/hooks/useError.tsx +1 -18
- package/src/widgets/add-tokens/hooks/useErrorHandler.ts +2 -12
- package/src/widgets/add-tokens/views/AddTokens.tsx +8 -154
- package/src/widgets/add-tokens/views/Review.tsx +6 -94
- package/src/widgets/bridge/BridgeWidget.tsx +0 -35
- package/src/widgets/bridge/BridgeWidgetRoot.tsx +17 -18
- package/src/widgets/bridge/components/BridgeForm.tsx +0 -20
- package/src/widgets/bridge/components/BridgeReviewSummary.tsx +1 -49
- package/src/widgets/bridge/components/WalletAndNetworkSelector.tsx +3 -122
- package/src/widgets/bridge/views/ApproveTransaction.tsx +1 -15
- package/src/widgets/bridge/views/Bridge.tsx +1 -16
- package/src/widgets/bridge/views/BridgeReview.tsx +1 -12
- package/src/widgets/bridge/views/ClaimWithdrawal.tsx +0 -11
- package/src/widgets/bridge/views/MoveInProgress.tsx +0 -24
- package/src/widgets/bridge/views/WalletNetworkSelectionView.tsx +1 -12
- package/src/widgets/connect/ConnectWidget.tsx +2 -18
- package/src/widgets/connect/ConnectWidgetRoot.tsx +15 -16
- package/src/widgets/connect/components/WalletList.tsx +6 -55
- package/src/widgets/connect/views/ConnectWallet.tsx +1 -12
- package/src/widgets/connect/views/ReadyToConnect.tsx +2 -29
- package/src/widgets/connect/views/SwitchNetworkEth.tsx +3 -22
- package/src/widgets/connect/views/SwitchNetworkZkEVM.tsx +0 -18
- package/src/widgets/immutable-commerce/CommerceWidgetRoot.tsx +17 -19
- package/src/widgets/on-ramp/OnRampWidget.tsx +0 -2
- package/src/widgets/on-ramp/OnRampWidgetRoot.tsx +23 -24
- package/src/widgets/on-ramp/views/OnRampMain.tsx +1 -91
- package/src/widgets/purchase/PurchaseWidgetRoot.tsx +22 -23
- package/src/widgets/purchase/components/PurchaseConnectWalletDrawer.tsx +2 -34
- package/src/widgets/purchase/components/PurchaseDeliverToWalletDrawer.tsx +0 -1
- package/src/widgets/purchase/components/PurchasePayWithWalletDrawer.tsx +0 -2
- package/src/widgets/purchase/components/PurchaseRouteOptionsDrawer/RouteOptionsDrawer.tsx +1 -30
- package/src/widgets/purchase/components/WithCard.tsx +0 -4
- package/src/widgets/purchase/views/Purchase.tsx +1 -2
- package/src/widgets/sale/SaleWidget.tsx +0 -2
- package/src/widgets/sale/SaleWidgetRoot.tsx +32 -33
- package/src/widgets/sale/components/OrderReview.tsx +2 -29
- package/src/widgets/sale/components/WithCard.tsx +0 -2
- package/src/widgets/sale/hooks/useSaleEvents.ts +3 -185
- package/src/widgets/sale/views/OrderSummary.tsx +2 -15
- package/src/widgets/sale/views/PayWithCard.tsx +4 -46
- package/src/widgets/sale/views/PayWithCoins.tsx +4 -9
- package/src/widgets/sale/views/PaymentMethods.tsx +3 -6
- package/src/widgets/sale/views/SaleErrorView.tsx +1 -1
- package/src/widgets/swap/SwapWidget.tsx +0 -24
- package/src/widgets/swap/SwapWidgetRoot.tsx +29 -30
- package/src/widgets/swap/components/Fees.tsx +1 -1
- package/src/widgets/swap/components/SwapForm.tsx +2 -140
- package/src/widgets/swap/views/ApproveERC20Onboarding.tsx +1 -36
- package/src/widgets/swap/views/SwapCoins.tsx +0 -17
- package/src/widgets/swap/views/SwapInProgress.tsx +0 -14
- package/src/widgets/transfer/TransferForm.tsx +3 -25
- package/src/widgets/transfer/TransferWidget.tsx +1 -23
- package/src/widgets/wallet/WalletWidgetRoot.tsx +24 -25
- package/src/widgets/wallet/components/BalanceItem/BalanceItem.tsx +1 -50
- package/src/widgets/wallet/components/NetworkMenu/NetworkMenu.tsx +0 -13
- package/src/widgets/wallet/components/WalletAddress/WalletAddress.tsx +0 -13
- package/src/widgets/wallet/views/CoinInfo.tsx +1 -12
- package/src/widgets/wallet/views/Settings.tsx +1 -15
- package/src/widgets/wallet/views/WalletBalances.tsx +0 -24
- package/tsconfig.json +0 -1
- package/dist/browser/auto-track-BcwQjFJ1.js +0 -105
- package/dist/browser/index-BSnE_6oQ.js +0 -27
- package/dist/browser/index-CKGatDzP.js +0 -60
- package/dist/browser/index-Cnt0i-EY.js +0 -65
- package/dist/browser/index-DLXeqRzN.js +0 -65
- package/dist/browser/index-MANbU_qG.js +0 -5634
- package/dist/browser/index-lHICKwNF.js +0 -446
- package/dist/browser/index.umd-Cn1Q502t.js +0 -32
- package/dist/browser/is-plan-event-enabled-mXX0dwl-.js +0 -17
- package/dist/types/context/analytics-provider/CustomAnalyticsProvider.d.ts +0 -7
- package/dist/types/context/analytics-provider/SegmentAnalyticsProvider.d.ts +0 -42
- package/dist/types/context/analytics-provider/SetupAnalytics.d.ts +0 -7
- package/dist/types/lib/analytics/identifyUser.d.ts +0 -8
- package/dist/types/lib/analytics/identifyUser.test.d.ts +0 -1
- package/src/context/analytics-provider/CustomAnalyticsProvider.tsx +0 -22
- package/src/context/analytics-provider/SegmentAnalyticsProvider.ts +0 -41
- package/src/context/analytics-provider/SetupAnalytics.tsx +0 -35
- package/src/lib/analytics/identifyUser.test.ts +0 -44
- package/src/lib/analytics/identifyUser.ts +0 -26
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import { e6 as __awaiter, e7 as __generator, e8 as loadScript, e9 as getNextIntegrationsURL, ea as unloadScript, eb as __spreadArray, ec as isOffline, ed as __assign, ee as ContextCancelation, ef as applyDestinationMiddleware, eg as dist, eh as isServer, ei as mergedOptions, ej as isPlainObject, ek as pWhile, el as PriorityQueue, em as PersistedPriorityQueue, en as attempt, eo as isOnline, ep as Context } from './index-WfurfROg.js';
|
|
2
|
-
import { i as isPlanEventEnabled } from './is-plan-event-enabled-mXX0dwl-.js';
|
|
3
|
-
|
|
4
|
-
function normalizeName(name) {
|
|
5
|
-
return name.toLowerCase().replace('.', '').replace(/\s+/g, '-');
|
|
6
|
-
}
|
|
7
|
-
function obfuscatePathName(pathName, obfuscate) {
|
|
8
|
-
if (obfuscate === void 0) { obfuscate = false; }
|
|
9
|
-
return obfuscate ? btoa(pathName).replace(/=/g, '') : undefined;
|
|
10
|
-
}
|
|
11
|
-
function resolveIntegrationNameFromSource(integrationSource) {
|
|
12
|
-
return ('Integration' in integrationSource
|
|
13
|
-
? integrationSource.Integration
|
|
14
|
-
: integrationSource).prototype.name;
|
|
15
|
-
}
|
|
16
|
-
function recordLoadMetrics(fullPath, ctx, name) {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
try {
|
|
19
|
-
var metric = ((_b = (_a = window === null || window === void 0 ? void 0 : window.performance) === null || _a === void 0 ? void 0 : _a.getEntriesByName(fullPath, 'resource')) !== null && _b !== void 0 ? _b : [])[0];
|
|
20
|
-
// we assume everything that took under 100ms is cached
|
|
21
|
-
metric &&
|
|
22
|
-
ctx.stats.gauge('legacy_destination_time', Math.round(metric.duration), __spreadArray([
|
|
23
|
-
name
|
|
24
|
-
], (metric.duration < 100 ? ['cached'] : []), true));
|
|
25
|
-
}
|
|
26
|
-
catch (_) {
|
|
27
|
-
// not available
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function buildIntegration(integrationSource, integrationSettings, analyticsInstance) {
|
|
31
|
-
var integrationCtr;
|
|
32
|
-
// GA and Appcues use a different interface to instantiating integrations
|
|
33
|
-
if ('Integration' in integrationSource) {
|
|
34
|
-
var analyticsStub = {
|
|
35
|
-
user: function () { return analyticsInstance.user(); },
|
|
36
|
-
addIntegration: function () { },
|
|
37
|
-
};
|
|
38
|
-
integrationSource(analyticsStub);
|
|
39
|
-
integrationCtr = integrationSource.Integration;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
integrationCtr = integrationSource;
|
|
43
|
-
}
|
|
44
|
-
var integration = new integrationCtr(integrationSettings);
|
|
45
|
-
integration.analytics = analyticsInstance;
|
|
46
|
-
return integration;
|
|
47
|
-
}
|
|
48
|
-
function loadIntegration(ctx, name, version, obfuscate) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var pathName, obfuscatedPathName, path, fullPath, err_1, deps;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
pathName = normalizeName(name);
|
|
55
|
-
obfuscatedPathName = obfuscatePathName(pathName, obfuscate);
|
|
56
|
-
path = getNextIntegrationsURL();
|
|
57
|
-
fullPath = "".concat(path, "/integrations/").concat(obfuscatedPathName !== null && obfuscatedPathName !== void 0 ? obfuscatedPathName : pathName, "/").concat(version, "/").concat(obfuscatedPathName !== null && obfuscatedPathName !== void 0 ? obfuscatedPathName : pathName, ".dynamic.js.gz");
|
|
58
|
-
_a.label = 1;
|
|
59
|
-
case 1:
|
|
60
|
-
_a.trys.push([1, 3, , 4]);
|
|
61
|
-
return [4 /*yield*/, loadScript(fullPath)];
|
|
62
|
-
case 2:
|
|
63
|
-
_a.sent();
|
|
64
|
-
recordLoadMetrics(fullPath, ctx, name);
|
|
65
|
-
return [3 /*break*/, 4];
|
|
66
|
-
case 3:
|
|
67
|
-
err_1 = _a.sent();
|
|
68
|
-
ctx.stats.gauge('legacy_destination_time', -1, ["plugin:".concat(name), "failed"]);
|
|
69
|
-
throw err_1;
|
|
70
|
-
case 4:
|
|
71
|
-
deps = window["".concat(pathName, "Deps")];
|
|
72
|
-
return [4 /*yield*/, Promise.all(deps.map(function (dep) { return loadScript(path + dep + '.gz'); }))
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
];
|
|
75
|
-
case 5:
|
|
76
|
-
_a.sent();
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
window["".concat(pathName, "Loader")]();
|
|
79
|
-
return [2 /*return*/, window[
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
"".concat(pathName, "Integration")]];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function unloadIntegration(name, version, obfuscate) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
var path, pathName, obfuscatedPathName, fullPath;
|
|
89
|
-
return __generator(this, function (_a) {
|
|
90
|
-
path = getNextIntegrationsURL();
|
|
91
|
-
pathName = normalizeName(name);
|
|
92
|
-
obfuscatedPathName = obfuscatePathName(name, obfuscate);
|
|
93
|
-
fullPath = "".concat(path, "/integrations/").concat(obfuscatedPathName !== null && obfuscatedPathName !== void 0 ? obfuscatedPathName : pathName, "/").concat(version, "/").concat(obfuscatedPathName !== null && obfuscatedPathName !== void 0 ? obfuscatedPathName : pathName, ".dynamic.js.gz");
|
|
94
|
-
return [2 /*return*/, unloadScript(fullPath)];
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
function resolveVersion(settings) {
|
|
99
|
-
var _a, _b, _c, _d;
|
|
100
|
-
return ((_d = (_b = (_a = settings === null || settings === void 0 ? void 0 : settings.versionSettings) === null || _a === void 0 ? void 0 : _a.override) !== null && _b !== void 0 ? _b : (_c = settings === null || settings === void 0 ? void 0 : settings.versionSettings) === null || _c === void 0 ? void 0 : _c.version) !== null && _d !== void 0 ? _d : 'latest');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
var isInstallableIntegration = function (name, integrationSettings) {
|
|
104
|
-
var _a;
|
|
105
|
-
var type = integrationSettings.type, bundlingStatus = integrationSettings.bundlingStatus, versionSettings = integrationSettings.versionSettings;
|
|
106
|
-
// We use `!== 'unbundled'` (versus `=== 'bundled'`) to be inclusive of
|
|
107
|
-
// destinations without a defined value for `bundlingStatus`
|
|
108
|
-
var deviceMode = bundlingStatus !== 'unbundled' &&
|
|
109
|
-
(type === 'browser' || ((_a = versionSettings === null || versionSettings === void 0 ? void 0 : versionSettings.componentTypes) === null || _a === void 0 ? void 0 : _a.includes('browser')));
|
|
110
|
-
// checking for iterable is a quick fix we need in place to prevent
|
|
111
|
-
// errors showing Iterable as a failed destiantion. Ideally, we should
|
|
112
|
-
// fix the Iterable metadata instead, but that's a longer process.
|
|
113
|
-
return !name.startsWith('Segment') && name !== 'Iterable' && deviceMode;
|
|
114
|
-
};
|
|
115
|
-
var isDisabledIntegration = function (integrationName, globalIntegrations) {
|
|
116
|
-
var allDisableAndNotDefined = globalIntegrations.All === false &&
|
|
117
|
-
globalIntegrations[integrationName] === undefined;
|
|
118
|
-
return (globalIntegrations[integrationName] === false || allDisableAndNotDefined);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
function flushQueue(xt, queue) {
|
|
122
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
-
var failedQueue;
|
|
124
|
-
var _this = this;
|
|
125
|
-
return __generator(this, function (_a) {
|
|
126
|
-
switch (_a.label) {
|
|
127
|
-
case 0:
|
|
128
|
-
failedQueue = [];
|
|
129
|
-
if (isOffline()) {
|
|
130
|
-
return [2 /*return*/, queue];
|
|
131
|
-
}
|
|
132
|
-
return [4 /*yield*/, pWhile(function () { return queue.length > 0 && isOnline(); }, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
133
|
-
var ctx, result, success;
|
|
134
|
-
return __generator(this, function (_a) {
|
|
135
|
-
switch (_a.label) {
|
|
136
|
-
case 0:
|
|
137
|
-
ctx = queue.pop();
|
|
138
|
-
if (!ctx) {
|
|
139
|
-
return [2 /*return*/];
|
|
140
|
-
}
|
|
141
|
-
return [4 /*yield*/, attempt(ctx, xt)];
|
|
142
|
-
case 1:
|
|
143
|
-
result = _a.sent();
|
|
144
|
-
success = result instanceof Context;
|
|
145
|
-
if (!success) {
|
|
146
|
-
failedQueue.push(ctx);
|
|
147
|
-
}
|
|
148
|
-
return [2 /*return*/];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}); })
|
|
152
|
-
// re-add failed tasks
|
|
153
|
-
];
|
|
154
|
-
case 1:
|
|
155
|
-
_a.sent();
|
|
156
|
-
// re-add failed tasks
|
|
157
|
-
failedQueue.map(function (failed) { return queue.pushWithBackoff(failed); });
|
|
158
|
-
return [2 /*return*/, queue];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
var LegacyDestination = /** @class */ (function () {
|
|
164
|
-
function LegacyDestination(name, version, writeKey, settings, options, integrationSource) {
|
|
165
|
-
if (settings === void 0) { settings = {}; }
|
|
166
|
-
this.options = {};
|
|
167
|
-
this.type = 'destination';
|
|
168
|
-
this.middleware = [];
|
|
169
|
-
this._ready = false;
|
|
170
|
-
this._initialized = false;
|
|
171
|
-
this.flushing = false;
|
|
172
|
-
this.name = name;
|
|
173
|
-
this.version = version;
|
|
174
|
-
this.settings = __assign({}, settings);
|
|
175
|
-
this.disableAutoISOConversion = options.disableAutoISOConversion || false;
|
|
176
|
-
this.integrationSource = integrationSource;
|
|
177
|
-
// AJS-Renderer sets an extraneous `type` setting that clobbers
|
|
178
|
-
// existing type defaults. We need to remove it if it's present
|
|
179
|
-
if (this.settings['type'] && this.settings['type'] === 'browser') {
|
|
180
|
-
delete this.settings['type'];
|
|
181
|
-
}
|
|
182
|
-
this.options = options;
|
|
183
|
-
this.buffer = options.disableClientPersistence
|
|
184
|
-
? new PriorityQueue(4, [])
|
|
185
|
-
: new PersistedPriorityQueue(4, "".concat(writeKey, ":dest-").concat(name));
|
|
186
|
-
this.scheduleFlush();
|
|
187
|
-
}
|
|
188
|
-
LegacyDestination.prototype.isLoaded = function () {
|
|
189
|
-
return this._ready;
|
|
190
|
-
};
|
|
191
|
-
LegacyDestination.prototype.ready = function () {
|
|
192
|
-
var _a;
|
|
193
|
-
return (_a = this.onReady) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
194
|
-
};
|
|
195
|
-
LegacyDestination.prototype.load = function (ctx, analyticsInstance) {
|
|
196
|
-
var _a;
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
var integrationSource, _b;
|
|
199
|
-
var _this = this;
|
|
200
|
-
return __generator(this, function (_c) {
|
|
201
|
-
switch (_c.label) {
|
|
202
|
-
case 0:
|
|
203
|
-
if (this._ready || this.onReady !== undefined) {
|
|
204
|
-
return [2 /*return*/];
|
|
205
|
-
}
|
|
206
|
-
if (!((_a = this.integrationSource) !== null && _a !== void 0)) return [3 /*break*/, 1];
|
|
207
|
-
_b = _a;
|
|
208
|
-
return [3 /*break*/, 3];
|
|
209
|
-
case 1: return [4 /*yield*/, loadIntegration(ctx, this.name, this.version, this.options.obfuscate)];
|
|
210
|
-
case 2:
|
|
211
|
-
_b = (_c.sent());
|
|
212
|
-
_c.label = 3;
|
|
213
|
-
case 3:
|
|
214
|
-
integrationSource = _b;
|
|
215
|
-
this.integration = buildIntegration(integrationSource, this.settings, analyticsInstance);
|
|
216
|
-
this.onReady = new Promise(function (resolve) {
|
|
217
|
-
var onReadyFn = function () {
|
|
218
|
-
_this._ready = true;
|
|
219
|
-
resolve(true);
|
|
220
|
-
};
|
|
221
|
-
_this.integration.once('ready', onReadyFn);
|
|
222
|
-
});
|
|
223
|
-
this.onInitialize = new Promise(function (resolve) {
|
|
224
|
-
var onInit = function () {
|
|
225
|
-
_this._initialized = true;
|
|
226
|
-
resolve(true);
|
|
227
|
-
};
|
|
228
|
-
_this.integration.on('initialize', onInit);
|
|
229
|
-
});
|
|
230
|
-
try {
|
|
231
|
-
ctx.stats.increment('analytics_js.integration.invoke', 1, [
|
|
232
|
-
"method:initialize",
|
|
233
|
-
"integration_name:".concat(this.name),
|
|
234
|
-
]);
|
|
235
|
-
this.integration.initialize();
|
|
236
|
-
}
|
|
237
|
-
catch (error) {
|
|
238
|
-
ctx.stats.increment('analytics_js.integration.invoke.error', 1, [
|
|
239
|
-
"method:initialize",
|
|
240
|
-
"integration_name:".concat(this.name),
|
|
241
|
-
]);
|
|
242
|
-
throw error;
|
|
243
|
-
}
|
|
244
|
-
return [2 /*return*/];
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
LegacyDestination.prototype.unload = function (_ctx, _analyticsInstance) {
|
|
250
|
-
return unloadIntegration(this.name, this.version, this.options.obfuscate);
|
|
251
|
-
};
|
|
252
|
-
LegacyDestination.prototype.addMiddleware = function () {
|
|
253
|
-
var _a;
|
|
254
|
-
var fn = [];
|
|
255
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
256
|
-
fn[_i] = arguments[_i];
|
|
257
|
-
}
|
|
258
|
-
this.middleware = (_a = this.middleware).concat.apply(_a, fn);
|
|
259
|
-
};
|
|
260
|
-
LegacyDestination.prototype.shouldBuffer = function (ctx) {
|
|
261
|
-
return (
|
|
262
|
-
// page events can't be buffered because of destinations that automatically add page views
|
|
263
|
-
ctx.event.type !== 'page' &&
|
|
264
|
-
(isOffline() || this._ready === false || this._initialized === false));
|
|
265
|
-
};
|
|
266
|
-
LegacyDestination.prototype.send = function (ctx, clz, eventType) {
|
|
267
|
-
var _a, _b;
|
|
268
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
269
|
-
var plan, ev, planEvent, afterMiddleware, event, err_1;
|
|
270
|
-
return __generator(this, function (_c) {
|
|
271
|
-
switch (_c.label) {
|
|
272
|
-
case 0:
|
|
273
|
-
if (this.shouldBuffer(ctx)) {
|
|
274
|
-
this.buffer.push(ctx);
|
|
275
|
-
this.scheduleFlush();
|
|
276
|
-
return [2 /*return*/, ctx];
|
|
277
|
-
}
|
|
278
|
-
plan = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.plan) === null || _b === void 0 ? void 0 : _b.track;
|
|
279
|
-
ev = ctx.event.event;
|
|
280
|
-
if (plan && ev && this.name !== 'Segment.io') {
|
|
281
|
-
planEvent = plan[ev];
|
|
282
|
-
if (!isPlanEventEnabled(plan, planEvent)) {
|
|
283
|
-
ctx.updateEvent('integrations', __assign(__assign({}, ctx.event.integrations), { All: false, 'Segment.io': true }));
|
|
284
|
-
ctx.cancel(new ContextCancelation({
|
|
285
|
-
retry: false,
|
|
286
|
-
reason: "Event ".concat(ev, " disabled for integration ").concat(this.name, " in tracking plan"),
|
|
287
|
-
type: 'Dropped by plan',
|
|
288
|
-
}));
|
|
289
|
-
return [2 /*return*/, ctx];
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
ctx.updateEvent('integrations', __assign(__assign({}, ctx.event.integrations), planEvent === null || planEvent === void 0 ? void 0 : planEvent.integrations));
|
|
293
|
-
}
|
|
294
|
-
if ((planEvent === null || planEvent === void 0 ? void 0 : planEvent.enabled) && (planEvent === null || planEvent === void 0 ? void 0 : planEvent.integrations[this.name]) === false) {
|
|
295
|
-
ctx.cancel(new ContextCancelation({
|
|
296
|
-
retry: false,
|
|
297
|
-
reason: "Event ".concat(ev, " disabled for integration ").concat(this.name, " in tracking plan"),
|
|
298
|
-
type: 'Dropped by plan',
|
|
299
|
-
}));
|
|
300
|
-
return [2 /*return*/, ctx];
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return [4 /*yield*/, applyDestinationMiddleware(this.name, ctx.event, this.middleware)];
|
|
304
|
-
case 1:
|
|
305
|
-
afterMiddleware = _c.sent();
|
|
306
|
-
if (afterMiddleware === null) {
|
|
307
|
-
return [2 /*return*/, ctx];
|
|
308
|
-
}
|
|
309
|
-
event = new clz(afterMiddleware, {
|
|
310
|
-
traverse: !this.disableAutoISOConversion,
|
|
311
|
-
});
|
|
312
|
-
ctx.stats.increment('analytics_js.integration.invoke', 1, [
|
|
313
|
-
"method:".concat(eventType),
|
|
314
|
-
"integration_name:".concat(this.name),
|
|
315
|
-
]);
|
|
316
|
-
_c.label = 2;
|
|
317
|
-
case 2:
|
|
318
|
-
_c.trys.push([2, 5, , 6]);
|
|
319
|
-
if (!this.integration) return [3 /*break*/, 4];
|
|
320
|
-
return [4 /*yield*/, this.integration.invoke.call(this.integration, eventType, event)];
|
|
321
|
-
case 3:
|
|
322
|
-
_c.sent();
|
|
323
|
-
_c.label = 4;
|
|
324
|
-
case 4: return [3 /*break*/, 6];
|
|
325
|
-
case 5:
|
|
326
|
-
err_1 = _c.sent();
|
|
327
|
-
ctx.stats.increment('analytics_js.integration.invoke.error', 1, [
|
|
328
|
-
"method:".concat(eventType),
|
|
329
|
-
"integration_name:".concat(this.name),
|
|
330
|
-
]);
|
|
331
|
-
throw err_1;
|
|
332
|
-
case 6: return [2 /*return*/, ctx];
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
LegacyDestination.prototype.track = function (ctx) {
|
|
338
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
339
|
-
return __generator(this, function (_a) {
|
|
340
|
-
return [2 /*return*/, this.send(ctx, dist.Track, 'track')];
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
LegacyDestination.prototype.page = function (ctx) {
|
|
345
|
-
var _a;
|
|
346
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
347
|
-
var _this = this;
|
|
348
|
-
return __generator(this, function (_b) {
|
|
349
|
-
if (((_a = this.integration) === null || _a === void 0 ? void 0 : _a._assumesPageview) && !this._initialized) {
|
|
350
|
-
this.integration.initialize();
|
|
351
|
-
}
|
|
352
|
-
return [2 /*return*/, this.onInitialize.then(function () {
|
|
353
|
-
return _this.send(ctx, dist.Page, 'page');
|
|
354
|
-
})];
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
};
|
|
358
|
-
LegacyDestination.prototype.identify = function (ctx) {
|
|
359
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
360
|
-
return __generator(this, function (_a) {
|
|
361
|
-
return [2 /*return*/, this.send(ctx, dist.Identify, 'identify')];
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
};
|
|
365
|
-
LegacyDestination.prototype.alias = function (ctx) {
|
|
366
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
367
|
-
return __generator(this, function (_a) {
|
|
368
|
-
return [2 /*return*/, this.send(ctx, dist.Alias, 'alias')];
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
LegacyDestination.prototype.group = function (ctx) {
|
|
373
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
374
|
-
return __generator(this, function (_a) {
|
|
375
|
-
return [2 /*return*/, this.send(ctx, dist.Group, 'group')];
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
};
|
|
379
|
-
LegacyDestination.prototype.scheduleFlush = function () {
|
|
380
|
-
var _this = this;
|
|
381
|
-
if (this.flushing) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
385
|
-
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
386
|
-
var _a;
|
|
387
|
-
return __generator(this, function (_b) {
|
|
388
|
-
switch (_b.label) {
|
|
389
|
-
case 0:
|
|
390
|
-
this.flushing = true;
|
|
391
|
-
_a = this;
|
|
392
|
-
return [4 /*yield*/, flushQueue(this, this.buffer)];
|
|
393
|
-
case 1:
|
|
394
|
-
_a.buffer = _b.sent();
|
|
395
|
-
this.flushing = false;
|
|
396
|
-
if (this.buffer.todo > 0) {
|
|
397
|
-
this.scheduleFlush();
|
|
398
|
-
}
|
|
399
|
-
return [2 /*return*/];
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}); }, Math.random() * 5000);
|
|
403
|
-
};
|
|
404
|
-
return LegacyDestination;
|
|
405
|
-
}());
|
|
406
|
-
function ajsDestinations(writeKey, settings, globalIntegrations, options, routingMiddleware, legacyIntegrationSources) {
|
|
407
|
-
var _a, _b;
|
|
408
|
-
if (globalIntegrations === void 0) { globalIntegrations = {}; }
|
|
409
|
-
if (options === void 0) { options = {}; }
|
|
410
|
-
if (isServer()) {
|
|
411
|
-
return [];
|
|
412
|
-
}
|
|
413
|
-
if (settings.plan) {
|
|
414
|
-
options = options !== null && options !== void 0 ? options : {};
|
|
415
|
-
options.plan = settings.plan;
|
|
416
|
-
}
|
|
417
|
-
var routingRules = (_b = (_a = settings.middlewareSettings) === null || _a === void 0 ? void 0 : _a.routingRules) !== null && _b !== void 0 ? _b : [];
|
|
418
|
-
var remoteIntegrationsConfig = settings.integrations;
|
|
419
|
-
var localIntegrationsConfig = options.integrations;
|
|
420
|
-
// merged remote CDN settings with user provided options
|
|
421
|
-
var integrationOptions = mergedOptions(settings, options !== null && options !== void 0 ? options : {});
|
|
422
|
-
var adhocIntegrationSources = legacyIntegrationSources === null || legacyIntegrationSources === void 0 ? void 0 : legacyIntegrationSources.reduce(function (acc, integrationSource) {
|
|
423
|
-
var _a;
|
|
424
|
-
return (__assign(__assign({}, acc), (_a = {}, _a[resolveIntegrationNameFromSource(integrationSource)] = integrationSource, _a)));
|
|
425
|
-
}, {});
|
|
426
|
-
var installableIntegrations = new Set(__spreadArray(__spreadArray([], Object.keys(remoteIntegrationsConfig).filter(function (name) {
|
|
427
|
-
return isInstallableIntegration(name, remoteIntegrationsConfig[name]);
|
|
428
|
-
}), true), Object.keys(adhocIntegrationSources || {}).filter(function (name) {
|
|
429
|
-
return isPlainObject(remoteIntegrationsConfig[name]) ||
|
|
430
|
-
isPlainObject(localIntegrationsConfig === null || localIntegrationsConfig === void 0 ? void 0 : localIntegrationsConfig[name]);
|
|
431
|
-
}), true));
|
|
432
|
-
return Array.from(installableIntegrations)
|
|
433
|
-
.filter(function (name) { return !isDisabledIntegration(name, globalIntegrations); })
|
|
434
|
-
.map(function (name) {
|
|
435
|
-
var integrationSettings = remoteIntegrationsConfig[name];
|
|
436
|
-
var version = resolveVersion(integrationSettings);
|
|
437
|
-
var destination = new LegacyDestination(name, version, writeKey, integrationOptions[name], options, adhocIntegrationSources === null || adhocIntegrationSources === void 0 ? void 0 : adhocIntegrationSources[name]);
|
|
438
|
-
var routing = routingRules.filter(function (rule) { return rule.destinationName === name; });
|
|
439
|
-
if (routing.length > 0 && routingMiddleware) {
|
|
440
|
-
destination.addMiddleware(routingMiddleware);
|
|
441
|
-
}
|
|
442
|
-
return destination;
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
export { LegacyDestination, ajsDestinations };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ay as getDefaultExportFromCjs } from './index-WfurfROg.js';
|
|
2
|
-
|
|
3
|
-
function _mergeNamespaces(n, m) {
|
|
4
|
-
m.forEach(function (e) {
|
|
5
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
6
|
-
if (k !== 'default' && !(k in n)) {
|
|
7
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
8
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () { return e[k]; }
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
return Object.freeze(n);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var index_umd$2 = {exports: {}};
|
|
19
|
-
|
|
20
|
-
(function (module, exports) {
|
|
21
|
-
!function(e,t){module.exports=t();}(window,(function(){return function(e){var t={};function a(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,a),i.l=!0,i.exports}return a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n});},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)a.d(n,i,function(t){return e[t]}.bind(null,i));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=2)}([function(e,t,a){a.r(t);var n="function"==typeof fetch?fetch.bind():function(e,t){return t=t||{},new Promise((function(a,n){var i=new XMLHttpRequest;for(var r in i.open(t.method||"get",e,!0),t.headers)i.setRequestHeader(r,t.headers[r]);function o(){var e,t=[],a=[],n={};return i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(i,r,o){t.push(r=r.toLowerCase()),a.push([r,o]),e=n[r],n[r]=e?e+","+o:o;})),{ok:2==(i.status/100|0),status:i.status,statusText:i.statusText,url:i.responseURL,clone:o,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},headers:{keys:function(){return t},entries:function(){return a},get:function(e){return n[e.toLowerCase()]},has:function(e){return e.toLowerCase()in n}}}}i.withCredentials="include"==t.credentials,i.onload=function(){a(o());},i.onerror=n,i.send(t.body);}))};t.default=n;},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}();var i=function(){function e(t,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.pluginName=t;}return n(e,[{key:"track",value:function(e,t){window.analytics.track(e,t,{integration:{name:this.pluginName}});}}]),e}();t.default=i;},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0}),t.YouTubeAnalytics=t.VimeoAnalytics=void 0;var n=r(a(3)),i=r(a(4));function r(e){return e&&e.__esModule?e:{default:e}}t.VimeoAnalytics=n.default,t.YouTubeAnalytics=i.default;},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}(),i=r(a(0));function r(e){return e&&e.__esModule?e:{default:e}}var o=function(e){function t(e,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return !t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"VimeoAnalytics"));return n.authToken=a,n.player=e,n.metadata={content:{},playback:{videoPlayer:"Vimeo"}},n.mostRecentHeartbeat=0,n.isPaused=!1,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t);}(t,e),n(t,[{key:"initialize",value:function(){var e=this,t={loaded:this.retrieveMetadata,play:this.trackPlay,pause:this.trackPause,ended:this.trackEnded,timeupdate:this.trackHeartbeat};for(var a in t)this.registerHandler(a,t[a]);this.player.getVideoId().then((function(t){e.retrieveMetadata({id:t});})).catch(console.error);}},{key:"registerHandler",value:function(e,t){var a=this;this.player.on(e,(function(e){a.updateMetadata(e),t.call(a,e);}));}},{key:"trackPlay",value:function(){this.isPaused?(this.track("Video Playback Resumed",this.metadata.playback),this.isPaused=!1):(this.track("Video Playback Started",this.metadata.playback),this.track("Video Content Started",this.metadata.content));}},{key:"trackEnded",value:function(){this.track("Video Playback Completed",this.metadata.playback),this.track("Video Content Completed",this.metadata.content);}},{key:"trackHeartbeat",value:function(){var e=this.mostRecentHeartbeat,t=this.metadata.playback.position;t!==e&&t-e>=10&&(this.track("Video Content Playing",this.metadata.content),this.mostRecentHeartbeat=Math.floor(t));}},{key:"trackPause",value:function(){this.isPaused=!0,this.track("Video Playback Paused",this.metadata.playback);}},{key:"retrieveMetadata",value:function(e){var t=this;return new Promise((function(a,n){var r=e.id;(0, i.default)("https://api.vimeo.com/videos/"+r,{headers:{Authorization:"Bearer "+t.authToken}}).then((function(e){return e.ok?e.json():n(e)})).then((function(e){t.metadata.content.title=e.name,t.metadata.content.description=e.description,t.metadata.content.publisher=e.user.name,t.metadata.playback.position=0,t.metadata.playback.totalLength=e.duration;})).catch((function(e){return console.error("Request to Vimeo API Failed with: ",e),n(e)}));}))}},{key:"updateMetadata",value:function(e){var t=this;return new Promise((function(a,n){t.player.getVolume().then((function(n){n&&(t.metadata.playback.sound=100*n),t.metadata.playback.position=e.seconds,a();})).catch(n);}))}}]),t}(r(a(1)).default);t.default=o;},function(e,t,a){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}(),i=o(a(0)),r=o(a(1));function o(e){return e&&e.__esModule?e:{default:e}}var s=function(e){function t(e,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return !t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"YoutubeAnalytics"));return n.player=e,n.apiKey=a,n.playerLoaded=!1,n.playbackStarted=!1,n.contentStarted=!1,n.isPaused=!1,n.isBuffering=!1,n.isSeeking=!1,n.lastRecordedTime={timeReported:Date.now(),timeElapsed:0},n.metadata=[{playback:{video_player:"youtube"},content:{}}],n.playlistIndex=0,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t);}(t,e),n(t,[{key:"initialize",value:function(){window.segmentYoutubeOnStateChange=this.onPlayerStateChange.bind(this),window.segmentYoutubeOnReady=this.onPlayerReady.bind(this),this.player.addEventListener("onReady","segmentYoutubeOnReady"),this.player.addEventListener("onStateChange","segmentYoutubeOnStateChange");}},{key:"onPlayerReady",value:function(e){this.retrieveMetadata();}},{key:"onPlayerStateChange",value:function(e){var t=this.player.getCurrentTime();switch(this.metadata[this.playlistIndex]&&(this.metadata[this.playlistIndex].playback.position=this.metadata[this.playlistIndex].content.position=t,this.metadata[this.playlistIndex].playback.quality=this.player.getPlaybackQuality(),this.metadata[this.playlistIndex].playback.sound=this.player.isMuted()?0:this.player.getVolume()),e.data){case-1:if(this.playerLoaded)break;this.retrieveMetadata(),this.playerLoaded=!0;break;case YT.PlayerState.BUFFERING:this.handleBuffer();break;case YT.PlayerState.PLAYING:this.handlePlay();break;case YT.PlayerState.PAUSED:this.handlePause();break;case YT.PlayerState.ENDED:this.handleEnd();}this.lastRecordedTime={timeReported:Date.now(),timeElapsed:1e3*this.player.getCurrentTime()};}},{key:"retrieveMetadata",value:function(){var e=this;return new Promise((function(t,a){var n=e.player.getVideoData(),r=e.player.getPlaylist()||[n.video_id],o=r.join();(0, i.default)("https://www.googleapis.com/youtube/v3/videos?id="+o+"&part=snippet,contentDetails&key="+e.apiKey).then((function(e){if(!e.ok){var t=new Error("Segment request to Youtube API failed (likely due to a bad API Key. Events will still be sent but will not contain video metadata)");throw t.response=e,t}return e.json()})).then((function(a){e.metadata=[];for(var n=0,i=0;i<r.length;i++){var o=a.items[i];e.metadata.push({content:{title:o.snippet.title,description:o.snippet.description,keywords:o.snippet.tags,channel:o.snippet.channelTitle,airdate:o.snippet.publishedAt}}),n+=l(o.contentDetails.duration);}for(i=0;i<r.length;i++)e.metadata[i].playback={total_length:n,video_player:"youtube"};t();})).catch((function(t){e.metadata=r.map((function(e){return {playback:{video_player:"youtube"},content:{}}})),a(t);}));}))}},{key:"handleBuffer",value:function(){var e=this.determineSeek();this.playbackStarted||(this.playbackStarted=!0,this.track("Video Playback Started",this.metadata[this.playlistIndex].playback)),e&&!this.isSeeking&&(this.isSeeking=!0,this.track("Video Playback Seek Started",this.metadata[this.playlistIndex].playback)),this.isSeeking&&(this.track("Video Playback Seek Completed",this.metadata[this.playlistIndex].playback),this.isSeeking=!1);var t=this.player.getPlaylist();t&&0===this.player.getCurrentTime()&&this.player.getPlaylistIndex()!==this.playlistIndex&&(this.contentStarted=!1,this.playlistIndex===t.length-1&&0===this.player.getPlaylistIndex()&&(this.track("Video Playback Completed",this.metadata[this.player.getPlaylistIndex()].playback),this.track("Video Playback Started",this.metadata[this.player.getPlaylistIndex()].playback))),this.track("Video Playback Buffer Started",this.metadata[this.playlistIndex].playback),this.isBuffering=!0;}},{key:"handlePlay",value:function(){this.contentStarted||(this.playlistIndex=this.player.getPlaylistIndex(),-1===this.playlistIndex&&(this.playlistIndex=0),this.track("Video Content Started",this.metadata[this.playlistIndex].content),this.contentStarted=!0),this.isBuffering&&(this.track("Video Playback Buffer Completed",this.metadata[this.playlistIndex].playback),this.isBuffering=!1),this.isPaused&&(this.track("Video Playback Resumed",this.metadata[this.playlistIndex].playback),this.isPaused=!1);}},{key:"handlePause",value:function(){var e=this.determineSeek();this.isBuffering&&(this.track("Video Playback Buffer Completed",this.metadata[this.playlistIndex].playback),this.isBuffering=!1),this.isPaused||(e?(this.track("Video Playback Seek Started",this.metadata[this.playlistIndex].playback),this.isSeeking=!0):(this.track("Video Playback Paused",this.metadata[this.playlistIndex].playback),this.isPaused=!0));}},{key:"handleEnd",value:function(){this.track("Video Content Completed",this.metadata[this.playlistIndex].content),this.contentStarted=!1;var e=this.player.getPlaylistIndex(),t=this.player.getPlaylist();(t&&e===t.length-1||-1===e)&&(this.track("Video Playback Completed",this.metadata[this.playlistIndex].playback),this.playbackStarted=!1);}},{key:"determineSeek",value:function(){var e=this.isPaused||this.isBuffering?0:Date.now()-this.lastRecordedTime.timeReported,t=1e3*this.player.getCurrentTime()-this.lastRecordedTime.timeElapsed;return Math.abs(e-t)>2e3}}]),t}(r.default);function l(e){var t=e.match(/PT(\d+H)?(\d+M)?(\d+S)?/);return t=t.slice(1).map((function(e){if(null!=e)return e.replace(/\D/,"")})),3600*(parseInt(t[0])||0)+60*(parseInt(t[1])||0)+(parseInt(t[2])||0)}t.default=s;}])}));
|
|
22
|
-
} (index_umd$2));
|
|
23
|
-
|
|
24
|
-
var index_umdExports = index_umd$2.exports;
|
|
25
|
-
var index_umd = /*@__PURE__*/getDefaultExportFromCjs(index_umdExports);
|
|
26
|
-
|
|
27
|
-
var index_umd$1 = /*#__PURE__*/_mergeNamespaces({
|
|
28
|
-
__proto__: null,
|
|
29
|
-
default: index_umd
|
|
30
|
-
}, [index_umdExports]);
|
|
31
|
-
|
|
32
|
-
export { index_umd$1 as i };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines whether a track event is allowed to be sent based on the
|
|
3
|
-
* user's tracking plan.
|
|
4
|
-
* If the user does not have a tracking plan or the event is allowed based
|
|
5
|
-
* on the tracking plan configuration, returns true.
|
|
6
|
-
*/
|
|
7
|
-
function isPlanEventEnabled(plan, planEvent) {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
// Always prioritize the event's `enabled` status
|
|
10
|
-
if (typeof (planEvent === null || planEvent === void 0 ? void 0 : planEvent.enabled) === 'boolean') {
|
|
11
|
-
return planEvent.enabled;
|
|
12
|
-
}
|
|
13
|
-
// Assume absence of a tracking plan means events are enabled
|
|
14
|
-
return (_b = (_a = plan === null || plan === void 0 ? void 0 : plan.__default) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { isPlanEventEnabled as i };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Checkout } from '@imtbl/checkout-sdk';
|
|
2
|
-
type CustomAnalyticsProps = {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
checkout: Checkout;
|
|
5
|
-
};
|
|
6
|
-
export declare function CustomAnalyticsProvider({ children, checkout }: CustomAnalyticsProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { StandardAnalyticsControlTypes } from '@imtbl/react-analytics';
|
|
2
|
-
import type { PropsWithChildren, ReactElement } from 'react';
|
|
3
|
-
export declare enum UserJourney {
|
|
4
|
-
CONNECT = "Connect",
|
|
5
|
-
WALLET = "Wallet",
|
|
6
|
-
ON_RAMP = "OnRamp",
|
|
7
|
-
SWAP = "Swap",
|
|
8
|
-
BRIDGE = "Bridge",
|
|
9
|
-
SALE = "PrimarySale",
|
|
10
|
-
ADD_TOKENS = "AddTokens",
|
|
11
|
-
PURCHASE = "Purchase",
|
|
12
|
-
TRANSFER = "Transfer"
|
|
13
|
-
}
|
|
14
|
-
export type AnalyticsControlTypes = StandardAnalyticsControlTypes | 'IframeEvent' | 'Event';
|
|
15
|
-
export declare const AnalyticsProvider: (props: PropsWithChildren) => ReactElement;
|
|
16
|
-
export declare const useAnalytics: () => {
|
|
17
|
-
page: (props: {
|
|
18
|
-
screen: string;
|
|
19
|
-
userJourney: UserJourney;
|
|
20
|
-
action?: import("@imtbl/react-analytics").StandardAnalyticsActions | undefined;
|
|
21
|
-
extras?: Record<string, unknown> | undefined;
|
|
22
|
-
}) => Promise<import("@segment/analytics-next").Context>;
|
|
23
|
-
track: (props: {
|
|
24
|
-
screen: string;
|
|
25
|
-
userJourney: UserJourney;
|
|
26
|
-
extras?: Record<string, unknown> | undefined;
|
|
27
|
-
} & ({
|
|
28
|
-
action: import("@imtbl/react-analytics").StandardAnalyticsActions;
|
|
29
|
-
control?: undefined;
|
|
30
|
-
controlType?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
control: string;
|
|
33
|
-
controlType: AnalyticsControlTypes;
|
|
34
|
-
action?: import("@imtbl/react-analytics").StandardAnalyticsActions | undefined;
|
|
35
|
-
})) => Promise<import("@segment/analytics-next").Context>;
|
|
36
|
-
identify: import("@segment/analytics-next/dist/types/core/buffer").AnalyticsBuffered["identify"];
|
|
37
|
-
group(traits: import("@segment/analytics-next").GroupTraits): Promise<import("@segment/analytics-next").Context>;
|
|
38
|
-
alias: import("@segment/analytics-next/dist/types/core/buffer").AnalyticsBuffered["alias"];
|
|
39
|
-
identifyFromCookie: () => Promise<import("@segment/analytics-next").Context>;
|
|
40
|
-
updateWriteKey: (writeKey: string) => void;
|
|
41
|
-
user: import("@segment/analytics-next/dist/types/core/buffer").AnalyticsBuffered["user"];
|
|
42
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Checkout } from '@imtbl/checkout-sdk';
|
|
2
|
-
type SetupAnalyticsProps = {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
checkout: Checkout;
|
|
5
|
-
};
|
|
6
|
-
export declare function SetupAnalytics({ children, checkout }: SetupAnalyticsProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WrappedBrowserProvider } from '@imtbl/checkout-sdk';
|
|
2
|
-
/**
|
|
3
|
-
* identifyUser - function to identify a user by their wallet address and call the function to raise analytics
|
|
4
|
-
* @param identify - The identify function from the useAnalytics() hook
|
|
5
|
-
* @param provider - the WrappedBrowserProvider used to find the user's walletAddress
|
|
6
|
-
* @param options - additional options to pass to the identify function
|
|
7
|
-
*/
|
|
8
|
-
export declare function identifyUser(identify: (id: string, attributes: Record<string, any>, options?: Record<string, any>) => void, provider: WrappedBrowserProvider, options?: Record<string, any>): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Checkout } from '@imtbl/checkout-sdk';
|
|
2
|
-
import {
|
|
3
|
-
AnalyticsProvider,
|
|
4
|
-
} from './SegmentAnalyticsProvider';
|
|
5
|
-
import { SetupAnalytics } from './SetupAnalytics';
|
|
6
|
-
|
|
7
|
-
type CustomAnalyticsProps = {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
checkout: Checkout;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function CustomAnalyticsProvider(
|
|
13
|
-
{ children, checkout }: CustomAnalyticsProps,
|
|
14
|
-
) {
|
|
15
|
-
return (
|
|
16
|
-
<AnalyticsProvider>
|
|
17
|
-
<SetupAnalytics checkout={checkout}>
|
|
18
|
-
{children}
|
|
19
|
-
</SetupAnalytics>
|
|
20
|
-
</AnalyticsProvider>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createAnalytics,
|
|
3
|
-
StandardAnalyticsControlTypes,
|
|
4
|
-
} from '@imtbl/react-analytics';
|
|
5
|
-
import type { PropsWithChildren, ReactElement } from 'react';
|
|
6
|
-
|
|
7
|
-
export enum UserJourney {
|
|
8
|
-
CONNECT = 'Connect',
|
|
9
|
-
WALLET = 'Wallet',
|
|
10
|
-
ON_RAMP = 'OnRamp',
|
|
11
|
-
SWAP = 'Swap',
|
|
12
|
-
BRIDGE = 'Bridge',
|
|
13
|
-
SALE = 'PrimarySale',
|
|
14
|
-
ADD_TOKENS = 'AddTokens',
|
|
15
|
-
PURCHASE = 'Purchase',
|
|
16
|
-
TRANSFER = 'Transfer',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type AnalyticsControlTypes =
|
|
20
|
-
| StandardAnalyticsControlTypes
|
|
21
|
-
| 'IframeEvent'
|
|
22
|
-
| 'Event';
|
|
23
|
-
|
|
24
|
-
const productName = 'checkout';
|
|
25
|
-
|
|
26
|
-
const analytics = createAnalytics<
|
|
27
|
-
UserJourney,
|
|
28
|
-
string,
|
|
29
|
-
string,
|
|
30
|
-
AnalyticsControlTypes
|
|
31
|
-
>({
|
|
32
|
-
writeKey: '',
|
|
33
|
-
appName: productName,
|
|
34
|
-
storageKeyPrefix: 'checkoutWidgets',
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Explicit annotation: createAnalytics returns emotion JSX.Element, which is not portable
|
|
38
|
-
export const AnalyticsProvider = analytics.AnalyticsProvider as (
|
|
39
|
-
props: PropsWithChildren,
|
|
40
|
-
) => ReactElement;
|
|
41
|
-
export const useAnalytics = analytics.useAnalytics;
|