fix: add sdk logs behind debug flag

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-12-15 10:20:19 +01:00
parent 3d8a3e8997
commit 1f5c648afe
2 changed files with 13 additions and 9 deletions

View File

@@ -68,6 +68,7 @@ export type OpenPanelOptions = {
waitForProfile?: boolean;
filter?: (payload: TrackHandlerPayload) => boolean;
disabled?: boolean;
debug?: boolean;
};
export class OpenPanel {
@@ -129,6 +130,7 @@ export class OpenPanel {
}
async track(name: string, properties?: TrackProperties) {
this.log('track event', name, properties);
return this.send({
type: 'track',
payload: {
@@ -143,6 +145,7 @@ export class OpenPanel {
}
async identify(payload: IdentifyPayload) {
this.log('identify user', payload);
if (payload.profileId) {
this.profileId = payload.profileId;
this.flush();
@@ -162,12 +165,10 @@ export class OpenPanel {
}
}
async alias(payload: AliasPayload) {
return this.send({
type: 'alias',
payload,
});
}
/**
* @deprecated This method is deprecated and will be removed in a future version.
*/
async alias(payload: AliasPayload) {}
async increment(payload: IncrementPayload) {
return this.send({
@@ -224,4 +225,10 @@ export class OpenPanel {
});
this.queue = [];
}
log(...args: any[]) {
if (this.options.debug) {
console.log('[OpenPanel.dev]', ...args);
}
}
}

View File

@@ -38,8 +38,6 @@ export class OpenPanel extends OpenPanelBase {
});
if (!this.isServer()) {
console.log('OpenPanel.dev - Initialized', this.options);
try {
const pending = sessionStorage.getItem('openpanel-pending-revenues');
if (pending) {
@@ -202,7 +200,6 @@ export class OpenPanel extends OpenPanelBase {
}
this.lastPath = path;
console.log('OpenPanel.dev - Track page view');
super.track('screen_view', {
...(properties ?? {}),
__path: path,