@rtsdk/topia 0.11.4 → 0.11.6
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 +30 -2
- package/dist/index.cjs +8 -20
- package/dist/index.d.ts +28 -41
- package/dist/index.js +8 -20
- package/package.json +1 -1
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
|
|
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.cjs
CHANGED
|
@@ -42229,19 +42229,13 @@ class DroppedAssetFactory extends SDKController {
|
|
|
42229
42229
|
* const droppedAssetInstance = await DroppedAsset.getWithUniqueName("exampleUniqueName", urlSlug, { interactivePublicKey, interactiveSecret });
|
|
42230
42230
|
* ```
|
|
42231
42231
|
*/
|
|
42232
|
-
getWithUniqueName(uniqueName, urlSlug, credentials) {
|
|
42232
|
+
getWithUniqueName(uniqueName, urlSlug, interactiveSecret, credentials) {
|
|
42233
42233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42234
|
-
const {
|
|
42235
|
-
const params = { apiKey, interactivePublicKey, interactiveSecret, uniqueName, urlSlug };
|
|
42234
|
+
const params = { credentials, interactiveSecret, uniqueName, urlSlug };
|
|
42236
42235
|
try {
|
|
42237
42236
|
const headers = {};
|
|
42238
|
-
|
|
42239
|
-
|
|
42240
|
-
}
|
|
42241
|
-
else if (interactivePublicKey && interactiveSecret) {
|
|
42242
|
-
headers.interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
42243
|
-
headers.publickey = interactivePublicKey;
|
|
42244
|
-
}
|
|
42237
|
+
headers.interactiveJWT = jwt.sign(credentials, interactiveSecret);
|
|
42238
|
+
headers.publickey = credentials.interactivePublicKey;
|
|
42245
42239
|
const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers });
|
|
42246
42240
|
const { id } = response.data;
|
|
42247
42241
|
return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
|
|
@@ -42475,19 +42469,13 @@ class WorldFactory extends SDKController {
|
|
|
42475
42469
|
* await World.deleteDroppedAssets(urlSlug, ["exampleDroppedAssetId1", "exampleDroppedAssetId2"], { interactivePublicKey, interactiveSecret });
|
|
42476
42470
|
* ```
|
|
42477
42471
|
*/
|
|
42478
|
-
deleteDroppedAssets(urlSlug, droppedAssetIds, credentials) {
|
|
42472
|
+
deleteDroppedAssets(urlSlug, droppedAssetIds, interactiveSecret, credentials) {
|
|
42479
42473
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42480
|
-
const {
|
|
42481
|
-
const params = { apiKey, droppedAssetIds, interactivePublicKey, interactiveSecret, urlSlug };
|
|
42474
|
+
const params = { credentials, droppedAssetIds, urlSlug };
|
|
42482
42475
|
try {
|
|
42483
42476
|
const headers = {};
|
|
42484
|
-
|
|
42485
|
-
|
|
42486
|
-
}
|
|
42487
|
-
else if (interactivePublicKey && interactiveSecret) {
|
|
42488
|
-
headers.interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
42489
|
-
headers.publickey = interactivePublicKey;
|
|
42490
|
-
}
|
|
42477
|
+
headers.interactiveJWT = jwt.sign(credentials, interactiveSecret);
|
|
42478
|
+
headers.publickey = credentials.interactivePublicKey;
|
|
42491
42479
|
const promiseArray = [];
|
|
42492
42480
|
for (const id of droppedAssetIds) {
|
|
42493
42481
|
promiseArray.push(this.topiaPublicApi().delete(`/world/${urlSlug}/assets/${id}`, {
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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
|
|
|
@@ -2046,10 +2033,10 @@ declare class DroppedAssetFactory extends SDKController {
|
|
|
2046
2033
|
* const droppedAssetInstance = await DroppedAsset.getWithUniqueName("exampleUniqueName", urlSlug, { interactivePublicKey, interactiveSecret });
|
|
2047
2034
|
* ```
|
|
2048
2035
|
*/
|
|
2049
|
-
getWithUniqueName(uniqueName: string, urlSlug: string, credentials: {
|
|
2050
|
-
|
|
2051
|
-
interactivePublicKey
|
|
2052
|
-
|
|
2036
|
+
getWithUniqueName(uniqueName: string, urlSlug: string, interactiveSecret: string, credentials: {
|
|
2037
|
+
interactiveNonce: string;
|
|
2038
|
+
interactivePublicKey: string;
|
|
2039
|
+
visitorId: string;
|
|
2053
2040
|
}): Promise<DroppedAsset>;
|
|
2054
2041
|
/**
|
|
2055
2042
|
* @summary
|
|
@@ -2225,10 +2212,10 @@ declare class WorldFactory extends SDKController {
|
|
|
2225
2212
|
* await World.deleteDroppedAssets(urlSlug, ["exampleDroppedAssetId1", "exampleDroppedAssetId2"], { interactivePublicKey, interactiveSecret });
|
|
2226
2213
|
* ```
|
|
2227
2214
|
*/
|
|
2228
|
-
deleteDroppedAssets(urlSlug: string, droppedAssetIds: string[], credentials: {
|
|
2229
|
-
|
|
2230
|
-
interactivePublicKey
|
|
2231
|
-
|
|
2215
|
+
deleteDroppedAssets(urlSlug: string, droppedAssetIds: string[], interactiveSecret: string, credentials: {
|
|
2216
|
+
interactiveNonce: string;
|
|
2217
|
+
interactivePublicKey: string;
|
|
2218
|
+
visitorId: string;
|
|
2232
2219
|
}): Promise<{
|
|
2233
2220
|
success: boolean;
|
|
2234
2221
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -42227,19 +42227,13 @@ class DroppedAssetFactory extends SDKController {
|
|
|
42227
42227
|
* const droppedAssetInstance = await DroppedAsset.getWithUniqueName("exampleUniqueName", urlSlug, { interactivePublicKey, interactiveSecret });
|
|
42228
42228
|
* ```
|
|
42229
42229
|
*/
|
|
42230
|
-
getWithUniqueName(uniqueName, urlSlug, credentials) {
|
|
42230
|
+
getWithUniqueName(uniqueName, urlSlug, interactiveSecret, credentials) {
|
|
42231
42231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42232
|
-
const {
|
|
42233
|
-
const params = { apiKey, interactivePublicKey, interactiveSecret, uniqueName, urlSlug };
|
|
42232
|
+
const params = { credentials, interactiveSecret, uniqueName, urlSlug };
|
|
42234
42233
|
try {
|
|
42235
42234
|
const headers = {};
|
|
42236
|
-
|
|
42237
|
-
|
|
42238
|
-
}
|
|
42239
|
-
else if (interactivePublicKey && interactiveSecret) {
|
|
42240
|
-
headers.interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
42241
|
-
headers.publickey = interactivePublicKey;
|
|
42242
|
-
}
|
|
42235
|
+
headers.interactiveJWT = jwt.sign(credentials, interactiveSecret);
|
|
42236
|
+
headers.publickey = credentials.interactivePublicKey;
|
|
42243
42237
|
const response = yield this.topiaPublicApi().get(`/world/${urlSlug}/asset-by-unique-name/${uniqueName}`, { headers });
|
|
42244
42238
|
const { id } = response.data;
|
|
42245
42239
|
return new DroppedAsset(this.topia, id, urlSlug, { attributes: response.data });
|
|
@@ -42473,19 +42467,13 @@ class WorldFactory extends SDKController {
|
|
|
42473
42467
|
* await World.deleteDroppedAssets(urlSlug, ["exampleDroppedAssetId1", "exampleDroppedAssetId2"], { interactivePublicKey, interactiveSecret });
|
|
42474
42468
|
* ```
|
|
42475
42469
|
*/
|
|
42476
|
-
deleteDroppedAssets(urlSlug, droppedAssetIds, credentials) {
|
|
42470
|
+
deleteDroppedAssets(urlSlug, droppedAssetIds, interactiveSecret, credentials) {
|
|
42477
42471
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42478
|
-
const {
|
|
42479
|
-
const params = { apiKey, droppedAssetIds, interactivePublicKey, interactiveSecret, urlSlug };
|
|
42472
|
+
const params = { credentials, droppedAssetIds, urlSlug };
|
|
42480
42473
|
try {
|
|
42481
42474
|
const headers = {};
|
|
42482
|
-
|
|
42483
|
-
|
|
42484
|
-
}
|
|
42485
|
-
else if (interactivePublicKey && interactiveSecret) {
|
|
42486
|
-
headers.interactiveJWT = jwt.sign(interactivePublicKey, interactiveSecret);
|
|
42487
|
-
headers.publickey = interactivePublicKey;
|
|
42488
|
-
}
|
|
42475
|
+
headers.interactiveJWT = jwt.sign(credentials, interactiveSecret);
|
|
42476
|
+
headers.publickey = credentials.interactivePublicKey;
|
|
42489
42477
|
const promiseArray = [];
|
|
42490
42478
|
for (const id of droppedAssetIds) {
|
|
42491
42479
|
promiseArray.push(this.topiaPublicApi().delete(`/world/${urlSlug}/assets/${id}`, {
|
package/package.json
CHANGED