@wxt-dev/analytics 0.2.0 → 0.2.2
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/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +6 -1
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
package/dist/client.d.ts
CHANGED
package/dist/client.mjs
CHANGED
|
@@ -2,10 +2,15 @@ import { UAParser } from 'ua-parser-js';
|
|
|
2
2
|
|
|
3
3
|
const ANALYTICS_PORT = "@wxt-dev/analytics";
|
|
4
4
|
function createAnalytics(config) {
|
|
5
|
-
if (
|
|
5
|
+
if (typeof chrome === "undefined" || !chrome?.runtime?.id)
|
|
6
6
|
throw Error(
|
|
7
7
|
"Cannot use WXT analytics in contexts without access to the browser.runtime APIs"
|
|
8
8
|
);
|
|
9
|
+
if (config == null) {
|
|
10
|
+
console.warn(
|
|
11
|
+
"[@wxt-dev/analytics] Config not provided to createAnalytics. If you're using WXT, add the 'analytics' property to '<srcDir>/app.config.ts'."
|
|
12
|
+
);
|
|
13
|
+
}
|
|
9
14
|
if (location.pathname === "/background.js")
|
|
10
15
|
return createBackgroundAnalytics(config);
|
|
11
16
|
return createFrontendAnalytics();
|
package/dist/index.mjs
CHANGED
|
@@ -18,9 +18,10 @@ const index = defineWxtModule({
|
|
|
18
18
|
"analytics/index.ts"
|
|
19
19
|
);
|
|
20
20
|
const analyticsModuleCode = `
|
|
21
|
-
|
|
21
|
+
import { createAnalytics } from '@wxt-dev/analytics/client';
|
|
22
|
+
import { useAppConfig } from 'wxt/client';
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
export const analytics = createAnalytics(useAppConfig().analytics);
|
|
24
25
|
`;
|
|
25
26
|
addAlias(wxt, "#analytics", analyticsModulePath);
|
|
26
27
|
wxt.hook("prepare:types", async (_, entries) => {
|