MCPcopy
hub / github.com/triggerdotdev/trigger.dev / Telemetry

Class Telemetry

apps/webapp/app/services/telemetry.server.ts:20–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18};
19
20class Telemetry {
21 #posthogClient: PostHog | undefined = undefined;
22 #triggerClient: TriggerClient | undefined = undefined;
23
24 constructor({ postHogApiKey, trigger }: Options) {
25 if (postHogApiKey) {
26 this.#posthogClient = new PostHog(postHogApiKey, { host: "https://eu.posthog.com" });
27 } else {
28 console.log("No PostHog API key, so analytics won't track");
29 }
30
31 if (trigger) {
32 this.#triggerClient = new TriggerClient({
33 id: "triggerdotdev",
34 apiKey: trigger.apiKey,
35 apiUrl: trigger.apiUrl,
36 });
37 console.log("Created telemetry TriggerClient");
38 }
39 }
40
41 user = {
42 identify: ({ user, isNewUser }: { user: User; isNewUser: boolean }) => {
43 if (this.#posthogClient) {
44 this.#posthogClient.identify({
45 distinctId: user.id,
46 properties: {
47 email: user.email,
48 name: user.name,
49 authenticationMethod: user.authenticationMethod,
50 admin: user.admin,
51 createdAt: user.createdAt,
52 isNewUser,
53 },
54 });
55 }
56 if (isNewUser) {
57 this.#capture({
58 userId: user.id,
59 event: "user created",
60 eventProperties: {
61 email: user.email,
62 name: user.name,
63 authenticationMethod: user.authenticationMethod,
64 admin: user.admin,
65 createdAt: user.createdAt,
66 },
67 });
68
69 loopsClient?.userCreated({
70 userId: user.id,
71 email: user.email,
72 name: user.name,
73 });
74
75 this.#triggerClient?.sendEvent({
76 name: "user.created",
77 payload: {

Callers

nothing calls this directly

Calls 4

#captureMethod · 0.95
identifyMethod · 0.80
userCreatedMethod · 0.80
sendEventMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…