Export events to posthog too
This commit is contained in:
parent
63ede0b51a
commit
e7a7cf3eb8
1 changed files with 18 additions and 7 deletions
|
@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { SpanExporter } from "@opentelemetry/sdk-trace-base";
|
||||
import { ReadableSpan } from "@opentelemetry/sdk-trace-base";
|
||||
import { SpanExporter, ReadableSpan } from "@opentelemetry/sdk-trace-base";
|
||||
import { ExportResult, ExportResultCode } from "@opentelemetry/core";
|
||||
|
||||
import { PosthogAnalytics } from "./PosthogAnalytics";
|
||||
|
@ -34,11 +33,23 @@ export class PosthogSpanExporter implements SpanExporter {
|
|||
resultCallback: (result: ExportResult) => void
|
||||
): Promise<void> {
|
||||
console.log("POSTHOGEXPORTER", spans);
|
||||
for (let i = 0; i < spans.length; i++) {
|
||||
const span = spans[i];
|
||||
const sendInstantly =
|
||||
span.name == "otel_callEnded" ||
|
||||
span.name == "otel_otherSentInstantlyEventName";
|
||||
for (const span of spans) {
|
||||
const sendInstantly = [
|
||||
"otel_callEnded",
|
||||
"otel_otherSentInstantlyEventName",
|
||||
].includes(span.name);
|
||||
|
||||
for (const spanEvent of span.events) {
|
||||
await PosthogAnalytics.instance.trackFromSpan(
|
||||
{
|
||||
eventName: spanEvent.name,
|
||||
...spanEvent.attributes,
|
||||
},
|
||||
{
|
||||
send_instantly: sendInstantly,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
await PosthogAnalytics.instance.trackFromSpan(
|
||||
{ eventName: span.name, ...span.attributes },
|
||||
|
|
Loading…
Reference in a new issue