Skip to content

Commit

Permalink
Merge branch 'v2.0' into chore/2.16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ganchoradkov authored Sep 18, 2024
2 parents 38a8168 + cb0a006 commit d9362bf
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/core/src/controllers/events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateChildLogger, Logger } from "@walletconnect/logger";
import { ICore, IEventClient, EventClientTypes } from "@walletconnect/types";
import { formatUA, isTestRun, uuidv4 } from "@walletconnect/utils";
import { formatUA, isTestRun, uuidv4, getAppMetadata } from "@walletconnect/utils";
import {
CORE_STORAGE_PREFIX,
EVENTS_CLIENT_API_URL,
Expand Down Expand Up @@ -45,6 +45,7 @@ export class EventClient extends IEventClient {
const initEvent = {
eventId: uuidv4(),
timestamp: Date.now(),
domain: this.getAppDomain(),
props: {
event: "INIT",
type: "",
Expand Down Expand Up @@ -83,12 +84,12 @@ export class EventClient extends IEventClient {
};
const eventObj = {
eventId,
bundleId,
timestamp,
props,
bundleId,
domain: this.getAppDomain(),
...this.setMethods(eventId),
};

if (this.telemetryEnabled) {
this.events.set(eventId, eventObj);
this.shouldPersist = true;
Expand Down Expand Up @@ -210,13 +211,19 @@ export class EventClient extends IEventClient {
};

private sendEvent = async (events: EventClientTypes.Event[]) => {
// if domain isn't available, set `sp` as `desktop` so data would be extracted on api side
const platform = this.getAppDomain() ? "" : "&sp=desktop";
const response = await fetch(
`${EVENTS_CLIENT_API_URL}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${RELAYER_SDK_VERSION}`,
`${EVENTS_CLIENT_API_URL}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${RELAYER_SDK_VERSION}${platform}`,
{
method: "POST",
body: JSON.stringify(events),
},
);
return response;
};

private getAppDomain = () => {
return getAppMetadata().url;
};
}

0 comments on commit d9362bf

Please sign in to comment.