Skip to content

Commit 074405b

Browse files
authored
Cartridge tag fix (#141)
* Move cartridgeTag to analyticsOptions * Add changeset
1 parent c5ce956 commit 074405b

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

.changeset/tame-garlics-retire.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@treasure-dev/tdk-react": patch
3+
"@treasure-dev/tdk-core": patch
4+
---
5+
6+
Moved cartridgeTag to analyticsOptions

examples/connect-react/src/App.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ const ERC20_MINTABLE_ABI = [
3434
},
3535
] as const;
3636

37-
const cartridgeTag = "tdk-examples-connect-react";
38-
3937
export const App = () => {
4038
const { client, chain, tdk, user, contractAddresses, trackCustomEvent } =
4139
useTreasure();
@@ -111,7 +109,6 @@ export const App = () => {
111109
setTracking(true);
112110
try {
113111
const result = await trackCustomEvent({
114-
cartridgeTag,
115112
name: "test-click",
116113
properties: { test: "test-value" },
117114
});
@@ -134,7 +131,6 @@ export const App = () => {
134131
console.log("Connect successful:", { method, wallet, nextUser });
135132
trackCustomEvent({
136133
address: nextUser?.address,
137-
cartridgeTag,
138134
name: "wallet-connect",
139135
properties: {
140136
method,

examples/connect-react/src/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ if (root) {
3535
app_version: "1.0.0",
3636
app_environment: 0,
3737
},
38+
cartridgeTag: "tdk-examples-connect-react",
3839
}}
3940
>
4041
<App />

packages/core/src/analytics/AnalyticsManager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export class AnalyticsManager {
2020

2121
app!: AppInfo;
2222

23+
cartridgeTag!: string;
24+
2325
private constructor() {}
2426

2527
public static get instance(): AnalyticsManager {
@@ -34,10 +36,12 @@ export class AnalyticsManager {
3436
apiUri = DEFAULT_TDK_DARKMATTER_BASE_URI,
3537
apiKey,
3638
app,
37-
}: { apiUri?: string; apiKey: string; app: AppInfo }) {
39+
cartridgeTag,
40+
}: { apiUri?: string; apiKey: string; app: AppInfo; cartridgeTag: string }) {
3841
this.apiUri = apiUri;
3942
this.apiKey = apiKey;
4043
this.app = app;
44+
this.cartridgeTag = cartridgeTag;
4145
this.initialized = true;
4246

4347
setInterval(
@@ -88,6 +92,7 @@ export class AnalyticsManager {
8892
const payload: AnalyticsPayload = {
8993
...event,
9094
id: eventId,
95+
cartridge_tag: this.cartridgeTag,
9196
time_server: serverTime,
9297
time_local: localTime,
9398
app: this.app,

packages/core/src/analytics/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export type AnalyticsPayload = PlayerIdPayload & {
6161
};
6262

6363
export type TrackableEvent = PlayerIdPayload & {
64-
cartridge_tag: string;
6564
name: string;
6665
properties: { [key: string]: PropertyValue | PropertyValue[] };
6766
};

packages/react/src/contexts/treasure.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const TreasureProviderInner = ({
112112
apiUri: analyticsOptions.apiUri,
113113
apiKey: analyticsOptions.apiKey,
114114
app: analyticsOptions.appInfo,
115+
cartridgeTag: analyticsOptions.cartridgeTag,
115116
});
116117

117118
return AnalyticsManager.instance;
@@ -147,7 +148,6 @@ const TreasureProviderInner = ({
147148

148149
const trackableEvent: TrackableEvent = {
149150
...playerId,
150-
cartridge_tag: event.cartridgeTag,
151151
name: event.name,
152152
properties: event.properties,
153153
};

packages/react/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type { Wallet } from "thirdweb/dist/types/exports/wallets";
1515
import type { SupportedLanguage } from "./i18n";
1616

1717
export type AnalyticsEvent = {
18-
cartridgeTag: string;
1918
name: string;
2019
userId?: string;
2120
address?: string;
@@ -30,6 +29,7 @@ type AnalyticsOptions = {
3029
apiUri?: string;
3130
apiKey: string;
3231
appInfo: AppInfo;
32+
cartridgeTag: string;
3333
};
3434

3535
export type Config = {

0 commit comments

Comments
 (0)