@inlang/sdk 2.6.2 → 2.8.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/json-schema/old-v1-message/toMessageV1.js +5 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -1
- package/dist/json-schema/old-v1-message/toMessageV1.test.js +41 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -1
- package/dist/json-schema/pattern.d.ts +134 -0
- package/dist/json-schema/pattern.d.ts.map +1 -1
- package/dist/json-schema/pattern.js +23 -1
- package/dist/json-schema/pattern.js.map +1 -1
- package/dist/json-schema/settings.d.ts +0 -1
- package/dist/json-schema/settings.d.ts.map +1 -1
- package/dist/json-schema/settings.js +0 -5
- package/dist/json-schema/settings.js.map +1 -1
- package/dist/project/loadProject.d.ts +0 -9
- package/dist/project/loadProject.d.ts.map +1 -1
- package/dist/project/loadProject.js +0 -16
- package/dist/project/loadProject.js.map +1 -1
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -1
- package/dist/project/loadProjectFromDirectory.js +1 -1
- package/dist/project/loadProjectFromDirectory.js.map +1 -1
- package/dist/project/newProject.d.ts.map +1 -1
- package/dist/project/newProject.js +1 -6
- package/dist/project/newProject.js.map +1 -1
- package/dist/project/newProject.test.js +12 -0
- package/dist/project/newProject.test.js.map +1 -1
- package/dist/query-utilities/selectBundleNested.d.ts +60 -0
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -1
- package/dist/services/env-variables/index.d.ts +0 -1
- package/dist/services/env-variables/index.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -2
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +1 -1
- package/src/json-schema/old-v1-message/toMessageV1.test.ts +45 -0
- package/src/json-schema/old-v1-message/toMessageV1.ts +8 -0
- package/src/json-schema/pattern.ts +33 -1
- package/src/json-schema/settings.ts +0 -10
- package/src/project/loadProject.ts +0 -28
- package/src/project/loadProjectFromDirectory.ts +1 -6
- package/src/project/newProject.test.ts +16 -0
- package/src/project/newProject.ts +1 -6
- package/src/services/env-variables/createIndexFile.js +0 -1
- package/src/services/env-variables/index.d.ts +0 -1
- package/dist/project/maybeCaptureTelemetry.d.ts +0 -16
- package/dist/project/maybeCaptureTelemetry.d.ts.map +0 -1
- package/dist/project/maybeCaptureTelemetry.js +0 -61
- package/dist/project/maybeCaptureTelemetry.js.map +0 -1
- package/dist/project/maybeCaptureTelemetry.test.d.ts +0 -2
- package/dist/project/maybeCaptureTelemetry.test.d.ts.map +0 -1
- package/dist/project/maybeCaptureTelemetry.test.js +0 -69
- package/dist/project/maybeCaptureTelemetry.test.js.map +0 -1
- package/dist/services/telemetry/capture.d.ts +0 -24
- package/dist/services/telemetry/capture.d.ts.map +0 -1
- package/dist/services/telemetry/capture.js +0 -72
- package/dist/services/telemetry/capture.js.map +0 -1
- package/dist/services/telemetry/capture.test.d.ts +0 -2
- package/dist/services/telemetry/capture.test.d.ts.map +0 -1
- package/dist/services/telemetry/capture.test.js +0 -43
- package/dist/services/telemetry/capture.test.js.map +0 -1
- package/src/project/maybeCaptureTelemetry.test.ts +0 -80
- package/src/project/maybeCaptureTelemetry.ts +0 -77
- package/src/services/telemetry/capture.test.ts +0 -50
- package/src/services/telemetry/capture.ts +0 -98
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// import { ENV_VARIABLES } from "../env-variables/index.js";
|
|
2
|
-
|
|
3
|
-
import type { ProjectSettings } from "../../json-schema/settings.js";
|
|
4
|
-
import { ENV_VARIABLES } from "../env-variables/index.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* List of telemetry events for typesafety.
|
|
8
|
-
*
|
|
9
|
-
* - prefix with `SDK` to avoid collisions with other apps
|
|
10
|
-
* - use past tense to indicate that the event is completed
|
|
11
|
-
*/
|
|
12
|
-
type TelemetryEvent = "SDK loaded project";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Capture an event.
|
|
16
|
-
*
|
|
17
|
-
* - manually calling the PostHog API because the SDKs were not platform angostic (and generally bloated)
|
|
18
|
-
*/
|
|
19
|
-
export const capture = async (
|
|
20
|
-
event: TelemetryEvent,
|
|
21
|
-
args: {
|
|
22
|
-
projectId: string;
|
|
23
|
-
accountId: string;
|
|
24
|
-
/**
|
|
25
|
-
* Please use snake_case for property names.
|
|
26
|
-
*/
|
|
27
|
-
properties: Record<string, any>;
|
|
28
|
-
settings: Pick<ProjectSettings, "telemetry">;
|
|
29
|
-
}
|
|
30
|
-
) => {
|
|
31
|
-
if (args.settings.telemetry === "off") {
|
|
32
|
-
return;
|
|
33
|
-
} else if (ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN === undefined) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
await fetch("https://eu.posthog.com/capture/", {
|
|
38
|
-
method: "POST",
|
|
39
|
-
body: JSON.stringify({
|
|
40
|
-
api_key: ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN,
|
|
41
|
-
event,
|
|
42
|
-
distinct_id: args.accountId,
|
|
43
|
-
properties: {
|
|
44
|
-
$groups: { project: args.projectId },
|
|
45
|
-
...args.properties,
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
});
|
|
49
|
-
await identifyProject({
|
|
50
|
-
projectId: args.projectId,
|
|
51
|
-
accountId: args.accountId,
|
|
52
|
-
// using the id for now as a name but can be changed in the future
|
|
53
|
-
// we need at least one property to make a project visible in the dashboar
|
|
54
|
-
properties: { name: args.projectId },
|
|
55
|
-
});
|
|
56
|
-
} catch {
|
|
57
|
-
// do nothing
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Identifying a project is needed.
|
|
63
|
-
*
|
|
64
|
-
* Otherwise, the project will not be visible in the PostHog dashboard.
|
|
65
|
-
*/
|
|
66
|
-
const identifyProject = async (args: {
|
|
67
|
-
projectId: string;
|
|
68
|
-
accountId: string;
|
|
69
|
-
/**
|
|
70
|
-
* Please use snake_case for property names.
|
|
71
|
-
*/
|
|
72
|
-
properties: Record<string, any>;
|
|
73
|
-
}) => {
|
|
74
|
-
// do not send events if the token is not set
|
|
75
|
-
// (assuming this eases testing)
|
|
76
|
-
if (ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN === undefined) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
await fetch("https://eu.posthog.com/capture/", {
|
|
81
|
-
method: "POST",
|
|
82
|
-
body: JSON.stringify({
|
|
83
|
-
api_key: ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN,
|
|
84
|
-
event: "$groupidentify",
|
|
85
|
-
distinct_id: args.accountId,
|
|
86
|
-
properties: {
|
|
87
|
-
$group_type: "project",
|
|
88
|
-
$group_key: args.projectId,
|
|
89
|
-
$group_set: {
|
|
90
|
-
...args.properties,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
}),
|
|
94
|
-
});
|
|
95
|
-
} catch {
|
|
96
|
-
// do nothing
|
|
97
|
-
}
|
|
98
|
-
};
|