@rtsdk/topia 0.11.4 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -243,10 +243,38 @@ try {
243
243
  Once complete be sure to also call `await keyAsset.updateDataObject({ turnCount: turnCount + 1 });` so that the next player is free to take their turn!
244
244
 
245
245
  **Custom analytics**
246
- You can leverage the data object methods for all types to track analytics unique to your Public Key by passing `analytics` as an optional array to all calls that set, update, or increment data objects!
246
+ You can leverage the data object methods for all types to track analytics unique to your Public Key by passing `analytics` as an optional array along with `profileId`, `urlSlug`, and/or `uniqueKey` to all calls that set, update, or increment data objects!
247
+
248
+ **World** and **Dropped Asset** classes will automatically include `urlSlug`. In addition to `analytics` you can also pass `profileId` if you want to track event per user and/or a `uniqueKey` to additionally track uniqueness of the event for all time, per user (if `profileId` is included), and per world.
249
+
250
+ Examples leveraging World data objects calls:
251
+
252
+ ```js
253
+ await world.setDataObject({ hello: "world" }, { analytics: [{ analyticName: "resets"} ], lock: { lockId, releaseLock: true });
254
+
255
+ await world.updateDataObject({}, { analytics: [ {analyticName: "matches", uniqueKey: `${playerOneProfileId}-${playerTwoProfileId}`, urlSlug }], });
256
+
257
+ await world.incrementDataObjectValue(`keyAssets.${assetId}.completions`, 1, { analytics: [{ analyticName:"completions", incrementBy: 2, profileId, uniqueKey: profileId, urlSlug }] });
258
+ ```
259
+
260
+ **Visitor** and **User** classes will automatically include `profileId`. In addition to `analytics` you can also pass `urlSlug` if you want to track event per world and/or a `uniqueKey` to additionally track uniqueness of the event for all time, per user, and per world (if `urlSlug` is included).
261
+
262
+ Examples leveraging Visitor data objects calls:
247
263
 
248
264
  ```js
249
- await droppedAsset.updateDataObject({ isResetInProgress: true }, { analytics: ["resetCount"], lock: { lockId } });
265
+ await visitor.setDataObject(
266
+ { hello: "world" },
267
+ { analytics: [{ analyticName: "starts" }], lock: { lockId, releaseLock: true } },
268
+ );
269
+
270
+ await visitor.updateDataObject(
271
+ {},
272
+ { analytics: [{ analyticName: "emotesUnlocked", profileId, uniqueKey: profileId }] },
273
+ );
274
+
275
+ await visitor.incrementDataObjectValue(`completions`, 1, {
276
+ analytics: [{ analyticName: "completions", incrementBy: 2, profileId, urlSlug, uniqueKey: profileId }],
277
+ });
250
278
  ```
251
279
 
252
280
  Note: This does NOT impact the data objects themselves but rather allows you to track custom analytics (incremented by 1) across all instances of your application with a given Public Key.
package/dist/index.d.ts CHANGED
@@ -77,6 +77,14 @@ declare class Scene extends SDKController implements SceneInterface {
77
77
  fetchSceneById(): Promise<void | ResponseType$1>;
78
78
  }
79
79
 
80
+ type AnalyticType = {
81
+ analyticName: string;
82
+ incrementBy?: number;
83
+ profileId?: string;
84
+ uniqueKey?: string;
85
+ urlSlug?: string;
86
+ };
87
+
80
88
  /**
81
89
  * @summary
82
90
  * Create an instance of Dropped Asset class with a given dropped asset id, url slug, and optional attributes and session credentials.
@@ -147,13 +155,11 @@ declare class DroppedAsset extends Asset implements DroppedAssetInterface {
147
155
  * ```
148
156
  */
149
157
  setDataObject(dataObject: object, options?: {
150
- analytics?: string[];
158
+ analytics?: AnalyticType[];
151
159
  lock?: {
152
160
  lockId: string;
153
161
  releaseLock?: boolean;
154
162
  };
155
- profileId?: string;
156
- uniqueKey?: string;
157
163
  }): Promise<void | ResponseType$1>;
158
164
  /**
159
165
  * @summary
@@ -169,13 +175,11 @@ declare class DroppedAsset extends Asset implements DroppedAssetInterface {
169
175
  * ```
170
176
  */
171
177
  updateDataObject(dataObject: object, options?: {
172
- analytics?: string[];
178
+ analytics?: AnalyticType[];
173
179
  lock?: {
174
180
  lockId: string;
175
181
  releaseLock?: boolean;
176
182
  };
177
- profileId?: string;
178
- uniqueKey?: string;
179
183
  }): Promise<void | ResponseType$1>;
180
184
  /**
181
185
  * @summary
@@ -192,13 +196,11 @@ declare class DroppedAsset extends Asset implements DroppedAssetInterface {
192
196
  * ```
193
197
  */
194
198
  incrementDataObjectValue(path: string, amount: number, options?: {
195
- analytics?: string[];
199
+ analytics?: AnalyticType[];
196
200
  lock?: {
197
201
  lockId: string;
198
202
  releaseLock?: boolean;
199
203
  };
200
- profileId?: string;
201
- uniqueKey?: string;
202
204
  }): Promise<void | ResponseType$1>;
203
205
  /**
204
206
  * @summary
@@ -735,13 +737,11 @@ declare class World extends SDKController implements WorldInterface {
735
737
  * ```
736
738
  */
737
739
  setDataObject: (dataObject: object | null | undefined, options?: {
738
- analytics?: string[];
740
+ analytics?: AnalyticType[];
739
741
  lock?: {
740
742
  lockId: string;
741
743
  releaseLock?: boolean;
742
744
  };
743
- profileId?: string;
744
- uniqueKey?: string;
745
745
  }) => Promise<void | ResponseType$1>;
746
746
  /**
747
747
  * @summary
@@ -758,13 +758,11 @@ declare class World extends SDKController implements WorldInterface {
758
758
  * ```
759
759
  */
760
760
  updateDataObject: (dataObject: object, options?: {
761
- analytics?: string[];
761
+ analytics?: AnalyticType[];
762
762
  lock?: {
763
763
  lockId: string;
764
764
  releaseLock?: boolean;
765
765
  };
766
- profileId?: string;
767
- uniqueKey?: string;
768
766
  }) => Promise<void | ResponseType$1>;
769
767
  /**
770
768
  * @summary
@@ -781,13 +779,11 @@ declare class World extends SDKController implements WorldInterface {
781
779
  * ```
782
780
  */
783
781
  incrementDataObjectValue(path: string, amount: number, options?: {
784
- analytics?: string[];
782
+ analytics?: AnalyticType[];
785
783
  lock?: {
786
784
  lockId: string;
787
785
  releaseLock?: boolean;
788
786
  };
789
- profileId?: string;
790
- uniqueKey?: string;
791
787
  }): Promise<void | ResponseType$1>;
792
788
  /**
793
789
  * @summary
@@ -1120,13 +1116,11 @@ declare class User extends SDKController implements UserInterface {
1120
1116
  * ```
1121
1117
  */
1122
1118
  setDataObject(dataObject: object | null | undefined, options?: {
1123
- analytics?: string[];
1119
+ analytics?: AnalyticType[];
1124
1120
  lock?: {
1125
1121
  lockId: string;
1126
1122
  releaseLock?: boolean;
1127
1123
  };
1128
- uniqueKey?: string;
1129
- urlSlug?: string;
1130
1124
  }): Promise<void | ResponseType$1>;
1131
1125
  /**
1132
1126
  * @summary
@@ -1142,13 +1136,11 @@ declare class User extends SDKController implements UserInterface {
1142
1136
  * ```
1143
1137
  */
1144
1138
  updateDataObject(dataObject: object, options?: {
1145
- analytics?: string[];
1139
+ analytics?: AnalyticType[];
1146
1140
  lock?: {
1147
1141
  lockId: string;
1148
1142
  releaseLock?: boolean;
1149
1143
  };
1150
- uniqueKey?: string;
1151
- urlSlug?: string;
1152
1144
  }): Promise<void | ResponseType$1>;
1153
1145
  /**
1154
1146
  * @summary
@@ -1165,13 +1157,11 @@ declare class User extends SDKController implements UserInterface {
1165
1157
  * ```
1166
1158
  */
1167
1159
  incrementDataObjectValue(path: string, amount: number, options?: {
1168
- analytics?: string[];
1160
+ analytics?: AnalyticType[];
1169
1161
  lock?: {
1170
1162
  lockId: string;
1171
1163
  releaseLock?: boolean;
1172
1164
  };
1173
- uniqueKey?: string;
1174
- urlSlug?: string;
1175
1165
  }): Promise<void | ResponseType$1>;
1176
1166
  }
