@playcraft/adsdk 1.0.7 → 1.0.8

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.
@@ -160,53 +160,174 @@
160
160
  }
161
161
 
162
162
  // src/tracking.ts
163
+ function trackURL(url) {
164
+ if (url) {
165
+ const trackingPixel = new Image();
166
+ trackingPixel.src = url;
167
+ }
168
+ }
169
+ function trackBigabidEvent(event) {
170
+ console.log(" trackBigabidEvent", event);
171
+ if (window.BIGABID_BIDTIMEMACROS && window.BIGABID_BIDTIMEMACROS[event]) {
172
+ trackURL(window.BIGABID_BIDTIMEMACROS[event]);
173
+ }
174
+ }
175
+ function trackInMobiEvent(event) {
176
+ console.log(" trackInMobiEvent", event);
177
+ if (window.INMOBI_DSPMACROS && window.INMOBI_DSPMACROS[event]) {
178
+ trackURL(window.INMOBI_DSPMACROS[event]);
179
+ }
180
+ }
181
+ function trackApplovinEvent(event) {
182
+ console.log(" trackApplovinEvent", event);
183
+ if (typeof window.ALPlayableAnalytics !== "undefined") {
184
+ window.ALPlayableAnalytics.trackEvent(event);
185
+ }
186
+ }
187
+ var totalInteractions = 0;
188
+ var progressMilestones = [];
189
+ function setTotalInteractions(total) {
190
+ totalInteractions = total;
191
+ }
192
+ function trackChallengeSuccess() {
193
+ if (AD_NETWORK === "applovin") {
194
+ trackApplovinEvent("CHALLENGE_SOLVED");
195
+ }
196
+ if (AD_NETWORK === "bigabid") {
197
+ trackBigabidComplete();
198
+ }
199
+ if (AD_NETWORK === "inmobi") {
200
+ trackInMobiEvent("Gameplay_Complete");
201
+ }
202
+ }
203
+ function trackChallengeFailed() {
204
+ if (AD_NETWORK === "applovin") {
205
+ trackApplovinEvent("CHALLENGE_FAILED");
206
+ }
207
+ }
208
+ function initProgressMilestones() {
209
+ if (totalInteractions <= 0) return;
210
+ if (AD_NETWORK === "applovin") {
211
+ progressMilestones = [
212
+ { percent: 25, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_25") },
213
+ { percent: 50, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_50") },
214
+ { percent: 75, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_75") },
215
+ { percent: 100, triggered: false, callback: () => trackChallengeSuccess() }
216
+ ];
217
+ } else if (AD_NETWORK === "bigabid") {
218
+ progressMilestones = [
219
+ { percent: 100, triggered: false, callback: () => trackChallengeSuccess() }
220
+ ];
221
+ }
222
+ }
223
+ function checkInteractionProgress(currentInteractions) {
224
+ if (totalInteractions <= 0 || progressMilestones.length === 0) return;
225
+ const currentPercent = currentInteractions / totalInteractions * 100;
226
+ for (const milestone of progressMilestones) {
227
+ if (!milestone.triggered && currentPercent >= milestone.percent) {
228
+ milestone.triggered = true;
229
+ milestone.callback();
230
+ }
231
+ }
232
+ }
233
+ var bigabidCompleteTriggered = false;
234
+ function trackBigabidComplete() {
235
+ if (!bigabidCompleteTriggered) {
236
+ trackBigabidEvent("complete");
237
+ bigabidCompleteTriggered = true;
238
+ }
239
+ }
240
+ var inmobiTimers = [];
241
+ function startInMobiDurationTracking() {
242
+ const durations = [5, 10, 15, 20, 25, 30];
243
+ for (const sec of durations) {
244
+ const timer = setTimeout(() => trackInMobiEvent(`Spent_${sec}_Seconds`), sec * 1e3);
245
+ inmobiTimers.push(timer);
246
+ }
247
+ }
248
+ function clearInMobiDurationTracking() {
249
+ for (const timer of inmobiTimers) {
250
+ clearTimeout(timer);
251
+ }
252
+ inmobiTimers = [];
253
+ }
163
254
  function initTrackingProtocols() {
164
- if (AD_NETWORK === "bigabid" || AD_NETWORK === "inmobi") {
165
- let trackURL2 = function(url) {
166
- if (url) {
167
- const trackingPixel = new Image();
168
- trackingPixel.src = url;
169
- }
170
- };
171
- var trackURL = trackURL2;
255
+ const supportedNetworks = ["bigabid", "inmobi", "applovin"];
256
+ if (!supportedNetworks.includes(AD_NETWORK)) {
257
+ return;
258
+ }
259
+ initProgressMilestones();
260
+ sdk.once("init", () => {
172
261
  if (AD_NETWORK === "bigabid") {
173
- let trackBigabidEvent2 = function(event) {
174
- if (window.BIGABID_BIDTIMEMACROS && window.BIGABID_BIDTIMEMACROS[event])
175
- trackURL2(window.BIGABID_BIDTIMEMACROS[event]);
176
- }, trackComplete2 = function() {
177
- if (!completeTriggered) trackBigabidEvent2("complete");
178
- completeTriggered = true;
179
- };
180
- var trackBigabidEvent = trackBigabidEvent2, trackComplete = trackComplete2;
181
- var completeTriggered = false;
182
- sdk.once("boot", () => trackBigabidEvent2("mraid_viewable"));
183
- sdk.once("start", () => trackBigabidEvent2("game_viewable"));
184
- sdk.once("interaction", () => trackBigabidEvent2("engagement"));
185
- sdk.once("finish", trackComplete2);
186
- sdk.on("interaction", (interactions) => {
187
- if (interactions > 3) trackComplete2();
188
- });
189
- sdk.once("install", () => trackBigabidEvent2("click"));
190
- } else if (AD_NETWORK === "inmobi") {
191
- let trackInMobiEvent2 = function(event) {
192
- if (window.INMOBI_DSPMACROS && window.INMOBI_DSPMACROS[event]) trackURL2(window.INMOBI_DSPMACROS[event]);
193
- };
194
- var trackInMobiEvent = trackInMobiEvent2;
195
- sdk.once("boot", () => trackInMobiEvent2("Ad_Load_Start"));
196
- sdk.once("start", () => trackInMobiEvent2("Ad_Viewable"));
197
- sdk.once("interaction", () => trackInMobiEvent2("First_Engagement"));
198
- sdk.once("finish", () => trackInMobiEvent2("Gameplay_Complete"));
199
- sdk.once("install", () => trackInMobiEvent2("DSP_Click"));
200
- sdk.once("start", () => {
201
- setTimeout(() => trackInMobiEvent2("Spent_5_Seconds"), 5e3);
202
- setTimeout(() => trackInMobiEvent2("Spent_10_Seconds"), 1e4);
203
- setTimeout(() => trackInMobiEvent2("Spent_15_Seconds"), 15e3);
204
- setTimeout(() => trackInMobiEvent2("Spent_20_Seconds"), 2e4);
205
- setTimeout(() => trackInMobiEvent2("Spent_25_Seconds"), 25e3);
206
- setTimeout(() => trackInMobiEvent2("Spent_30_Seconds"), 3e4);
207
- });
262
+ trackBigabidEvent("mraid_viewable");
208
263
  }
209
- }
264
+ if (AD_NETWORK === "inmobi") {
265
+ trackInMobiEvent("Ad_Load_Start");
266
+ }
267
+ if (AD_NETWORK === "applovin") {
268
+ trackApplovinEvent("LOADING");
269
+ }
270
+ });
271
+ sdk.once("start", () => {
272
+ if (AD_NETWORK === "bigabid") {
273
+ trackBigabidEvent("game_viewable");
274
+ }
275
+ if (AD_NETWORK === "inmobi") {
276
+ trackInMobiEvent("Ad_Viewable");
277
+ startInMobiDurationTracking();
278
+ }
279
+ if (AD_NETWORK === "applovin") {
280
+ trackApplovinEvent("LOADED");
281
+ }
282
+ });
283
+ sdk.once("interactive", () => {
284
+ if (AD_NETWORK === "applovin") {
285
+ trackApplovinEvent("DISPLAYED");
286
+ }
287
+ });
288
+ sdk.once("interaction", () => {
289
+ if (AD_NETWORK === "bigabid") {
290
+ trackBigabidEvent("engagement");
291
+ }
292
+ if (AD_NETWORK === "inmobi") {
293
+ trackInMobiEvent("First_Engagement");
294
+ }
295
+ if (AD_NETWORK === "applovin") {
296
+ trackApplovinEvent("CHALLENGE_STARTED");
297
+ }
298
+ });
299
+ sdk.on("success", (successCount) => {
300
+ checkInteractionProgress(successCount);
301
+ });
302
+ sdk.once("finish", () => {
303
+ if (AD_NETWORK === "bigabid") {
304
+ trackBigabidComplete();
305
+ }
306
+ if (AD_NETWORK === "inmobi") {
307
+ trackInMobiEvent("Gameplay_Complete");
308
+ clearInMobiDurationTracking();
309
+ }
310
+ if (AD_NETWORK === "applovin") {
311
+ trackApplovinEvent("ENDCARD_SHOWN");
312
+ }
313
+ });
314
+ sdk.on("install", () => {
315
+ if (AD_NETWORK === "bigabid") {
316
+ trackBigabidEvent("click");
317
+ }
318
+ if (AD_NETWORK === "inmobi") {
319
+ trackInMobiEvent("DSP_Click");
320
+ clearInMobiDurationTracking();
321
+ }
322
+ if (AD_NETWORK === "applovin") {
323
+ trackApplovinEvent("CTA_CLICKED");
324
+ }
325
+ });
326
+ sdk.once("retry", () => {
327
+ if (AD_NETWORK === "applovin") {
328
+ trackApplovinEvent("CHALLENGE_RETRY");
329
+ }
330
+ });
210
331
  }
211
332
 
212
333
  // src/assets/images.ts
@@ -485,7 +606,7 @@
485
606
  };
486
607
  function bootAd() {
487
608
  if (sdk.isReady) return;
488
- emitEvent("boot");
609
+ emitEvent("init");
489
610
  document.body.oncontextmenu = function() {
490
611
  return false;
491
612
  };
@@ -802,7 +923,6 @@
802
923
  } else {
803
924
  startDefaultProtocol();
804
925
  }
805
- emitEvent("init");
806
926
  }
807
927
  var _sdk = class _sdk {
808
928
  /**
@@ -810,6 +930,12 @@
810
930
  * This must be called as earlier as possible.
811
931
  *
812
932
  * @param callback Optional function called when ad container is ready
933
+ * @param options Optional configuration options
934
+ * @param options.totalSuccessCount Total number of successful actions expected for progress tracking.
935
+ * When set, the SDK will track success progress as a percentage and trigger
936
+ * channel-specific milestone events (e.g., AppLovin: CHALLENGE_PASS_25/50/75, CHALLENGE_SOLVED).
937
+ * Different channels monitor different percentage thresholds independently.
938
+ * Set to 0 or omit to disable progress tracking.
813
939
  * @example
814
940
  * // Basic initialization
815
941
  * sdk.init();
@@ -819,13 +945,20 @@
819
945
  * new App(width, height)
820
946
  * });
821
947
  *
822
- * @fires init When initialization starts
823
- * @fires boot When the ad begins booting
824
- * @fires ready When Ad Network is ready and playable ad can be initialized
948
+ * // Initialization with success count progress tracking
949
+ * sdk.init((width, height) => {
950
+ * new App(width, height)
951
+ * }, { totalSuccessCount: 20 });
952
+ *
953
+ * @fires loading When SDK initialization starts
954
+ * @fires loaded When game instance is created and ready to load resources
825
955
  */
826
- static init(callback) {
956
+ static init(callback, options) {
827
957
  if (isSDKInitialized) return;
828
958
  if (callback) initCallback = callback;
959
+ if ((options == null ? void 0 : options.totalSuccessCount) && options.totalSuccessCount > 0) {
960
+ setTotalInteractions(options.totalSuccessCount);
961
+ }
829
962
  initTrackingProtocols();
830
963
  document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", initSDK) : initSDK();
831
964
  isSDKInitialized = true;
@@ -865,6 +998,22 @@
865
998
  _sdk.resize();
866
999
  }
867
1000
  }
1001
+ /**
1002
+ * Marks the main scene as fully loaded and ready for user interaction.
1003
+ * Should be called at the end of your main game scene's create() method.
1004
+ *
1005
+ * @example
1006
+ * // In Phaser MainScene.create()
1007
+ * create() {
1008
+ * // ... all initialization code ...
1009
+ * sdk.interactive();
1010
+ * }
1011
+ *
1012
+ * @fires interactive When the main scene is ready for user interaction
1013
+ */
1014
+ static interactive() {
1015
+ emitEvent("interactive");
1016
+ }
868
1017
  /**
869
1018
  * Marks the playable ad as finished.
870
1019
  * This triggers network-specific completion handlers.
@@ -1039,6 +1188,60 @@
1039
1188
  static resize() {
1040
1189
  handleResize(_sdk.maxWidth, _sdk.maxHeight);
1041
1190
  }
1191
+ /**
1192
+ * Records successful game actions (e.g., successful match, level clear).
1193
+ * This should be called by game logic when a meaningful success occurs.
1194
+ * This count is used for progress tracking (e.g., AppLovin milestone events).
1195
+ *
1196
+ * @param count Optional success count to add (default: 1)
1197
+ *
1198
+ * @example
1199
+ * // Record single success when match completes
1200
+ * onMatchSuccess() {
1201
+ * sdk.recordSuccessCount();
1202
+ * }
1203
+ *
1204
+ * // Record multiple successes at once
1205
+ * onComboMatch(comboCount) {
1206
+ * sdk.recordSuccessCount(comboCount);
1207
+ * }
1208
+ *
1209
+ * @fires success With updated success count (triggers progress tracking)
1210
+ */
1211
+ static recordSuccessCount(count = 1) {
1212
+ _sdk.successCount += count;
1213
+ emitEvent("success", _sdk.successCount);
1214
+ }
1215
+ /**
1216
+ * Records a game success/completion event.
1217
+ * Sends platform-specific success tracking events:
1218
+ * - AppLovin: CHALLENGE_SOLVED
1219
+ * - Bigabid: complete
1220
+ * - InMobi: Gameplay_Complete
1221
+ *
1222
+ * @example
1223
+ * // When player completes the level
1224
+ * onLevelComplete() {
1225
+ * sdk.recordSuccess();
1226
+ * }
1227
+ */
1228
+ static recordSuccess() {
1229
+ trackChallengeSuccess();
1230
+ }
1231
+ /**
1232
+ * Records a game failure event.
1233
+ * Sends platform-specific failure tracking events:
1234
+ * - AppLovin: CHALLENGE_FAILED
1235
+ *
1236
+ * @example
1237
+ * // When player fails the level
1238
+ * onLevelFailed() {
1239
+ * sdk.recordFailed();
1240
+ * }
1241
+ */
1242
+ static recordFailed() {
1243
+ trackChallengeFailed();
1244
+ }
1042
1245
  /**
1043
1246
  * Forces the playable ad into a paused state.
1044
1247
  *
@@ -1132,9 +1335,15 @@
1132
1335
  static getCurChannel() {
1133
1336
  return AD_NETWORK;
1134
1337
  }
1338
+ /**
1339
+ * 判断是否是 Google
1340
+ */
1341
+ static isGoogle() {
1342
+ return _sdk.getCurChannel() === "google";
1343
+ }
1135
1344
  };
1136
1345
  /** Current version of the SDK */
1137
- _sdk.version = "1.0.24";
1346
+ _sdk.version = "1.0.26";
1138
1347
  /** Current maximum width of the playable ad container in pixels */
1139
1348
  _sdk.maxWidth = Math.floor(window.innerWidth);
1140
1349
  /** Current maximum height of the playable ad container in pixels */
@@ -1151,8 +1360,12 @@
1151
1360
  _sdk.isFinished = false;
1152
1361
  /** Current volume level (0-1) */
1153
1362
  _sdk.volume = actualVolume;
1154
- /** Number of user interactions with the playable ad */
1363
+ /** Number of user interactions with the playable ad (auto-incremented on each touch/click) */
1155
1364
  _sdk.interactions = 0;
1365
+ /** Number of successful game actions (e.g., successful matches, level clears).
1366
+ * Controlled by calling sdk.recordSuccessCount(), NOT auto-incremented.
1367
+ */
1368
+ _sdk.successCount = 0;
1156
1369
  var sdk = _sdk;
1157
1370
  window["console"].log(
1158
1371
  `%c @tencent/playable-sdk %c v${sdk.version} `,
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- type EventName = 'init' | 'boot' | 'ready' | 'start' | 'interaction' | 'resize' | 'pause' | 'resume' | 'volume' | 'retry' | 'finish' | 'install';
1
+ type EventName = 'init' | 'ready' | 'start' | 'interactive' | 'interaction' | 'success' | 'resize' | 'pause' | 'resume' | 'volume' | 'retry' | 'finish' | 'install';
2
2
 
3
3
  type InitCallbackType = (maxWidth: number, maxHeight: number) => void;
4
4
  /**
@@ -24,13 +24,23 @@ declare class sdk {
24
24
  static isFinished: boolean;
25
25
  /** Current volume level (0-1) */
26
26
  static volume: number;
27
- /** Number of user interactions with the playable ad */
27
+ /** Number of user interactions with the playable ad (auto-incremented on each touch/click) */
28
28
  static interactions: number;
29
+ /** Number of successful game actions (e.g., successful matches, level clears).
30
+ * Controlled by calling sdk.recordSuccessCount(), NOT auto-incremented.
31
+ */
32
+ static successCount: number;
29
33
  /**
30
34
  * Initializes the SDK and sets up protocol-specific handlers.
31
35
  * This must be called as earlier as possible.
32
36
  *
33
37
  * @param callback Optional function called when ad container is ready
38
+ * @param options Optional configuration options
39
+ * @param options.totalSuccessCount Total number of successful actions expected for progress tracking.
40
+ * When set, the SDK will track success progress as a percentage and trigger
41
+ * channel-specific milestone events (e.g., AppLovin: CHALLENGE_PASS_25/50/75, CHALLENGE_SOLVED).
42
+ * Different channels monitor different percentage thresholds independently.
43
+ * Set to 0 or omit to disable progress tracking.
34
44
  * @example
35
45
  * // Basic initialization
36
46
  * sdk.init();
@@ -40,11 +50,17 @@ declare class sdk {
40
50
  * new App(width, height)
41
51
  * });
42
52
  *
43
- * @fires init When initialization starts
44
- * @fires boot When the ad begins booting
45
- * @fires ready When Ad Network is ready and playable ad can be initialized
53
+ * // Initialization with success count progress tracking
54
+ * sdk.init((width, height) => {
55
+ * new App(width, height)
56
+ * }, { totalSuccessCount: 20 });
57
+ *
58
+ * @fires loading When SDK initialization starts
59
+ * @fires loaded When game instance is created and ready to load resources
46
60
  */
47
- static init(callback?: InitCallbackType): void;
61
+ static init(callback?: InitCallbackType, options?: {
62
+ totalSuccessCount?: number;
63
+ }): void;
48
64
  /**
49
65
  * Starts the playable ad experience.
50
66
  * Should be called after all resources are loaded and first frame is rendered.
@@ -57,6 +73,20 @@ declare class sdk {
57
73
  * @fires resize When the ad container is initially sized
58
74
  */
59
75
  static start(): void;
76
+ /**
77
+ * Marks the main scene as fully loaded and ready for user interaction.
78
+ * Should be called at the end of your main game scene's create() method.
79
+ *
80
+ * @example
81
+ * // In Phaser MainScene.create()
82
+ * create() {
83
+ * // ... all initialization code ...
84
+ * sdk.interactive();
85
+ * }
86
+ *
87
+ * @fires interactive When the main scene is ready for user interaction
88
+ */
89
+ static interactive(): void;
60
90
  /**
61
91
  * Marks the playable ad as finished.
62
92
  * This triggers network-specific completion handlers.
@@ -104,6 +134,53 @@ declare class sdk {
104
134
  * @fires resize With current maxWidth and maxHeight
105
135
  */
106
136
  static resize(): void;
137
+ /**
138
+ * Records successful game actions (e.g., successful match, level clear).
139
+ * This should be called by game logic when a meaningful success occurs.
140
+ * This count is used for progress tracking (e.g., AppLovin milestone events).
141
+ *
142
+ * @param count Optional success count to add (default: 1)
143
+ *
144
+ * @example
145
+ * // Record single success when match completes
146
+ * onMatchSuccess() {
147
+ * sdk.recordSuccessCount();
148
+ * }
149
+ *
150
+ * // Record multiple successes at once
151
+ * onComboMatch(comboCount) {
152
+ * sdk.recordSuccessCount(comboCount);
153
+ * }
154
+ *
155
+ * @fires success With updated success count (triggers progress tracking)
156
+ */
157
+ static recordSuccessCount(count?: number): void;
158
+ /**
159
+ * Records a game success/completion event.
160
+ * Sends platform-specific success tracking events:
161
+ * - AppLovin: CHALLENGE_SOLVED
162
+ * - Bigabid: complete
163
+ * - InMobi: Gameplay_Complete
164
+ *
165
+ * @example
166
+ * // When player completes the level
167
+ * onLevelComplete() {
168
+ * sdk.recordSuccess();
169
+ * }
170
+ */
171
+ static recordSuccess(): void;
172
+ /**
173
+ * Records a game failure event.
174
+ * Sends platform-specific failure tracking events:
175
+ * - AppLovin: CHALLENGE_FAILED
176
+ *
177
+ * @example
178
+ * // When player fails the level
179
+ * onLevelFailed() {
180
+ * sdk.recordFailed();
181
+ * }
182
+ */
183
+ static recordFailed(): void;
107
184
  /**
108
185
  * Forces the playable ad into a paused state.
109
186
  *
@@ -179,6 +256,10 @@ declare class sdk {
179
256
  * @returns 当前渠道
180
257
  */
181
258
  static getCurChannel(): "applovin" | "ironsource" | "unity" | "mintegral" | "preview" | "google" | "facebook" | "moloco" | "vungle" | "adcolony" | "tapjoy" | "snapchat" | "tiktok" | "appreciate" | "chartboost" | "pangle" | "mytarget" | "liftoff" | "smadex" | "adikteev" | "bigabid" | "inmobi" | "bigoads";
259
+ /**
260
+ * 判断是否是 Google
261
+ */
262
+ static isGoogle(): boolean;
182
263
  }
183
264
 
184
265
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type EventName = 'init' | 'boot' | 'ready' | 'start' | 'interaction' | 'resize' | 'pause' | 'resume' | 'volume' | 'retry' | 'finish' | 'install';
1
+ type EventName = 'init' | 'ready' | 'start' | 'interactive' | 'interaction' | 'success' | 'resize' | 'pause' | 'resume' | 'volume' | 'retry' | 'finish' | 'install';
2
2
 
3
3
  type InitCallbackType = (maxWidth: number, maxHeight: number) => void;
4
4
  /**
@@ -24,13 +24,23 @@ declare class sdk {
24
24
  static isFinished: boolean;
25
25
  /** Current volume level (0-1) */
26
26
  static volume: number;
27
- /** Number of user interactions with the playable ad */
27
+ /** Number of user interactions with the playable ad (auto-incremented on each touch/click) */
28
28
  static interactions: number;
29
+ /** Number of successful game actions (e.g., successful matches, level clears).
30
+ * Controlled by calling sdk.recordSuccessCount(), NOT auto-incremented.
31
+ */
32
+ static successCount: number;
29
33
  /**
30
34
  * Initializes the SDK and sets up protocol-specific handlers.
31
35
  * This must be called as earlier as possible.
32
36
  *
33
37
  * @param callback Optional function called when ad container is ready
38
+ * @param options Optional configuration options
39
+ * @param options.totalSuccessCount Total number of successful actions expected for progress tracking.
40
+ * When set, the SDK will track success progress as a percentage and trigger
41
+ * channel-specific milestone events (e.g., AppLovin: CHALLENGE_PASS_25/50/75, CHALLENGE_SOLVED).
42
+ * Different channels monitor different percentage thresholds independently.
43
+ * Set to 0 or omit to disable progress tracking.
34
44
  * @example
35
45
  * // Basic initialization
36
46
  * sdk.init();
@@ -40,11 +50,17 @@ declare class sdk {
40
50
  * new App(width, height)
41
51
  * });
42
52
  *
43
- * @fires init When initialization starts
44
- * @fires boot When the ad begins booting
45
- * @fires ready When Ad Network is ready and playable ad can be initialized
53
+ * // Initialization with success count progress tracking
54
+ * sdk.init((width, height) => {
55
+ * new App(width, height)
56
+ * }, { totalSuccessCount: 20 });
57
+ *
58
+ * @fires loading When SDK initialization starts
59
+ * @fires loaded When game instance is created and ready to load resources
46
60
  */
47
- static init(callback?: InitCallbackType): void;
61
+ static init(callback?: InitCallbackType, options?: {
62
+ totalSuccessCount?: number;
63
+ }): void;
48
64
  /**
49
65
  * Starts the playable ad experience.
50
66
  * Should be called after all resources are loaded and first frame is rendered.
@@ -57,6 +73,20 @@ declare class sdk {
57
73
  * @fires resize When the ad container is initially sized
58
74
  */
59
75
  static start(): void;
76
+ /**
77
+ * Marks the main scene as fully loaded and ready for user interaction.
78
+ * Should be called at the end of your main game scene's create() method.
79
+ *
80
+ * @example
81
+ * // In Phaser MainScene.create()
82
+ * create() {
83
+ * // ... all initialization code ...
84
+ * sdk.interactive();
85
+ * }
86
+ *
87
+ * @fires interactive When the main scene is ready for user interaction
88
+ */
89
+ static interactive(): void;
60
90
  /**
61
91
  * Marks the playable ad as finished.
62
92
  * This triggers network-specific completion handlers.
@@ -104,6 +134,53 @@ declare class sdk {
104
134
  * @fires resize With current maxWidth and maxHeight
105
135
  */
106
136
  static resize(): void;
137
+ /**
138
+ * Records successful game actions (e.g., successful match, level clear).
139
+ * This should be called by game logic when a meaningful success occurs.
140
+ * This count is used for progress tracking (e.g., AppLovin milestone events).
141
+ *
142
+ * @param count Optional success count to add (default: 1)
143
+ *
144
+ * @example
145
+ * // Record single success when match completes
146
+ * onMatchSuccess() {
147
+ * sdk.recordSuccessCount();
148
+ * }
149
+ *
150
+ * // Record multiple successes at once
151
+ * onComboMatch(comboCount) {
152
+ * sdk.recordSuccessCount(comboCount);
153
+ * }
154
+ *
155
+ * @fires success With updated success count (triggers progress tracking)
156
+ */
157
+ static recordSuccessCount(count?: number): void;
158
+ /**
159
+ * Records a game success/completion event.
160
+ * Sends platform-specific success tracking events:
161
+ * - AppLovin: CHALLENGE_SOLVED
162
+ * - Bigabid: complete
163
+ * - InMobi: Gameplay_Complete
164
+ *
165
+ * @example
166
+ * // When player completes the level
167
+ * onLevelComplete() {
168
+ * sdk.recordSuccess();
169
+ * }
170
+ */
171
+ static recordSuccess(): void;
172
+ /**
173
+ * Records a game failure event.
174
+ * Sends platform-specific failure tracking events:
175
+ * - AppLovin: CHALLENGE_FAILED
176
+ *
177
+ * @example
178
+ * // When player fails the level
179
+ * onLevelFailed() {
180
+ * sdk.recordFailed();
181
+ * }
182
+ */
183
+ static recordFailed(): void;
107
184
  /**
108
185
  * Forces the playable ad into a paused state.
109
186
  *
@@ -179,6 +256,10 @@ declare class sdk {
179
256
  * @returns 当前渠道
180
257
  */
181
258
  static getCurChannel(): "applovin" | "ironsource" | "unity" | "mintegral" | "preview" | "google" | "facebook" | "moloco" | "vungle" | "adcolony" | "tapjoy" | "snapchat" | "tiktok" | "appreciate" | "chartboost" | "pangle" | "mytarget" | "liftoff" | "smadex" | "adikteev" | "bigabid" | "inmobi" | "bigoads";
259
+ /**
260
+ * 判断是否是 Google
261
+ */
262
+ static isGoogle(): boolean;
182
263
  }
183
264
 
184
265
  /**