@rork-ai/toolkit-sdk 0.2.10 → 0.2.11
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/lib/module/analytics.js
CHANGED
|
@@ -7,13 +7,18 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
const projectId = process.env.EXPO_PUBLIC_PROJECT_ID;
|
|
8
8
|
const teamId = process.env.EXPO_PUBLIC_TEAM_ID;
|
|
9
9
|
const isAnalyticsEnabled = !!projectId && !!teamId;
|
|
10
|
+
const $groups = {
|
|
11
|
+
project: projectId,
|
|
12
|
+
team: teamId
|
|
13
|
+
};
|
|
10
14
|
let posthog = null;
|
|
11
15
|
function getPostHogClient() {
|
|
12
16
|
if (!isAnalyticsEnabled) return null;
|
|
13
17
|
if (!posthog) {
|
|
14
18
|
posthog = new PostHog("phc_vYe1AkzyZn9BWXWd8B4v79p5nPVADg8Ydf2zJ8NGnBZ", {
|
|
15
19
|
host: "https://toolkit.rork.com/relay-GnBZ/",
|
|
16
|
-
captureAppLifecycleEvents: true
|
|
20
|
+
captureAppLifecycleEvents: true,
|
|
21
|
+
disableCompression: true
|
|
17
22
|
});
|
|
18
23
|
}
|
|
19
24
|
return posthog;
|
|
@@ -24,10 +29,7 @@ export function trackEvent(name, properties) {
|
|
|
24
29
|
}
|
|
25
30
|
getPostHogClient()?.capture(name, {
|
|
26
31
|
...properties,
|
|
27
|
-
$groups
|
|
28
|
-
project: projectId,
|
|
29
|
-
team: teamId
|
|
30
|
-
}
|
|
32
|
+
$groups
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
export function AnalyticsProvider({
|
|
@@ -38,7 +40,10 @@ export function AnalyticsProvider({
|
|
|
38
40
|
const posthogClient = getPostHogClient();
|
|
39
41
|
useEffect(() => {
|
|
40
42
|
if (!isAnalyticsEnabled) return;
|
|
41
|
-
posthogClient?.screen(pathname,
|
|
43
|
+
posthogClient?.screen(pathname, {
|
|
44
|
+
...params,
|
|
45
|
+
$groups
|
|
46
|
+
});
|
|
42
47
|
}, [pathname, params]);
|
|
43
48
|
if (!posthogClient) {
|
|
44
49
|
return children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useGlobalSearchParams","usePathname","PostHog","PostHogProvider","useEffect","jsx","_jsx","projectId","process","env","EXPO_PUBLIC_PROJECT_ID","teamId","EXPO_PUBLIC_TEAM_ID","isAnalyticsEnabled","
|
|
1
|
+
{"version":3,"names":["useGlobalSearchParams","usePathname","PostHog","PostHogProvider","useEffect","jsx","_jsx","projectId","process","env","EXPO_PUBLIC_PROJECT_ID","teamId","EXPO_PUBLIC_TEAM_ID","isAnalyticsEnabled","$groups","project","team","posthog","getPostHogClient","host","captureAppLifecycleEvents","disableCompression","trackEvent","name","properties","capture","AnalyticsProvider","children","pathname","params","posthogClient","screen","client","autocapture","captureTouches"],"sourceRoot":"../../src","sources":["analytics.tsx"],"mappings":";;AAAA,SAASA,qBAAqB,EAAEC,WAAW,QAAQ,aAAa;AAChE,OAAOC,OAAO,IAAIC,eAAe,QAAQ,sBAAsB;AAC/D,SAASC,SAAS,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElC,MAAMC,SAAS,GAAGC,OAAO,CAACC,GAAG,CAACC,sBAAsB;AACpD,MAAMC,MAAM,GAAGH,OAAO,CAACC,GAAG,CAACG,mBAAmB;AAE9C,MAAMC,kBAAkB,GAAG,CAAC,CAACN,SAAS,IAAI,CAAC,CAACI,MAAM;AAElD,MAAMG,OAAO,GAAG;EAAEC,OAAO,EAAER,SAAS;EAAES,IAAI,EAAEL;AAAO,CAAC;AAEpD,IAAIM,OAAuB,GAAG,IAAI;AAClC,SAASC,gBAAgBA,CAAA,EAAG;EAC1B,IAAI,CAACL,kBAAkB,EAAE,OAAO,IAAI;EACpC,IAAI,CAACI,OAAO,EAAE;IACZA,OAAO,GAAG,IAAIf,OAAO,CAAC,iDAAiD,EAAE;MACvEiB,IAAI,EAAE,sCAAsC;MAC5CC,yBAAyB,EAAE,IAAI;MAC/BC,kBAAkB,EAAE;IACtB,CAAC,CAAC;EACJ;EAEA,OAAOJ,OAAO;AAChB;AAEA,OAAO,SAASK,UAAUA,CAACC,IAAY,EAAEC,UAA+B,EAAE;EACxE,IAAI,CAACX,kBAAkB,EAAE;IACvB;EACF;EAEAK,gBAAgB,CAAC,CAAC,EAAEO,OAAO,CAACF,IAAI,EAAE;IAAE,GAAGC,UAAU;IAAEV;EAAQ,CAAC,CAAC;AAC/D;AAEA,OAAO,SAASY,iBAAiBA,CAAC;EAAEC;AAAwC,CAAC,EAAE;EAC7E,MAAMC,QAAQ,GAAG3B,WAAW,CAAC,CAAC;EAC9B,MAAM4B,MAAM,GAAG7B,qBAAqB,CAAC,CAAC;EACtC,MAAM8B,aAAa,GAAGZ,gBAAgB,CAAC,CAAC;EAExCd,SAAS,CAAC,MAAM;IACd,IAAI,CAACS,kBAAkB,EAAE;IAEzBiB,aAAa,EAAEC,MAAM,CAACH,QAAQ,EAAE;MAAE,GAAGC,MAAM;MAAEf;IAAQ,CAAC,CAAC;EACzD,CAAC,EAAE,CAACc,QAAQ,EAAEC,MAAM,CAAC,CAAC;EAEtB,IAAI,CAACC,aAAa,EAAE;IAClB,OAAOH,QAAQ;EACjB;EAEA,oBACErB,IAAA,CAACH,eAAe;IACd6B,MAAM,EAAEF,aAAc;IACtBG,WAAW,EAAE;MAAEC,cAAc,EAAE;IAAK,CAAE;IAAAP,QAAA,EAErCA;EAAQ,CACM,CAAC;AAEtB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/analytics.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/analytics.tsx"],"names":[],"mappings":"AAyBA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAMvE;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2WAuB5E"}
|
package/package.json
CHANGED
package/src/analytics.tsx
CHANGED
|
@@ -7,6 +7,8 @@ const teamId = process.env.EXPO_PUBLIC_TEAM_ID;
|
|
|
7
7
|
|
|
8
8
|
const isAnalyticsEnabled = !!projectId && !!teamId;
|
|
9
9
|
|
|
10
|
+
const $groups = { project: projectId, team: teamId };
|
|
11
|
+
|
|
10
12
|
let posthog: PostHog | null = null;
|
|
11
13
|
function getPostHogClient() {
|
|
12
14
|
if (!isAnalyticsEnabled) return null;
|
|
@@ -14,6 +16,7 @@ function getPostHogClient() {
|
|
|
14
16
|
posthog = new PostHog("phc_vYe1AkzyZn9BWXWd8B4v79p5nPVADg8Ydf2zJ8NGnBZ", {
|
|
15
17
|
host: "https://toolkit.rork.com/relay-GnBZ/",
|
|
16
18
|
captureAppLifecycleEvents: true,
|
|
19
|
+
disableCompression: true,
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -25,13 +28,7 @@ export function trackEvent(name: string, properties: Record<string, any>) {
|
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
getPostHogClient()?.capture(name, {
|
|
29
|
-
...properties,
|
|
30
|
-
$groups: {
|
|
31
|
-
project: projectId,
|
|
32
|
-
team: teamId,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
31
|
+
getPostHogClient()?.capture(name, { ...properties, $groups });
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
export function AnalyticsProvider({ children }: { children: React.ReactNode }) {
|
|
@@ -42,7 +39,7 @@ export function AnalyticsProvider({ children }: { children: React.ReactNode }) {
|
|
|
42
39
|
useEffect(() => {
|
|
43
40
|
if (!isAnalyticsEnabled) return;
|
|
44
41
|
|
|
45
|
-
posthogClient?.screen(pathname, params);
|
|
42
|
+
posthogClient?.screen(pathname, { ...params, $groups });
|
|
46
43
|
}, [pathname, params]);
|
|
47
44
|
|
|
48
45
|
if (!posthogClient) {
|