1177
1167
 
@@ -1339,12 +1329,11 @@ declare class Visitor extends User implements VisitorInterface {
1339
1329
  * ```
1340
1330
  */
1341
1331
  setDataObject(dataObject: object | null | undefined, options?: {
1342
- analytics?: string[];
1332
+ analytics?: AnalyticType[];
1343
1333
  lock?: {
1344
1334
  lockId: string;
1345
1335
  releaseLock?: boolean;
1346
1336
  };
1347
- uniqueKey?: string;
1348
1337
  }): Promise<void | ResponseType$1>;
1349
1338
  /**
1350
1339
  * @summary
@@ -1360,12 +1349,11 @@ declare class Visitor extends User implements VisitorInterface {
1360
1349
  * ```
1361
1350
  */
1362
1351
  updateDataObject(dataObject: object, options?: {
1363
- analytics?: string[];
1352
+ analytics?: AnalyticType[];
1364
1353
  lock?: {
1365
1354
  lockId: string;
1366
1355
  releaseLock?: boolean;
1367
1356
  };
1368
- uniqueKey?: string;
1369
1357
  }): Promise<void | ResponseType$1>;
1370
1358
  /**
1371
1359
  * @summary
@@ -1382,12 +1370,11 @@ declare class Visitor extends User implements VisitorInterface {
1382
1370
  * ```
1383
1371
  */
1384
1372
  incrementDataObjectValue(path: string, amount: number, options?: {
1385
- analytics?: string[];
1373
+ analytics?: AnalyticType[];
1386
1374
  lock?: {
1387
1375
  lockId: string;
1388
1376
  releaseLock?: boolean;
1389
1377
  };
1390
- uniqueKey?: string;
1391
1378
  }): Promise<void | ResponseType$1>;
1392
1379
  }
1393
1380
 
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "local-publish": "yarn build && yalc publish --push --no-scripts"
60
60
  },
61
61
  "type": "module",
62
- "version": "0.11.4"
62
+ "version": "0.11.5"
63
63
  }