Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
948577e
feat(analytics): add video analytics pipeline with ingest server, eve…
aman-imagekit Apr 16, 2026
ee93524
feat(analytics): mandatory playback ID to remove duplicate row and t…
aman-imagekit Apr 27, 2026
b31088c
feat(analytics): enhance codec detection and video source URL handlin…
aman-imagekit Apr 27, 2026
b00bd4f
feat(video-player): add new "Try It Yourself 2" page and update Vite …
aman-imagekit Apr 30, 2026
d8ed9df
feat(video-player): implement default poster transformation handling …
aman-imagekit Apr 30, 2026
80d7d35
Merge branch 'dev' into video_analytics
aman-imagekit Apr 30, 2026
ff2b884
feat(analytics): improve seek handling in analytics state machine and…
aman-imagekit May 19, 2026
2f6b966
feat(analytics): enhance analytics tracking with custom dimensions an…
aman-imagekit May 28, 2026
2066246
feat(analytics): refactor batch processing to use v1 transport and ad…
aman-imagekit May 28, 2026
f232a67
Merge pull request #7 from imagekit-developer/video_analytis_ingestio…
aman051197 May 28, 2026
444a2a8
feat(analytics): add mapError function to remap/enrich error reportin…
aman-imagekit May 30, 2026
c904d51
Merge branch 'video_analytis_ingestion_fix' into video_analytics
aman-imagekit May 30, 2026
9c9d6ef
Merge branch 'main' into video_analytics
aman-imagekit Jun 2, 2026
06da939
feat(analytics): implement imperative mapError for astro support
aman-imagekit Jun 2, 2026
803a7a1
feat(analytics): implement session rotation and predecessor links for…
aman-imagekit Jun 2, 2026
99f95ff
fix(analytics): build for astro
aman-imagekit Jun 3, 2026
8337565
feat(analytics): add reportError method for non-fatal error reporting…
aman-imagekit Jun 3, 2026
847467b
feat(analytics): add support for application-reported errors in analy…
aman-imagekit Jun 3, 2026
fa7486f
feat(analytics): enhance analytics options with user ID, custom dimen…
aman-imagekit Jun 3, 2026
79ca423
fix(analytics): standardize user ID property to camelCase across exam…
aman-imagekit Jun 4, 2026
4bf4ff1
fix(analytics): improve batch queue flush logic and cleanup handling
aman-imagekit Jun 4, 2026
2cfd05c
feat(analytics): add page_hide signal and enhance session rotation ha…
aman-imagekit Jun 11, 2026
a7ca947
feat(analytics): enhance video scale percentage calculation with obje…
aman-imagekit Jun 17, 2026
6a30016
fix(analytics): remove conflicting error check for translations in va…
aman-imagekit Jun 29, 2026
ff03338
feat(analytics): update version to 1.0.0-beta.5, pick version automat…
aman-imagekit Jul 1, 2026
db3d62e
refactor(analytics): feedbacks addressed
aman-imagekit Jul 1, 2026
4548b47
refactor(playlist): revert changes, will be done separately.
aman-imagekit Jul 1, 2026
5f55a8b
fix(analytics): update analytics ingest URL to production endpoint
aman-imagekit Jul 1, 2026
c8b4caa
Potential fix for pull request finding
aman051197 Jul 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions examples/astro/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,36 @@ const playlist: { sources: SourceOptions[]; options?: PlaylistOptions } = {
signerOptions={{ mode: 'imperative' }}
/>
</section>

<!-- ====================================================================
5. Analytics with imperative mapError
Functions can't be serialized into Astro props, so mapError is
assigned imperatively via el.mapError from a sibling <script>.
===================================================================== -->
<section>
<h2>5. Analytics with imperative <code>mapError</code></h2>
<p>
Uses a <strong>deliberately broken URL</strong> to trigger error code
<code>2</code> (MEDIA_ERR_NETWORK). The <code>mapError</code> callback
enriches the reported context with extra metadata and logs the input/output
</p>
<IKVideoPlayer
id="player-analytics"
ikOptions={{
...ikOptions,
analytics: {
enabled: true,
userId: 'demo-user-001',
customDimensions: { cd_1: '1.0.0', cd_2: 'astro-example' },
},
}}
videoJsOptions={videoJsOptions}
source={{ src: 'https://ik.imagekit.io/demo/this-does-not-exist-404.mp4' }}
/>
<div id="map-error-log" style="margin-top:8px;padding:10px 12px;background:#f6f8fa;border:1px solid #e0e0e0;border-radius:4px;font-family:monospace;font-size:13px;min-height:32px;">
Waiting for error…
</div>
</section>
</main>
</Layout>

Expand Down Expand Up @@ -208,6 +238,39 @@ const playlist: { sources: SourceOptions[]; options?: PlaylistOptions } = {
if (el) {
el.signerFn = makeSigner();
}

// Imperative mapError wiring for section 5.
// Enriches the reported context with a bit of extra metadata.
type MapErrorFn = (error: { code: string; message?: string; context?: string }) =>
{ code?: string; message?: string; context?: string } | null | undefined;
type IKAnalyticsEl = HTMLElement & { mapError?: MapErrorFn };

const analyticsEl = document.querySelector<IKAnalyticsEl>('#player-analytics');
const logEl = document.querySelector<HTMLDivElement>('#map-error-log');

function showLog(before: object, after: object | null | undefined) {
if (!logEl) return;
logEl.innerHTML =
`<strong>mapError called</strong><br>` +
`IN:&nbsp; <span style="color:#c7254e">${JSON.stringify(before)}</span><br>` +
`OUT: <span style="color:#2a7a2a">${JSON.stringify(after)}</span>`;
}

if (analyticsEl) {
analyticsEl.mapError = (err) => {
// Keep the original error, just attach some extra context metadata.
const result = {
context: JSON.stringify({
original: err.context,
page: 'astro-example',
url: location.href,
}),
};
console.log('[mapError] IN:', err, '→ OUT:', result);
showLog(err, result);
return result;
};
}
</script>

<style>
Expand Down
Loading
Loading